wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Skills

Total questions: 15

Worksheet time: 23mins

Name
Class
Date
1.

What is the correct syntax for creating a variable that is bound to a set?

a)

A

b)

B

c)

C

d)

D

2.

This code provides the ______ of the list of the numbers.

a)

A

b)

B

c)

C

d)

D

3.

What is the correct syntax for defining an __init__() method that takes no parameters?

a)

A

b)

B

c)

C

d)

D

4.

What is the difference between class attributes and instance attributes?

a)

Class attributes are shared by all instances of the class. Instance attributes may be unique just to that instance.

b)

There is no difference between class attributes and isntance attributes.

c)

Instance attributes can be charged, but class attributes cannot be changed.

d)

Class attributes belong just to the class, not to instances of that class. Instance attributes are shared among all instances of a class.

5.

Which command will create a list from 10 down to 1? For example [10,9,8,7,6,5,4,3,2,1]

a)

A

b)

B

c)

C

d)

D

6.

What is the correct syntax for creating a variable that is bound to a dictionary?

a)

A

b)

B

c)

C

d)

D

7.

What is the output of the code?

a)

A

b)

B

c)

C

d)

D

8.

What is the correct syntax for adding a key called "variety" to the "fruit_info" dictionary that has value of "Red Delicious"?

a)

A

b)

B

c)

C

d)

D

9.

How would you access and store all of the keys in this dictionary at once?

a)

A

b)

B

c)

C

d)

D

10.

What is a lambda function?

a)

a function that gets executed when decorators are used

b)

a small, snonymous function that can take any nuber of arguments but has only on expression to evaluate

c)

any function that makes use of scientific or mathematical constants, often represented by Greek letters in academic writing

d)

any function whose definition is contained within five lines of code or fewer

11.

What is the correct syntax for defining an __init__() method that sets instance-specific attributes upon creation of a new class instance?

a)

A

b)

B

c)

C

d)

D

12.

What is a common use of Python's sys library?

a)

to capture command-line arguments given at a file's runtime

b)

to connect various systems, such as connecting a web fron end, an API service, a database, and a mobile app.

c)

to take a snapshot of all the packages and libraries in your virtual environment

d)

to scan the health of you Python ecosystem while inside a virtual environment

13.

Jaccard Similarity is a formula that tells you how similar two sets are. It is defined as the cardinality of the intersection divided by the cardinality of the union. Which is an accurate implementation in Python?

a)

A

b)

B

c)

C

d)

D

14.

How do you add a comment to existing Python script?

a)

-- This is a comment

b)

/* This is a coment *\

c)

// This is a comment

d)

# This is a comment

15.

When an array is large, NumPy will not print the entire array when given to the built-in print function. What function can you use within NumPy to force it to print the entire array?

a)

set_fullprint

b)

set_printwhole

c)

set_printoptions

d)

set_printparams