C Programming - Short Notes
Python Programming - Short Notes
1. Introduction to Python:
Python is a high-level, interpreted programming language. It is known for its simplicity and readability.
2. Basic Structure of a Python Program:
print("Hello, World!")
3. Data Types in Python:
- int, float, str, bool, list, tuple, dict, set
4. Variables and Constants:
Variables store data. Constants are defined using uppercase variable names by convention.
5. Operators in Python:
- Arithmetic: +, -, *, /, %, **, //
- Relational: ==, !=, >, <, >=, <=
- Logical: and, or, not
6. Conditional Statements:
if, if-else, elif
7. Loops in Python:
- for loop (used with range or iterable)
- while loop
8. Functions in Python:
Functions are defined using the def keyword.
Example:
C Programming - Short Notes
def add(a, b):
return a + b
9. Data Structures:
- List: [1, 2, 3]
- Tuple: (1, 2, 3)
- Set: {1, 2, 3}
- Dictionary: {"name": "Alice", "age": 25}
10. Object-Oriented Programming (OOP) Concepts:
- Class and Object
- Inheritance
- Encapsulation
- Polymorphism
Example:
class Student:
def __init__(self, name):
self.name = name
def display(self):
print("Name:", self.name)
11. File Handling in Python:
- open(), read(), write(), close()
Example:
with open("file.txt", "r") as file:
data = file.read()
C Programming - Short Notes
12. Advantages of Python:
- Simple and easy to learn
- Large community support
- Extensive libraries and frameworks
- Versatile (web, data science, automation)