How do I ask the user to input how far away someone is?
e.g.
"How far away is the closest person: "
and then get it to tell me if it is under 600m
e.g.
"Canon start Rocket Lift Off because the closest person is less than 600m away
How do I ask the user to input how far away someone is?
e.g.
"How far away is the closest person: "
and then get it to tell me if it is under 600m
e.g.
"Canon start Rocket Lift Off because the closest person is less than 600m away
Use Python's input()
method.
>>> a = input("Input the distance: ")
Input the distance: 800
>>> print(a)
800
For the 600m requirement, read up on if
statements.
>>> a = "test"
>>> if a == "test":
... print("true")
...
true
To ask the user a question, do:
x = raw_input("How far away is the closest person: ")
for python 2.7 or
x = input("How far away is the closest person: ")
for python 3
and then as you will probably have worked out by now:
if x < 600:
# do something
Just use print()
to display information, input()
to receive the input info, and if
statement to determine whether the distance is enough. float(input())
means converting what you input to a float type object.
print "How far away is the closest person: "
if float(input()) <= 600:
print "Canon start Rocket Lift Off because the closest person is less than 600m away"