0% found this document useful (0 votes)
26 views13 pages

Ix Lab PGMS 24 25 250204 193427

The document outlines a series of Python programming exercises for Class IX students at Maharishi Vidya Mandir School in Chennai for the academic year 2024-2025. It includes 15 different programming tasks such as creating a biodata program, demonstrating data types, converting temperatures, and calculating the factorial of a number. Each task is accompanied by sample code and expected output to guide students in their learning.

Uploaded by

vmithun09102015
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)
26 views13 pages

Ix Lab PGMS 24 25 250204 193427

The document outlines a series of Python programming exercises for Class IX students at Maharishi Vidya Mandir School in Chennai for the academic year 2024-2025. It includes 15 different programming tasks such as creating a biodata program, demonstrating data types, converting temperatures, and calculating the factorial of a number. Each task is accompanied by sample code and expected output to guide students in their learning.

Uploaded by

vmithun09102015
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
You are on page 1/ 13

JAI GURU DEV

MAHARISHI VIDYA MANDIR SR. SEC. SCHOOL,CHETPET,CHENNAI-31

CLASS IX PYTHON RECORD PROGRAMS 2024-2025

Note :

Write the program in right side and output in the left side page (Plain page)

INDEX PAGE :

1. Write a python program to print your biodata.

2. Write a program to demonstrate different number datatypes in python.

3. Write a Python program to convert temperatures from Celsius to Fahrenheit.

4. Write a python program to compute a simple calculator.

5. Write a Program to Calculate Total Marks Percentage of a Student.

6. Write a program to accept radius of a sphere as input from the user. Write a program

to calculate the surface area and volume of a sphere using the radius provided.

7. Write a program to find whether given number is odd or even.

8. Write a program to find the factorial of a given number.

9. Write a program to take a string from the user, reverse the string and print it.

10. Write a program to display the pyramid of numbers.

11. Write a program to check whether the given number is a prime number or not.

12. Write a program to input a character and to print whether a given

character is an alphabet, digit or any other character.

13. Write a Python Program to Compute the Power of a Number.

14. Write a Python program to find the largest number among the three input numbers.

15. Write a program to create, append, remove, clear lists in python.


1. Write a python program to print your biodata.

CODE :

name=str(input("Enter your name :"))

age=int(input("Enter your age :"))

fname=str(input("Enter your father’s name :"))

mname=str(input ("Enter your mother’s name :"))

address=str(input("Enter your address :"))

pno=int(input("Enter your phone number :"))

print(" ")

print("Name:",name)

print("Age:",age)

print("Phone Number:",pno)

print("Address:",address)

print("Mothers name:",mname)

print("Fathers name:",fname)

OUTPUT:
Enter your name :SIVA
Enter your age :30
Enter your father’s name :SANKAR
Enter your mother’s name :PARVATHY
Enter your address :NO 2 CHITLAPAKKAM
Enter your phone number :9777673820

Name: SIVA
Age: 30
Phone Number: 9777673820
Address: NO 2 CHITLAPAKKAM
Mothers name: PARVATHY
Fathers name: SANKAR
2. Write a program to demonstrate different number datatypes in python.

CODE :

i=7
c=24+8j
f=70.1
s='HELLO EVERYONE!!'
b= True
print("The value of i is:",i,'\n Its type is:',type(i))
print("The value of c is:",c,'\n Its type is:',type(c))
print("The value of f is:",f,'\n Its type is:',type(f))
print("The value of s is:",s,'\n Its type is:',type(s))
print("The value of b is:",b,'\n Its type is:',type(b))

OUTPUT:
The value of i is: 7
Its type is: <class 'int'>
The value of c is: (24+8j)
Its type is: <class 'complex'>
The value of f is: 70.1
Its type is: <class 'float'>
The value of s is: HELLO EVERYONE!!
Its type is: <class 'str'>
The value of b is: True
Its type is: <class 'bool'>
3. Write a Python program to convert temperatures from Celsius to Fahrenheit.
CODE :

print("Convert temperatures from Celsius to Fahrenheit \n")


cel = float(input("Enter Temperature in Celsius: "))
fahr = (cel*9/5)+32
print("Temperature in Fahrenheit =",fahr)

OUTPUT:
Convert temperatures from Celsius to Fahrenheit

Enter Temperature in Celsius: 40


Temperature in Fahrenheit = 104.0
4. Write a python program to compute a simple calculator.

CODE:

num1 = float(input("Enter first number: "))


num2 = float(input("Enter second number: "))
# choose an operation

print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

select = input("Select operation(1/2/3/4): ")

# check operations and display result


# add(+) two numbers

if select == "1":

print(num1, "+", num2, "=", num1+num2)


# subtract(-) two numbers

elif select == "2":

print(num1, "-", num2, "=", num1-num2)


# multiplies(*) two numbers

elif select == "3":

print(num1, "*", num2, "=", num1*num2)


# divides(/) two numbers

elif select == "4":

print(num1, "/", num2, "=", num1/num2)


else:

print("Invalid Input")

OUTPUT
Enter first number: 45
Enter second number: 23
Select operation.
1.Add
2.Subtract
3.Multiply
4.Divide
Select operation(1/2/3/4): 3
45.0 * 23.0 = 1035.0
5. Write a Program to Calculate Total Marks Percentage of a Student.
CODE:
print("Enter the marks of five subjects::")
subject_1 = float (input ("Enter marks of English:"))
subject_2 = float (input ("Enter marks of II Language:"))
subject_3 = float (input ("Enter marks of Mathematics:"))
subject_4 = float (input ("Enter marks of Science:"))
subject_5 = float (input ("Enter marks of Social Science:"))
total, average, percentage = None, None, None
total = subject_1 + subject_2 + subject_3 + subject_4 + subject_5
average = total / 5.0
percentage = (total / 500.0) * 100
print ("\n The Total marks is:\t", total, "/ 500.00")
print ("\n The Average marks is:\t", average)
print ("\n The Percentage is:\t", percentage, "%")

