To add two numbers in Python, you can simply use the + operator. Here's an example:
main.py35 chars5 lines
Output:
main.py2 chars2 lines
In the code above, we declare two variables a
and b
that store the values we want to add. We then use the "+" operator to add them together and store the result in a variable called sum
. Finally, we print out the value of sum
, which in this case is 8
.
gistlibby LogSnag