WorksheetsGet started with python
Total questions: 19
Worksheet time: 9mins
What are the basic data types in Python?
char, list, tuple, dict
int, float, str, bool
int, float, array, set
string, number, boolean, object
How do you define a variable in Python?
x : 10.
int x = 10.
x; 10.
x = 10.
What is the purpose of the 'if' statement in Python?
To define a function in Python.
To execute code conditionally based on a boolean expression.
To create a loop that iterates over a list.
To declare a variable in Python.
Explain the difference between a list and a tuple in Python.
A list is immutable and tuple is mutable
Both lists and tuples are mutable
A list contain integers, tuple contain string.
A list is mutable and
tuple is immutable
How functions is defined in python?
Using 'def' keyword
Using 'define' keyword
Using 'func' keyword.
Using x=fun()
How do you import a module in Python?
Using 'require' statement
Using 'load' command
Using 'import' statement
By function call
What is the syntax for a for loop in Python?
for variable in sequence:
for variable to sequence:
foreach variable in sequence:
for (variable : sequence)
In python String concatenation is done using ?
'concat()' method.
'append()' function
'+' operator.
'&' operator.
What is the output of the expression '5' + '3'?
'53'
'5''3'
53
8
How do you access an element in a list by its index?
list.get(index)
list.index
list[index]
list[index + 1]
What is the purpose of the 'return' statement in a function?
To end the function execution immediately.
To define the function's parameters.
The purpose of the 'return' statement is to provide a value from a function to its caller.
To create a loop within the function.
How do you create a dictionary in Python?
{'key': 'value'}.
import dict module.
('key', 'value')
['key': 'value']
What is the difference between '==' and 'is' in Python?
'==' compares values, 'is' compares identities.
'==' is faster than 'is' for large data sets.
'==' is used for assignment, 'is' is for comparison.
'==' checks data types, 'is' checks values.
How do you handle exceptions in Python?
Exception handling not possible
Using if-else statements
Ignore exceptions & go on.
Using try-except blocks
What is the purpose of the 'break' statement in a loop?
To exit the loop immediately.
To skip the current iteration and continue with the next one.
To pause the loop for a specified time.
To define a new function within the loop.
How can you check the length of a list in Python?
Using the 'length()' function.
Using 'len(list)'.
Using 'size(list)'.
Using 'count(list)'.
What does the 'pass' statement do in Python?
It terminates the program.
It acts as a placeholder for future code.
It raises an exception.
It defines a new variable.
What is the purpose of the 'elif' statement in Python?
To define a function in Python.
To execute multiple conditional checks in a sequence.
To create a loop that iterates over a list.
To declare a variable in Python.
What is the output of the expression '10' * 3?
30
'101010'
'10'*3
TypeError
