Question

In: Computer Science

- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are...

- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are working and 1 program (Python). Explainthe intent of the pseudocode / program. If you use test data, note the test data.  .  You are NOT trying to find mistakes.


Use this textbox to explain the pseudocode/ code intent. Include any test data used:

What does this do? Desk Checking #4:  Explain the intent of this code.  Be as specific as possible.  
List the data you use for example data.

import random

number = random.randint(1, 10)

keepGoing = input("Do you want to guess a number? Enter Y or N ")

while (keepGoing != "Y") and (keepGoing != "N"):

    keepGoing = input("Invalid Response." + " Please type Y or N. ")

while keepGoing == "Y":

    

    stringNumber = input("I'm thinking of a number. .\n Try to guess by entering a number between 1 and 10 ")

    userNumber = int(stringNumber)

    

    while (userNumber < 1) or (userNumber > 10):

        stringNumber = input("Number must be in the range of 1 to 10: Please try again: ")

        userNumber = int(stringNumber)

    if userNumber == number:

        keepGoing = "N"

        print("You are a genius. That's correct!")

    else:

        keepGoing = input("That's not correct. Do you want to guess again? Enter Y or N ")

        

        while (keepGoing != "Y") and (keepGoing != "N"):

            keepGoing = input("Invalid Response." + " Please type Y or N. ")

Solutions

Expert Solution

The program imports the module random at first inorder to use the random function.Using the random function a number between 1 to 10 is generated and this is stored in the variable number. This arguments of the random function is the range.Here it is 1 to 10.This is assigned to number

lets assume number=4

Then the screen prompts the user with the following message

Do you want to guess a number?Enter Y or N

if the user inputs anything other than Y or N then the following message is displayed.

Invalid Response. Please typeY or N.

if the user inputs Y then the following steps are executed.(This is checked using the while loop.)

following message is displayed on the screen.

I'm Thinking of a number..

Try to guess a number between 1 and 10.

example : if it is 4

usernumber=4

while loop is checked to see if usernumber<1 or usernumber>10.(displays Number must be in the range of 1 to 10 .try again)here the condition is not satisfied.

checks if usernumber=number(checks if usernumber = system generated number)

here it is satisfied 4=4

so displays You are a genius.That's correct!

else the message displays as That's not correct. Do you want to guess again?Enter Y or N.

if it is Y then the above steps are executed.Else

if the user inputs anything other than Y or N then the following message is displayed.

Invalid Response. Please typeY or N.

if it is N then program Ends


Related Solutions

- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are...
- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are working and 1 program (Python). Explainthe intent of the pseudocode / program. If you use test data, note the test data.  .  You are NOT trying to find mistakes. What does this do? Desk Checking #2:  Explain the intent of this pseudocode.  Be as specific as possible. List the data you use as the example data. Use this textbox to explain the pseudocode/ code intent. Include any test...
- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are...
- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are working and 1 program (Python). Explainthe intent of the pseudocode / program. If you use test data, note the test data.  .  You are NOT trying to find mistakes What does this do? Desk Checking #3:  Explain the intent of this pseudocode.  Be as specific as possible.   List the data you use for example data. Use this textbox to explain the pseudocode/ code intent. Include any test data...
- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are...
- Part 2 – 4 Desk Checking Exercises – these are 3 programs (pseudocode) that are working and 1 program (Python). Explainthe intent of the pseudocode / program. If you use test data, note the test data.  .  You are NOT trying to find mistakes. What does this do? Desk Checking #1:  Explain the intent of this pseudocode. List the data you use as the example data. start                   Declarations          num balance Use this textbox to explain the pseudocode/ code intent. Include any test...
Show your results all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application...
Show your results all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application that allows a user to enter the price of an item and computes 6.25 percent sales tax on the item.
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an...
Show your results using all planning tools (algorithm, IPO chart, desk checking, pseudocode, flowchart) for an application that allows a user to enter the number of text messages he or she sent last month and then displays the bill. Messages cost 25 cents each, and 8 percent tax is charged on the total.
Write program logic or pseudocode to create 3 small programs that do the following: The first...
Write program logic or pseudocode to create 3 small programs that do the following: The first should compute the sum of 2 given integers. The second should multiply the 2 integers. The third should triple the sum of the 2 integers.
4. PROPOSED SOLUTION (PSEUDOCODE) • Start. • Initialize the clear cycle=1 and part[2],generated=0. • Declare the...
4. PROPOSED SOLUTION (PSEUDOCODE) • Start. • Initialize the clear cycle=1 and part[2],generated=0. • Declare the parts of the car as ‘engine’, ‘chassis’, ‘ss’. • Initialize the semaphore sem t ready. • Assign the ids from 0 to 3. • Declare the function void * gen branch(void*arg) which generates the assembly branch. • In the above function declare i,j,k=0 . • Repeat the step 7 until while(1). • Declare sleep(1) so that when the loop runs the next time it...
- Part 1 – 4 Debugging Exercises – there are things wrong – either logic or...
- Part 1 – 4 Debugging Exercises – there are things wrong – either logic or syntax errors.  Correct the pseudocode and one Java program. Add the corrected code in BOLD and change the corrected color to RED.   Debugging 2:  Add the missing code in bold and red. start                   Declarations                            num number                             housekeeping()                   while number >= 15                            detailLoop()                   endwhile                             finish()     stop housekeeping()          number = 1 return detailLoop()          output number          num = number + 1 return finishUp()          output “End of program”...
In the same file, complete the following exercises in the author’s pseudocode as presented in the...
In the same file, complete the following exercises in the author’s pseudocode as presented in the text book and material on Blackboard in this chapter, and following all requirements for good program design that were shown in Chapter 2 and all examples since then. At the Summer Olympic Games every four years, for historical reasons, athletes represent National Olympic Committees (NOCs) rather than strictly countries. For the sake of convenience in our program, let us refer to them simply as...
what is inspection, walkthrough and Desk checking testing my course is analysis and design and it's...
what is inspection, walkthrough and Desk checking testing my course is analysis and design and it's not shows in the subject so i choose operation management just to complete the process !!!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT