numeric and scalar types Flashcards

1
Q

float 64 bit

A

1 - sign, 11-exponent, 52-fraction

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

get float info

A

sys.float_info

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

decimal context

A

decimal.getcontext()

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

set precision on decimals

A

decimal.getcontext().prec = 6

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

infinity decimal

A

decimal.Decimal(“Infinity”)

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

-7//3

A

3

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

import fractions

A

from fractions import Fraction

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

create complex number

A

a=3+2j a=complex(‘(3+2j)’) a=complex(3,2)

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

extract real from complex

A

a.real

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

extract image from complex

A

a.imag

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

get a conjugate

A

a.conjugate()

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

module for complex

A

cmath

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

get polar

A

modulus, phase = cmath.polar(1+1j)

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

get phase of complex

A

cmath.phase()

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

built-in function that gives distance from zero

A

abs()

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

built-in function that perfoms decimal rounding

A

round(0.2825,3)

17
Q

convert to 16 base string

A

hex(52)

18
Q

convert to 8 base string

A

oct()

19
Q

date from timestamp

A

datetime.date.fromtimestamp(100000)

20
Q

get weekday (0,1,2,3,4,5,6) from date

A

d.weekday()

21
Q

year month and day from date

A

d.year d.month d.day

22
Q

get weekday(1,2,3,4,5,6,7)

A

d.isoweekday()

23
Q

combine date and time to datetime

A

datetime.datetime.combine(d, t)