0% found this document useful (0 votes)
36 views11 pages

Cs Practical File 11th

This document is a practical file for Computer Science, specifically focusing on Python programming for the academic session 2025-2026. It includes a series of programming tasks and examples, covering topics such as calculating student grades, factorial computation, list operations, and stack implementation. The file is submitted by a student named Shubhkarman Singh from class XI C.
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)
36 views11 pages

Cs Practical File 11th

This document is a practical file for Computer Science, specifically focusing on Python programming for the academic session 2025-2026. It includes a series of programming tasks and examples, covering topics such as calculating student grades, factorial computation, list operations, and stack implementation. The file is submitted by a student named Shubhkarman Singh from class XI C.
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

BANASTHALI PUBLIC SCHOOL

SESSION 2025-2026

PRACTICAL FILE
COMPUTER SCIENCE

(PYTHON PROGRAMMING FILE)

SUBMITTED BY : SHUBHKARMAN SINGH


CLASS: XI C
ROLL NO: 25
INDEX
T.
[Link] PROGRAMS DATE
Sign.
PROGRAMS OF PYTHON REVISION TOUR
1. Write Python program to calculate the result (Total and percentage)
of student and display result and grade according to given criteria:
Percentage Grade
>=90 A
< 90 and >=75 B
< 75 and >=60 C
< 60 D
2. Write a program to calculate factorial of a number using while loop.
3. Write the program to find the maximum, minimum and mean value
from the inputted list.
4. Write the program to generate Fibonacci series.
5. Write a program to store students’ information like admission
number, roll number, name and marks in a dictionary, and display
information on the basis of admission number.
6. Write a Python program to count number of items in a dictionary
value that is a list.
7. Write a menu-driven Python program that performs the various
operations on a list.
8. Write a menu-driven Python program that performs the various
operations on a tuple.
9. Write a menu-driven Python program that performs the various
operations on a string.
10. Write a menu-driven Python program that performs the various
operations on a dictionary.

PROGRAMS OF FUNCTIONS
11. Write a program to input a string and pass to the function that
counts the number of uppercase and lowercase letters.
12. Write a program to pass string to a function and count how many
vowels are there in the string.
13. Write a program to pass string to a function and count how many
times any character is present in the string.
14. Write a program to passing list to a function to double the odd
values and half the even values.
15. Write a function dispBook(BOOKS) in Python, that takes a
dictionary BOOKS as an argument and displays the names in
uppercase of those books whose name starts with a consonant.
For example, Consider the following dictionary
BOOKS = {1:"Python", 2:"Internet Fundamentals ",
3:"Networking ", 4:"Oracle sets", 5:"Understanding HTML"}
The output should be:
PYTHON
NETWORKING
16. Write a function remove_element() in Python that accepts a list L
and a number n. If the number n exists in the list, it should be
removed. If it does not exist, print a message saying "Element not
found".

STACK IMPLEMENTATION

17. A stack named KeyStack contains records of some computer


keyboards. Each record is represented as a list containing Make,
Keys, Connectivity. The Make and Connectivity are strings, and
Keys is an integer.
For example, a record in the stack may be ('Hitech', 105, 'USB').
Write the following user-defined functions in Python to perform the
specified operations on KeyStack:
(a) push_key(KeyStack, new_key): This function takes the stack
KeyStack and a new record new_key as arguments and pushes
this new record onto the stack.
(b) pop_key(KeyStack): This function pops the topmost record
from the stack and returns it. If the stack is already empty, the
function should display the message "Underflow".
(c) isEmpty(KeyStack): This function checks whether the stack is
empty. If the stack is empty, the function should return True,
otherwise
the function should return False.

18. A list contains following record of course details for a University:


[Course_Name,Fees]
Write the following user defined function to perform given
operations on the stack ‘Univ’:
(I) Push_element(): to push an object containing the course_name,
fees,
duration which has fees greater than 100000 to stack.
(II) Pop_element(): To pop the object from the stack and display it.
Also,
display “underflow” where there is no element in the stack.
PROGRAMS OF PYTHON REVISION TOUR
1. Write Python program to calculate the result (Total and percentage) of student
and display result and grade according to given criteria:
Percentage Grade
>=90 A
< 90 and >=75 B
< 75 and >=60 C
< 60 D
CODE:
total = 0

for i in range(1, 6):


marks = float(input("Enter marks of Subject " + str(i) + ": "))
total = total + marks

percentage = (total / 500) * 100

print("Total Marks =", total)


print("Percentage =", percentage)

if percentage >= 90:


grade = "A"
elif percentage >= 75:
grade = "B"
elif percentage >= 60:
grade = "C"
else:
grade = "D"

print("Grade =", grade)

OUTPUT:
Enter marks of Subject 1: 75
Enter marks of Subject 2: 75
Enter marks of Subject 3: 80
Enter marks of Subject 4: 95
Enter marks of Subject 5: 100
Total Marks = 425.0
Percentage = 85.0
Grade = B

2. Write a program to calculate factorial of a number using while loop.


CODE:
n = int(input("Enter a number: "))
fact = 1

while n > 0:
fact = fact * n
n=n-1
print("Factorial =", fact)

OUTPUT:
Enter a number: 5
Factorial = 120

3. Write the program to find the maximum, minimum and mean value from the
inputted list.
CODE:
list = eval(input("enter your list : "))
maxx = max(list)
minn= min(list)
mean = sum(list) / len(list)
print("max value is :",maxx)
print("min value is :",minn)
print("mean value is:",mean)

OUTPUT:
enter your list : (20,40,50,60,80)
max value is : 80
min value is : 20
mean value is: 50.0

