Commit 24aa7f96 authored by goekce's avatar goekce
Browse files

solutions

parent ae18f76c
Pipeline #13212 passed with stage
in 6 minutes and 32 seconds
......@@ -21,7 +21,7 @@ which of the following works?
import math
```
A) `[int( math.log2(x) ) for x in l if x!=0]`{.py}
A) `[int( math.log2(x) ) for x in l if x!=0]`{.py} <!-- ✅ -->
A) `int( math.log2(x) for x in l if x!=0 )`{.py}
A) `[int( math.log2(x) ) if x!=0 else '' for x in l]`{.py}
A) `int( math.log2(x) if x!=0 else '' for x in l )`{.py}
......@@ -134,7 +134,7 @@ bot.hi()
what is the output?
A) `AttributeError`
A) `AttributeError`<!-- ✅ -->
A) `NameError`
A) `'Hello'`
A) `'hello'`
......@@ -167,7 +167,7 @@ x.remove(1)
```
What is the output?
A) `AttributeError`
A) `AttributeError`<!-- ✅ -->
A) `TypeError`
A) `ValueError`
A) `CreativityLostError`
......@@ -204,7 +204,7 @@ def fib(n):
[fib(n) for n in range(-1, 3)]
```
A) `AssertionError`
A) `AssertionError`<!-- ✅ -->
A) `ValueError`
A) `[-1, 0, 1, 1]`
A) `[-1, 0, 1, 1, 2]`
......@@ -253,7 +253,7 @@ todos[-1]
A) `'mom: call'`
A) `'uni: bio project proposal'`
A) `RecursionError`
A) no output, code stuck
A) no output, program stuck<!-- ✅ -->
A) I don't know
......@@ -265,7 +265,7 @@ How would you fix the previous code?
Modifying a mutable object while we are iterating over it could make the loop infinite. In our case we append strings which contain the string `'project'` which again get replaced again.
An idea could be that we prepend the todo item:
An idea is to prepend the todo item:
```py
for todo in todos:
if 'project' in todo:
......@@ -323,7 +323,7 @@ What is the output?
---
A) `(['shower', 'flower'], ['shower', 'flower'])`
A) `(['shower', 'flower'], ['shower', 'flower'])`<!-- ✅ -->
A) `(['shower'], ['flower'])`
A) `(['flower'], ['shower'])`
A) `AttributeError`
......@@ -368,7 +368,7 @@ What is the output?
---
A) 'merhaba'
A) 'merhaba'<!-- ✅ -->
A) `TypeError`
A) `AttributeError`
A) `ValueError`
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment