Search Header Logo

Python Test 2

Authored by Peter Parfenov

Computers

University

Used 1+ times

Python Test 2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

19 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

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

b = a.flatten()

print(len(a), len(b))

6 2

2 3

3 6

3 2

2.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What do you expect from this code (more than 1 answer)?

import numpy as np

a = np.arange(4)

b = a / 0

print(b)

[nan nan nan]

[nan inf inf inf]

Zero Division Warning

[inf inf inf inf]

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

a = np.linspace(1, 3, 3) ** 3

x = a > 20

print(x)

[False False True]

[True True False]

[True True True]

[False False False]

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

x1 = np.linspace(0, 5, 5, endpoint=False)

y1 = np.linspace(0, 5, 5, endpoint=True)

x2 = np.linspace(0, 5, 5, endpoint=False)

y2 = np.linspace(0, 4, 5, endpoint=True)

print(np.sum(x1) == np.sum(y1), np.sum(x2) == np.sum(y2))

[True True]

[False False]

[True False]

[False True]

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

a = np.arange(2)

b = np.arange(2, 0, -1)

print(a == b)

[False True]

[True True]

[False False]

[True False]

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

a = np.array(((1, 0, 1), (0, 1, 0)))

print(a.size)

3

2

6

(2, 6)

(2, 3)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import numpy as np

a = np.array(((1, 0, 1), (0, 1, 0)))

print(a.ndim)

2

3

6

(2, 3)

(2, 6)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers