Introduction Variables Data Types Numbers Casting Strings Boolean Operators Lists Tuples Dictionaries If-Else While Loops For Loops Functions Arrays Scope Modules User Input File Handling Python Maths

Welcome to the lesson on Numbers

Numbers

Numbers are data types assigned to numbers for calculation purposes.

In this lesson we will explore the three types of Numbers.

List of the three types of numbers.

1. int

2. float

3. complex

syntax
Try it out yourself

For extra confirmation, type() can be used to determine the numeric data type of a variable.

Integers

Integers are whole numbers, either negative or positive.

Example:

syntax
Try it out yourself

Float

Floating point number , or float is a decimal number , either negative or positive.

Example:

syntax
Try it out yourself

Complex

a complex number is a number that ends with a j

syntax
Try it out yourself

The random() Function

the random function can be used to generate a random number.

Example:

syntax
Try it out yourself

First, start off by importing random. Next, type random.randrange() and specify the range of numbers you would like python to choose from. if you would like a range from 1 to 10, enter 1 , 10 inside the brackets.

End of Python Numbers

You have learned Numbers in simple terms. Let's proceed on to Quiz.

Quiz Time!
Next Lesson
Back To Top