Hey there! In this post I'll be talking about getting a Python code running on your machine. If you're a Mac user, you don't have to install Python. You'll most likely find Python 2.7 already installed on your machine.
To check if Python is installed you can make use of the which command or the --version command as given below -
Once you're sure Python is installed on your machine, just create a new text file (in textEdit or notepad) and type the following code inside it.
print "Hello World"
Then save the file on your desktop with the name hello.py. Now open your terminal and navigate to desktop using the cd command (cd stands for change directory).
And finally to execute the program type python followed by file name. In this case the command would be python hello.py.
To check if Python is installed you can make use of the which command or the --version command as given below -
Once you're sure Python is installed on your machine, just create a new text file (in textEdit or notepad) and type the following code inside it.
print "Hello World"
Then save the file on your desktop with the name hello.py. Now open your terminal and navigate to desktop using the cd command (cd stands for change directory).
And finally to execute the program type python followed by file name. In this case the command would be python hello.py.
And you've successfully executed your first Python Program called Hello World.


No comments:
Post a Comment