Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Coding Write a program that simulates an encounter with a zombie in an RPG Create a list of possible weapons. In a variable called

Python Coding

Write a program that simulates an encounter with a zombie in an RPG

Create a list of possible weapons.

In a variable called zombieWeakness store the name of one of the weapons from the list.

Output messages telling the user that they have encountered a zombie and should prepare to fight.

Output the list of weapons to the user. Ask if they want to type 1 to use one from the list or 2 to pick their own.

If they type 1 then they should input the weapon name - store it to a new variable.

If they type 2 they should input the weapon name - add it to the list and save it to a new variable.

If the weapon picked matches the zombieWeakness, output a message telling the user that they have won the fight.

Otherwise output a message saying that they have lost.

List Operations - Reference Table

Output item Outputs a single item from the array. print(arrayName[itemIndex]) print(sweets[3])
Edit item Changes or replaces an item in an array. arrayName[itemIndex] = New data sweets[1] = "Haribo"
Add an item Puts a new item onto the end of the array arrayName.append(new data) sweets.append("Galaxy")
Remove an item Removes an item from the array arrayName.pop(itemIndex) sweets.pop(2)
Output all items Outputs every item in the array one by one using a loop. for i in range(0, len(arrayName)): print(arrayName[i]) for i in range(0, len(sweets)): print(arrayName[i]) OR #This is a nice built in Python shortcut, but you need to know how to do the for loop version for the exam. print(sweets)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions