Writing your first code in Python
Today we are going to see about Writing your first code in Python
In case if you have missed our previous topics
Watch in youtube: https://youtu.be/Mj6HSMLvikc
Writing your first Python code
Where to write?
You can use any Notepad or Text editor for writing your Python program. But there are May IDEs available to help us with auto fill the code snippet or help us with formatting the code and check for any syntax errors.
But today we are going to write our first code, So lets use simple notepad or text editor.
Your first Python program
# This is my first Python code # To print Hello world in the console print("Hello World")
Save the above file in any folder with the name helloworld.py
.py is the file extension used to identify the file is Python script
Well you have now officially a Python developer, because you have written your first python code.
How to execute the Python program?
In order to execute the python program, we need Python Interpreter which will do the magic.
What is that magic?
Its the Interpretation of simple English into 0’s and 1’s, Yes the Python Interpreter is going to read your code and convert into 0’s and 1’s so that machine can understand the instructions.
To execute the Python code,
- You need to open Terminal or Command prompt in your Machine.
- Type “python3 filename.py” (In our case, “python3 helloworld.py”
- Hit Enter, you should see the output in the console.
Got into issue while running the program?
Goto this link https://youtu.be/Mj6HSMLvikc and comment the error message. We will have a loot at what went wrong and why the error appeared.
