Python 5 Mark Programs
Python 5 Mark Programs
Python Program:
```python
# Creating a tuple
# Accessing elements
print("Name:", student_info[0])
print("Age:", student_info[1])
print("Course:", student_info[2])
# student_info[1] = 22
```
Output:
Name: Alice
Age: 21
Course: BCA
Count of 85: 2
Index of 95: 3
Python Program:
```python
# Creating a dictionary
student = {
"name": "Bob",
"age": 20,
"course": "Python"
}
# Accessing values
print("Name:", student["name"])
student["grade"] = "A"
# Modifying a value
student["age"] = 21
```
Output:
Name: Bob
name : Bob
age : 21
course : Python
grade : A
Python Program:
```python
# Creating a set
# Adding elements
colors.add("yellow")
# Removing elements
colors.discard("green")
# Set operations
a = {1, 2, 3}
b = {3, 4, 5}
print("Union:", a | b)
print("Intersection:", a & b)
# Traversing a set
print("Color:", color)
```
Output:
Union: {1, 2, 3, 4, 5}
Intersection: {3}
Color: red
Color: blue
Color: yellow