Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 117 - 2611_SmartGPT Pro V(5.0) C-6
P. 117

    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  115

| 112 113 114 115 116 117 118 119 120 121 122 |