Python is a simple, modern language for writing code. It has powerful libraries that can evaluate any expression. Python is the main competitor for Matlab and Octave. By launching Python interactively, the remainder of the division can be easily found by the user. But that is not all! Python can be a powerful calculator.
Operator concept
To easily find the remainder of a division in Python, you need to deal with some definitions. Operator - a sign or line that allows you to perform mathematical, bitwise, logical and other calculations. Expressions or numbers entered by the user to find the remainder of division in Python 3, the identity of a combination or comparison, are called operands.
The following types of operators are divided:
- arithmetic;
- bitwise;
- brain teaser;
- assignment operators;
- comparisons
- membership
- .
, "15 - 5" «–», – 15 5. . «True and True», «and», – "True" "True". .
.
, +, -, *, /, **, //, %. . , , , , . «**» .
(/) (//) . , . , 9 // 4 = 2. div Turbo Pascal. . «/» , , – . Python , «%». " " «%» mod. , 9%2 = 1, .. Python 1. .
, Python divmod(,). – , – . divmod (9,3) (3,0). , 3, – 0.
. . , print.
math
math, .
, : import math. , math. . , x = math.ceil(5.6).
, . , . : from math import ceil from math import *. .
Python
Python , math. .
| | |
int(x) | , .. «». | int(5.3) >>> 5 int(5.6) >>>5 int(5.987) >>> 5 |
round(x) | . | round(5.4) >>>5.0 round(5.7) >>>6.0 round(5.5) >>>6.0 round(5.987) >>>6.0 |
round(x, n) | n | round(5.8776,2) >>> 5.88 round(5.9876,3) >>> 5.988 |
abs(x) | | abs(-7) >>>7 abs(7.8) >>>7.8 abs(-66.55) >>>66.55 |
, ( from math import *), .
| |
ceil(x) | («») |
floor(x) | , («») |
sqrt(x) | |
log(x) | . , . |
e | |
sin(x) | , |
cos(x) |
tan(x) |
asin(x) |
acos(x) |
atan(x) |
atan2(x,y) | , |
degrees(x) | |
radians(x) | , , , |
pi | π |
.
.
math . .