Anda di halaman 1dari 4

Module 2 challenge (displaying text)

Write a program that will display the following poem on the screen

There once was a movie star icon


who preferred to sleep with the light on.
They learned how to code
a device that sure glowed
and lit up the night using Python!

Module 3 challenge (string variables)


Write a program that allows a person to personalize a story

• 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)

Module 4 challenge (storing numbers)


Have the user enter the cost of the loan, the interest rate, and the number of years for the loan and
calculate monthly payments with the following formula

M = L[i(1+i)n] / [(1+i)n-1]

• M = monthly payment

• L = Loan amount

• i = interest rate (for an interest rate of 5%, i = 0.05)

• n = number of payments

Module 5 challenge (working with dates and times)


Help determine how much time someone has left to meet a deadline

• Ask a user to enter the deadline for their project

• 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)

Module 6 challenge (making decisions with code)


Calculate shipping charges for a shopper

• 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

• Don’t forget to test your solution with

– a value > 50

– a value < 50

– a value of exactly 50

Module 7 Challenge (complex decisions with code)


Calculate the total to charge for an order from an online store in Canada

• Ask user what country they are from and their order total

• If the user is from Canada, ask which province

• If the order is from outside Canada do not charge any taxes

• If the order was placed in Canada calculate tax based on the province

– Alberta charge .05% General sales Tax (GST)

– 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

Module 8 Challenge (repeating events)


Get turtle to draw an octagon

• 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!

Module 9 challenge (repeating events until done)


Create an etch a sketch program

• Have the user enter a pen color, a line length, and an angle

• Use turtle to draw a line based on their specifications

• 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.

Module 10 challenge (remembering lists)


Ask the user to enter the names of everyone attending a party

Then return a list of the party guests in alphabetical order

This will require pulling together everything we have learned so far, so let’s walk through the thought
process of idea to code

1. Ask the users to enter the names of everyone attending a party

a. What command do we use to ask a user for a value?

input function

b. What type of variable will we need to store all the names?

A list

c. How can I ask the user for more than one name?

Use a loop

2. Put those values in a list

a) Declare an empty list

b) Each time a new name is entered, add it to the list

3. Sort the list

a) Once the values are in a list, use the sort function to sort the list alphabetically

4. Print the sorted list

a) Use a loop to go through the values in the list

b) For each value, print the name

Module 11 challenge (how to save information in files)


Create the CSV file below
Module 12 challenge (reading from files)
Write a program that will print the names and ages of the guests in the guest list file you created in the
last module

• If you didn’t do the last challenge, you can just create a file to read using Notepad that contains
names and ages

Module 13 challenge (functions)


Create a function with two parameters

One parameter to hold a string of text

One parameter to hold a filename

Write code in the function that will write the text to a file with the name specified

Module 14 challenge (error handling)


Write code to open and read a file

Allow the user to specify the file name

Add error handling to provide a suitable error message if the file specified by the user could not be
found

Anda mungkin juga menyukai