Use python write
Thank you so much!

pets.txt dog alyson 5.5 cat chester 1.5 cat felice 16 dog jesse 14 cat merlin 5 cat percy 12 cat puppet 18
to_transfer.txt
cat merlin 5 cat percy 12
intake.txt
bird joe 3 cat sylvester 4.5
the website is https://www2.cs.arizona.edu/classes/cs110/spring17/homework.shtml
animal_shelter.py
from operator import itemgetter
#create lists required
pets = [] # pets currently in shelter
to_transfer = [] # pets already transferred to another shelter
adopted = [] # pets adopted from this shelter
#read files to fill up the lists with tuples
file = open("pets.txt", "r")
for line in file:
pets.append(tuple(line.split()))
#print(pets)
file = open("adopted.txt", "r") # you have not provided adopted file so it shows empty list for now
for line in file:
adopted.append(tuple(line.split()))
#print(adopted)
file = open("to_transfer.txt", "r")
for line in file:
to_transfer.append(tuple(line.split()))
#print(to_transfer)
while(1):
input_option=input("""Type one of the following options:
adopt: adopt a pet
intake: add more animals to the shelter
list: display all adoptable pets
quit: exit the program
save: save the current data
transfer: transfer pets to another shelter
option?""")
print(input_option)
if (input_option=="adopt"):
type = input("cats, dogs or all?")
petname = input("pet name?")
flag = False # flag to indicate that pet was not found
for pet in pets:
if type == pet[0] and petname == pet[1]:
pets.remove(pet) # remove this pet from shelter
#removing pet doesn't hurt sorting order
adopted.append(pet) #add this pet to adopted list
# sort adopted list using item 1 that is name of pets
adopted = sorted(adopted, key=itemgetter(1))
# write sorted adopted list back to file in right format
# you can do this in save
with open('adopted.txt', 'w') as fp:
fp.write('\n'.join('%s %s %s' % x for x in adopted))
#also update pets file
with open('pets.txt', 'w') as fp:
fp.write('\n'.join('%s %s %s' % x for x in pets))
flag = True
if not flag:
print("pet not found")
elif(input_option=="intake"):
filename = input("file name?")
file = open(filename, "r")
for line in file:
pets.append(tuple(line.split())) # add all pets in intake to shelter
# sort pets list using item 1 that is name of pets
pets = sorted(pets, key=itemgetter(1))
# write sorted pets list back to file in right format
with open('pets.txt', 'w') as fp:
fp.write('\n'.join('%s %s %s' % x for x in pets))
flag = True
print("sorted list=")
print(pets)
#list all if option is all or selectively list according to type.
elif (input_option == "list"):
type = input("cats, dogs or all?")
if(type=='all'):
for pet in pets:
print(pet)
else:
for pet in pets:
if(type == pet[0]):
print(pet)
elif(input_option=="quit"):
# you can add counters to the above mentioned options and print them
print("print counters here..")
break
elif (input_option == "save"):
print("save")
#implement the save using file writing described above.
elif (input_option == "transfer"):
print("transfer")
file = input("file name?")
#implement like adopted and intake
else:
print("invalid input. choose again")
continue
=========================================================================
OUTPUTS
1) list
2) adopt

pets.txt after adopt

adopted.txt after adopt

3) Intake

pets.txt after intake (taking care of sorted order with names of pets)

Use python write Thank you so much! pets.txt dog alyson 5.5 cat chester 1.5 cat felice...
Java:Netbeans-Use the LinkedList class to simulate a queue, and use the add method to simulate the enqueue, and the remove method to simulate the dequeue method for a Queue. Remember to use FIFO. Need help with 0. Add New Microchips pushMicroChip(), popMicroChip() and . To simulate this, you will create a menu option 0, which will generate 100 microchip long objects, and place them into a stack of microchips. Those microchip objects will be generated by using the System.nanotime() method. ...
please use C++ write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. each line in the file has tile, ..... write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. Each line in...
please use python and provide run result, thank you!
click on pic to make it bigger
For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...
Please try to write the code with Project 1,2 and 3 in
mind. And use java language, thank you very much.
Create an Edit Menu in your GUI
Add a second menu to the GUI called Edit which will have one
menu item called Search. Clicking on search should prompt the user
using a JOptionPane input dialog to enter a car make. The GUI
should then display only cars of that make. You will need to write
a second menu...
// Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...