0% found this document useful (0 votes)
13 views3 pages

Class9 Programs

The document contains a series of Python programs designed for Class 9 students. These programs cover various topics such as calculating the surface area and volume of a cuboid, converting height from centimeters to feet and inches, checking voting eligibility, identifying the greatest of three numbers, and more. Each program includes user input and outputs results based on the provided data.

Uploaded by

xgsnappy.07
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)
13 views3 pages

Class9 Programs

The document contains a series of Python programs designed for Class 9 students. These programs cover various topics such as calculating the surface area and volume of a cuboid, converting height from centimeters to feet and inches, checking voting eligibility, identifying the greatest of three numbers, and more. Each program includes user input and outputs results based on the provided data.

Uploaded by

xgsnappy.07
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/ 3

Class 9 Python Programs

Write a program to calculate the surface area and volume of cuboid.


# Program to calculate surface area and volume of a cuboid
l = float(input("Enter length: "))
w = float(input("Enter width: "))
h = float(input("Enter height: "))

surface_area = 2 * (l*w + w*h + h*l)


volume = l * w * h

print("Surface Area:", surface_area)


print("Volume:", volume)

Write a program to ask for height in centimeters and convert it into feet and
inches.
# Program to convert height in cm to feet and inches
cm = float(input("Enter height in cm: "))
inches = cm / 2.54
feet = int(inches // 12)
remaining_inches = inches % 12

print("Height:", feet, "feet", round(remaining_inches, 2),


"inches")

Write a program to check whether the applicant is eligible to vote in the


elections or not.
# Program to check voting eligibility
age = int(input("Enter age: "))
if age >= 18:
print("Eligible to vote.")
else:
print("Not eligible to vote.")

Write a program to check whether the entered number is positive and even,
positive and odd, negative and even, or negative and odd.
# Program to check number type (positive/negative and even/odd)
num = int(input("Enter a number: "))
if num > 0:
if num % 2 == 0:
print("Positive and Even")
else:
print("Positive and Odd")
elif num < 0:
if num % 2 == 0:
print("Negative and Even")
else:
print("Negative and Odd")
else:
print("Number is Zero")

Write a program to input three numbers and find the Greatest number.
# Program to find greatest of 3 numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

print("Greatest number is:", max(a, b, c))

Write a program to input week day number and display its corresponding day
name.
# Program to find day of week
day = int(input("Enter weekday number (1-7): "))
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Saturday", "Sunday"]

if 1 <= day <= 7:


print("Day is:", days[day-1])
else:
print("Invalid input")

Write a program to input a number and find its table.


# Program to print multiplication table
num = int(input("Enter a number: "))
for i in range(1, 11):
print(num, "x", i, "=", num*i)

Write a program to find the sum of even numbers and odd numbers separately
from 1 to 10.
# Program to find sum of even and odd numbers from 1 to 10
sum_even = 0
sum_odd = 0
for i in range(1, 11):
if i % 2 == 0:
sum_even += i
else:
sum_odd += i
print("Sum of even numbers:", sum_even)
print("Sum of odd numbers:", sum_odd)

Write a program to input two numbers and find their HCF.


# Program to find HCF of two numbers
import math

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

print("HCF is:", math.gcd(a, b))

Write a program to input a number and display whether it is a palindrome or


not.
# Program to check if number is palindrome
num = input("Enter a number: ")
if num == num[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

Write a program to check whether the entered number is even or odd.


# Program to check even or odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even number")
else:
print("Odd number")

Write a program to find the sum of all number stored in a list.


# Program to find sum of numbers in a list
numbers = [int(x) for x in input("Enter numbers separated by
space: ").split()]
print("Sum of numbers:", sum(numbers))

You might also like