Ip Revision Unit 2
Ip Revision Unit 2
1.
x,y=2,6
x,y=y,x+2
print(x,y)
2. What will be the output of the following expression
12 * ( 13%4 ) // 2 + 6
3.What is debugging?
4.Define type casting.
5. Explain Comments in python
6.
Shivi has written the following program but she is not getting the desired result
.Why ?
a=input(“enter a number”)
b=input(“enter 2nd Number”)
c=a+b
print(c)
7. Choose the correct identifier name
a) 9marks b)&sum c ) _Total d) All are correct
8. The Escape sequence \n is used for ………
9. Write output:
print( ‘H’ in ‘Hello’)
10. In Python a function is defined by ……….keyword.
11. What will be the output of the following code
p=10
q=20
p*=q/3
q+=p+q*2
print(p,q)
12.
Which of the following operators is the correct option for power(ab)?
a. a ^ b
b. a**b
c. a ^ ^ b
d. a ^ * b
13.
How many times following loop will execute:
for x in [1,3,5,7,9,11]:
print(x)
14.
Which will be the correct if statement for expression : “Place is either Delhi or
Goa but not Jaipur”
a. if place= = “Delhi” and place= = “Goa” and place != “Jaipur” :
b. if place= = “Delhi” or place= = “Goa” and place != “Jaipur” :
c. if place= = “Delhi” and place= = “Goa” or place != “Jaipur” :
d. if (place= = “Delhi” or place= = “Goa” ) and place != “Jaipur” :
15.
Consider the following code
X=int(input(“Enter integer”))
Y=int(input(“Enter integer”))
Z=int(input(“Enter integer”))
for K in range (X, Y, Z):
print(K, end= “ ,”)
What will be printed if the user enters 2 for X , 10 for Y and 2 for Z
16.
How many times “Entry” will print on screen after execution of given code:
for x in range(3,9,3):
print(“Entry”)
for y in range(x,0,-2):
print(“Hello”)
else:
print(“Entry”)
17.
What will print on screen after execution of given code:
s,p=0,1
for x in range(1,10,2):
s+=x
p*=x
else:
print('final x=',x)
print('sum =',s)
print('product=',p)
18.
What will be the output of the following code?
list1=[8,0,9,5]
print(list1[::-1])
19.
Write the output of the following:
T=[1,2,3,4]
T1=[3,4,5,6]
T2=T.append(T1)
print(T2)
20.
Find the output of the following program:
L1=[1,2,3,4]
L2=L1
L3=L1.copy()
L4=L1
L1[0]=[5]
print(L1,L2,L3,L4)
21.
Which of the following will give error?
Suppose dict1={"a":1,"b":2,"c":3}
(a) print(len(dict1))
(b) print(dict1.get("b"))
(c) dict1["a"]=5
(d) None of these.
22.
What will be the output of the following Python code?
>>> a={1:”A”,2:”B”,3:”C”}
>>>a.items( )
23.
What will be the output of the following Python code snippet?
>>> a={1:”A”,2:”B”,3:”C”}
>>> del a
(a) method del doesn’t exist for the dictionary
(b) del deletes the values in the dictionary
(c) del deletes the entire dictionary
(d) del deletes the keys in the dictionary
24.
What will be the output of the following Python code snippet?
d = {“john”:40, “peter”:45}
“john” in d
(i) True
(ii) False
(iii) None
(iv) Error
25.Mutable and immutable data types
1.