0% found this document useful (0 votes)
2 views4 pages

Class - Ix Practicals Python

The document contains a series of Python programming exercises for Class IX practicals. Each program demonstrates basic programming concepts such as input/output, arithmetic operations, and list manipulation. The exercises include calculating sums, converting temperatures, computing areas, and handling student details.

Uploaded by

miprakush
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)
2 views4 pages

Class - Ix Practicals Python

The document contains a series of Python programming exercises for Class IX practicals. Each program demonstrates basic programming concepts such as input/output, arithmetic operations, and list manipulation. The exercises include calculating sums, converting temperatures, computing areas, and handling student details.

Uploaded by

miprakush
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/ 4

CLASS_IX (PRACTICALS PYTHON)

# PROGRAM-1 : Program to obtain three numbers and print their sum.


Ans Code:
num1 = int (input('Enter number 1 :'))
num2 = int (input('Enter number 2:'))
num3 = int (input('Enter number 3 :'))
sum = num1+ num2+ num3
print ('Three numbers are:' ,num1, num2, num3)
print ('their sum is :',sum)
OUTPUT-

# PROGRAM-2 : Write a program to obtain temperature in Celsius and convert it into Fahrenheit using formula

Ans Code:
cels=float(input("enter temp in celsius:"))
print ("Temprature in celsius is:",cels)
Farh = cels*9/5+32
print ("Temprature in fahrenheit is:",Farh)
OUTPUT-

# PROGRAM-3 : Program to obtain length and breadth of a rectangle and calculate its area.

Ans Code:
length= float(input("Enter length of the rectangle:"))
breadth= float(input("Enter breadth of the rectangle:"))
area = length * breadth
print("Rectangle specifications")
print("length=",length)
print("breadth=",breadth)
print("area=",area)
OUTPUT-
# PROGRAM-4 : Write a python program that accepts radius of a circle and prints its area.

Ans Code:
radius = float(input("Enter radius of circle: "))
area = 3.14159 * radius * radius
print("Area of circle =", area)

OUTPUT-

# PROGRAM-5 : Write a python program that accepts marks in 5 subjects and outputs average marks.

Ans Code:
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-

# PROGRAM-6 : Write a python program to compute simple interest and compound interest.

Ans Code:
p = float(input("Enter principal: "))
r = float(input("Enter rate: "))
t = int(input("Enter time: "))
si = (p * r * t) / 100
ci = p * ((1 + (r / 100 ))** t) - p
print("Simple interest = ", si)
print("Compound interest = ", ci)
OUTPUT-
# PROGRAM-7 : Write a python program to read details like name, class, age of a student and then print details firstly
in same line and then in separate lines.

Ans Code:
n = input("Enter name of student: ")
c = int(input("Enter class of student: "))
a = int(input("Enter age of student: "))
print("Name:", n, "Class:", c, "Age:", a)
print()
print()
print("Name:", n)
print("Class:", c)
print("Age:", a)

OUTPUT-

# PROGRAM-8: Take the list --- animals = [‘cat’, ’dog’, ’mouse’ ,’hamster’]

i) Print out each item in the list using a for loop.

ii) Print the first animal in the animals list.(with using positive index)

iii) Print the last animal in the animals list (with using negative index)
Ans Code:
animals = [‘cat’, ’dog’, ’mouse’ ,’hamster’]
for one in animals:
print(one)
print (animals[0]) #first element
size = len(animals)
print(animals[-1]) #last element
OUTPUT-
# PROGRAM-9: Take the list --- animals = [‘cat’, ’dog’, ’mouse’ ,’hamster’]

i) Print out each item in the list using a for loop.

ii) Print the first animal in the animals list.(with using negative index)

iii) Print the last animal in the animals list (with using positive index)
Ans Code:
animals = [‘cat’, ’dog’, ’mouse’ ,’hamster’]
for one in animals:
print(one)
size = len(animals)
print (animals[-size]) #first element
print(animals[size-1]) #last element

# PROGRAM- 10 Create a list namely test having at least 3 integers, 2 floating point numbers and two strings.

(i) print the first element from the list.


(ii) print the last element from the list.
(iii)print the second element.

Ans Code:

test=list((2,5,7,9.8,7.6,"apple","kiwi"))

print(test)
print(test[0]) #first element
print(test[-1]) #last element
print(test[1]) #2nd element

You might also like