0% found this document useful (0 votes)
19 views10 pages

CS Practical-11

computer science

Uploaded by

hitharesmi07
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)
19 views10 pages

CS Practical-11

computer science

Uploaded by

hitharesmi07
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/ 10

ANGELS ARC SENIOR SECONDARY SCHOOL, KAYAMKULAM

COMPUTER SCIENCE

Grade: XI

PRACTICAL PROGRAM

PROGRAM 1
AIM: Write a program to find Simple Interest
SOURCE CODE:
P= float(input("Enter a Principle Amount: "))
R= float(input("Enter a Rate of Interest: "))
T= float(input("Enter the Time: "))
SI=(P*R*T)/100
print("Principle= ",P,"Rate=",R,"Time=",T)
print("Simple Interest =", SI)
PROGRAM 2
AIM: Write a program to convert Celsius to Fahrenheit.
SOURCE CODE:
c=float(input("Enter temperature in Celsius: "))
f=c*9/5+32
print("Celsius=",c)
print("Temperature in Farenheit is :")
print("F=",f)
PROGRAM 3
AIM: Write a program to display a menu for calculating area of
circle or perimeter of circle.
SOURCE CODE:
r= float(input("Enter the radius:"))
print("1. Area of Circle")
print("2. Perimeter of Circle")
ch=int(input("Enter the choice:"))
if ch==1:
area=3.14*r*r
print("Area of Circle=",area)
elif ch==2:
per=2*3.14*r
print("Perimeter of Circle=",per)
else:
print("Invalid Choice")
PROGRAM 4
AIM: Write a program to find largest of 3 numbers.
SOURCE CODE:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if num1 > num2:
if num1 > num3:
print(num1, "is greater")
else:
print(num3, "is greater")
elif num2 > num3:
print(num2, "is greater")
else:
print(num3, "is greater")
PROGRAM 5
AIM: Write a program to find the factorial of a given number?
SOURCE CODE:
n=int(input("Enter a number: "))
fac=1
i=1
while i<=n:
fac= fac*i
i=i+1
print("Factorial of the number= ",fac)
PROGRAM 6
AIM:Write a program to check whether the number entered is an
Armstrong or not.
SOURCE CODE:
n=int(input("Enter the number"))
s=0
r=0
x=n
while n>0:
r=n%10
s=s+(r*r*r)
n=n//10
if x==s:
print(s,": The number is Armstrong")
else:
print(s,": The number is not Armstrong")
PROGRAM 7
AIM: Write a program to check a number is divisible by another.
SOURCE CODE:
a=int(input("Enter the number: "))
b=int(input("Enter the number: "))
if a % b ==0:
print(a,"is divisible by",b)
else:
print(a,"is not divisible by",b)
PROGRAM 8
AIM:Write a program to find reverse of a given number.
SOURCE CODE:
n=int(input("Enter a value: "))
r=0
rev=0
while n>0:
r=n%10
rev=rev*10+r
n=n//10
print("Reverse=",rev)
PROGRAM 9
AIM: Write a program to print the pattern:
*
**
***
****
*****
SOURCE CODE:
for i in range(1,6):
for j in range(1,i+1):
print('*',end=' ')
print()
PROGRAM 10
AIM: Write a program to print the pattern:
4321
432
43
4
SOURCE CODE:
for i in range(1,5):
for j in range(4,i-1,-1):
print(j,end=' ')
print()
PROGRAM 11
AIM:Write a program that reads a line. Then counts words and
display how many words are in the line.
SOURCE CODE:
s=input("Enter the line: ")
x=s.split()
c=0
for i in x:
c=c+1
print(c)

PROGRAM 12
AIM: Write a program to find minimum element from a list of
element along with its index in the list.
SOURCE CODE:
l=eval(input("Enter the list: "))
length=len(l)
min=l[0]
min_index=0
for i in range(1,length):
if l[i]<min :
min=l[i]
min_index=i
print("Given list is :",l)
print("The minimum element of the given list: ", min)
print("at index",min_index)
PROGRAM 13
AIM: Write a program to find mean of a given list of numbers
SOURCE CODE:
l=eval(input("Enter the list: "))
length=len(l)
mean=sum=0
for i in range(0,length):
sum+=l[i]
mean=sum/length
print("Given list is :",l)
print("The mean of the given list is: ", mean)
PROGRAM 14
AIM: Write a program that takes any two list l and m of the
same size and adds their elements together to form a new list n
whose element are sum of the corresponding elements in l and
m.
SOURCE CODE:
lst1 = eval(input("enter first list = "))
lst2 = eval(input("enter second list = "))
lst3 = [ ]
for i in range(len(lst1)):
lst3 = lst3 + [ lst1 [ i ] + lst2 [ i ] ]
print("new list = ",lst3)
PROGRAM 15
AIM:Write a program to check if a number is present in the list
or not. If the number is present, print the position of the number.
Print an appropriate message if the number is not present in the
list.
SOURCE CODE:
lst = eval(input("Enter first list :-"))
num = int(input("Enter the number which you
want to search :-"))
if num in lst :
print(lst.index( num ) )
else :
print("Number not found")
PROGRAM 16
AIM:Write a program that Ask the user to enter a list containing
numbers between 1 and 12 then replace all of the entries in the
list that are greater than 10 with 10.
SOURCE CODE:

a = eval(input ("Enter the list ="))

for i in range(len(a)) :

if a[i] > 10 :

a[i] = 10

print ("new list ",a)


PROGRAM 17
AIM: Write a program to input n numbers from the user. Store
these numbers in a tuple. Print the maximum and minimum
number from this tuple.
SOURCE CODE:
tup= ()
while True :
num = int(input("Enter a number :- "))
tup += (num,)
user = input("Do you want to quit enter yes =")
if user == "yes":
print(tup)
print("Max :-",max( tup ))
print("Min :-",min( tup ))
break
PROGRAM 18
AIM: Write a program to create a nested tuple to store roll
number, name and marks of students.
SOURCE CODE:
tup= ()
while True :
roll = int(input("Enter a roll number :- "))
name = input("Enter name :-")
mark = int(input("Enter marks :-"))
tup += ( (roll,name,mark ),)
user = input("Do you want to quit enter yes =")
if user == "yes":
print(tup)
break
PROGRAM 19
AIM: Write a program to swap value of 2 tuples
SOURCE CODE:
t1=tuple()
n=int(input("Total number of values on first tuple: "))
for i in range(n):
a=int(input("Enter elemnt:"))
t1=t1+ (a,)
t2=tuple()
m=int(input("Total number of values on second tuple: "))
for i in range(m):
a=int(input("Enter elemnt:"))
t2=t2+ (a,)
print("First tuple:")
print(t1)
print("Second tuple:")
print(t2)
t1,t2=t2,t1
print("After Swapping: ")
print("First tuple:")
print(t1)
print("Second tuple:")
print(t2)
PROGRAM 20
AIM:Write a program in Python to input ‘n’ names and phone
number to store it in a dictionary and print the phone number of a
particular name.
SOURCE CODE:
phone= dict()
i=1
n=int(input("Enter number of entries:"))
while i<=n:
a=input("Enter name: ")
b=input("Enter phone number: ")
phone[a]=b
i=i+1
l=phone.keys()
x=input("Enter name to be searched:")
for i in l:
if i==x:
print(x,":Phone number is:",phone[i])
break;
else:
print(x,"doesnot exist")
PROGRAM 21
AIM: Write a program to input names of n employees and their
salary details like basic salary, house rent and conveyance
allowance. Calculate total salary of each employee and display.
SOURCE CODE
d1=dict()
i=1
n=int(input("Enter number of entries:"))
while i<=n:
nm=input("Enter name of employees: ")
basic=int(input("Enter Salary: "))
hra=int(input("Enter House Rent: "))
ca=int(input("Enter Conveyance Allowance: "))
d1[nm]=[basic,hra,ca]
i=i+1
l=d1.keys()
print("\n Name","\t Net Salary")
for i in l:
Salary=0
z=d1[i]
for j in z:
Salary=Salary +j
print(i,'\t\t',Salary)

You might also like