Question: in python code: Part 1 : ( a ) Create the set of positive integers. For this assignment, you may use the following set: s
in python code:
Part :
a Create the set of positive integers. For this assignment, you may use the following set:
s
b Prompt the user to guess the elements of the set using a for or while loop. You can assume the user will provide an integer you do not need to do input validation
a Terminating Conditions:
i The user has a maximum number of guesses ie inputs equal to times the number of elements of the set. Once the user has used all their guesses, the loop terminates. In other words, the number of inputs provided by the user will be less than or equal to times the number of elements in the set. You must use the len function as part of this determination.
ii If the user correctly guesses all the numbers, the game should end prematurely.You must use a break statement for this.
b After a user makes a guess
i When a user correctly guesses a number, a message is displayed indicating that the guess was correct, and the number is removed from the set
ii If the user does not guess correctly, a message is displayed indicating the guess was NOT correct. Note: If a user previously guessed a number, then guesses the same number again, their guess is NOT correct even if it was previously correct Hint: This can be accomplished using a for or while loop
c At the end of guessing,
a If the user has correctly guessed all of the numbers hint if there are no more numbers in the set then a message is displayed indicating that the user wins.
b If the user has MISSED any members of the set, then a message is
displayed that tells the user which members of the set were missed
Part :
a At the start of the game, create an additional, empty set
b Use this second set to track correct guesses ie add the value to the new set if the user makes
a correct guess in Part b
c Whenever the user guesses an answer that they have previously guessed, and the previous guess was correct print a message to indicate that the user has previously guessed this correct answer hint: this condition can trigger if the users guess is in the second set
a Note: This message will appear instead of the messages from Part bb
b Note: This still counts against their total number of guesses
c Note: This condition should NOT trigger if the value was previously guessed but was NOT correct, ie if the value has never been in s
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
