Font size
WorksheetsPython-Loops-Iterables
Total questions: 25
Worksheet time: 13mins
Which of the following is not an iterable?
List
Dict
String
int
Which of the Following is a mutable Data Type?
List
Tuple
Which Arithematic Operator Cannot be used for Strings
' + ' operator
' - ' operator
' * ' operator
All the above.
What will be the Output of the Code
(a)
Which of the following functions is a built-in function in python?
seed
sqrt
factorial
What will be the output of the following Python function?
sum(2,4,6)
sum([1,2,3])
Error
6
12
Error
12
6
Error
Error
How do you insert comments in python
#This is a comment
//This is a comment
/*This is a comment*/
<!This is a comment>
Which one is NOT a legal variable name?
VARNAME
_var_name_
var-name
VarName
What is the correct way to create a function?
def myfunction():
create myfunction():
function myfunction():
Which collection is ordered, changeable, and allows duplicate members?
List
Set
Tuple
Dictionary
Which collection does not allow duplicate members?
Set
Tuple
List
What is the output for −
'Hello World' [100:200]?
Index Error
"Hello World"
Syntax Error
""
Which among them is incorrect for set S={100,101,102,103}
len(S)
sum(S)
print(S[3])
max(S)
st=”Cadbury Dairy Milk”
x=st.split(‘a’)
print(len(x))
What is the output of the above code?
3
6
7
9
Which of the following sorts the elements of tuple?
ex: tup = (6,4,8)
sort(tup)
tup.sort()
sorted(tup)
tup.sorted()
Which of the following is used to create an empty set?
{}
[]
()
set()
If return statement is not used inside the function, the function will return:
None Object
An arbitrary int
Error
Function must return somethingd
What would this print?
To remove the spaces present at start and end of the string, you can use
split()
len()
strip()
remove()
The code above prints all numbers between 1 and 30 that are
not divisible by 5
divisible by 5
The program above prints the sum of
all odd numbers less than 100
all even numbers less than 100
all numbers less than 100
The program above prints the sum of all the numbers between 0 and 101 that are
alternate odd numbers
alternate even numbers
alternate numbers
The program above prints each number between 1 and 10
as many times as the number itself
10 times
11 times
How many times will 1 be printed
3
4
5
6
print("3+4")