OUTPUT:
Enter the marks of five subjects::
Enter marks of English:40
Enter marks of II Language:45
Enter marks of Mathematics:40
Enter marks of Science:48
Enter marks of Social Science:50

The Total marks is: 223.0 / 500.00


The Average marks is: 44.6
The Percentage is: 44.6 %
6. Write a program to accept radius of a sphere as input from the user. Write
a program to calculate the surface area and volume of a sphere using the
radius provided.
code:
r = float(input("Enter radius of the sphere: "))
pi_v=3.14
sa=4*pi_v * r**2
v = 4 / 3 *pi_v * r ** 3
print("The surface area of a sphere with the radius", r , "is", sa)
print("Volume of sphere = ", v)

OUTPUT:
Enter radius of the sphere: 5
The surface area of a sphere with the radius 5.0 is 314.0
Volume of sphere = 523.3333333333334

7. Write a program to find whether given number is odd or even


Code:
num = int(input("Enter a number: "))
if (num % 2) == 0:
print(num, "is even number")
else:
print(num, "is odd number")

OUTPUT:
Enter a number: 4
4 is even number
Enter a number: 3
3 is odd number
8. Write a program to find the factorial of a given number
Code:
num=int(input('Enter the no. to print its factorial: '))
n=num

res=1
while n>0:

res*=n
n-=1

print('Factorial of',num,'is: ',res)

OUTPUT:

Enter the no. to print its factorial: 5


Factorial of 5 is: 120

9. Write a program to take a string from the user, reverse the string and print
it.
CODE:

Word= input(“enter the word to reverse: ”)


for char in range(len(word)-1,-1,-1):
print(word[char],end=””)
print(“The reversed word is:”)
print(“\n”)
OUTPUT:

Enter the word to reverse: Hello


The reversed word is : olleH

10. Write a program to display the pyramid of


numbers. CODE:
r = int(input("Enter number of rows: "))
for i in range(r):

for j in range(i+1):
print(j+1, end=" ")
print("\n")
OUTPUT:
Enter number of rows: 3
1

12

123

11. Write a program to check whether the given number is a prime number
or not.
CODE:
num = int(input("Enter a number : "))
# If given number is greater than 1
if num > 1:
# Iterate from 2 to n / 2
for i in range(2, int(num/2)+1):
# If num is divisible by any number between
# 2 and n / 2, it is not prime
if (num % i) == 0:
print(num, "is not a prime number")
break
else:
print(num, "is a prime number")
else:
print(num, "is not a prime number")

OUTPUT:
Enter a number : 344
344 is not a prime number
Enter a number : 11
11 is a prime number
12. Write a program to input a character and to print whether a given

character is an alphabet, digit or any other character.


CODE:
ch=input("Enter a character: ")
if ch.isalpha():

print(ch, "is an alphabet")


elifch.isdigit():

print(ch, "is a digit")


elifch.isalnum():

print(ch, "is alphabet and numeric")


else:

print(ch, "is a special symbol")

OUTPUT:

Enter a character: b
b is an alphabet

Enter a character:4
4 is a digit

Enter a character:&

& is a special symbol

13. Write a Python Program to Compute the Power of a Number.


CODE:
base = int(input("Enter the value of base: "))
exp = int(input("Enter the value of exponent: "))
result = 1

while exp != 0:
result *= base
exp -=1

print("Answer = " + str(result))

OUTPUT:

Enter the value of base: 3


Enter the value of exponent: 2
Answer = 9
14. Write a Python program to find the largest number among the three input
numbers.
PROGRAM:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))

if (num1 >= num2) and (num1 >= num3):


largest = num1

elif (num2 >= num1) and (num2 >= num3):


largest = num2

else:

largest = num3

print("The largest number is", largest)

OUTPUT:
Enter first number: 5
Enter second number: 4
Enter third number: 8
The largest number is 8.0
15. Write a program to create, append, remove, clear lists in python.
PROGRAM :
Bikes =["Cruiser", "Kawasaki", "Royal Enfield", "Pulsar", "Jawa"]
Cars=["Chevrolet", "Porsche", "Audi", "Ferrari", "Rolls-Royce"]
print("Bikes are :",Bikes)
print("Cars are :",Cars)
Vehicles=Bikes+Cars
print("Vehicles are :",Vehicles)
Cars.remove("Porsche")

print("Updated Cars are :",Cars)


Bikes.pop()
print("Updated Bikes are :",Bikes)
Vehicles.clear()
print("Empty List:",Vehicles)
OUTPUT:
Bikes are : ['Cruiser', 'Kawasaki', 'Royal Enfield', 'Pulsar', 'Jawa']
Cars are : ['Chevrolet', 'Porsche', 'Audi', 'Ferrari', 'Rolls-Royce']
Vehicles are : ['Cruiser', 'Kawasaki', 'Royal Enfield', 'Pulsar', 'Jawa', 'Chevrolet',
'Porsche', 'Audi', 'Ferrari', 'Rolls-Royce']
Updated Cars are : ['Chevrolet', 'Audi', 'Ferrari', 'Rolls-Royce']
Updated Bikes are : ['Cruiser', 'Kawasaki', 'Royal Enfield', 'Pulsar']
Empty List: []

You might also like