Beginner-friendly Python exercises to help learners practice using print() and input()

🔹 Exercise 1: Hello You!
Ask the user for their name and greet them.
# Expected:
# Enter your name: Ramesh
# Hello, Ramesh!
🔹 Exercise 2: Simple Math
Ask the user to enter two numbers. Print the total.
# Hint: Use int() or float() to convert input
# Expected:
# Enter first number: 10
# Enter second number: 20
# Total is: 30
🔹 Exercise 3: Age Calculator
Ask for the user's birth year and calculate their age.
# Hint: Assume current year is 2025
# Expected:
# Enter your birth year: 2000
# You are 25 years old.
🔹 Exercise 4: Favorite Things
Ask the user for 3 favorite things and print them in one line.
# Example:
# What’s your favorite color? Blue
# Favorite food? Pizza
# Favorite movie? Leo
# Your favorites: Blue, Pizza, Leo
🔹 Exercise 5: Repeating Output
Ask the user for a word and a number. Print the word that many times.
# Example:
# Enter a word: Hello
# How many times to repeat? 3
# Output:
# HelloHelloHello
Answers
🔹 Exercise 1: Hello You!
Ask the user for their name and greet them.
# Code:
name = input("Enter your name: ")
print("Hello,", name + "!")
🔹 Exercise 2: Simple Math
Ask the user to enter two numbers and print the total.
# Code:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
total = num1 + num2
print("Total is:", total)
🔹 Exercise 3: Age Calculator
Ask for the user's birth year and calculate their age.
# Code:
birth_year = int(input("Enter your birth year: "))
current_year = 2025
age = current_year - birth_year
print("You are", age, "years old.")
🔹 Exercise 4: Favorite Things
Ask for 3 favorite things and print them in one line.
# Code:
color = input("What’s your favorite color? ")
food = input("Favorite food? ")
movie = input("Favorite movie? ")
print("Your favorites:", color + ",", food + ",", movie)
🔹 Exercise 5: Repeating Output
Ask the user for a word and a number. Print the word that many times.
# Code:
word = input("Enter a word: ")
times = int(input("How many times to repeat? "))
print(word * times)




