0% found this document useful (0 votes)
2 views

ApCompSci Notes

The document outlines key concepts in algorithms, including sequencing, selection, and iteration, along with examples of code statements and expressions. It explains the MOD operator, order of operations, Boolean expressions, while loops, conditionals, and nested conditionals. Additionally, it covers the development of algorithms, appending and removing elements from lists, and the structure of if statements and while loops in Python.

Uploaded by

vtyler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ApCompSci Notes

The document outlines key concepts in algorithms, including sequencing, selection, and iteration, along with examples of code statements and expressions. It explains the MOD operator, order of operations, Boolean expressions, while loops, conditionals, and nested conditionals. Additionally, it covers the development of algorithms, appending and removing elements from lists, and the structure of if statements and while loops in Python.

Uploaded by

vtyler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Some of these aren't labelled correctly but I'm pretty sure I got every college board lesson notes

on here

Algorithms are a finite set of instructions that accomplish a specific task

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

● Code statements and expressions


Grade ← 82
highScore← current score
Name ← firstName + lastName

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

● Check below for relational operations


● 3.5 Boolean expressions
Boolean statements are yes or no questions such as do you have a cat
To check if someone can drive you might do: age ≥16
AND OPERATOR
If one side is false, then the result if false. Only if both are true then the result is true
OR OPERATOR
If one side is correct, the result is correct. Only if both sides are false then it is false
● While loops
There is no “while” in college board, you must use “Repeat Until”
While condition:
Commands to be performed go here

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.7 nested conditionals


A nested condition is a condition in a condition

● 3.8 iteration
Ex:

1. Number everyone from 1 to 367 and put them in a line


2. Make person 1 the starter
3. The person with the number 1 greater than person number 1 will be the
questioner
4. The questioner will ask the starter if they have the same birthday
5. Make the person one greater than the current number the new starter
6. Repeat steps 4 and 5 until the questioner has asked everyone in the line with a
greater number
7. Make person 1 greater than the current questioner and the new questioner
8. Repeat steps 3-7 until you find a match
● 3.9 developing algorithms

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

2.18 while loops

while block of code:


block of code

while loops repeat a certain block of code until a condition is met


infinite loops occur when there is no way for the condition to be met.

You might also like