Page 131 - trackpad v5.1 class 6 flipbook
P. 131

MORE PROGRAMS


                 Program 1. Write a program to input your name, school name and also print.
                     Program1.py
                  File  Edit  Format  Run   Options   Window    Help

                  # Store Input Data
                  name = input(" Enter your name: ")
                  school_name = input(" Enter your school name: ")
                  # Display the Input Data
                  print ("Name:",name)
                  print ("School Name:", school_name)




                 On running the above program, we get the following output:

                     Output
                  Enter your name: Jaspreet
                  Enter your school name: DPS
                  Name: Jaspreet
                  School Name: DPS







                 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)




                 On running the above program, we get the following output:
                     Output

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







                                                                                             Introduction to Python  129
   126   127   128   129   130   131   132   133   134   135   136