You are on page 1of 2

📝

Practice
1. Write a program that asks the user to enter their age and then prints a message
based on the following criteria:

If the age is less than 13, print “You are a child.”

If the age is between 13 and 19, print “You are a teenager.”

If the age is between 20 and 59, print “You are an adult.”

If the age is 60 or more, print “You are a senior.”

Use if , else if , and else statements to implement the logic.

2. Write a program that prints the multiplication table of a number entered by the
user. For example, if the user enters 5, the program should print:

Input:

Output:

5 x 1 = 5
5 x 2 = 10
5 x 3 = 15

Practice 1
5 x 4 = 20
5 x 5 = 25

3. Write a program that prints all the prime numbers between 1 and 100. A prime
number is a number that is only divisible by itself and 1. For example, some
prime numbers are 2, 3, 5, 7, etc. The output of the program should be.

The prime numbers between 1 and 100 are:


2 3 5 7 11 13 17 ..

4. Write a program that prints the Fibonacci sequence up to a certain limit entered
by the user. The Fibonacci sequence is a series of numbers where each number
is the sum of the previous two numbers. The first two numbers are 1 and 1. For
example, some Fibonacci numbers are:

5. Write a program that prints the sum of the first n natural numbers, where n is
entered by the user. For example, if the user enters 10, the program should print:

Input:

10

Output

55

Explain: 55 = 1 + 2 + 3 + … + 10

Practice 2

You might also like