Python3> round (a --b, 7)

@ Introduction to Python for science and technology calculation ――Development basics, essential libraries, acceleration by Kenji Nakahisa (Target environment: Python 3.5 or later)

In the unittest function, round (a-b, 7) == 0 was introduced as the processing of ʻassertAlmostEqual (a, b)`.

Related: http://qiita.com/aomidro/items/3e3449fde924893f18ca

I haven't learned round () yet.

link

https://docs.python.jp/3/library/functions.html#round ** Please note the notes **

code

I tried using it.

http://ideone.com/6lVook

#       12345678
in1 = 3.1415926
in2 = 3.14159265
dif = round(in1 - in2, 7)
print("%.8f" % dif)

#       123456789
in1 = 3.14159265
in2 = 3.141592653
dif = round(in1 - in2, 7)
print("%.8f" % dif)

run


-0.00000010 
-0.00000000

Recommended Posts

Python3> round (a --b, 7)
Python a + = b and a = a + b are different
[Python] return A [or / and] B
ABC126 A, B, C Explanation (python)
python> keyword arguments> hoge (** {'a': 1,'b': 2,'c': 3})
Solve ABC165 A, B, D in Python
A * algorithm (Python edition)
[Python] Take a screenshot
Create a Python module
A python lambda expression ...
Daemonize a Python process
python memo-"if not A and B" was "if (not A) and B"
Create a Python environment
Solve Atcoder ABC176 (A, B, C, E) in Python
AtCoder ABC 177 Python (A ~ E)
Take a screenshot in Python
Python round is not strictly round
Create a Wox plugin (Python)
Create a function in Python
Create a dictionary in Python
AtCoder ABC 178 Python (A ~ E)
A road to intermediate Python
[Python] Use a string sequence
ABC129 A, B, C commentary
AtCoder ABC 176 Python (A ~ E)
Python list is not a list
Make a bookmarklet in Python
Building a Python virtual environment
Create a python numpy array
Make a fortune with Python
I made a python text
A memorandum about Python mock
raspberry pi 1 model b, python
AtCoder ABC 182 Python (A ~ D)
Build a Python environment offline
Create a directory with python
Building a Python virtual environment
Codeforces Round # 626 B. Count Subrectangles
[Python] Dynamic programming TDPC A
What is a python map?
A note about [python] __debug__
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
Different from the import type of python. from A import B meaning
Create code that outputs "A and pretending B" in python
getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
[AtCoder explanation] Control ABC164 A, B, C problems with Python!
[Python3] "A // B" and "math.floor (A / B)" are not always the same! ??
[AtCoder explanation] Control ABC168 A, B, C problems with Python!
A record of patching a python package
[Python] What is a zip function?
Maybe in a python (original title: Maybe in Python)
[Python] What is a with statement?
Write a binary search in Python
Call a Python function from p5.js.
How to write a Python class
Solve ABC163 A ~ C with Python
Operate a receipt printer with python
A python graphing manual with Matplotlib.
A good description of Python decorators
[python] Manage functions in a list