0% found this document useful (0 votes)
9 views9 pages

Grade 10 Python Programs

The document contains a series of Python programs designed for Grade 10 Computer Science students at Abu Dhabi Indian School, covering various topics such as calculating percentages, averages, areas, and conversions. Each program includes user input prompts, calculations, and sample outputs demonstrating the functionality. The programs also address conditional statements for checking eligibility, divisibility, and character types.

Uploaded by

asrikar2710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views9 pages

Grade 10 Python Programs

The document contains a series of Python programs designed for Grade 10 Computer Science students at Abu Dhabi Indian School, covering various topics such as calculating percentages, averages, areas, and conversions. Each program includes user input prompts, calculations, and sample outputs demonstrating the functionality. The programs also address conditional statements for checking eligibility, divisibility, and character types.

Uploaded by

asrikar2710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ABU DHABI INDIAN SCHOOL – BRANCH 1, AL WATHBA

GRADE10 - COMPUTER SCIENCE - PYTHON PROGRAMS


1. WAPP to accept your 5 subject marks, then calculate and display the
percentage.
Program:-
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: "))
percentage = (m1 + m2+ m3+ m4 + m5) / 500*100;
print("Percentage =", percentage)
Output:-
Enter first subject marks: 90
Enter second subject marks: 90
Enter third subject marks: 90
Enter fourth subject marks: 90
Enter fifth subject marks: 90
Percentage = 90.0

2. WAPP to accept three numbers and then display its average.


Program:-
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
average = (num1 + num2 + num3) / 3
print("The average is:", average)
Output:-
Enter first number: 20
Enter second number: 30
Enter third number: 40
The average is: 30.0

