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
In Word, tables can be styled much like text can.<br> True<br> False
Delvig [45]

Answer:

True

Explanation:

There are many formatting options from color, size, and many more.

Hope this helps!

3 0
3 years ago
In Python please:
Sedaia [141]

Answer:

Here is the python code:

StartingSal = int(input("Enter the starting salary: "))

AnnualIncrease = (int(input("Enter the annual % increase: ")) / 100)

Years = int(input("Enter the number of years: "))

for count in range(1,Years+1):  

   print("Year ", count, " Salary: ", StartingSal*((1+AnnualIncrease)**(count-1)))

   

Explanation:

This program prompts the user to enter starting salary, percentage increase in salary per year and number of years.

The for loop has range function which is used to specify how many times the salaries are going to be calculated for the number of years entered. It starts from 1 and ends after Years+1 means one value more than the year to display 10 too when user inputs 10 days.

The year and corresponding salary is displayed in output. At every iteration the starting salary is multiplied by annual percentage increase input by user. Here count is used to count the number of salaries per year, count-1 means it will start from 30000.

8 0
3 years ago
Kristi, an event planner, wants to store caterers’ names and contact information in an organized manner. Kristi will MOST LIKELY
bixtya [17]

Answer:

Publisher Program

Explanation:

5 0
3 years ago
A term to describe articles that can be displayed in their entirety,as opposed to abstract and references only
babunello [35]

Answer:

Full Record - A screen containing complete or detailed citation information which may include a summary or abstract. Full Text - A term to describe articles that can be displayed in their entirety, as opposed to Abstract and References only.

Explanation:

5 0
3 years ago
Gabe wants to move text from one document to another document. He should _____.
Lorico [155]
Copy and paste the text
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which network could NOT carry commercial traffic?
    5·1 answer
  • A type of touch screen that can be up to four feet by six feet is a(n) _____. plasma screen multitouch interface Electronic Pape
    10·2 answers
  • convert the following c code to mips. assume the address of base array is associated with $s0, n is associated with $s1, positio
    14·1 answer
  • 110101111.11011 to decimal (base 10)
    6·1 answer
  • Over the last few years, security cameras and other devices have become more common. Some people argue that these measures viola
    14·2 answers
  • When parking on hills or an unlevel surface, make sure your_____is
    15·2 answers
  • Which table attributes would this code produce?
    15·1 answer
  • Write a program that takes a decimal number from the user and then prints the integer part and the decimal part separately. For
    13·1 answer
  • Which type of computer is used to process large amount of data​
    15·2 answers
  • Pls need this asap
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!