0% found this document useful (0 votes)
2 views2 pages

Python Notes

Uploaded by

Bilal Saifi
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)
2 views2 pages

Python Notes

Uploaded by

Bilal Saifi
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

PYTHON NOTES (BEGINNER TO INTERMEDIATE)

1. Introduction to Python

Python is a high-level, interpreted programming language used for web development, data analysis,
automation, and more. It is known for its simple syntax and readability.

2. Data Types in Python

(a) Integer (int): Used to store whole numbers.


Example: x = 10

(b) Float (float): Used to store decimal numbers.


Example: x = 10.5

(c) String (str): Used to store text.


Example: name = 'Bilal'

(d) Boolean (bool): Used to store True or False values.


Example: is_valid = True

Why Data Types are used?

Data types define the type of data a variable can store. They help Python understand what
operations can be performed on that data.

3. Data Structures

(a) List: Ordered, mutable collection.


Example: [1,2,3]

(b) Tuple: Ordered, immutable collection.


Example: (1,2,3)

(c) Dictionary: Key-value pairs.


Example: {'name':'Bilal'}

(d) Set: Unordered, unique elements.


Example: {1,2,3}

4. Loops in Python

(a) For Loop

Used when the number of iterations is known.


Example:
for i in range(5): print(i)

(b) While Loop

Used when the number of iterations is unknown and depends on condition.


Example:
while i < 5: i += 1

Loop Control Statements

break: Stops the loop completely.


continue: Skips current iteration.
Why Loops are used?

Loops help automate repetitive tasks and reduce code duplication.

5. Functions

Functions are reusable blocks of code.


Example:
def greet(name): return 'Hello ' + name

6. Conclusion

Python is powerful and easy to learn. Understanding data types and loops is essential for building
strong programming logic.

You might also like