Category Python

How to Run Python Code

how to python

You can run Python code directly on a terminal as commands or save the code in a file with .py extension and run the Python file. Terminal Running commands directly on a terminal is recommended when you want to run…

Python Syntax

how to python

Python is known for its clean syntax. The language avoids using unnecessary characters to indicate some specificity. Semicolons Python makes no use of semicolons to finish lines. A new line is enough to tell the interpreter that a new command…

Introduction to Python

code on screen

Python was created in 1990 by Guido Van Rossum in Holland. One of the objectives of the language was to be accessible to non-programmers. Python was also designed to be a second language to programmers due to its low learning…

How to Install Python 3

how to python

If you use a Mac or Linux you already have Python installed, Windows doesn’t come with Python installed by default. But you might have Python 2 and we are going to use Python 3. Check if you have Python 3…

Membership Operators in Python

how to python

These operators provide an easy way to check if a certain object is present in a sequence: string, list, tuple, set, and dictionary. They are: in: returns True if the object is present not in: returns True if the object…

Identity Operators in Python

how to python

These operators are used to check if two objects are at the same memory location. Notice that they do not compare values, but memory location. They are: is: returns True if both objects are identical is not: returns True if…

Comparison Operators in Python

how to python

Use comparison operators to compare two values. These operators return either True or False. They are: ==: Equal !=: Not equal >: Greater than <: Less than >=: Greater than or equal to <=: Less than or equal to Let’s…

Logical Operators in Python

how to python

Logical operators are used to combine statements applying boolean algebra as shown in this article Booleans in Python. They are: and: True only when both statements are true or: False only when both x and y are false not: The…

Assignment Operators in Python

how to python

As the name implies, these operators are used to assign values to variables. x = 7 in the first example is a direct assignment storing the number 7 in the variable x. The assignment operation takes the value on the…

Arithmetic Operators in Python

how to python

Arithmetic operators are the most common type of operators and also the most recognizable ones. They allow you to perform mathematical operations. They are: +: Addition -: Subtraction *: Multiplication /: Division **: Exponentiation //: Floor Division, rounds down the…