avatarSamer Sallam

Summary

This article serves as an introductory guide to Python programming concepts, specifically focusing on variables, data structures, and operators, as part of a comprehensive Python Complete Beginner to Expert Course.

Abstract

The article introduces readers to the fundamental aspects of Python programming, emphasizing the use of variables to store data of various types, the organization and management of data through different data structures, and the application of operators to manipulate data. It highlights Python's dynamic typing system, which contrasts with statically typed languages like Java, and outlines the six primary data structures supported by Python, including both single-item (e.g., numbers) and multi-item (e.g., strings, lists, tuples, dictionaries, and sets) types. The piece also explains the role of operators in performing operations on data and details the importance of understanding operator characteristics such as the number of operands, their data types, the operation they perform, and the type of result they produce. The article is part of a larger series, with links provided for previous and subsequent parts, and encourages reader engagement through subscriptions and Medium membership.

Opinions

  • The author suggests that understanding variables, data structures, and operators is crucial for Python programming, indicating a foundational approach to learning the language.
  • Python's dynamic data typing is presented as a user-friendly feature that simplifies the programming process by automatically allocating memory based on the value's data type.
  • The article implies that familiarity with tuples and lists is important, foreshadowing future in-depth coverage of these data structures in the series.
  • The author expresses enthusiasm for teaching these concepts, as indicated by the use of emojis and encouragement for readers to subscribe and follow for more content.
  • The mention of writers earning on Medium suggests the author's view of the platform as a viable avenue for both learning and potentially earning through writing about technical subjects like Python programming.

Introduction to Variables, Data Structures and Operators: Python Complete Course — Part 10

https://www.hitalent.co/blog/2019/12/tech-jobs-python-programming-language-and-aws-skills-demand-has-exploded

Before we start let me tell you that:

  • This article is a part of Python Complete Beginner to Expert Course which you can find it here.
  • This article is also available as a YouTube video here.

Introduction

After you have learned how to identify variables in Python, and how to add comments to your code. Now, it is time to learn what are the supported data types in Python and how to deal with them.

So this article will cover the following outlines:

  1. Variables
  2. Data Structures
  3. Available Data Structures in Python
  4. Operators
  5. Operators Details

1. Variables

A variable is a reserved location in the memory to store values, and the value could be one of any type like integer, float, string, or any other supported data structure in Python.

Photo by Fredy Jacob on Unsplash

You should know that Python is a dynamic data type, which means based on the data type of the value, the interpreter allocates the required memory space, and there is no need for an explicit declaration of the variable data type. Furthermore, it is different from other programming languages like Java, for example, in which you have to explicitly specify the variable data type.

Image By Author

In addition to, keep in your mind that you have to use the equal sign (=) to assign a value to a variable and according to this value, the interpreter will understand the type of that variable.

Now let us talk about data structures.

2. Data Structures

It is a special variable format defining how to deal with the variable itself. In other words, how to organize, process, retrieve and store data inside the variable. In Python, like any other programming language data structure is designed to arrange data to suit a specific purpose. For example,

  • If you want a data structure to define a collection of ordered items, you have to use a list.
  • If you want to make your data structure a read-only memory, you have to use a tuple.

Don’t worry if you are not familiar with tuple and list right now, you are going to learn in details about these two data structures in the future articles.😊

For each data structure, there is a set of operators defined to process that data structure, and one operator could be common between multiple data structures, and for each one of these data structures, it could have a different job. So, what are the data structures available in Python?

3. Available Data Structures in Python

Python mainly supports six major data structures divided into two main categories:

  • Single-item data structures: when a variable of these data structures is defined, it should have only one item like a Number.
  • Multi-item data structures: they are also known as Collections in Python like strings, lists, tuples, dictionaries, and sets. All of these data structures might have more than one item, Refer to Figure 1.
Figure 1: Supported data structures in Python (Image By Author)

Now, let us move on and talk about operators.

https://unsplash.com/photos/JLW-T4LiJCw

4. Operators

An operator is a construct, represented by a symbol, which processes the value of operands to produce the final result.

For example, consider the following expression:

Image By Author

In this expression, 4 and 5 are operands, whereas the (+) sign is an operator. The operator's job here is to add 4 to 5, and the final result is 9.

5. Operator Details:

For each operator, you have to know some details like:

  1. The number of operands: how many operands you have to pass to this operator, in order to work properly.
  2. The data types of the operands: the data type for each operand. Where you will get an error if you pass a different data type than the expected one.
  3. How this operator works: for example, one operator adds one number to another, one operator subtracts one number from another, and so on.
  4. The Final result data type: once the operator works, it will give you a result. Therefore, you have to know the data type of this result.

Now, let us summarize what we have learned in this article:

Photo by Ann H on pexels

In this article you have learned:

  • Variable is a reserved location in the memory to store values.
  • Data structure is a variable format that organize, process, retrieve and store data inside the variable.
  • Python supports multiple data structures, and these data structures are divided into Single-Item data structures and Multi-Item data structure.
  • Single-Item data structures: numbers.
  • Multi-Item data structures: strings, lists, tuples, dictionaries, and stets.
  • Operator is a construct represented by a (symbol) to process the operands.
  • Operator details: number of operands, the data types of the operands, how this operator works, and the final result data type.

P.S.: A million thanks for your time reading my story. Before you leave let me mention quickly two points:

  • First, to get my posts in your inbox directly, would you please subscribe here, and you can follow me here.
  • Second, writers made thousands of $$ on Medium. To get unlimited access to Medium stories and start earning, sign up now for Medium membership which only costs $5 per month. By signing up with this link, you can directly support me at no extra cost to you.

To get back to the previous article, you can use the following link:

Part 9:Comments in Python

To move on to the next article, you can use the following link:

Part 11:Python Numbers

Python
Programming
Variables
Data Structures
Operators
Recommended from ReadMedium