JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Python interview questions part 22
Python interview questions part 22
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of the line of code shown below? list(map((lambda x:x^2), range(10)))
A. [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
B. Error
C. [2, 3, 0, 1, 6, 7, 4, 5, 10, 11]
D. No output
Show Correct Answer
Correct Answer is :
[2, 3, 0, 1, 6, 7, 4, 5, 10, 11]
2. What is the output of the line of code shown below? list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10))))
A. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B. [0, 4, 16, 36, 64]
C. Error
D. No output
Show Correct Answer
Correct Answer is :
[0, 4, 16, 36, 64]
3. The output of the two codes shown below is the same. State whether true or false. [x**2 for x in range(10)] list(map((lambda x:x**2), range(10)))
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
4. The output of the code shown below is: def f1(): x=15 print(x) x=12 f1()
A. Error
B. 12
C. 15
D. 1512
Show Correct Answer
Correct Answer is :
15
5. What is the output of the code shown below? def f1(): x=100 print(x) x=+1 f1()
A. Error
B. 100
C. 101
D. 99
Show Correct Answer
Correct Answer is :
100
6. What is the output of the code shown below? def san(x): print(x+1) x=-2 x=4 san(12)
A. 13
B. 10
C. 2
D. 5
Show Correct Answer
Correct Answer is :
13
7. What is the output of the code shown? def f1(): global x x+=1 print(x) x=12 print("x")
A. Error
B. 13
C. 13
D. x
Show Correct Answer
Correct Answer is :
x
8. What is the output of the code shown below? def f1(x): global x x+=1 print(x) f1(15) print("hello")
A. error
B. hello
C. 16
D. 16
Show Correct Answer
Correct Answer is :
error
9. What is the output of the following code? x=12 def f1(a,b=x): print(a,b) x=15 f1(4)
A. Error
B. 45630
C. 45394
D. 45397
Show Correct Answer
Correct Answer is :
45394
10. What is the output of the code shown? def f(): global a print(a) a = "hello" print(a) a = "world" f() print(a)
A. hello
B. world
C. hello
D. world
Show Correct Answer
Correct Answer is :
world
11. What is the output of the code shown below? def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
A. [3,2,4]
B. [2,3,4]
C. Error
D. [3,4,2]
Show Correct Answer
Correct Answer is :
[3,4,2]
12. What is the output of the code shown below? def f(p, q, r): global s p = 10 q = 20 r = 30 s = 40 print(p,q,r,s) p,q,r,s = 1,2,3,4 f(5,10,15)
A. 1 2 3 4
B. 5 10 15 4
C. 10 20 30 40
D. 5 10 15 40
Show Correct Answer
Correct Answer is :
10 20 30 40
13. What is the output of the code shown below? def f(x): print("outer") def f1(a): print("inner") print(a,x) f(3) f1(1)
A. outer
B. inner
C. outer
D. error
Show Correct Answer
Correct Answer is :
outer
14. The output of code shown below is: x = 5 def f1(): global x x = 4 def f2(a,b): global x return a+b+x f1() total = f2(1,2) print(total)
A. Error
B. 7
C. 8
D. 15
Show Correct Answer
Correct Answer is :
7
15. What is the output of the code shown below? x=100 def f1(): global x x=90 def f2(): global x x=80 print(x)
A. 100
B. 90
C. 80
D. Error
Show Correct Answer
Correct Answer is :
100
16. Read the code shown below carefully and point out the global variables: y, z = 1, 2 def f(): global x x = y+z
A. x
B. y and z
C. x, y and z
D. Neither x, nor y, nor z
Show Correct Answer
Correct Answer is :
x, y and z
17. Which of the following data structures is returned by the functions globals() and locals()?
A. list
B. set
C. dictionary
D. tuple
Show Correct Answer
Correct Answer is :
dictionary
18. What is the output of the code shown below? x=1 def cg(): global x x=x+1 cg() x
A. 2
B. 1
C. 0
D. Error
Show Correct Answer
Correct Answer is :
2
19. On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
FALSE
20. What is the output of the code shown below? e="butter" def f(a): print(a)+e f("bitter")
A. error
B. butter
C. bitter
D. bitterbutter
Show Correct Answer
Correct Answer is :
bitter
Similar Interview Questions
Search for latest jobs
Find Jobs