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
vovikov84 [41]
3 years ago
11

Write a program for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program

returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 53840, and the user guesses 83241, the digits 3 and 4.
Computers and Technology
1 answer:
Margaret [11]3 years ago
6 0

Answer:

from random import randint

winner  = False

number = str(randint(10000, 99999))

while (not winner):

   correct = 0

   total = 0

   guess = input()

   

   if(number==guess):

       winner = True

   else:

       for i in range(5):

           if(number[i] == guess[i]):

               correct+=1

               total+=int(number[i])

       

       print('Correct: '+ str(correct))

       print('Total: '+ str(total))

print('Winner')

Explanation:

I´m gonna show a solution in python 3

Step 1 import library for generate random number

from random import randint

Step 2 create necesary variables to get the number and if the player is winner or not

winner  = False

number = str(randint(10000, 99999))

Step 3 loop while the player is not the winner

while (not winner):

Step 4 get the player guess number

guess = input()

Step 5 validate if the player win

if(number==guess):

       winner = True

Step 6 if the player is not winner review what numbers are  in the correct position

for i in range(5):

           if(number[i] == guess[i]):

               correct+=1

               total+=int(number[i])

Step 7 print the hint

print('Correct: '+ str(correct))

print('Total: '+ str(total))

You might be interested in
Steve is proofreading his memo and he notices that he has typed a phrase twice. Steve should _____.
butalik [34]
The answer is B.) <span>highlight the phrase and press Delete</span>
7 0
3 years ago
Read 2 more answers
Im getting hit offline can someone help or give me some advice
Lubov Fominskaja [6]

Answer:

What do you mean bro?

Explanation:

4 0
2 years ago
A company that hires only American Indians is practicing
Mashutka [201]
What’s the question ?
7 0
2 years ago
Read 2 more answers
D is the correct answer
pogonyaev
For what Question ?
7 0
3 years ago
Read 2 more answers
A DFA is equivalent in power to an NFA. True False
sattari [20]

Answer: True

Explanation:

  Yes, the given statement is true that a DFA is equivalent to NFA in terms of power. For any type of NFA we can easily build an equal DFA so, the NFA are not much powerful as compared to DFA. Both NFA and DFA are characterized by a similar type of class.

DFA is a special case of NFA and They both defined in the same class of language. Each condition in the DFA get summarized by all the condition that the NFA has itself.

4 0
2 years ago
Other questions:
  • Which component is the smallest unit in a spreadsheet?
    14·2 answers
  • What runs a network, steering information between computers and managing security and users?
    11·1 answer
  • Pretrial services programs are also known as early intervention programs. <br> a. True <br> b. False
    15·1 answer
  • When you first start your computer, which software will have to start first?
    5·2 answers
  • An algorithm written out in plain English statements is called __________.
    8·1 answer
  • What do developers do to support software products
    14·1 answer
  • Convert 78 to binary
    6·2 answers
  • Question # 2
    7·1 answer
  • Explain the different features available in Print command?
    10·1 answer
  • What Does The Computer Monitor Contain?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!