What is Python? - Python is a high-level, interpreted programming language. - It is known for its simplicity and readability. - Used in web development, data science, automation, and more.
Features of Python - Easy to learn and use - Open-source and free - Interpreted language - Cross-platform compatibility - Large standard library - Object-oriented and functional programming support
Python Syntax and Variables - Python uses indentation instead of braces. - Variables do not require explicit declaration. - Example: ```python name = 'John' age = 25 print(name, age) ```
Data Types and Operators - Common Data Types: int, float, str, list, tuple, dict - Operators: Arithmetic, Comparison, Logical, Assignment, Bitwise - Example: ```python a = 10 b = 5 print(a + b, a > b) ```
Control Flow (if-else, loops) - Conditional statements (if, elif, else) - Loops (for, while) - Example: ```python x = 10 if x > 5: print('X is greater than 5') for i in range(3): print(i) ```
Functions and Modules - Functions help in code reusability. - Modules allow importing additional functionalities. - Example: ```python def greet(name): return f'Hello, {name}!' print(greet('Alice')) ```
Basic File Handling - Reading and writing files - Example: ```python with open('file.txt', 'w') as f: f.write('Hello, Python!') ```
Simple Python Program Example - Example program to add two numbers: ```python num1 = int(input('Enter first number: ')) num2 = int(input('Enter second number: ')) sum = num1 + num2 print('Sum:', sum) ```
Conclusion - Python is a beginner-friendly language. - It is widely used in various fields. - Start practicing by writing simple programs! - Explore libraries and frameworks to enhance your skills.
Creating a List # List of integers a = [Audi, BMW, Farari ] # List of strings b = ['apple', 'banana', 'cherry'] # Mixed data types c = [hello] print(a) print(b) print(c)