NEW
Font size
WorksheetsPython basics
Total questions: 10
Worksheet time: 2mins
What is the correct way to define a function in Python?
function myFunc():
def myFunc:
def myFunc():
define myFunc():
Which of the following is a correct way to create a list in Python?
a) list = "apple", "banana", "cherry"
b) list = ["apple", "banana", "cherry"]
c) list = ("apple", "banana", "cherry")
d) list = {"apple", "banana", "cherry"}
What is the output of the following code?
i = 1
while i < 4:
print(i)
i += 1
a) 1 2 3 4
b) 0 1 2 3
c) 1 2 3
d) Infinite loop
Which Python loop is best suited for iterating over a sequence like a list?
a) While loop
b) For loop
c) Switch loop
d) Sequence loop
In Python, what is the output of len([1, 2, 3, 4])?
a) 3
b) 4
c) Error
c) 2
In Machine Learning, which of the following is an example of supervised learning?
a) Clustering customers by behavior
b) Classifying emails as spam or not spam
c) Playing games using rewards
d) Grouping images without labels
Which type of learning focuses on finding hidden patterns in data without labels?
a) Supervised learning
b) Unsupervised learning
c) Reinforcement learning
d) Guided learning
In reinforcement learning, what helps the agent to improve its actions?
a) Rewards and penalties
b) Data labeling
c) Pre-trained models
d) Feature scaling
Which layer in the Machine Learning process is responsible for cleaning and preparing data?
a) Model layer
b) Data layer
c) Evaluation layer
d) Deployment layer
In Python, what will be the output of the following code?
print(type([1, 2, 3]))
a) <class 'list'>
b) <class 'tuple'>
c) <class 'dictionary'>
d) <class 'set'>
