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
A poker hand consists of 5 cards drawn at random without replacement from a 52 card deck. Using python and the cards data frame
PSYCHO15rus [73]

Answer:

# Python program to shuffle a deck of card

# importing modules

import itertools, random

# make a deck of cards

deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))

# shuffle the cards

random.shuffle(deck)

# draw five cards

print("You got:")

for i in range(5):

  print(deck[i][0], "of", deck[i][1])

Output

You got:

5 of Heart

1 of Heart

8 of Spade

12 of Spade

4 of Spade

Explanation:

5 0
3 years ago
CO! Oher...9
kondor19780726 [428]

Answer:

Altitude of the town(h1) = 1,196.8 m

Explanation:

Given:

Height of barometer(h) = 65 cm Hg = 0.65

Standard atmospheric pressure  = 76 cm Hg = 0.76

Density of mercury(Pm) = 13,600 kg/m³

Density of  air (Pa) = 1.25 kg/m³

Find:

Altitude of the town(h1)

Computation:

Pressure due column = Δp mercury column

(Pa)(h1) = (Pm)(h)

(1.25)(h1) = (13,600)(0.76-0.65)

(1.25)(h1) = 1,496

Altitude of the town(h1) = 1,196.8 m

6 0
3 years ago
Why should kids not play violent video games
marta [7]
Becouse they could grow up and think that that kinda stuff's normal, and it could eventualy affect their sanity(could cause them to be legally insane)<span />
7 0
3 years ago
Read 2 more answers
Select all examples of proper keyboarding technique.
krok68 [10]

Answer:

all except keeping your hands higher than your elbows

4 0
3 years ago
A technician is trouble-shooting an IDE hard drive that is emitting a humming sound. They suspect a faulty connector. Which of t
IRINA_888 [86]

Answer:

IDE hard drives <em>(Integrated Drive Electronics)</em> aka <em>(PATA) </em>or <em>"Parallel ATA"</em> <em>(Advanced Technology Attachment)</em>, were the previous standard before SATA which are faster; IDE drives are disposed with 41 to 44 pins, and they normally use 5V; although to certain extent small laptop 2.5" drives need only 5V, some of them also need 12V; and 3.5" drives require 12V plus 5V for the motor and logic.

Thereby the most suitable answers are <em>B.)</em> &<em> E.)</em> ,

5V and 12V respectively.

5 0
4 years ago
Other questions:
  • You are researching RAM for a computer you are building for a friend who will be using the system as a home office server for he
    13·1 answer
  • How does Hadoop work? It breaks up Big Data into multiple parts so each part can be processed and analyzed at the same time on o
    5·1 answer
  • To move one screen to the left press ____.
    9·1 answer
  • Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, g
    7·2 answers
  • Write a java program which uses methods for calculating the sum of any 5 non-zero integer digits that are input. The program mus
    8·1 answer
  • Jeremy is designing a website for a florist. He intends to discuss the web design with his client. Which tool should Jeremy use
    6·1 answer
  • In C++ Please :
    6·1 answer
  • Describe how electrons move between atoms to create electricity.
    7·2 answers
  • What is the main difference between weathering, erosion and leaching​
    9·1 answer
  • What is the significance of the scientific method?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!