AP Computer Science Principles Practice Questions

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

Which data structure in Python is immutable? (Hint: Tupperware is sealed shut)

Tuple

2
New cards

What is the result of True and False in Python?

False

(Needs both to be True for it to count as True)

3
New cards

What is the result of type([1,2,3])?

<class ‘list’>

(Because [ ] makes a list)

4
New cards

Valid Python operators:

*+, -, , /, %, =, ==, <, >, <=, >=, and, or, not

(These are used for math and logic)

5
New cards

Correct way to import specific items from a module:

from module_name import item_name

6
New cards

Output of print(list(range(3))):

[0, 1, 2]

(Range starts at 0 and stops before 3)

7
New cards

Which of the following correctly declares a variable in Python?

x = 5

(No “var” or “let” like JavaScript — just name = value.)

8
New cards

In Python, how do you create a single line comment?

#

9
New cards

Which data type stores a sequence of characters?

String (str)

*(Example: "Hello")

10
New cards

What is the result of 7 % 3 in Python?

1

(7 divided by 3 leaves a remainder of 1.)

11
New cards

Which loop structure is used when you want to iterate a specific number of times?

for loop

*(Example: for i in range(5):)

12
New cards

How do you check if two values are equal in Python?

==

(Example: if a == b:)

13
New cards

What is the correct way to create a list in Python?

my_list = [1, 2, 3]

14
New cards

Correct syntax for an if-else statement in Python:

if condition:
    # do something
else:
    # do something else

(Remember the colon : and indentation!)

15
New cards

How do you convert a string into an integer in Python?

int(“5”) → 5

16
New cards

Which operator is used for string concatenation?

+

*(Example: "Hello " + "World")

17
New cards

Concatenation

joining two or more sequences

18
New cards

Immutable

an object whose state cannot be modified after it is created