Python Exercise list

Print Statements

1.  Write a program To print a message

“Wish you all the best!”

2.  Write a program To print the message

“Programming is fun”

3.  Write a program To print a message

“Hello!
How are you?”

4.  Write a program To print a message

“India is my country
I love my country
I proud to be an Indian”

5. Write a program To print the message

“This is my first
                Day of programming”

6. Write a program to print a message

“Hi
    Have a nice day!”

7. Write a program to print a message

“Happy
       New
           Year!”

8. Write a program To print a message

“Wish you
	Many many
Happy returns
	Of the day!”

9. Write a program to print a message

“Wish you
     A very happy
         And
     Prosperous
New Year!”

Datatypes

1 . Write a program to store nos. 10 and 20 and reprint them.

2. Write a program to store 20 and 30 and get their addition.

3. Write a program to store 60 and 20 and get their addition, subtraction, multiplication, and division.

4. Write a program to get a square and cube of 7.

5. Write a program to store length as 3.5 and 4.8 as the breadth of a rectangle and get its area.

                          Area=Length*Breadth

6. Write a program to store base as 7.5 and height as 4.9 and get the area of a triangle.

                         Area=0.5*Base*Height

7. Write a program to store the radius of a circle as 3.5 and get its area and circumference.

                         Area=3.14*r2

                         Circumference=2*3.14*r

8. Write a program to store the name of the student as Ram and his grade as A and reprint them as “Grade of Ram is A”

9. Write a program to store the name of the country as the USA and its currency symbol as $ and print as “Currency symbol of USA is $”

10. Write a program to store the name of the person as Dinesh Joshi, building as Sai Darshan, street as D. P. Road, name of the city as Badlapur, the region as ‘E’, Pincode as 421503. Print all the details one below another.

11. Write a program to store name as “Ramesh Kulkarni”, gender as “M”, age as 30 years and weight as 66.5 kg. and print all the details one below another.

12. Write a program to store roll no. as “R50”, name of the student as “Amit Jadhav”, his grade as “A”, marks of English as 75,  Math as 82 and Science as 94. Get his total and average. The print mark sheet along with all the details.

Input Statements

  1. Write a program to accept any 2 nos. and reprint them.
  2. Write a program to accept any 2 nos. and get their sum.
  3. Write a program to accept any 2 nos. and get their addition, subtraction, multiplication, and division.
  4. Write a program to accept any no. and get its square and cube.
  5. Write a program to accept the length and breadth of a rectangle and get its area.
  6. Write a program to accept the base and height of a triangle and get its area.
  7. Write a program to accept the side of the square and get its area.
  8. Write a program to accept the radius of a circle and get its area and circumference.
  9. Write a program to accept the name and grade of a student and reprint them.
  10. Write a program to accept the name of the country and its currency symbol and reprint them.
  11. Write a program to accept the name of a person, building name, street, city, pin code, and region (E/W) and print them one below another.
  12. Write a program to accept roll no., name, grade, and marks of English, Math,s, and Science of a student and get their total and average. The print mark sheet along with all the details.
  13. Write a program to accept worker no., name of the worker, type of worker(T/P) hours worked and calculate wages by Rs. 100/hr. Prepare wage-slip.
  14. Write a program to accept meter no., name of the consumer, line type(C/D), current reading, previous reading and calculate net units consumed and charges by Rs. 4.5/unit consumed. Print electricity bill along with all the details.
  15. Write a program to accept item no., name of the item, the price per item, quantity purchased, and calculate total bill amount, discount @ 10%, and net bill amount after deducting discount. The print bill including all details.
  16. Write a program to accept account no., name of an account holder, type of account(S/C), and current balance. Calculate simple interest @ 7% on the current balance and also calculate the updated balance. Print all the details.
  17. Write a program to accept employee no., name of the employee, his grade, and basic salary. Calculate the following allowances.

        HRA     ——   30% on basic salary

        DA        ——    20% on basic salary

        CA        ——    10% on basic salary

        PF        ——    5% on basic salary

        Gross salary = Basic salary + HRA + DA + CA

        Net salary = Gross salary – PF

        Print pay-slip along with all the details.

