Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

Part I

Use these libraries and global variables that should remain immutable (they're "constants") - you MUST use these constants in your code so if they're changed, everything will still work as it should. Your code should handle four 20-sided die rolled nine times per test just as easily as five 6-sided die rolled three times per test.

Define a class called 3 (singular for "dice") that will have the following methods:

++ ++0 %) (+%+ 1 creates a 3 object with the given number of sides (for example, +53061 a "normal" 6-sided die, or +5301 for a gamer's 20-sided die.

It should even be able to handle an odd number, such as a 17-sided die! We are not limited by the need for physical symmetry here.

(0 %1 will roll the 3 based on the number of sides and assigns the value rolled to a "hidden" variable - a positive integer from 1 to the number of sides. For example, a 6-sided 3 will generate and return a value from 1 to 6.

1 will generate a random integer whose value is equally likely to be any integer from 1 through 100, including both 1 and 100.

0 %1 will return an integer, the current value of the die as it was last rolled. If the die has never been rolled, it should return a value of .

Also, in your "main" code at the bottom of the Python module, write Python code to create a list called

+. whose items are 3 objects. This

+. list will represent the dice in your main executable code, and must match the requirements for the +. parameter for the pre-written functions.

Part II

Using 3 objects as defined above, you will define the function called

+

>0+.1

(much like

+ 01 in the previous project), that will perform the simulation as specified below.

The function will return =( if the outcome is a Yahtzee, and ' if it is not.

In the game of Yahtzee, a player rolls dice. In your function, the player will try to get a Yahtzee by

following these rules:

(1) For the first roll, roll all the dice

(2) Determine which value is on the most dice, and set those dice aside so they won't be re-rolled

(3) Re-roll all the dice that weren't set aside

(4) Repeat steps (2) and (3) until you're out of rolls (in Yahtzee, it's a maximum of 3 rolls)

(5) If, after the rolls, all the dice have the same value, you have a Yahtzee! If not, then you don't.

Consider the following code to print the values of all your dice to the screen. The parameter +. is a list of 3 objects - notice how each die is represented by ^^ this is part of the homework.

Python, Programming

  • Category:- Python
  • Reference No.:- M91771634
  • Price:- $75

Priced at Now at $75, Verified Solution

Have any Question?


Related Questions in Python

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Foundations of programming assignment - feduni bankingthis

Foundations of Programming Assignment - FedUni Banking This assignment will test your skills in designing and programming applications to specification. Assignment Overview - You are tasked with creating an application t ...

Question why is software configuration management

Question : Why is software configuration management considered an umbrella activity in software engineering? Please include examples and supporting discussion. The response must be typed, single spaced, must be in times ...

Project reconnaissance and attack on ics

Project: Reconnaissance and Attack on ICS NetworksEnvironment Setup The second mini project will be based on Industrial Network Protocols, specifically the Modbus protocol. Please follow the instructions carefully to set ...

Environment setupthe first mini project will be based on

Environment Setup The first mini project will be based on Ladder Logic programming. We will be using Schneider Electric's IDE called SoMachine Basic to do the programming. The latest ver- sion of SoMachine Basic for Wind ...

Question research pythons dictionary data type dictdiscuss

Question : Research Python's dictionary data type (dict). Discuss its interface and usage. Include examples. Discuss practical applications of dictionaries.

Learning outcomes lo3 - research develop and document a

Learning Outcomes LO3 - Research, develop, and document a basic security policy, and analyse, record, and resolve all security incidents LO4 - Identify and assess the threats to, and vulnerabilities of networks Assessmen ...

Homework -this homework will have both a short written and

Homework - This homework will have, both a short written and coding assignment. The problems that are supposed to be written are clearly marked. 1) (Written) Make heuristics Describe two heuristics for the slide problem ...

The second task in this assignment is to create a python

The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes after a series of flips.(PYTHON 3) Problem Task In this problem, your input w ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As