CHINMAYA VIDHYALAYA
PALLAVUR
COMPUTER SCIENCE (083)
PRACTICAL FILES -2021-22
Submitted to: Submitted by:
Mrs: K Usha Baburaj Sreelakshmi Jayan
CHINMAYA VIDHYALAYA
PALLAVUR PALAKKAD
Subject……………………………………………………………………
Name of the Student……………………………………………………
Class………………………………………………………………………
Register Number………………………………………………
Certified that this is a bonafide record of Practical Work Done by
Sri/ Kumari …...…………………………………………………………
With Reg.no …………………………………….of the Year…………..
Date………..
Teacher in-charge Principal
Submitted for the practical Exam held on …………………………….
Date:……………………..
Signatures:
1) External examiner
2) Internal examiner
S.NO TOPIC Page No:
1. Greatest and smallest of two number 4
2. Greatest and smallest of 3 numbers 5
3. Star Pattern 6
4. Sum of the series 7
5. Fibonacci series 8
6. Perfect num and Angstrom 9
7. Prime or composite 10
8. Sum of the digits entered 11
9. Vowels or consonants 12
10. String palindrome 13
INDEX
1.Program to write program to input 3 numbers and find the
greatest of them
Source Code
num1=int(input("Enter the first number:"))
num2=int(input("Enter the second number:"))
if num1>num2:
print(num1,"is greater",num2,"is smaller")
else:
print(num2,"is greater",num1,"is smaller")
Output
Pg.4
2.Program find the largest and smallest among the 3 user accepted
numbers
Source Code
num1=int(input("Enter the first number:"))
num2=int(input("Enter the second number:"))
num3=int(input("Enter the third number:"))
if num1>num2 and num1>num3:
print(num1,"is the largest")
if num2>num3:
print(num3,"is the smallest")
else:
print(num2,"is the smallest")
elif num2>num3:
print(num2,"is the the largest")
if num1>num3:
print(num3,"is the smallest")
else:
print(num1,"is the smallest")
else:
print(num3,"is the largest")
if num1>num2:
print(num2,'is the smallest')
else:
print(num1,'is the smallest')
Output
Pg.5
3.Program to generate the following pattern using a nested loop
*
**
***
****
*****
Source Code:
num=int(input("Enter the number : "))
for i in range(1 ,num+1):
for j in range( 1 , i+1 ):
print("*" , end = " " )
print()
Output:
Pg.6
4.To input the value for x and n and print the sum of the given series
1+x+x^2+x^3+x^4……….+x^n
Source Code
sum=0
x=int(input("Enter the value of x : "))
n=int(input("Enter the value of n : "))
for i in range(0, n+1) :
sum=sum+(x**i)
print(sum)
Output
Pg.7
5.Program to print fibonacci series
Source code
n=int(input("enter the number:"))
a=0
b=1
print(a)
print(b)
for i in range(2,n):
c=a+b
a=b
b=c
print(c)
Output
Pg.8
6.Program to find the perfect number and armstrong number
Source Code
n=int(input('Enter the number:'))
y=n
sum1=0
def armstrong(n,y,sum1):
while n>0:
r=n%10
x=str(y)
r=r**len(x)
sum1=sum1+r
n=n//10
if sum1==y:
print(y,'is an armstrong number')
else:
print(y,'is not an armstrong number')
exit
armstrong(n,y,sum1)
def perfect(n):
factors = [i for i in range(2,n+1) if n%i == 0]
if sum( [1]+factors) == 2*n:
print(n," the number is a perfect number")
else:
print( n, "the number is not a perfect number")
perfect(n)
Output
Pg.9
7.Program to check whether the given number is prime number or
composite number
Source Code
n=int(input("enter the number :"))
for i in range(2,n):
if (n%i)==0:
print(n,"is not a prime number")
break
else:
print(n,"is a prime number")
Output
Pg.10
8.Program to find the sum of the two digits
Source Code
n=int(input("Enter a number:"))
sum=0
while(n>0):
r=n%10
n=n//10
sum=sum+r
print(sum)
Output
Pg.11
9.Program to count vowels or consonants
Source Code
str=input("Enter Your String: ")
v= 0
c=0
for i in str:
if(i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'
or i == 'A' or i == 'E' or i == 'I' or i == 'O' or i == 'U'):
v=v+1
else:
c=c+1
print("Number of Vowels = ",v)
print("Number of Consonants= ",c)
Output
Pg.12
10.Program to check whether a String is palindrome or not
Source Code
def Palindrome(s):
if s == s[::-1]:
print("The entered string is a pallindrome")
else:
print("The entered string is not a pallindrome")
s=input("Enter a string: ")
Palindrome(s)
Output
Pg.13