Math Flashcards

1
Q

What is the result of 5 / 2 in Python?

A

2.5 (decimal division)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the result of 5 // 2 in Python?

A

2 (// rounds to the smallest number)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the result of -3 // 2 in Python?

A

-2 (rounds to the smallest number)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the correct workaround for Python to round towards zero?

A

int(-3 / 2)

This will result in -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When modding a value, what package can you use to get the correct negative value?

A

math.fmod()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the result of math.floor in Python?

A

Rounds down

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the result of math.ceil in Python?

A

Rounds up

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What package can you use in Python to get the square root of a number?

A

math.sqrt()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What package can you use to get the power of something in Python?

A

math.pow()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the best way to initialize a minimum possible value in Python?

A

float(“-inf”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the best way to initialize a maximum possible value in Python?

A

float(“inf”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: You have to be careful when using float(“inf”) because Python values can overflow

A

False - Python values are infinite and never overflow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly