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
Nadusha1986 [10]
3 years ago
12

In this problem, you will fill in the code for a function count_digits(val) that takes a positive integer, val, and returns a li

st containing the count of the number of times that each digit 0 - 9 appears in val. Type the provided code into IDLE (or whatever Python IDE you are using). You will fill in the code where specified in the count_digits function. The function contains the line of code count_lst
Computers and Technology
1 answer:
mars1129 [50]3 years ago
7 0

Answer:

def count_digits(val):

   count_lst = [0] * 10

   val = str(val)

   for digit in val:

       if digit == "0":

         count_lst[0] += 1

       elif digit == "1":

         count_lst[1] += 1

       elif digit == "2":

         count_lst[2] += 1

       elif digit == "3":

         count_lst[3] += 1

       elif digit == "4":

         count_lst[4] += 1

       elif digit == "5":

         count_lst[5] += 1

       elif digit == "6":

         count_lst[6] += 1

       elif digit == "7":

         count_lst[7] += 1

       elif digit == "8":

         count_lst[8] += 1

       elif digit == "9":

         count_lst[9] += 1

   return count_lst

Explanation:

Create a function called count_digits that takes one integer parameter, val

Initialize a count_list that will hold the counts for the digits in the val

Convert val to string

Initialize a for loop that iterates through the val

Inside the loop, check each digit in val and increment its corresponding position in the count_list

When the loop is done, return the count_list

You might be interested in
Search the web to discover the 10 most common user-selected passwords, and store them in an array. Design a program that prompts
Airida [17]

Answer:

userpassword = {"123456",

"password",

"123456789",

"12345678",

"12345",

"111111",

"1234567",

"sunshine",

"qwerty",

"abc123"}

#We define the function that prompts the user for a password

def user_passinput():

   password = input("Choose enter a password: ")

   return password

#Function that checks the password

def check_password():

   count = 0

   check_pass = user_passinput()

   if check_pass in userpassword:

       print("Yay!! you entered the correct password")

   elif count <10:

           count = count+1

           print("Please try again")

          user_passinput()

   else:

       print ("Maximum tries exceeded")

check_password()

Explanation:

Using Python for this code, in the first line of the code, we list the dictionary of 10 most common passwords searched on the web. In line 12, we define the function that will demand the user to enter a password and return the value the user entered. Line 16 defines the function that checks if the password is common and prints to the screen either "Yay!! you entered the correct password", "Please try again" or "Maximum tries exceeded" depending on the condition that is satisfied. The last line of the code calls the check_password() function, which actually initiates the designed program.

7 0
4 years ago
How can we get the number of records or rows in a table using MySQL? *
luda_lava [24]

The number of records or rows in a table using MySQL can be got by using the COUNT statement.

Explanation:

  • To counts all of the rows in a table, whether they contain NULL values or not, use COUNT
  • That form of the COUNT() function basically returns the number of rows in a result set returned by a SELECT statement
  • The SQL COUNT() function returns the number of rows in a table satisfying the criteria specified in the WHERE clause.
  • It sets the number of rows or non NULL column values.
  • COUNT() returns 0 if there were no matching rows.
  • The SQL COUNT function is an aggregate function that returns the number of rows returned by a query. You can use the COUNT function in the SELECT statement to get the number of employees, the number of employees in each department, the number of employees who hold a specific job, etc.
3 0
3 years ago
The search text that you type is called your _____.
Dvinal [7]
It's call your question I Bielive but I'm not sure what your 
6 0
4 years ago
How to make your nest learning thermostat stop doing something
k0ka [10]

Answer:

You could unplug it? LOL

and get a different thermostat.

Explanation:

Could you mark this answer as brainiest?

Thanks! :)

4 0
3 years ago
What is an audit trial
Nastasia [14]

Hi there!

A audit trial is a report of changes that have been obtained to a file or some kind of database.

Hope this helped!~

7 0
3 years ago
Other questions:
  • You recently set up a DHCP server and need to configure your computer to start using it. Click the IPv4 properties option that y
    10·1 answer
  • What is the standard markup language of the world wide web?
    14·1 answer
  • Which of the following is an object-oriented prototype-based language? Java Pike REBOL MATLAB
    9·1 answer
  • When all RGB colors have the same value, the resulting color will most likely be some variation of _______________.
    11·1 answer
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    7·2 answers
  • Ben Dover is the name of my best immature joke thank you
    7·2 answers
  • Does anyone know how to connect a nintendo switch to a laptop?
    10·2 answers
  • Which of the following are NOT possible using the RANDOM(a, b) and DISPLAY(expression) abstractions?
    10·1 answer
  • Which is the best description of the difference between bound and unbound forms?
    5·2 answers
  • True/false questions are useful in determining a student’s ability to____information
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!