Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 144 - logicode 2609 C6
P. 144

    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

                      142   Premium Edition-VI

| 139 140 141 142 143 144 145 146 147 148 149 |