AP Computer Science Practice
AP Computer Science Practice
1 VIDEO 1-Collaboration
★ A computing innovation includes a program as an integral part of its function.
★ A computing innovation can be physical (self-driving car), nonphysical computing
software (picture editing software), or a nonphysical computing concept (e-commerce).
★ Effective collaboration produces a computing innovation that reflects the diversity of
talents and perspectives of those who design it.
★ Collaboration that includes diverse perspectives helps avoid bias in the development of
computing innovations.
★ Effective collaboration teams practice interpersonal skills, including, but not limited to:
○ Communication
○ Consensus building
○ Conflict resolution
○ Negotiation
Examples
1. Facebook: has large areas for team collaboration
2. Super Mario brothers 2 vs. Super Mario brothers 3: Kensuke Tenabe and Shigeru
Miyamoto worked together to create Super Mario brothers 2 and 3.
Practice
What are the benefits of collaborating with your peers?
a. Effective collaboration suppresses communication, consensus building, conflict
resolution, and negotiation skills.
b. Effective collaboration produces a computing innovation that reflects the diversity
of talents and perspectives of those who designed it.
c. Collaboration gives you a chance to be the alpha and lets your classmates marvel at
your sheer dominance while you belittle them.
d. Collaboration that includes diverse perspectives promotes bias in the development of
computing innovations.
1.2 VIDEO 1
~E-commerce-My answer
E-commerse exists to help people shop online without needing to go out to stores
~E-commerce-Their answer
Allows users to save money and time by being able to shop from home.
Computer programs take inputs in a variety of fashions to influence the program’s behavior
Program inputs are data sent to a computer for processing by a program. Inputs can come in a
variety of different forms, such as tactile, audio, visual, or text.
Events can be generated when a key is pressed, a mouse is clicked,a program is started, or any
other defined action occurs that affects the flow of execution.
In event driven programming, program statements are executed when triggered rather than
through the sequential flow of control.
Input can come from a user or other programs.
Program outputs are any data sent from a program to a device. Program output can come in a
variety of forms, such as tactile, audio, visual, or text.
Program output is usually based on a program’s input or prior state (ex: internal values).
➔ Phones/tablets-have a touchscreen (touch input). Different ways you touch the screen,
different buttons you press=different inputs through touch. Face ID=visual input. Type in
your passcode=text.
➔ Laptop-has a mouse, keyboard
➔ Gaming console-you push the different buttons (A, B, up, down…)-you’re inputting
information.
Events are triggered by some action, which usually sends input to the program.
➢ Gaming console
○ Remote vibrates=tactile
The program jumps to the code segments according to the event. There may be many lines of
code. They don’t all have to be executed in the order they are written. The code segment is
executed and the output is triggered by the code segment (or additional events are triggered).
Event driven programming is when the program jumps to a specific line of code and executes it
based on a trigger to that event.
Program code is not necessarily executed in order. They are executed as they are called,
according to the events triggered.
The behavior of a function is how a program functions during execution and is often described
by how a user interacts with it.
A program can be described broadly by what it does, or in more detail by both what the program
does and how the program statements accomplish this function.
What is a program?
A collection of statements.
~A statement is a single command.
~A group of statements is called a code segment.
~Code segments are executed according to the rules of the programming language.
~A program is often referred to as software. Software is something that you download.
(you download a program and run it on your device)
Ex: Have a code segment in pseudocode and block segment. The code segment was written to
find the minimum value in a list.
Code segments need to work for a variety of different lists, like lists that include:
-Numbers out of order
-Negative numbers
-Large numbers
-Decimals
The description of a code segment should simply explain what the code segment does. It should
be explained in a way that someone could use the code segment in a larger program. Or the
description should include how the segment does what it does, by explaining in detail how the
code segment functions, so that someone could expand upon the code segment.
Think about early AI projects, like a personal assistant (set an alarm for 7:30am, search for
….,play this song,etc.)
Newer AI projects use the old ones and expand them more.
After investigation and reflection, the developers design the program by:
➢ Brainstorming (draw on investigation)
➢ Storyboarding the program (draw out what the user is going to do to show what is
possible with our program)
➢ Planning the user experience (this is how the user will interact with the program. This is
what they will see, hear…)
➢ Laying out the user interface (what does the user have to do to interact with the device.
Does there need to be a screen? Does the user need to click different buttons? What do
they have to say?)
➢ Organizing into modules ( Different components of the program that will be developed
individually so they can say group A will do ….. Group B will do ….)
➢ Developing a testing strategy (how will they know that the program is actually doing what
it’s meant to do)
➢ Deciding on program requirements that:
a) Describe how a program should behave
b) Include a list of user interactions
➢ Making Program specifications that outline all of the requirements.
➢ Creating a prototype. Developers create a prototype of the program (or components):
○ An incremental process is frequently used so developers can refine small parts
(modules) of the program
➢ Doing lots of testing at the micro and macro level. The program is tested every step of
the way.
➢ Developers refine and revise through testing, feedback, and reflection.
Practice question:
Which of the following does not need to be sourced:
1. Use of code segments from another program written by someone else in a program you
are writing
2. Use of your own original code segments in a program you are writing.
3. Use of an algorithm written by someone else in a program you are writing.
4. Use of code segments you collaborate on with others in a program you are writing.
The error is that the ranges are overlapping. For example, if someone got a 99, A,B,C,D would
be displayed because 99 > 89,79,69,59…
Border case- if you got an 89.5 it should count as an A, but an 89.4 should count as a B.
Ex: 1. Most integrated development environments (IDEs) display information when there is
a syntax error. This information usually directs the programmer to the line in the program
where the error has occurred. (might say:syntax error:bad input on line 2). Sometimes
you need to do a little digging to find the error.
2. Logic errors are harder to identify. Using test cases is the first strategy programmers
use to find logic errors.
OR
IF (grade >89)
(DISPLAY (“A”))
ELSE (IF grade > 79) (DISPLAY (“B”))
ELSE (IF (grade > 69)(DISPLAY (“C”))
ELSE (IF (grade > 59)(DISPLAY (“D”))
ELSE (IF (grade> 49)(DISPLAY (“F”))
Hand tracing:
➔ Hand tracing is writing out the values of the values of the variables within the loop as it
iterates to determine if the outcome is correct.
➔ Useful for small code segments and loops that iterate a small number of times.
➔ Larger code segments or loops might require a debugging program.
● Here we used hand tracing to find out that this algorithm is incorrect. The algorithm was
actually just displaying the last time a number was less than the number after it in a list.
It was not comparing each number to all the other numbers.
● Sometimes, even if the algorithm works one time, it is still incorrect and wont work with
other examples. Therefore, multiple varying test cases must be used.
● To correct this algorithm, we would need to ask if the min<list(index)<list(index+1). And
repeat the LENGTH (list) times
Programmers test their programs a ton and use the results to revise, refine, and improve their
programs. Then they test their programs again. After the programmers test, the users test and
the program is refined even more. Eventually, the program is released.
VIDEO 3.1-Variables and Assignments
A variable is an abstraction inside a program that can hold a value. (Value can be text, number,
lists, boolean values, etc.)
label=variable
Ex=
Dos: Keep it short but clear.
Let’s say you want to store the high score of a game, create a variable called ‘highScore’
If you want to store a name- fistName
For boolean value-isRaining
For phone number-phoneNumber
There are different data types. Make sure to store your variable with the correct type
High score=integer
First name=text or string
Is raining=boolean
Phone number=text (not integer because integer is when doing math with the numbers.)
Practice
To store a person's age
Variable name: age
Variable type: integer (have to add 1 every yr)
⬅️
3.1 VIDEO 2- Variables and Assignments
⬅️
High score 100
⬅️
firstName ”Ashley”
⬅️
isRainging true
phoneNumber ”555-0101”
“” show text/string
Changing variables
⬅️
Ex:
⬅️
Num1 4
⬅️
Num2 6
Num1 num2
After sunning code segment, num1 will be displayed as 6 and num 2 will also be displayed as 6
⬅️
⬅️
Num1 25
⬅️
Num2 15
⬅️
Num3 30
⬅️
Num2 num3
⬅️
Num3 num1
Num1 num2
After running code segment:
Num 2 will be displayed as 30
Num 3 will be displayed as 25
Num 1 will be displayed as 30 (change num 1 based off of the already changed num 2)
The output is the changed variable’s value, not the original value.
★
★ Sometimes you may create an empty list so you can add things to it in future
★ Sometimes you will want to replace one list with another which you can do with the
arrow store button thing
○ classAStudents<-classBStudents
★
★
●
●
3.3 VIDEO 1-Mathematical Expressions
Algorithms:
➔ An algorithm is a finite set of instructions that accomplish a specific task. (ex:recipe,
morning routine, how you wash dishes)
➔ Beyond visual and textual programming languages, algorithms can be expressed in a
variety of ways, such as natural language, diagrams, and pseudocode.
➔ Algorithms executed by programs are implemented using programming languages.
➔ Every algorithm can be constructed using combinations of sequencing, selection, and
iteration.