Operators

  1. Write a program to accept any 2 nos. and get their quotient and remainder.
  2. Write a program to accept the length of a metal strip in meters only and find out many pieces you can make of 5 meters and 3 meters of the strip. And also find out wastage.
  3. Write a program to accept any amount in rupees only and find out no. of notes of Rs.1000, Rs.500, Rs.100, Rs.50, Rs.20, Rs.10, Rs.5, Rs.2, and Re.1 in it.
  4. Write a program to accept any 3 digits no. and get its digits in reverse sequence.
  5. Write a program to accept any 3 digits no. and get the sum of its digits.
  6. Write a program to accept any 3 digits no. and get its reverse no.
  7. Write a program to accept marks of English, Maths, Science. If a student has scored at least 35 marks in each subject consider him as passed otherwise failed.
  8. Write a program to accept any 3 nos. and arrange them in ascending order.
  9. Write a program to accept roll no., name of a student, marks of theory and practical out of 50 each of one subject. Get their total. If the student has scored at least 15 marks in each subject and his total is at least 40 then consider him as passed. If a student has scored at least 15 marks in each subject and his total is exactly 39 then consider him as promoted. In all other cases consider him as failed.
  10. Write a program to accept roll no., name, grade, and marks of English, Maths, and Science of a student and get their total and average.  If a student has scored at least 35 marks in each subject consider him as passed otherwise failed. Allot him grades as follows

                      Average above 60 —- ‘A’

                      Average between 45 to 60 —- ‘B’

                      Average between 35 to 45 —- ‘C’

                      Average below 35 —- ‘- ‘

          Prepare mark-sheet.

 11. Write a program to accept marks of English, Maths, Science. If a student has scored less than 35 marks in any subject then consider him as failed otherwise consider him as passed.

 12. Write a program to accept any character any check whether it is a vowel or not.

 13. Write a program to accept any no. between 1 to 10 and print whether it is even or odd.

 14. Write a program to accept month no. and year and display no. of days in that month.

 15. Write a program to print a message as follows.

           Hello!

           Have a nice day!

           How are you?

           How are your parents?

           Also, tell them,

           Have a nice day!

 16. Write a program to accept any 2 nos. and get their sum.

 17. Write a program to accept any 2 nos. and find out the maximum.

 18. Write a program to accept any 3 nos. and find out the minimum out of them.

 19. Write a program to accept any no. and get its factorial.

 20. Write a program to accept any no. and check whether it is prime or not using returning object method.

 21. Write a program to print prime nos. between 20 to 50 using returning value method.

 22. Write a program to accept any 2 nos. and find out its GCD and LCM using returning object method.

23. Write a program to solve the following series.

24. Write a program to solve the following series.

25. Write a program to solve the following series.

If_else

  1. Write a program to accept salesman no., name of a salesman, and sales amount. Calculate commission @ 5% if sales amount is up to Rs. 1000/- otherwise calculate sales amount @ 10%.
  2. Write a program to accept any integer and check whether it is even or odd.
  3. Write a program to accept any 3 nos. and find out the maximum out of them.
  4. Write a program to accept any 3 nos. and find out the minimum out of them.
  5. Write a program to accept item no., name of the item, the price per item, and quantity. Calculate total bill amount and apply discount @ 10% for bill amount above Rs. 5000/- otherwise apply discount @ 8% also calculate net bill amount.
  6. Write a program to accept worker no., name of the worker, hours worked and calculate wages as follows.

                           For the first 8 hours      —-         Rs. 50/hr.

                           Next all hours                 —-         Rs. 70/hr.

 7. Write a program to accept meter no., name of the consumer, current reading, previous reading, and calculate net units consumed and charges as follows.

                           For first 100 units         —-         Rs. 3.5/unit 

                            Next all units                 —-        Rs. 5/unit

 8. Write a program to accept any 2 nos. and compare them with each other and display proper messages.

 9. Write a program to accept any 3 nos. and find out the maximum and minimum out of them.

 10. Write a program to accept salesman no., name of a salesman, the salary of a salesman, and sales amount. Calculate commission as follows.

                             Sales amount              Commission

                              1 – 1500                            5%

                              1501 – 3000                    7%

                             3001 – 4500                    10%

                             4501 and above              12%

Calculate the total income of the salesman. Display all details.

 11 . Write a program to accept item no., name of the item, the price per item, and quantity. Calculate the total bill amount and calculate the discount as follows.

                       Bill amount                  Discount

                        1 – 3000                          2%

                        3001  – 6000                  3%

                        6001 and above             5%

    Calculate net bill amount. Display all details.

 12. Write a program to accept worker no., name of the worker, hours worked and calculate wages as follows.

                   For the first 8 hours —- Rs. 50/hr.

                   Next 2 hours —- Rs. 70/hr.

                   Next all hours —- Rs. 90/hr.

 13. Write a program to accept meter no., name of the consumer, current reading, previous reading, and calculate net units consumed and charges as follows.

                    For first 100 units —- Rs. 3.5/unit 

                    Next 250 units —- Rs. 5/unit

                    Next all units —- Rs. 7.5/unit

 14. Write a program to accept worker no., name of the worker, hours worked, and type of worker (T/P) and calculate wages as follows.

         ‘T’- Temporary

                    For the first 8 hours      —-     Rs. 20/hr.

                    Next 2 hours                   —-      Rs. 30/hr.

                    Next all hours                 —-      Rs. 50/hr.

         ‘P’ – Permanent

                   For first 8 hours —- Rs. 70/hr.

                   Next 2 hours —- Rs. 80/hr.

                   Next all hours —- Rs. 90/hr.

 15. Write a program to accept meter no., name of the consumer, current reading, previous reading, and line type(C/D/I) and calculate net units consumed and charges as follows.

         ‘D’ – Domestic

                     For first 100 units —- Rs. 2.5/unit 

                    Next 250 units —- Rs. 4/unit

                    Next all units —- Rs. 5.5/unit

         ‘C’ – Commercial

                   For first 100 units —- Rs. 3.5/unit 

                   Next 250 units —- Rs. 5/unit

                   Next all units —- Rs. 7.5/unit

          ‘I’ – Industrial

                  For first 100 units —- Rs. 4/unit 

                  Next 250 units —- Rs. 6/unit

                  Next all units —- Rs. 8/unit

