Worksheetspython gen
Total questions: 45
Worksheet time: 45mins
What is the output of the following code?
10
15
25
125
Error: invalid syntax
What will be the output
?
PythonPython is fun
Error
PythonPythonis fun
PythonPythonis fun
What is the output of the following code?
Python Quiz
PythonQuiz
Python+Quiz
Error
Are the statements below true or false?
*Strings are immutable in Python.
-Every time we modify a string, Python always creates a new string and assigns it to that variable.
True
False
What is the Output of the following code?
0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5
0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5
Error: The Program executed with errors
What is the output of the following code?
20
30
The program executed with errors
Which of the following is NOT a valid variable name in Python?
myvariable
_my_variable
2myvariable
my_variable2
What is the output of the following code?
py
yt
pyt
yth
How do you add an element to the end of a list in Python?
list.add(element)
list.insert(element)
list.append(element)
list.extend(element)
What is the output of the following code?
Jam
dno
maJ
dnoB semaJ
What is the output of the following code?
D
-space-
r
i
this is else block statement
D
r
i
this is else block statement
D
r
i
n
SyntaxError
What is the output of the following code?
{"Ahmmed","layla", "Salma", "Omar"}
{"layla","Salma", "Omar",1,"Ahmmed"}
The program executed with error
What is the output of the following code
Salary: 12000
Salary: 8000
Salary: 12000
Salary: 12000
The program failed with errors
What is the output of the following code?
1
2
3
4
What is the output of the add() function call
15
{8, 7}
(8, 7)
Syntax Error
What will be the output of the following Python code?
8
15
Error
multiply
What will be the output of the following Python code?
5
10
None
Error (Cannot assign to global variable)
What will be the output of the following Python code?
10
0
10
None
Error
10
Error
What will be the output of the following Python code?
15
Syntax Error
(5, 10)
What will be the output of the following Python code?
[1, 2, 3]
[1, 2, 3, 4]
[4]
Error
What will be the output of the following Python code?
0 1
Inner loop finished normally
1 0
Inner loop finished normally
Outer loop finished normally
0 1
Inner loop finished normally
1 0
Inner loop finished normally
0 1
Inner loop finished normally
1 0
Inner loop finished normally
Inner loop finished normally
Outer loop finished normally
0 1
1 0
2 0
Outer loop finished normally
What will be the output of the following Python code?
1
2
3
1
3
1
2
Error
What is the value of x
0
8
Error
10
What is the output of the following if statement
False
True
Which list comprehension correctly filters a list numbers to include only odd numbers?
[x for x in numbers if x % 2 ]
[x if x % 2 == 0 for x in numbers]
[x for x in numbers else x % 2 == 0]
[x where x % 2 == 0 in numbers]
What will be the output of the following Python code?
*** ** *
1 22 333
* * * * * *
* ** ***
What will be the output of the following Python code?
0
1
2
Loop completed
0
1
2
0
1
Error
What will be the output of the following Python code?
1 2
3 4
1 2 3 4
[1, 2] [3, 4]
Error
Given the nested if-else structure below, what will be the value of x
2
0
4
3
Select all valid String creation in Python
str1 = 'str1'
str1 = "str1"
str1 = '''str'''
str1 = 'str1'
str1 = "str1""
str1 = '''str1''
str1 = str(Rund)
What will be the output of the following Python code?
hello
world
[‘hello’, ‘world’]
helloworld
Which function is used to convert a string to an integer?
parse_int()
to_int()
int()
str_to_int()
What will be the output of the following Python code?
1
3
Error
(5,2,3)
What will be the output of the following Python code?
['', 'usr', 'local', 'bin', 'python']
['usr', 'local', 'bin', 'python']
['/usr', '/local', '/bin', '/python']
['/', 'usr', 'local', 'bin', 'python']
What will be the output of the following Python code?
level
True
False
Error
Select the correct output of the following String operations
Error
6
5
What will be the output of the following Python code?
True
True
False
False
True
False
False
True
What will be the output of the following string comparison
True
False
True
True
False
True
False
False
What will be the output of the following string operation?
Welcom Py Sdk
Welcom Py sdk
Elcom Py Sdk
What will be the output of the following Python code?
Joy Joy Joy
Joy Bliss Joy
Bliss Bliss Joy
Joy Joy Bliss
What will be the output of the following Python code?
banana
[‘apple’, ‘cherry’]
banana
[‘apple’, ‘banana’, ‘cherry’]
[‘apple’, ‘cherry’]
banana
Error
What will be the output of the following set operation?
{‘Yellow’, ‘Orange’, ‘Red’, ‘Black’, ‘Green’, ‘Blue’}
{‘Yellow’, ‘Orange’, ‘Black’, [“Blue”, “Green”, “Red”]}
TypeError: update() doesn’t allow list as a argument.
What will be the output of the following union operation?
{10, 20, 30, 40, 50}
{20, 30}
{10, 20, 30, 40, ’10’, 50}
Error: Different types cannot be used with sets
What will be the output of the following set operation?
{1, 2, 3, 4, 5}
{3}
{1, 2}
{4, 5}
What will be the output of the following code?
False
False
True
True
True
False
True
False
