urpose: To practice reading from a tabular file to a simple dictionary Degree of Difficulty: Easy. Before starting this question, first, download the data file parameters.txt from the class Moodle. Mak ure to put it in the same folder as your a6.py python code. Vrite a function called fnReadInParameters () that takes as parameter(s): · a string indicating the name of the parameter file his function should return a dictionary that stores all of the parameter file data of the SIR model in a forma hat we will describe further below. nput File Format he data file for this question looks like this: amma, 14.0 eta_normal, 0.2 eta_intervention, 0.1 imulation_days, 540 , 10000 ach line of the file contains a name-value pair of a parameter. The first item of a line is always the param ter's name. It is clear that names of parameters are unique. The second item is always the value of th arameter in the same line Allof the data items of each line are separated by cor as The function

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Purpose: To practice reading from a tabular file to a simple dictionary
Degree of Difficulty: Easy.
Before starting this question, first, download the data file parameters.txt from the class Moodle. Make
sure to put it in the same folder as your a6.py python code.
Write a function called fnReadInParameters () that takes as parameter(s):
· a string indicating the name of the parameter file
This function should return a dictionary that stores all of the parameter file data of the SIR model in a format
that we will describe further below.
Input File Format
The data file for this question looks like this:
gamma, 14.0
beta_normal, 0.2
beta_intervention, 0.1
simulation_days, 540
N, 10000
Each line of the file contains a name-value pair of a parameter. The first item of a line is always the param-
eter's name. It is clear that names of parameters are unique. The second item is always the value of the
parameter in the same line. All of the data items of each line are separated by commas. The function of
"fnSperateLine()" created in Q1 should be called to process lines of the read in file.
Transcribed Image Text:Purpose: To practice reading from a tabular file to a simple dictionary Degree of Difficulty: Easy. Before starting this question, first, download the data file parameters.txt from the class Moodle. Make sure to put it in the same folder as your a6.py python code. Write a function called fnReadInParameters () that takes as parameter(s): · a string indicating the name of the parameter file This function should return a dictionary that stores all of the parameter file data of the SIR model in a format that we will describe further below. Input File Format The data file for this question looks like this: gamma, 14.0 beta_normal, 0.2 beta_intervention, 0.1 simulation_days, 540 N, 10000 Each line of the file contains a name-value pair of a parameter. The first item of a line is always the param- eter's name. It is clear that names of parameters are unique. The second item is always the value of the parameter in the same line. All of the data items of each line are separated by commas. The function of "fnSperateLine()" created in Q1 should be called to process lines of the read in file.
Your function should open the file given as a parameter and read the data from it into a dictionary. The
keys for this dictionary will be the parameter names, and the values of this dictionary will be the values of
the corresponding parameters.
The data type of the keys in this dictionary is always strings. However, each entry's data type of the value
in the dictionary is different:
The type of the value of parameter "gamma", is a float.
• The type of the value of parameter "beta_normal", is a float.
• The type of the value of parameter "beta_intervention", is a float.
• The type of the value of parameter "simulation_days', is an integer.
The type of the value of parameter "N", is a float.
Once the dictionary is built, the function should return it.
Transcribed Image Text:Your function should open the file given as a parameter and read the data from it into a dictionary. The keys for this dictionary will be the parameter names, and the values of this dictionary will be the values of the corresponding parameters. The data type of the keys in this dictionary is always strings. However, each entry's data type of the value in the dictionary is different: The type of the value of parameter "gamma", is a float. • The type of the value of parameter "beta_normal", is a float. • The type of the value of parameter "beta_intervention", is a float. • The type of the value of parameter "simulation_days', is an integer. The type of the value of parameter "N", is a float. Once the dictionary is built, the function should return it.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education