0% found this document useful (0 votes)
18 views3 pages

Python Presentation Basics

The document provides an overview of Python, a high-level programming language used for various applications. It covers key concepts such as variables, data types, and operators, including assignment, arithmetic, comparison, logical, and membership operators. Understanding these basics is essential for programming in Python.

Uploaded by

shahzainab20104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Python Presentation Basics

The document provides an overview of Python, a high-level programming language used for various applications. It covers key concepts such as variables, data types, and operators, including assignment, arithmetic, comparison, logical, and membership operators. Understanding these basics is essential for programming in Python.

Uploaded by

shahzainab20104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Basics: Variables, Data Types, and

Operators

What is Python?
Python is a high-level, easy-to-understand programming language used to build websites, apps,
games, and more.

Variables in Python
A variable is a name used to store a value in memory.

Example:
name = "Zainab"
age = 15
Here, name and age are variables. "=" assigns the value to the variable.

Data Types in Python


Data types tell us what kind of value a variable is storing.

Common Data Types:

Data Type Example Explanation


int 5, -3 Whole numbers
float 3.14, -1.5 Decimal numbers
str "Hello" A sequence of characters (text)
bool True, False Represents yes/no logic
list [1, 2, 3] Collection of values

Assignment Operator
Used to assign a value to a variable.
Symbol: =
Definition: Assigns the value on the right to the variable on the left.
Example: x = 10

Augmented Assignment Operators


Used to update the value of a variable using another value.
Symbols: +=, -=, *=, /=, %=, //=, **=
Definition: Combines assignment with another operation.
Example:
x = 5
x += 3 # x = x + 3 → x becomes 8

Arithmetic Operators
Used to perform basic math operations.

Operator Meaning Example (a=10, b=3) Result


+ Addition a+b 13
- Subtraction a-b 7
* Multiplication a*b 30
/ Division a/b 3.33
// Floor Division a // b 3
% Modulus a%b 1
** Exponentiation a ** b 1000

Comparison Operators
Used to compare two values and return True or False.

Operator Meaning Example (a=5, b=3) Result


== Equal to a == b False
!= Not equal to a != b True
> Greater than a>b True
< Less than a<b False
>= Greater than or equal a >= 5 True
<= Less than or equal a <= 2 False

Logical Operators
Used to combine multiple conditions.

Operator Meaning Example Result


and True if both are true a > 2 and b < 5 True
or True if at least one is true a > 2 or b > 5 True
not Reverses the result not(a > 2) False

Membership Operators
Used to check if a value exists in a sequence like list or string.
Operator Meaning Example Result
in Checks if value is present 'a' in 'apple' True
not in Checks if value is not present 'z' not in 'apple' True

Conclusion
Variables store data. Data types describe the kind of data. Operators let us perform actions like
math, comparisons, and logic. Python is beginner-friendly and powerful when you understand the
basics!

You might also like