Python (Variable, Condition, Expression and Functions)
We all have already gone through from the Python Language Introduction, where we have seen a lot of basic things from it.
Now lets begin with some concepts regarding Python to write some codes.
Running your First Code in Python :
Python programs are not compiled, rather they are interpreted. Now, let us move to writing a python code and running it.
Making a Python file :
Python files are stored with the extension “.py”. Open text editor and save a file with the name “hello.py”. Open it and write the following code:
print ("hello world")
# no semi-colon is to be used
output :
hello world
If you are using linux OS then
Reading the file contents:
Linux System – Move to the directory from terminal where the created file (hello.py) is stored by using the ‘cd’ command, and then type the following in the terminal :
python hello.py
Windows system – Open command prompt and move to the directory where the file is stored by using the ‘cd’ command and then run the file by writing the file name as command.
Variables in Python :
Variables need not be declared first in python. They can be used directly. Variables in python are case sensitive as most of the other programming languages.You have to be careful with the upper and lower characters you are using for declaring the variables.
Example:
In this article i have explained a brief details of Variables related to Python.
0 Comments
If you have any doubt, Please let me know.