Input / Output
Hands On Exercise
- Beginner
- January 8, 2026
Explore Python input and output concepts by completing practical exercises that help you apply input(), print(), and data formatting methods effectively. This lesson guides you to take user input, convert data types, and format numerical output for clear program results.
Congratulations on completing the lesson on Python I/O. Test your knowledge through these short snippets and get one step closer to mastering Python!
Exercise 1
Suppose you have to input the year of birth from a user and save it in a variable called birth_year. Fill in the blank below to take a valid input without adding any prompt. Once you’ve added your changes, run the code to see the output and compare it with the solution.
birth_year = _______
Exercise 2
This time, give the user a prompt that says “Enter your birth year here:”. Be sure to also convert the input obtained to a suitable data type and save it in a variable called birth_year_converted. Once you’ve added your changes, run the code to see the output and compare it with the solution.
birth_year = _______
birth_year_converted = _______
Exercise 3
Suppose we have a variable named “accuracy” with a value of 98.43138921. Print “accuracy” such that it is only displayed to 3 decimal places.
accuracy = 98.43138921
_______
In This Module