Question: Use the course material located at: o COSC 1336 Program 9 can be completed using content from the following chapters: o Welcome! through File I/O

Use the course material located at: o COSC 1336 Program 9 can be completed using content from the following chapters: o Welcome! through File I/O Requirements (remember to identify the requirements by number): Create a file using PyCharm. Name the source file program_9.py. Format code like the examples. Include comments in your code like the examples. Code the requirements in the numbered list below. Output a header in the console: This is Program 9 COSC 1336 Program 9 Page 2 of 2 Requirements to be numbered in program_9.py: Start with the program you produced for Program 8. In addition to all of the requirements for Program 8, do the following: 1. Print This program keeps track of Pokmon characters, saves the data to a file, and displays the data from a file. 2. Call the function save_data() to save the Pokmon data to a file. 3. Call the function display_data() read the data from a file and display the output just like requirement #4 in Program 8. 4. Print a statement explaining your experiences with Program 9. TEST TEST TEST your application to ensure the specific program requirements are met. Use the list above and the common requirements as a confirmation checklist. Not meeting all requirements = 0 points for the assignment. Program 8. class Pokemon: # __init__ called AUTOMATICALLY when an object is created # this also assigns argument name and ability to 'self.__name & self.__ability' def __init__(self, name, ability): self.__name = name self.__ability = ability def get_name(self): return self.__name def get_ability(self): return self.__ability

# main() function def main(): print(" Requirement 1:" " This program keeps track of the Pokemon characters") print(" Requirement 2:") print("########## In main() ##########") pokemon_list = add_pokemon() print(" Requirement 3 & 4:") display_pokemon(pokemon_list) print(" Requirement 5:") print("Pokemon.")

# add_pokemon() function def add_pokemon(): print(" __________ In add_pokemon __________") # creating a new list to hold pokemon characters pokemon_list = [] # counter used in loop pokemon_number = 1 more_pokemon = input(" Do you have a pokemon to enter? (y/n) ").lower() while more_pokemon == 'y': # user inputs pokemon name pokemon_name = input(" Enter name for Pokemon #{}: ".format(pokemon_number)) # user inputs pokemon ability pokemon_ability = input(" Enter ability for Pokemon #{}: ".format(pokemon_number)) # creating a new pokemon object with pokemon_name and pokemon_ability new_pokemon = Pokemon(pokemon_name, pokemon_ability) # adding new_pokemon to list pokemon_list.append(new_pokemon) # incrementing counter pokemon_number += 1 # user inputs whether he/she wants to enter another pokemon more_pokemon = input(" Another pokemon to enter? (y/n) ").lower() return pokemon_list

def display_pokemon(pokemon_list): print(" __________ In display_pokemon() _________") for pokemon in pokemon_list: poke_index = pokemon_list.index(pokemon) + 1 print(" Name of Pokemon #"+str(poke_index)+": "+pokemon.get_name()) print(" Ability of Pokemon #"+str(poke_index)+": "+pokemon.get_ability())

if __name__ == '__main__': main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!