[go: up one dir, main page]

0% found this document useful (0 votes)
29 views15 pages

Practical File Navaneeth

This document is a practical file for Computer Science submitted by a student at Chinmaya Vidyalaya for the academic year 2020-2021. It includes various programming exercises such as finding the greatest and smallest numbers, generating Fibonacci series, and checking for prime numbers, along with source code and output screenshots for each program. The file is structured with an index and certification sections for submission to examiners.

Uploaded by

ushavalsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views15 pages

Practical File Navaneeth

This document is a practical file for Computer Science submitted by a student at Chinmaya Vidyalaya for the academic year 2020-2021. It includes various programming exercises such as finding the greatest and smallest numbers, generating Fibonacci series, and checking for prime numbers, along with source code and output screenshots for each program. The file is structured with an index and certification sections for submission to examiners.

Uploaded by

ushavalsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CHINMAYA VIDYALAYA

PALLAVUR

COMPUTER SCIENCE
PRACTICAL FILE 2020-2021

Submitted to: Submitted by:

Mrs. USHA BHABURAJ P.NAVANEETHAKRISHNAN


CHINMAYA VIDYALAYA
PALLAVUR-PALAKKAD

PRACTICAL FILE
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: ……………………………………………………………………… in the year………....…………………………

Date……………......

Teacher in-charge Principal


------------------------------------------------------------------------------------

Submitted for the practical Exam held in march………………..…………………….

Date …………………….

Signatures:

1 . EXTERNAL EXAMINER

2 . INTERNAL EXAMINER
INDEX

S.NO TOPICS Page no:


1. Greatest and smallest of two numbers 4

2. Greatest and smallest of three numbers 5

3. Star Pattern 6

4. Sum of series 7

5. Fibonacci series 8

6. Perfect Number and Armstrong Number 9

7. Prime or composite 10

8. Sum of digits 11

9. Count the no: of vowels and consonants 12

10. String palindrome 13

1.Program to find the Greatest and Smallest of two numbers


SOURCE CODE:
num1=int(input("Enter the first number"))

num2=int(input("Enter the second number"))

if num1>num2:

print("num1 is the greatest")

else:

print("num2 is the smallest")

OUTPUT SCREENSHOT:

4|Page

2.Program to find the Greatest and Smallest of three 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 smallest")

else:

print(num2,"is smallest")

elif num2>num3:

print(num2,"is the largest")

if num1>num3:

print(num3,"is smallest")

else:

print(num1,"is smallest")

else:

print(num3,"is the largest")

if num1>num2

print(num2,"is the smallest")

else:

print(num1,"is the smallest'")

OUPUT SCREENSHOT:
5|Page

3.Program to print Star pattern

SOURCE CODE:
num=int(input("Enter a number : "))

for i in range(1 ,num+1):

for j in range( 1 , i+1 ):

print("*" , end = " " )

print()

OUTPUT SCREENSHOT:
6|Page

4. Program to print the Sum of the series 1+x+x^2+x^3....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 SCREENSHOT:
7|Page

5. Program to print Fibonnaci series

SOURCE CODE:
num=int(input("Enter the number"))

a=0

b=1

print(a)

print(b)

for i in range(2,num):

c=a+b

b=c

print(c)

OUTPUT SCREENSHOT:
8|Page

6. Program to find Perfect number and Armstrong number

SOURCE CODE:
n=int(input('Enter the number : '))

y=n

sum1=0

s=0

j=n

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,s,j):

for i in range(1,n):

if n%i==0:

s=s+i

if s==j:

print("perfect")

else:

print("not perfect")

perfect(n,s,j)

OUTPUT SCREENSHOT:
9|Page

7. Program to check whether a number is prime or composite

SOURCE CODE:
num= num1=int(input("Enter the value"))

for i in range(2,num1):

rem=num1%i

if(rem==0):

print("num1 is composite")

else:

print("num1 is prime")

OUTPUT SCREENSHOT:
10|Page

8. Program to find the sum of digits

SOURSE CODE:

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

tot=0

while(n>0):

dig=n%10

tot=tot+dig

n=n/10

print("the total sum of digits",tot)

OUTPUT SCREENSHOT:
11|Page

9. Program to count the Vowels and consonants of a string

SOURCE CODE:
str=input(" Enter The String : ")

vowels = 0

consonants = 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'):

vowels = vowels + 1

else:

consonants = consonants + 1

print("Total Number of Vowels in this String = ", vowels)


print("Total Number of Consonants in this String = ", consonants)

OUTPUT SCREENSHOT:

12|Page

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 : ")

OUTPUT SCREENSHOT:

You might also like