Blog

python tutorials and learn python

Created with Sketch.

Python Not Equal Operator (!=)

Understanding the Not Equal Operator (!=) in Python Introduction: In Python, the not equal operator (!=) is a fundamental comparison operator that allows programmers to check if two values are different. It is an essential tool in building conditional statements and making decisions within Python programs. This blog post will explore the usage, significance, and…
Read more

Operators in Python – Logical, Arithmetic, Comparison

In Python, operators are special symbols or keywords that perform operations on one or more operands. Here’s an overview of some common types of operators in Python: 1. Arithmetic Operators: Perform mathematical operations. 2. Comparison Operators: Compare values and return True or False. 3. Logical Operators: Perform logical operations. 4. Assignment Operators: Assign values to…
Read more

Python Dictionary Append: How to Add Key/Value Pair

In Python dictionaries, you don’t use the term “append” like you would with lists. Instead, you add a new key-value pair to a dictionary. Here’s how you can add key-value pairs to a dictionary, along with a description: Adding a Key-Value Pair to a Dictionary: You can add a new key-value pair to a dictionary…
Read more

Dictionary in Python with Syntax & Example

A dictionary in Python is a mutable, unordered collection of key-value pairs, where each key must be unique. Dictionaries are useful for storing and retrieving data efficiently based on a specific key. Here is the syntax and an example of using dictionaries in Python: Syntax: Example:   Dictionaries provide a flexible and efficient way to…
Read more

Python TUPLE – Pack, Unpack, Compare, Slicing, Delete, Key

A tuple in Python is an immutable, ordered collection of elements. Once a tuple is created, you cannot change its values or length. Here are various operations you can perform with tuples: 1. Creating a Tuple: You can create a tuple using parentheses (). 2. Packing and Unpacking: Packing: Assigning multiple values to a single…
Read more

How to Run Python Scripts: Step by Step Guide

Running Python scripts involves executing the code stored in a Python file. Here is a step-by-step guide on how to run Python scripts: 1. Create a Python Script: Open your preferred text editor and write your Python code. Save the file with a .py extension, which is the standard extension for Python scripts. Example: myscript.py…
Read more

How to Check Python Version on Linux, Mac & Windows

Checking the Python version can be done using the command line or terminal on Linux, Mac, and Windows. Here are the steps for each operating system: On Linux: Open a terminal and use the following command: Or This will display the installed Python version. On Mac: Open the terminal and enter one of the following…
Read more

Python Escape Character Sequences (Examples)

Escape characters in Python are used to represent characters that are difficult to type directly, such as special characters, control characters, or characters with specific meanings. These escape characters are represented by a backslash (\) followed by a character or sequence of characters. Here are some common escape character sequences in Python: 1. Newline (\n):…
Read more

Python Variables: How to Define/Declare String Variable Types

In Python, defining or declaring string variables is a straightforward process. Here’s how you can define string variables: 1. Explicit Declaration: 2. Implicit Declaration: In Python, you don’t need to explicitly declare the variable type. Python is dynamically typed, meaning you can assign values to variables without specifying their type. 3. Concatenation: You can concatenate…
Read more

Python Print() Statement: How to Print with Examples

Python print() Statement: Printing Examples In Python, the print() statement is a fundamental function used for displaying messages on the screen. This versatile function can be applied to print strings, objects, or a combination thereof. Here are several examples to illustrate the usage of the print() statement: 1. Printing a Simple String: Output: 2. Printing…
Read more