Determine which value is on the most dice

Assignment Help Python Programming
Reference no: EM131047200

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.

Reference no: EM131047200

Questions Cloud

Find the slope of the tangent lines : Find dy/dx and the slope of the tangent lines shown on the graph of the polar equation- r = 2 + 3 sin(θ)
Compare and contrast the newly revised ghs : Compare and contrast the newly revised GHS-based requirements for information on Safety Data Sheets (SDS) in 29 CFR 1910.1200 with the previous HazCom Standard requirements for information on Material Safety Data Sheets (MSDS).
The company provides health insurance : Doug, age 40, is the owner of a small firm that sells window blinds and cleans carpets. The company provides health insurance for seven employees. The wife of one employee has breast cancer and has incurred substantial medical bills, which resulte..
Onset of the menstrual cycle : You are the nurse providing care for a client reporting symptoms of bloating, irritability, and breast 1) tenderness. The symptoms recur monthly about 3 weeks after the onset of the menstrual cycle.
Determine which value is on the most dice : Determine which value is on the most dice, and set those dice aside so they won't be re-rolled. Repeat steps (2) and (3) until you're out of rolls (in Yahtzee, it's a maximum of 3 rolls)
Group term life insurance and group universal life : Group term life insurance and group universal life insurance have different characteristics and objectives. Compare (1) group term insurance with (2) group universal life insurance with respect to each of the following:
Design of new products using decide framework : What is the Importance of Evaluation in the Creation and Design of New Products using DECIDE framework?
Plan an e-commerce site for a real or hypothetical business : Plan an e-commerce site for a real or hypothetical business and implement the site using open source tools. Students are to present their plan and implementation in an oral presentation using PowerPoint and in a written summary.
Major issues with wegmans food markets : How to resolve major issues with wegmans food markets? Must include (1) operations management technique (2) method of application (3) evaluation plan.

Reviews

Write a Review

Python Programming Questions & Answers

  Console program where you will implement

Create a console program where you will implement coding constructs and variables that are needed for this program and will implement the code within Main and any required static methods.

  Recursive sorts are easier to write in functional style

Recursive sorts are easier to write in functional style than others. Two recursive sorts are  Quicksort and Mergesort. Write functional versions of (a) Quicksort; (b) Mergesort in an  imperative language of your choice (e.g., C, Ada, C++, Python), us..

  Calculate the accuracy of your linear classifier

Plot X,Y and the decision boundary. Make sure that you use a good plotting technique so that it is easy to distinguish which datapoint is X and which is Y. Calculate the accuracy of your linear classifier.

  Given the strings s1 and s2 that are of the same length

Given the strings s1 and s2 that are of the same length, create a new string consisting of the first character of s1 followed by the first character of s2, followed by the second character of s1, followed by the second character of s2, and so on (in ..

  Assume that the variables gpa , deanslist and studentname

Assume that the variables gpa , deansList and studentName , have been initialized. Write a statement that adds 1 to deansList and prints studentName to standard out if gpa exceeds 3.5.

  Make a python program that uses the getcwd

Make a Python program that uses the getcwd() function to provide a string of the current working directory. Save the string in the variable current folder and display the value.

  Grade that will calculate and return a student''s exam

Write a function overall Grade that will calculate and return a student's 2316 exam average. It will accept five parameters, which correspond to exam1,2,3,4 and the Final grade. It should replace the lowest exam grade with the 2nd lowest exam grade

  Ida to reverse engineer a piece of shellcode

You are a Malware Investigator at 0xC0ff33, Inc and an incident responder came across injected shellcode during an investigation. He has done all he can in IDA and has passed on the .idb file to you. Figure out what the purpose of the malware was ..

  Write a program that does simple packet routing

Write a program that does simple packet routing and your program will take three command-line arguments:

  The interest rate per period

The interest rate per period. For example, if your loan's interest is 6.5% per year, and you are paying monthly, this would be 6.5%/12. If you are paying every two weeks, r would be 6.5%/26, because there are 26 two-week periods in a year.

  Create a ride share simulator assignment

Create a ride share simulator assignment. In this particular function, I am trying to create a list of the drivers in a Driver Class that are currently listed as idle. Since they are idle, I can then match them up with an awaiting rider. The assignme..

  Write a program that reads the name of a data file

Write a program that reads the name of a data file which contains student ids (such as c1234500) and their scores. The program will find and print the average score, the number of students processed.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd