Question
The language is python. Create a function to help turtle determine how much to carry in his shell while on the run. Though he may
The language is python.
Create a function to help turtle determine how much to carry in his shell while on the run. Though he may not be "teenage-ninja" strong, turtle is still "mutant" strong since he can carry up to 100 pounds.
Start by defining a list of supplies; your list should contain at least six item names. Also, either in a separate list or as part of the supplies list, define a unique weight for each supply item in the supplies list.
Your function should repeatedly print the supply list and prompt the user to select an item from the list. When the user selects an item, check to make sure that the turtle can carry that weight, and if so, add that selected item to a 'carry' list in order to keep track of which items the turtle has selected. Then subtract the selected items weight from your friends maximum capacity so that after each selection, the function can display how much more weight the turtle can carry. Keep prompting and subtracting until turtle's remaining capacity is less than the weight of the lightest item in the list. At that time, your function should display a message to let your turtle friend know that he cannot carry any more items. It should then display a list of all the supplies that have been selected.
Notes:
The output should look like a variation of this (where the menu contains supplies and weights that you define):
Remaining capacity: 100 pounds
1 food mushrooms, 10 pounds
2 food speed-enhancing star snacks, 15 pounds
3 food wildflowers, 20 pounds
4 clothing fireball-proof vest, 30 pounds
5 clothing crush-proof shell plating, 40 pounds
6 ammo fireballs, 50 pounds
Select an item:
Remaining capacity: 70 pounds (if user selects 4)
1 food mushrooms, 10 pounds
2 food speed-enhancing star snacks, 15 pounds
3 food wildflowers, 20 pounds
4 clothing fireball-proof vest, 30 pounds
5 clothing crush-proof shell plating, 40 pounds
6 ammo fireballs, 50 pounds
Select an item:
Remaining capacity: 20 pounds (if user selects 6)
1 food mushrooms, 10 pounds
2 food speed-enhancing star snacks, 15 pounds
3 food wildflowers, 20 pounds
4 clothing fireball-proof vest, 30 pounds
5 clothing crush-proof shell plating, 40 pounds
6 ammo fireballs, 50 pounds
Select an item:
Remaining capacity: 5 pounds (if user selects 2)
Cannot carry any more items.
Shell contents:
clothing fireball-proof vest
ammo fireballs
food speed-enhancing star snacks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started