DEV Community

Saravanan Cn
Saravanan Cn

Posted on

Python for Beginners: What Is Python? A Complete Introduction 🐍

1. What Is Python?

  • Python is a high-level, general-purpose programming language known for its simple syntax and readability.
  • It was created by Guido van Rossum and first released in 1991.
  • Python allows developers to write programs using code that is relatively easy for humans to read and understand.

Example:

`print("Hello, World!")

Output:

Hello, World!

The print() function displays the text on the screen.`

Where is Python used?

Python is used in many fields, including:

Web development: Building websites and web applications.

Artificial intelligence: Developing AI applications and machine learning models.

Data science: Analyzing and visualizing data.

**Automation: **Automating repetitive tasks.

Scientific computing: Performing mathematical and scientific calculations.

Software development: Building different kinds of applications.

2. Difference Between Python and Python 3

Python is the name of the programming language. Python 3 is the modern major version of Python.

Python 2 and Python 3 are different major versions. Python 2 reached the end of its official support on January 1, 2020.

Important: Python 3 is the recommended version for beginners and new projects.

3. High-Level vs. Low-Level Programming Languages

Programming languages can be described by how closely they relate to human-readable concepts or the computer's hardware.

High-level programming language

A high-level language uses syntax and concepts that are relatively easy for humans to understand. It hides many hardware details.

Examples:

  • Python
  • Java
  • JavaScript

Example:

`a = 10
b = 20

print(a + b)`

Python lets us add two numbers without manually managing the computer's registers or memory addresses.

Low-level programming language

A low-level language is closer to the computer's hardware and instruction set.

Examples:

Machine code

Assembly language

Low-level programming can offer detailed control over hardware, but it generally requires more knowledge of the underlying computer architecture.

4. Programming Language vs. Scripting Language

  • A scripting language is commonly used to automate tasks, control other programs, or execute sequences of instructions.
  • Examples of languages commonly used for scripting include Python, JavaScript, and Bash.
  • Programming language
  • Programming languages can be used to build software, applications, operating systems, and many other systems.
  • Scripting language
  • Scripting is often focused on automation and connecting existing tools or components. For example, a Python script could automatically rename hundreds of files instead of requiring you to rename each file manually.

for number in range(1, 6):
print("Learning Python", number)

Output:

Learning Python 1
Learning Python 2
Learning Python 3
Learning Python 4
Learning Python 5

Is Python a programming language or a scripting language?

Python is both.

It is a general-purpose programming language that is also widely used for scripting and automation. The distinction is mainly about how a language is used, rather than a strict technical division between two types of languages.

5. Compiled Language vs. Interpreted Language

Programs written in different languages need to be translated or executed in a form the computer can process.

Compiled languages

  • A compiler translates source code into another form, often machine code or an intermediate representation, before the program runs.
  • Examples include C and C++, which are commonly compiled to native machine code. ** Interpreted languages ** An interpreter executes a program by processing its instructions at runtime. Some implementations interpret source code directly, while others use intermediate forms.

Python is commonly described as an interpreted language.

In the standard Python implementation, CPython, source code is generally compiled into bytecode, which the Python virtual machine executes.

Main differences

Compiled approach

  • Often translates code before execution
  • Can produce a standalone native executable
  • C and C++ are common examples
  • Errors may be detected during compilation or execution

Interpreted approach

  • Often processes code during execution
  • May require a runtime or interpreter
  • Python is a common example
  • Errors may be detected during execution

6. Disadvantages of Python

Python is useful, but it also has some limitations.

1. Slower execution speed

Python can be slower than compiled languages such as C and C++ for CPU-intensive tasks because of its runtime overhead.

2. Higher memory usage

Some Python programs use more memory than comparable programs written in lower-level languages. This can matter for memory-constrained applications.

3. Not always ideal for mobile development

Python is not as commonly used as languages such as Kotlin or Swift for developing native Android and iOS applications.

4. Runtime errors

Because Python is dynamically typed, some type-related errors may only become apparent when the relevant code runs.

5. Global Interpreter Lock in CPython

In standard GIL-enabled CPython builds, the Global Interpreter Lock (GIL) limits how multiple threads execute Python bytecode at the same time. This can affect CPU-bound multithreaded programs, although multiprocessing, native extensions, and free-threaded Python builds provide alternatives.

6. Not ideal for every application

Python may not be the best choice for every real-time, hardware-constrained, or performance-critical application.

Despite these limitations, Python remains a popular and powerful languages for beginners and experienced developers alike.

Top comments (0)