WorksheetsBasic Python Programming Concepts
Total questions: 15
Worksheet time: 8mins
What is the correct way to create a variable in Python?
let x = 10
x : 10
10 = x
x = 10
Which of the following is a valid Python data type?
int
float
string
list
What symbol is used for comments in Python?
#
//
%%
How do you start a function definition in Python?
function_name(parameters) start with def
def function_name(parameters):
function_name(parameters) is defined using define
function_name(parameters) begin with func
Which of the following is used to create a loop in Python?
repeat
looping
for, while
iterate
What will be the output of print(2 ** 3)?
6
9
4
8
How do you check the type of a variable in Python?
Use the 'checktype()' function.
Use the 'instanceof' operator.
Use the 'var_type()' method.
Use the 'type()' function.
Which keyword is used to handle exceptions in Python?
catch
finally
except
throw
What is the output of the following code: print('Hello' + ' World')?
Hello World
HelloWorld
Hello, World
Hello World!
How do you create a list in Python?
You create a list in Python using square brackets, e.g., my_list = [1, 2, 3].
You create a list in Python by using the list() function, e.g., my_list = list(1, 2, 3).
You create a list in Python using parentheses, e.g., my_list = (1, 2, 3).
You create a list in Python using curly braces, e.g., my_list = {1, 2, 3}.
Which of the following is a correct way to import a module in Python?
using math;
require('math')
import math()
import math
What is the purpose of the 'return' statement in a function?
The 'return' statement is used to declare variables within a function.
The 'return' statement is used to define a function's name.
The 'return' statement stops the execution of a program entirely.
The 'return' statement provides a way to output a value from a function.
How do you define a class in Python?
class ClassName: pass
class ClassName() {}
define ClassName as a function
class ClassName[]:
What is the output of the following code: print(len('Python'))?
8
7
6
5
Which operator is used for comparison in Python?
Logical operators
Comparison operators
Arithmetic operators
Bitwise operators
