What is the output?
text = "Code"
print(text[1])
What is the output?
nums = [5, 10, 15]
print(nums[0])
5
What is the output?
for i in range(3):
print(i)
0
1
2
What is the output?
count = 1
while count <= 3:
print(count)
count += 1
1
2
3
What is the output?
name = "Sam"
print(f"Hello {name}")
Hello Sam
What is the output?
word = "apple"
print(word[-2])
1
What is the output?
nums = [1, 2, 3]
nums.append(4)
print(nums)
[1, 2, 3, 4]
What is the output?
for i in range(2, 6):
print(i)
2
3
4
5
What is the output?
x = 3
while x > 0:
print(x)
x -= 1
3
2
1
What is the output?
nums = [1, 2]
for n in nums:
print(n * 2)
2
4
What is the output?
msg = "Python"
print(msg[:3])
Pyt
What is the output?
items = ["a", "b", "c"]
items.insert(1, "x")
print(items)
['a', 'x', 'b', 'c']
What is the output?
for i in range(1, 10, 3):
print(i)
1
4
7
How many times will this loop run?
num = 5
while num < 5:
print(num)
num += 1
0 times
What is the output?
word = "abc"
for letter in word:
print(letter)
a
b
c
What is the output?
text = "banana"
print(text.count("a"))
3
What is the output?
letters = ["A", "B", "C"]
letters.remove("B")
print(len(letters))
2
How many times will this loop run?
for x in range(5):
print("Hi")
5 times
What is the output?
count = 0
while count < 4:
print("Loop")
count += 2
Loop
Loop
What is the output?
nums = [1, 2, 3]
print(len(nums) * 2)
6
What is the output?
text = "Hello"
new = text.replace("l", "z")
print(new)
Hezzo
What is the output?
nums = [10, 20, 30, 40]
nums.pop()
print(nums)
[10, 20, 30]
What is the output?
total = 0
for i in range(1, 4):
total += i
print(total)
6
What is the output?
n = 1
while n < 10:
print(n)
n *= 2
1
2
4
8
What is the output?
text = "Hi"
for i in range(3):
text += "!"
print(text)
Hi!!!