Question: Design a function called is _ parfect that takes a whole number ( greater than zero ) . The function should determine whether the given
Design a function called isparfect that takes a whole number greater than zero The function should determine whether the given number is a perfect number.
Perfect number definition taken from Wikipedia:
In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, has divisors and excluding itself and so is a perfect number."
Design a function called nperfectnunber's that takes a nonnegative integer n The function should return a string containing the first perfect numbers.
Think simple, repeatedly check one number at a time to see if it is a perfect number, if it is append it to the sequence, if it is not, do not append it to the sequence. Repeat this until you have n numbers appended to the sequence.
The call nperfactnutbers e should return the string:
The call nperfectnumbers should return the string:
The call nperfectnurbers should return the string:
The returned string must be formatted exactly as demonstrated in the examples, with commas between values and no additional white space or trailing commas.
NOTE: you may not use the following Python String functions: join, strip, rstrip, strip
NOTE: This algorithm will require a lot of computation and be very slow as n gets bigger.
Part
In this part of the assignment you are going to write a set of functions that will simulate part of a player version of the dice game Bunko. The specification for our Bunko version is below.
We have provided you with a function rolonedie in the
assignentpy starter file. You must call this rollonedie function provided when your program needs to roll a dice. Our automated tester will depend on you calling this function. See the comment within the rollonedie function definition for help with testing versus running a realistic version of the function. When submitting, you should have uncommented the call to rardor. randint and commented out the call to input.
TESTING NOTE: You can omit the examples from your docstring as these kinds of functions that cutput escape sequences are hard to test using doctest. You should still test your functions by calling them from your shell with different inputs before subrritting. You should still have a docstring with a purpose statement.
To encourage good software development practices we are requiring you to design a specified set of helper functions in your implementation. You are free to include additional functions, but to receive full marks your implementation must include and adhere to the following function specifications including function names and order of arguments.
Design the function taketurn that takes the following three arguments:
o the name of the player taking the turn
o the current number of points the player has in the current round
o the round number being played which is the target value and is guaranteed to be a number from to inclusive The function should repeatedly simulate the roll of the three dice, calculate the roll score and add the roll score to the players current points. The function will continue to do this until the player has a roll score that is worth or the player has accrued at least total points.
The function should return the updated total number of points the player has accrued.
The scoring for the three dice roll is as follows:
if all three dice match the target value the round number a score of is awarded
o if all three dice are the same but do not match the target value the round number a score of is awarded
if less than three dice match the target value the round number a score of point for each dice matching the target is awarded
Example:
calling the function as taketurnuchenna MacAoidh', a a sample fun:
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
