Write a function ones_and_tens_digit_histogram(numbers) that takes as input a list of numbers and produces as output a list of 10 numbers.   Each element of the result indicates the frequency with which that digit appeared in the ones place or the tens place in the input. here is an example call and result:   Call: ones_and_tens_digit_histogram([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) Return: [0.21428571428571427, 0.14285714285714285, 0.047619047619047616, 0.11904761904761904, 0.09523809523809523, 0.09523809523809523, 0.023809523809523808, 0.09523809523809523, 0.11904761904761904, 0.047619047619047616] In this example call, the index 1 of the list contains the element 0.14285714285714285 because the value 1 appears in 14.285714285714285% of the ones or tens digits of the given numbers. In a number that is less than 10, such as 3, the tens place is implicitly zero. That is 3 must be treated as 03. Your code should treat the tens digits of these values as zero.    Hints: To get the ones and tens digits of a number, review the % and // operators. For example, what is the result of 31 % 10? Why? What is the result of 31 // 10? Why? What about 4 // 10 and 0 % 10? In order to calculate an average for digit i, you will need to know the number of times i appears in the ones or tens digit — for the numerator — and the total number of digits — for the denominator. What should the denominator be? Make sure your averages aren't off by a factor of two. To generate a list of the same number X with length N, you can use the syntax [X] * N   Python PRogramming please

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a function ones_and_tens_digit_histogram(numbers) that takes as input a list of numbers and produces as output a list of 10 numbers.

 

Each element of the result indicates the frequency with which that digit appeared in the ones place or the tens place in the input. here is an example call and result:

 

Call: ones_and_tens_digit_histogram([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765])

Return: [0.21428571428571427, 0.14285714285714285, 0.047619047619047616, 0.11904761904761904, 0.09523809523809523, 0.09523809523809523, 0.023809523809523808, 0.09523809523809523, 0.11904761904761904, 0.047619047619047616]

In this example call, the index 1 of the list contains the element 0.14285714285714285 because the value 1 appears in 14.285714285714285% of the ones or tens digits of the given numbers. In a number that is less than 10, such as 3, the tens place is implicitly zero. That is 3 must be treated as 03. Your code should treat the tens digits of these values as zero. 

 

Hints:

  • To get the ones and tens digits of a number, review the % and // operators. For example, what is the result of 31 % 10? Why? What is the result of 31 // 10? Why? What about 4 // 10 and 0 % 10?
  • In order to calculate an average for digit i, you will need to know the number of times i appears in the ones or tens digit — for the numerator — and the total number of digits — for the denominator. What should the denominator be? Make sure your averages aren't off by a factor of two.
  • To generate a list of the same number X with length N, you can use the syntax [X] * N

 

Python PRogramming please

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY