We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
PERIODIC TEST - 1- 2023 - 2024
Computer Science
She
Timethr3o min
General instru, tions:
This Question paper has 2 sections, Section A & B. All questions are compulsory.
Section has 11 questions carrying 01 mark each.
Section p has 12 questions carrying 2 marks each.
All Programming questions are to be answered using Python Language only.
SECTION-A
VELAMMAL VIDHYASHRAM, Surapet { 2
Date: 18.04.2023 Max: 35 Marks
1. State True of False.
“In Python, else block defined after the loop will be executed only when the loop is
terminated by break statement.”
2. Given a function that does not return any value, what value is thrown by default when
executed in shell?
(a) int {b) bool. (c) void(df None
3. Add a pair of parentheses to each expression so that it evaluates to True.
alee a= Oy) == 06 === 5)
4. Select the correct output of the code:
STR= "Architect of your own life"
D=STR.partition("life")
print(D)
(a) (‘Architect of your own’, 'life') \(b) (Architect of your own ', ‘life’, '')
{b) ("Architect of your own "life') (d) (‘Architect of your own’, ‘ife']
5, Which of the following statement(s) would give an error afterexecuting the
following code?
C=svAWsyeBr: 27GtS #statement 1
sum_keys = 0 statement 2 -
for val in d.keys(): statements yyn yor. Yaar
sum_keys = sum_keys + val #statement 4 Oyon Jip ) () 4 $2
print(sum_keys) ? ve vad ¢
(a) Statement 1(b) Statement 2 (c) Statement 3 (d) Statement 4
6. Which of the following functions return 0 and -1 respectively, if the element given as
parameter in those functions, is not found in a defined string?
(a) find(), count() —_—_(b) index(), find() (c) count(), find) (d) find(),index()
7. Given Fruit = {"Apple”: 100 , “Grapes”: 75, “Cherry”: 15}, Which of the
following methods will display the value 75 for a given key “Grapes”,
(a) get() (b) items() {c) keys() _(d) values()
8, What will be the output for the following python statement?
T=(10,20,[30,40,50],60,70)
T[2]{4]=100
print(T)
{a) (10,20,100,60,70) {b) (10,20,{30,100,50},60,70)
(c) (10,20,[100,40,50],60,70) (d) ErrorwpoweR’ at the 5" =
9, Which of the following statement(s) will add a new string 'POWE! POSition
Value in the list L? MATIC")
L=["ENERGY", "INSPIRE", "COURAGE", "WISDOM’, ani nd("POWER)
i ny 1) 2 ”
(a) L.append({"POwER") (¢) Linsert(-1,"POWER")
(c) Linsert(5,"POWER")
Q.10 and Q.41 are ASSERTION (A) and REASONING (R) based questions.
Mark the correct choice as
(2) Both (A) and (R) are True and (R) is the correct explanation for (A).
(b) Both (A) and (R) are True and (R) not is the correct explanation for (A).
(c) (A) is true but (R) is false. (d) (A) is false but (R) is true.
10. Assertion (A): The title() function in python is used to convert the first character in each
word to Uppercase and remaining characters to Lowercase in the string and returns an
updated string.
Reason(R): Strings are immutable in python.
11, Assertion (A): When slicing a string, the slicing statement is able to return a String which
can be assigned to L value.
Reason (R): Slicing process upon iterable objects such as list, tuples, and strings would
always return the output in the respective type used.
SECTION -B
12, Rewrite the following code in python after removing all the syntax errors.
Underline each correction done in the code.
num1, num2= 10
While num1% num2 = 0
num1+= 20
num2+= 30
Else:
print(‘hello’)
13, What will the following expression be evaluated to in Python?
print(25 //4+3**1**2 * 2)
(a) 24 (b) 18 (06 (d)12
14. Write the output to the following codes (a) and (b):
Tday="Focus from Self-image to Self-esteem”
X=Tday.split()
print(X{0},x[3],x{4})
print(Tday.capitalize(), Tday. title())
15. An immutable data type is one that cannot change after being created, Give three
reasons to immutable data.
(oR)
Differentiate between break and continue statement in Python.
16. (a) Given is a Python string declaration:
message="Bring it on!!!"
Write the output of: print(message
(b) Write the output of the code given belo
book_dict = {"title": "You can win", “copies”:15}
book_dict['author'] = “Shiv Khera”
book_dict['genre'] = "Motivation"
print(book_dict.items())
ee een ee en ee eaeper
47. a)What
b) Why Se ee can be used as keys in dictionaries?
18. Write the output A Used as keys In dictionaries?
ann put of the code given below:
Name="9@Days"
forx in name:
ifxIn "aelou"s
strestr+x.upper()
elif not x.Isalnum():
Strestr+""#"
elif x.isdigit():
pass
else:
str=str+x.lower()
print(str)
19. Find the output of the following code:
Moves=[11, 22, 33, 44]
Queen=Moves
Moves[2]+=22
L=len(Moves)
for iin range (L):
print("Now@", Queen|[L-i-1], "#", Moves [i])
20. Predict the output of following code.
tupled = ({7,6], [44], [5,9], [3,41 (5.5) 16,2], [8,4])
listy = list( tuple)
new_list = list()
for elem in listy:
tot=0
for value in elem:
tot += value
if elem.count(value) == 2:
new_list.append(value)
tot=0
else:
print( tuple(new_list) )
24, Write a program that creates a list of all integers less than 100 that are multiples of 3 or 5.
22, Write a short python code segment that print the longest word in the list of the word.
23. Write a Python program to define a list of strings and display the strings if Palindrome.
Sample Input:
Lwords=["Noon
Sample Output:
Noon
Rotator
Deed
Level
(oR)
Write a Python program to define a dictionary with student records as given below
and display the student names whose marks is greater than 85.
Rotator",""Civics","Good","Deed", "| Level")
Sample Input:
Stud_rec=("RAVIN":93,"AMIR":74, "ARUN":86,"NIRMAL":77}
Sample Output:
RAVINSARUNS:
ee eeeeeR EE
Se ee ee oe