Data Abstraction Homework Python
Quick practice with Javascript Lists
# 📝 Data Abstraction Hack (Python Version)
# --- Instructions ---
# 1. Edit the `students` list to use your own names (friends, classmates, etc.).
# 2. Edit the `scores` list to assign each student a score of your choice.
# 3. Run this program to see how the output changes automatically.
# 4. After experimenting with `students` and `scores`, complete the 🚀 Hack Challenge at the bottom.
# --- 1. Define lists ---
students = ["Meryl", "Avantika", "Anika"]
scores = [1000000000000000000000000000000, 99, 99]
# --- 2. Print roster ---
print("Students:", ", ".join(students))
# --- 3. Print first student and score ---
print("First student:", students[0], "-", scores[0])
# --- 4. Add a new student and score ---
students.append("Kaylin")
scores.append(95)
print("After adding Kaylin:", ", ".join(students))
# --- 5. Remove a student who transfers out ---
if "Hope" in students:
index = students.index("Hope")
students.pop(index)
scores.pop(index)
print("After removing Hope:", ", ".join(students))
# --- 6. Curve all scores by +5 ---
for i in range(len(scores)):
scores[i] += 5
# --- 7. Print each student with score ---
print("\nFinal Scores:")
for i in range(len(students)):
print(students[i], "-", scores[i])
# --- 8. Hack Challenge: create new list ---
favorite_foods = ["Sushi", "Falafel", "Hotdogs"]
print("\nFavorite Foods:")
for food in favorite_foods:
print(food)
Students: Meryl, Avantika, Anika
First student: Meryl - 1000000000000000000000000000000
After adding Kaylin: Meryl, Avantika, Anika, Kaylin
After removing Hope: Meryl, Avantika, Anika, Kaylin
Final Scores:
Meryl - 1000000000000000000000000000005
Avantika - 104
Anika - 104
Kaylin - 100
Favorite Foods:
Sushi
Falafel
Hotdogs