0% found this document useful (0 votes)
9 views

XI CS practical programs

The document outlines the mark distribution for the XI Computer Science practical exam, totaling 30 marks, with specific allocations for Python practicals, record notes, viva voce, and project reports. It includes a list of 12 Python practical programs with coding examples and expected outputs, covering topics such as area and circumference of a circle, finding the greatest of four numbers, calculating factorials, generating Fibonacci series, and more. Each program is accompanied by coding instructions and sample outputs to illustrate functionality.

Uploaded by

ravijayalaxmi008
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)
9 views

XI CS practical programs

The document outlines the mark distribution for the XI Computer Science practical exam, totaling 30 marks, with specific allocations for Python practicals, record notes, viva voce, and project reports. It includes a list of 12 Python practical programs with coding examples and expected outputs, covering topics such as area and circumference of a circle, finding the greatest of four numbers, calculating factorials, generating Fibonacci series, and more. Each program is accompanied by coding instructions and sample outputs to illustrate functionality.

Uploaded by

ravijayalaxmi008
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/ 13

XI COMPUTER SCIENCE (083)

Mark Distribution for Practical Exam (30 Marks)

Python Practical Exam 12 Marks


Completed Python Record Note 7 Marks
Viva voce 3 Marks
Project Report 8 Marks
(Maximum 3 Students in one Project)

PYTHON PRACTICAL PROGRAMS


S.No. Program Page No.

1 Area and Circumference of a Circle 2

2 Greatest of four numbers using if..elif 3

3 Factorial 4

4 Fibonacci Series 5

5 Maximum and Minimum from List 6

6 Palindrome 7

7 Display a Pattern 8

8 Count Odd and Even Numbers 9

9 Arithmetic Operation 10

10 Counting in String 11

11 Student Search in a Tuple 12

12 Student List using Dictionary 13

1
1. Area and Circumference of a Circle

Write a program to accept radius of a Circle from the user and display its Area and
Circumference. Area=𝝅𝒓𝟐 and Circumference=𝟐 𝝅𝒓

Coding:

area,circum=0.0,0.0
radius=float(input("Enter the radius to display area and circumference of a circle "))
area = 22/7*radius**2
circum = 2*22/7*radius
print("Area of a Circle %.2f " %area)
print('Circumference of a Circle %.2f ' %circum)

Output
Enter the radius to display area and circumference of a circle 3.4
Area of a Circle 36.33
Circumference of a Circle 21.37

2
2. Greatest of Four Numbers

Write a program to find greatest of four numbers using if-elif-else

CODING

a=int(input("Enter the First Number "))


b=int(input("Enter the Second Number "))
c=int(input("Enter the Third Number "))
d= int(input("Enter the Fourth Number "))
if not (a==b or a==c or a==d or b==c or b==d or c==d) :
if a > b :
if a > c:
if a > d:
maxi = a
else:
maxi = d
elif c > d:
maxi = c
else:
maxi = d
elif b > c:
if b > d:
maxi = b
else:
maxi = d
elif c > d:
maxi = c
else:
maxi = d
print("The greatest of given four numbers is",maxi)
else:
print("Same numbers should not be given as input")

OUTPUT

Enter the First Number 55


Enter the Second Number 64
Enter the Third Number -9
Enter the Fourth Number 25
The greatest of given four numbers is 64

Enter the First Number 15


Enter the Second Number 87
Enter the Third Number 15
Enter the Fourth Number 56
Same numbers should not be given as input

3
3.Factorial

Write a program to find factorial of a given number

CODING

num = int(input("Enter number to find factorial "))


fact=1
if num < 0:
print("Factorial does not exist for Negative Number ")
elif num == 0 or num==1 :
print("Factorial is 1")
else:
for i in range(1,num+1,1):
fact = fact * i
print("The factorial of ", num, " is ",fact)

OUTPUT

Enter number to find factorial 0


Factorial is 1

Enter number to find factorial -4


