Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The question is: \"You are going to create some vet records for three animals at

ID: 3681172 • Letter: T

Question

The question is:

"You are going to create some vet records for three animals at a vet clinic. You will store all records as a list of lists. Each vet record must consist of an integer ID number, a pet name, a pet species, and owner first name and last name.

The record should be a list of the form [ ID, name, species, owner_first, owner_last ]

Your program should ask the user to enter three records. It should then display all the records in a pretty table. You may reuse some of your or your partner’s old lab/hwk code for exercise 2 instead of writing it all from scratch.

You are required to write a function named getNewVetRecord. It does not take any parameters. It has ONE return value, a single record (one list). As the user is entering data for the records, you must validate it. Valid IDs are integer numbers, not strings, not floats.

Valid names and species strings must contain letters, no numbers. In other words, they should NOT be string you can convert to numbers. Hint: Try looking up isdigit(), isalpha(), and similar string fuctions.

You are required to write a function named getInteger. It takes one parameter, the prompt for the user (for example “pet ID: ”). It has one return value, an integer (NOT a string). It is required to contain a validation loop. You are required to write a function named getValidString. It takes one parameter, the prompt for the user (for example “pet name: ”). It has one return value, a string that is NOT convertible to a number. Again, this function must use a validation loop. You do NOT have to make sure that all ID numbers are unique for this exercise. In a real life, on the job, you would be expected to verify that. "

I have written a code for this part but it is not working. Please help me fix the following code. (Python 3.5) (Don't use break function). Here is my code:

def getNewVetRecord():

getNewVetRecord=[]

return getNewvetRecord

def getInteger(prompt):

Ask_for_value = True

while Ask_for_value != False:

try:

ID = int(input(prompt))

Ask_for_value = False
  

except ValueError:

print("Please enter an integer")

return ID

def getValidString(prompt):

Ask_for_value = True

Input_String = ("")

while Ask_for_value != True:

Input_String = input(prompt)

Ask_for_value = Input_String.isalpha()

if ask_for_value == False:

print("Please enter a valid name")
return Input_String

Explanation / Answer

VetRecords=[[],[],[]]
def getInteger():
    Ask_for_value = True
    while Ask_for_value != False:
        try:
            ID = int(input())
            Ask_for_value = False
        except ValueError:
            print("Please enter an integer")
    return ID

def getValidString():
    Ask_for_value = True
    Input_String = ("")
    while Ask_for_value != False:
        Ask_for_value = False
        Input_String = input()
        Ask_for_value = Input_String.isalpha()
        if Ask_for_value == False:
            print("Please enter a valid name")
        else:
            return str(Input_String)   
def getNewVetRecord():
    i=0
    id=0;
    pet_name=""
    pet_species=""
    first_name=""
    last_name=""
    while (i<2):
        print "Enter id"
        id=getInteger()
        VetRecords[i].append(id)
        print "Enter pet name"
        pet_name=getValidString()
        VetRecords[i].append(pet_name)
        print "Enter pet species"
        pet_species=getValidString()
        VetRecords[i].append(pet_species)
        print "Enter owner first name"
        first_name=getValidString()
        VetRecords[i].append(first_name)
        print "Enter owner last name"
        last_name=getValidString()
        VetRecords[i].append(last_name)
        i=i+1
    print VetRecords
getNewVetRecord()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote