troubleshooting Question

using Python Modules

Avatar of jskfan
jskfanFlag for Cyprus asked on
Programming Languages-OtherPython
6 Comments1 Solution146 ViewsLast Modified:
using Python Modules

I have this Python Code:

def test1(weight):
    return weight * 0.45

def test2(weight):
    return weight/ 0.45

I want to call the methods above from this program and pass the wight argument for instance 200
from mod1 import test1,test2

however, it seems like if I do not specify the weight  in   the calling code will fail.

C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe C:/Python-Projects/Mydjangoproject/
Traceback (most recent call last):
  File "C:/Python-Projects/Mydjangoproject/", line 1, in <module>
    from mod1 import test1,test2
  File "C:\Python-Projects\Mydjangoproject\", line 3, in <module>
TypeError: test1() missing 1 required positional argument: 'weight'

Process finished with exit code 1[code]

NorieSenior Associate
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros