exercise
exercise
Conditional Statements
1. Leap Year: Write a program to check if a given year is a leap year. (Remember the rules
for leap years).
2. FizzBuzz: Print the numbers from 1 to 100. But, for multiples of 3 print "Fizz", for multiples
of 5 print "Buzz", and for multiples of both 3 and 5 print "FizzBuzz".
3. Even or Odd: Get a number from the user and determine if it's even or odd.
For Loops
1. Multiplication Table: Ask the user for a number. Print the multiplication table for that
number up to 10.
2. Factorial: Calculate the factorial of a number entered by the user. (Factorial of n is the
product of all numbers from 1 to n)
3. Reverse a String: Use a for loop to reverse a string given by the user.
While Loops
1. Guessing Game: Have the computer pick a random number. The user has to keep
guessing until they get the correct number. Provide hints like "higher" or "lower".
2. Countdown Timer: Create a simple countdown timer. Let the user input the starting
number of seconds.
3. Number Sequence: Use a while loop to generate a series of numbers based on a user-
defined starting point and a mathematical rule (like adding 5 to each number or doubling the
previous number).
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx