Activity #5 – Applying Functions The output of this activity will be the same as activity #3 but instead you are required to use a function for the following algorithm:
1. A function for getting the length of each string
2. A function to get the shortest string
3. And a function to get the longest string Assume that each string has its own unique length.
Sample Run:
Sample Run A
Enter value of X: 3
Enter string value: a
Enter string value: ab
Enter string value: abc
a - total length is 1
ab - total length is 2
abc - total length is 3
The shortest string is a
The longest string is abc
Sample Run B
Enter value of X: 4
Enter string value: chico
Enter string value: strawberry
Enter string value: banana
Enter string value: guyabano
chico - total length is 5
strawberry - total length is 10
banana - total length is 6
guyabano - total length is 8
The shortest string is chico
The longest string is strawberry
You are assisting a Coffee Shop create a program to run at their kiosk for customers to purchase their items. You will create a program to create a dictionary of their current coffee products and prices:
Coffee item Price
Hot brew $4.25
Latte 4.75
Mocha 4.99
Cold brew 3.95
Cappuccino 4.89
Donut 1.50
Create a program in Python to accept input from a customer inquiring what item they would like to purchase. Customers can purchase more than one item. Test to see if the item they request is in your dictionary – if not display a message that you don’t currently carry that item. Total up the costs of all the items they wish to purchase and then display to them their total bill, including 7% tax.
Write a statement that asks the user to enter the year and convert it to an integer. Store the resulting information in a variable called year.
Calculate the first 50 perfect cubes and store them in a list. Do not calculate them individually with fifty separate calculations. Use a loop. Each time through the loop, the program should calculate a perfect cube and append it to the list. 2. Use another loop to traverse the list and display the numbers in order.