Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 95 - 2615_KEC
P. 95

    Output

                      Enter your name: Rohit
                      Enter your school name: KPS
                      Name: Rohit
                      School Name: KPS

                     Program 2. Write a program to add two numbers.

                         Program2.py
                      File  Edit  Format  Run   Options   Window    Help

                      #Program to add two numbers
                      num1 = int(input(" Enter first number: "))
                      num2 = int(input(" Enter Second number: "))
                      ans=num1+num2
                      print(" The sum is : ", ans)

                         Output
                      Enter first number: 3
                      Enter Second number: 2
                      The sum is : 5

                     Program 3. Write a program to calculate the average marks of three subjects.

                         Program3.py
                      File  Edit  Format  Run   Options   Window    Help

                      #Program to calculate the average marks of three subjects
                      Eng = float(input(" Enter English Marks: "))
                      Math = float(input(" Enter Math Marks: "))
                      Hindi = float(input(" Enter Hindi Marks: "))
                      avg=( Eng+ Math + Hindi)/3
                      print("Average is :", avg)

                         Output

                      Enter English Marks: 90
                      Enter Math Marks: 95
                      Enter Hindi Marks: 80
                      Average is : 88.33333333333333

                                                                                                 Introduction to Python  93

| 90 91 92 93 94 95 96 97 98 99 100 |