NEW
Font size
WorksheetsPython Class 1
Total questions: 15
Worksheet time: 8mins
What is the correct syntax to print "Hello, World!" in Python?
System.out.println("Hello, World!")
echo "Hello, World!"
print("Hello, World!")
cout << "Hello, World!"
What will be the output of the following code?
x = 5
y = 2
print(x % y)
1
2
0
5
Which of the following data types is mutable in Python?
Tuple
String
List
Integer
What is the result of this operation?
print(2 ** 3)
6
8
9
ERROR
How do you start a comment in Python?
//
#
/*
<--
What will the following code print?
Hello, World! Hello, World!
Hello, World! Hello, Alice!
Hello, Alice! Hello, World!
None of the above
What is the output of this code snippet?
apple
banana
cherry
Error
How do you handle exceptions in Python?
Using try-except
Using catch
Using if-else
Using finally
What does the following list comprehension do?
Creates a list of squares of numbers from 0 to 4
Creates a list of numbers from 0 to 5
Creates a list of numbers from 1 to 5
Creates a list of numbers from 1 to 25
What will the following code snippet output?
[1, 2, 3]
[1, 2, 3, 4]
[1, 2]
Error
What is the purpose of the @staticmethod decorator?
Define a method that does not require access to the instance or class
Define a method that can only access class-level data
Define a method that modifies static variables
None of the above
What will be the output of this code?
[1] [1]
[1, 1] [1, 1]
[1] [1, 1]
Error
How can you create a Python generator?
Using the yield keyword
Using return inside a loop
Using the @generator decorator
Using next function only
What will be the output of this code snippet?
10
15
20
Error
How do you optimize a function for large datasets?
Use recursion for efficiency
Use generators to yield data incrementally
Load all data into memory for faster access
Use print statements to debug and optimize
