NEW
Font size
WorksheetsPractise Quiz
Total questions: 12
Worksheet time: 6mins
1. Myra is working on a Python project where she needs to filter out certain characters from a string. What will be the output of the following Python code snippet?
Prints all the vowels in my_strin
Prints all the consonants in my_string
Prints only on executing print(k)
Prints all characters of my_string that aren’t vowels
2. Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)]?
list_1 = [] for i in list_0: if func(i): list_1.append(i)
for i in list_0: if func(i): list_1.append(expr(i))
list_1 = [] for i in list_0: if func(i): list_1.append(expr(i))
none of the mentioned
3. What will be the output of the following Python code?
[4, 8, 12, 5, 10, 15, 6, 12, 18]
[18, 12, 6, 15, 10, 5, 12, 8, 4]
[4, 10, 18]
[4, 5, 6, 8, 10, 12, 12, 15, 18]
What will be the output of the following Python code?
[0, 1, 2]
[1, 2, 3]
error
none of the mentioned
What will be the output of the following Python code?
4
2
error
none of the mentioned
What will be the output of the following Python code?
[0, 2, 4, 6, 8, 10]
[1, 3, 5, 7, 9]
Error
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Aanya is trying to calculate the product of a list of numbers using Python. She writes the following code:
What will be the output of the code?
10
Error
No output
24
Vanya is trying to combine letters from two different sets to create new combinations. She has the first set of letters as 'abc' and the second set as 'def'. What will be the output of the following Python code snippet?
[‘ad’, ‘ae’, ‘af’, ‘bd’, ‘be’, ‘bf’, ‘cd’, ‘ce’, ‘cf’]
[‘da’, ‘db’, ‘dc’, ‘ea’, ‘eb’, ‘ec’, ‘fa’, ‘fb’, ‘fc’]
[[‘a’, ‘b’, ‘c’], [‘d’, ‘e’, ‘f’]]
[‘a’, ‘d’, ‘b’, ‘e’, ‘c’, ‘f’]
Aashi is planning a community event and wants to create a list of all the participants whose ages are multiples of 3. Write a list comprehension for producing a list of ages between 1 and 1000 that are divisible by 3.
[x for x in range(1, 1001) if x % 3 == 0]
[x%3 for x in range(1, 1000)]
[x%3=0 for x in range(1, 1000)]
[x in range(1, 1000) if x%3==0]
Which of the following represents the correct syntax to refer to a specific item in a 2D list?
list_name[column][row]
list_name[row, column]
list_name[row][column]
Rohan is analyzing the performance of teams in a tournament using a 2D list that contains the scores of each team in each match. Which of the following methods is the most effective way to access each score in this 2D list in Python?
Utilize a single for loop to access each score directly from the list.
Implement two nested for loops to traverse through each team's scores in the list.
Apply a recursive function to process the scores in the 2D list.
Which of the following statements about map() is true?
It creates a new array with the results of calling a provided function on every element in the calling array
It modifies the original array in place
It can only be used with numeric arrays.
It always returns an array of the same length as the original