Factorial does not exist for Negative Number

Enter number to find factorial 6


The factorial of 6 is 720

4
4. Fibonacci series

Write a program to generate Fibonacci Series

CODING:

nterms=int(input("Enter Number of terms to be generated for fibonacci series: "))


a,b=-1,1
print("\n\nFibonacci Series.....")
for i in range(1,nterms+1,1):
c=a+b
print(c)
a=b
b=c

OUTPUT

Enter Number of terms to be generated for fibonacci series: 15

Fibonacci Series.....
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377

5
5. Maximum and Minimum from List

Write a program to find maximum and minimum number from the List without using
built-in function

CODING

num = int(input("Enter How many numbers to be added in the List: "))


numList =[]
for sE in range(1,num+1,1):
print("Enter ", sE," Number ")
numList.append(int(input()))
maxiNum = numList[0]
miniNum = numList[0]
for sE in numList:
if maxiNum < sE:
maxiNum=sE
elif miniNum > sE:
miniNum = sE
print("The maximum in given List is ",maxiNum)
print("The minimum in given List is ",miniNum)

OUTPUT

Enter How many numbers to be added in the List: 8


Enter 1 Number
25
Enter 2 Number
89
Enter 3 Number
-8
Enter 4 Number
56
Enter 5 Number
37
Enter 6 Number
-78
Enter 7 Number
64
Enter 8 Number
58
The maximum in given List is 89
The minimum in given List is -78

6
6. Palindrome

Write a program to find whether the given word is palindrome or not

CODING

word=input('Enter the word ')


length=0
word_rev=''
for ch in word:
length = length+1
for ch in range(-1,-length-1,-1):
word_rev=word_rev+word[ch]
if word==word_rev:
print(word,' is a palindrome')
else:
print(word,' is not a palindrome')

OUTPUT

Enter the word malayalam


malayalam is a palindrome

Enter the word python


python is not a palindrome

7
7. DISPLAY A PATTERN

Write a program to print in the following pattern and Read n to print for number of lines
1
23
456
7 8 9 10
11 12 13 14 15
..

CODING

n=int(input('How many lines the pattern to be generated '))


line=1
for i in range(0,n+1):
for j in range(1,i+1):
print(line,end=" ")
line=line+1
print()

OUTPUT

How many lines the pattern to be generated 10

1
23
456
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55

8
8. Count Odd and Even Numbers

Write a program to count odd and even numbers in a list

CODING

num = int(input("Enter How many numbers to be added in the List: "))


numList =[]
for ae in range(1,num+1,1):
print("Enter ", ae," Number ")
numList.append(int(input()))
odd=0
even=0
for num in numList:
if num % 2==1:
odd = odd + 1
else:
even = even + 1
print('The Number of Odd numbers in the list is ',odd)
print('The Number of Even numbers in the list is ',even)

OUTPUT
Enter How many numbers to be added in the List: 8
Enter 1 Number
15
Enter 2 Number
98
Enter 3 Number
-74
Enter 4 Number
23
Enter 5 Number
16
Enter 6 Number
9
Enter 7 Number
52
Enter 8 Number
-3
The Number of Odd numbers in the list is 4
The Number of Even numbers in the list is 4

9
9. Arithmetic Operation

Write a program that reads two numbers and an arithmetic operator and displays the
computed result.

CODING:

firstNum = float(input('Enter the first number:'))


secondNum = float(input('Enter the second number:'))
op=input("Enter any one operator ' /,*,+,- ': ")
flag=0
if op=='/':
if secondNum==0:
print("Divide by zero")
flag=1
else:
result=firstNum / secondNum
elif op=='*':
result=firstNum * secondNum
elif op=='+':
result=firstNum + secondNum
elif op=='-':
result=firstNum - secondNum
else:
print('You have entered an invalid operator')
flag=1
if not flag:
print("The result is ",result)

OUTPUT

Enter the first number:25


Enter the second number:6
Enter any one operator ' /,*,+,- ': -
The result is 19.0

