ApCompSci Notes
ApCompSci Notes
on here
Video 1
● Sequencing
First step
Second step
Third step
● Selection
First step to do → decision to make →→ yes → step to do if true →no → step to do if
false
● Iteration
First step to do → second step → →condition to continue → second step → step to
do if true
Video 2
Grade1← 10
Grade2 ← grade1
average Grade ← (grade1 + grade2)/2
DISPLAY(averageGrade)
Num1 ← 25
Num2 ← 43
Num3 ←18
Average ← (num1 + num2 + num3)/3
Video 3
● MOD operator :
Determines values after condition (if you try to give 6 friends 2 pieces of candy out of
your 9 pieces, one friend only gets 1 piece. MOD or modulus finds what the 1 piece is
when you didn’t know it. It finds the remainder.)
● Order of operations
10+5*8/4
= 10 + 40/4
= 10 + 10
= 20
(10+5)*8/4
= 15*8/4
= 120/4
=30
10 + 5 *(8/4)
= 10 + 5 *2
= 10+10
= 20
● for i in range (start, end, increasing by)
Its’ starting value is always 0
The code will keep running until the user puts “No” as their answer
● 3.6 conditionals
Ex. updating a high score:
1. Set highScore to 10
2. Get currentScore from user
3. If current score is greater than highScore, set highScore to current score
4. Display highScore
● 3.8 iteration
Ex:
temp ← first
First← second
Second ← temp
● Append
Append means to add to the end of the list
pop means the opposite
you can also use the remove to get rid of specific stuff
● 1.1.8 if statements + nested conditionals
If — :
Block of code
Else:
Block of code
The elif statement will only execute after the previous conditions evaluate to false and
its own condition evaluates to true.
Need to memorize the elif statement
● Lists
lists are done in square brackets
Python
2.16 if statements
if block of code:
block of code
the block of code in the if statement only runs if the first block of code is true