Python Revision Tour Practice Question
Identifiers ,keywords and operator(expression evaluation) X=int(13.25+4/2)
(types of questions) (2M)
a) 17 b) 14 c) 15 d) 23
Q1. which of the following is valid identifiers.
[Link] the expression 8/4/2
a)2My_Days b)Day_two c)Day two d)2 day
a) 4 b)4.0 c)1 d)1.0
Q2. Which of the following is a invalid identifiers
[Link] is the value of the following expression:
a) _my b) _2 c)my 2 d)my_2
X=(3+3.0 , 3**3.0)
Q2.1 Which of the following is a invalid identifiers
a)(6.0,27.0) b) (6.0,9.0) c) (6,27) d) [6.0,27.0]
a) Roll_no b) Salary c) Account no d) Empid
Q14. What will be the output of the following statement:
[Link] of the following is not considered as a valid
(16*5/4*2/5-8)
identifiers in python?
a) -3.30 b) 6.0 c) 0.0 d) -13.33
a) two2 b) _main c) hello_rsp1 d) 2 hundred
[Link] is the purpose of the // python operator and
Q4. Find the valid identifiers from the following.
solve the expression.
in is Name2nd with My Name is not
(25+7)//(3*2)
true _init_ not in
Q what will be the output of the following statement .
Q4.1 Find the invalid identifier
print(3-10**2+99/11)
a) Name b) class c) section d)break
[Link] the type of the tokens [Link] of the Following expression evaluate the True?
1. if a)(False) or (True and False) b) (False and True) or not
2. roll_no
(False) c)(True and not(True)) or (False)
Q6. The reserved words in python are called ............... and d) not(True or False) and True
these can’t be used names or identifiers.
Q17 which of the following expression evaluate the True?
[Link]: Every small unit in a python programming
a) not(True and False) or False b) True and (False or
statement is termed as a token.
not(True)) c)False and (True or not(False))
Reason: Tokens are not interpreted but are an integral part
d) not(False or True)and True
while designing the code.
Q18. which of the following expression evaluate the False?
[Link] of the following is not a keyword.
a) not(False) and True b)True or not(False) c)
a) eval b) else c) nonlocal d)pass
not(True and False) d) False and (True or False)
Q9. Evaluate the expression :14+13%15
a) 14 b) 27 c) 12 d) 0
Q10. Evaluate the expression A%B//A if A=16 and B=15
a) 0.0 b) 0 c)1.0 d) 1
[Link] is the value of X?
Python Revision Tour Practice Question
Q19. Assertion: The assignment operator assign or change Q32. State True or False
the value of the variable on its right side. “continue keyword skips remaining part of an iteration in a loop”
Reason: The logical operator evaluate to either True or Q33.
False based on the logical operands on either side. Rewrite the following code in python after removing syntax error.
Underline each correction done in the code.
Q20 What will be the output of the following expression:
30 = To
print(5+3**2/2)
for K in range(0,To)
a)32 b) 8.0 c)9.5 d) 32.0 IF k% * 4 = 0
print ( K * 4)
Q21 which of the following is a valid logical operator. Else:
print (K + 3)
a) && b) || c) > d) and
Q22. The ……Operator used with the tuple and an
integer ,gives a replicated tuple.
Q23 The …… ............. operator concatenate .
Q24. State True/False “Keywords can be used as identifiers
in python”
Q25. The ....................... is the empty statement in python.
Q34.
Q26. State True /False : “Variable name can be begin with
_symbol” “HELLO”=string
for i in range(0,len(string)-1)
if string[i]=> “M”
print string[i], “*”
Else
Q27. Which of the following is a invalid datatype in python print string[i-1]
Ans:
a) int b) float c) super d)None of these
Q28. State True or False
“Python identifiers are dynamically typed” (i) for Name in[Ramesh,Suraj,Priya]
IF Name[0]=‘S’:
Q29. Which of the following is a invalid operator. print(Name)
a)+= b) /= c) in d)=% ii) String=“Welcome Note”
[Link] a python program if a break statement is given in for S in range [0,8]:
nested loop ,it terminate the execution of all loops in one print string(s)
go. print s+string
[Link] True or False:
“In a Python loops can also have else clause”
Python Revision Tour Practice Question
else :
iii) Num=int(input(“Number:”)) print( Number *2)
sum=0 Number=Number+50
for i in range(10, Num,3)
Sum+=I
STRING QUESTION
if i%2=0:
Q. message=“World Peace”
print i*2
print(message[-2: :-2]
Else:
print i*3
[Link]=“ programming”
iv) Val=int(rawinput(“Value”)) print(str[-3:-9:-2])
Adder=0
for i in range(1,Val,3) Q .text=“WelcomeToPython”
Adder+=I print(text[-11:-7])
if i%2=0:
Print i*10
Else:
print i
else:
print( i) Q. What will be the output of the snippet?
text=“DataScienceRocks”
v) 250=Number print(text[2:-6])
WHILE Number<=1000:
if Number =>750:
print Number
Number=Number+100
else
print Number *2
Number=Number+50
Python Revision Tour Practice Question
c) #THON#PROGRAME
d) #YTHON#PROGRAM
Q What will be the output of the following snippet?
text=“Data Science”
print(text[::4][::-1])
Q T=“Hello World”
T=[Link](‘ ‘ , ‘_’)
print(T)
Q L=“Learning Python” a) Hello_World b)HelloWorld c)H_e_l_l_o_W_o_r_l_d
print(L[-1:-6:-1]
d)Hello_W_o_r_l_d
Q. text=“abcdef”
Q. What is the output of the following code
print(text[:-5:-1]
Country=‘International’
print([Link](“n”)
a) (‘I’ ,’ter’, ‘atio’ ,’al’)
Q text=“Python”
b) [‘I’ ,’ter’, ‘atio’ ,’al’]
result=text[1:4]+text[-1]
c) [‘I’ ,’n’,’ter’, ’n’ ,‘atio’ ,’al’]
print(result)
d) Error
a)yth b) ythn c) Pytho d)on
Q s=“python is fun Programming”
Q. data=“Data Science”
print([Link](“ ”))
print(data[:4]+data[5:])
a)[‘python’ ,’is fun’ ,’programming’] b) [‘python is’ ,’ fun’
a)DataScience b)DataSicence c) Data Science d)Error
,’programming’] c) )[‘python’ ,’is’, fun’ ,’programming’]
d) Error
Q A=“Python programming”
print(A[::2])
Q. What will be the output of the snippet?
a) Pto rgamn b) Pythnpormig c) Python programming
Text=“APPLEAPPLEAPPLEBANANA”
d)Error
A=[Link](“APPLE”)
B=[Link](“BANANA”)
Q .text=“PYTHONPROGRAME”
print(A,B)
text=[Link](“PY”, ”#”)
a) 3 1 b) 3 0 c) 1 3 d) 0 3
print(text)
Q. text=##welcome#to#the#Python#world##”
a) #THONPROGRAME
s=[Link](“#”)
b) ##THONPROGRAME
print(s)
a) welcome#to#the#Python#world
b) welcome#to#the#Python#world##
c) welcometothePythonworld
d) ##welcome#to#the#Python#world
Q A=“PYTHON”
B=[Link]()
print(B)
a) python b) Python c)PYTHON D)Error
Python Revision Tour Practice Question
Q
Output Based Question(string): s='welcome2cs'
s="Racecar Car Radar" n=len(s)
L=[Link]() m=''
for W in L: for i in range(0,n):
x=[Link]() if s[i]>='a' and s[i]<='m':
if x==x[::-1]: m=m+s[i].upper()
for I in x: elif s[i]>='n' and s[i]<='z':
print(I,end="*") m=m+s[i-1]
else: elif s[i].isupper():
for I in x: m=m+s[i].lower()
print(I,end="#") else:
print() m=m+'&'
print(m)
Q
str1='EXAM2020'
str2=''
I=0 Q
while I<len(str1): def makenew(mystr):
if str1[I]>='A' and str1[I]<='M': newstr=""
str2=str2+str1[I+1] count=0
elif str1[I]>='0' and str1[I]<='9': for i in mystr:
str2=str2+str1[I-1] if count%2!=0:
else: newstr=newstr+str(count)
str2=str2+'*' else:
I=I+1 if [Link]():
print(str2) newstr=newstr+[Link]()
else:
Q newstr=newstr+i
str1="EXAM2020" count=count+1
str2="" print(newstr)
I=0 makenew("No@1")
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]
else:
str2=str2+"#"
I=I+1
print(str2)
Python Revision Tour Practice Question
Assertion and reason Based Question(String)
Assertion: String is a sequence which is made up of one or
more UNICODE characters.
Reason: A string is created by enclosing one or more character
in the single,double,triple quotes.
Assertion: Python allows an index value to be positive only.
Reason: Negative indices are used when we want to access the
character of string from right to left.
Assertion: String in python is mutable
Reason: The character index 0 and the last character has the
index n-1 .where n is length of string.