As per addition on my previous post on Python Basic Programming, I want to add how to download and install Python, running it, and create basic Python program.
Download and Install Python
You can visit official Python website, https://www.python.org/. The latest version, as per October 2018 is Python 3.7.1rc2 and I think it is advisable to start learning using latest version to avoid any problems with older, legacy version.
Python officially release version on many platforms, like Windows, Linux, Mac OS, and iOS.
Run IDLE (Integrated Development and Learning Environment) Python
With this IDLE, let's start writing Python program :
print("Welcome to Python for Beginner!")
print("My name is Anityo")
The picture above also show the result of your file if you using IDLE.
Another way to open is using command prompt as follow :
Executing Python on Command Line
Other than using IDLE shell and editor window to create and run the programs that we write, we can use text editor to code our Python's program before running it on the command line.
I will try using Notepad and try to coding as follow :
Save the file into any folder of your computer with extension .py
To run that file, you can use command prompt and type the filename as follow :
Download and Install Python
You can visit official Python website, https://www.python.org/. The latest version, as per October 2018 is Python 3.7.1rc2 and I think it is advisable to start learning using latest version to avoid any problems with older, legacy version.
Python officially release version on many platforms, like Windows, Linux, Mac OS, and iOS.
Run IDLE (Integrated Development and Learning Environment) Python
With this IDLE, let's start writing Python program :
- Click File, then New File. We can also press Ctrl+N.
- A blank editor window will open. That is for us write the code.
- Enter the following commands on separate lines :
print("Welcome to Python for Beginner!")
print("My name is Anityo")
- To save file, click File, then Save, or press Ctrl+S
- On Save As window, type Hello as the file name and then click Save.
- Herewith the result :
The picture above also show the result of your file if you using IDLE.
Another way to open is using command prompt as follow :
Working in Interactive Mode using IDLE
Python can processes the code you entered in the shell window.
Let's try some commands :
1. Run IDLE and on the >>, enter the following command :
print("My name is Anityo")
press Enter, this will print My name is Anityo on the next line.
2. Let's try other commands :
Enter 3+5, then press Enter and the result will appear on next line
Enter 256*1.5/1024+4096-0.384 and press Enter.
3. Enter the following command with press Enter after each line
x=10
print(x)
The answer 10 will appear on the next line
4. Enter the following command :
name="Anityo"
print(name)
The answer Anityo will appear on the next line.
5. Enter print(x) once more and value 10 will appear as we defined x from before.
herewith the result :
To clear the IDLE, we can use this way :
Click Shell, then Restart Shell, or by pressing Ctrl+F6
Executing Python on Command Line
Other than using IDLE shell and editor window to create and run the programs that we write, we can use text editor to code our Python's program before running it on the command line.
I will try using Notepad and try to coding as follow :
Save the file into any folder of your computer with extension .py
To run that file, you can use command prompt and type the filename as follow :
Comments
Post a Comment