zuai-logo
zuai-logo
  1. AP Computer Science Principles
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

What are the differences between a library and an API?

Library: A collection of pre-written code. | API: Specifies how to use the library's functions.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What are the differences between a library and an API?

Library: A collection of pre-written code. | API: Specifies how to use the library's functions.

What are the differences between sequence and iteration control structures?

Sequence: Executes instructions in order. | Iteration: Repeats a block of code multiple times.

What are the differences between lists and dictionaries?

Lists: Ordered collection of items, accessed by index. | Dictionaries: Collection of key-value pairs, accessed by key.

What are the differences between integers and floats?

Integers: Whole numbers without decimal places. | Floats: Numbers with decimal places.

What are the differences between the for and while loops?

for loop: Iterates over a sequence of elements. | while loop: Iterates as long as a condition is true.

What are the differences between testing and debugging?

Testing: Verifies if the program meets requirements. | Debugging: Identifies and fixes errors in the code.

What are the differences between data abstraction and data representation?

Data Abstraction: Hides complex implementation details. | Data Representation: Defines how data is stored and manipulated.

What are the differences between positive and negative impacts of computing?

Positive Impacts: Advancements in various fields, improved efficiency. | Negative Impacts: Job displacement, privacy concerns, digital divide.

What are the differences between procedural and object-oriented programming?

Procedural: Focuses on procedures and functions. | Object-Oriented: Focuses on objects with data and methods.

What are the differences between local and global variables?

Local: Defined within a function, accessible only in that function. | Global: Defined outside functions, accessible throughout the program.

What is modularity in programming?

Breaking down a program into smaller, independent modules or functions to improve code organization, reusability, and maintainability.

Why is code reuse important?

It reduces development time, improves code reliability, and promotes collaboration among developers.

Explain the benefits of using libraries.

Libraries provide pre-tested and optimized code, saving time and effort. They also enhance reliability and promote code sharing.

What is the purpose of control structures?

Control structures (sequence, selection, iteration) determine the order in which instructions are executed in a program, guiding the flow of execution.

Explain the concept of algorithm design.

Algorithm design involves breaking down a problem into smaller, manageable steps and creating a logical sequence of instructions to solve it.

What is the importance of program testing and debugging?

Testing and debugging ensure that a program functions correctly, identifies and fixes errors, and improves overall code quality and reliability.

Describe the positive impacts of computing innovations.

Computing innovations have led to advancements in communication, healthcare, education, and various other fields, improving quality of life and efficiency.

Describe the negative impacts of computing innovations.

Negative impacts include job displacement, privacy concerns, cybersecurity threats, and the digital divide, which can exacerbate social inequalities.

What is the importance of data representation in computing?

Data representation defines how data is stored and manipulated within a computer, influencing efficiency, accuracy, and the types of operations that can be performed.

Explain the benefits of using APIs.

APIs allow developers to easily integrate pre-built functionalities into their applications, promoting code reuse and saving development time.

What does the following code output?

python
from math import ceil

number = 4.2
result = ceil(number)
print(result)

5

Identify the error in the following code:

python
import random

number = random.randit(1, 10)
print(number)

The function randint is misspelled as randit. It should be corrected to randint.

What does the following code output?

python
from math import pi

print(pi)

3.141592653589793

Identify the error in the following code:

python
from math import log

number = -5
result = log(number)
print(result)

The math.log() function will raise a ValueError because it is being called with a negative number, which is not allowed for natural logarithms.

What does the following code output?

python
from math import pow

result = pow(2, 3)
print(result)

8.0

Identify the error in the following code:

python
import statistics

data = [1, 2, '3', 4, 5]
result = statistics.mean(data)
print(result)

The statistics.mean() function will raise a TypeError because the list data contains a string element ('3') while it expects numerical values.

What does the following code output?

python
from random import random

print(random())

A pseudo-random floating point number between 0.0 and 1.0.

Identify the error in the following code:

python
from math import factorial

number = 5.5
result = factorial(number)
print(result)

The math.factorial() function will raise a ValueError because it only accepts non-negative integer arguments, not floats.

What does the following code output?

python
from math import floor

number = 5.9
result = floor(number)
print(result)

5

Identify the error in the following code:

python
from math import exp

number = 'ten'
result = exp(number)
print(result)

The math.exp() function will raise a TypeError because it expects a numerical argument, not a string.