Python Introduction
Python was created by Guido van Rossum in 1991 and further developed by the
Python Software Foundation. It was designed with focus on code readability and
its syntax allows us to express concepts in fewer lines of code.
Key Features of Python
Python’s simple and readable syntax makes it beginner-friendly.
Python runs seamlessly on Windows, macOS and Linux.
Supports multiple programming paradigms, including object-oriented,
functional and procedural programming.
Python is free to use, distribute and modify.
Understanding Hello World Program in Python
Hello, World! in python is the first python program which we learn when we start
learning any program. It’s a simple program that displays the message “Hello,
World!” on the screen.
What can we do with Python?
Python is used for:
Web Development: Frameworks like Django, Flask.
Data Science and Analysis: Libraries like Pandas, NumPy, Matplotlib.
Machine Learning and AI: TensorFlow, PyTorch, Scikit-learn.
Automation and Scripting: Automate repetitive tasks.
Game Development: Libraries like Pygame.
Taking input in Python
Python's input() function is used to take user input. By default, it returns the user
input in form of a string.
Example:
num = input("Enter your number: ")
print("YOUR NUMBER= ", num)
Output
Enter your number: 5
YOUR NUMBER= 5
Python Variables
In Python, variables are used to store data that can be referenced and
manipulated during program execution. A variable is essentially a name that is
assigned to a value. Unlike many other programming languages, Python variables
do not require explicit declaration of type. The type of the variable is inferred
based on the value assigned.
Rules for Naming Variables
To use variables effectively, we must follow Python’s naming rules:
Variable names can only contain letters, digits and underscores (_).
A variable name cannot start with a digit.
Variable names are case-sensitive (myVar and myvar are different).
Avoid using Python keywords (e.g., if, else, for) as variable names.
Basic Assignment
Variables in Python are assigned values using the = operator.
Getting the Type of Variable
In Python, we can determine the type of a variable using the type() function.
This built-in function returns the type of the object passed to it.
Example Usage of type()
Python Operators
Last Updated : 19 Jun, 2025
In Python programming, Operators in general are used to perform operations on
values and variables. These are standard symbols used for logical and arithmetic
operations. In this article, we will look into different types of Python operators.
OPERATORS: These are the special symbols. Eg- + , * , /, etc.
OPERAND: It is the value on which the operator is appliedwin+shift+s.
Arithmetic Operators in Python
Python Arithmetic operators are used to perform basic mathematical
operations like addition, subtraction, multiplication and division.
Example of Arithmetic Operators in Python:
Output
Comparison of Python Operators
In Python Comparison of Relational operators compares the values. It either
returns True or False according to the condition.
Logical Operators in Python
Python Logical operators perform Logical AND, Logical OR and Logical NOT
operations. It is used to combine conditional statements.
The precedence of Logical Operators in Python is as follows:
1. Logical not
2. logical and
3. logical or
Python Keywords
Keywords in Python are reserved words that have special meanings and serve
specific purposes in the language syntax. Python keywords cannot be used as
the names of variables, functions, and classes or any other identifie
Python Data Types
Python Data types are the classification or categorization of data items. It
represents the kind of value that tells what operations can be performed on a
particular data. Since everything is an object in Python programming, Python
data types are classes and variables are instances (objects) of these classes. The
following are the standard or built-in data types in Python:
Numeric - int, float
Sequence Type - string, list, tuple
Mapping Type - dict
Boolean - bool
1. Numeric Data Types in Python
The numeric data type in Python represents the data that has a numeric value. A
numeric value can be an integer, a floating number, or even a complex number.
These values are defined as Python int and Python float classes in Python.
Integers - This value is represented by int class. It contains positive or
negative whole numbers (without fractions or decimals). In Python, there is
no limit to how long an integer value can be.
Float - This value is represented by the float class. It is a real number with a
floating-point representation. It is specified by a decimal point. Optionally,
the character e or E followed by a positive or negative integer may be
appended to specify scientific notation.
2. Sequence Data Types in Python
The sequence Data Type in Python is the ordered collection of similar or
different Python data types. Sequences allow storing of multiple values in an
organized and efficient fashion. There are several sequence data types of
Python:
Python String
Python List
Python Tuple
String Data Type
Python Strings are arrays of bytes representing Unicode characters. In Python,
there is no character data type Python, a character is a string of length one. It is
represented by str class.
Strings in Python can be created using single quotes, double quotes or even
triple quotes. We can access individual characters of a String using index.
List Data Type
Lists are just like arrays, declared in other languages which is an ordered
collection of data. It is very flexible as the items in a list do not need to be of the
same type.
Tuple Data Type
Just like a list, a tuple is also an ordered collection of Python objects. The only
difference between a tuple and a list is that tuples are immutable. Tuples cannot
be modified after it is created.
3. Boolean Data Type in Python
Python Data type with one of the two built-in values, True or False. Boolean
objects that are equal to True are truthy (true), and those equal to False are
falsy (false). However non-Boolean objects can be evaluated in a Boolean
context as well and determined to be true or false. It is denoted by the class
bool.