12.3 - Challenges
Create a solution for each challenge below. It must match any dataflow provided.
All required files in study kit.
1 - Postcodes
100 postcodes are stored in the file postcodes.txt.
b759cp r701ed f706dt ...
Write a program that will count and display how many postcodes start with ‘g’.
Example run
8 postcodes start with 'g'.
2 - Items and prices
The names of 5 items are stored in the file items.txt.
Write a program that will ask the user to enter a price for each item and then save the items and their prices to a file names items_and_prices.csv.
Example run
Enter Soap price: 1 Enter Pizza price: 3 Enter Apples price: 2 Enter Carrots price: 1 Enter Ice Cream price: 4
items_and_prices.csv
Soap,1 Pizza,3 Apples,2 Carrots,1 Ice Cream,4
3 - Customer ID
The id’s for 50 customers are stored in the file customers.txt.
The id’s are stored using the format:
- name+signup year
- Jane2020
Write a program that will count and display how many customers have signed up from 2020 onwards.
Example run
35 customers signed up from 2020 onwards.