Page 69 - KEC Khaitan C7 Flipbook
P. 69
On running the above program, we get the following output:
Output
Enter your name: Rohit
Enter your school name: KPS
Name: Rohit
School Name: KPS
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
Program 3. Write a program to calculate the average marks of three subjects.
Program3.py
File Edit Format Run Options Window Help
#Program to calculate the average marks of three subjects
Eng = float(input(" Enter English Marks: "))
Math = float(input(" Enter Math Marks: "))
Hindi = float(input(" Enter Hindi Marks: "))
avg=( Eng+ Math + Hindi)/3
print("Average is :", avg)
On running the above program, we get the following output:
Output
Enter English Marks: 90
Enter Math Marks: 95
Enter Hindi Marks: 80
Average is : 88.33333333333333
Introduction to Python 67

