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

XI Computer Science Practicle file questions and answers

It includes class 11 computer science practicals for the whole year . Very beneficial for making computer science project files and learning and practicing the programs

Uploaded by

bishtstudy3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

XI Computer Science Practicle file questions and answers

It includes class 11 computer science practicals for the whole year . Very beneficial for making computer science project files and learning and practicing the programs

Uploaded by

bishtstudy3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Practical File

Computer Science (Python)


Session ( )
Subject Code(083)
Class XI

Name:-
Class and Section:-
Rollno:-
Student ID:-
Teacher’s Name:-
INDEX
S.No Program Name Page Signature
No
1 Write a program that accepts marks in 5 subjects and output
average marks.
2 Write a program to calculate Simple Interest and Compound
interest.
3 Write a program to convert temperature from Celsius to
Fahrenheit.
4 Write a program to Input any alphanumeric character and print
whether it is an uppercase / lowercase character or a digit.

5 Write a program to find the largest number among the three


inputted numbers.
6 Write a program that to create a mini calculator using if, elif,
else. (Reads two number and an arithmetic operator and display
the result).

7 Write a program to accept a number and calculate its Factorial.

8 Write a program to accept a number and check whether that


number is Prime or not.
9 Write a program to print Fibonacci series up to a certain limit.

10 Write a program to accept a number and check whether that


number palindrome or not.
11 Write a program to print the sum of following series: -
1+x+x2+x3+x4+……+xn

12 Write a program to print following pattern.


13 Write a program to print following pattern.
A
A B
A B C
A B C D
A B C D E
A B C D E F
14 Write a program to count the number of vowels in a string.
15 Write a program that reads a String and display the longest
substring of the given string.
16 Write a program to count the frequency of a given element in a
list of numbers.
17 Write a menu driven program for bank management system that
performs following operations.
1) Add a customer (deposit amount if customer already
exists).
2) Modify customer details (by giving the position).
3) Delete a customer details. If the user chooses a
deletion option, display a submenu and ask if element
is to be deleted with customer number or by position.
4) Sort the records. If the user chooses a Sort option,
display a submenu and ask if you want to sort in
Ascending or descending order.
5) Display the sorted list.
6) Exit

18 Write a program to perform Linear search on a tuple of


numbers.
19 Write a program to count how many times a character appears
in a string and show it using dictionary.
20 Write a menu driven program to input your friend’s names and
their Phone Numbers and store them in a Dictionary as the Key-
Value pair. Perform the following Operations on dictionary?
1) Display the name and phone number of all your
friends.
2) Add a new key-value pair in this dictionary and display
the modified dictionary.
3) Delete a particular friend from dictionary.
4) Modify the phone number of an existing friend.
5) Check if a friend is present in the dictionary or not.
6) Display the dictionary in sorted order of names.
Points to remember While creating file
1) File must be in printed.
2) Create program in Python IDLE and then copy paste the program as well as
output in MS-Word for formatting.
3) Font type must be either Calibri / Times new Roman.
4) Font size of Program Heading must be 16 and Bold.
5) Font size of program must be 14
6) Output of each and every program must be there.
7) Only one program on one page.
8) You can add border as well.
9) Example given on next page.
# Write a program to find the largest number among the three inputted
numbers.

n1 = int(input("Enter first number "))

n2 = int(input("Enter second number "))

n3 = int(input("Enter third number "))

large = n1

if (large<n2):

large=n2

if(large<n3):

large=n3

print("Largest number is ", large)

Output
Enter first number 23
Enter second number 56
Enter third number 12
Largest number is 56
S.No Program Name Reference
1 Write a program that accepts marks in 5 subjects and output average Chapter 4
marks. Unsolved Que 31

2 Write a program to calculate Simple Interest and Compound interest. Chapter 4 Example 3
(p.no 4.17)

3 Write a program to convert temperature from Celsius to Fahrenheit. Chapter 4


solved Que 20

4 Write a program to Input any alphanumeric character and print PPT1 Chapter 5
whether it is an uppercase / lowercase character or a digit.

5 Write a program to find the largest number among the three inputted Chapter 5 solved
numbers. question 22

6 Write a program that to create a mini calculator using if, elif, else. Chapter 5 solved
(Reads two number and an arithmetic operator and display the result). question 24

