You can easily perform calculations with variables in Python. Here's an example:
main.py58 chars5 lines
In this example, we create two variables s
and p
, and assign them the values 5 and 10 respectively. We then add the two variables together to get the result, which we store in another variable called result
. Finally, we print the result to the screen using the print()
function.
You can perform other arithmetic operations, such as subtraction (-), multiplication (*), and division (/), using variables in the same way. For example:
main.py58 chars5 lines
This performs a multiplication operation on s
and p
, and stores the result in result
. We then print result
to the screen, which outputs 50
.
gistlibby LogSnag