ඒ අනුව, r%3*c+10/y යන පයිතන් ප්රකාශයේ නිවැරත්ථ අගය කුමක් ද?
(1) 6.2 (2) 8.0 (3) 12.0 (4) 24.0 (5) 40.0
command | name | example | output |
+ | Addition | 4+5 | 9 |
- | Subtraction | 8-5 | 3 |
* | Multiplication | 4*5 | 20 |
/ | Division | 19/3 | 6 |
% | Remainder | 19%3 | 5 |
** | Exponent | 2**4 | 16 |
The order of operations
- parentheses ()
- exponents **
- multiplication *, division \, and remainder %
- addition + and subtraction -
r%3*c+10/y
((r% 3)*c)+(10/y)
((11% 3)*4)+(10/2.5)
(2*4)+(4)
12
All operators
+ - * ** / // %
<< >> & | ^ ~
< > <= >= == !=
100 - 25 * 3 % 4 the result is 97 how?
25*3 = 7575 % 4 = 3 (4*18 = 72; remainder is 3)
100 - 3 = 97
Operator | Description | Example |
---|---|---|
+, - | Addition, Subtraction | 10 -3 |
*, /, % | Multiplication, Division, Modulo | 27 % 7 Result: 6 |
// | Truncation Division (also known as floordivision) The result of the division is truncated to an integer. Works for integers and floating-point numbers as well | 27 % 7 Result: 6 |
+x, -x | Unary minus and Unary plus (Algebraic signs) | -3 |
~x | Bitwise negation | ~3 - 4 Result: -8 |
** | Exponentiation | 10 ** 3 Result: 1000 |
or, and, not | Boolean Or, Boolean And, Boolean Not | (a or b) and c |
in | "Element of" | 1 in [3, 2, 1] |
<, <=, >, >=, !=, == | The usual comparison operators | 2 <= 3 |
|, &, ^ | Bitwise Or, Bitwise And, Bitwise XOR | 6 ^ 3 |
<<, >> | Shift Operatoren | 6 << 3 |
No comments:
Post a Comment