3. WAPP to accept the length and breadth of a rectangle and then display its
area and perimeter.
Program:-
length = float(input("Enter the length of the rectangle: "))
breadth = float(input("Enter the breadth of the rectangle: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area of the rectangle:", area)
print("Perimeter of the rectangle:", perimeter)
Output:-
Enter the length of the rectangle: 20
Enter the breadth of the rectangle: 10
Area of the rectangle: 200.0
Perimeter of the rectangle: 60.0

4. WAPP to accept the radius and height of a cone, then display its volume.
Program:-
radius = float(input("Enter the radius of the cone: "))
height = float(input("Enter the height of the cone: "))
volume = (1/3) * 3.14 * radius**2 * height
print("Volume of cone=",volume)
Output:-
Enter the radius of the cone: 10
Enter the height of the cone: 10
Volume of cone= 1046.6666666666665

5. WAPP to accept the amount in dollars and then convert and display it in
rupees.
Program:-
amount = float(input("Enter amount in dollars "))
conversion_rate = float(input("Enter conversion rate "))
amount_in_rupees = amount * conversion_rate
print("Converted amount in rupees:", amount_in_rupees)
Output:-
Enter amount in dollars 70
Enter conversion rate 81
Converted amount in rupees: 5670.0

6. WAPP to accept the values of a,b, and c, then calculate and display
the result of 4a3+3b2+c.
Program:-
a = float(input("Enter the value of a: "))
b = float(input("Enter the value of b: "))
c = float(input("Enter the value of c: "))
result = 4 * a**3 + 3 * b**2 + c
print("The result of 4a³ + 3b² + c is:", result)
Output:-
Enter the value of a: 10
Enter the value of b: 5
Enter the value of c: 2
The result of 4a³ + 3b² + c is: 4077.0

7. WAPP to accept the age of a person and check whether he/she is eligible
to vote or not.
Program:-
age = int(input("Enter age : "))
if age >= 18:
print("Eligible for Voting!")
else:
print("Not Eligible for Voting!")
Output:-
Enter age : 25
Eligible for Voting!

8. WAPP to accept a number from the user, then display whether it is odd or
even.
Program:-
number=int(input("Enter a number: "))
if number%2==0:
print("The number is even.")
else:
print("The number is odd.")
Output:-
Enter a number: 12
The number is even.

9. WAPP to accept a number from the user, then display whether it is


divisible by 5 or not.
Program:-
number=int(input("Enter a number: "))
if number%5==0:
print(number," is divisible by 5.")
else:
print(number,"is not divisible by 5.")
Output:-
Enter a number: 24
24 is not divisible by 5

10.WAPP to accept a number from the user, then display whether the last
digit of the number is divisible by 3 or not.
Program:-
number=int(input("Enter the number : "))
digit=number%10
if digit%3==0:
print("last digit of ",number,"is divisible by 3")
else:
print("last digit of ",number,"is not divisible by 3")
Output:-
Enter the number : 69
last digit of 69 is divisible by 3

11.WAPP to accept two numbers from the user, then display the greatest
number.
Program:-
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
if num1 > num2:
greatest = num1
else:
greatest = num2
print("The greatest number is:", greatest)
Output:-
Enter the first number: 12
Enter the second number: 30
The greatest number is: 30

12.WAPP to accept two numbers, then check whether the first number is
divisible by the second number.
Program:-
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
if num2 == 0:
print("Division by zero is not allowed.")
elif num1 % num2 == 0:
print(num1,” is divisible by”,num2)
else:
print(num1,” is not divisible by”,num2")
Output:-
Enter the first number: 10
Enter the second number: 5
10 is divisible by 5

13.WAPP to accept a number from the user, then display whether it is


divisible by 5 and 3.
Program:-
number = int(input("Enter a number: "))
if number % 5 == 0 and number % 3 == 0:
print("The number is divisible by both 5 and 3.")
else:
print("The number is not divisible by both 5 and 3.")
Output:-
Enter a number: 15
The number is divisible by both 5 and 3.

14.WAPP to accept a character from the user, then display whether it is a


vowel or a consonant.
Program:-
l = input("Input a letter of the alphabet: ")
if l in "AEIOUaeiou":
print(l, "is a vowel.")
else:
print(l," is a consonant.")
Output:-
Input a letter of the alphabet: A
A is a vowel.

15.WAPP to accept the percentage of a student then display the grade as per
the following criteria.

Percentage Grade
>=90 and <=100 A

>=80 and <90 B

>=70 and <80 C

>=50 and <70 D

<50 Fail
Program:-
p = int(input("Enter your percentage"))
if p>=90 and p<=100:
print("Grade A")
elif p>=80 and p<90:
print("Grade B")
elif p>=70 and p<80:
print("Grade C")
elif p>=50 and p<70:
print("Grade D")
elif p<50:
print("Fail")
else:
print("Invalid Percentage")
Output:-
Enter your percentage56
Grade D

16.WAPP to accept a day number form the user then display its day name.
Program:-
d = int(input("Enter a day number(1-7)"))
if d==1:
print("Monday")
elif d==2:
print("Tuesday")
elif d==3:
print("Wednesday")
elif d==4:
print("Thursday")
elif d==5:
print("Friday")
elif d==6:
print("Saturday")
elif d==7:
print("Sunday")
else:
print("Invalid Day Number!")
Output:-
Enter a day number(1-7)5
Friday

17.WAPP to accept a character from the user then display whether it is


uppercase letter or lowercase letter or digit or a special character.
Program:-
char = input("Enter a character: ")
if char>='A' and char<='Z':
print("Uppercase letter")
elif char>='a' and char<='z':
print("Lowercase letter")
elif char>='0' and char<='9':
print("Digit")
else:
print("Special character")
Output:-
Enter a character: A
Uppercase letter

18.Write a Python program to input 3 sides of a triangle and print whether it


is an equilateral, scalene or isosceles triangle.
Program:-
side1 = float(input("Enter the length of side 1: "))
side2 = float(input("Enter the length of side 2: "))
side3 = float(input("Enter the length of side 3: "))
if side1 == side2 == side3:
print("Equilateral triangle")
elif side1 == side2 or side1 == side3 or side2 == side3:
print("Isosceles triangle")
else:
print("Scalene triangle")
Output:-
Enter the length of side 1: 12
Enter the length of side 2: 12
Enter the length of side 3: 12
Equilateral triangle

19.Ask the user to enter a temperature in Celsius. The program should print a
message based on the temperature:
If the temperature is less than -273.15, print that the temperature is
invalid because it is below absolute zero.
If it is exactly -273.15, print that the temperature is absolute 0.
If the temperature is between -273.15 and 0, print that the temperature is
below freezing.
If it is 0, print that the temperature is at the freezing point.
If it is between 0 and 100, print that the temperature is in the normal
range.
If it is 100, print that the temperature is at the boiling point.
If it is above 100, print that the temperature is above the boiling point.
Program:-
temp = float(input("Enter Temperature in Celsius: "))
if temp < -273.15 :
print("Temperature is invalid as it is below absolute zero")
elif temp == -273.15 :
print("Temperature is absolute zero")
elif -273.15 <= temp < 0:
print("Temperature is below freezing")
elif temp == 0 :
print("Temperature is at the freezing point")
elif 0 < temp < 100:
print("Temperature is in the normal range")
elif temp == 100 :
print("Temperature is at the boiling point")
else :
print("Temperature is above the boiling point")
Output:-
Enter Temperature in Celsius: 100
Temperature is at the boiling point
20.Write a short program to input a digit and print it in words.
Program:-
d = int(input("Enter a digit(0-9): "))
if d == 0 :
print("Zero")
elif d == 1 :
print("One")
elif d == 2 :
print("Two")
elif d == 3 :
print("Three")
elif d == 4 :
print("Four")
elif d == 5 :
print("Five")
elif d == 6 :
print("Six")
elif d == 7 :
print("Seven")
elif d == 8 :
print("Eight")
elif d == 9 :
print("Nine")
else :
print("Invalid Digit")
Output
Enter a digit(0-9): 6
Six

You might also like