- Under Construction. Please send suggestions to [email protected] -
Python thinks of words as strings of letters.
for letter in "word":
print letter
Python knows all kinds of math!
print 2 + 2
Try adding a few numbers in a row!
print 2 * 2
Try mulitplying a few numbers in a row!
So far we’ve only been dealing with whole numbers. Python treats whole numbers specially and only returns whole numbers:
# python 2
print 3 / 2
If we expect decimals from division we need to give Python decimals:
print 3.0 / 2
Python can do exponents! Two squared is:
print 2 ** 2
Python can do remainders! The remainder of 8 divided by 5 is:
print 8 % 5