Home>Article>Backend Development> How to enter numbers in python
In programming, numbers are often used to record game scores, represent visual data, store web application information, etc. Python handles numbers differently depending on their usage. Since integers are the easiest to use, let’s first take a look at how Python manages them. Today we will learn how to enter numbers in python and the three number types among them!
In python, three number types are supported: integer type, floating point type and complex number type.
How to enter numbers in python:
1. First, open IDLE and see the >>> prompt
2. Behind the prompt Just enter the numbers directly, as shown below:
The output results are: integer 35, floating point number (decimal) 9.3, complex number 12 4j
How So, isn’t it very simple? Of course, python also supports multiple types of operations. Let’s introduce them separately
Integer types
##In Python, integers can be performed Add ( ), subtract (-), multiply (*) and divide (/) operations.
For example: In a terminal session, Python directly returns the result of the operation. Python uses two multiplication signs to represent exponentiation operations: Python also supports the order of operations, so you can use multiple operations in the same expression. You can also use parentheses to modify the order of operations and let Python perform operations in the order you specify, as follows:Floating point type (decimal)
Python calls numbers with decimal points floating point numbers. This term is used in most programming languages and refers to the fact that the decimal point can appear anywhere in a number. Every programming language must be carefully designed to handle floating-point numbers properly, ensuring that numbers behave normally regardless of the position of the decimal point. Look at the example:Plural type
z = a bj a is the real part, b is the imaginary part, a and b are both floating point types, the imaginary part is represented by j or J For example:The above is the detailed content of How to enter numbers in python. For more information, please follow other related articles on the PHP Chinese website!