- Under Construction. Please send suggestions to [email protected] -

Strings

Python thinks of words as strings of letters.

for letter in "word":
  print letter

Numbers

Python knows all kinds of math!

Addtion

print 2 + 2

Try adding a few numbers in a row!

Multiplication

print 2 * 2

Try mulitplying a few numbers in a row!

Division

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

Exponents

Python can do exponents! Two squared is:

print 2 ** 2

Remainders

Python can do remainders! The remainder of 8 divided by 5 is:

print 8 % 5