Tuple in Python

A tuple is a built-in Python data type that represents an ordered, immutable collection of elements. Key Features:Ordered: Elements have a defined order (you can access by index). Immutable: Once created, elements cannot be changed. Allows duplicates: Same value can appear more than once. Can contain mixed data types (integers, strings, lists, etc.).

Set in Python

A set is a built-in data type in Python that represents an unordered collection of unique elements. Key Features:Unordered: The elements have no fixed position. Unique: Duplicate values are automatically removed. Mutable: You can add or remove elements. Iterable: You can loop through a set.

List in Python

A list in Python is a built-in, ordered, and mutable collection of elements. It can hold items of different data types such as integers, strings, floats, or even other lists. Key Features:Ordered: Items maintain their insertion order. Mutable: You can add, remove, or change items after the list is created. Heterogeneous: Can store mixed data…

Importing Libraries in Python

What is a Library? A library is a collection of reusable functions, classes, and modules. Python comes with many built-in libraries, and you can also use external libraries created by the Python community. Importing Built-in Libraries import mathprint(“Square root of 16 is:”, math.sqrt(16)) Output:Square root of 16 is: 4.0 Importing with an Alias Use as…

If-Else Statements in Python

Basic If Statement The simplest form of decision making in Python. The if statement runs a block of code only when the given condition is true. age = 18 if age >= 18: print(“You are eligible to vote.”) Output: You are eligible to vote. If-Else Statement Use else to specify a block of code that…