0% found this document useful (0 votes)
20 views

Worksheet Chapter-1 Revision of Python Basics

This document is a worksheet designed for Class XII students at PM SHRI KV Pitampura, Delhi, focusing on the revision of Python basics in preparation for the 2024-25 board exam. It contains a series of questions, including true/false statements, identification of valid identifiers, and code correction exercises, aimed at testing students' understanding of Python programming concepts. The worksheet covers various topics such as data types, loops, dictionaries, and string operations.

Uploaded by

adarshjha778
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)
20 views

Worksheet Chapter-1 Revision of Python Basics

This document is a worksheet designed for Class XII students at PM SHRI KV Pitampura, Delhi, focusing on the revision of Python basics in preparation for the 2024-25 board exam. It contains a series of questions, including true/false statements, identification of valid identifiers, and code correction exercises, aimed at testing students' understanding of Python programming concepts. The worksheet covers various topics such as data types, loops, dictionaries, and string operations.

Uploaded by

adarshjha778
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/ 4

PM SHRI KV PITAMPURA DELHI

XIIA CS PREPARATION OF BOARD EXAM 2024-25


Worksheet (Chapter-1)
Revision of Python Basics

1 State True or False


“Dictionary is data type in Python which contain data in key-value pair.”
2 State True or False:
“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”
3 State True or False
“Variable declaration is implicit in Python.”
4 Which of the following is not a valid identifier?
a. amount b. 10_amt c. Amount d. Amount5
5 Which of the following is not a keyword?
(A) eval (B) assert (C) nonlocal (D) pass
6 Find the invalid identifier from the following
a. none b. address c. Name d. pass
7 Which of the following is an invalid datatype in Python?
(a) Set (b) None (c)Integer (d)Real
8 Consider a declaration L = (1, 'Python', '3.14').
Which of the following represents the data type of L?
a. list b. tuple c. dictionary d. string
9 Given the following dictionaries
bank = {"Account Number" : "0113025330", "Customer Name" : "Shahana"}
bank1 = {"Balance" : 575895, "Gender" : "F"}
Which statement will merge the contents of both dictionaries?
a. bank + bank1 b. bank.add(bank1)
c. bank.merge(bank1) d. bank.update(bank1)
10 Identify the output of the following Python statements.
lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
a. 2 b. 3 c. 4 d. 20
11 Consider a tuple tup1 = (10, 15, 25, 30). Identify the statement that will result in an
error.
a. print(tup1[2]) b. tup1[2] = 20
c. print(min(tup1)) d. print(len(tup1))
12 Which of the following statement(s) would give an error after executing the
following code?
D={'rno':32,'name':'Ms Archana','subject':['hindi','english'],'marks':(85,75)} #S1
print(D) #S2
D['subject'][1]='IP' #S3
D['marks'][1]=80 #S4
print(D) #S5
(A) S1 (B) S3
(C) S4 (D) S3 and S4
13 Given a tuple Tup1=(25,35,43,22,13,56,45,78,90), Identify the statement from the
options below that will produce the result as (25,43,13,45)
a. print(Tup1[-9:-2:2]) b. print(Tup1[0:7:1])
c. print(Tup1[::2]) d. print(Tup1[-8:-2:2])
1
14 Consider the given expression:
not False or True and False or True
Which of the following will be correct output if the given expression is evaluated?
a. True b. False c. None d. Error
15 Select the correct output of the code:
t= "Smile @is the best #medicine"
t=t.split("best")
st = "So"+t[0] + "@@@" + t[1]
print(st)
16 Select the correct output of the following python code:
str="My program is program for you"
t = str.partition("program")
print(t)
17 Which of the following operations on a string will generate an error?
a. "DELHI"*4 b. "DELHI" + "400"
c. "DELHI" + 40 d. "DELHI" + "DELHI"
18 What will the following expression be evaluated in Python?
45/ 5 * 15// 2+5*7
a. 12.0 b. 120 c. error d. 120.0
19 Which of these about a dictionary is false?
a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c) Dictionaries aren’t ordered
d) Dictionaries are mutable
20 Identify the output of the following Python statements.
b=1
for a in range(1, 10, 2):
b += a + 2
print(b)
a. 31 b. 33 c. 36 d. 39
21 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
n1+= 20
n2+= 30
Else:
print(“hello’)
22 Rewrite the following code in python after removing all syntax error(s).
Underline each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)
23 Rewrite the following code in Python after removing all syntax
error(s). Underline each correction done in the code.
"HELLO"=String
for I in range(0,len(String)–1)
if String[I]=>"M":
print String[I],"*"
Else:
print String[I-1]
2
24 Find and write the output of the following Python code : 2
Str1="EXAM2018"
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)
25 What will be the output of the following string operation.
str="PYTHON@LANGUAGE"
print(str[2:12:2])
26 Predict the output of the following python code:
data = [2,4,2,1,2,1,3,3,4,4]
d={}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
27 What will be the output of the following python program?
str = " "
name = "9@Days"
for x in name:
if x in "aeiou":
str+=x.upper()
elif not x.isalnum():
str += " * "
elif x.isdigit():
pass
else:
str+=x.lower()
print(str)
28 What will be the output of the following code?
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
a. Delhi#Mumbai#Chennai#Kolkata#
b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi#
d. Mumbai# Mumbai #Chennai # Mumbai
29 Find the output of the following code:
Name="PythoN3.1"
R=" "
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
3
30 Predict the output of the Python code given below:
data=["L",20,"M",40,"N",60]
times=0
alpha=" "
add=0
for c in range(1,6,2):
times = times + c
alpha = alpha + data [c-1] + "@"
add = add + data[c]
print (times, add, alpha)
31 Predict the output of the Python code given below:
L=[1,2,3,4,5]
Lst=[ ]
for i in range(len(L)):
if i%2==1:
t=(L[i],L[i]**2)
Lst.append(t)
print(Lst)
32 Predict the output of the code given below:
s="C++VsPy"
m=" "
for i in range(0, len(s)):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)
33 Predict the output of the Python code given below:
P = (85,65,34,79,95,68)
Q =list(P)
R=[]
for i in Q:
if i%2==0:
R.append(i)
R = tuple(R)
print(R)
34 What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”# “)
(i) 10#40#70# (ii) 30#40#50#
(iii) 50#60#70# (iv) 40#50#70#

****** Prepared by Vijay Chawla, PGT(CS), PM SHRI KV Pitampura, Delhi *****

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy