Question

In: Computer Science

DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1. You just started your...

DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1.

You just started your summer internship with ImmunityPlus based in La Crosse, Wisconsin. You are working with the forecasting team to estimate how many doses of an immunization drug will be needed. For each drug estimation, you will be provided the following information:

corona.txt
39
20
31
10
42
49
54
21
70
40
47
60

- The size of the target population.
- The life expectancy, in years, of an individual in the population.
- A file containing ages, in years, of a sample of 12 people infected in the population.

To calculate the number of doses needed, proceed as follows:

- Calculate the average age of infection from the sample of 12 ages.
- Calculate the Base Reproduction Number (R0): ?0 = ???? ?????????? ??????? / ??? ?? ?????????
- Calculate the Herd Immunity Threshold (Q) ? = 1 − (1 / ?0)
- Calculate the estimated number of doses ????? = ? ∗ ?????????? ????

QUESTION: Construct a program that allows a user to enter the size of the target population, the life expectancy of an individual in the population, and the name of the sample file. Once this information is obtained, perform the above four calculations and output the result of each calculation, appropriately labeled.

Example: Enter population size: 329450000
Enter life expectancy: 78.87
Enter sample file name: corona.txt

Average Age of Infection: 40.25
Base Reproduction Number: 1.959503106
Herd Immunity Threshold: 0.48966654
Doses Required: 161320641.6

Solutions

Expert Solution

  • Complete program is well commented for better understanding.
  • Program follows all the instructions given in question.
  • Snippets of program and corona.txt file are provided below the typed code.
  • Output snippet is also attached below.

Program:

# Obtaining required input information
population_size = int(input("Enter population size: "))
life_expectancy = float(input("Enter life expectancy: "))
file_name = input("Enter sample file name: ")
# opening file with given filename
f = open(file_name)
# extracting file contents in int type by splitting file data and mapping into int
values_list = list(map(int, f.read().split('\n')))

# calculating average age of infection
average_age = sum(values_list)/len(values_list)
# Base reproduction number
R0 = life_expectancy/average_age
# herd immunity threshold
Q = 1 - (1/R0)
# estimate number of doses
e_num_doses = Q * population_size

# printing each calculation result using labels given in sample output
print("Average Age of Infection: ", average_age)
# rounding values accordingly to match with given sample output while printing
# these value rounding can be adjusted easily according to need
print("Base Reproduction Number: ", round(R0, 9))
print("Herd Immunity Threshold: ", round(Q, 8))
print("Doses Required: ", round(e_num_doses, 1))

Program Snippet:

corona.txt:

Output Snippet:

I hope you got the provided solution.

Thank You.


Related Solutions

"""    CS 125 - Intro to Computer Science    File Name: CS125_Lab1.py    Python Programming...
"""    CS 125 - Intro to Computer Science    File Name: CS125_Lab1.py    Python Programming    Lab 1    Name 1: FirstName1 LastName1    Name 2: FirstName2 LastName2    Description: This file contains the Python source code for deal or no deal. """ class CS125_Lab1(): def __init__(self): # Welcome user to game print("Let's play DEAL OR NO DEAL")    # Define instance variables and init board self.cashPrizes = [.01, .50, 1, 5, 10, 50, 100, 250, 500, 1000, 5000,...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
I did the complete programming in python , just want to use tkinter for GUI. please...
I did the complete programming in python , just want to use tkinter for GUI. please look at the 2nd part . i did some part of this program using tkinter but could not finis it. Thank you. import random image = 'w' # modified functions which accepts two numbers each and returns the respective # output def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def kidCalc():...
python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
Name your file “DMx1_Your last name_Your first name.” You can use MS Word to complete the...
Name your file “DMx1_Your last name_Your first name.” You can use MS Word to complete the matrices (go to Insert, Table, Insert table, fill the table). Save the file as a PDF file. If you draw the matrices on paper, take pictures. Make sure the pictures are clear and readable. Insert the pictures in MS Word document and save it as a PDF file. 1. Align using dot matrix: horizontal sequence – AGGCTCCC, vertical sequence – GCGCTCCG. Trace and explain...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file as LASTNAME_FIRSTNAME_M07HW2. (worth 15 points) Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected]. please help!!!!
Using Python You just started your summer internship with NU Bank as part of its growing...
Using Python You just started your summer internship with NU Bank as part of its growing development team. Your first assignment is to design and build two classes that are to be utilized in both the banks website and internal applications. The first is a loan class representing a loan contract. The second is a customer class representing the individual receiving the loan. You will be building the business logic classes, so you don’t have to worry about forms for...
Name your program file warmup.py Submit your working Python code to your CodePost.io account. In this...
Name your program file warmup.py Submit your working Python code to your CodePost.io account. In this challenge, establish if a given integer num is a Curzon number. If 1 plus 2 elevated to num is exactly divisible by 1 plus 2 multiplied by num, then num is a Curzon number. Given a non-negative integer num, implement a function that returns True if num is a Curzon number, or False otherwise. Examples is_curzon(5) ➞ True 2 ** 5 + 1 =...
Complete the following problems using R.  Name the file with your last name, e.g., “Prob set 6-Smith.eoc”Clearly...
Complete the following problems using R.  Name the file with your last name, e.g., “Prob set 6-Smith.eoc”Clearly label problems, and be sure to turn in explanations and interpretations where appropriate. 3.Total cholesterol has been reported to be 200 mg/dL on average in the US by the Centers for Disease Control.  You measure total cholesterol on a random sample of 80 Alabama adults, with the intention of comparing Alabamians’ cholesterol level to that of the US average. Data are included in the assignment...
Your primary task for this exercise is to complete header file by writing three functions with...
Your primary task for this exercise is to complete header file by writing three functions with its description below: removeAt function – to remove the item from the list at the position specified by location. Because the list elements are in no particular order (unsorted list), you could simple remove the element by swapping the last element of the list with the item to be removed and reducing the length of the list. insertAt function - to insert an item...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT