Question

In: Computer Science

Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of...

Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of the parameter le This function should return a dictionary that stores all of the parameter le data of the SIR model in a format that we will describe further below.

Solutions

Expert Solution

ANSWER:

As a further any specific programming language to work on the problem is not given, I am using the most common language to work with dictionaries i.e. Python to work on the problem.

I have provided the properly commented and indented code so you can easily copy the code as well as check for correct indentation.
I have provided the output image of the code so you can easily cross-check for the correct output of the code.
Have a nice and healthy day!!

PYTHON CODE

# defining function fnReadInParameters
# takes input string indicating the name of the parameter
def fnReadInParameters(stringInput,*params):
    # converting dict from parameter names from stringInput and params passed
    # in params list
    
    # first fetching all names from stringInput using split method of string
    # spliting string by ,
    paramnames = stringInput.split(",")
    
    # creating dict using dict function of python bu passing key,value pair in it
    # to convert two lists to tuple pairs using zip function of python
    resultdict = dict(zip(paramnames,params))
    
    # return dict
    return resultdict

# calling function fnReadInParameters and displaying result
result = fnReadInParameters("x,y,z",1,2,3)
print("Result:",result)

OUTPUT IMAGE


Related Solutions

Write a function that takes a C string as an input parameter and reverses the string.
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
Write a static method called "evaluate" that takes a string as a parameter
In Java language  Write a static method called "evaluate" that takes a string as a parameter. The string will contain a postfix expression, consisting only of integer operands and the arithmetic operators +, -, *, and / (representing addition, subtraction, multiplication, and division respectively). All operations should be performed as integer operations. You may assume that the input string contains a properly-formed postfix expression. The method should return the integer that the expression evaluates to. The method MUST use a stack...
Python Programming 1. Write a function name split_name which takes one parameter called name. If the...
Python Programming 1. Write a function name split_name which takes one parameter called name. If the name parameter value is a name in the form LastName, FirstName(e.g., ”Grounds, Nic”) then the function should return a list of two elements where FirstName is the first element and LastName is the second element. If the name parameter value is a name in the form FirstName LastName(e.g., ”Nic Grounds”) then the function should return a list of two elements where FirstName is the...
in c++ Write a function that takes a C string as an input parameter and reverses...
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
Write a function named "characters" that takes a string as a parameter and returns the number...
Write a function named "characters" that takes a string as a parameter and returns the number of characters in the input string
Write a function named "replacement" that takes a string as a parameter and returns an identical...
Write a function named "replacement" that takes a string as a parameter and returns an identical string except with every instance of the character "w" replaced with the character "v" My code: function replacement(word){ var str=word; var n=str.replace("w","v"); return n; } Syntax Error: function replacement incorrect on input Not sure how to fix? Can't use a loop for answer
} 1. write a function that takes a string as parameter, return true if it’s a...
} 1. write a function that takes a string as parameter, return true if it’s a valid variable name, false otherwise. You can use keyword module’s  iskeyword() to determine is a string is keyword. import keyword keyword.iskeyword(var)   #returns true or false }2. write a function that returns the length of a string (without using len() function) }3. write a function that counts number of vowels in a string }4. write a function that checks if a word is palindrome PYTHON PROGRAMMING
Java Write a valid Java method called printReverse that takes a String as a parameter and...
Java Write a valid Java method called printReverse that takes a String as a parameter and prints out the reverse of the String. Your method should not return anything. Make sure you use the appropriate return type.
Write a function called remove_punct() that accepts a string as a parameter, removes the punctuation (',',...
Write a function called remove_punct() that accepts a string as a parameter, removes the punctuation (',', '!', '.') characters from the string, and returns the number of punctuation characters removed. For example, if the string contains ['C', 'p', 't', 'S', ',', '1', '2', '1', '.', 'i', 's', 'f', 'u', 'n', '!', '\0'], then the function should remove the punctuation characters. The function must remove the characters by shifting all characters to the right of each punctuation character, left by one...
C++ Write a function called linearSearch that takes an array as a parameter and search for...
C++ Write a function called linearSearch that takes an array as a parameter and search for a specific value inside this parameter. The function returns the frequency of a specific value in the array. In the main function: 1. Define an array called salaries of length 5. 2. Initialize the array by asking the user to input the values of its elements. 3. Define a variable called key and ask the user to enter a value for this variable. 4....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT