Skip to main content

Command Palette

Search for a command to run...

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

Published
2 min read
Beginner-friendly Python exercises to help learners practice using print() and input()
A
I co-founded🫆digizen (fighting internet chaos 🧠), building an AI app to tackle misinformation, and running ideaGeek to turn “I have an idea” into real startups. I also share tech + travel on YouTube (TechNomad & Rz Omar). I touch grass too 🌱… but mostly to debug life 💻

🔹 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)

Python

Part 1 of 10

I break down Python basics with clear explanations and practical exercises. Whether you're a beginner or looking to refresh your skills, follow along to strengthen your Python fundamentals through hands-on practice. Let's code and grow together!

Up next

Beginner Exercises for If-Else Statements in Python

1. Even or Odd Ask the user for a number. Print if it's even or odd. 2. Greater Number Ask the user to enter two numbers. Print the greater one. 3. Pass or Fail Ask the user for a score.If score >= 50, print “Pass”. Otherwise, print “Fail”. 4. Temper...

More from this blog

T

TechNomad

46 posts

TechNomad is mostly coding exercises, not long boring explanations 😌. I share what I teach and learn through hands-on problems—mainly for my students, but anyone can jump in. If you learn by doing (and breaking things), you’ll fit right in. Less theory, more “try this and see what happens.”