numeric and scalar types Flashcards
1
Q
float 64 bit
A
1 - sign, 11-exponent, 52-fraction
2
Q
get float info
A
sys.float_info
3
Q
decimal context
A
decimal.getcontext()
4
Q
set precision on decimals
A
decimal.getcontext().prec = 6
5
Q
infinity decimal
A
decimal.Decimal(“Infinity”)
6
Q
-7//3
A
3
7
Q
import fractions
A
from fractions import Fraction
8
Q
create complex number
A
a=3+2j a=complex(‘(3+2j)’) a=complex(3,2)
9
Q
extract real from complex
A
a.real
10
Q
extract image from complex
A
a.imag
11
Q
get a conjugate
A
a.conjugate()
12
Q
module for complex
A
cmath
13
Q
get polar
A
modulus, phase = cmath.polar(1+1j)
14
Q
get phase of complex
A
cmath.phase()
15
Q
built-in function that gives distance from zero
A
abs()