7 Write a program to accept a number and calculate its Factorial. Chapter 5 Practical
implementation 15 ,
page no :- 5.18
8 Write a program to accept a number and check whether that number is Chapter 5 solved
Prime or not. question 29

9 Write a program to print Fibonacci series up to a certain limit. Chapter 5 solved


question 28

10 Write a program to accept a number and check whether that number Chapter 5 solved
palindrome or not. question 31

11 Write a program to print the sum of following series: - Chapter 5 Practical


1+x+x2+x3+x4+……+xn implementation 16 page
no 5.20
12 Write a program to print following pattern. Chapter 5 solved
question 39 (a)

13 Write a program to print following pattern. Notes/do it yourself


A
A B
A B C
A B C D
A B C D E
A B C D E F
14 Write a program in to count the number of vowels in a string. Chapter 6 , solved Q-17
15 Write a program that reads a String and display the longest substring of Chapter 6 solved Que-26
the given string.
16 Write a program to count the frequency of a given element in a list of Chapter 7 Practical
numbers. implementation 6 , page
no-7.32
17 Write a menu driven program for bank management system that Case Based Question
performs following operations. Chapter 7 , Page no-44-
7) Add a customer(deposit amount if customer already exists). 45
8) Modify customer details (by giving the position).
9) Delete a customer details. If the user chooses a deletion
option, display a submenu and ask if element is to be
deleted with customer number or by position.
10) Sort the records. If the user chooses a Sort option, display a
submenu and ask if you want to sort in Ascending or
descending order.
11) Display the sorted list.
12) Exit

18 Write a program to perform Linear search on a tuple of numbers. chapter 8, Practical


implementation 8, page
no-8.17
19 Write a program to count how many times a character appears in a chapter 8, Practical
string and show it using dictionary. implementation 19, page
no-8.32
20 Write a menu driven program to input your friend’s names and their chapter 8, Solved Que:-
Phone Numbers and store them in a Dictionary as the Key-Value pair. 31, page no-8.48
Perform the following Operations on dictionary.
1) Display the name and phone number of all your friends.
2) Add a new key-value pair in this dictionary and display the
modified dictionary.
3) Delete a particular friend from dictionary.
4) Modify the phone number of an existing friend.
5) Check if a friend is present in the dictionary or not.
6) Display the dictionary in sorted order of names.
1

#Write a program that accepts marks in 5 subjects and output average marks.
Math=float(input("Enter marks in Math:- "))

English=float(input("Enter marks in English:- "))

Chem=float(input("Enter marks in Chemistry:- "))

Physics=float(input("Enter marks in Physics:- "))

CS=float(input("Enter marks in Computer Science:- "))

average=(Math+English+Chem+Physics+CS)/5

print("Average of 5 subjects is :- ",average)

Output
Enter marks in Math:- 45

Enter marks in English:- 78

Enter marks in Chemistry:- 90

Enter marks in Physics:- 56

Enter marks in Computer Science:- 78

Average of 5 subjects is :- 69.4


2

'''Write a program to calculate Simple Interest and Compound interest. '''

principle=eval(input("Enter value of Principle :- "))

rate=float(input("Enter Rate:- "))

time=int(input("Enter Time:- "))

S_i=(principle*rate*time)/100

print("Simple Interest is :- ",S_i)

Amount = principle * ((1 + rate / 100)**time)

C_I = Amount - principle

print("Compound interest is", C_I)

Output
Enter value of Principle :- 5000

Enter Rate:- 4

Enter Time:- 2

Simple Interest is :- 400.0

Compound interest is 408.0000000000009


3

'''Write a program to convert temperature from Celsius to Fahrenheit. '''

cels=float(input("Enter Temperature in Celsius:- "))


f=cels*9/5+32
print("Temperature in Fahrenheit is :- ",f)

Output

Enter Temperature in Celsius:- 37


Temperature in Fahrenheit is :- 98.6

4
'''Write a program to accept a character from the user and display whether it is a
vowel or consonant. '''

ch=input("Enter a character")
if ch==' ':
print("space")
elif ch>='0' and ch<='9':
print("Digit")
elif ch>="A" and ch<="Z":
print("Upper case")
elif ch>="a" and ch<="z":
print("Lower case")
else:
print("Special Character")