Loop

  1. Write a program to print “hello” for 5 times.
  2. Write a program to get areas of 7 rectangles.
  3. Write a program to print the first 10 natural nos.
  4. Write a program to print the first 10 even nos.
  5. Write a program to print first n natural nos.
  6. Write a program to print first n even nos.
  7. Write a program to print the sum of first n natural nos.
  8. Write a program to get factorial of any no.
  9. Write a program to get the table of n.
  10. Write a program to print first 20 elements of Fibonacci series. (0,1,1,2,3,5,8,13,21,……) 
  11. Write a program to accept any no. and check whether it is prime or not.
  12. Write a program to accept any integer and get the sum of its digits.
  13. Write a program to accept any integer and get its reverse no.
  14. Write a program to accept any 2 nos. and get its GCD and LCM.
  15. Write a program to accept any no. and check whether it is Armstrong no. or not.
  16. Write a program to accept any integer and check whether it is palindrome no. or not.
  17. Write a program to accept principal amt, a period of deposit, and rate of interest and calculate cumulative interest as follows Principal amt*((1+rate/100)^1 +(1+rate/100)^2——–+(1+rate/100)^n)
  18. Write a program to print2
    1
    2 2
    3 3 3
    4 4 4 4
  19. Write a program to print 
    1
    1 2 
    1 2 3
    1 2 3 4
    1 2 3 4 5
  20. Write a program to print
    1 
    2 3 
    4 5 6
    7 8 9 10
  21. Write a program to print   
    *
    * *
    * * *
    * * * *
  22. Write a program to print
    *
    * *
    * * *
    * * * *
    * * * * *
    * * * *
    * * *
    * *
    *
  23. Write a program to print 
       *
      * *
     * * *
    * * * *
     * * *
      * *
       *
  24. Write a program to print 
          *
        * * *
      * * * * *
    * * * * * * *
    
  25. Write a program to print
    * * * * * * * *
    * * *     * * *
    * *         * *
    *             *
    
  26. Write a program to print 
          1
        1 2 1
      1 2 3 2 1
    1 2 3 4 3 2 1
    
  27. Write a program to print 
    a
    a b
    a b c
    a b c d 
    
  28. Write a program to print 
          A
        A B A
      A B C B A
    A B C D C B A
    

     

  29. Write a program to print prime nos. between 20 to 50.
  30. Write a program to print prime nos. between a given range.
  31. Write a program to print Armstrong nos. between 1 to 500.
  32. Write a program to print Armstrong nos. between a given range.
  33. Write a program to print tables from 5 to 10.
  34. Write a program to print tables between the given range.

Functions

  1. Write a program to accept any no. and get its square and cube.
  2. Write a program to solve the following equation.

3. Write a program to find out the roots of a quadratic equation.

   4. Write a program to accept a principal amount, a period of deposit, rate of interest, and find out compound interest. Principal amt. * (1 + rate/100) ^ period

  5. Write a program to accept roll no., name, grade, and marks of English, Maths, and Science of a student and get their total and average.  If a student has scored at least 35 marks in each subject allot him remark as “Pass” otherwise “fail”. Allot him, classes, as follows

                                       Average above 60                     —-            First

                                       Average between 45 to 60      —-            Second

                                       Average between 35 to 45      —-             Pass

                                       Average below 35                    —-             

          Prepare mark-sheet.

 6. Write a program to accept name and surname and join them including space.

 7. Write a program to accept the name, middle name, and surname and get a full name in another variable separated by spaces by keeping original values as it is.

 8. Write a program to accept worker no., name of the worker, hours worked, and type of worker and calculate wages as follows.

               Skilled

                             For the first 8 hours         —-         Rs. 20/hr.

                             Next all hours                    —-           Rs. 50/hr.

           Unskilled

                            For the first 8 hours          —-         Rs. 70/hr.

                            Next all hours                     —-         Rs. 90/hr.

 9. Write a program to accept any word and check whether it is palindrome or not.

 

 

 

 

Facebook Comments
(Visited 1 times, 1 visits today)

Leave A Comment

Your email address will not be published. Required fields are marked *