Python for beginners

Here's a 7-day plan for practicing basic Python coding skills. Each day includes a small exercise and sample code to help you get started.


# Print a welcome message
print("Welcome to Python Programming!")

# Basic arithmetic operations
a = 10
b = 5

# Addition
sum = a + b
print("Sum:", sum)

# Subtraction
difference = a - b
print("Difference:", difference)

# Multiplication
product = a * b
print("Product:", product)

# Division
quotient = a / b
print("Quotient:", quotient)

 


# Get user input
name = input("Enter your name: ")

age = input("Enter your age: ")

# Print a personalized message
print(f"Hello, {name}! You are {age} years old.")

 


# Get user input
number = float(input("Enter a number: "))

# Check if the number is positive, negative, or zero
if number > 0:
print(“The number is positive.”)
elif number < 0:
print(“The number is negative.”)
else:
print(“The number is zero.”)

 

 


# Print the first 10 positive integers
for i in range(1, 11):
print(i)


# Create a list of numbers
numbers = [1, 2, 3, 4, 5]

# Print each number squared
for number in numbers:
print(number ** 2)


# Define a function to add two numbers
def add_numbers(x, y):
return x + y

# Call the function with different values
result1 = add_numbers(3, 5)
result2 = add_numbers(10, 20)

# Print the results
print(“Sum of 3 and 5:”, result1)
print(“Sum of 10 and 20:”, result2)

 


# Create a dictionary with names and ages
people = {
"Alice": 30,
"Bob": 25,
"Charlie": 35
}

# Print each person's name and age
for name, age in people.items():
print(f"{name} is {age} years old.")

 

Scroll to Top