4.0 KiB
4.0 KiB
In [ ]:
# Addition
2+1In [ ]:
# Subtraction
2-1In [ ]:
# Multiplication
2*2In [ ]:
# Division
3/2In [ ]:
# Floor Division
7//4In [ ]:
# Modulo
7%4In [ ]:
# Powers
2**3In [ ]:
# Can also do roots this way
4**0.5In [ ]:
# Order of Operations followed in Python
2 + 10 * 10 + 3In [ ]:
# Can use parentheses to specify orders
(2+10) * (10+3)In [ ]:
# Let's create an object called "a" and assign it the number 5
a = 5In [ ]:
# Adding the objects
a+aIn [ ]:
# Reassignment
a = 10In [ ]:
# Check
aIn [ ]:
# Check
aIn [ ]:
# Use A to redefine A
a = a + aIn [ ]:
# Check
aIn [ ]:
# Use object names to keep better track of what's going on in your code!
my_income = 100
tax_rate = 0.1
my_taxes = my_income*tax_rateIn [ ]:
# Show my taxes!
my_taxes