wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python basics

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

What is the correct way to define a function in Python?

a)

function myFunc():

b)

def myFunc:

c)

def myFunc():

d)

define myFunc():

2.

Which of the following is a correct way to create a list in Python?

a)

a) list = "apple", "banana", "cherry"

b)

b) list = ["apple", "banana", "cherry"]

c)

c) list = ("apple", "banana", "cherry")

d)

d) list = {"apple", "banana", "cherry"}

3.

What is the output of the following code?

i = 1

while i < 4:

print(i)

i += 1

a)

a) 1 2 3 4

b)

b) 0 1 2 3

c)

c) 1 2 3

d)

d) Infinite loop

4.

Which Python loop is best suited for iterating over a sequence like a list?

a)

a) While loop

b)

b) For loop

c)

c) Switch loop

d)

d) Sequence loop

5.

In Python, what is the output of len([1, 2, 3, 4])?

a)

a) 3

b)

b) 4

c)

c) Error

d)

c) 2

6.

In Machine Learning, which of the following is an example of supervised learning?

a)

a) Clustering customers by behavior

b)

b) Classifying emails as spam or not spam

c)

c) Playing games using rewards

d)

d) Grouping images without labels

7.

Which type of learning focuses on finding hidden patterns in data without labels?

a)

a) Supervised learning

b)

b) Unsupervised learning

c)

c) Reinforcement learning

d)

d) Guided learning

8.

In reinforcement learning, what helps the agent to improve its actions?

a)

a) Rewards and penalties

b)

b) Data labeling

c)

c) Pre-trained models

d)

d) Feature scaling

9.

Which layer in the Machine Learning process is responsible for cleaning and preparing data?

a)

a) Model layer

b)

b) Data layer

c)

c) Evaluation layer

d)

d) Deployment layer

10.

In Python, what will be the output of the following code?

print(type([1, 2, 3]))

a)

a) <class 'list'>

b)

b) <class 'tuple'>

c)

c) <class 'dictionary'>

d)

d) <class 'set'>