In python I have  N unique coupons that are included in boxes of the cereal being sold. A consumer wins the contest after collecting N coupons. I seek to simulate the contest with the function couponTrial(N,debug), where ? is the number of coupons and debug is a flag that is set when the function is being debugged. It must include the function and imports the Python random number generator.

Question
Asked Oct 9, 2019

In python I have  N unique coupons that are included in boxes of the cereal being sold. A consumer wins the contest after collecting N coupons. I seek to simulate the contest with the function couponTrial(N,debug), where ? is the number of coupons and debug is a flag that is set when the function is being debugged. It must include the function and imports the Python random number generator.

check_circleExpert Solution
Step 1

All the lines included after the #(hash) are python comments.

To print the N unique coupons:

for loop is used from variable i to N, where i starts with 1 and ends with N.

random.randint() function is used to print N unique coupons. This function can print any random value in the range of 1 to 100000.

Step 2

Program:

#imports the Python random number generator

import random

#included the function

def couponTrial(N,debug):

  if bool(debug==1):

    #displaying message

    print(" Function is being debugged")

    print("The unique coupons that are included in boxes of the cereal are:")

    #for loop from i to N

    for i in range(N):

   &nbs...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Suppose you have two tables: EMPLOYEE and EMPLOYEE_1. The EMPLOYEE table contains the records for th...

A: To display the output of the given tables by using UNION operator.Two tables are given:First Table n...

question_answer

Q: In my C++ program I am trying to have a series of if statements check if a user input is negative, n...

A: To check the input is of the given type (double), use the following:if (cin >> numberOfShares)...

question_answer

Q: 1

A: Different business rules are given in the question which form the entities like Volunteer, Area, Loc...

question_answer

Q: Explain in at least a paragraph what are considered pervasive security infrastructure risks

A: Pervasive security infrastructure refers to cloud security risks. As many users possibly from differ...

question_answer

Q: Write a statement that outputs variable numObjects. End with a newline. Program will be tested with ...

A: Note: The program code is written as per the user requirements.The code is commented well for better...

question_answer

Q: Write an application starting with ProjectTemplate. Name the class AgeCalcApp. The app needs to prom...

A: To write an application name ProjectTemplate with the class name AgeCalcApp. This application prompt...

question_answer

Q: I am completely stumped on this homework question and cannot figure out how to make the range count ...

A: Program Instructions:Use -1 to decrement down the count.The text can be made 5 characters wide by us...

question_answer

Q: Is a honeypot entrapment or is it a way of observing the details of illegal computer activities?

A: Honeypot:A honeypot is a computer security mechanism set up as a decoy for luring malicious attacker...

question_answer

Q: How become a ggod programmer?

A: Good programmer:Becoming programmer is not a big thing; it is all about learning the logics of the p...