4. Write the program to generate Fibonacci series.


CODE:
n = int(input("Enter number of terms: "))

a=0
b=1

print("Fibonacci Series:", end=" ")

count = 0
while count < n:
print(a, end=" ")
c=a+b
a=b
b=c
count += 1

OUTPUT:
Enter number of terms: 7
Fibonacci Series: 0 1 1 2 3 5 8

5. Write a program to store students’ information like admission number, roll


number, name and marks in a dictionary, and display information on the basis
of admission number.
CODE:
students = {"5850": {"Roll No": 25, "Name": "SHUBH", "Marks": 85},
"6879": {"Roll No": 9, "Name": "dakshg", "Marks": 31}}

adm_no = input("Enter admission number to display info: ")

if adm_no in students:
print("Roll Number:", students[adm_no]["Roll No"])
print("Name:", students[adm_no]["Name"])
print("Marks:", students[adm_no]["Marks"])
else:
print("No student found with this admission number.")

OUTPUT:
Enter admission number to display info: 5850
Roll Number: 25
Name: SHUBH
Marks: 85

6. Write a Python program to count number of items in a dictionary value that is a


list.
CODE:
d = {'a':[1,2,3]}

total = 0
for x in [Link]():
if type(x) == list:
total = total + len(x)

print("no of items are : " ,total)

OUTPUT:
no of items are : 3

7. Write a menu-driven Python program that performs the various operations on a


list.
CODE:

OUTPUT:

8. Write a menu-driven Python program that performs the various operations on a


tuple.
CODE:

OUTPUT:

9. Write a menu-driven Python program that performs the various operations on a


string.
CODE:

OUTPUT:

10. Write a menu-driven Python program that performs the various operations on a
dictionary.
CODE:

OUTPUT:

PROGRAMS OF FUNCTIONS
11. Write a program to input a string and pass to the function that counts the
number of uppercase and lowercase letters.
CODE:
text = input("Enter a string: ")
ch = input("Choose (upper/lower): ")

uppercase = 0
lowercase = 0

def upc():
global uppercase
for i in text:
if [Link]():
uppercase += 1
def low():
global lowercase
for i in text:
if [Link]():
lowercase += 1

if ch == "upper":
upc()
print("Uppercase letters:", uppercase)
elif ch == "lower":
low()
print("Lowercase letters:", lowercase)
else:
print("Invalid choice! Choose 'upper' or 'lower'.")

OUTPUT:
Enter a string: I am Batman VENGEANCE
Choose (upper/lower): upper
Uppercase letters: 11

12. Write a program to pass string to a function and count how many vowels are
there in the string.
CODE:
def count_vowels():
c=0
for i in st:
if i in 'aeiou':
c=c+1
print("No. of vowels in string are =", c)

st = input("Enter string: ")


count_vowels()

OUTPUT:
Enter string: the quick brown fox jumps over the lazy dog
No. of vowels in string are = 11

13. Write a program to pass string to a function and count how many times any
character is present in the string.
CODE:
def count_char():
c = input("Enter character: ")
total = 0
for i in st:
if i == c:
total += 1
print(c, "appears", total, "times")

st = input("Enter string: ")


count_char()

OUTPUT:
Enter string: mississippi
Enter character: s
s appears 4 times

14. Write a program to passing list to a function to double the odd values and half
the even values.
CODE:
def modify_list():
for i in range(len(numbers)):
if numbers[i] % 2 == 0:
numbers[i] = numbers[i] // 2
else:
numbers[i] = numbers[i] * 2

numbers = [1, 2, 3, 4, 5, 6, 7, 8]

print("Before:", numbers)

modify_list()

print("After :", numbers)

OUTPUT:
Before: [1, 2, 3, 4, 5, 6, 7, 8]
After : [2, 1, 6, 2, 10, 3, 14, 4]

15. Write a function dispBook(BOOKS) in Python, that takes a dictionary


BOOKS as an argument and displays the names in uppercase of those books
whose name starts with a consonant.
For example, Consider the following dictionary
BOOKS = {1:"Python", 2:"Internet Fundamentals ", 3:"Networking ",
4:"Oracle sets", 5:"Understanding HTML"}
The output should be:
PYTHON
NETWORKING

CODE:

OUTPUT:

16. Write a function remove_element() in Python that accepts a list L and a


number n. If the number n exists in the list, it should be removed. If it does not
exist, print a message saying "Element not found".

CODE:

OUTPUT:

STACK IMPLEMENTATION

17. A stack named KeyStack contains records of some computer keyboards. Each
record is represented as a list containing Make, Keys, Connectivity. The Make
and Connectivity are strings, and Keys is an integer.
For example, a record in the stack may be ('Hitech', 105, 'USB').
Write the following user-defined functions in Python to perform the specified
operations on KeyStack:
(a) push_key(KeyStack, new_key): This function takes the stack KeyStack and
a new record new_key as arguments and pushes this new record onto the
stack.
(b) pop_key(KeyStack): This function pops the topmost record from the stack
and returns it. If the stack is already empty, the function should display the
message "Underflow".
(c) isEmpty(KeyStack): This function checks whether the stack is
empty. If the stack is empty, the function should return True, otherwise
the function should return False.

CODE:
OUTPUT:

18. A list contains following record of course details for a University:


[Course_Name,Fees]
Write the following user defined function to perform given operations on the
stack ‘Univ’:
(I) Push_element(): to push an object containing the course_name, fees,
duration which has fees greater than 100000 to stack.
(II) Pop_element(): To pop the object from the stack and display it. Also,
display “underflow” where there is no element in the stack.

CODE:

OUTPUT:

You might also like