Class 11 - CS - Practical Assessment
Class 11 - CS - Practical Assessment
General instructions :-
Program :-
for i in range(1,6):
for j in range(1,i+1):
print('*',end=' ')
print()
Output :-
**
***
****
*****
0,1,1,2,3,5,8,13,21,34,55,89,144,233,….
Program :-
x,y=0,1
if n>=1:
print(x,end=',')
if n>=2:
print(y,end=',')
for i in range(3,n+1):
z=x+y
print(z,end=',')
x,y=y,z
Output :-
0,1,1,2,3,5,8,13,21,34
Program :-
astring=input("Enter a string:")
vow=cons=up=low=0
for ch in astring:
if ch.isalpha():
if ch.lower() in 'aeiou':
vow+=1
else:
cons+=1
if ch.islower():
low+=1
else:
up+=1
print("Vowels=",vow)
print("Consonants=",cons)
print("Lowercase=",low)
print("Uppercase=",up)
Output :-
Vowels= 6
Consonants= 8
Lowercase= 4
Uppercase= 10
Program :-
print("Smallest element=",min(numbers))
print("Largest element=",max(numbers))
Output :-
Smallest element= 2
Largest element= 85
5 Input a list of numbers and swap elements at the even location with the
elements at the odd location.
Program :-
if len(numbers)%2==0:
n=len(numbers)
else:
n=len(numbers)-1
for i in range(n):
if i%2==0:
numbers[i],numbers[i+1]=numbers[i+1],numbers[i]
print("Changed list=",numbers)
Output :-
Program :-
if ele in numbers:
else:
Output :-
7 Create a dictionary with the roll number, name and marks of n students in a
class and display the names of students who have scored marks above 75.
Program :-
srecords=dict()
rollno=int(input("Rollno.?"))
sname=input("Name of student?")
marks=float(input("Marks?"))
srecords[rollno]=(sname,marks)
if srecords[rollno][1]>75:
print(srecords[rollno][0])
Output :-
Rollno.?1
Name of student?Sakshi
Marks?78
Rollno.?2
Name of student?Devansh
Marks?65
Rollno.?3
Name of student?Rohan
Marks?85
Rollno.?4
Name of student?Milind
Marks?64
Rollno.?5
Name of student?Manish
Marks?90
Sakshi
Rohan
Manish
8 Write a program which takes a string as an argument, count and display the
occurrence of words starting with a vowel in the given string.
Program :-
text=input("Enter a string:")
words=text.split()
c=0
for x in words:
if x[0] in 'aeiouAEIOU':
c+=1
print("no.of words starting with vowel=",c)
output :-
i. Ask position of the element to be deleted and delete the element at the
desired position in the list.
ii. Print the sum of all elements.
Program :-
print("element deleted=",L.pop(pos-1))
print("L=",L)
Output :-
L= [5, 6, 8, 7, 10]
−𝑏±√𝐷
Formula for calculation of roots = 2𝑎
Program :-
import math
d=b*b-4*a*c
if d<0:
print("Imaginary roots")
elif d==0:
r=-b/(2*a)
else:
r1=(-b+math.sqrt(d))/(2*a)
r2=(-b-math.sqrt(d))/(2*a)
Enter a:3
Enter b:2
Enter c:4
Imaginary roots
Enter a:2
Enter b:-5
Enter c:3
**************