Getting Started with python3 # 3 Try Advanced Computations Using Import Statements

Hi, my name is beatbox4108. This time, I would like to write about advanced calculation using __import statement __.

What is the import statement in the first place?

You can use the __import statement __ to execute other python files (.py .pyw).

Import statement type

ʻImport module name: You can refer to it in a python file as module name. ʻImport module name as reference name: You can refer to it in a python file as a reference name. from module name import function name: Imports the specified function. from module name import *: Import all functions in module name.

Do advanced calculations immediately.

There is a math module in the python standard library, so I would like to import it and use it. Please write like this.

main.py


import math as m
print("Pi:",m.pi)#3.141592653589793
print("3.Round up 5:",m.ceil(3.5))#4
print("3.Devaluation of 5:",m.floor(3.5))#3
print("3 to the 5th power:",m.pow(3,5))#243.0(The power of the math module is returned as a float type. Built-in pow function,**You can also use operators.)
print("Make 180 degrees radians:",m.radians(180))#3.141592653589793
print("180 radians at an angle:",m.degrees(3.141592653589793))#180.0
print("sin 100:",m.sin(100),",cos 100:",m.cos(100),",tan 100",m.tan(100))
#sin 100: -0.5063656411097588 ,cos 100: 0.8623188722876839 ,tan 100 -0.5872139151569291
print("Square root of 9",m.sqrt(9))#3

... you can do it well. Next, I haven't posted the table of arithmetic operators even once, so I'd like to post it.

Table of arithmetic operators

operator function Example Description
+(Unary plus operator) Positive number +x Specify a positive number. It does not change even if a code is added.
-(Unary minus operator) Sign inversion -x Invert the sign of the value of a.
+ addition x + y Add y to x.
- subtraction x - y Subtract y from x.
* multiplication x * y Multiply x by y.
/ division x / y Divide x by y.
// Integer division(If the expression contains a decimal number, it can be of type float.) x // y Truncate the decimal from the result of dividing x by y.
** multiplier x**y Find x to the yth power.
% Surplus x % y Find the remainder of x divided by y

This time, I would like to end with this. Stay tuned for the next time! Go to Table of Contents

Recommended Posts

Getting Started with python3 # 3 Try Advanced Computations Using Import Statements
1.1 Getting Started with Python
Getting Started with Python
Getting Started with Python
Getting Started with Python Functions
Getting Started with Python Django (1)
Getting Started with Python Django (4)
Getting Started with Python Django (3)
Getting Started with Python Django (6)
Python3 | Getting Started with numpy
Getting Started with Python Django (5)
Getting Started with Python Web Applications
Getting Started with Python for PHPer-Classes
Getting Started with Python Basics of Python
Getting Started with Python Genetic Algorithms
Getting started with Python 3.8 on Windows
Getting Started with Python for PHPer-Functions
Try mathematical formulas using Σ with python
Getting Started with Python Web Scraping Practice
Try using Python with Google Cloud Functions
Getting Started with Python for PHPer-Super Basics
Getting Started with Python Web Scraping Practice
Getting started with Dynamo from Python boto
Getting started with Python with 100 knocks on language processing
[Translation] Getting Started with Rust for Python Programmers
Getting started with AWS IoT easily in Python
Getting Started with Python's ast Module (Using NodeVisitor)
Materials to read when getting started with Python
Settings for getting started with MongoDB in python
Django 1.11 started with Python3.6
Try scraping with Python.
Getting started with Android!
Getting Started with Golang 2
Getting started with apache2
Getting Started with Golang 1
Getting Started with Django 1
Getting Started with Optimization
Getting Started with Golang 3
Getting Started with Numpy
Getting started with Spark
Import tsv with Python
Getting Started with Pydantic
Getting Started with Golang 4
Try using Tweepy [Python2.7]
Getting Started with Jython
Getting Started with Django 2
Try projective transformation of images using OpenCV with Python
Getting Started with Google App Engine for Python & PHP
Translate Getting Started With TensorFlow
Getting Started with Tkinter 2: Buttons
Try using PythonTex with Texpad.
Getting Started with Go Assembly
[S3] CRUD with S3 using Python [Python]
[Python] Try using Tkinter's canvas
Getting Started with PKI with Golang ―― 4
Import vtk with brew python
Using Quaternion with Python ~ numpy-quaternion ~
Try using matplotlib with PyCharm
Try Python output with Haxe 3.2
Try using Kubernetes Client -Python-
[Python] Using OpenCV with Python (Basic)