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
one data is in memory the computer interpets and executeinstructions to process the data into informationA. TrueB. False
lidiya [134]

Answer:

Option A is the correct answer for the above question.

Explanation:

  • The computer is a system that processes the data to produce information. For any computer system when the data is processed then it will form the information.
  • The user gives some instruction to process that can also be called the program. Then the computer takes the instruction and processes the data on behalf of the instruction and for the information because in any system when data is processed it can form the information.
  • The above question says that the computer follows the instruction to process the data to produce the information which is correct as described above. Hence True is the correct answer to the above question.
4 0
3 years ago
Type of file containing instructions that tell your computer how to perform ___
julsineya [31]

Answer:

A)File

B)Native

C)Extension

D)File size

Explanation:

6 0
3 years ago
Armando is trying to decide how he will alert players that the game is over in the new video game that he is designing. He is co
mojhsa [17]

Answer:

He is working on the outcome

Explanation:

Because this is the outcome if you fail or die and the other objectives are the following

operation: A single objective in a level of the the whole game

obstacles: Trying to stop the player like blocks or walls or traps

objective:The main goal of the game

8 0
2 years ago
Darren built a tower out of 23 toy blocks. each block has a mass of 7grams. what is the mass of the whole tower?​
KIM [24]

Answer:

23 x 7 = 161

161 grams

8 0
3 years ago
Read 2 more answers
Paavo was reviewing a request by an executive for a new subnotebook computer. The executive said that he wanted USB OTG support
grandymaker [24]

Answer:

Connecting a mobile device as a peripheral to an infected computer could allow malware to be sent to that device.

Explanation:

Since in the question it is mentioned that Paavo reviewed a request by an executive for subnotebook computer i.e new. but he needs to USB OTG support so it is a  USB i.e on the go that links the devices from one device to another

Therefore by links the mobile device to the computer i.e infected that allows malware we called virus so that we are able to send it to that device. By this,  he wants to tell about the USB OTG security

4 0
3 years ago
Other questions:
  • Credit card numbers follow a standard system. For example, Visa, MasterCard, and Discpver Card all have 16 digits, and the first
    11·1 answer
  • PLEASE DON'T DELETE THIS QUESTION!!!!
    15·2 answers
  • Garry is a record executive who is building a data table to include in a presentation about one of his artists. The table is mea
    15·1 answer
  • To prepare a data character for transmission, a ____ bit is added to the beginning of the character and informs the receiver tha
    11·1 answer
  • In the early 1800's, a “computer" was not a machine, it was a person who did math
    8·2 answers
  • Design a loop that asks the user to enter a number. The loop should iterate 10
    15·1 answer
  • An animation of a person standing with their arms extended out to their sides. There are 3 dimensional boxes around the torso of
    5·1 answer
  • A construction-based client would like to develop an application that can analyze an image of machinery and overlay information
    8·1 answer
  • I want to build a video player on the html5 canvas here is my code
    9·1 answer
  • which of the following commands can be used to display any email messages awaiting delivery alongside the reason that they were
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!