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
olya-2409 [2.1K]
3 years ago
10

Your program will choose a random 4 digit number as the secret number. Your program must prompt the user to enter a 4 digit numb

er as their guess. The program will respond with a message indicating how many of the digits in the user's guess are the same as the digit in the same position in the secret number. For example, if the secret number is 3749, and the user's guess is 9753, then the program would respond with the message You matched 1, because only one of the digits (the 7) in the user's guess is the same as the digits in the same position in the secret number. The program will allow the user to continue to enter guesses until they guess the correct secret number. mere presente la memories more than more than After the user has entered the secret number, the programevill output a count of the total number of guesses the user took to find the secret number. Then the program will ask the user if they would like to play again. If the user answers "yes", then the program will choose another random 4 digit number and play continues as described above. Here's an example interaction (user input in bold): ----- MASTERMIND ----- Guess the 4 digit number! Guess 1: 0000 You matched 0 Guess 2: 1111 You matched 1 Guess 3: 1234 You matched 1 Guess 4: 2444 You matched 2 Guess 5: 1442 You matched 4 Congratulations! You guessed the right number in 5 guesses. Would you like to play again (yes/no)?
Computers and Technology
1 answer:
gtnhenbr [62]3 years ago
3 0

Answer:

Written in Python

import random

#randnum = str(random.randint(999, 9999))

tryagain = "Yes"

while tryagain == "Yes":

     randnum = "1234"

     trys = 1

     guess = input("Guess: ")

     count = 0

     while not count == 4:

           for i in range(0,4):

                 if randnum[i] == guess[i]:

                       count = count + 1

                 if not count == 4:

                       print("You match "+str(count))

                       guess = input("Guess: ")

                       trys = trys + 1

                 else:

                       print("Congratulations, you match at "+str(trys))

                       trys = 1

                       tryagain = input("Start? (Yes/No): ")

Explanation:

I've added the full source code as an attachment where I used comments as explanation

Download txt
You might be interested in
Which type of service offers a preconfigured testing environment for application developers to create new software applications?
Vaselesa [24]

A type of service which offers a preconfigured testing environment for application developers to create new software applications is: B - Platforms as a Service (PaaS).

<h3>What is cloud computing?</h3>

Cloud computing can be defined as a type of computing service that requires the use of shared computing resources over the Internet, rather than the use of local servers and hard drives.

<h3>The categories of cloud service.</h3>

Generally, cloud computing comprises three (3) service models which includes the following;

  • Infrastructure as a Service (IaaS).
  • Software as a Service (SaaS).
  • Platform as a Service (PaaS).

In conclusion, a type of service which offers application developers a preconfigured hosting and testing environment to create new software applications is Platforms as a Service (PaaS).

Read more on Platform as a Service here: brainly.com/question/24233315

#SPJ1

6 0
1 year ago
                                                       HELP PLEASE 
Marina CMI [18]
Your answer should be mode







5 0
3 years ago
Read 2 more answers
Consider the following two code segments: Segment 1: while (k &gt; 0) { System.out.println(k); k--; } --------------- Segment 2:
zepelin [54]

Answer:

Always same value

Explanation:

These both code segments will always generate identical values given that we provide same value of k to both segments.

You can see attached pictures.

6 0
3 years ago
Which of the following statements about federal student loans is true?
never [62]
The correct answer is a.<span>) the interest rate on your loan will be fixed over time. 
</span>
7 0
3 years ago
Virus infections often disable antivirus programs and prevent them from being enabled
SCORPION-xisa [38]
Some of the advanced viruses do this. So it would be true.
3 0
3 years ago
Other questions:
  • Help asap. 10 points.
    8·2 answers
  • When inserting a fly in animation what is the first step in the process?
    9·1 answer
  • Once a graph has been created, you would need to start over to make any changes to it?
    5·1 answer
  • What are the programming concepts (within or outside the scope of IT210) that you would like to strengthen and delve into furthe
    11·1 answer
  • You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery, Inc. (ACM), charges money a
    10·1 answer
  • What is the name of the function below?<br><br> function go(){<br> alert("hello everybody");<br> }
    10·1 answer
  • What job does a front-end developer perform?
    15·1 answer
  • Im trying to do an animation only using simplegui in python and my objective is make the ball enters frame, be confused and jump
    12·1 answer
  • ANSWER QUICKLY!!! <br><br> Which aspect of planning is a preventive action?
    15·1 answer
  • How does abstraction make programming languages easier to use
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!