Pop Quiz!

Tested with: Python 3.7.1

True or True or not False and False

What does that print?

Go ↓ for solution or
→ for next question

True
print(1 + 1.0)

What does that print?

Go ↓ for solution or
→ for next question

2.0
print("dammit im mad"[::-1])

What does that print?

Go ↓ for solution or
→ for next question

dam mi timmad
list_a = [1, 2, 3]
l = [ [a**2, a**3] for a in list_a]
print(l)

What does that print?

Go ↓ for solution or
→ for next question

[[1, 1], [4, 8], [9, 27]]
d = {
    ('foo', 100),
    ('bar', 200),
    ('baz', 300)
}
print(type(d))

What does that print?

Go ↓ for solution or
→ for next question

>>> print(type(d))
<class 'set'>
# set() vs. dict()
#
# Dict:

d = { 'foo': 100}
d['foo'] = 200

# Set:

d = { 'foo', 100}
d['foo'] = 200
x = [
    'a',
    'b',
    {
        'foo': 1,
        'bar':
        {
            'x' : 10,
            'y' : 20,
            'z' : 30
        },
        'baz': 3
    },
    'c',
    'd'
]

How to access the value 30?

Go ↓ for solution or
→ for next question

print(x[2]['bar']['z'])
30
def Foo(x):
  if (x==1):
    return 1
  else:
    return x+Foo(x-1)

print(Foo(4))

Go ↓ for solution or
→ for next question

What does that print?

10
g = map(lambda x: "Happy Birthday to " + 
       ("you" if x != 2 else "dear Björk"), range(4))

for line in g:
    print(line)

Go ↓ for solution or
→ for next question

What does that print?

Happy Birthday to you
Happy Birthday to you
Happy Birthday to dear Björk
Happy Birthday to you

Python Popquiz #1

By Stefan Antoni

Python Popquiz #1

A little pop quiz for the python user group ffm

  • 92
Loading comments...

More from Stefan Antoni