wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz 1

Total questions: 24

Worksheet time: 12mins

Name
Class
Date
1.

Python language was developed in which year

a)

1985

b)

1991

c)

1920

d)

2001

2.

The following code is used to create a variable and store a value. Why will it not work?

My number=36

a)

The equals symbol should be at the beginning of the line

b)

A variable name cannot have any spaces

c)

The variable can’t share a number

d)

There variable names cannot be called my number

3.

Which of the following is a prominent python “statistics and econometrics library”?

a)

Bokeh

b)

Seaborn

c)

Statsmodels

d)

None of the above

4.

Identify the correct statement:

a)

The standard marker for missing data in Pandas is NaN

b)

Series acts in a way like that of an array

c)

Both of the above

d)

None of the above

5.

A series is a one-dimensional array which is labelled and can hold any data type.

a)

True

b)

False

6.

Which of the following can be used to make a Dataframe?

a)

Series

b)

Dataframe

c)

Structured ndarray

d)

All of the above

7.

Suppose you are defining a tuple as:

tup = (1,2,3,4,5)

We want to update the value at the second index from 2 to 10. How would we do it?

a)

tup(2) = 10

b)

tup[2] = 10

c)

tup{2} = 10

d)

None of these

8.

Data structures in Pandas can be mutated in the terms of ____ but not of _____.

a)

size, value

b)

value, size

c)

semantic, size

d)

None of the above

9.

Identify the correct statement:

a)

Moving window statistics are available in Pandas

b)

Pandas have a set of array data structures which are labelled

c)

Pandas consist of an integrated group by engine for transforming and aggregating data sets

d)

All of the above

10.

Which of the following is implemented on DataFrame to compute the correlation between like-labeled Series contained in different DataFrame objects?

a)

corrwith

b)

corwith

c)

corwth

d)

None of the above

11.

Lambda functions in Python can extend beyond a single line.

a)

True

b)

False

12.

What is the output of the following program?

x = ['ab', 'cd']

for i in x:

i.upper()

print(x)

a)

[‘ab’, ‘cd’]

b)

[‘AB’, ‘CD’]

13.

All keywords in python are:

a)

UPPER CASE

b)

lower case

c)

Capitalized

d)

None of the above

14.

What is the return type of function id()?

a)

Float

b)

Bool

c)

Dict

d)

Int

15.

Which of the following data types is not supported in python?

a)

String

b)

Numbers

c)

Slice

d)

List

16.

Select the reserved keyword in python?

a)

else

b)

raise

c)

import

d)

All of the above

17.

What is the output of 7^10 in python?

a)

13

b)

15

c)

2

d)

None of the above

18.

Which of the following functions is a built-in function in python?

a)

seed()

b)

sqrt()

c)

factorial()

d)

map()

19.

What will be the output of the following python functions?

sum(2,4,6)

sum([1,2,3])

a)

Error, 6

b)

12, Error

c)

12, 6

d)

Error, Error

20.

Assume, you are given two lists: a = [1,2,3,4,5], b = [6,7,8,9]

The task is to create a list which has all the elements of a and b in one dimension.

Output:

a = [1,2,3,4,5,6,7,8,9]

Which of the following option would you choose?

a)

a.append(b)

b)

a.extend(b)

c)

Any of the above

d)

None of the above

21.

In Python, an ELSE IF statement is represented as what?

a)

elsif

b)

elif

c)

ifelse

d)

Elseif

22.

Which of the following would work?

a)

If answer ==”Yes”:

b)

If answer=”yes”:

c)

If answer==”yes”

d)

IF answer == ”Yes”:

23.

What is the correct order?

1. print(“See you there”) 2. elif reply == “maybe”: 3. reply = input (“Are you going to the fair?”) 4. print(“I hope you do!”) 5. else: 6. if reply == “Yes”: 7. print(“Why not?”)

a)

3,6,1,2,4,5,7

b)

3,6,4,2,1,5,7

c)

3,1,6,5,7,2,4

d)

6,5,3,4,2,1,7

24.

Python is based on which principal?

a)

PEMDAS

b)

PEDMAS

c)

PEASDM

d)

PAESDM