Question: In my program I am trying to generate a random sequence of numbers when the user enters an applicant id and residency program. For the

In my program I am trying to generate a random sequence of numbers when the user enters an applicant id and residency program. For the first iteration the program works fine but if the user decides to enter a new applicant id and residency program this is where my problem occurs.

The program generates 8 random numbers from 1-10 after receiving input from the user. So, after running my code below and inputting what it asks you to, you should get a random sequence of numbers like 6 7 3 4 5 3 1 8 or any other variation from 1-10. This is fine, however, when the program runs again and the user inputs different values and a new sequence of numbers is generated they are added on to the previous sequence of numbers. For example, the 8 numbers I listed earlier 6 7 3 4 5 3 1 8 would appear first, followed by the new sequence of 8 numbers. I don't want this, I just want a new sequence of 8 numbers to appear without the previous sequence of numbers. Any help would be greatly appreciated. This program was made with python and my code is as appears below.

import random num_interviewers = 8 sum_scores = 0 scores = [] end_loop = False def main(): for i in range(num_interviewers): scores.append(random.randint(1, 10)) while not end_loop: id_applicant = int(input("Enter the id of the applicant: ")) res_program = input("Enter the desired residency program: ") average = sum(scores) / len(scores) print("interviewers scores: " + ' '.join(map(str, scores))) print("Average is:", average) if average >= 7: print("Applicant", id_applicant, "is accepted in the", res_program, "residency program.") elif 5 <= average < 7: print("Applicant", id_applicant, "wil be matched with an available residency spot.") else: print("Applicant", id_applicant, "is not accepted into the residency program at this time") next_applicant = input("Would you like to continue? ") if next_applicant == "yes": 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!