AP Computer Science Principles
AP Computer Science Principles
Section titled “AP Computer Science Principles”Course Overview
Section titled “Course Overview”AP Computer Science Principles introduces students to the foundational concepts of computer science and computational thinking. The course emphasizes creativity, collaboration, and problem-solving.
Exam Format
Section titled “Exam Format”- Duration: 2 hours 45 minutes
- Sections:
- Section I: 74 multiple-choice questions (1 hour 30 minutes)
- Section II: Performance task (submitted separately)
- Score: 1-5 (credit policy is per-institution: most state universities grant credit for 3+; selective colleges commonly require 4-5 or award placement instead)
Big Ideas
Section titled “Big Ideas”| Big Idea | Weight | Description |
|---|---|---|
| Creative Development | 10-15% | Collaboration, program design, abstraction |
| Data | 15-20% | Binary data, data compression, using data |
| Algorithms | 20-25% | Algorithm development, efficiency, correctness |
| Programming | 30-35% | Variables, control structures, procedures |
| Computing Systems and Networks | 10-15% | Internet, cybersecurity, parallel computing |
| Impact of Computing | 10-15% | Beneficial/harmful effects, digital divide |
Digital Information
Section titled “Digital Information”Binary Representation
Section titled “Binary Representation”Computers store data in binary (base-2) using 0s and 1s.
# Decimal to Binarydef decimal_to_binary(n): if n == 0: return "0" binary = "" while n > 0: binary = str(n % 2) + binary n = n // 2 return binary
# Binary to Decimaldef binary_to_decimal(binary): decimal = 0 for i, bit in enumerate(reversed(binary)): decimal += int(bit) * (2 ** i) return decimal
# Examplesprint(decimal_to_binary(42)) # "101010"print(binary_to_decimal("101010")) # 42Data Compression
Section titled “Data Compression”Lossless Compression
Section titled “Lossless Compression”- Run-Length Encoding (RLE): Replace consecutive identical values with count
- Huffman Coding: Variable-length codes based on frequency
# Run-Length Encodingdef rle_compress(data): compressed = [] i = 0 while i < len(data): count = 1 while i + count < len(data) and data[i] == data[i + count]: count += 1 compressed.append((data[i], count)) i += count return compressed
# Exampledata = "AAABBBCCDDDDD"print(rle_compress(data)) # [('A', 3), ('B', 3), ('C', 2), ('D', 5)]Lossy Compression
Section titled “Lossy Compression”- JPEG: Image compression using DCT
- MP3: Audio compression using psychoacoustic models
- Video compression: Frame differencing, motion estimation
The Internet
Section titled “The Internet”Internet Protocols
Section titled “Internet Protocols”TCP/IP Model
Section titled “TCP/IP Model”Layer 4: Application (HTTP, FTP, SMTP, DNS)Layer 3: Transport (TCP, UDP)Layer 2: Internet (IP, ICMP, ARP)Layer 1: Network Access (Ethernet, Wi-Fi)HTTP Request/Response
Section titled “HTTP Request/Response”GET /index.html HTTP/1.1Host: www.example.comUser-Agent: Mozilla/5.0Accept: text/htmlHTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 1234
<html>...</html>Cybersecurity
Section titled “Cybersecurity”Common Threats
Section titled “Common Threats”- Malware: Viruses, worms, trojans, ransomware
- Phishing: Fake emails/sites to steal credentials
- DDoS: Overwhelm servers with traffic
- SQL Injection: Insert malicious SQL queries
- XSS: Inject malicious scripts into web pages
Security Measures
Section titled “Security Measures”- Encryption: SSL/TLS, AES, RSA
- Authentication: Passwords, biometrics, 2FA
- Authorization: Access control, permissions
- Firewalls: Filter network traffic
- Updates: Patch vulnerabilities
Programming
Section titled “Programming”Variables and Data Types
Section titled “Variables and Data Types”# Python Variablesname = "Alice" # Stringage = 16 # Integerheight = 5.5 # Floatis_student = True # Boolean
# Lists (dynamic arrays)grades = [90, 85, 92, 88]
# Dictionaries (key-value pairs)student = { "name": "Alice", "age": 16, "grades": [90, 85, 92]}Control Structures
Section titled “Control Structures”# If-Elseif age >= 18: print("Adult")elif age >= 13: print("Teenager")else: print("Child")
# For Loopfor i in range(10): print(i)
# While Loopcount = 0while count < 10: print(count) count += 1
# Try-Except (Error Handling)try: result = 10 / 0except ZeroDivisionError: print("Cannot divide by zero")Functions
Section titled “Functions”# Function Definitiondef calculate_average(numbers): """Calculate the average of a list of numbers.""" if not numbers: return 0 return sum(numbers) / len(numbers)
# Function Callgrades = [90, 85, 92, 88]avg = calculate_average(grades)print(f"Average: {avg:.2f}")
# Recursive Functiondef factorial(n): """Calculate factorial recursively.""" if n <= 1: return 1 return n * factorial(n - 1)Algorithms
Section titled “Algorithms”Sequencing, Selection, Iteration
Section titled “Sequencing, Selection, Iteration”# Sequencing: Execute steps in orderdef make_sandwich(): get_bread() add_spread() add_filling() close_sandwich()
# Selection: Choose between optionsdef get_grade(score): if score >= 90: return "A" elif score >= 80: return "B" else: return "C"
# Iteration: Repeat stepsdef sum_list(numbers): total = 0 for num in numbers: total += num return totalAlgorithm Efficiency
Section titled “Algorithm Efficiency”Time Complexity
Section titled “Time Complexity”# O(1) - Constant Timedef get_first(items): return items[0]
# O(n) - Linear Timedef find_max(items): max_val = items[0] for item in items: if item > max_val: max_val = item return max_val
# O(n²) - Quadratic Timedef bubble_sort(items): n = len(items) for i in range(n): for j in range(0, n-i-1): if items[j] > items[j+1]: items[j], items[j+1] = items[j+1], items[j] return itemsSpace Complexity
Section titled “Space Complexity”- O(1): Fixed extra space
- O(n): Space proportional to input
- O(n²): Space for 2D structures
Data and Information
Section titled “Data and Information”Big Data
Section titled “Big Data”3 V’s of Big Data
Section titled “3 V’s of Big Data”- Volume: Large amounts of data (terabytes, petabytes)
- Velocity: Fast generation and processing
- Variety: Different formats (structured, unstructured)
Data Processing
Section titled “Data Processing”# Data Analysis with Pythonimport pandas as pd
# Load datadf = pd.read_csv("data.csv")
# Basic statisticsprint(df.describe())
# Filteringhigh_scores = df[df["score"] > 90]
# Groupingaverage_by_group = df.groupby("group")["score"].mean()Machine Learning
Section titled “Machine Learning”Types of Learning
Section titled “Types of Learning”- Supervised Learning: Labeled training data
- Unsupervised Learning: Find patterns in unlabeled data
- Reinforcement Learning: Learn from rewards/punishments
Simple Example
Section titled “Simple Example”# Linear Regression (simplified)def predict(x, slope, intercept): return slope * x + intercept
# Training datax = [1, 2, 3, 4, 5]y = [2, 4, 5, 4, 5]
# Simple gradient descentslope = 0intercept = 0learning_rate = 0.01
for _ in range(1000): for xi, yi in zip(x, y): prediction = predict(xi, slope, intercept) error = prediction - yi slope -= learning_rate * error * xi intercept -= learning_rate * error
print(f"Slope: {slope:.2f}, Intercept: {intercept:.2f}")Impact of Computing
Section titled “Impact of Computing”Beneficial Effects
Section titled “Beneficial Effects”- Communication: Email, social media, video calls
- Education: Online learning, educational apps
- Healthcare: Medical records, telemedicine
- Transportation: GPS, ride-sharing, autonomous vehicles
- Entertainment: Streaming, gaming, virtual reality
Harmful Effects
Section titled “Harmful Effects”- Privacy: Data collection, surveillance
- Security: Hacking, identity theft
- Employment: Automation, job displacement
- Health: Screen addiction, sedentary lifestyle
- Environment: E-waste, energy consumption
Digital Divide
Section titled “Digital Divide”- Access: Not everyone has internet or devices
- Skills: Not everyone knows how to use technology
- Affordability: Technology can be expensive
- Literacy: Understanding how to use technology effectively
Performance Task
Section titled “Performance Task”Requirements
Section titled “Requirements”- Program Design: Document your program’s purpose and design
- Development Process: Show iterative development
- Program Functionality: Program must be complete and functional
- Video: 1-minute video demonstrating your program
Tips for Success
Section titled “Tips for Success”- Choose a meaningful project - Solve a real problem
- Document your process - Show iterations and improvements
- Test thoroughly - Demonstrate all functionality
- Practice your video - Be clear and concise
Exam Preparation
Section titled “Exam Preparation”Practice Questions
Section titled “Practice Questions”Question 1: What is the decimal equivalent of binary 1010? A) 8 B) 10 C) 12 D) 14
Answer: B) 10 (1×8 + 0×4 + 1×2 + 0×1)
Question 2: Which compression method is lossy? A) Run-Length Encoding B) Huffman Coding C) JPEG D) ZIP
Answer: C) JPEG (images lose some quality)
Question 3: What is the time complexity of binary search? A) O(n) B) O(log n) C) O(n²) D) O(1)
Answer: B) O(log n)
Study Strategies
Section titled “Study Strategies”- Understand concepts - Don’t just memorize
- Practice coding - Build real programs
- Review big ideas - Focus on major themes
- Take practice exams - Familiarize with format
- Discuss with others - Explain concepts to learn better