Skip to main content

Python A New Beginning

A program is a set of instructions to the computer by using different programming languages to perform a set of jobs. This programming language generally contains words and phrases from English languages.

A program written in human-readable form can be called source code which then needs to be converted to machine code to perform the task by the Computer and this conversion is made by Interpreters and Compilers.

Compiler and Python Interpreter?

A compiler is a special program that translates a programming language's source code into machine code whole at once unlike the interpreter.

A piece of software to run a Python code is called a Python interpreter.

The interpreter is a layer of software that works between your program and your computer hardware to get your code running. 

Python codes are first compiled (translates) into equivalent byte code then the installed Python interpreter converts the python byte code into machine-executable code.


What is Machine code?

Machine code or machine understandable code is the base-level form of instructions that can be directly executed by the CPU.

What is a Python script?

A plain text file containing Python code that is intended to be directly executed by the user is usually called a script.

How do you create and run a simple python file in Windows?

It's pretty easy to create a python file in Windows, you can always make a python file like any other file type.

The type of a file is generally recognized by its extension (e.g., .txt, .md..), no exception for python as well. A regular Python file always has *.py extension (e.g., myscript.py, calculator.py), though it's not mandatory to have a file extension but it's one of the best practices. That means a file with *.txt extension can have a Python source code.

Create a folder as you like and create a text file with an extension *.py

I have created a file called demo.py with the content as print("Hello World!")

Your python source code is ready! Pretty cool is, isn't it๐Ÿ˜ƒ

Let's run this code.

Make sure you have downloaded and installed the right Python interpreter for your OS. Python releases for Windows can be downloaded from here.

  1. Locate and copy your newly created python file and get the file path using the properties of the demo.py

    2. Open the Command Prompt using Run, Win + R with cmd then press OK.

    3. cd to the copied location (change your location accordingly), cd C:\shared\sample-codes
    4. Execute your code using python command, e.g., python demo.py

Here we have written the code to display the line Hello World!, and as mentioned in the above screenshot we have got the expected result.

Yes, you have successfully executed your first Python program! Keep coding!

References,

https://realpython.com/

Comments