tput 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

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

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:
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:
<generator object converter_gen at ...>
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))
<generator object converter_gen at 0x7fdbde3d7f20>
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))
<generator object converter gen at 0x7fdbdde19350>
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', 'А']
Transcribed Image 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: <generator object converter_gen at ...> 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)) <generator object converter_gen at 0x7fdbde3d7f20> 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)) <generator object converter gen at 0x7fdbdde19350> 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', 'А']
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
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