> py test.py
| b = 1 + 3x-5n |
Ans: a = (x + 2 * y) / (x - 3 * y) b = 1 + 3 * x ** (3 * n)
x = 3 y = 5 n = 2 a = (x + 2 * y) / (x - 3 * y) b = 1 + 3 * x ** (-5 * n) print("Output:", round(a, 4), round(b, 6)) # Output: Output: -1.0833 1.000051
P3 5 5 255 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 255 128 0 255 128 0 255 128 0 128 128 128 128 128 128 255 128 0 0 128 128 255 128 0 128 128 128 128 128 128 255 128 0 255 128 0 255 128 0 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128The header line P3 5 5 255 indicates the following:
P3: Portable Pixel Map (ppm) 5: Image is 5 pixels wide 5: Image is 5 pixels high 255: Component value range is 0 to 255.Pixels contain red, green, and blue components.
Operator | Meaning |
---|---|
+ | Addition Concatenation |
- | Subtraction |
* | Multiplication Addition |
/ | Floating Point Division |
// | Integer Point Division |
** | Exponentiation |
% | Remainder from Floating Point Division |
= | Assignment |
n = 3 * 5This statement assigns the value on the right, which is 3 * 5 = 15 to the variable n.
< <= > >= == != and or not
a = 5 b = 7 a = 3 print(a, b) Ans: Variable Trace: a b -----+----- 5 | 7 3 | Output: 3 7The latest value of a variable is always the one used. This is why a 3 is printed for a instead of 5
# Trace1 Exampl # Perform variable trace and predict output. a = 3 b = 7 c = 5 a = 2 * a + 2 * b + c b = a + c c = 2 * c + 1 a = a + 2 b = b + 3 c = c + 4 Variable Trace: a b c -----+-----+----- 3 7 5 25 30 11 a = 2 * a + 2 * b + c 27 33 15 = 2 * 3 + 2 * 7 + 5 # Output: = 6 + 14 + 5 Output: 27 33 15 = 25