0% found this document useful (0 votes)
7 views22 pages

UTKARSHSINGHCLASS12CSRECORDFILE Final2023

This document is a record file for Utkarsh Singh from Delhi Public School, Nerul, Navi Mumbai, certifying his completion of practicals for the AISSCE-2024 examination. It includes an index of programming tasks, with detailed coding examples and outputs for various exercises involving nested tuples, string manipulation, list operations, and dictionary usage. The document serves as a comprehensive record of the student's practical work and programming skills.
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)
7 views22 pages

UTKARSHSINGHCLASS12CSRECORDFILE Final2023

This document is a record file for Utkarsh Singh from Delhi Public School, Nerul, Navi Mumbai, certifying his completion of practicals for the AISSCE-2024 examination. It includes an index of programming tasks, with detailed coding examples and outputs for various exercises involving nested tuples, string manipulation, list operations, and dictionary usage. The document serves as a comprehensive record of the student's practical work and programming skills.
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
You are on page 1/ 22

DELHI PUBLIC SCHOOL

NERUL , NAVI MUMBAI


RECORD FILE-2024

Name: UTKARSH SINGH

Board Rollno:
DELHI PUBLIC SCHOOL
NERUL , NAVI MUMBAI
Certificate

This is to certify that this record file is the work of

Utkarsh Singh of Class XII ,Board Roll

Number____________________.

He has satisfactorily completed the required number of

practicals as per the guidelines of the Central Board of

Secondary Education for AISSCE-2024 practical

examination.

____________ __________ __________ _____

Internal External Principal School


Seal
Examiner Examiner

INDEX
SNO Program Pagen Date Sign
o

1.
Working with nested tuples

2. Check for unique characters in a string

3. Using inbuilt string methods

4. Alternate location swap in a list

5. Mirror image of alphabets using a dictionary

Working with a dictionary using a menu driven


6.
program.

7. Working with a list of strings.

Working with a list of tuples.


8.
PROGRAM 1:

Q1. Accept 3 marks for 5 students using a nested tuple.


Display the total and average marks of each student.

CODE:
st=()
sum=0
avg=0
for i in range(5):
print("\nPlease enter the marks for student ",i+1)
m1=int(input('Please enter the marks '))
m2=int(input('Please enter the marks '))
m3=int(input('Please enter the marks '))
st+=(m1,m2,m3)
sum=m1+m2+m3
avg=sum/3
print('Total marks of student',i+1,' is ',sum)
print('average marks of student',i+1,' is ',avg)

OUTPUT:

Please enter the marks for student 1

Please enter the marks 99


Please enter the marks 98

Please enter the marks 100

Total marks of student 1 is 297

average marks of student 1 is 99.0

Please enter the marks for student 2

Please enter the marks 92

Please enter the marks 95

Please enter the marks 97

Total marks of student 2 is 284

average marks of student 2 is 94.66666666666667

Please enter the marks for student 3

Please enter the marks 82

Please enter the marks 83

Please enter the marks 89

Total marks of student 3 is 254

average marks of student 3 is 84.66666666666667

Please enter the marks for student 4

Please enter the marks 56

Please enter the marks 62

Please enter the marks 71

Total marks of student 4 is 189

average marks of student 4 is 63.0

Please enter the marks for student 5


Please enter the marks 75

Please enter the marks 74

Please enter the marks 78

Total marks of student 5 is 227

average marks of student 5 is 75.66666666666667

=
PROGRAM 2:
Q2. Accept a string and check if it contains all unique
characters. Display the entered string and the message
UNIQUE or NOT UNIQUE Ex: If entered string is ‘apple’
display NOT UNIQUE and if the entered string is
‘bats*29’ display UNIQUE.

CODE:

Str = input('Please enter a string ')


c=0
for i in Str:
if Str.count(i)>1:
c+=1
print('NOT UNIQUE')
break
if c==0:
print('UNIQUE')

OUTPUT:
Please enter a string ABCD_123
UNIQUE
Please enter a string APPLE
NOT UNIQUE
Program 3:
Q3. Accept a string S and a word W from the user and do
the following(Use in built string methods ) a. Check if
the string begins with the accepted word and display
appropriate messages. b. Check if the string ends with
the accepted word and display appropriate messages. c.
Partition the string with the accepted word and display
the partitioned tuple. d. Replace all occurrences of the
given word by ‘***’ in the string and display the
replaced string. e. Swap the case of the string and
display the swapped string. f. Join every word of the
given string with ‘#’ and display the joined string

S = input('Please enter a string ')


W =input('Please enter a string ')
# startswith
if S.startswith(W):
print("IT BEGINS WITH THE WORD ", W)
else:
print("IT DOES NOT BEGINS WITH", W)
#endswith
if S.endswith(W):
print("IT DOES ENDS WITH", W)
else:
print("IT DOES NOT ENDS WITH", W)

#partition
print('\nPartitioned String: ')
print(S.partition(W))

#replace
print('\nreplaced String: ')
print(S.replace(W,'***'))

#swap
print('\nCase swapped String: ')
print(S.swapcase())

#join
print('\n# joint String: ')
print('#'.join(S.split()))
OUTPUT:

Please enter a string MY NAME IS UTKARSH


Please enter a string MY
IT BEGINS WITH THE WORD MY
IT DOES NOT ENDS WITH MY

Partitioned String:
('', 'MY', ' NAME IS UTKARSH')

