Skip to the content. Back to Chapter 2
<style> :not(ul) + ol { counter-reset: list-ctr; list-style-type: none; list-style-position: outside; } :not(ul) + ol > li { counter-increment: list-ctr; } :not(ul) + ol > li::before { content:"Q" counter(list-ctr) ". "; margin-left: -25px; } ol ul { list-style-type: lower-alpha; } ol ul ul { list-style-type: lower-roman; } ul ol { list-style-type: circle; } ul { list-style-type: decimal; } ul ul { list-style-type: lower-alpha; } ul ul ul { list-style-type: lower-roman; }

Chapter 33

Example 1

bird_name = ["robin", "blackbird", "pigeon", "magpie", "bluetit"]
bird_count = [0 for i in range(8)]
bird = input("Enter bird name (x to end): ")
while bird != "x":
    bird_found = False
    num_species = len(bird_name)
    for count in range(num_species):
        if bird == bird_name[count]:
            bird_found = True
            birds_observed = int(input("Number observed: "))
            bird_count[count] += birds_observed
    if bird_found == False:
        print("Bird species not in array")
    bird = input("Enter bird name (x to end): ")
for count in range(8):
    print(bird_name[count], bird_count[count])
  1. 10 [√]
  2. print("Staff name: ", staff[s]) [√]

Example 2

staff = ["Anna", "Bob", "Carol"]
quarter_sales = [
    [100, 110, 120, 110],
    [350, 355, 360, 360],
    [200, 210, 220, 220],
]
for s in range(3):
    annual_sales = 0
    print("Staff name:", staff[s])
    for q in range(4):
        print("Quarter", q, quarter_sales[s][q])
        annual_sales += quarter_sales[s][q]
    print("Annual sales:", annual_sales)

Exercises