Mark As Completed Discussion

Variables in Python

In Python, variables can be directly created by providing a variable name and assigning it some corresponding value. The code block below shows the creation of the variable number, which has the value 10.

If we execute this code in a Python interpreter, it will give no output. Why?

Because this is a statement, and this statement did not tell the programming language to display the value of variable number. For that, we'd need to either print() it, or log it out in some other way.

However, it did create a variable number in memory and assigned it the value 10. To check if the value was properly assigned, type either the variable name on the console, or use the print() function. It will display the variable name on the console.

The value that you stored earlier in number is successfully displayed, and we can see that it correctly assigned the value.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment