Python Fundamentals: The Building Blocks of Python Language.
Photo by Markus Spiske: https://www.pexels.com/photo/green-and-brown-wooden-blocks-105855/

Python Fundamentals: The Building Blocks of Python Language.

Python fundamentals are the building blocks of Python language. To understand Python language, is to master the fundamentals. Whatever career path that you decide to take with Python, you will only be successful if you master these building blocks of Python language. In this article we are going to go over the main fundamentals of Python language that you need to master.

Python Data types

The data in Python is classified into categories. It is important to understand the different categorization of data types, because different data types can do different things. Here are the main data types in Python:

  • Numeric - The three different number data types in Python are integers, floats, and complex number. Integers are numbers without decimal places. Floats are any number with a decimal point. Complex numbers are a mixture of real and imaginary parts
  • Strings - Any data type enclosed in quotation marks is classified as a string. The quotation can be single, double, or triple.
  • Lists - A data structure that stores data in square brackets [ ] is called a list. Certain operations such as slicing can be performed on lists because they are ordered.
  • Sets - Sets are enclosed in {} brackets and are not ordered. Therefore, you cannot perform slicing on a set. Sets are mutable.
  • Tuple - Tuples are enclosed in round brackets( ) and are immutable. Tuples are ordered
  • Frozen sets - Frozen sets are a type of sets; but unlike normal sets, frozen sets are immutable.
  • Dict - This is what is called a mapping data type in Python. It is enclosed in {} curly brackets. Dicts have key-value pairs. Every key is mapped to a value.
  • Boolean - This is a data type that represent two values, True or False.

Loops and Conditional

Loops are used to iterate over a sequence (strings, sets, tuples etc) in Python. There are two types of loops in Python, for loops and while loops. A for loop iterates over a sequence. A while loop will iterate over a block of code as long as the condition evaluates to True.

Conditional statements in Python (popularly known as if, elif, else statements) are what is known as control structure in Python. When you want to execute a statement only when a condition is true, you use conditional statements.

Functions

A function is a block of code that does something. In Python function start with the keyword - def. A function will only run when it is called. Functions help in ensuring that our code is well organized. Organized code will ensure that we avoid repeating code in our script.

Classes

Python is an object-oriented programming language; this means that everything in Python is an object. The blueprint for creating an object in Python is the keyword - class. Just like functions, classes help to ensure that our code is well organized. Understanding classes is essential for anyone learning Python.

Modules

A module is simply a Python file containing Python code. Learning to create and import modules in our script is an import skill to master. Some of the popular modules used for data science include, Numpy, Pandas, Scikit-learn, and Seaborn. In web development you have popular modules such as Flask and Django.

10k Subscribers Giveaway

We have have reached a mile stone of 10,000 subscribers for this newsletter. To celebrate, I will be giving away free ( you are also free to contribute whatever you want toward the book) copies of my book - Master Python Fundamentals - The Ultimate Guide for Beginners for the rest of this week. Headover to the link below and download yourself a copy

No alt text provided for this image

Click on the link below:


Thank for reading this article, please share and subscribe if you are not a member of this group yet.

要查看或添加评论,请登录

Benjamin Bennett Alexander的更多文章

社区洞察

其他会员也浏览了