Page 120 - 2622_Delhi Police Public School_C-6
P. 120

Operator                                  Name

                           not
                           and                           Logical
                           or


              SOME MORE PROGRAMS


                Program 6: To compute the difference between two numbers entered by the user

                   Program6.py

                File  Edit  Format   Run   Options   Window    Help

                #Program to compute the difference between two numbers entered by the user
                a = int (input ("Enter the first number: " ))
                b = int (input ("Enter the second number: " ))
                sub = a - b
                print ("Difference of two numbers is :" , sub)




                Program 7: To calculate the average marks of three subjects

                   Program7.py

                File  Edit  Format   Run   Options   Window    Help

                #Program to calculate the average marks of three subjects
                sub1 = int (input ("Enter the marks of first subject: " ))
                sub2 = int (input ("Enter the marks of second subject: " ))
                sub3 = int (input ("Enter the marks of third subject: " ))
                avg= (subl + sub2 + sub3)/3
                print ("Average of marks is :" , avg)




                Program 8: To calculate the volume and surface area of a cylinder

                   Program8.py

                File  Edit  Format   Run   Options   Window    Help

                #Program to calculate the volume and surface area of cylinder
                pi = 22/7
                radius = float (input ("Enter the radius of the cylinder: " ))
                height = float (input ("Enter the height of the cylinder: " ))
                volume = pi * radius * radius * height
                total_surface_area= ((2 * pi * radius) * (radius + height))
                print ("The volume of the cylinder is:" , volume)
                print ("Surface area is :", total_surface_area)






                118     Premium Edition-VI
   115   116   117   118   119   120   121   122   123   124   125