What is the output of this code snippet?
[python]
x = 50*2 + (60-20)/4
print(x)
[/python]
The Python interpreter is a powerful tool. In this puzzle, it acts as a simple calculator. It takes a basic mathematical expression and calculates the result.
The syntax of maths expressions is straightforward: use the operators +, -, * and / exactly as you have learned them in school. The Python interpreter will handle basic rules such as multiplication before addition for you.
Note that a common mistake here is that people write the result as an integer rather than as a float. This can lead to difficult bugs in the code in a dynamically typed language such as Python. A dynamically typed language assigns the type of a variable at runtime and not at compile time like Java.
Are you a master coder?
Test your skills now!
Related Video
Solution
110.0