STD Xi Comp Sci Practical Report File

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

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:
11. WAP to find the factorial of a number

Code:

n=int(input("Enter number:"))
fact=1
while(n>0):
fact=fact*n
n=n-1
print("Factorial of the number is: ")
print(fact)

SAMPLE OUTPUT:
12. 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:
13. Write Python program to Display the terms of a Fibonacci
series.

Code:

Number = int(input("\nPlease Enter the Range Number: "))

# Initializing First and Second Values of a Series

First_Value = 0

Second_Value = 1

# Find & Displaying Fibonacci series

for Num in range(0, Number):

if(Num <= 1):

Next = Num

else:

Next = First_Value + Second_Value

First_Value = Second_Value

Second_Value = Next

print(Next)

SAMPLE OUTPUT:
14. WAP to print the following series:

(i) 1 4 7 10. . . . . . . 40

(ii) 1 -4 7 -10 . . . . . . . - 40

Code:

print("First Series:")

for i in range(1, 41, 3) :

print(i, end = ' ')

print("\nSecond Series:")

x=1

for i in range(1, 41, 3) :

print(i * x, end = ' ')

x *= -1

SAMPLE OUTPUT:
15. WAP to determine whether a number is a palindrome.

Code:

n=int(input("Enter number:"))

temp=n

rev=0

while(n>0):

dig=n%10

rev=rev*10+dig

n=n//10

if(temp==rev):

print("The number is a palindrome!")

else:

print("The number isn't a palindrome!")

SAMPLE OUTPUT:
16. Write a Program to take in the marks of 5 subjects and
display the grade.

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
if(avg>=90):
print("Grade: A")
elif(avg>=80 and avg<90):
print("Grade: B")
elif(avg>=70 and avg<80):
print("Grade: C")
elif(avg>=60 and avg<70):
print("Grade: D")
else:
print("Grade: F")

SAMPLE OUTPUT:
17. WAP to check the given year is leap year or not

Code:

year = int(input("Enter a year: "))


if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))

SAMPLE OUTPUT:
18. WAP to Determine whether a number is a perfect number.

Code:

n = int(input("Enter any number: "))

sum1 = 0

for i in range(1, n):

if(n % i == 0):

sum1 = sum1 + i

if (sum1 == n):

print("The number is a Perfect number!")

else:

print("The number is not a Perfect number!")

SAMPLE OUTPUT:
19. WAP to determine whether a number is an armstrong number.

Code:

import math
print ("Enter the a number")
number = int(input())
#to calculate the number of digits in a number
number_of_digits = int(math.log10(number))+1
sum_arm = 0
temp = number

while temp != 0:
sum_arm = sum_arm + int(math.pow (temp%10,number_of_digits))

temp = temp//10
if sum_arm == number:
print ("Yes an Armstrong number")
else:
print ("No")

SAMPLE OUTPUT:
20. WAP to Input a number and check if the number is a prime or
composite number.

Code:

import math

print ("Enter the a number")

number = int(input())

i=2

prime = True

#if the number is not divisible by any number less than the
#square root of the number

#then it is prime

while i <= int(math.sqrt(number)):

if number%i == 0:

prime = False

break

i = i+1

if number < 2:

prime = False

if prime:

print (number,"is a prime number")

else:

print (number,"is not a prime number")

SAMPLE OUTPUT:
21. Write a Menu-Driven Program to create a simple calculator

Code:

# Menu-Driven Program to create a simple calculator

print("WELCOME TO A SIMPLE CALCULATOR")

# using the while loop to print menu list

while True:

print("\nMENU")

print("1. Sum of two Numbers")

print("2. Difference between two Numbers")

print("3. Product of two Numbers")

print("4. Division of two Numbers")

print("5. Exit")

choice = int(input("\nEnter the Choice: "))

# using if-elif-else statement to pick different options

if choice == 1:

print( "\nADDITION\n")

a = int( input("First Number: "))

b = int( input("Second Number: "))

sum = a + b

print(a, "+", b, "=", sum)

elif choice == 2:

print( "\nSUBTRACTION\n")

a = int( input("First Number: "))

b = int( input("Second Number: "))

difference = a - b

print(a, "-", b, "=", difference)


elif choice == 3:

print( "\nMULTIPLICATION\n")

a = int( input("First Number: "))

b = int( input("Second Number: "))

product = a * b

print(a, "x", b, "=", product)

elif choice == 4:

print( "\nDIVISION\n")

a = int( input("First Number: "))

b = int( input("Second Number: "))

division = a / b

print(a, "/", b, "=", division)

elif choice == 5:

break

else:

print( "Please Provide a valid Input!")

SAMPLE OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy