Alien head

Simple Python Quiz

Description: Simple Python Quiz
Number of Questions: 7
Created by:
Tags: python

numbers= [1,2,3,4] numbers.append([5,6,7,8]) print len(numbers)

  1. 4

  2. 5

  3. 8

  4. 12

  5. An exception is thrown

Answer: 2

for i in range(2): print i for i in range(4,6): print i

  1. 2, 4, 6

  2. 0, 1, 2, 4, 5, 6

  3. 0, 1, 4, 5

  4. 0, 1, 4, 5, 6, 7, 8, 9

  5. 1, 2, 4, 5, 6

Answer: 3

foo = {1:'1', 2:'2', 3:'3'} del foo[1] foo[1] = '10' del foo[2] print len(foo)

  1. 2

  2. 7

  3. 3

  4. 4

  5. An exception is thrown

Answer: 1

Which of the following data structures can be used with the "in" operator to check if an item is in the data structure?

  1. List

  2. Set

  3. Dictionary

  4. None of the above

  5. All of the above

Answer: 5

my_tuple = (1, 2, 3, 4) my_tuple.append( (5, 6, 7) ) print len(my_tuple)

  1. 1

  2. 6

  3. 4

  4. 5

  5. An exception is thrown

Answer: 4

print type([1,2]).The output is:

Answer: 4

names =['Amir', 'Barry', 'Chales', 'Dao'] print names [-1][-1] The output is:

  1. A

  2. r

  3. Amir

  4. Dao

  5. O

Answer: 5
+ View questions