DEV Community

Cover image for Basic Python for Beginners
Vadim Kolobanov for Abstract

Posted on • Updated on • Originally published at dev.to

Basic Python for Beginners

A few words about python

Python is a very popular programming language at the moment, and its popularity is only growing over time. It has found its application in many areas of software development.

Let's look at the main characteristics of Python as a programming language:

  • High-level.
  • General purpose.
  • Interpreted.
  • Object-oriented.
  • Imperative.
  • Strictly (strongly) typed.
  • It has dynamic typing.

Let's look at this in more detail

High-level

Programming languages are divided into high-level and low-level. Low-level languages are languages that are close to programming in machine code or structures close to them (for example, byte codes). Classics of low-level programming: Assembler.

High-level languages are designed accordingly for ease of use and speed of program writing. They use certain abstractions - data structures, a certain set of auxiliary functions, etc. These are almost all the languages you know.

It is worth noting that high-level languages are heterogeneous. Some, such as Python, completely free the programmer from direct use of computer resources, others, such as C, allow you to work directly with memory and even use assembler inserts.

General purpose.

Languages are divided into general-purpose languages (Python, C, Pascal) and specialized (DSL) (SQL, HTML).

Interpreted

Languages are divided into interpreted (Python, Basic) and compiled (C, Pascal). In the first case, the program is executed by a special interpreter program, "on the fly", in the second, the program is first converted into executable files understandable to the computer.

It is worth noting that in fact, many modern "interpreted languages" are actually intermediate representation languages that first distill our program into special "byte codes" understandable to the interpreter, after which he interprets them. Python, Java, and many others are just such languages.

Object-oriented.

Languages are divided into procedural, functional, and object-oriented languages, depending on which structures the program is structured with and how the problem is solved.

In object-oriented languages, we work with classes as types and instances of classes as objects of this type. Problem-solving is based on the interaction of different classes.

Nevertheless, Python, being an object-oriented language, supports both procedural programming and a program that can be written without a single class.

Functional languages are based on a different computing system from the previous ones, called lambda calculus.

Imperative

Languages are divided into imperative - when we set a sequence of commands to perform a task, and declarative - when we describe the result we want to get (SQL).

Strictly (strongly) typed.

Strongly typed languages assume that the interpreter will not implicitly cast types when trying to execute a command. (Java, Python, Haskell, Lisp) Implicit-type conversions can occur in weakly typed languages. (C, JavaScript, Visual Basic, PHP.)

Dynamic typing

Dynamic typing assumes that during the execution of a command, a variable can contain objects of various types.

Static typing assumes that when setting a variable, the data type that it can contain is immediately indicated.

Python Features

  • There are many features in the standard library.
  • Introspection.
  • Automatic memory management.
  • Multiplatform.
  • Design patterns.
  • Usability
  • Readability - part of the syntax is a formatting
  • Interactive language

Basic concepts

A variable is a named memory area whose name can be used to access data. The object (in Python everything is an object) referenced by a variable is called the value of the variable.

Variable assignment (assignment) is the process of specifying an object variable to which it will refer. In Python, assignment is performed using =

An operator or instruction is the smallest part of a programming language. This is a command or a set of commands that can be executed by an executor. The objects on which operators perform actions are called operands. Depending on their number, the operators are divided into:

  • Unary (-1 is a unary minus).
  • Binary (1 + 2 - addition).
  • Ternary
[on_true] if [expression or condition] else [on_false]
Enter fullscreen mode Exit fullscreen mode
  • Expression is a set of variables, operators, and functions that can be evaluated according to the syntax of the language.

Data Types in Python

All data types built into Python are divided into:

  • Immutable - numbers, strings, tuples, boolean.
  • Mutable - dictionaries, lists, sets, and virtually all other types.

There are 3 types of numbers in Python:

  • Integers (int).
  • Decimal numbers (float).
  • Complex numbers are a pair of integers, the first of which is called the real part, and the second is called the imaginary part.

Operations performed on numbers:

"+" is the addition of two numbers.
"-" - subtraction.
" * " - multiplication.
" ** " - exponentiation.
"/" - true division.
"//" - quotient.
"%" is the remainder of the division.
" - " - unary minus.
"abs" are the number module.

Additional information

PEP - Python Enhancement Proposals.

PEP-8 is a set of rules on how to write code.

PEP-257 standard flow for docstrings

Python is not named after a snake

Python creator - Guido van Rossum
and he named his language after the Monty Python troupe.

Good Luck!

Write me on Face....oh...Meta

My Twitter

Become a patron

Top comments (4)

Collapse
 
foxy4096 profile image
Foxy4096

Neat and nice post, btw what does DSL means?

Collapse
 
vadimkolobanov profile image
Vadim Kolobanov

Oh, I'll be happy to explain to you)

Domain-Specific Language(DSL) is a programming or modeling language created for use within a specific subject area if we speak the language of terms))))

With such you meet languages almost every day: SQL, shell scripts, user interface description languages (read HTML) are all examples of domain-specific languages, since they were created to solve certain tasks, work in some specific subject area.

To put it even simpler, DSL is the language of a specific sphere. You won't be able to make a project on it, but you need it to make the project work. I have given good examples for you: HTML, SQL, shell commands)))

Collapse
 
rodrygors profile image
Rodrigo Silva

You have an error on the number operators part, "" for multiplication and "*" for exponentiation.
Great article otherwise!

Collapse
 
vadimkolobanov profile image
Vadim Kolobanov

Thank you very much) I have to work through a translator and it is difficult to track errors in the finished version)