Question: Write a script that prints a randomly generated integer between 1 and 6. When I run your script, it should print out only the number

  1. Write a script that prints a randomly generated integer between 1 and 6. When I run your script, it should print out only the number that would appear on the die like this: 5 and nothing else.
  2. Write a script that takes input for the number of sides on the die. An n sided die should return a random integer between 1 and n with the same stipulations as in Exercise 1. You should take n from the user as typed input. Output should be the same as in #1.
  3. Write a script that takes input for the number of dice to roll and for the number of sides for the dice. Roll that many n-sided dice and store the values an array. Take the number of sides of the dice and the number of dice as typed inputs from the user. Output should be a comma separated list of the die numbers with no spaces like this: 6,4,1,3,1
  4. HARD: Write a script that will simulate the roll of an UNFAIR 6-sided die. Instead of each side having an even chance of coming up (1/6 = 16.7%), the middle numbers should be favored. There should be a 20% chance of rolling a 2, 3, 4, or 5, and only a 10% chance of rolling a 1 or a 6. Hint: You will need the round function and some other simple math. This is hard because of the thinking involved, not because of the coding; in fact, you can write it in one (sort of complex) line of code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!