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).
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.
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]