AP Computer Science Principles
AP Computer Science Principles
7. What type of errors arise when a program does not run as expected due to incorrect logic?
a) Syntax errors
b) Run-time errors
c) Logic errors
d) Input errors
8. How does a high-level programming language differ from machine language?
a) High-level languages are understood directly by computers
b) High-level languages use abstraction and are easier for humans to read
c) High-level languages are slower to execute
d) High-level languages contain only 1s and 0s
Unit 2: Programming
x = 2
REPEAT 3 TIMES
x = x + 2
DISPLAY x
a) 4
b) 6
c) 8
d) 10
14. Which of these represents a conditional statement?
a) REPEAT UNTIL x = 5
b) IF score > 90 THEN PRINT "A"
c) x = x + 5
d) RETURN x + y
16. A programmer needs to test a program for errors. What is this process called?
a) Debugging
b) Documentation
c) Looping
d) Abstraction
y = 10
IF y > 5 THEN
DISPLAY "High"
ELSE
DISPLAY "Low"
a) High
b) Low
c) Error
d) 10
Unit 3: Lists
22. How do you access the first element of a list in most programming languages?
a) list[1]
b) list[0]
c) list[first]
d) list[-1]
a) 5
b) 10
c) 15
d) 20
list = [2, 4, 6, 8]
FOR EACH item IN list
DISPLAY item + 1
a) 2, 4, 6, 8
b) 3, 5, 7, 9
c) 1, 3, 5, 7
d) 2, 3, 4, 5
37. Why is lossy compression often used for media files like images and audio?
a) It ensures no data is lost
b) It significantly reduces file size by removing unnecessary data
c) It improves the resolution of the media
d) It makes files more secure
40. A sound file is sampled at 44,100 Hz. What does this mean?
a) The sound is sampled 44,100 times per minute
b) The sound is sampled 44,100 times per second
c) The sound frequency is 44,100 kHz
d) The file size will always be 44,100 MB
45. Which of the following file types uses lossy compression for audio?
a) WAV
b) MP3
c) FLAC
d) TXT
46. What is the main trade-off of using lossy compression for images?
a) Improved quality but slower loading times
b) Smaller file size but reduced quality
c) Higher resolution but larger file size
d) Faster compression but higher storage costs
47. A programmer compresses an image file and notices some quality is lost. Which format was
likely used?
a) BMP
b) PNG
c) JPEG
d) TIFF
48. What does increasing the sampling rate of a sound file achieve?
a) It decreases the file size
b) It increases the accuracy of the recorded sound
c) It reduces the sound quality
d) It removes background noise
49. Which of the following reduces image file size without losing any data?
a) Converting a file to a JPEG format
b) Saving a file in PNG format
c) Increasing image resolution
d) Adding metadata