To enter the python repel, open the terminal and type in py. To exit the python repel type in quit()
To make a comment in python, use the # symbol
# This is a comment
Python DOES NOT ignore whitespace
-
4/3 = 1.333...
-
4//3 = 1, Using // in operations will round down your division no matter the decimal
-
round(4/2.3) = 2 and round(4/3) = 1, round will either round up or down depend on the answers
-
24 % 5 = 4, this gives you back the remainder of a division quotent
-
2 ** 4 = 16, this means to the power of, ex - 2 x 2 x 2 x 2 = 16
-
Using +=, countup = 12, countup += 1, countup = 13, using += will add 1 to the variable - likewise -= will subtract, *= multiply and /= divide...
NOTE: Using /= with give your answer a float (decimal) output. to rid this you can round() the answer
#For exmaple...
divide = 20
divide /= 4
5.0 #answer
#rid the decimal as so,
divide = 20
divide /= 4
round(divide)
5 #answer
#OR
divide = 20
divide /= 4
divide = round(divide)
divide
5 #answer
"Dave " + "Liebherr" = 'David Liebherr'
- returns a boolen
12 == 11 #False
13 == 13 #True
13 != 12 #True (! means NOT, so in this case 13 IS NOT equal to 12, which is true)
13 != 13 #False
12 > 11 # True
112 > 1231 = #False
#<=, >= AS WELL
- and
- or
- not
True and False must start with an uppercase letter
is_true = True
is_false = False