What you’re trying to figure out is, nothing more, nothing less than the teto
of a number.
The teto
of a number real
(which may be a floating point number) is the menor
number inteiro
greater than that actual value.
Example 01:
The teto
of 22.6
is 23
For the menor
integer superior
the actual value number 22.6
has as a result the number 23
Example 02:
The teto
of -22.6
is -22
For the menor
integer superior
the actual value number -22.6
results in the number `-22.
Before making any decision before this 2nd example you should note the direção
the provision of values in real straight.
In the reta real
the numbers are distributed in the sentido
of esquerda
to the direita
. In other words, given a real number N, every number maior
that N
will be placed at your direita
...
22.6, 27.0 29.6, 30.4...
...every number menor
that N
will be placed at your esquerda
...
...16.0, 17.5, 20.0, 22.4, 22.6
Faced with this explanation we can now clearly see the result of 2º exemplo
, that is to say,
-25.0, -24.7, -22.6, -22.0, -21.5, ...
That is, as the value -22 is positioned to the right of -22.6. this means that the teto
of -22.6
is the number -22
.
Now, after all this explanation, how do we calculate the teto
of a number with the Python
?
To calculate the teto
of a number in Python
it is necessary to execute the method ceil
class math
.
To show how this método
I developed the following algorithm...
from math import ceil
lista = [15.3, 16.3, 17.9, 21.4, 22.5, 25.6, 26.9]
resultado = list()
for numero in lista:
# Calculando os valores dos Tetos de cada valor contido em "lista".
resultado.append(ceil(numero))
print(f'\033[32mOs valores dos Tetos são: {resultado}\033[m')
See how the algorithm works on repl it.
Note that this algorithm calculates and displays the value of teto
of all values in the previous list.
Also note that the function result ceil
will always be a value inteiro
.
Duplicate of https://answall.com/q/317381/5878
– Woss