The output should match with the provided test cases below. converter_gen takes a generator object scores (which is iterable) and converts all the randomly generated scores between 0 and 100 to...


The output should match with the provided test cases below. converter_gen takes a generator object scores (which is iterable) and converts all the randomly generated scores between 0 and 100 to corresponding letter grades as follows: · [0-59) --> 'F' . (60-69] --> 'D 70-79 --> C [80-89) --> 'B [90-100] --> 'A' converter_gen function would cover scores between 0 and 100 only. It assumes that the scores in the input argument scores are between 0 and 100 (no validation is required). Both generator functions should use yiled to return the generated scores/grades. NOTE: . Your generator functions must return the scores/grades using yield statement and should match with the provided output: to be considered as a generator function. • The memory location and random numbers, of course, would be different in each execution




Write a pipeline of two generator functions random_gen and converter_gen as specified below:<br>random gen takes two int numbers m andn as arguments (no validation is required) and generates m random integer<br>numbers between 0 and n inclusive [0, n].<br>You may use random.randint() function to get random integers.<br>Each time a random score is generated, it should be printed with the following message:
'F' • [60-69] --> 'D' [70-79] --> 'C' [80-89] --> 'B' [90-100] --> 'A' converter gen function would cover scores between 0 and 100 only. It assumes that the scores in the input argument scores are between 0 and 100 (no validation is required). Both generator functions should use yiled to return the generated scores/grades. NOTE: Your generator functions must return the scores/grades using yield statement and should match with the provided output: to be considered as a generator function. The memory location and random numbers, of course, would be different in each execution. • Non-generator solutions and solutions that do not match with the format of the output of the provided test cases will get ZERO points. In [480]: import random def random_gen (m, n) : ... generatesm random integer numbers between 0 and n def converter_gen(scores): ''' converts the numeric scores to letter grades ... In [434]: random_grades = converter_gen (random_gen ( 3, 100)) In [435]: print (random_grades) print (list (random_grades)) Next random score is: 77 Next random score is: 98 Next random score is: 11 ['C', 'A', 'F'] In [495]: random_grades = converter_gen (random_gen (5, 100)) In [496]: print (random_grades) print (list (random_grades)) Next random score is: 80 Next random score is: 58 Next random score is: 35 Next random score is: 83 Next random score is: 94 ['"В', 'F', "F', 'B', 'А'] "/>
Extracted text: Write a pipeline of two generator functions random_gen and converter_gen as specified below: random gen takes two int numbers m andn as arguments (no validation is required) and generates m random integer numbers between 0 and n inclusive [0, n]. You may use random.randint() function to get random integers. Each time a random score is generated, it should be printed with the following message: "Next random score is:" followed by the yielded random score. The output should match with the provided test cases below. converter_gen takes a generator object scores (which is iterable) and converts all the randomly generated scores between 0 and 100 to corresponding letter grades as follows: • [0-59] --> 'F' • [60-69] --> 'D' [70-79] --> 'C' [80-89] --> 'B' [90-100] --> 'A' converter gen function would cover scores between 0 and 100 only. It assumes that the scores in the input argument scores are between 0 and 100 (no validation is required). Both generator functions should use yiled to return the generated scores/grades. NOTE: Your generator functions must return the scores/grades using yield statement and should match with the provided output: to be considered as a generator function. The memory location and random numbers, of course, would be different in each execution. • Non-generator solutions and solutions that do not match with the format of the output of the provided test cases will get ZERO points. In [480]: import random def random_gen (m, n) : ... generatesm random integer numbers between 0 and n def converter_gen(scores): ''' converts the numeric scores to letter grades ... In [434]: random_grades = converter_gen (random_gen ( 3, 100)) In [435]: print (random_grades) print (list (random_grades)) Next random score is: 77 Next random score is: 98 Next random score is: 11 ['C', 'A', 'F'] In [495]: random_grades = converter_gen (random_gen (5, 100)) In [496]: print (random_grades) print (list (random_grades)) Next random score is: 80 Next random score is: 58 Next random score is: 35 Next random score is: 83 Next random score is: 94 ['"В', 'F', "F', 'B', 'А']

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here