In: Computer Science
Assignment 3-4: IN PYTHON
Guest List: If you could invite anyone to dinner, who would you invite? Make a list that includes at least three people you’d like to invite to dinner. Then use your list to print a message to each person, inviting them to dinner.
---------------------------------------------------------------
Assignment 3-5:
Changing Guest List: You just heard that one of your guests can’t make the dinner, so you need to send out a new set of invitations. You’ll have to think of someone else to invite.
---------------------------------------------------------------
Assignment 3-6:
More Guests: You just found a bigger dinner table, so now more space is available. Think of three more guests to invite to dinner.
---------------------------------------------------------------
Assignment 3-7:
Shrinking Guest List: You just found out that your new dinner table won’t arrive in time for the dinner, and you have space for only two guests.
PreviousNext
Thanks for the question. Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks =========================================================================== # assignment 3-4 invited=['Obama','Trump','Diana'] for person in invited: print('Hello {}, I am pleased to invite you for dinner.'.format(person)) # assignment 3 -5 print('Trump is busy. He can\'t come for dinner') index_trump=invited.index('Trump') invited[index_trump]='Queen Elizabeth' for person in invited: print('Hello {}, I am pleased to invite you for dinner.'.format(person)) # assignment 3-6 invited.insert(0,'Enya') # add to the front invited.insert(len(invited)//2,'Donna') # add to the middle invited.append('Marsha') # add to the end for person in invited: print('Hello {}, I am pleased to invite you for dinner.'.format(person)) # assignment 3-7 while len(invited)!=2: name=invited.pop() print('I am sorry {}, we can\'t invite you for dinner.'.format(name)) #Use del to remove the last two names from your list, so you have an empty list del invited[-1] del invited[-1] #Print your list to make sure you actually have an empty list at the end of your program. for person in invited: print('Hello {}, I am pleased to invite you for dinner.'.format(person))