Lists are used to store multiple items in a single variable.
List items are ordered, changeable, and allow duplicate values.
List items are indexed, the first item has index [0], the second item has index [1] etc.
list1 = ["abc", 34, True, 40, "male"]
Tuples are used to store multiple items in a single variable.
Tuple Creation: Using parentheses ()
Tuple items are ordered, unchangeable, and allow duplicate values.
Tuple items are indexed, the first item has index [0], the second item has index [1] etc.
tuple1 = ("abc", 34, True, 40, "male")
Sets are used to store multiple items in a single variable.
Set items are unordered, unchangeable, and do not allow duplicate values.
True and 1 is considered the same value:
thisset = {"apple", "banana", "cherry", True, 1, 2}
Creating a Set: Using curly braces {}
Dictionaries are used to store data values in key:value pairs.
A dictionary is a collection which is ordered*, changeable and do not allow duplicates.
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
What are the key features of Python?
•Easy to learn and use
•Interpreted language (no need for compilation)
•Dynamically typed
•Extensive (vyaapak) standard libraries
•Open-source and cross-platform
•How Python is Different from Other Programming Languages?
•Easy to Learn & Use
•Python has simple and readable syntax, making it beginner-friendly.
•Dynamically Typed
•No need to declare variable types (Python automatically detects them).
•Interpreted Language
•Python executes code line by line (no need for compilation).
•Cross-Platform
•Python runs on Windows, macOS, Linux without changes.
•Supports Multiple Programming Paradigms
•Python supports procedural, object-oriented (OOP), and functional programming.
Large Standard Library
• Python has built-in modules for tasks like file handling, networking, and web development.
• Memory Management
• Python has automatic garbage collection, so you don’t need to manually free memory.
• Used in Many Fields
• Web Development (Django, Flask)
• Data Science (Pandas, NumPy)
• Machine Learning (TensorFlow, Scikit-learn)
• Automation (Scripting & Bots)
Popular Python Libraries with Examples
1. math (Mathematical Operations)
Used for: Performing mathematical calculations.
random (Generating Random Numbers)
Used for: Generating random numbers and choices.
datetime (Working with Date & Time)
Used for: Handling dates and time.
Third-Party Libraries (Require Installation)
6. numpy (Numerical Computing)
Used for: Handling arrays, matrices, and numerical calculations.
7. pandas (Data Manipulation)
Used for: Handling and analyzing data in table format.