11th Grade Computer Practicals
11th Grade Computer Practicals
11th Grade Computer Practicals
CLASS : XI – E (BOYS)
CERTIFICATE
This is to certify that Cadet Jeetamitra Nayak CBSE Roll No:27115574 has
satisfactorily completed the laboratory work in COMPUTER SCIENCE (083) Python laid down
in the regulations of CBSE for the purpose of AISSCE Practical Examination _________
in Class XI to be held in Bright Riders School, Abu Dhabi on______________.
(Ms.Nithya)
PGT for Computer Science
Examiners:
1 Name:Ms.Nithya Signature:
(Internal)
INDEX
S.NO DATE PROGRAMS PAGE NO SIGNATURE
PYTHON PROGRAMS
Python program to Input two numbers and display
1. 1 28/1/23 the larger and smaller number. 4
Python program to Input three numbers and display
2. “ the largest / smallest number. 5
Write a program to input the value of x and n and
3. “ print the sum of the following series: 7
1+x+x2+x3+x4+ ............xn
Write a program to find the sum of following series
4. “ x + x2/2 + ……….xn/n 8
Python program to Determine whether a number is
5. “ a perfect number. 8
Python program to Determine whether a number is
6. “ an Armstrong number. 9
Python program to Determine whether a number is
7. “ a palindrome. 9
Python program to Input a number and check if the
8. “ number is a prime or composite number. 10
13. “ 13
CODING:
OUTPUT:
Enter any number1:- 2
Enter any number2:- 3
3 is greater than number 2
2. Python program to Input three numbers and display
the largest / smallest number.
CODING:
OUTPUT:
Enter any number1:- 5
Enter any number2:- 1
Enter any number3:- 7
7 is greatest, 1 is the smallest
3) Write a program to input the value of x and n and print
the sum of the following series:
1+x+x2+x3+x4+ ............xn
CODING:
x = float (input("Enter value of x:- "))
n = int (input ("Enter value of n:-"))
s = 0
for a in range (n + 1) :
s+= x**a
print ("Sum of Series:- ",s)
OUTPUT:
CODING:
x = int(input("Enter the value of x: "))
n = int(input("Enter the value of n: "))
sum = 0
m = 1
for i in range(1, n) :
fact = 1
for j in range(1, i+1) :
fact *= j
term = x ** i / fact
sum += term * m
m = m * -1
OUTPUT:
Enter the value of x: 5
Enter the value of n: 6
Sum = 13.333333333333332
CODING:
n=int(input("Enter a number to check:"))
temp = n
cnt=0
while temp > 0:
digit = temp % 10
cnt += digit ** 3
temp //= 10
if n == cnt:
print(n, "is an Armstrong number")
else:
print(n, "is not an Armstrong number")
OUTPUT:
Enter a number to check: 6
6 is not an Armstrong number
CODING:
n=int(input("Enter a number to check:"))
rev=0
temp = n
while n > 0:
dig = n % 10
rev = rev * 10 + dig
n = n // 10
if temp == rev:
print(temp, "The number is a palindrome!")
else:
print(temp, "The number isn’t a palindrome!")
OUTPUT:
Enter a number to check:6
6 The number is a palindrome!
8) Python program to Input a number and check if the number is
a prime or composite number.
CODING:
num=int(input("enter a number "))
if num>1:
for x in range(2,num):
if num%x == 0:
print("composite number")
break
else:
print("prime number")
elif num<0:
print("negative numbers cannot be determined if prime or composite")
else:
print("neither prime nor composite")
OUTPUT:
enter a number 6
composite number
CODING:
nterms = int(input("Enter number of terms to display:"))
n1, n2 = 0, 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1,end=" ")
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1, ",", end=" ")
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
OUTPUT:
Enter number of terms to display:7
Fibonacci sequence:
0 , 1 , 1 , 2 , 3 , 5 , 8 ,
CODING:
num1 = int(input('Enter your first number: '))
num2 = int(input('Enter your second number: '))
def compute_lcm(x, y):
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
print("The L.C.M. is", compute_lcm(num1, num2))
OUTPUT:
Enter your first number: 6
Enter your second number: 4
The L.C.M. is 12
11) Python program to Count and display the number of vowels,
consonants, uppercase, lowercase characters in string.
CODING:
txt = input("Enter Your text : ")
v = c = uc = lc = 0
v_list = ['a','e','i','o','u','A','E','I','O','U']
for i in txt:
if i in v_list:
v += 1
if i.isalpha():
if i not in v_list:
c += 1
if i.isupper():
uc += 1
if i.islower():
lc += 1
print("Number of Vowels in this text = ", v)
print("Number of Consonants in this text = ", c)
print("Number of Uppercase characters in this text = ", uc)
print("Number of Lowercase characters in this text = ", lc)
OUTPUT:
CODING:
a=(input("enter the string"))
b=str(a)
c=b[::-1]
if(b==c):
print("it is a palindrome")
else:
print("not a palindrome")
OUTPUT: -
enter the string ONLINE CLASS IS BETTER
not a palindrome
rows = 5
for i in range(0, rows):
# nested loop for each column
for j in range(0, i + 1):
# print star
print("*", end=' ')
# new line after each row
print("\r")
OUTPUT:-
*
**
***
****
*****
CODING:-
lst = []
num = int(input('How many numbers: '))
for n in range(num):
numbers = int(input('Enter number '))
lst.append(numbers)
print("Maximum element in the list is :", max(lst), "\nMinimum element in the list is
:", min(lst))
OUTPUT:-
How many numbers: 5
Enter number 1
Enter number 2
Enter number 3
Enter number 4
Enter number 4
Maximum element in the list is : 4
Minimum element in the list is : 1
CODING:-
val=eval(input("Enter a list "))
print("Original List is:",val)
s=len(val)
if s%2!=0:
s=s-1
for i in range(0,s,2):
val[i],val[i+1]=val[i+1],val[i]
print("List after swapping :",val)
CODING:-
lst = []
num = int(input('How many numbers: '))
for n in range(num):
numbers = int(input('Enter number '))
lst.append(numbers)
print("Sum of elements in given list is :", sum(lst))
OUTPUT:-
CODING:-
OUTPUT:-
18) Write a python 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:-
OUTPUT:-
Enter the number of students: 8
1
2
3
4
5
6
7
8
Enter name to find: 3
Name found
Name found
CODING:-
lgsmTuple = (78, 67, 44, 9, 34, 88, 11, 122, 23, 19)
print("Tuple Items = ", lgsmTuple)
20) Write a python program to add the integers in a Tuple and display the sum.
CODING:-
t = list()
for i in range(n):
t.append(int(input('>> ')))
t = tuple(t)
s = sum(t)
print('Given tuple:', t)
print('Sum of elements:', s)
OUTPUT:-
21) Write python program to search for the given element in the tuple.
CODING:-
OUTPUT:-
Enter the number of students: 6
1
2
3
4
5
6
Enter name to find: 6
Name found
22) Write a python program to find the highest two values in a dictionary
CODING:-
OUTPUT:-
Second largest element found = 11
CODING:-
color_dict = {'red': '#FF0000',
'green': '#008000',
'black': '#000000',
'white': '#FFFFFF'}
OUTPUT:-
black: #000000
green: #008000
red: #FF0000
white: #FFFFFF
24) Write a Python program to print a dictionary where the keys are numbers between 1 and 15 (both
included) and the values are square of keys.
CODING:-
d = dict()
for x in range(1, 16):
d[x] = x ** 2
print(d)
OUTPUT:-
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196,
15: 225}