Apr-25-2018, 09:46 AM
I have a simple user input program:
#!/usr/bin/python
#QuickTest.py
def getLocation(x,y,z):
x = input("Specify horizontal position: ")#latitude
y = input("Specify vertical position: ")#longitude
z = input("Specify altitude: ")#above sea level
return x,y,z
def QuickTestMain():
## x = 0
## y = 0
## z = 0
getLocation(x,y,z)
print("You are located at " + str(x) + "degrees latitude, " +
str(y) + " degrees longitude, " + " and " + str(z) +
" feet above sea level.")
QuickTestMain()When lines 11 - 13 are not commented out, it just prints all 0's (I just wanted to initialize them, so that they exist in the program):Error:========== RESTART: I:/Python/Python36-32/SamsPrograms/QuickTest.py ==========
Specify horizontal position: 3
Specify vertical position: 4
Specify altitude: 5
You are located at 0degrees latitude, 0 degrees longitude, and 0 feet above sea level.
>>>And then if I comment them out, I get:Error:========== RESTART: I:/Python/Python36-32/SamsPrograms/QuickTest.py ==========
Traceback (most recent call last):
File "I:/Python/Python36-32/SamsPrograms/QuickTest.py", line 19, in <module>
QuickTestMain()
File "I:/Python/Python36-32/SamsPrograms/QuickTest.py", line 14, in QuickTestMain
getLocation(x,y,z)
NameError: name 'x' is not defined
>>>How do I fix this?
