Simple Python Quiz
Tests basic Python programming concepts including data structures (lists, tuples, dictionaries), loops, and type checking
Questions
Question 1 Multiple Choice (Single Answer)
numbers= [1,2,3,4] numbers.append([5,6,7,8]) print len(numbers)
- 4
- 5
- 8
- 12
- An exception is thrown
Question 2 Multiple Choice (Single Answer)
for i in range(2): print i for i in range(4,6): print i
- 2, 4, 6
- 0, 1, 2, 4, 5, 6
- 0, 1, 4, 5
- 0, 1, 4, 5, 6, 7, 8, 9
- 1, 2, 4, 5, 6
Question 3 Multiple Choice (Single Answer)
foo = {1:'1', 2:'2', 3:'3'} del foo[1] foo[1] = '10' del foo[2] print len(foo)
- 2
- 7
- 3
- 4
- An exception is thrown
Question 4 Multiple Choice (Single Answer)
Which of the following data structures can be used with the "in" operator to check if an item is in the data structure?
- List
- Set
- Dictionary
- None of the above
- All of the above
Question 5 Multiple Choice (Single Answer)
my_tuple = (1, 2, 3, 4) my_tuple.append( (5, 6, 7) ) print len(my_tuple)
- 1
- 6
- 4
- 5
- An exception is thrown
Question 6 Multiple Choice (Single Answer)
print type([1,2]).The output is:
- <type 'tuple'>
- <type 'int'>
- <type 'complex'>
- <type 'list'>
- <type ‘Dictionary’>
Question 7 Multiple Choice (Single Answer)
names =['Amir', 'Barry', 'Chales', 'Dao'] print names [-1][-1] The output is:
- A
- r
- Amir
- Dao
- O