0% found this document useful (0 votes)
41 views3 pages

Cs HHW

Uploaded by

acegecko1969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Cs HHW

Uploaded by

acegecko1969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SUMMER HOLIDAY HW FOR XII CS 2024-25

1 Out of the following, find those identifiers, which cannot be used for naming Variables or
functions in a Python program:
#Tag, While, Class, Switch, 3rdRow, finally, Column 31, Total+ , Days * Rent, For, A_price,
Grand Total, do, 2Clients, Participant13, My_city

2 Which string method is used to implement the following:


i To count the number of characters in the string.
ii To change the first character of the string in capital letter.
iii To check whether given character is letter or a number.
iv To change lowercase to uppercase letter.
v Change one character into another character.

3 Write a program to check whether a string is palindrome or not.

4 WAP a program to reverse a number (without using slicing) and check whether it is a palindrome
or not.

5 Rewrite the following for loop into while loop:


for a in range(90, 9, -9):
print (a)

6 Write a program to input any string and to find the number of words in the string and also print
the 5th word.

7 How many times will Python execute the code inside the following while loop? You should
answer the question without using the interpreter! Justify your answers.
i=0
while i < 0 and i > 2 :
print “Hello ...”
i = i+1

8 What is the correct way to add an element to the end of a list in Python?
a. list.add(element) b. list.append(element) c. list.insert(element) d. list.extend(element)

9 What will be the output of print("Welcome To My Blog"[2:6] + "Welcome To My Blog"[5:9])


a. Lcomme b. lcomme T c. lcomme To d. lcomme

10 Which of the following statement(s) would give an error during the


execution of the following code?
R = {'pno':52,'pname':'Virat', 'expert':['Badminton','Tennis'] ,'score':(77,44)}
print(R) #Statement 1
R['expert'][0]='Cricket' #Statement 2
R['score'][0]=50 #Statement 3
R['pno']=50 #Statement 4
a. Statement 1 b. Statement 2 c. Statement 3 d. Statement 4
11 Given the following dictionaries
dict_student = {"rno" : "53", "name" : 'Rajveer Singh'}
dict_marks = {"Accts" : 87, "English" : 65}
Which statement will append the contents of dict_marks in dict_student?
a. dict_student + dict_marks b. dict_student.add(dict_marks)
c. dict_student.merge(dict_marks) d. dict_student.update(dict_marks)

12 Which of the following is not a component of the math module in Python?


a. ceil() b. mean() c. fabs() d. pi

13 Write the Python statement for each of the following tasks using BUILT-IN functions/methods
only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.

14 What will be the output of the following code?


L=["One , Two", "Three", "Four"]
print(len(L)/2*len(L[0]))
a. 6.5 b. 13 c. 13.5 d. 6.0
15 Write a program to add multiply two numbers through a function.

Take numbers as an input through user.

Give output outside the function through return statement.

Function name – calcPro()


16 Write the correct output for the following Python statement:
print("Computer Science"[-8:])
17 What will be the ouput given by following expression:
2**2**3= ________
18 Study the following program and select the possible output(s) from the options (i) to
(iv). Also, write the maximum and the minimum values that can be assigned to the
variable Y.
import random
X= random. random ( )
Y= random. randint (0,4)
print(int(X),":”, Y+int(X))
(i) 0: 0
(ii) 1: 6
(iii) 2: 4
(iv) 0: 3
19 Consider the following code and answer the five questions after the
code as per the Statements 1-5 respectively:
mystr=”sTUdeNT”
newstr = " "
count = 0
for i in ______: # Statement 1
if ___________: # Statement 2
newstr = newstr + str(count)
else:
if _________: # Statement 3
newstr = newstr + i.upper()
else:
newstr = _________ # Statement 4
count += 1
newstr = newstr + mystr[:1]
print("The new string is:", ________) # Statement 5
i. Write for loop to iterate the given string.
ii. Write if condition to check whether count is odd.
iii. Write if condition to check whether i is lower.
iv. Write the statement to assign the sum of newstr and i to newstr.
v. Write the print statement with the updated newstr.
20 Find the errors, underline and rewrite the program:
S=’Python program”
L=length(S)
for i in range[L]:
if i%2=0:
print(S[i])
else
print(S[i))

You might also like