Python Exercises
Python Exercises
2. Simple Sum
• Create a program that adds 5 + 3 and prints the result to the console.
result = 5 + 3
print(result)
3. Personal Greeting
• Ask the user for their name and print a greeting message.
name = input("What is your name? ")
print("Hello, " + name + "!")
4. Count to Ten
• Use a loop to print the numbers 1 to 10.
for i in range(1, 11):
print(i)
5. Simple List
• Create a list of 5 fruits and print the list to the console.
fruits = ["apple", "banana", "cherry", "date", "elderberry"]
print(fruits)
6. List Addition
• Add a new fruit to your list of fruits and print the updated list.
fruits.append("fig")
print(fruits)
1
7. Easy Multiplication
• Create a program that multiplies 7 by 6 and prints the result.
result = 7 * 6
print(result)
8. Favorite Color
• Ask the user for their favorite color and print a message saying "X is a nice
color!", replacing X with the user's input.
color = input("What is your favorite color? ")
print(color + " is a nice color!")
9. Simple Division
• Create a program that divides 8 by 4 and prints the result.
result = 8 / 4
print(result)