Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 87 - 2606_PlugGPT_C6_Flipbook
P. 87

    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  85

| 82 83 84 85 86 87 88 89 90 91 92 |