How does Python output integers

**Python output integer method: **

First use the str() function to convert the number into a string and assign it to the variable i, and then use the "if i.count('.') == 0" statement to determine whether there is no decimal point in the string, and if so, output the string. So the output numbers are all integers

The sample code is as follows:

x =[23.5,45.6,987,698,123,654]for i in x:
 i =str(i)if i.count('.')==0:print(I)

The results are as follows:

Example extension:

Python decimal integer output

f =1.6print("1.6 Direct integer output is%d"%f,end="\n")print("1.6Using the precision range output of floating point numbers%.0f"%f)

Output

1.6 Direct integer output is 1
1.6 Output 2 using the precision range of floating point numbers

It directly becomes an integer output, and the mantissa is directly discarded.

The accuracy display is rounded.

The above is the details of how Python outputs integers. For more information about Python output integer example methods, please pay attention to other related articles on ZaLou.Cn!

Recommended Posts

How does Python output integers
How does python output backslashes
How does python update packages
How does python perform matrix operations
How does Python list update value
How does python change the environment
How does python call java classes
How does python import dependency packages
How does python enter interactive mode
How does Python generate xml files
How does python determine prime numbers
How does python improve the calculation speed
How does python call its own function
How does Python handle the json module
How does python distinguish return and yield
How does Python call cmd using OS modules
How does Python store data to json files
How python was invented
How Python parses XML
How does python call the key of a dictionary
How does python get input examples from the keyboard
How does python handle the program cannot be opened
How does python judge the module installation is complete
How to comment python code
How Python converts string case
How long does it take to learn python by myself?
How to learn python quickly
How to uninstall python plugin
Python output mathematical symbols example
Does Python support multiple inheritance?
How Python implements FTP function
How to understand python objects
How to use python tuples
Explain how python references package package
Python string three formatted output
python how to view webpage code
How to use python thread pool
How Python implements the mail function
How to write python configuration file
How to wrap in python code
What does rc1 mean in python
How to save the python program
What does def in python do
How to omit parentheses in Python
How to install Python 3.8 on CentOS 8
How to install Python 3.8 on Ubuntu 18.04
How to write classes in python
How to filter numbers in python
How to read Excel in Python
How to install Python on CentOS 8
How to solve python dict garbled
How to view errors in python
What does np do in python
How to write return in python
How Python operates on file directories
How Python implements the timer function
How to view the python module
How to understand variables in Python
How to clear variables in python
How to understand python object-oriented programming
Python realizes console output color font