Question: The program CANNOT: 1 ) Change any given code unless instructed otherwise. 2 ) Use the break and / or continue statements. Instrusctions - -
The program CANNOT:
Change any given code unless instructed otherwise.
Use the break andor continue statements.
Instrusctions each is a different set of code that needs to be written
Use the Repetition Operator to define and initialize a list named "dice" that has a length of constant NUMBEROFDICE and that contains all zeros
Using the range function, write a forloop that iterates from zero to one fewer than constant NUMBEROFDICE inclusive.
Code block for the forloop in Step :
A Write a statement that uses the loop control variable in Step to index into list "dice", assigning each element of the list the following expression: random.randintMINNUMBERONDIE, MAXNUMBERONDIE
Using the range function, write a forloop that iterates from zero to one fewer than constant UPPERCATEGORYUPPERBOUND inclusive.
Code block for the forloop in Step :
A Write an ifstatement that checks each element of parameter tuple "tScores" for "inequality tonot equal to constant
SCORENOVALUE. Use the loop control variable in Step to index into tuple "tScores".
B Code block for the ifstatement in Step A:
a Write a statement that accumulates the associated tuple element from parameter tuple "tScores" into local variable "score".
Using the range function, write a forloop that iterates from constant UPPERCATEGORYUPPERBOUND to one fewer than constant LOWERCATEGORYUPPERBOUND inclusive.
Code block for the forloop in Step :
A Write an ifstatement that checks each element of parameter tuple "tScores" for "inequality tonot equal to constant SCORENOVALUE. Use the loop control variable in Step to index into tuple "tScores".
B Code block for the ifstatement in Step A:
a Write a statement that accumulates the associated tuple element from parameter tuple "tScores" into local variable "score".
Using the range function, write a forloop that iterates from zero to one fewer than constant NUMBEROFDICE inclusive.
Code block for the forloop in Step :
A Write an ifstatement that checks each element of parameter tuple "tDice" for "equality toequal to parameter variable "dieNumber". Use the loop control variable in Step to index into tuple "tDice".
B Code block for the ifstatement in Step A:
a Write a statement that accumulates the associated tuple element from parameter tuple "tDice" into local variable "score". Alternately, Step can be written using the in operator instead of using the range function, and then Step can be written in a manner not using list indexing.
Write a forloop that iterates over parameter tuple "tDieCount" using the in operator instead of using the range function and list indexing.
Code block for the forloop in Step :
A Write an ifstatement whose condition checks the VALUE of each element in parameter tuple "tDieCount" for "equality toequal to parameter variable "nKind".
B Code block for the ifstatement in Step A:
a Assign True to the local variable "isNKind".
C Write an elifstatement whose condition is made of two Boolean expressions joined by the Boolean "and" operator:
a The first Boolean expression checks the VALUE of each element in parameter tuple "tDieCount" for "greater than or equal to parameter variable "nKind".
b The second Boolean expression checks parameter variable "exactFlag" for "equality toequal to False.
D Code block for the elifstatement in Step C:
a Assign True to the local variable "isNKind".
Not connected to nor nested within the code in Steps and write an ifstatement that checks the local variable "isNKind" for "equality toequal to True.
Code block for the ifstatement in Step :
A Call function "sumAllDice" passing parameter tuple "tDice" as an argument.
a Assign this function call to local variable "score".
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
