0% found this document useful (0 votes)
6 views2 pages

Python Programs

The document provides Python programs for three tasks: calculating the average marks of five subjects, checking if a number is odd or even, and adding two numbers based on user input. Each program includes user prompts for input and displays the results. Example outputs for each program are also included to illustrate functionality.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Python Programs

The document provides Python programs for three tasks: calculating the average marks of five subjects, checking if a number is odd or even, and adding two numbers based on user input. Each program includes user prompts for input and displays the results. Example outputs for each program are also included to illustrate functionality.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Question 11

Write Python program that accepts marks in 5 subjects and outputs average marks.

Answer

m1 = int(input("Enter first subject marks: "))

m2 = int(input("Enter second subject marks: "))

m3 = int(input("Enter third subject marks: "))

m4 = int(input("Enter fourth subject marks: "))

m5 = int(input("Enter fifth subject marks: "))

avg = (m1 + m2+ m3+ m4 + m5) / 5;

print("Average Marks =", avg)

Output

Enter first subject marks: 65

Enter second subject marks: 78

Enter third subject marks: 79

Enter fourth subject marks: 80

Enter fifth subject marks: 85

Average Marks = 77.4

Write a Python Program to Check if a Number is Odd or Even

Answer:

num = int (input (“Enter any number to test whether it is odd or even: “)

if (num % 2) == 0:

print (num, “The number is even”)

else:

print (num, “The provided number is odd”)

Output:

Enter any number to test whether it is odd or even:

887

887 is odd.
Python program for the addition of two numbers with user
input.
Answer:

#Addition of two numbers inputted by a user

num1=int(input("Enter first no. :"))

num2=int(input("Enter second no. :"))

addition=(num1+num2)

#displaying the user input values

print("First number is :",num1)

print("Second number is :",num2)

#displaying addition of user input

print("Addition is : ",addition)

You might also like