Do you know Python?

Hello! In this quiz I tried to collect the most non-trivial features of Python. The time is unlimited, but, please, don't run any Python code during the test. After the end of test your results will be autosubmitted to my server for further analysis. Have fun!
All questions are about Python 3.

    Lists, tuples, etc

  1. What will be placed in a? a = 2,3
    2
    3
    (2,3)
    No, it will be the tupple. See parenthesized forms help:
    Note that tuples are not formed by the parentheses, but rather by use of the comma operator. The exception is the empty tuple, for which parentheses are required — allowing unparenthesized “nothing” in expressions would cause ambiguities and allow common typos to pass uncaught.
  2. How to assign a tuple of length 1 to a?
    a = 1
    a = (1,)
    a = (1)
    a = tuple(1)
    No, See parenthesized forms help:
    A parenthesized form is an optional expression list enclosed in parentheses:
    parenth_form ::= "(" [expression_list] ")"
    A parenthesized expression list yields whatever that expression list yields: if the list contains at least one comma, it yields a tuple; otherwise, it yields the single expression that makes up the expression list.
  3. What is the result of this code? a = {'a':1,'b':2,'c':3}
    a['a','b']
    KeyError
    [1,2]
    {'a':1,'b':2}
    No, See help
  4. What is the result of this code? a = {(1,2):1,(2,3):2}
    a[1,2]
    KeyError
    1
    No, See help
  5. What will be placed in a? a = {'a': 1,'b':2, 'a':3}
    It causes SyntaxError
    {'a': 1,'b': 2, 'a': 3}
    The behavior is undefined
    {'a': 1,'b': 2}
    {'a': 3,'b': 2}
    No, See help: Clashes between duplicate keys are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails.
  6. What will be placed in a? a = [1,2,3]
    a[-3:-1] = 10,20,30,40
    IndexError
    TypeError
    [10, 20, 30, 40, 3]
    [10, 20, 30, 40, 2, 3]
    [10, 20, 30, 40]
    [[10, 20, 30, 40],3]
    [(10, 20, 30, 40),3]
    No, See help
  7. What is the result of this code? a=[1,2,3,4,5,6,7,8,9]
    a[::2]
    [1,2]
    [1,3]
    [8,9]
    [1,3,5,7,9]
    SyntaxError
    No, See help
  8. What is the result of this code? a=[1,2,3,4,5,6,7,8,9]
    a[::2]=10,20,30,40,50,60
    SyntaxError
    ValueError
    [10, 2, 20, 4, 30, 6, 40, 8, 50, 9, 60]
    No, See help
  9. What is the result of this code? a=[1,2,3,4,5]
    a[3:1:-1]
    SyntaxError
    ValueError
    [3, 2]
    [4, 3]
    [4, 3, 2]
    No, See help
  10. Types

  11. What is the type of b? a = "bay"
    b = a[0]
    chr
    ord
    int
    str
    No, See help
  12. What is the type of b? a = -1
    b = a ** 0.5
    float
    complex
    int
    str
    No, See help: Raising a negative number to a fractional power results in a complex number. (In earlier versions it raised a ValueError.)
  13. What is the type of a? a = 10/5
    float
    int
    No, See help: Integer division yields a float
  14. What is the type of a? a = 10.0//5
    float
    int
    No, See help: The numeric arguments are first converted to a common type. Integer division yields a float, while floor division of integers results in an integert
  15. What is the type of a? a = {1,2:3}
    dict
    set
    It causes SyntaxError
  16. What is the type of a? a = {}
    dict
    set
    No, See help: An empty set cannot be constructed with {}; this literal constructs an empty dictionary.
  17. What is the type of a? a = (b for b in [1,2])
    tuple
    generator
    No, See help.
  18. Order of operations

  19. What the will be in a? a = -1 ** 2
    -1
    1
    No, See help.
  20. The operations |, ^ and & ..
    .. have same priority
    .. not have same priority
    No, See help.
  21. Calculations

  22. a = ? a = -4 % 1.5
    0.5
    1.0
    -0.5
    -1.0
    No, See help.
  23. a = ? a = -4 // 1.5
    2.0
    3.0
    -2.0
    -3.0
    No, See help.
  24. Comprehensions

  25. Is this syntax valid? a = { i for i in range(0,10,2) }
    Yes
    No
    No, see help.
  26. Is this syntax valid? a = { i,j for i in range(0,10,2) for j in range(1,10,2)}
    Yes
    No
    No, due to comma =)
  27. a = ? a = { b : b+10 for b in range(10) }
    It causes a SyntaxError
    {0: 9}
    {0: 10, 1: 11, 2: 12, 3: 13, 4: 14, 5: 15, 6: 16, 7: 17, 8: 18, 9: 19}
    No, see help.
  28. Functions

  29. What will be printed: def f(a, b):
     print(a, b)

    f(b=1, *(2,))
    2 1
    1 2
    This code causes TypeError
    No, see help.
  30. Is this syntax valid? def f(a):
     pass

    f(a for a in [1,2])
    Yes
    No, it causes SyntaxError: Generator expression must be parenthesized
    No, see help.
  31. What does this function return? def f(a,b):
     return a,b

    f(**{'b':2,'a':1})
    (1, 2)
    (2, 1)
    It causes TypeError: f() got an unexpected keyword argument
    No, see help.
  32. a = ? def f(a=[]):
     a.append(1)
     return a

    a=(f(),f())
    ([1], [1])
    ([1], [1,1])
    ([1,1], [1,1])
    No, see help: Default values are calculated, once, when the function is defined; thus, a mutable object such as a list or dictionary used as default value will be shared by all calls that don’t specify an argument value for the corresponding slot; this should usually be avoided..
  33. Logical operations

  34. a = ? a = 3 < 5 < 7
    True
    False
    It causes SyntaxError
    No, see help.
  35. a = ? a = 1 < 2 == 2 > 1 in [1,2,3] < [2,3,4,5] != 1
    True
    False
    It causes SyntaxError
    No, see help.
  36. How many times f() will be printed? def f():
     print("f()")
     return 1

    a = 0<f()<2
    a = 0<f() and f()<2
    One
    Two
    Three
    Four
    No, see help.
  37. a = ? a = [1,2,3]>(2,3)
    True
    False
    It causes TypeError
    No, see help.
  38. a = ? a = {1,2,3}<{2,3,4,5}
    True
    False
    It causes TypeError
    No, see help.
  39. a = ? a = {1:2,2:3,3:4}<{2:5,3:6,4:7,5:8}
    True
    False
    It causes TypeError
    No, see help.
  40. a = ? a = {1:'a',2:'b'}=={2:'b',1:'a'}
    True
    False
    It causes TypeError
    No, see help.
  41. a = ? a = ( 'bay' and 'cat' )
    True
    False
    'bay'
    'cat'
    No, see help.
  42. Generators

  43. Will "f()" be printed? def f():
     print("f()")
     yield 1

    f()
    Yes
    No
    No, see help.
  44. What will be printed? def f(value):
     while True:
      value = (yield value)

    a=f(10)
    print(next(a))
    print(next(a))
    print(a.send(20))
    10,10
    10,10,20
    10,None,20
    10,None,None
    No, see help.
  45. Classes

  46. How to get access to __b__ in outside of class a class a:
     __b__="hello"
    It is impossible
    a.__b__
    a._a__b__
    No, see help.
  47. How to get access to __b_ in outside of class a class a:
     __b_="hello"
    It is impossible
    a.__b_
    a._a__b_
    No, see help.
  48. Misc

  49. a = ? a = [[1] * 2] * 2
    a[0][0]=2
    [[2, 1], [1, 1]]
    [[2, 1], [2, 1]]
    [[2, 2], [2, 2]]
    No, the outer array a consists of two pointers to the same [1,1] array.
  50. What is this: exec((lambda x:x).__code__.__class__(0,0,0,0,0,b'd\x00S\x00',(),(),(),"","",0,b""))
    Some random invalid code
    Valid code in Python 3
    A way to execute Python bytecode