Arithmetic Operations

  • Addition: (+)
  • Subtraction: (-)
  • Multiplication (*)
  • Division: (/)
  • Getting the remainder: (%)

Order of Operations

  • Operations in parentheses should be done first
  • " * " and " / " before " + " and " - "
  • " % " are similar to " * " and " / "

Variables

  • Sequence is very important
  • Tracking variables is commonly used in the AP Exams and is an important thing

Hacks/Homework

Num1 = 50
Num2 = Num1 % 9 + 15
Num3 = Num2 / Num1 + ( Num2 * 2 )
Num4 = Num3 + Num1 / 5 - 10
Result = Num4 - Num2


# 50/9 = 45 R=5; 5 + 15 = 20 = num2
# 2/5 + 40 = 40.4 = num 3
# 40.4 + (50/5) - 10 = 40.4 + 10 - 10 = 40.4 =  num4 
# Result = 40.4 - 20 = 20.4
# Checking answers

print(Num1)
print(Num2)
print(Num3)
print(Num4)
print(Result)
50
20
40.4
40.4
20.4
Num1 = 10
Num2 = Num1 % 3 * 4
Num1 = Num2
Num3 = Num1 * 3
Result = Num3 % 2

# num1 = 4
# 10/3 = 1 x 4 = 4 = num2
# 4 x 3 = 12 = num3
# 12/2 = 0 = Result 
# Checking answers

print(Num1)
print(Num2)
print(Num3)
print(Result)
4
4
12
0
valueA = 4
valueB = 90
valueC = 17
valueB = valueC - valueA
valueA = valueA * 10
if valueB > 10:
    print(valueC)

# 17 - 4 = 13 
# valueA = 40
# code will print 17 since 13>10
# Checking answers
17
type = "curly"
color = "brown"
length = "short"
type = "straight"
hair = type + color + length
print(hair)

# Will print straightbrownshort
# Checking answers
straightbrownshort
Noun = "Mr.Mortenson" 
Adjective = "handsome" 
Adjective2 = "Very" 
Verb = "is" 
abrev = Noun[0:4] 
yoda = (Adjective + " " + Adjective2 + " " + abrev + " " + Verb + ".") 
print(yoda)
handsome Very Mr.M is.
cookie = "chocolate" 
cookie2 = "rasin" 
len1 = len(cookie) / 2 
len2 = len(cookie2) * 45 
vote1 = (cookie + " cookie votes: " + str(len1)) # creating a string 
vote2 = (cookie2 + " cookie votes: " + str(len2)) # creating a string 
votes = (vote1 + "           " + vote2) # displaying votes 
print(votes)
chocolate cookie votes: 4.5           rasin cookie votes: 225