Numbers Flashcards
1
Q
Convert string to floating point
A
float(‘123.45’)
2
Q
Print floating point number with precision
A
print(f’{value:.6f}’)
3
Q
Initialise a variable to negative or positive infinity
A
variable = float(‘inf’)
variable = -float(‘inf’)
4
Q
Convert to integer
A
int(‘123’)
5
Q
Round a number
A
round(number)
6
Q
Round down
A
math.floor(number)
7
Q
Round up
A
math.ceil(number)
8
Q
Integer division
A
4 // 2
9
Q
Find remainder of division
A
Number % divisor
10
Q
Find min of list
A
min(numbers)
11
Q
Find min of list
A
min(numbers)
12
Q
Find max of list
A
max(numbers)