Python by Swaroop C H - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

How It Works

Here's how this program works. First, we assign the literal constant value 5 to the variablei using the assignment operator (=). This line is called a statement because it states that something should be done and in this case, we connect the variable namei to the value5. Next, we print the value ofi using the print statement which, unsurprisingly, just prints the value of the variable to the screen.

The we add1 to the value stored ini and store it back. We then print it and expectedly, we get the value 6.

 

Similarly, we assign the literal string to the variables and then print it.

Note for C/C++ Programmers

Variables are used by just assigning them a value. No declaration or data type definition is needed/used.