Output
Enter a character:- A
Uppercase character
5

'''Write a program to find the largest number among the three inputted numbers. '''

n1 = int(input("Enter first number "))


n2 = int(input("Enter second number "))
n3 = int(input("Enter third number "))
large = n1
if (large<n2):
large=n2
if(large<n3):
large=n3
print("Largest number is ", large)

Output
Enter first number 20
Enter second number 45
Enter third number 12
Largest number is 45
6

'''Write a program that to create a mini calculator using if, elif, else. (Reads two
number and an arithmetic operator and display the result).'''

a=float(input("Enter first number:- "))


b=float(input("Enter second number:- "))
Op=input("Enter Operator (+,-,*,/,%,**):- ")
if Op=='+':
print("Result is :- ",a+b)
elif Op=='-':
print("Result is :- ",a-b)
elif Op=='*':
print("Result is :- ",a*b)
elif Op=='/':
print("Result is :- ",a/b)
elif Op=='%':
print("Result is :- ",a%b)
elif Op=='**':
print("Result is :- ",a**b)
else:
print("Invalid Operator")

Output

Enter first number:- 20


Enter second number:- 4
Enter Operator (+,-,*,/,%,**):- /
Result is :- 5.0
7
'''Write a program to accept a number and calculate its Factorial.'''

num=int(input("Enter a non- negative number :- "))


fact=1
for i in range(num,0,-1):
fact=fact*i
print("Factorial is" ,fact)

output
Enter a non- negative number :- 3
Factorial is 6

8
'''Write a program to accept a number and check whether that number is Prime or
not.'''

num=int(input("Enter a number:- "))


