Page 109 - TP_Play_V2.1_class6
P. 109

SOME MORE PROGRAMS

                 Program 5: To subtract two numbers entered by the user
                     Program5.py

                  File  Edit  Format   Run   Options   Window     Help

                  a = int(input('Enter the first number: '))
                  b = int(input('Enter the second number: '))
                  sub = a - b
                  print('Difference of two numbers is:', sub)



                 The result of the above program is:

                     Output
                  Enter the first number: 20
                  Enter the second number: 8
                  Difference of two numbers is: 12



                 Program 6: To calculate the average marks of three subjects
                     Program6.py

                  File  Edit  Format   Run   Options   Window     Help

                  sub1 = int(input('Enter marks of the first subject: '))
                  sub2 = int(input('Enter marks of the second subject: '))
                  sub1 = int(input('Enter marks of the third subject: '))
                  avg = (sub1 + sub2 + sub3)/3
                  print('Average of marks is: ', avg)




                 The result of the above program is:
                     Output

                  Enter marks of the first subject: 95
                  Enter marks of the second subject: 96
                  Enter marks of the third subject: 94
                  Average of marks is: 95.0



                 Program 7: To calculate the volume and surface area of cylinder
                     Program7.py

                  File  Edit  Format   Run   Options   Window     Help

                  pi = 22/7
                  height = float(input('Enter the height of cylinder: '))
                  radius = float(input('Enter the redius of cylinder: '))
                  volume = pi * radius * radius * height
                  surface_area - ((2 * pi * radius) * height) + ((pi * radius ** 2) * 2)
                  print('The volume of the cylinder is:', volume)
                  print('Surface area is:', surface_area)





                                                                        Introduction to Programming Python       107
   104   105   106   107   108   109   110   111   112   113   114