Content:
Questions & Answers:
Content:
print(fruits[0]) # Output: apple
print(fruits[-1]) # Output: cherry (negative index accesses elements from the end)
fruits.remove("apple") # Removes "apple"
Questions & Answers:
Content:
numbers = [0, 1, 2, 3, 4, 5]
print(numbers[1:4]) # Output: [1, 2, 3]
Questions & Answers:
Content:
student = {"name": "Alice", "age": 25, "grade": "A"}
print(student["name"]) # Output: Alice
Questions & Answers:
Content:
print(student.keys()) # Output: dict_keys(['name', 'age', 'grade'])
print(student.values()) # Output: dict_values(['Alice', 26, 'A'])
Questions & Answers:
Content:
classroom = {
"student1": {"name": "Alice", "age": 25},
"student2": {"name": "Bob", "age": 22}
}
print(classroom["student1"]["name"]) # Output: Alice
students = [
{"name": "Alice", "age": 25},
{"name": "Bob", "age": 22}
]
print(students[0]["name"]) # Output: Alice
Questions & Answers:
Content:
for fruit in fruits:
print(fruit)
Questions & Answers:
Content:
Questions & Answers:
GoInnovateSoftware
Copyright © 2024 GoInnovateSoftware - All Rights Reserved.
Powered by GoDaddy
We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.