What is the output of this cote?
my_set = {1, 2, 3}
my_set.add(4)
my_set.remove(2)
print(my_set)
Error
{1,2,3,4}
{1,2,3}
{1,3,4}
{1,3,4}
davidmacago posted 2 years ago
What is the output of this cote?
my_set = {1, 2, 3}
my_set.add(4)
my_set.remove(2)
print(my_set)
Error
{1,2,3,4}
{1,2,3}
{1,3,4}
{1,3,4}
In the text box, below, write a for each loop that prints out each element in a list (named myList) preceded by its index using the appropriate python method. Use three spaces to indent instead of a tab.
for i,j in enumerate(myList):
print(f"{i}. {j}")
What is the output of this code?
for number in range(10):
if number % 2 == 0: # number % 2 == 0 (means number is even), number % 2 != 0 (means number is odd)
continue
print(number)
1, 5, 9
0, 2, 4, 6, 8
1, 3, 5, 7, 9
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
1, 3, 5, 7, 9
What is the output of this code?
for i in range(1, 6):
if i == 3:
break
print(i)
1, 2
1, 2, 3, 4, 5
1, 2, 3
1, 2, 3, 4
1, 2
What is the output of this code?
my_list = [1, 2, 3]
my_list.append([4, 5])
print(my_list)
[1, 2, 3, [4, 5]]
[1, 2, 3]
[1, 2, 3, 4, 5]
Error
[1, 2, 3, [4, 5]]
What is the output of this code?
my_tuple = (1, 2, 3)
my_tuple[0] = 4
print(my_tuple)
Error
(1,2,3)
(1,2,3,4)
(4,2,3)
Error
What is the output of this cote?
set_a = {1, 2, 3, 4, 5}
set_b = {3, 4, 5, 6, 7}
print(set_a | set_b)
print(set_a & set_b)
print(set_a - set_b)
{1,2,3,4,5,6,7}
{3,4,5}
{1,2}
{1,2,3,4,5}
{3,4,5}
{1,2}
{1,2,3,4,5,6,7}
{3,4,5,6,7}
{1,2,3,4,5,6,7}
{1,2,6,7}
{3,4,5}
{1,2,6,7}
{1,2,3,4,5,6,7}
{3,4,5}
{1,2}
What is the output of this code?
word = "Quiz"
for letter in word:
print(letter * 2)
Q, u, i, z, Q, u, i, z
QQ, uu, ii, zz
QuizQuiz
Q, u, i, z
QQ, uu, ii, zz
What is the output of this code?
my_list = ['apple', 'banana', 'cherry']
my_list.pop(1)
print(my_list)
['apple','banana']
['banana','cherry']
Error
['apple', 'cherry']
['apple', 'cherry']
Which statement creates an empty set
x = {}
x = ()
x= []
None of these
None of these
What is the output of this code?
for i in range(3, 10, 2):
print(i)
3, 5, 7, 9
3, 5, 7, 9, 11
0, 2, 4, 6, 8
3, 5, 7
3, 5, 7, 9
In the text box below write a for loop that prints all of the possible rolls of two six-sided dice. Use three spaces to indent instead of a tab
possible_rolls = [(i,j) for i in range(1,7) for j in range(1,7)]
print(possible_rolls)
What is the output of this code?
my_list = ['apple', 'banana', 'cherry']
for index, item in enumerate(my_list):
print(index, item)
0, 1, 2
apple, banana, cherry
1 apple, 2 banana, 3 cherry
0 apple, 1 banana, 2 cherry
0 apple, 1 banana, 2 cherry



