Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1. What gets printed?

name = 'python' while bool(name) == False: print('hi')

A) hi
B) true
C) false
D) nothing

2. String in python is immutable?

A) True
B) False

3. What gets printed? var = 100 if ( var == 100 ) : print "Value of expression is 100"

A) Nothing
B) An Error
C) Value of expression is 100
D) NONE

4. what gets printed? a = range(5) b = range(10) print(zip(a,b))

A) 5 10
B) 1 2 3 4 5
C) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
D) 0, 0, 1, 1, 2, 2, 3, 3, 4, 4

5. Syntax of constructor in Python?

A) def __init__()
B) def _init_()
C) _init_()
D) All of these

6. What gets printed? while a = 10: print('Howdy')

A) Howdy
B) Nothing
C) An Error
D) 10

7. What gets printed? unichr(1234)

A) 1234
B) abcd
C) u04d2
D) None of the above

8. strings can be enclosed within single, double or triple quotes?

A) True
B) False
9. What gets printed? def myfunc(x, y, z, a): print x + y nums = [1, 2, 3, 4] myfunc(*nums)

A) 1
B) 3
C) 4
D) 5

10. What sequence of numbers is printed? values = [1, 2, 1, 3] nums = set(values) def checkit(num): if num in
nums: return True else: return False for i in filter(checkit, values): print i

A) 1 2 3
B) 1 2 1 3
C) 1 2 13 1 2 1 3
D) Error

11. Which of these is not a core datatype?

A) Lists
B) Dictionary
C) Tuples
D) Class

12. What gets printed? name = "snow storm" name[5] = 'X' print name

A) snow storm
B) snowXstorm
C) snow Xtorm
D) ERROR, this code will not run

13. What gets printed? print "hello" 'world'

A) The text, "hello world" in one line


B) The text, "helloworld" in one line
C) "hello" in one line and "world" in the next line
D) Syntax Error. This Python program will not run.

14. What gets printed? a = 10 b = 2 print a if b else 0

A) 10
B) 2
C) 0
D) Error

15. What gets printed? def dostuff(param1, *param2): print type(param2) dostuff('apples', 'bananas',
'cherry', 'dates')

A) str
B) int
C) tuple
D) list
16. What gets printed? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print
len(mylist)

A) 1
B) 3
C) 4
D) 5

17. slicing operations can be used on strings as well?

A) True
B) False

18. What is the output of the following Python program? num1 = 5 if num1 >= 91: num2 = 3 else: if num1 <
6: num2 = 4 else: num2 = 2 x = num2 * num1 + 1 print (x,x%7)

A) 21 3
B) 21 0
C) 21 21
D) NONE

19. What gets printed? if False: print('Hi') elif True: print('Hello') else: print('Howdy')

A) Nothing
B) Hi
C) Hello
D) Howdy

20. What is the python file format?

A) TXT
B) DAT
C) PY
D) JAVA

You might also like