XI Computer Science Practicle file questions and answers
XI Computer Science Practicle file questions and answers
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.
large = n1
if (large<n2):
large=n2
if(large<n3):
large=n3
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)
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
10 Write a program to accept a number and check whether that number Chapter 5 solved
palindrome or not. question 31
#Write a program that accepts marks in 5 subjects and output average marks.
Math=float(input("Enter marks in Math:- "))
average=(Math+English+Chem+Physics+CS)/5
Output
Enter marks in Math:- 45
S_i=(principle*rate*time)/100
Output
Enter value of Principle :- 5000
Enter Rate:- 4
Enter Time:- 2
Output
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. '''
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).'''
Output
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.'''
Output
Enter a number:- 78
78 is not prime
9
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
Output
Enter the value of X:- 2
Enter value of n:- 4
Sum of first 4 terms: 31.0
12
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.
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. '''
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.
Output
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
Output
Output
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