Python
Python 2 vs Python 3
20 flashcards · answers and review in the app — launching soon
Why is Python 2's input() considered dangerous, and what replaced it?
In Python 3, what does the built-in input() return when the user types 2**5?
What does this print in Python 3?
```
print 5 / 2
```
In Python 3, what does this evaluate to?
```
5 / 2
```
In Python 3, what is the result of each?
```
10 // 4
10.0 // 4
```
In Python 3, what does -7 // 2 evaluate to?
In Python 3, what does this print?
```
r = map(str, [1, 2, 3])
print(r)
```
In Python 3, what does this print?
```
r = range(5)
print(r)
```
You need a list from a Python 2 zip() call after porting to Python 3. What's the fix and why?
In Python 3, what type does dict.keys() return, and what's the practical gotcha?
In Python 3, what type is the result of "text".encode("ascii")?
In Python 3, what does this do?
```
b"abc" + "def"
```
Why does opening a file in binary vs text mode matter more in Python 3 than Python 2?
In Python 3, what's wrong with this and how do you fix it?
```
except ValueError, e:
```
How do you raise an exception with a message in Python 3?
In Python 3, what's the largest int you can store, and what happened to long?
In Python 3, what does type(10 ** 100) return?
What is the 2to3 tool and what does it produce by default?
Why can't 2to3 reliably convert every print statement on its own?
When did Python 2 reach end-of-life, and what does that mean for new code?