limit=int(num//2)+1
for i in range(2,limit):
if (num%i==0):
print(num,"is not prime")
break
else:
print(num,"is prime")

Output
Enter a number:- 78
78 is not prime
9

#Write a program to print Fibonacci series up to a certain limit.


n=int(input("Enter number of terms:- "))
sum=0
first=0
second=1
print(first,end= " ")
print(second,end= " ")
for i in range (1,n-1):
sum=first+second
first=second
second=sum
print(sum, end= " ")

Output
Enter number of terms:- 7

0 1 1 2 3 5 8

10

#Write a program to accept a number and check whether that number palindrome
or not.
num=int(input("Enter a number:- "))
original=num
rev=0
while num>0:
rem=num%10
rev=rev*10+rem
num//=10
if(rev==original):
print(original," is Palindrome")
else:
print(original," is not Palindrome")

output

Enter a number:- 1331


1331 is Palindrome
11
'''Write a program to print the sum of following series'''

x=float(input("Enter the value of X:- "))


n=int(input("Enter value of n:- "))
sum=0
for a in range(n+1):
sum=sum+(x**a)
print("Sum of first", n, "terms: " ,sum )

Output
Enter the value of X:- 2
Enter value of n:- 4
Sum of first 4 terms: 31.0

12

#Write a program to print following pattern.


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

Output
1
12
123
1234
12345
13
#Write a program to print following pattern.

for i in range(6):
for j in range(6):
if i >= j :
print(chr(65+j)+" ",end="")
print()

Output
A
AB
ABC
ABCD
ABCDE
ABCDEF

14
#Write a program to count the number of vowels in a string.

string=input("Eter a string:- ")


count=0
for letter in string:
if letter in "aeiouAEIOU":
count=count+1
print("Number of vowels in ",string," is:- ",count)

Output
Eter a string:- Hello Python
Number of vowels in Hello Python is:- 3
15
'''Write a program that reads a String and display the longest substring of the given
string. '''

str1= input("Enter any string:- ")


word=str1.split()
maxlength=0
maxword=""
for i in word:
x=len(i)
if (x>maxlength and i.isalpha()==True):
#print(i)
maxlength=x
maxword=i
print("Substring with maximum length is : ",maxword)

Output
Enter any string:- We will learn python in computer science
Substring with maximum length is : computer
16
#Write a program to count the frequency of a given element in a list of numbers.

num=int(input("How many items you want to enter in a list"))


A=[] # empty list
for i in range(num):
j=int(input("Enter element:"))
A.append(j)
print("List is :" , A)
n=int(input("Enter the number you want frequency for "))
count=0
for i in A:
if(i==n):
count=count+1
print("frequency of ",n ," is ", count)

Output

How many items you want to enter in a list7


Enter element:12
Enter element:13
Enter element:22
Enter element:10
Enter element:12
Enter element:12
Enter element:22
List is : [12, 13, 22, 10, 12, 12, 22]
Enter the number you want frequency for 12
frequency of 12 is 3
17

ch=0
list=[]
while True:
print("List Menu")
print("1. Add a customer")
print("2. Modify customer details")
print("3. Delete a customer details")
print("4. Sort Customer List")
print("5. Display Sorted List")
print("6. Exit")
ch=int(input("Enter your choice "))
if ch==1:
print("1. Add Amount Deposit")
print("2. Add a customer record")
ch1=int(input("Enter your choice(1/2)"))
if ch1==1:
amt=int(input("Enter deposit amount "))
pos=int(input("Enter position to add "))
list.insert(pos,amt)
elif ch1==2:
list2=eval(input("Enter added customer list"))
list.extend(list2)
else:
print("Enter valid choice(1/2)")
print("Successfully added")

elif ch==2:
pos=int(input("Enter position where details are to be modified "))
new_cust=int(input("Enter new value"))
old=list[pos]
list[pos]=new_cust
print(old,"Modified with",new_cust)

elif ch==3:
print("1. Delete details by position")
print("2. Delete details by customer number")
ch1=int(input("Enter your choice(1/2)"))
if ch1==1:
pos=int(input("Enter position "))
cust=list.pop(pos)
print(cust, "Deleted")
elif ch1==2:
cust=int(input("Enter element "))
pos=list.remove(cust)
print("Successfully deleted")
else:
print("Enter valid choice(1/2)")

elif ch==4:
print("1. Ascending")
print("2. Descending")
ch1=int(input("Enter your choice(1/2)"))
if ch1==1:
list.sort()
elif ch1==2:
list.sort(reverse=True)
else:
print("Enter valid choice(1/2)")

elif ch==5:
print(list)

elif ch==6:
break

else:
print("Enter valid choice(1 to 6)")

Output
18

# Write a program to perform Linear search on a tuple of numbers.


l1=(12,45,23,76,44)
print("Tuple is :-",l1)
found=0
n=int(input("Enter the number you want to search:- "))
for i in l1:
if(i==n):
position=l1.index(n)
found=1
if found==0:
print("Element not found")
else:
print("Element found at position ",position+1)

Output

Tuple is :- (12, 45, 23, 76, 44)


Enter the number you want to search:- 76
Element found at position 4
19
’’’Write a program to count how many times a character appears in a string and
show it using dictionary.’’’

st=input("Enter a String:- ")


dic={}
for ch in st:
if ch in dic:
dic[ch]+=1
else:
dic[ch]=1
for key in dic:
print(key, ":", dic[key])

Output

Enter a String:- computer programming


c:1
o:2
m:3
p:2
u:1
t:1
e:1
r:3
:1
g:2
a:1
i:1
n:1
20

n=int(input("No of friends:"))
dict={}
for i in range(n):
name=input("Name:")
ph_no=int(input("Phone number:"))
dict[name]=ph_no
while True:
print("MENU\n1.Display name & phone numbers\n\
2.Add new name\n\
3.Delete a name\n\
4.Modify an existing number\n\
5.Check if a name is there\n\
6.Display dictionary in sorted order\n\
7.Exist")
ch=int(input("Enter your choice(1-6):"))
if ch==1:
for i in dict:
print(i,"-",dict[i])
elif ch==2:
name1=input("Enter name:")
ph_no1=int(input("Enter phone number:"))
dict[name1]=ph_no1
print("Modified dictionary:",dict)
elif ch==3:
name1=input("Name of friend to be deleted:")
dict.pop(name1)
print("Modified dictionary:",dict)
elif ch==4:
name1=input('Name of friend:')
ph_no1=int(input("New ph_no:"))
dict[name1]=ph_no1
elif ch==5:
name1=input("Name of friend:")
if name1 in dict:
print('Friend is in dictionary')
elif ch==6:
D=dict
dict1=sorted(D.items())
print("Mofified dictionary:",dict1)
elif ch==7:
break
else:
print("Invalid choice")

Output

You might also like