top of page

#Program to display the even numbers between 1 and p:

p=int(input("Enter the limit"))
for i in range(1, p+1):

    if i%2==0:

          print(i)

#Program to find sum of all numbers divisible by 6.

p=int(input("Enter the limit"))

sum=0
for i in range(1, p+1):

    if i%6==0:

          sum+=i

print("Sum is" , sum)

#Program to display the factorial of a number:

x=int(input("Enter a number"))
p=1

while x>0:
    p=p*x
    x=x-1

print("The factorial of ", x, "is:",p)

#Program to print multiplication table of a number

 

x=int(input("enter a no.")) 

i=0 

while i<10: 

    i=i+1 

    print(i,"x",x,"=",i*x) 

Practice Programs 

1. WAP to display numbers from 1 to n(input by the user). Also display the sum and average of the numbers.

Solution

2. WAP to input m and n . Display all positive numbers between m and n. 

 

Solution 

3. WAP to input x and display its multiplication table till n(input by the user).

Solution

4. WAP to input y and find sum of all odd numbers between 1 and y.

Solution:

5. WAP to print the sum of the following series. n is to be input by the user.

Sample Run:

Enter n: 25

Series : 1,2,4,7,11,16,22    

Sum of the series is  : 63

Solution

6. WAP to input a number and check if it is an Armstrong number.

For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )

Solution

7. WAP to input a number and a power. Without using power function, display the number raised to the given power.

Solution

8. WAP to print the sum of first N natural numbers. N has to be input by the user.

Solution

9. WAP to input a list of numbers and display the largest number.

Solution

10. WAP to input a number and find the sum of its digits.

Solution

11. WAP to input a number and check whether it is a Prime number.

Solution

12. Write a program that prompts the user to input an integer and then outputs the number with the digits reversed. For example, if the input is 12345, the output should be 54321.

Solution

13. WAP to input a number and check if it is a palindrome. A palindrome example: 1221.      

Solution

14. Write a program to print Fibonacci series of n terms where n is input by user :
0 1 1 2 3 5 8 13 24 ..... 

Solution

15.Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered. 

Solution

16. WAP to print the following pattern. If the input is 4:

       

      *

      * *

      * * *

      * * * *

   Solution

          

17. WAP to print the following pattern if the input is 6.

        * * * * * *

        * * * * *

        * * * *

        * * *

        * *

        *

18. WAP to print the sum of the following series:

sum=

Solution

19. WAP to input a number , n . Display all the numbers between 1 and n except for the numbers which are divisible by 3.

20. WAP to input a list of n numbers. Check and display the prime numbers in the list.

21. WAP to accept the weather of a city for a week. Display the maximum and minimum temperature and also the average daily temperature.

22. WAP to find the sum of the series 2 +22 + 222 + 2222 + .. n terms

Example: if n =4, then the series would be:

 

2+22+222+2222

 

Sum will be : 2468 

23. WAP to print the following pattern if the user inputs 4(n):

@

@@

@@@

@@@@

@@@

@@

@

24. Write a Python program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. 
Example:

if Rows = 3, Columns = 4
Expected output : [0, 0, 0, 0],

                              [0, 1, 2, 3],

                              [0, 2, 4, 6]

series1.JPG

Solved Programs

Looping Programs

bottom of page