- Notifications
You must be signed in to change notification settings - Fork 0
Chapter 7
Jarlin Almanzar edited this page Nov 21, 2019
·
3 revisions
The function pauses your program and waits for the user to enter some text. Once it retrieves the input, it assigns it to a variable.
Python interprets Input values as a string
height=input("How tall are you, in inches: ")
height=int(height)
ifheight>48:
print("You are tall enough")
else:
print("\n You'll be able to ride when you're a little older.")A loop that runs as long as the condition is true.
curr_num=1whilecurr_num<=5:
print(curr_num)
curr_num+=1prompt="Tell me something, and I will repeat it back to you."prompt+="\n Enter 'quit' to end the program."msg=""whilemsg!='quit':
msg=input(prompt)
print(msg)active=Truewhileactive:
msg=input(prompt)
ifmsg=='quit':
active=Falseelse:
print(msg)whileTrue:
msg=input(prompt)
ifmsg=='quit':
breakelse:
print(msg)