Question: python Implement count, which takes a digit element and an integer holder. It returns the number of times that element appears in holder. Warning: n

 python Implement count, which takes a digit element and an integer
holder. It returns the number of times that element appears in holder.
Warning: n % d and n // d may not behave as
you expect for negative n. For example, -123 % 18 evaluates to
7.-1 // 10 evaluates to -1. You do not need to know
how these operators apply to negative n in order to solve this
problem. def count(element, holder): "Count how many times digit element appears in
python

Implement count, which takes a digit element and an integer holder. It returns the number of times that element appears in holder. Warning: n % d and n // d may not behave as you expect for negative n. For example, -123 % 18 evaluates to 7.-1 // 10 evaluates to -1. You do not need to know how these operators apply to negative n in order to solve this problem. def count(element, holder): "Count how many times digit element appears in integer holder. # Case 1 >>> count(2, 222122) 5 # Case 2 >>> count(0, -2020) 2 # Case 3 >>> count(0, 0) @ # has no digits Day assert element >= 0 and element @: if (b) total = (c) holder = holder // 10 return total Q1.1.1 Points: 2 Fill in blank (a). Saved Q1.1.2 Points: 1 Which of these could fill in blank (b)? holder = element holder % element == holder 10 == element holder % element > Saved Q1.1.3 Points: 1 Which of these could fill in blank (c)? total + 1 holder % 10 total + element element total + holder % 10 Saved Implement count_nine, which takes a digit element and a non-negative integer holder. It returns the number of times that element appears in holder and is not adjacent to a 9. def count_nine(element, holder): Count how many times digit element appears in the non-negative integer holder in a place that is not next to a 9. # Case 1 >>> count_nine(2, 222122) 5 # Case 2 >>> count_nine(1, 1911191) # Only the middle 1 is not next to a 9 1 # Case 3 >>> count_nine(9, 9) 1 # Case 4 >>> count_nine (9, 99) # Case 5 >>> count_nine(3, 314159265359) 2 # Case 6 >>> count_nine(5, 314159265359) 1 # Case 7 >>> count_nine(9, 314159265359) 2 # Case 8 >>> count_nine(0, 0) # No digits are in @ assert element > 0 and element 0 nine, total = False, O while holder > 0: if and not (nine or ): (a) (b) total = # (c) nine = = 9 # (d) holder = holder // 10 return total Q1.2.1 Points: 1 Which of these could fill in blank (a)? holder % element > 0 holder % element == 0 holder = element holder % 10 = element Saved Q1.2.2 Points: 2 Fill in blank (b). Saved Q1.2.3 Points: 1 Which of these could fill in blank (c)? total + 1 holder 10 total + element element total + holder % 10 Saved Q1.2.4 Points: 1 Fill in blank (d). Saved Implement fit, which takes two non-negative integers spikes and grooves. It returns whether every digit in spikes appears at least as many times in grooves as it does in spikes. def fit(spikes, grooves): "Return whether every digit in spikes appears at least as many times in grooves as it does in spikes. # Case 1 >>> fit(123, 321) True # Each digit appears once in spikes and in grooves. # Case 2 >>> fit(1213, 33221) # 1 appears twice in spikes, but only once in grooves. False # Case 3 >>> fit(12, 22) False # 1 appears once in spikes, but not at all in grooves. # Case 4 >>> fit(314159, 112233456789) True i = 0 while i co (a) if (b) (c) i = 1 + 1 return (d) Q1.3.1 Points: 1 Fill in blank (a). Saved Q1.3.2 Points: 2 Fill in blank (b). Saved Q1.3.3 Points: 1 Fill in blank (c). 1 Saved

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!