Monday, June 29, 2020

Numbers

 Numbers

An int can be unlimited length.

Very small floats are auto converted to scientific notation when you try and print them.

Very large or very small floats auto convert to an a.bEd format on print. a is a single digit when d is positive. d can be positive or negative and must be greater than 13 or any negative integer to get the auto conversion to occur. Otherwise, the scientific notation is expanded out and a decimal point is used.


population  = 327E+6

print(population)

# result is:
327000000.0

-----------------

population  = 327E+14

print(population)

# result is:

3.27E+16

-----------------

population  = 327E+13

print(population)

# result is:

3270000000000000.0

-----------------------


population  = 327E-1

print(population)

# result is:

32.7

-----------------------


Math can be performed on very small float numbers, even if it means making them smaller.


Printing a complex number that only has a negative imaginary part will format with a -0 for the real part.

imag = -9j

print(imag)

# result is:

-0-9j

pos_imag = 9j

print(pos_imag)

# result is:

9j

import the random module

There is a randrange() function that takes two integers A&B. The range covered is from A to B-1 inclusive. B must be greater than A.

randrange(1,8) covers from 1 to 7 and returns an integer.








No comments:

Post a Comment