Page 103 - 2403_Trackpad_V5.1_C6_Fb
P. 103

MORE PROGRAMS


                 Program 1. Write a program to print your name.
                     Program1.py
                  File  Edit  Format  Run   Options   Window    Help

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



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

                     Output
                  Enter your name: Jaspreet
                  Enter your roll number: 11
                  Enter your school name: DPS
                  Name: Jaspreet
                  Roll Number: 11
                  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  101
   98   99   100   101   102   103   104   105   106   107   108