Python 101 (part 1): Snake Eyes - Adding Things Up (
Page 6 of 6 )
Here's another program, this
one performing an arithmetic operation on a variable and displaying the result.
>>> num1 = 10
>>> num2 = 5
>>> num3 = num1 + num2
>>> num3
15
>>>
Note that Python also allows you to display the value of a variable (in the command
line interpreter only) by stating the variable name without a preceding print()
function call.
Finally, Python also allows you to simultaneously assign a value to multiple
variables - check it out.
>>> huey = dewey = louie = 75
>>> dewey
75
>>> louie
75
>>>
And that's about it for this introduction to Python. In this article, I've provided
a brief history of Python, and explained some of the features which make it so
popular among discerning developers. I've also discussed the two methods available
to run a Python program, demonstrated the print() function, and offered some insight
into the rules governing Python variables.
In the next article, I'll be delving deeper into Python's data structures and
built-in objects - numbers and - together with a closer look at the various arithmetic
and comparison operators. See you then!