72.9k views
18 votes
Write Python statement to do the following tasks (a) create a list that contain the name of 5 student of your class (b) add one more name to the list of 5 students (c)

delete the first name from the list of student​

User Ssasa
by
3.9k points

1 Answer

8 votes

Answer:

classroster = ["Bill", "Tyler", "Jake", "Sam", "Joe"]

print("Original Roster: " + str(classroster))

classroster.append("June")

print("Added student: " + str(classroster))

classroster.pop(0)

print("Removed the first student" + str(classroster))

Step-by-step explanation:

We create a variable named classroster and assign it a list value by using []

We print text with the value of the variable classroster, but we used the str tag to make it a string value

We used classroster.append to add "June" to the end of the list.

We then print the classroster again

We use classroster.pop(0) to remove "Bill" on the list. If we wanted to remove "Tyler" from the list, we would use classroster.pop(1).

If we wanted to remove "Jake" we would use classroster.pop(2)

and so on. goodluck!

User Agweber
by
5.1k points