Python2 Python3
print
syntax
statement
print "Hello World"
function
print("Hello World")
int
division
5 / 2 → 2
(same as //)
5 / 2 → 2.5
(always float)
range() return list return iterator
variable
leakage
(comprehension)
x = 10
y = [x for x in range(5)]
print(x) # 4
x = 10
y = [x for x in range(5)]
print(x) # 10
storage of str ASCII (7bits) Unicode (8bits)
string
formatting
format
"Hi, {}".format(name)
f-string
f"Hi, {name}"

Leave a comment