Python has three types of numeric data types. They are:
The int data type is a numeric type without fractional point.
x = 100 print(x)
The float data type is a numeric type with fractional point.
x = 100.70 y = 53e43 print(x) print(y)
The complex data type is a numeric type with real and imaginary components denoted by j character.
z = 7j print(z)
There are functions such as int(), float(), complex() available in Python to convert from one type to another.
a = 10 b = 20.28 c = 8j #convert from int to float print(float(a)) #convert from float to int print(int(b)) #convert from int to complex print(int(c))
Note: A complex number cannot be converted into int or float type.
Python has a built-in module random for generating random numbers.
import random print(random.randrange(1,100))