Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Python Programming Language Question 2 ( a ) A genRandomintSeq ( m ) function is defined as below, to generate a sequence of integers
Use Python Programming Language
Question
a
A genRandomintSeq m function is defined as below, to generate a sequence of
integers from until
# Importing random function from random module
# that generates a floating number from
# including but not
from random import random
def genRandomintSeq m :
# There are errors in the codes below
set
while True:
# Generate a random integer from
if i not in :
s add i
yield i
When the function is used in codes below, a sequence of five integers should be
printed in random order, for example, "RandomlntSeq
# There is no error in the codes below
print RandomIntSeq end
for in genRandomintseq :
print end
print
Since there are some errors in how the function is defined, the expected output is not
obtained. What is the output with the current erroneous codes? Explain why such
output is obtained instead. Give the corrected codes, how the function should be
defined, so that the correct output for example, "RandomintSeq can be
obtained.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started