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
Maslowich
2 years ago
14

What kind of loop should be used in a game where the user is guessing a secret code and the message"guess again" appears until t

he user guesses correctly?
Computers and Technology
1 answer:
GenaCL600 [577]2 years ago
3 0

Answer:

While loop

Explanation:

It should be noted that the number of times which the computer will ask the user to take a guess is not known.

When we have a condition like this, the while loop (or in some programs; the do-while loop) is to be used.

To further back my point, see the following program in python.

<em>secret_code = 1234</em>

<em>user_guess = int(input("Take a guess: "))</em>

<em>while user_guess != secret_code:</em>

<em>     user_guess = int(input("guess again: "))</em>

<em>print("You guessed right")</em>

<em />

The above program will keep asking the user to take a guess until the user enters 1234.

<em>This may or may not be possible with a for loop.</em>

You might be interested in
Ask the user for a total food bill and then find the new total after 6% tax and a tip of the users choice (15, 18, 20%) in pytho
chubhunter [2.5K]

Answer:

#here is code in python.

# read the food bill

tot_bill=float(input("Please enter the food bill:"))

# tax on food

tax=0.06

#choice for tip by user

choice=int(input("enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)"))

// calculate the total food bill

if choice==1:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.15)

elif choice==2:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.18)

elif choice==3:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.2)

else:

   print("invalid choice:")

#print the total food bill

print("total food bill is ",tot_food_bill)    

Explanation:

Read the food bill from user and assign it to variable "tot_bill".Initialize the tax=0.06 (i.e. 6%) on the bill.Then ask user to give his choice for tip. if the choice is 1 then tip will be 15%, if 2 then 18% and if choice is 3 Then tip will be 20% of the bill.Calculate the total food bill and assign it to variable "tot_food_bill".

Output:

Please enter the food bill:100                                                                                                                                

enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)2                                                                                            

total food bill is  124.0

3 0
3 years ago
PLSSSSS HELPP!! Population biologists are concerned about invasive species such as the zebra mussel found in North American wate
elixir [45]

Answer: A.The introduced species compete for resources more effectively than native species.

Explanation:

An introduced species is also called the exotic species and this is an organism which is not a native organism or specie and therefore isn't native to the place but rather it's being transported to the place through the activities of human being.

When the introduced species are introduced to a particular area, they compete with the natives for the available resources and often do this more effectively than the other native species.

Therefore, the correct option is A.

4 0
3 years ago
Rachel wants to minimize project risks. Arrange the steps in an order that will correctly help Rachel and her team to minimize p
Thepotemich [5.8K]
Identify, evaluate, prioritize, and then control
8 0
2 years ago
Read 2 more answers
Answer this and you get free 100 points
Agata [3.3K]

Answer:

thanks my dude I needed it

5 0
3 years ago
Read 2 more answers
What is a good computer i should get
algol [13]

Answer:

MacBook or a Dell computer in my opinion

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • When using the wait and signal operations, ____ sets the process's process control block to the blocked state and links it to th
    12·1 answer
  • If your problem is caused by a bad hardware or software installation and you get an error message the first time you restart the
    6·1 answer
  • The Internet is considered a WAN. *<br><br> True<br> False
    9·1 answer
  • Select the correct answer.
    6·1 answer
  • From the Software Engineering Code of Ethics, which clauses relate to intellectual property (check all that apply)
    15·1 answer
  • Which of these is the term used to describe the location of an Internet page? A) social network B) Web address C) blog D) net
    6·2 answers
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    15·1 answer
  • What lets you do many things, like write book reports and stories?
    14·2 answers
  • PLEASE HELP I HAVE A TEST RIGHT NOW!!!
    13·1 answer
  • What is connectivity?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!