Professional Documents
Culture Documents
Practice
1. Write a program that asks the user to enter their age and then prints a message
based on the following criteria:
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.
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