Module 2 Challenge (Displaying Text)
Module 2 Challenge (Displaying Text)
Write a program that will display the following poem on the screen
• Take a page from a book or make up a story. Ask the user to enter information you can replace
in the story such as their name, a place, or insert adjectives or adverbs into the story. Then
display the personalized story to the user
• For extra credit make sure you correct anything they type in with the incorrect case (e.g. if they
type an adjective in uppercase you may want to display it in lowercase)
M = L[i(1+i)n] / [(1+i)n-1]
• M = monthly payment
• L = Loan amount
• n = number of payments
• Tell them how many days they have to complete the project
• For extra credit, give them the answer as a combination of weeks & days (Hint: you will need
some of the math functions from the module on numeric values)
• Ask the user to enter the amount for their total purchase
• If their total is under $50 add $10, otherwise shipping is free
• Tell the user their final total including shipping costs and format the number so it looks like a
monetary value
– a value > 50
– a value < 50
– a value of exactly 50
• Ask user what country they are from and their order total
• If the order was placed in Canada calculate tax based on the province
– Ontario, New Brunswick, Nova Scotia charge .13% Harmonized sales tax
– All other provinces charge .06% provincial sales tax + .05% GST tax
• Tell the user the total with taxes for their order
• Hint: to calculate the angle, you take 360 degrees and divide it by the number of sides of the
shape you are drawing
• Extra challenge: Let the user specify how many sides the object will have and draw whatever
they ask
• Double bonus challenge, add a nested loop to draw a smaller version of the object inside!
• Have the user enter a pen color, a line length, and an angle
• Let them specify new lines over and over until they enter a line length of 0.
• When the user specifies a line length of 0 stop drawing.
This will require pulling together everything we have learned so far, so let’s walk through the thought
process of idea to code
input function
A list
c. How can I ask the user for more than one name?
Use a loop
a) Once the values are in a list, use the sort function to sort the list alphabetically
• If you didn’t do the last challenge, you can just create a file to read using Notepad that contains
names and ages
Write code in the function that will write the text to a file with the name specified
Add error handling to provide a suitable error message if the file specified by the user could not be
found