You are on page 1of 3

International Indian School-Dammam

Class : XII ,Summer Holiday Assignment 2023-24

Q1. Rewrite the following code in python after removing all syntax error(s). Underline each correction
done in the code.

def Tot(Number) #Method to find Total


Sum=0
for C in Range (l, Number+l):

RETURN Sum
print Tot[3] #Function Calls

Q2. Find and write the output of the following python code :
(a)
def change(P,Q=30):
P=P+Q
Q=Q-P
print(P,”#”,Q)
return(p)
R=150
S=100
R=Change(R,S)
print(R,”#’,S)
S=Change(S)
print(R,”#”,S)

(b)
for Name in ['John','Garima','Seema','Karan']:
print( Name)
if Name[0]== 'S':
break
else :
print ('Completed!')
print ('Well done’)

(c)What possible outputs(s) are not expected to be displayed on screen at the time of execution
of the program from the following code? Also specify the maximum and minimum values that can
be assigned to the variable Start

import random
N=[20,30,40,50,60,70];
Start =random.randint(1,3)
End =random.randint(2,4)
for a in range(Start, End +1):
print ( N*a+,end=”@“)

(i) 30@40@50@ (ii) 10@40@70@ (iii) 40@50@70@


(iv) 50@60@70@

(d) Find and write the output of the following Python code:

Str1 = "EXAM2024"
Str2 = " "
I=0
while I<len(Str1):
if Str1[I]>="A" and Str1[I]<="M":
Str2=Str2+Str1[I+1]
elif Str1[I]>="0" and Str1[I]<="9":
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+"*"
I=I+1
print(Str2)

(e) def makenew(mystr):


newstr = " "
count = 0
for i in mystr:
if count%2 ==0:
newstr = newstr+i.lower()
else:
if i.islower():
newstr = newstr+i.upper()
else:
newstr = newstr+i
count +=1
newstr = newstr+mystr[:3]
print ("The new string is :",newstr)
makenew("St@akis2020")

Q3. (i)
Write definition of a method/function HowMany(ID,Val) to count and display number
of times the value of Val is present in the list ID.
For example,
If the ID contains [115,122,137,110,122,113]and Val contains 122
The function should display
122 found 2 Times

(ii) Write a python method/function Swapper(Numbers) to swap the first half of the
content of a list Numbers with second half of the content of list Numbers and
Note: Assuming that the list has even number of values in it
For Example:
If the list Numbers contain
[35,67,89,23,12,45]
After swapping the list content should be displayed as
[23,12,45,35,67,89]
(iii)
Write definition of a Method AFIND(CITIES) to display all the city names from a list
of CITIES, which are starting with alphabet A.
For example:
If the list CITIES contains

["AHMEDABAD","CHENNAI","NEW DELHI","AMRITSAR","AGRA"]

The following should get displayed


AHEMDABAD
AMRITSAR
Q4.

Q5. Consider the above table and answer the following questions
(i) Name the primary key of table Subject and Teacher
(ii) What is the degree and cardinality of table Subject
(iii) Mention the foreign key of table Teacher
(iv) Write the Sql commands
(a) To add a new column Grade of data type char and size 1 in table subject
(b) To display the name of columns , data type and size of table Teacher.
(c) To display a report containing subject code and subject name of all the subjects except Marks_Prac 0.
(d) To display subject code and Theory marks of all the subjects in ascending order of Title.
Q6. Consider the following tables and write the sql commands for (i) to (v)

You might also like