Python Basics Guide
Python Basics Guide
1. List
A list is an ordered, mutable collection of items, and it allows duplicates. Lists are defined by square
brackets [].
Basic Operations:
Useful Functions:
2. Tuple
A tuple is an ordered, immutable collection. Tuples are defined by parentheses () and are often used
Basic Operations:
- Tuple Unpacking:
a, b, c = my_tuple
print(a, b, c) # Outputs: 1 2 3
Useful Functions:
3. Dictionary
A dictionary is a collection of key-value pairs. It is unordered, mutable, and defined with curly braces
Basic Operations:
Useful Functions:
5. if else Statement
The `if else` statement allows for conditional execution based on whether a condition is `True` or
`False`.
Basic Structure:
else:
print("Grade: A")
print("Grade: B")
elif score >= 70:
print("Grade: C")
else:
print("Grade: F")
Nested if Statements:
if is_student == "yes":
else:
else: