Advanced Python
If-Else:
1. Write a program that takes an integer as input and prints "Positive" if it is greater
than 0, otherwise prints "Negative or Zero".
2. Write a program that checks whether a number is even or odd using an if-else
statement.
Loops:
3. Write a Python program using a for loop to print numbers from 1 to 10.
4. Write a for loop to print the square of numbers from 1 to 5.
5. Write a Python program using a while loop to print all even numbers from 2 to 20.
Functions:
6. Write a Python function called greet() that prints "Hello, welcome to Python
programming!" when called.
7. Write a function add_numbers(a, b) that takes two numbers as input and returns
their sum.
Lists:
8. Create a list of five colors ("red", "blue", "green", "yellow",
"black") and use a for loop to print each color.
9. Write a Python program to add a new color "white" to the list in Question 6 and
print the updated list.