Question: Exercise 2 . 3 ( 2 0 marks ) Using a single print statement and the variables created earlier, print your Name in the next

Exercise 2.3(20 marks)
Using a single print statement and the variables created earlier, print your Name in the next line your Age, and after three lines your Height.
name = input("Please enter your name: ").upper()
age = int(input("Please enter your age: "))
height = float(input("Please enter your height in inches: "))
Please enter your name: aleck
Please enter your age: 22
Please enter your height in inches: 66
print("Name:", name,"
Age:", age,"
height:",height )
statements =['Thank you for your order','Would you like fries with that too? (Y or N)',
'Excellent, I\'ll add them to your order, Have a nice day!',
'Are you sure? They are really yummy (Y or N)',
'Ok, no fries!
Have a nice day cheapskate',
'You did not enter a Y or N, I can\'t take this ambiguity, I quit']
print(statements[0])
fries = str(input(statements[1])).upper() # input with prompt, typecast into string, force uppercase
# selection
if fries =='Y':
print(statements[2])
elif fries =='N':
print(statements[3])
fries = str(input(statements[1])).upper() # input with prompt, typecast into string, force uppercase
if fries =='Y':
print(statements[2])
elif fries =='N':
print(statements[4])
else:
print(statements[5])
Thank you for your order
Would you like fries with that too? (Y or N) y
Excellent, I'll add them to your order, Have a nice day!
if you use yes or Yes as an answer to the input you get the response 'You did not enter a Y or N, I can't take this ambiguity, I quit' but if you use y you get a different response. Why does small letter y work but we have capital letter Y in the statement.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!