Enter the first number:20


Enter the second number:5
Enter any one operator ' /,*,+,- ': $
You have entered an invalid operator

Enter the first number:10


Enter the second number:0
Enter any one operator ' /,*,+,- ': /
Divide by zero

10
10. Counting in String

Write a program to read a sentence and print Number of Upper case, Lower case,
vowels and digits present in it.

CODING

line=input('Enter a line: ')


lowercount=uppercount=0
digitcount=vowel=0
for a in line:
if a.islower():
lowercount+=1
elif a.isupper():
uppercount+=1
elif a.isdigit():
digitcount+=1
if a in ['a','e','i','o','u','A','E','I','O','U']:
vowel = vowel+1
print('Number of uppercase letters are:',uppercount)
print('Number of lowercase letters are:',lowercount)
print('Number of Vowels are:',vowel)
print('Number of digits are:',digitcount)

OUTPUT

Enter a line: Ram is a Legend No.1938


Number of uppercase letters are: 3
Number of lowercase letters are: 11
Number of Vowels are: 6
Number of digits are: 4

11
11. Student Search in a Tuple

Write a program to input names of n students and store them in a tuple. Also input a
name from the user and find if this student is present in the tuple or not.

CODING:

n=int(input("Enter how many Student Names to be stored: "))


sL=[]
for i in range(0,n):
ele=input("Enter Name : ")
sL.append(ele)
sT=tuple(sL)
stname=input("Enter name to be searched : ")
print(sT)
for i in range(0,n):
if sT[i]==stname:
print(stname, "is present in the tuple")
break
else:
print(stname, "is not present in the tuple")

OUTPUT

Enter how many Student Names to be stored: 6


Enter Name : raj
Enter Name : arun
Enter Name : ram
Enter Name : malini
Enter Name : balaji
Enter Name : arjun
Enter name to be searched : arun
('raj', 'arun', 'ram', 'malini', 'balaji', 'arjun')
arun is present in the tuple

Enter how many Student Names to be stored: 5


Enter Name : ganesh
Enter Name : lakshmi
Enter Name : gugan
Enter Name : jagan
Enter Name : sharma
Enter name to be searched : arjun
('ganesh', 'lakshmi', 'gugan', 'jagan', 'sharma')
arjun is not present in the tuple

12
12. Student List using Dictionary

Write a program to create a dictionary with the roll number, name and marks of n
students in a class and displays the names of students who have marks above 75.

CODING

n=int(input("How many students? "))


stu={}
for i in range (1,n+1):
print("Enter details of students ",i)
rollno=int(input("Enter the Roll Number : "))
name=input("Enter Name of the Student: ")
marks=float(input("Enter the mark "))
D={"Roll_No":rollno, "Name":name, "Marks":marks}
key="Stu"+str(i)
stu[key]=D
print("Student with marks above 75 are :")
for i in range(1,n+1):
key="Stu"+str(i)
if stu[key]["Marks"]>=75:
print(stu[key])

OUTPUT
How many students? 5
Enter details of students 1
Enter the Roll Number : 12101
Enter Name of the Student: Nakulan
Enter the mark 77
Enter details of students 2
Enter the Roll Number : 12501
Enter Name of the Student: Sujith
Enter the mark 74
Enter details of students 3
Enter the Roll Number : 12506
Enter Name of the Student: Bharath
Enter the mark 87
Enter details of students 4
Enter the Roll Number : 12604
Enter Name of the Student: Naresh
Enter the mark 90
Enter details of students 5
Enter the Roll Number : 12201
Enter Name of the Student: Vani
Enter the mark 70
Student with marks above 75 are :
{'Roll_No': 12101, 'Name': 'Nakulan', 'Marks': 77.0}
{'Roll_No': 12506, 'Name': 'Bharath', 'Marks': 87.0}
{'Roll_No': 12604, 'Name': 'Naresh', 'Marks': 90.0}

13

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