Question: The program CANNOT: 1 ) Change any given code unless instructed otherwise. 2 ) Use the break and / or continue statements. Instrusctions - -

The program CANNOT:
1) Change any given code unless instructed otherwise.
2) Use the break and/or continue statements.
Instrusctions--- each 1 is a different set of code that needs to be written
1) Use the Repetition Operator to define and initialize a list named "dice" that has a length of constant NUMBER_OF_DICE and that contains all zeros (0).
1) Using the range function, write a for-loop that iterates from zero (0) to one (1) fewer than constant NUMBER_OF_DICE inclusive.
2) Code block for the for-loop in Step 1:
A) Write a statement that uses the loop control variable in Step 1 to index into list "dice", assigning each element of the list the following expression: random.randint(MIN_NUMBER_ON_DIE, MAX_NUMBER_ON_DIE)
1) Using the range function, write a for-loop that iterates from zero (0) to one (1) fewer than constant UPPER_CATEGORY_UPPER_BOUND inclusive.
2) Code block for the for-loop in Step 1:
A) Write an if-statement that checks each element of parameter tuple "tScores" for "inequality to"(not equal to) constant
SCORE_NO_VALUE. Use the loop control variable in Step 1 to index into tuple "tScores".
B) Code block for the if-statement in Step 2A:
a) Write a statement that accumulates the associated tuple element from parameter tuple "tScores" into local variable "score".
1) Using the range function, write a for-loop that iterates from constant UPPER_CATEGORY_UPPER_BOUND to one (1) fewer than constant LOWER_CATEGORY_UPPER_BOUND inclusive.
2) Code block for the for-loop in Step 1:
A) Write an if-statement that checks each element of parameter tuple "tScores" for "inequality to"(not equal to) constant SCORE_NO_VALUE. Use the loop control variable in Step 1 to index into tuple "tScores".
B) Code block for the if-statement in Step 2A:
a) Write a statement that accumulates the associated tuple element from parameter tuple "tScores" into local variable "score".
1) Using the range function, write a for-loop that iterates from zero (0) to one (1) fewer than constant NUMBER_OF_DICE inclusive.
2) Code block for the for-loop in Step 1:
A) Write an if-statement that checks each element of parameter tuple "tDice" for "equality to"(equal to) parameter variable "dieNumber". Use the loop control variable in Step 1 to index into tuple "tDice".
B) Code block for the if-statement in Step 2A:
a) Write a statement that accumulates the associated tuple element from parameter tuple "tDice" into local variable "score". Alternately, Step 1 can be written using the "in" operator instead of using the range function, and then Step 2 can be written in a manner not using list indexing.
1) Write a for-loop that iterates over parameter tuple "tDieCount" using the "in" operator instead of using the range function and list indexing.
2) Code block for the for-loop in Step 1:
A) Write an if-statement whose condition checks the VALUE of each element in parameter tuple "tDieCount" for "equality to"(equal to) parameter variable "nKind".
B) Code block for the if-statement in Step 2A:
a) Assign True to the local variable "isNKind".
C) Write an elif-statement 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 to"(equal to) False.
D) Code block for the elif-statement in Step 2C:
a) Assign True to the local variable "isNKind".
3) Not connected to nor nested within the code in Steps 1 and 2, write an if-statement that checks the local variable "isNKind" for "equality to"(equal to) True.
4) Code block for the if-statement in Step 3:
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 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 Programming Questions!