Python Interview Questions - 2 | Snaprecruit.com
Python Interview Questions - 2 | Snaprecruit.com
JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing
Enterprises
Python interview questions part 2
Python interview questions part 2
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. How are keyword arguments specified in the function heading?
A. one star followed by a valid identifier
B. one underscore followed by a valid identifier
C. two stars followed by a valid identifier
D. two underscores followed by a valid identifier
Show Correct Answer
Correct Answer is :
two stars followed by a valid identifier
2. How many keyword arguments can be passed to a function in a single function call?
A. zero
B. one
C. zero or more
D. one or more
Show Correct Answer
Correct Answer is :
zero or more
3. What is the output of the following code? def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])
A. 45352
B. 45294
C. error
D. none of the mentioned
Show Correct Answer
Correct Answer is :
45352
4. What is the output of the following code? def foo(): return total + 1 total = 0 print(foo())
A. 0
B. 1
C. error
D. none of the mentioned
Show Correct Answer
Correct Answer is :
1
5. What is the output of the following code? def foo(): total += 1 return total total = 0 print(foo())
A. 0
B. 1
C. error
D. none of the mentioned
Show Correct Answer
Correct Answer is :
error
6. What is the output of the following code? def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
A. TRUE
B. FALSE
C. None
D. Error
Show Correct Answer
Correct Answer is :
FALSE
7. What is the output of the following code? def foo(i, x=[]): x.append(i) return x for i in range(3): print(foo(i))
A. [0] [1] [2].
B. [0] [0, 1] [0, 1, 2].
C. [1] [2] [3].
D. [1] [1, 2] [1, 2, 3].
Show Correct Answer
Correct Answer is :
[0] [0, 1] [0, 1, 2].
8. What is the output of the following code? def foo(k): k = [1] q = [0] foo(q) print(q)
A. [0].
B. [1].
C. [1, 0].
D. [0, 1].
Show Correct Answer
Correct Answer is :
[0].
9. How are variable length arguments specified in the function heading?
A. one star followed by a valid identifier
B. one underscore followed by a valid identifier
C. two stars followed by a valid identifier
D. two underscores followed by a valid identifier
Show Correct Answer
Correct Answer is :
one star followed by a valid identifier
10. Which module in the python standard library parses options received from the command line?
A. getopt
B. os
C. getarg
D. main
Show Correct Answer
Correct Answer is :
getopt
11. What is the type of sys.argv?
A. set
B. list
C. tuple
D. string
Show Correct Answer
Correct Answer is :
list
12. What is the value stored in sys.argv[0]?
A.
B. you cannot access it
C. the program’s name
D. the first argument
Show Correct Answer
Correct Answer is :
the program’s name
13. How are default arguments specified in the function heading?
A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Show Correct Answer
Correct Answer is :
identifier followed by an equal to sign and the default value
14. How are required arguments specified in the function heading?
A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Show Correct Answer
Correct Answer is :
identifier
15. What is the output of the following code? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
A. TRUE
B. FALSE
C. None
D. Error
Show Correct Answer
Correct Answer is :
TRUE
16. Where are the arguments received from the command line stored?
A. sys.argv
B. os.argv
C. argv
D. none of the mentioned
Show Correct Answer
Correct Answer is :
sys.argv
17. What is the output of the following? def foo(i, x=[]): x.append(x.append(i)) return x for i in range(3): y = foo(i) print(y)
A. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
B. [[0], [[0], 1], [[0], [[0], 1], 2]].
C. [0, None, 1, None, 2, None].
D. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
Show Correct Answer
Correct Answer is :
[0, None, 1, None, 2, None].
18. Which is the correct operator for power(xy)?
A. X^y
B. X**y
C. X^^y
D. None of the mentioned
Show Correct Answer
Correct Answer is :
X**y
19. Which one of these is floor division?
A. /
B. //
C. %
D. None of the mentioned
Show Correct Answer
Correct Answer is :
//
20. What is the order of precedence in python? i) Parentheses ii) Exponential iii) Multiplication iv) Division v) Addition vi) Subtraction
A. i,ii,iii,iv,v,vi
B. ii,i,iii,iv,v,vi
C. ii,i,iv,iii,v,vi
D. i,ii,iii,iv,vi,v
Show Correct Answer
Correct Answer is :
i,ii,iii,iv,v,vi
Similar Interview Questions
Search for latest jobs
Find Jobs