Mayungo's Python Learning Episode 5: I tried to do four arithmetic operations with numbers

Mayungo Mayu Mayu

This time we will calculate the numbers because it is the 5th episode.

The same video is available, so please have a look if you like.

Use "+" when adding on python.

It's the same as when we usually calculate.

print(5 + 2)

7

When I calculated it with 5 + 2, it became 7.

Subtraction also uses "-" as in normal calculations.

print(5 - 2)

3

If you calculate with 5-2, 3 will come out.

It's a little different from multiplication.

Use "*" instead of "x" for multiplication.

print(5 * 2)

10

It is necessary to use them properly in division. First, "/".

print(5 / 2)

2.5

If you try to calculate with this, the decimal point will come out.

the other one is"//".

print(5 // 2)

2

If you do this, you will see integers and no decimals.

Even if the expression is divisible by an integer, it is necessary to use it properly.

Use "%" for the remainder that is not divisible.

print(5 % 2)

1

Use "**" to get a power.

For example, to get the square of 5, write 5 ** 2.

print(5 ** 2)

25

print(5 ** 3)

125

The number that comes after "**", not the number of "*", is the number specified as the power.

Finally, it is the reversal of positive and negative.

Put 114514 in the variable message.

If you add "-" here, the positive and negative will be reversed.

message = 114514
print(-message)

-114514

This time I touched on numerical calculation. Thank you for subscribing to the channel.

Click here for a list of each story.

Recommended Posts

Mayungo's Python Learning Episode 5: I tried to do four arithmetic operations with numbers
Mayungo's Python Learning Episode 3: I tried to print numbers with print
Mayungo's Python Learning Episode 2: I tried to put out characters with variables
Mayungo's Python Learning Episode 1: I tried printing with print
Mayungo's Python Learning Episode 8: I tried input
Mayungo's Python Learning Episode 7: I tried printing with if, elif, else
Mayungo's Python Learning Episode 6: I tried to convert a character string to a number
Mayungo's Python Learning Episode 4: I tried to see what happens when numbers are treated as letters
I tried to create a list of prime numbers with python
I tried to create a program to convert hexadecimal numbers to decimal numbers with python
I tried to learn logical operations with TF Learn
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
I tried to automate sushi making with python
I tried to automate internal operations with Docker, Python and Twitter API + bonus
I tried to move machine learning (ObjectDetection) with TouchDesigner
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to solve the soma cube with python
I tried to get started with blender python script_Part 02
I tried to implement an artificial perceptron with python
I tried to automatically generate a password with Python3
[ML Ops] I want to do multi-project with Python
I tried to solve the problem with Python Vol.1
I tried to analyze J League data with Python
I tried to summarize the string operations of Python
I tried to solve AOJ's number theory with Python
I tried fp-growth with python
I tried scraping with Python
I tried to make a real-time sound source separation mock with Python machine learning
Four arithmetic operations in python
I tried gRPC with Python
I tried scraping with python
I tried to build an environment for machine learning with Python (Mac OS X)
I tried to find the entropy of the image with python
I tried to simulate how the infection spreads with Python
I tried various methods to send Japanese mail with Python
[Python] I tried to visualize tweets about Corona with WordCloud
I tried to implement ListNet of rank learning with Chainer
I tried to make GUI tic-tac-toe with Python and Tkinter
I tried to divide the file into folders with Python
I tried to divide with a deep learning language model
I tried to touch Python (installation)
I tried machine learning with liblinear
I tried web scraping with python.
To do tail recursion with Python2
What to do with PYTHON release?
I want to do ○○ with Pandas
I want to debug with Python
I tried running prolog with python 3.8.2.
I tried SMTP communication with Python
I tried learning LightGBM with Yellowbrick
[5th] I tried to make a certain authenticator-like tool with python
I tried to solve the ant book beginner's edition with python
[2nd] I tried to make a certain authenticator-like tool with python
[3rd] I tried to make a certain authenticator-like tool with python
[Python] A memo that I tried to get started with asyncio
I want to do a full text search with elasticsearch + python
[Pandas] I tried to analyze sales data with Python [For beginners]