The version of Python used is 3.5.1. It is convenient to install numpy ・ (scipy ・) matplotlib ・ sympy as a package, but I will not use it this time.
If you installed Python as a package on Linux, you can also install it from the package. Others use pip. (For Windows, start the command prompt powershell with administrator privileges in advance, and install the wheel package with pip (pip install wheel
). If the installation with pip fails, https: // pypi Please download the wheel that matches the Python architecture (32/64 bit) / version from .python.org/pypi/wheel/ in advance and then feed it to " pip install
")
For Unix, start from the terminal. (python3
)
In the case of Windows, you can start it from the command prompt / powershell if you pass the path, but you cannot use character strings that are not in Shift-JIS such as seagulls.
First is the basic operation.
>>> 1 + 1
2
>>> 2**3
8
>>> 1/2
0.5
>>> 1 % 2
1
>>> 5 % 3
2
>>> 0.5 * 0.25
0.125
Variable settings / use / deletion are as follows.
>>> x = 5
>>> x ** 2
25
>>> del(x)
Then use various functions.
First,
>>> import math as MT
>>> MT.sin(MT.pi * 0.25)
0.7071067811865476
Next, let's ask for 610 !.
Take the common logarithm on both sides of
Substitute $ n = 610 $
If you find 610! As it is, the number of digits will be dangerous, so find it with the coefficient of $ a \ times 10 ^ b \ quad (1 \ leq a <10 \ wedge b \ in \ mathbb {Z}) $.
$610! = a \times 10^b $
Take the common logarithm on both sides of
From $ 0 \ leq \ log_ {10} a <1 \ wedge b \ in \ mathbb {Z} $
That is,
It will be.
Relation:
If you write this down in Python, it will look like this:
>>> val = 0
>>> for i in range(2,611):
val += MT.log10(i)
>>> print("610! = ", 10 ** (val - MT.floor(val)), "×10^", MT.floor(val), sep = "")
610! = 8.382616099017579×10^1435
Wow ~ McDonald's Ripoff ~ (Stick reading)
With numpy and scipy, you can do more advanced things such as matrix and vector operations. (e.g. numpy.array
)
In addition, sympy can transform variable expressions and solve equations. (e.g. sympy.symbols
)
matplotlib can draw graphs. That is, you can take away the work of gnuplot.
Recommended Posts