Question: Write a Python program using if structure (only one keyword if can be used in your program) which firstly asks user to enter his/her age.

Write a Python program using if structure (only one keyword if can be used in your program) which firstly asks user to enter his/her age. If the user is younger than (less than) 16, print the following two separate lines of warning messages:

"You are too young to drive!"

"Take a bus instead!"

By the end the program, print the following line of message regardless of user's age:

"Session end"

Hint: don't forget to indent the statements inside the if block (In Canvas, "Tab" is not adding spaces for you, you have to manually type a number of "SPACE" key).

The screenshot below contains two test runs: 17 is entered in the 1st test run; 15 is entered in the 2nd test run.

RESTART: C:\Users\lwu\OneD .py Enter your age?17 Session end >>> RESTART: C:\Users\lwu\OneDr .py Enter your age?15 You are too young to drive! Take a bus instead! Session end

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 Databases Questions!