Python Assignment Solution
Python Assignment Solution
a) Variable:
Example:
x = 10
name = "Alice"
b) Data type:
Example:
age = 20 (Integer)
pi = 3.14 (Float)
c) Identifier:
d) Tuple:
Example:
List:
- Mutable
- Uses []
- Example: [1, 2, 3]
Tuple:
- Immutable
- Uses ()
- Cannot add/remove
- Example: (1, 2, 3)
# a) 3rd subject
# b) Replace 2nd
marks[1] = 80
Python Assignment Solutions
# c) Add two
marks.append(90)
marks.append(95)
# d) Sort
marks.sort()
5. Tuple operations
print(info[0], info[2])
# b) Modify age
info[1] = 21
data = []
for i in range(3):
data.append(value)