Cafe Hash Counting Python

Task 1
Create a new Python file in this folder called cafe.py.
Create a list called menu, which should contain at least 4 items in the
cafe.
Next, create a dictionary called stock, which should contain the stock
value for each item on your menu.
Create another dictionary called price, which should contain the prices for
each item on your menu.
Next, calculate the total stock worth in the cafe. You will need to
remember to loop through the appropriate dictionaries and lists to do
this.
Finally, print out the result of your calculation.

Task 2

Create a new Python file in this folder called hash.py
Create a dictionary called countryMap, where the KEYS are the name of a
country (i.e. a string), and the VALUE for each key is the name of that
country’s capital city.
○ For example:
countryMap = {
‘UnitedKingdom’: ‘London’,
‘Sweden’: ‘Stockholm’,
‘Canada’: ‘Ottawa’,
}
What does print(countryMap[‘Sweden’]) return?

Task 3

Write a Python program called counting.py to count the number of
times a character occurs (character frequency) in a string.
Store each letter followed by the number of occurrences in a dictionary
and print it out.
Sample String : ‘google.com’
Expected Result : {‘o’: 3, ‘g’: 2, ‘.’: 1, ‘e’: 1, ‘l’: 1, ‘m’: 1, ‘c’: 1}

×
New Download