answer.
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
kaheart [24]
2 years ago
5

Write a program that plays a reverse guessing game with the user. The user thinks of a number between 1 and 10, and the computer

repeatedly tries to guess it by guessing random numbers. It’s fine for the computer to guess the same random number more than once. At the end of the game, the program reports how many guesses it made.
Computers and Technology
1 answer:
nika2105 [10]2 years ago
4 0

Answer:

  1. import random  
  2. target = 7  
  3. count = 0
  4. for i in range(100):
  5.    guess = random.randint(1,10)  
  6.    
  7.    if(guess == target):
  8.        count += 1
  9. print("Total of correct guess: " + str(count))

Explanation:

The solution is written in Python 3.

Firstly, import the random module since we are going to simulate the random guess by computer. Next, we presume user set a target number 7 (Line 3). Create a counter variable to track the number of correct guess (Line 4).

Presume the computer will attempt one hundred times of guessing and we use randint to repeatedly generate a random integer between 1 - 10 as guess number (Line 6). If the guess number is equal to the target, increment count by one (Line 8-9).

Display the total number of right guess to terminal (Line 11).  

You might be interested in
What are some ways to accomplish full-duplex (FDX) digital communications on guided medium at the physical layer (OSI Layer 1)?
labwork [276]

Answer:

d. All of the above

Explanation:

Physical layer is the lowest layer of the OSI reference model that deals with the setup of physical connection to the network and with transmission and reception of signals.

Full duplex (FDx) is a bidirectional type of communication system where two end nodes send and receive data signals at the same time, and a single carrier is simultaneously used for dual communication.

To send or receive data, the participating nodes in a Full Duplex system do not have to wait for a free carrier/medium. It employs a medium that has at least two internal channels - one for sending and one for receiving.

Based on the above explanations, options A, B and C are valid and are correct ways to accomplish full-duplex (FDX) digital communications on guided medium at the physical layer (OSI Layer 1). There all of them are correct.

6 0
2 years ago
Which of the following best describes open-source web browsers?
podryga [215]
Hello, Good Works mate!

Answer: A) <span>Open-source web browsers allow non-paid access and distribution.

Kind Regards.</span>
4 0
2 years ago
Read 2 more answers
Which of the following is ideal for long distance communication ?
Vinvika [58]
Microwave transmission is ideal for long distance communication. It is so good that it is used for satellite and space probe communication.
3 0
2 years ago
Which statement accurately describes the clutter feature in outlook 2016
I am Lyosha [343]

Answer:

The answer is the last option

8 0
2 years ago
Write a java program that will print out the following pattern 1 12 123 1234 12345
Ilya [14]

Answer:

public class Main {

  public static void main(String[] args)

{

  int n,m;

  int k=5;

  for(n=1;n<=k;n++)

  {

for(m=1;m<=n;m++)

  System.out.print(m);

   System.out.print(" ");

   }

}

}

Explanation:

The solution to this problem is the use of nested loops of an inner and outer loop to generate a half pyramid of numbers, but displayed on the same line so we have a sequence 1 12 123 1234 12345. The outer loop iterates for n=1 to n<=5 and the inner loop that has the print statement prints the integers from for m = 1 to m<=n.

Note that the value k = 5 is hard coded which in some sense is the number of rows, that is the length of iteration of the outer loop.

5 0
2 years ago
Other questions:
  • Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
    13·1 answer
  • When you park on a hill, think about which way _____.
    6·2 answers
  • Carl knows that water moves through different kinds of soil at different rates. How easily water moves through a soil is known a
    6·1 answer
  • You're the sole IT employee at your company. Most of the computers in your fleet are Windows machines. Your boss wants you to se
    11·1 answer
  • (a) Show how to use (the Boolean formula satisfiability program) satisfiable num (and substitute) to find a satisfying assignmen
    9·1 answer
  • A ______________ deals with the potential for weaknesses within the existing infrastructure to be exploited.
    10·2 answers
  • #Write a function called "replace_all" that accepts three #arguments: # # - target_string, a string in which to search. # - find
    11·1 answer
  • Janice has a "jammed" key on her keyboard. Every time she strikes the "S" key it sticks and doesn't pop back. What should Janice
    6·2 answers
  • 4. Word Separator:Write a program that accepts as input a sentence in which all of thewords are run together but the first chara
    10·1 answer
  • In an IPv4 datagram, the fragflag bit is 0, the value of HLEN is 5 (Its unit is word or 32-bits ), the value of total length is
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!