curriculum/challenges/english/blocks/quiz-loops-and-sequences/67f41268a129e63f8e071736.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
Which of the following is the correct syntax for a list?
cities = //'Los Angeles', 'London', 'Tokyo'\\
cities = {'Los Angeles', 'London', 'Tokyo'}
cities = <'Los Angeles', 'London', 'Tokyo'>
cities = ['Los Angeles', 'London', 'Tokyo']
What will be printed to the console?
cities = ['Los Angeles', 'London', 'Tokyo']
print(cities[-1])
'None'
'Los Angeles'
'London'
'Tokyo'
What is an iterable?
It is a special type of string that can hold a large amount of characters.
It is a special type of number used to represent really large values.
It is a special data type mainly used in classes and special functions.
It is a special type of object that can be looped over one item at a time.
What will the following print to the console?
developer = 'Jessica'
print(list(developer))
'J', 'e', 's', 's', 'i', 'c', 'a'
{'J', 'e', 's', 's', 'i', 'c', 'a'}
<'J', 'e', 's', 's', 'i', 'c', 'a'>
['J', 'e', 's', 's', 'i', 'c', 'a']
Which of the following is used to get the number of elements in a list?
list()
long()
length()
len()
What happens if you try to pass in an index (either positive or negative) that is out of bounds for a list?
You will receive a SyntaxError.
You will receive a RangeError.
You will receive a TypeError.
You will receive an IndexError.
What will be printed to the console?
desserts = ['Cake', 'Cookies', 'Ice Cream', 'Pie']
print(desserts[1:3])
['Cake', 'Cookies', 'Ice Cream', 'Pie']
['Cake', 'Cookies']
['Cake', 'Cookies', 'Cookies', 'Ice Cream']
['Cookies', 'Ice Cream']
Which of the following methods is used to add an item to the end of a list?
add()
pop()
push()
append()
What will be printed to the console?
numbers = [1, 2, 3, 4, 5]
even_numbers = [6, 8, 10]
numbers.extend(even_numbers)
print(numbers)
[2, 3, 4, 5, 6, 8, 10]
[5, 6, 8, 10]
[1, 2, 3, 4]
[1, 2, 3, 4, 5, 6, 8, 10]
Which of the following methods is used to insert an element at a specific index in a list?
push()
add()
place()
insert()
What will be printed to the console?
numbers = [1, 2, 3, 4, 5, 5, 5]
numbers.remove(5)
print(numbers)
[1, 2, 3, 4]
[1, 2, 3, 4, 5, 5, 5]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 5]
Which of the following methods is used to empty a list?
pop()
empty()
remove()
clear()
What is a tuple?
It is a mutable data type of a random sequence of values.
It is a special data type used to represent large numbers.
It is a method used to add elements to a list.
It is an immutable ordered sequence of values.
Which of the following is the correct way to unpack items from a tuple?
developer = ('Alice', 34, 'Rust Developer')
(name, age, job) <= developer
developer = ('Alice', 34, 'Rust Developer')
<<name, age, job>> = developer
developer = ('Alice', 34, 'Rust Developer')
name, age, job == developer
developer = ('Alice', 34, 'Rust Developer')
name, age, job = developer
What will be the result of the following code?
developer = ('Jane Doe', 23, 'Python Developer')
del developer[1]
It will produce a RangeError.
Nothing will happen.
It will create an infinite loop.
It will produce a TypeError.
What will be the result for the following code?
programming_languages = ('Rust', 'Java', 'Python', 'C++', 'Rust', 'Python')
programming_languages.index('Python', 3)
2
6
0
5
Which of the following functions is used to create a new list of the sorted values?
has_sort()
sort()
is_sorted()
sorted()
Which of the following is the correct way to use a for loop?
programming_languages = ['Rust', 'Java', 'Python', 'C++']
for language in programming_languages [
print(language)
]
programming_languages = ['Rust', 'Java', 'Python', 'C++']
for language of programming_languages:
print(language)
programming_languages = ['Rust', 'Java', 'Python', 'C++']
for language in programming_languages {
print(language)
}
programming_languages = ['Rust', 'Java', 'Python', 'C++']
for language in programming_languages:
print(language)
Which of the following functions is used to generate a sequence of integers?
for()
int()
sequence()
range()
Which of the following functions is used to iterate over multiple iterables in parallel?
map()
filter()
reduce()
zip()