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]
4 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]4 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
February 1995, Kevin Mitnick was arrested. While on parole was he allowed to have a phone or computer?
m_a_m_a [10]

Answer:

He was not allowed on a phone of computer after being arrested.

Explanation:

If you read about it he wasn't even allowed to work at 7-11 because of an electronic cash register.

6 0
3 years ago
Read 2 more answers
A network administrator needs 10 prevent users from accessing the accounting department records. All users are connected to the
mojhsa [17]

Answer:

C

Explanation:

6 0
3 years ago
Read 2 more answers
A musician has recorded some initial ideas for new songs which she wishes to share with her bandmates. As these are initial idea
Ugo [173]

Answer:

1.save the audio using a low sampling rate

2.save the audio using a low bit depth

Explanation:

1. if the quality of the audio is low then the size of the audio will also be low and which will make the size of the data to be less and also easier to download

3 0
3 years ago
Your computer uses 4 bits to represent decimal numbers (0, 1, 2, 3 and so on) in binary. What is the SMALLEST number
lord [1]

Answer:

C

Explanation:

I believe this is because you cannot represent the number sixteen with only four binary bits. The highest you can go is 15.

8 0
3 years ago
Write a BASIC program to find the product of any two numbers​
GuDViN [60]

Answer:

Print 4 + 4

Explanation:

If you're writing this in the programming language called BASIC, this is how you would add any two numbers.

6 0
3 years ago
Other questions:
  • Provide an example of a time in your personal or work life when you used the household measuring system and measured out an exac
    6·1 answer
  • You want to place a video from the internet to your desktop. what process do you use?
    15·1 answer
  • wHAT ARE THE 5 LAYERS in the internet protocol stack andwhat are the principal responsibilities of eack of theselayers.?
    12·1 answer
  • What is batch processing?
    12·1 answer
  • Does anyone know this page for drivers ed?
    9·1 answer
  • A chef writing up her famed recipe for beef stew realizes she has switched parsley and oregano everywhere in the recipe. The che
    13·1 answer
  • Which of the following is the correct ordering of operating systems, oldest to newest?
    5·2 answers
  • How to calculate least count of a stopwatch
    8·1 answer
  • Suppose there are two hosts, S and R. They are communicating over a TCP connection, and R has already received from S al bytes f
    11·1 answer
  • Use the drop-down menu to complete the steps for using the Goal Seek feature.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!