wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PYTHON-QUIZ-2023

Total questions: 17

Worksheet time: 8mins

Name
Class
Date
1.

USN

4 lines
2.

NAME

4 lines
3.

To open a file c:\scores.txt for reading, we use _____________

a)

  infile = open(“c:\scores.txt”, “r”)

b)

infile = open(“c:\\scores.txt”, “r”)

c)

infile = open(file = “c:\scores.txt”, “r”)

d)

infile = open(file = “c:\\scores.txt”, “r”)

4.

1.      To read the entire remaining contents of the file as a string from a file object infile, we use ____________

a)

infile.read(2)

b)

infile.readline()i

c)

infile.read()

d)

infile.readlines()

5.

The readlines() method returns (a)  

6.

The character * is used in ________.

a)

Insert Query

b)

Delete query

c)

Select Query

d)

All of the above

7.

Python DB-API is

a)

Is a Python module

b)

connectivity modules

is used to access

c)

Specification for database SQLite database

d)

None of these

8.

What is a cursor in the context of database programming?

a)

It is an indicator showing the current position for user interaction on a computer monitor.

b)

It acts as a handle for a given SQL query using which records are traversed.

c)

It stores the list of rows in a table.

d)

None of these

9.

The ________ function returns its argument with a modified shape, whereas the ________ method modifies the array itself.

a)

      reshape, resize

b)

resize, reshape

c)

resize, resize

d)

all of the mentioned.

10.

To create sequences of numbers, NumPy provides a function __________ analogous to range that returns arrays instead of lists.

a)

arange

b)

aspace

c)

aline

d)

all of the mentioned

11.

Which of the following function stacks 1D arrays as columns into a 2D array?

a)

row_stack

b)

column_stack

c)

com_stack

d)

all of the mentioned

12.

ndarray.dataitemSize is the buffer containing the actual elements of the array.

a)

True

b)

False

13.

What will be printed?

 import numpy as np

 a = np.array([1,2,3,5,8])

 b = np.array([0,3,4,2,1])

 c = a + b

 c = c*a

 print (c[2])

a)

7

b)

12

c)

10

d)

21

14.

What will be output for the following code?

a)

0

b)

1

c)

2

d)

3

15.

What will be output for the following code?

a)

10

b)

3

c)

5

d)

45

16.

Which of the following statement is false?

a)

ndarray is also known as the axis array.

b)

ndarray.dataitemSize is the buffer containing

    the actual elements of the array.

c)

NumPy main object is the homogeneous

    multidimensional array

d)

In Numpy, dimensions are called axes

17.

What will be output for the following code?

a)

1

b)

2

c)

3

d)

4