A high-level language for general-purpose programming is called Python. It’s an object-oriented, interpreted, free-source programming language. Guido van Rossum, a Dutch programmer, invented Python. The British sketch comedy series Month Python’s Flying Circus served as the inspiration for the name of the Python programming language. February 20, 1991, saw the release of the first edition. You can gain step-by-step knowledge of the newest Python version, Python 3, with the help of this 30-day Python challenge. The themes are divided into 30 days, with multiple topics per day that include clear explanations, examples from real-world situations, and lots of practical activities and tasks.
It is a programming language that is easy to learn and use since it is quite similar to human language. Many different sectors and businesses (including Google) use Python. It has been utilized in the development of machine learning libraries, desktop and web applications, and system administration. In the fields of data science and machine learning, Python is widely used. I hope this is sufficient to persuade you to begin studying Python. You are murdering Python before it eats you because it is consuming the globe.
Installing Python
To run a Python script, you need to install Python. Let’s download and install Python. If you are a Windows user, click here to install the latest version of Python.
If you are a Mac user, click here to install the latest version of Python.
If Python is installed, write the below-mentioned command on your device terminal to check.
# python –version
As you can see in our terminal, it shows Python version 3.9.7, which means Python is installed.
Python Shell
Python does not require compilation because it is an interpreted scripting language. It indicates that the code is run line by line. The Python Shell (Python Interactive Shell) is included with Python. It is used to run one Python command and obtain the outcome.
The Python shell awaits the user’s Python code. It decodes the code that you enter and displays the outcome in the line that follows. Launch the command prompt (cmd) or terminal and type: python
You can now write Python code (Python scripts) by using the Python interactive shell. Next to this >>> symbol, you will type your Python script, and then press Enter. Let’s use the Python programming shell to write our first script.
You’ve successfully written your first Python script using the interactive shell in Python. The Python interactive shell can be closed in what way? Next to this symbol, type the exit() command and hit Enter to end the shell.
Now, you know how to open and exit the Python interactive shell.
Python gives you results if you write a Python-understandable script; if not, it returns an error.
The returned message, which states that we made a mistake and that the error was a syntax message: invalid syntax, is proof that Python is a very sophisticated language. Because (x) is not a viable syntax in Python, using x as a multiplication is a syntax mistake. For multiplication, we use an asterisk (*) in place of (x). The returned error makes it evident what has to be fixed.
Debugging is the process of finding and fixing flaws in software. Let’s debug it by substituting * for x.
After we addressed our bug, the code was executed and produced the desired outcome. You will encounter these kinds of mistakes daily as a coder. Being able to debug is useful. Understanding the types of faults you are encountering is essential for proficient debugging. SyntaxError, IndexError, NameError, ModuleNotFoundError, KeyError, ImportError, AttributeError, TypeError, ValueError, ZeroDivisionError, and other mistakes are some of the Python issues that you could run into. Later sections will cover more about the various forms of Python errors.
Let’s perform several fundamental mathematical operations, including division, addition, subtraction, multiplication, modulus, and exponential.
First, let’s conduct some math before writing any Python code:
We have the following additional operations: In Python,
Let us convert the mathematical formulas above into a Python script. We can now put a comment at the very beginning of the Python shell since it has been opened.
A comment is a section of code that Python does not run. Thus, to make our code more legible, we might leave some words in it. Python does not execute the comment part. In Python, a comment begins with the hash(#) symbol. This is how a Python comment is written.
# comment starts with hash # this is a python comment because it starts with a (#) symbol
Let’s continue honing our skills in the Python interactive shell before moving on to the next phase. Let’s practice writing a text on the Python shell by closing the open shell, writing exit() on it, and then opening it again.
Visual Studio Code editor
How to install Visual Studio code
Jupyter Notebook (anaconda3)
Python files have the.py extension, and scripts can be written in the code editor or with the Python interactive shell.
A text’s white space is an indentation. Indentation in many languages is used to promote code readability, whereas Python uses indentation to form blocks of code. Instead of using indentation to form code blocks, curly brackets are utilized in various programming languages. One of the common errors when developing Python code is improper indentation.
Comments are essential for adding notes to our code and for making it easier to read. Python does not execute the code’s comment sections. In Python, a text that begins with a hash(#) is considered a comment.
Single-line comment
# This is the first comment # This is the second comment # Python is eating the world
Multiline Comment
In the multiline comment triple quote can be used if it is not assigned to a variable
"""This is multiline comment multiline comment takes multiple lines. python is eating the world """
There are various kinds of data types in Python. Let’s begin with the most typical ones. Further sections will address various data types in more detail. Let’s just go over and become acquainted with the various data kinds for the time being.
A collection of one or more characters under a single or double quote. If a string is more than one sentence then we use a triple quote.
Example:
'Tech'
'India'
'Python'
'I love teaching'
'I hope you are enjoying the first day of python'
A boolean data type is either a True or False value. T and F should be always uppercase.
Example:
True # Is the fan on? If it is on, then the value is True
False # Is the fan on? If it is off, then the value is False
Python list is an ordered collection that allows to storage of different data type items. A list is similar to an array in JavaScript.
Example:
[0, 1, 2, 3, 4, 5] # all are the same data types - a list of numbers
['Apple', 'Orange', 'Mango', 'Avocado'] # all the same data types - a list of strings (fruits)
['England','America', 'India','Bhootan'] # all the same data types - a list of strings (countries)
['Banana', 20, False, 7.81] # different data types in the list - string, integer, boolean and float
A Python dictionary object is an unordered collection of data in a key-value pair format.
Example:
{
'first_name':'Tech',
'last_name':'G',
'country':'India',
'age':25,
'is_married':True,
'skills':['C++', '.Net', 'Node', 'Python']
}
A tuple is an ordered collection of different data types like a list but tuples can not be modified once they are created. They are immutable.
Example:
('Tech', 'Pawl', 'Brooks', 'Abra', 'Lida') # Names
('Earth', 'Jupiter', 'Neptune', 'Mars', 'Venus', 'Saturn', 'Uranus', 'Mercury') # planets
A set is a collection of data types similar to a list and tuple. Unlike a list and tuple, a set is not an ordered collection of items. Like in Mathematics, set in Python stores unique items.
In later sections, we will go into detail about every Python data type.
Example:
{2, 4, 3, 5}
{3.14, 9.81, 2.7} # order is not important in set
To check the data type of certain data/variables we use the type function. In the following terminal you will see different Python data types:
Day2>>
Day 30 Conclusions In the process of preparing this material, I have learned quite a…
Day 29: Building API In this section, we will cover a RESTful API that uses HTTP…
Day 28: Application Programming Interface (API) API API stands for Application Programming Interface. The kind…
Day 27: Python with MongoDB Python is a backend technology, and it can be connected…
Day 26: Python for Web Python is a general-purpose programming language, and it can be…
Day 25: Pandas Pandas is an open-source, high-performance, easy-to-use data structure, and data analysis tool…
View Comments