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 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]
How is encryption applied in real-world scenarios?
Protecting sensitive data like passwords, credit card numbers, and personal information during online transactions.
How are algorithms applied in real-world scenarios?
Search engines use complex algorithms to rank search results, and social media platforms use algorithms to personalize content feeds.
How is data abstraction applied in real-world scenarios?
Using a car: you don't need to know how the engine works to drive it; you only need to know how to use the steering wheel, pedals, etc.