Exercise
Calculating Years
Objective
Develop a Python program to prompt the user for their age (e.g., 20) and respond with a message like "You look younger than 20" (the age entered by the user should be displayed in place of "20").
Example Python Exercise
Show Python Code
# Prompt the user to enter their age
age = int(input("Please enter your age: "))
# Display a message with the user's age
print(f"You look younger than {age}")
Output
Please enter your age: 20
You look younger than 20
Share this Python Exercise
Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.
In this exercise, you will develop a Python program to prompt the user for a number and display it four times in a row, separated by spaces, and then four time...
In this exercise, you will develop a Python program to prompt the user for a number and then display a rectangle 3 columns wide and 5 rows tall using that d...
In this exercise, you will develop a Python program that asks the user for a temperature in Celsius and converts it to both Kelvin and Fahrenheit...
In this exercise, you will develop a Python program to output "Hello" on the screen, followed by your name on a separate line. This exercise is perfect for pra...
In this exercise, you will develop a Python program to print the result of adding 12 and 13 on the screen. This exercise is perfect for practicing basic arithm...
In this exercise, you will develop a Python program to display the result of dividing 24 by 5 on the screen. This exercise is perfect for practicing basic arit...