You and a partner are creating a program that will store the titles of songs. Your partner wants to use a stack, and you want to use a list. What would you say to your partner?
Describe two situations in which it would make sense to use a tree as a data structure.
Consider this program:
clothes = {"pants", "shirts", "socks", "jackets"}
clothes.add("skirts")
clothes.add("socks")
print(len(clothes))
Describe what each line of code is doing to explain why the output is 5.
Consider this program:
clothes = ("pants", "shirts", "socks", "jackets")
clothes.add("skirts")
clothes.add("socks")
print(len(clothes))
Describe what each line of code is doing to explain why the output is an error message.
Consider this program:
theStack = [2, 8, 3, 7]
theStack.append(5)
print(theStack.pop())
Describe what each line of code is doing to explain why the output is 5.