1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
faltersainse [42]
3 years ago
11

**GIVING ALL POINTS** 4.02 Coding With Loops

Computers and Technology
1 answer:
Anestetic [448]3 years ago
3 0

Answer:

import random

from time import sleep as sleep

 

def main():

   # Initialize random seed

   random.seed()

 

   # How many guesses the user has currently used

   guesses = 0

   

   # Declare minimum value to generate

   minNumber = 1

 

   # Declare maximum value to generate

   maxNumber = 20

 

   # Declare wait time variable

   EventWaitTime = 10 # (Seconds)

 

   # Incorrect config check

   if (minNumber > maxNumber or maxNumber < minNumber):

       print("Incorrect config values! minNumber is greater than maxNumber or maxNumber is smaller than minNumber!\nDEBUG INFO:\nminNumber = " + str(minNumber) + "\nmaxNumber = " + str(maxNumber) + "\nExiting in " + str(EventWaitTime) + " seconds...")

       sleep(EventWaitTime)

       exit(0)

 

   # Generate Random Number

   secretNumber = random.randint(minNumber, maxNumber)

 

   # Declare user guess variable

   userGuess = None

 

   # Ask for name and get input

   name = str(input("Hello! What is your name?\n"))

 

   # Run this repeatedly until we want to stop (break)

   while (True):

 

       # Prompt user for input then ensure they put in an integer or something that can be interpreted as an integer

       try:

           userGuess = int(input("Guess a number between " + str(minNumber) + " and " + str(maxNumber) + ": "))

       except ValueError:

           print("ERROR: You didn't input a number! Please input a number!")

           continue

 

       # Increment guesses by 1

       guesses += 1

 

       # Check if number is lower, equal too, or higher

       if (userGuess < secretNumber):

           print("You guessed: " + str(userGuess) + ". Too low.\n")

           continue

       elif (userGuess == secretNumber):

           break

       elif (userGuess > secretNumber):

           print("You guessed: " + str(userGuess) + ". Too high.\n")

           continue

   

   # This only runs when we use the 'break' statement to get out of the infinite true loop. So, print congrats, wait 5 seconds, exit.

   print("Congratulations, " + name + "! You beat the game!\nThe number was: " + str(secretNumber) + ".\nYou beat the game in " + str(guesses) + " guesses!\n\nThink you can do better? Re-open the program!\n(Auto-exiting in 5 seconds)")

   sleep(EventWaitTime)

   exit(0)

 

if __name__ == '__main__':

   main()

Explanation:

You might be interested in
Choose all that apply.
kirill115 [55]

Answer:

Bullets can be turned off and on.

Lists don't have to use numbers or bullets.

Explanation:

because L just wanted the light

6 0
3 years ago
Read 2 more answers
8. Which clause will always executes<br> a) try b) catch c) finally d) None of them
sleet_krkn [62]

Answer:

I think a is correct answer

6 0
3 years ago
You view a portion of a document on the screen through a
Stells [14]

Answer:

Document window is through which we view the portion of a document.

Explanation:

We have many portions like tabs, ruler, ribbon, etc in word. There is one another feature called Document Window in word where it represents the actual view of a document in GUI (Graphical User Interface) operating system.

Here the actual contents of the page are created and the user can also insert various shapes based on the need.  Any feature in the tabs can be included in the document window. You can set the zoom size of the document according to the need.

6 0
3 years ago
Which protocol is often used to publish web pages to a web server?
zmey [24]
 File Transfer Protocol, also known as FTP
5 0
3 years ago
Lenders always accept applications for credit
LenKa [72]
The correct answer to the question that is being stated above is FALSE.

The statement is false because lenders do not always accept applications for credit. Lenders always consider credit history of the applicant. If the applicant has a good credit history background, then he qualifies.
3 0
4 years ago
Other questions:
  • Use the following business rules to assign name to the tables on the ERD: Note: These rules are in the context of a small retail
    7·1 answer
  • What prefix describes a mass that is 1000 times smaller than a gram
    5·2 answers
  • What is the power dissipated by a resistor with a current of 0.02 A and a resistance of 1,000 ?
    15·1 answer
  • Today when Dylan turned on his computer, he noticed that the monitor was very dim. He could still see the desktop icon and text.
    15·1 answer
  • Choose the accurate answer from the drop-down choices.
    11·1 answer
  • nder a Huffman encoding ofnsymbols with frequenciesf1, f2, . . . , fn, what is the longest a codewordcould possibly be
    13·1 answer
  • Madeleine's Instructor praised her for capturing a nearly perfect image. It included dominance, harmony, and proportion among ot
    13·1 answer
  • What are the advantages of Radio waves over micro waves?​
    14·1 answer
  • What data type of data type would you use to represent the registration letter of a car​
    5·2 answers
  • With social media presence growing why is cyberbullying at an all time high
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!