Expressions¶
Evaluate manually the following expressions. Then type them in a Python shell and check the result.
Division
15/3 15//3 17/3 17//3 17%3 -17//3 -17%3 17/-3 -17/-3
Priority rules
3*4+2 (3*4)+2 3*(4+2) 7+2**3 7+(2**3) (7+2)**3 2**2**3 2**(2**3) (2**2)**3
Boolean expressions
2 > 4 or 2 > 1 2 > 4 and 2 > 1 2 < 4 and not(3 > 5 or 7 < 8)
Expressions with strings
'How' + ' are ' + 'you ?' 'Fine '*3 'I have '+ str(3) + ' sisters.'
Write the following mathematical expressions using the Python syntax (use the minimum number of parenthesis):
\(\frac{x+2y-1}{z}\)
\(\frac{4x}{2y+3z}\)
\(\frac{5xy}{2z}\)
\(\frac{x}{4yz}\)
\(\frac{x^5}{3} + \frac{(2x-1)^3}{6} + \frac{x}{12} + 1\)
\(\frac{y^3 \tan x}{cos(y^2)-3}\)
\(\frac{|8x-4y|}{\sqrt{x^2+cos(y)+4}}\)
You can find the solution in file
expressions.py