Part 1: Programming Basics
1. Write a line of code that creates a variable named age,
assigns it the value of your age, and prints it out.
Part 2: Control Flow & Logic
4. Write a script that checks a variable called temperature.
If it's greater than 30, print "It's hot!". Otherwise,
print "It's nice outside.".
5. Write a loop that prints the numbers from 1 to 5.
Part 3: Data Structures & Functions
7. Given the list fruits = ["apple", "banana", "cherry"],
how do you change "banana" to "blueberry"?
8. Create a simple dictionary named user that stores a person's
name and city.
9. Write a function named greet that takes a name as an argument
(e.g., "Alice") and returns a string like "Hello, Alice!".
Part 4: Problem Solving & Concepts
10. This code is supposed to check if a number is even, but it
contains syntax errors. Fix it:
def is_even(num)
if num % 2 = 0:
return True
11. (Optional) If you know what a list comprehension is,
convert this loop into one:
squares = []
for x in range(5):
squares.append(x * x)
13. Write a function that returns the largest of two numbers.
14. Write a program that prints only the even numbers from 1 to 10.
Part 5: Real Programming Tasks
15. Create a list called grades with at least 5 numbers in it.
Then print the highest grade.
16. Write code that asks the user for their name and then prints:
"Welcome, NAME!"
18. Fix the error in this code:
my_list = [1, 2, 3]
print(mylist)