replaced String:
*** NAME IS UTKARSH
Case swapped String:
my name is utkarsh

# joint String:
MY#NAME#IS#UTKARSH

PROGRAM 4:

Q4. Accept a list of EIGHT numbers as per the users


choice. Swap the alternate locations of the list as shown
below. Display the list before and after the change. (No
new list to be used. Work on the original list)

CODE:
L = eval(input('Please enter a list of eight numbers '))
L1=L.copy()
for i in range(0,8,2):
L[i],L[i+1]=L[i+1],L[i]
print('The changed list after swapping is',L)
print("the original list is :",L1)

OUTPUT:

Please enter a list of eight numbers [10,20,30,40,50,60,70,80]


The changed string after swapping is [20, 10, 40, 30, 60, 50, 80, 70]
the original list is : [10, 20, 30, 40, 50, 60, 70, 80]
PROPGRAM 5:
Q5. Create a dictionary to hold lower case alphabets as

keys and their mirror character as value. Accept a string

from the user( only having lowercase alphabets) and

display it in its mirror form using the dictionary.

CODE:
d={}
for i in range(26):
d[chr(97+i)]=chr(122-i)
print('mirror alphabet dictionary \n', d)
S = input('Please enter a lowercase string ')
mirror=''
for i in S:
mirror+=d[i]
print(mirror)

OUTPUT:

mirror alphabet dictionary


{'a': 'z', 'b': 'y', 'c': 'x', 'd': 'w', 'e': 'v', 'f': 'u', 'g': 't', 'h': 's', 'i': 'r', 'j': 'q', 'k': 'p', 'l': 'o',
'm': 'n', 'n': 'm', 'o': 'l', 'p': 'k', 'q': 'j', 'r': 'i', 's': 'h', 't': 'g', 'u': 'f', 'v': 'e', 'w': 'd', 'x': 'c',
'y': 'b', 'z': 'a'}
Please enter a lowercase string abcde
Zyxwv
PROGRAM 6:

Q6. Write a menu driven program to add, update, delete

and display from a dictionary PRODUCT which has

product code as key and product name as value. Add:

Accept a product code and name from the user and add
into the dictionary. Update: Accept a product code and

new name from the user and update the dictionary.

Delete: Accept a product code and remove the product

details from the dictionary. If product code is not found

appropriate message has to be displayed. Display :

Accept a product code and display its name. If product

code is not found appropriate message has to be

displayed.

CODE:
PRODUCT={}
end = ''
pcode=0
pname=''
while end!='no':
S = input('Please enter the number beside the options to perform the functions
\n1.Add \n2.Update \n3.Delete \n4.Display\n ').lower()
if S=='1':
pcode = input('Please enter the product code ')
pname = input('Please enter the product name ')
PRODUCT[pcode]=pname
end=input('Do you want to continue? ').lower()

elif S=='2':
pcode = input('Please enter the product code ')
pname = input('Please enter the product name ')
PRODUCT[pcode]=pname
end=input('Do you want to continue? ').lower()

elif S=='3':
pcode = input('Please enter the product code ')
if pcode in PRODUCT:
del PRODUCT[pcode]
else:
print('The product does not exist')
end=input('Do you want to continue? ').lower()

elif S=='4':
pcode = input('Please enter the product code ')
if pcode in PRODUCT:
print('pname of the product is', PRODUCT[pcode])
else:
print('The product does not exist')
end=input('Do you want to continue? ').lower()

OUTPUT:
Please enter the number beside the options to perform the functions
1.Add
2.Update
3.Delete
4.Display
1
Please enter the product code SMG001
Please enter the product name SAMSUNGGALAXYULTRA
Do you want to continue? YES
Please enter the number beside the options to perform the functions
1.Add
2.Update
3.Delete
4.Display
2
Please enter the product code SMG002
Please enter the product name WIRELESSHEADPHONES
Do you want to continue? YES
Please enter the number beside the options to perform the functions
1.Add
2.Update
3.Delete
4.Display
3
Please enter the product code SMG001
Do you want to continue? YES
Please enter the number beside the options to perform the functions
1.Add
2.Update
3.Delete
4.Display
4
Please enter the product code SMG002
pname of the product is WIRELESSHEADPHONES
Do you want to continue? NO

PROGRAM 7:

Q7. Accept a list of strings ‘S’ . Accept another list C

having a few characters. Remove all the strings from the

list S which have any or all of the characters present in

the list C.

Code:

S = eval(input('Please enter a list of strings '))

C = eval(input('Please enter a list of characters '))

for i in C:

for j in S:

if i in j:
S.remove(j)

print(S)

OUTPUT:

Please enter a list of strings ["apple","is","good","for","health"]

Please enter a list of characters ["a","i"]

['good', 'for']
PROGRAM 8:
Accept a list of tuples T. Each tuple has numbers in it.
Accept another integer K . Display all those tuples which
have numbers having K digits in it.

CODE:

T = eval(input('Please enter a list of tuples having numbers '))

K = eval(input('Please enter a number '))

for i in T:

for j in i:

if len(str(j))!=K:

break
else:

print(i)

OUTPUT:

Please enter a list of tuples having numbers [(22,33,44,55),(12,24,36,48,60),(111,222,333,444,555),


(2,4,8),(18,36,54,72)]

Please enter a number 2

(22, 33, 44, 55)

(12, 24, 36, 48, 60)

(18, 36, 54, 72)

You might also like