notecards
notecards
AP Computer Science Principles Flashcards
# Collaboration
# Working together in the software development process can:
# - Lead to better problem-solving
# - Encourage diverse thinking
# - Make debugging easier
# Example:
# One student writes code while another reviews it,
# then they switch roles (pair programming).
# Program Function and Purpose
# A program is created to solve problems or perform tasks.
# Example:
# A calculator app helps users compute math problems.
# Purpose: Make arithmetic faster and easier.
# Program Design and Development
# The process of planning, creating, and refining a program's functionality.
# Example:
# A web app requires planning its structure and designing the user interface.
# Testing and feedback refine its design.
# Debugging
# Syntax Error: Mistake in code structure
# Logic Error: Code runs but doesn't do the right thing
# Example:
num = "5"
print(num + 1)
# Error: Can't add str and int
# Fix:
print(int(num) + 1) # Output: 6
# Binary Numbers
# Binary is the base-2 number system (0s and 1s).
# Used to represent all digital data.
# Example:
# 1010 in binary = 10 in decimal.
# Data Compression
# Reduces the size of data to save space or transmit faster.
# Lossless vs. Lossy compression.
# Example: JPEG (lossy), PNG (lossless).
# Extracting Information from Data
# Process of analyzing and retrieving useful insights from data.
# Example:
# Extracting customer purchasing trends from sales data.
# Using Programs with Data
# Programs are used to analyze, process, and visualize data.
# Example:
# A program that sorts data into categories and graphs the results.
# Variables and Assignments
# Variables store data that can change. Assignments give values to variables.
# Example:
x = 10 # Assigning 10 to the variable x
y = x + 5 # Assigning the value of x + 5 to y
# Data Abstraction
# Simplifying complex data structures to focus on the necessary information.
# Example:
# Using a list of dictionaries to store student names and grades, rather than creating individual variables for each student.
# Mathematical Expressions
# A combination of numbers, variables, and operators to perform calculations.
# Example:
x = 5
y = 3
result = x * y # result = 15
# Strings
# A string is a sequence of characters enclosed in quotes.
# Example:
name = "Alice"
greeting = "Hello, " + name # Concatenates "Hello, " with "Alice"
# Boolean Expressions
# Expressions that evaluate to either true or false.
# Example:
x = 5
y = 10
result = x < y # result = True
# Conditionals
# A statement that runs code based on whether a condition is true or false.
# Example:
if x > y:
print("x is greater")
else:
print("y is greater")
# Nested Conditionals
# A conditional statement inside another conditional statement.
# Example:
if x > y:
if x > z:
print("x is the greatest")
else:
print("z is the greatest")
else:
print("y is the greatest")
# Iteration
# Repeating a set of instructions until a condition is met.
# Example:
for i in range(5):
print(i) # Output: 0, 1, 2, 3, 4
# Developing Algorithms
# The process of creating a set of instructions to solve a problem.
# Example:
# To sort a list of numbers:
# 1. Compare the first two elements.
# 2. If needed, swap them.
# 3. Repeat until all elements are sorted.
# Lists
# A list is an ordered collection of elements.
# Example:
numbers = [1, 2, 3, 4]
print(numbers[2]) # Output: 3 (the third element)
# Binary Search
# A search algorithm that finds the position of a target value within a sorted array.
# Example:
# Given a sorted list [1, 3, 5, 7, 9], and target 5:
# - Start in the middle (5), find the target at index 2.
# Efficient with a time complexity of O(log n).
# Calling Procedures
# A procedure (or function) is a set of instructions that can be executed when called.
# Example:
def greet(name):
print("Hello, " + name)
greet("Alice") # Output: Hello, Alice
# Developing Procedures
# The process of creating functions to perform specific tasks in a program.
# Example:
# A procedure that calculates the square of a number:
def square(x):
return x * x
# Libraries
# A collection of pre-written code that provides common functionality.
# Example:
# The math library in Python:
import math
print(math.sqrt(16)) # Output: 4.0
# Random Values
# The generation of values that are not predictable.
# Example:
import random
print(random.randint(1, 10)) # Output: A random integer between 1 and 10
# Simulations
# Using models to represent real-world phenomena and experiment with different scenarios.
# Example:
# Simulating a dice roll:
import random
roll = random.randint(1, 6)
print("Dice roll: " + str(roll))
# Algorithmic Efficiency
# The measure of how fast an algorithm performs based on the size of the input.
# Example:
# A linear search has O(n) time complexity, while binary search has O(log n) time complexity.
# Undecidable Problems
# Problems that no algorithm can solve in a reasonable amount of time.
# Example:
# The halting problem: determining if a program will run forever or stop.
# The Internet
# A global network that connects millions of devices and allows communication.
# Example:
# Websites, emails, and file sharing are all services that use the internet.
# Fault Tolerance
# The ability of a system to continue operating even when parts of it fail.
# Example:
# RAID (Redundant Array of Independent Disks) systems replicate data across multiple disks.
# Parallel and Distributed Computing
# The use of multiple computers or processors to solve problems faster.
# Example:
# A large-scale weather simulation using multiple computers to process data simultaneously.
# Beneficial and Harmful Effects
# The impact of computing on society, including both positive and negative effects.
# Example:
# Beneficial: Improved healthcare through data analysis.
# Harmful: Privacy concerns due to personal data collection.
# Digital Divide
# The gap between those who have access to modern computing technology and those who do not.
# Example:
# Some rural areas may have limited access to the internet compared to urban areas.
# Computing Bias
# When a computing system produces unfair or unrepresentative results due to biased data or algorithms.
# Example:
# A facial recognition system that is less accurate for people with darker skin tones due to biased training data.
# Crowdsourcing
# The practice of obtaining input, services, or solutions by soliciting contributions from a large group of people.
# Example:
# Wikipedia is a crowdsourced project where users contribute and edit articles.
# Legal and Ethical Concerns
# Issues related to privacy, security, and the fairness of computing systems.
# Example:
# The use of personal data without consent raises ethical concerns and potential legal issues.
# Safe Computing
# Practices that ensure secure, responsible, and ethical use of computers and the internet.
# Example:
# Using strong passwords, enabling two-factor authentication, and avoiding malware.
Potential Questions for the AP Computer Science Principles (CSP) Exam
1. Concepts of Computing
- What is the purpose of abstraction in computing?
- Describe how abstraction is used in different levels of computing, from hardware to software.
- Explain the difference between a high-level and a low-level programming language.
- Give examples of each and describe how they interact with computer hardware.
- What is the role of an operating system?
- Describe how operating systems manage hardware, software, and user interactions.
- How do hardware and software interact?
- Explain how software relies on hardware resources to execute tasks.
2. Algorithms and Problem Solving
- What is an algorithm?
- Define an algorithm and explain why efficiency is important in algorithm design.
- Explain the concept of algorithmic complexity.
- What is the difference between O(n), O(log n), and O(1) complexity?
- How does a binary search algorithm work?
- Write a pseudocode or function that demonstrates binary search on a sorted array.
- Describe the difference between a linear search and a binary search.
- How do their efficiencies compare in terms of time complexity?
- What is the significance of developing algorithms to solve problems?
- Explain the process of designing an algorithm and give an example of a real-world problem and its solution using an algorithm.
3. Data Structures
- What is a list and how does it differ from other data structures?
- Discuss the benefits and limitations of lists compared to arrays, stacks, and queues.
- What is the difference between a list and a tuple in Python?
- When would you use one over the other?
- Explain the concept of a dictionary (or hash map).
- Describe how key-value pairs work and provide a use case example.
- What is recursion?
- Provide an example of a recursive function and explain its benefits and challenges.
4. Boolean Logic
- What is a Boolean expression?
- Write Boolean expressions and explain how they are evaluated.
- Explain how AND, OR, and NOT operators work.
- Provide examples of each and explain how they are used in programming.
- What are truth tables?
- Create a truth table for a complex Boolean expression.
5. Programming and Software Development
- What is a function/procedure, and why is it important?
- Provide an example of how to define and call a function in Python or JavaScript.
- Explain the concept of a “return” statement in a function.
- How does a return statement affect the execution of a program?
- What is the purpose of debugging?
- Describe common types of errors (syntax errors, logic errors, runtime errors) and how to debug them.
- Describe the process of software development using an iterative approach.
- What is the difference between a waterfall model and an agile model in software development?
6. Data and Information
- What is the difference between data and information?
- Provide examples and describe how data can be processed into useful information.
- What is the concept of data abstraction?
- Explain how data can be represented in more abstract ways to make processing easier.
- What is data compression?
- Discuss the importance of compressing data and give examples of compression algorithms (e.g., Huffman coding, Run-Length Encoding).
7. Internet and Networks
- How does the Internet work?
- Describe the role of protocols such as HTTP, TCP/IP, and DNS in ensuring successful communication over the internet.
- What is the difference between client-server and peer-to-peer models?
- Provide examples of systems that use each model.
- What is encryption, and why is it important for secure communication?
- Explain how encryption works and give an example of encryption algorithms.
- What are DNS and IP addresses?
- Describe the role of the Domain Name System and how IP addresses are used to identify devices on a network.
8. Ethical and Social Impacts
- What is the digital divide, and how does it affect access to technology?
- Discuss the social and economic impacts of unequal access to computing resources.
- Explain the concept of computing bias.
- Provide examples of how bias can be introduced into algorithms and its consequences.
- What are the ethical implications of crowdsourcing?
- Discuss the pros and cons of crowdsourcing in computing and how it impacts individuals and society.