Python Exercises
Here some beginner exercises for Python 3 are given. These can be easily tried out in the online python compiler in the Home Page.
Here are a few beginner-level "Hello, World!" exercises for Python 3
Exercise 1: Simple Hello World Write a program that prints "Hello, World!" to the console.
print("Hello, World!")
Exercise 2: Greeting User Write a program that asks the user for their name and then prints a personalized greeting.
name = input("Enter your name: ")
print("Hello, " + name + "!")
Exercise 3: Multiple Greetings Write a program that asks the user how many times they want to be greeted and then prints "Hello" that many times.
count = int(input("How many greetings do you want? "))
for _ in range(count):
print("Hello!")
Exercise 4: Greeting with Customization Write a program that asks the user for their name and the number of times they want to be greeted, and then prints personalized greetings that many times.
name = input("Enter your name: ")
count = int(input("How many greetings do you want? "))
for _ in range(count):
print("Hello, " + name + "!")
Exercise 5: Greeting with Function Write a program that defines a function greet() which takes a name as a parameter and prints a greeting message.
def greet(name):
print("Hello, " + name + "!")
name = input("Enter your name: ")
greet(name)
Feel free to try out these exercises and modify them as you learn more about Python. Have fun exploring the world of Python programming!