JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Python interview questions part 1
Python interview questions part 1
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. Which way among them is used to create an event loop ?
A. Window.eventloop()
B. Window.mainloop()
C. Window.loop()
D. Eventloop.window()
Show Correct Answer
Correct Answer is :
Window.mainloop()
2. Which is the special symbol used in python to add comments?
A. $
B. //
C. /*.... */
D. #
Show Correct Answer
Correct Answer is :
#
3. Select the correct function among them which can be used to write the data to perform for a binary output?
A. Write
B. Output.binary
C. Dump
D. Binary.output
Show Correct Answer
Correct Answer is :
Dump
4. What is output for −2 * 2 **3
A. 12
B. 64
C. 16
D. 36
Show Correct Answer
Correct Answer is :
16
5. What is the output of the following code? import math def main(): math.cos(math.pi) main() print(main())
A. -1
B. None
C. Error
D. Math.pi not defined
Show Correct Answer
Correct Answer is :
None
6. What is the output of the code shown? l=list('HELLO') 'first={0[0]}, third={0[2]}'.format(l)
A. ‘first=H, third=L’
B. ‘first=0, third=2’
C. Error
D. ‘first=0, third=L’
Show Correct Answer
Correct Answer is :
‘first=H, third=L’
7. What is the output of the code shown below? l=list('HELLO') p=l[0], l[-1], l[1:3] 'a={0}, b={1}, c={2}'.format(*p)
A. Error
B. “a=’H’, b=’O’, c=(E, L)”
C. “a=H, b=O, c=[‘E’, ‘L’]”
D. Junk value
Show Correct Answer
Correct Answer is :
“a=H, b=O, c=[‘E’, ‘L’]”
8. Fill in the blanks: The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
A. first, right
B. second, left
C. first, left
D. second, right
Show Correct Answer
Correct Answer is :
second, left
9. What is the output of the following code? hex(255), int('FF', 16), 0xFF
A. [0xFF, 255, 16, 255]
B. (‘0xff’, 155, 16, 255)
C. Error
D. (‘0xff’, 255, 255)
Show Correct Answer
Correct Answer is :
(‘0xff’, 255, 255)
10. The output of the two codes shown below is the same. State whether this statement is true or false. bin((2**16)-1) '{}'.format(bin((2**16)-1))
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
11. What is the output of the code shown below? '{a}{b}{a}'.format(a='hello', b='world')
A. ‘hello world’
B. ‘hello’ ‘world’ ‘hello’
C. ‘helloworldhello’
D. ‘hello’ ‘hello’ ‘world’
Show Correct Answer
Correct Answer is :
‘helloworldhello’
12. What is the output of the code shown below? D=dict(p='san', q='foundry') '{p}{q}'.format(**D)
A. Error
B. sanfoundry
C. san foundry
D. {‘san’, ‘foundry’}
Show Correct Answer
Correct Answer is :
sanfoundry
13. What is the output of the code shown below? 'The {} side {1} {2}'.format('bright', 'of', 'life')
A. Error
B. ‘The bright side of life’
C. ‘The {bright} side {of} {life}’
D. No output
Show Correct Answer
Correct Answer is :
Error
14. The output of the code shown below is: '{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
A. Error
B. ‘1.234560, 1.22345, 1.23’
C. No output
D. ‘1.234560, 1.234560, 01.23’
Show Correct Answer
Correct Answer is :
‘1.234560, 1.234560, 01.23’
15. What is the output of the code shown below? '%.2f%s' % (1.2345, 99)
A. ‘1.2345’, ‘99’
B. ‘1.2399’
C. ‘1.234599’
D. 1.23, 99
Show Correct Answer
Correct Answer is :
‘1.2399’
16. What is the output of the code shown below? '%s' %((1.23,),)
A. ‘(1.23,)’
B. 1.23,
C. (,1.23)
D. ‘1.23’
Show Correct Answer
Correct Answer is :
‘(1.23,)’
17. What is the output of the two codes shown below? '{0}'.format(4.56) '{0}'.format([4.56,])
A. ‘4.56’, ‘4.56,’
B. ‘4.56’, ‘[4.56]’
C. 4.56, [4.56,]
D. 4.56, [4.56,]
Show Correct Answer
Correct Answer is :
‘4.56’, ‘[4.56]’
18. What is the type of each element in sys.argv?
A. set
B. list
C. tuple
D. string
Show Correct Answer
Correct Answer is :
string
19. What is the length of sys.argv?
A. number of arguments
B. number of arguments + 1
C. number of arguments – 1
D. none of the mentioned
Show Correct Answer
Correct Answer is :
number of arguments + 1
20. What is the output of the following code? def foo(k): k[0] = 1 q = [0] foo(q) print(q)
A. [0].
B. [1].
C. [1, 0].
D. [0, 1].
Show Correct Answer
Correct Answer is :
[1].
Similar Interview Questions
Search for latest jobs
Find Jobs