You are on page 1of 8

COMPUTER SCIENCE

2023-24

NAME:
ROLL NO:
CLASS: XI
STREAM:
NERUL, NAVI MUMBAI

CERTIFICATE

This is to certify that this computer practical file has been


completed by ____________________ of class XI
Science/Commerce, in partial fulfillment of the
curriculum of the Central Board of Secondary Education
leading to the award of All India Senior School
Certificate for the year 2023-24.

Roll No. :

__________________
Internal Examiner
Date:

__________________ ___________________
SCHOOL SEAL PRINCIPAL
Date:
PYTHON PROGRAMS

1. WAP to Input a welcome message and display it.

Code:

msg=input("Enter a welcome message"))

print(msg)

SAMPLE OUTPUT:

2. WAP to Input two numbers and display the smaller number.

Code:

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


num2 = float(input("Enter second number: "))
if (num1 < num2):
print("The smallest number is", num1)
else:
print("The smallest number is", num2)

SAMPLE OUTPUT:
3. Write Python program to print the area of circle when radius
of the circle is given by user.

Code:

radius=float(input("Enter radius of circle"))

PI=3.14

area = PI*radius**2

print("The area of circle is: ", area)

SAMPLE OUTPUT:

4. Write Python program that accepts marks in 5 subjects and


outputs average marks.

Code:

sub1=int(input("Enter marks of the first subject: "))


sub2=int(input("Enter marks of the second subject: "))
sub3=int(input("Enter marks of the third subject: "))
sub4=int(input("Enter marks of the fourth subject: "))
sub5=int(input("Enter marks of the fifth subject: "))

avg=(sub1+sub2+sub3+sub4+sub4)/5

print("The average of 5 subjects is ", avg)

SAMPLE OUTPUT:
5. Write a short program that asks for your height in centimetres
and then converts your height to feet and inches. (1 foot = 12
inches, 1 inch = 2.54 cm).

Code:

h = float(input('Enter your height in centimetres : '))

h = h/2.54 # height in inches

print('Height is', h//12, 'feets and', h%12, 'inches')

SAMPLE OUTPUT:
6. Write Python program to compute simple interest and
compound interest.

Code:

#simple interest
P = float(input("enter amount"))
R = float(input("enter rate"))
T = float(input("enter time"))

SI = (P * R * T) / 100
print("simple interest is", SI)

#Compound Interest
principle=float(input("Enter principle amount:"))
time=int(input("Enter time duration:"))
rate=float(input("Enter rate of interest:"))

amount = (principle * (1 + (float(rate)/100))**time)


compound_interest=amount-principle

print("Total amount:- ",amount)


print("Compound interest:- ",compound_interest)

SAMPLE OUTPUT:
7. Write Python program to calculate the Area of a Triangle
(given base and height)

Code:

b = float(input('Enter base of a triangle: '))

h = float(input('Enter height of a triangle: '))

area = (b * h) / 2

print('The area of the triangle is %0.2f' % area)

SAMPLE OUTPUT:

8. WAP to Input three numbers and display the largest number.

Code:

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)

SAMPLE OUTPUT:
9. Write Python program to convert Celsius into Fahrenheit.

Code:

celsius = int(input("Enter the Temperature in Celsius :\n"))

fahrenheit = (1.8 * celsius) + 32

print("Temperature in Fahrenheit :", fahrenheit)

SAMPLE OUTPUT:

10. Write Python program to convert Fahrenheit into Celsius.

Code:

temperature = float(input("Please enter temperature in fahrenheit:"))

celsius = (temperature - 32) * 5 / 9

print("Temperature in celsius: " , celsius)

SAMPLE OUTPUT:

You might also like