Python
Function Name:
sign_count
Parameters: a list of integers
Returns: an integer
Description: Speed signs should be posted every mile on a given street. You are given a list of 0s & 1s, where each number represents a quarter of a mile. Thus, every 4 zeroes requires a speed sign. However, a 1 indicates an intersection, and each intersection is automatically required to have a speed limit sign. A sign for each mile proceeds as usual after the intersection.
Your goal is to count the number of signs required for a given stretch of road, that is represented by a list of 0’s & 1’s.
Example Call: sign_count([1,1,1]) Expected Result: 3
Example Call: sign_count([0,0,0]) Expected Result: 0
Example Call: sign_count([0,0,0,0]) Expected Result: 1
Example Call: sign_count([0,0,0,0,0,0,0,0]) Expected Result: 2
Example Call: sign_count([0,1,1,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0]) Expected Result: 7
def sign_count(lst):
count, zero_count = 0, 0
for num in lst:
if num == 1:
count += 1
zero_count = 0
else:
zero_count += 1
if zero_count == 4:
zero_count = 0
count += 1
return count
print(sign_count([1, 1, 1]))
print(sign_count([0, 0, 0]))
print(sign_count([0, 0, 0, 0]))
print(sign_count([0, 0, 0, 0, 0, 0, 0, 0]))
print(sign_count([0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]))

Python Function Name: sign_count Parameters: a list of integers Returns: an integer Description: Speed signs should...
Python Function Name: unscramble Parameters: a string Returns: a string Description: Write a function, unscramble, that takes an input string, and returns a the unscrambled version of the argument. To unscramble the string: When the string has an odd number of characters, middle character is the first character in the unscrambled result Pairs of remaining characters are added to the result, proceeding left to right from inner-most to outer-most characters. Example Call: unscramble('3cis1') Expected result: ics31 Example Call: unscramble('ocicssol') Expected...
Python Function Name: networks Parameters: int, list of tuples of int Returns: list of sets of int Description: In your class, many students are friends. Let’s assume that two students sharing a friend must be friends themselves; in other words, if students 0 and 1 are friends and students 1 and 2 are friends, then students 0 and 2 must be friends. Using this rule, we can partition the students into circles of friends. To do this, implement a function...
#Write a function called next_fib. next_fib should take #have two parameters: a list of integers and a single integer. #For this description, we'll call the single integer n. # #next_fib should modify the list to add the next n pseudo- #Fibonacci numbers to the end of the sequence. A pseudo- #Fibonacci number is the sum of the previous two numbers in #the sequence, but in our case, the previous two numbers may #not be the original numbers from the Fibonacci...
Read about Cokes strategy in Africa in the article below and discuss the ethics of selling soft drinks to very poor people. Is this an issue that a company like Coke should consider? Africa: Coke's Last Frontier Sales are flat in developed countries. For Coke to keep growing, Africa is it By Duane Stanford Piles of trash are burning outside the Mamakamau Shop in Uthiru, a suburb of Nairobi, Kenya. Sewage trickles by in an open trench. Across the street,...
Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...
How can we assess whether a project is a success or a
failure?
This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...