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

What is the definition of a string?

Ordered sequences of characters (text).

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

All Flashcards

What is the definition of a string?

Ordered sequences of characters (text).

What is string indexing?

Accessing individual characters in a string using their position (starting from 0).

What is string slicing?

Extracting a portion (substring) of a string.

What is string concatenation?

Joining two or more strings end-to-end.

What is a boolean?

Represents truth values: True or False.

What is a variable?

Named storage locations in memory that hold values.

What is sequencing?

Executing code statements in order, one after another.

What is selection in programming?

Executing different blocks of code based on a condition (if/else).

What is iteration?

Repeating a block of code multiple times (loops).

What is a function?

Reusable blocks of code that perform a specific task and return a value.

What are the differences between a for loop and a while loop?

for loop: iterates a specific number of times or over a sequence. while loop: iterates as long as a condition is true.

What are the differences between functions and procedures?

Functions: return a value. Procedures: do not return a value.

What are the differences between lists and dictionaries?

Lists: ordered collections of items (mutable). Dictionaries: key-value pairs (unordered, mutable).

What does the following code output?

python
text = "Hello World"
print(text[6:])

World

What does the following code output?

python
text = "Programming"
print(text[:4])

Prog

What does the following code output?

python
str1 = "Hello"
str2 = "World"
print(str1 + " " + str2)

Hello World

What does the following code output?

python
word = "Python"
for i in range(len(word)):
    print(word[i])

P y t h o n

What does the following code output?

python
text = "OpenAI"
print(text.lower())

openai

What does the following code output?

python
text = "Coding is fun!"
print(text.replace("fun", "awesome"))

Coding is awesome!

Identify the error in the following code:

python
if x = 5:
  print("x is 5")

The assignment operator = should be the equality operator == in the if statement.

What does the following code output?

python
count = 0
while count < 3:
    print(count)
    count += 1

0 1 2

What does the following code output?

python
def greet(name):
    print("Hello, " + name + "!")

greet("Alice")

Hello, Alice!

What does the following code output?

python
numbers = [1, 2, 3, 4, 5]
print(numbers[1:3])

[2, 3]