Python Revision Tour Imp Question
Python Revision Tour Imp Question
Python
Revision
Tour
Important Questions
Important Question of Python Revision
Tour
Valid / invalid Identifiers. Concatenation and
Type of tokens
Error
Random module
Output(string /list/ tuple) (inbuilt
Slicing
State True and False
“Variable declaration is implicit in python”
“The extend method extends the 1st list with 2nd list contents”
“A list is immutable”
“A string is immutable”
“A dictionary is immutable”
(a) Modularity
(b) Reusability
(c) Simplicity
The method that can be delete a range of values from a list is del.
Given a dictionary dream. The statement dream.items() displays the keys of the
item only.
1. 2_Myname
2. My name
3. True
4. Myname_2
operator
1. a>b or a>c
Q. Which of the following operator can be used with string data type?
1. **
2. %
3. +
4. /
Evaluate the expressions
operator
a) **
b) ==
c) is
d)or
e) not in
Evaluate the expressions
(a) 14.75
(b)14.0
(c) 15
(d) 15.5
Output
i=1
while True:
if i % 007 == 0:
break
print(i)
Output
X=5678
while X>0:
print(X)
X=X//10
Output
St=“Dream”
for i in St:
print(i ,” ”,end=“ “)
What is the use of id() function in python?
t1= (9,5,4,3)
t2=(7,0,9,8)
t=t1+t2
print(t)
Output
import math
a=math.ceil(20.5)
b=a/5
c=math.floor(b)
print(c)
Output
What will be the output
1. ‘Dream Technology’.count(‘olo’7,16)
2. dic={}
dic[(1,2,3)]=8
dic[(4,2,1)]=10
dic[(1,2)]=24
sum=0
for i in dic:
sum=sum+dic[i]
print(sum)
Output
• What will be the output
print(print(“Dream”))
Output
• Write the output of the following given python code
Msg1="WelcOME"
Msg2="GUESTS“
Msg3="“
for I in range(0,len(Msg2)+1):
if Msg1[1]>="A" and Msg1[1]<="M":
Msg3-Msg3+Msg1[1]
elif Msg1[1]="N" and Msg1[1]<="2":
Msg3-Msg3+Msg2[1]
else:
Msg3-Msg3+"*"print (Msg3)
Output
for i in range(1,10):
pass
print(i)
Output
X=(1,)
print(X*2)
y=(1)
print(Y*2)
Output
• Consider the following code.
• x=10
• y=x
• print(x==y)
• print(id(x)==id(y))
Output
my_dict['age'] = 27
my_dict['address'] = "Delhi“
print (my_dict.items())
Output
Output
• Predict the output of the Python code given below:
tuple1 = (11, 22, 33, 44, 55,66)
listl =list (tuple1)
new list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple
tuple (new_list) = print (new_tuple)
Output
Output
Output
0o11 is equal to 1⋅8¹ + 1⋅8⁰ = 9
1. s[4:]
2. s[:4]
3. s[-4:]
4. s[:-4]
The append() method adds an element at
1. First
2. Last
3. specified index
4. at any location
Rewrite the following program after removing all error(s), also underline each
correction
N=int(input("Enter any number")
For i in range(1,N)
if N%i==0:
c=c+1
if c=2:
print(Prime)
Else:
print(Not a prime)
Which of the following is invalid data type in python.
1. Set
2. None
3. Integer
4. Real
Given an object obj1=(10,20,30,40,50,60,70,80,90).What will be the
output of print(obj1[3:7:2])?
1. (40,50,60,70,80)
2. (40,50,60,70)
3. (40,50,60)
4. (40,60)
Which of the following is/are not python keyword?
1. True
2. break
3. math
4. for
Consider the given expression:
not 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) NULL
In complex number a+ib ,b represents as
1. Real number
2. Imaginary part
3. Special part
4. None of these
DREAM
TECNOLOGY