wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Workshop Day - 2

Total questions: 15

Worksheet time: 3mins

Name
Class
Date
1.

What method in Python is used to add an element at the end of a list?

a)

add()

b)

extend()

c)

insert()

d)

append()

2.

How are tuples different from lists in Python?

a)

Tuples are immutable, while lists are mutable.

b)

Tuples are mutable, while lists are immutable.

c)

Tuples are ordered, while lists are unordered.

d)

Tuples use square brackets, while lists use parentheses.

3.

Which of the following methods is used to concatenate two tuples in Python?

a)

merge()

b)

append()

c)

The '+' operator

d)

extend()

4.

How is a single-element tuple defined in Python?

a)

(element)

b)

(element,)

c)

[element]

d)

element,

5.

What is the primary characteristic of a set in Python?

a)

Does not allow duplicate elements

b)

Allows duplicate elements

c)

 Maintains elements in order of insertion

d)

Stores elements in key-value pairs

6.

In a list, what method is used to remove the last element?

a)

remove()

b)

pop()

c)

discard()

d)

delete()

7.

What is the primary difference between a set and a list in Python?

a)

Sets allow duplicate elements, whereas lists do not.

b)

Lists are unordered, while sets are ordered.

c)

Lists are immutable, while sets are mutable.

d)

Sets do not allow duplicate elements, whereas lists do.

8.

What does the 'difference()' method do in sets in Python?

a)

Returns the symmetric difference of two sets

b)

Returns the intersection of two sets

c)

Returns the difference of two sets

d)

Returns the union of two sets

9.

In NumPy, what does the shape of an array represent?

a)

Number of elements in the array

b)

Number of dimensions and size along each dimension

c)

Data type of the array

d)

Total size of the array

10.

What is the primary data structure in pandas for one-dimensional labelled data?

a)

DataFrame

b)

Series

c)

Array

d)

List

11.

In pandas, what is the purpose of the df.head() method?

a)

 Display the last few rows of the DataFrame

b)

Display the first 10 rows of the DataFrame

c)

Display the first 5 rows of the DataFrame

d)

Sort the DataFrame in ascending order

12.

How can you check for missing values in a pandas DataFrame?

a)

df.check_missing()

b)

df.has_null()

c)

df.isnull()

d)

df.missing_values()

13.

What is the purpose of the pd.read_csv function in pandas?

a)

Write data to a CSV file

b)

 Read data from a CSV file into a DataFrame

c)

Calculate summary statistics for a CSV file

d)

Convert a DataFrame to a CSV file

14.

Which of the following statements is true about the pyplot module in Matplotlib?

a)

It is not a part of Matplotlib.

b)

It is used for creating complex, interactive visualizations.

c)

It provides a MATLAB-like interface for creating simple plots.

d)

It is specifically designed for handling pandas DataFrames.

15.

How can you create a line plot in Matplotlib using the pyplot module?

a)

pyplot.line()

b)

 pyplot.plot_line()

c)

pyplot.create_line()

d)

pyplot.plot()