0% found this document useful (0 votes)
120 views6 pages

Python Programs Class VIII

This is python

Uploaded by

jainmanan306
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
120 views6 pages

Python Programs Class VIII

This is python

Uploaded by

jainmanan306
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 6

1.

Write a program in Python to take two numbers as input from the user and print the
sum.

2. Write a program in Python to take two numbers from the user and print their difference.

3. Write a program in Python to take principal, rate and time from the user and print the
Simple Interest.

4. Write a program in Python to take marks obtained from the user and print the
percentage if the maximum marks are 500.

5. Write a program in Python to take first name, middle name and last name from the user
and print their full name.
6. Write a program in Python to take distance in Km from the user and change it to miles.
(1 km = 0.621371 mile)

7. Write a program in Python to take a number from the user and print if the number is
positive, negative or zero.

8. Write a program in Python to take a number from the user and check whether the
number is odd or even.

9. Write a program in Python to take temperature in degree Celsius from the user and
convert it into Fahrenheit.

10.Write a program in Python to take height and base of triangle from the user and print its
area.
11.Write a Program in Python to take age from the user and print whether they can vote or
not. (Age to vote is 18 or more)

12.Write a program in Python to take three different numbers from the user and print the
largest number.

13.Write a program in Python to print your name 10 times using while loop

14.Write a program in Python to take number from the user and print its table using while
loop.

15. Write a program to find the greatest of four numbers entered by the user.
16.#Program to print the grade of a Student based on total percentage obtained:
english=int(input("English:"))
hindi=int(input("Hindi:"))
sanskrit=int(input("Sanskrit:"))
sst=int(input("Social Science:"))
maths=int(input("Mathematics:"))
science=int(input("Science:"))
ai=int(input("Artificial Intelligence:"))
gk=int(input("General Knowledge:"))
om=english+hindi+sanskrit+sst+maths+science+ai+gk
total=160
percentage=om*100/total
if percentage>=90:
print("Grade: A+")
elif percentage>=80 and percentage<90:
print("Grade: A")
elif percentage>=60 and percentage<80:
print("Grade: B")
elif percentage>=40 and percentage<60:
print("Grade: c")
else:
print("Fail")
17.# Python program to find the factorial of a number provided by the user.

num = int(input("Enter any no. to find the factorial:"))

factorial = 1

# check if the number is negative, positive or zero


if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
18. # Python program to display all the prime numbers within an interval

lower = int(input("Enter the initial value:"))


upper = int(input("Enter the final value:"))

print("Prime numbers between", lower, "and", upper, "are:")

for num in range(lower, upper + 1):


# all prime numbers are greater than 1
if num > 1:
for i in range(2, num):
if (num % i) == 0:
break
else:
print(num)
19.Write a program to take input from the user Length and Breadth of a rectangle and print
area and perimeter.
20.Write a program to take input from the user x and y and swap their values using a
temporary variable.
21.Write a program to check whether a year is leap year or not.
(A leap year is exactly divisible by 4 except for century years (years ending with 00). The
century year is a leap year only if it is perfectly divisible by 400. For example,
2017 is not a leap year
1900 is a not leap year
2012 is a leap year
2000 is a leap year)
22.Write a program in Python to take marks of each subject in Half-yearly exam from the
user and print the overall percentage also mark them grades based on the following
criteria
91 to 100 – A+
81 to 90 – A
71 to 80 – B+
61 to 70 – B
51 to 60 – C+
41 to 50 – C
33 to 40 – D
Less than 33 - Fail

You might also like