In Python 3, what does this print?
print(5 / 2)Show answer
Answer
2.5
Plain / always gives a float in Python 3, even when both numbers are whole. 5 / 2 is 2.5.
Read short Python snippets and predict what they print
Python Basics is a Bertopia flashcard pack of 73 cards: read short Python snippets and predict what they print. It covers values and types; variables, input and print; strings; lists; dictionaries; conditions; loops; functions.
print(5 / 2)Answer
Answer
word = 'Python'
print(word[0])Answer
squares = [1, 4, 9, 16, 25]
print(squares[-1])Answer
tel = {'jack': 4098, 'sape': 4139}
print(tel['sape'])Answer
x = 1
if x < 0:
print('Negative')
elif x == 0:
print('Zero')
elif x == 1:
print('Single')
else:
print('More')Answer