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
At the data science laboratory, the data scientists and data engineers are required to process millions of data every second to
defon

Answer:

the type of computer system that is required for processing of scientific data is : supercomputer

for distribution of data over a network :Client/server computing

working from home :A laptop

3 0
3 years ago
How is a non-disclosure agreement an important tool for businesses?
Sloan [31]

Answer:

D

Explanation:

4 0
3 years ago
Read 2 more answers
9. Question
Gennadij [26K]
A server stopped provide service to 100 users
5 0
2 years ago
You want to select the minimum windows server 2012 edition to support the required roles and hardware. which edition should you
nirvana33 [79]

Edition should you install <u>essentials edition.</u>

<u></u>

<h3>What are the two editions of Windows Server?</h3>

Microsoft has proposed Standard and Datacenter editions of its Windows Server operating systems for several years, which continued with Windows Server 2022.

<h3>What is Windows Server Edition?</h3>

Microsoft Windows Server OS (operating system) is a series of enterprise-class server operating systems created to share services with multiple users and provide extensive managerial control of data storage, applications and corporate networks.

To learn more about Workspace Essentials, refer

brainly.com/question/12578161

#SPJ4

8 0
1 year ago
What is the name of a statement written to retrieve specific data from a table?
Shkiper50 [21]
The answer is b.record
4 0
3 years ago
Other questions:
  • Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
    15·1 answer
  • How does soil lose its value? A.When the top soil is stripped by wind or water B.When the bedrock is damaged by animals C.When w
    15·1 answer
  • What unit is used for measure disk size ?
    10·1 answer
  • In this mode, your presentation will fill up the entire screen. Auto Default Standard Window
    6·2 answers
  • In order to use an object in a program, its class must be defined.
    9·1 answer
  • What kind of information B2B SaaS companies wish to know about their competition, apart from information about their competitors
    15·1 answer
  • Which one of the following will not be considered as a microcomputer?
    12·2 answers
  • Rick works for the government and is investigating a small business that the government suspects has been cheating on its taxes.
    15·1 answer
  • What type of diagram will you find nodes?
    15·1 answer
  • Explain how loops can be utilized in list processing. Please provide Python examples in your response.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!