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

Python Full Guide

Uploaded by

samigamer727
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 views3 pages

Python Full Guide

Uploaded by

samigamer727
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 Full Guide (Beginner → Advanced)

1. Python Syntax

1 Python uses indentation (spaces) instead of {}.


2 Code blocks are defined by consistent spacing.
3 Example: if x > 5: print(x)

2. Variables

1 Variables store values in memory.


2 No need to declare type.
3 Example: x = 10, name = 'Sam'

3. Data Types

1 int (numbers), float (decimal), str (text), bool (True/False)


2 Check type using type(x)

4. Operators

1 +, -, *, /, %, ** (power)
2 Comparison: ==, !=, >, <
3 Logical: and, or, not

5. Strings

1 Used for text.


2 Methods: upper(), lower(), strip()
3 Example: [Link]()

6. Lists

1 Ordered, changeable collection.


2 Example: nums = [1,2,3]
3 Access: nums[0]
7. Dictionaries

1 Store key-value pairs.


2 Example: user = {'name':'Sam', 'age':20}

8. If-Else Conditions

1 Control decision making.


2 Example: if x > 10: print('High') else: print('Low')

9. Loops

1 Repeat tasks.
2 for loop: for i in range(5):
3 while loop: while condition:

10. Functions

1 Reusable blocks of code.


2 Example: def add(a,b): return a+b

11. Error Handling

1 Use try/except to prevent crashes.


2 Example: try: x = int('a') except: print('Error')

12. Object-Oriented Programming (OOP)

1 Classes and objects.


2 Example: class Car: def __init__(self, name): [Link] = name

13. Modules & Libraries

1 Reuse code using import.


2 Example: import math
3 pip install library_name
14. File Handling

1 Read/write files.
2 Example: with open('[Link]','r') as f: data = [Link]()

15. Virtual Environments

1 Isolate project dependencies.


2 Command: python -m venv env

16. Advanced Topics

1 Decorators, Generators, Lambda functions


2 Example lambda: lambda x: x*2

You might also like