$29
Submit each program as a separate file.
25 points
P3_if_numbers.py 5 points
1 point
Create two variables, count and limit Assign a 5 to count, assign 3 to limit.
If count is less than limit, print a message showing count and announcing that count is less than the limit
Else, print a message showing count and announcing that count is NOT less than the limit.
2 points
Create a list of amounts in inventory like this
amounts = [5, 16, 44, 31, 107, 48, 22, 999, 8]
Print an inventory report on each item
Set message to "OK"
For items less than low_limit of 10 Set message to "Too few items"
For amounts above high_limit of 99 Set message to "Too many items"
For amounts equal to missing –it's 999 Set message to
"Unknown number of items - recheck inventory"
Print amount and message
2 points
Create a list of prices at the Cohnah Market like this
prices_list = [4.95, 9.90, 12.44, 1.99, 27.95, 5.00, 11.05, 144.23, 20.00]
For price less than or equal to bargain of 5.00
Set message to "Sale price!"
For price at or above quality of 20.00 Set message to "Exclusive offering"
Print price and message
P3_if_text.py 3 points
Create several variables with these values
word1 = 'Book'
word2 = 'art'
word3 = 'artist'
word4 = 'book'
1 point
Compare word2 with word3.
if word2 comes before word3, print word2 "comes before" word3 else print word2 "comes after" word3
1 point
Compare word1 with word2.
if word1 comes before word2, print word1 "comes before" word2 else print word1 "comes after" word2
1 point
Create this variable and this list
name = 'Wenlan'
chosen = ['Bob', 'Jan', 'Wenlan', 'Ashley'] check whether name in chosen list
if name in chosen, print(name, "is in list")
if not, print(name, "is NOT in list")
P3_elif.py 10 points
The Python if, elif, elif, else statements allow assigning a data item to one and only category. elif means "else if".
Example
After getting a value such as "very short" to category, Python jumps past all remaining elif and else; it then prints height and category.
For this part of the assignment, use if elif elif else …
You will ask for a name, or "Quit" then for the number of points earned on a test. Using this table below, assign a letter grade, print the name, points and grade, then repeat.
1
2 points
Use a while loop to repeatedly ask for a name or "Quit".
2 points
Ask for number of points earned.
5 points
Use an if elif structure to assign a value such as "A" or "B" based on the number of points.
1 point
Ask again for name or "Quit".
Results may look like this (notice a test for each grade):
B onus + 1 Collect names and points in 2 lists, print grades after all data collected.
After collecting the names and points into 2 lists, calculate grades and print name, points and grade for each student. Your results will look something like this:
P3_Spiral.py 7 points
Never save a file called "turtle.py" – if you do so, turtle graphics will not work on your computer until you change the name to anything else.
To fill a triangle with a blue color, do this
2
1 points Set up to draw a spiral as before
Set pencolor to "red"
Set pensize to 2.
Set speed to 'fastest'
Set the variable size to 20
Set the variable angle to 360 divided by 4
Set the variable nudge to 4.7 (any amount from 3 to 8 could
work here)
Set the variable bump to 5
1 point
Repeat the following 60 times
4 points
Draw a square with side length size
filled with the next color from a color_list of at least 3 colors
1 point
Turn the turtle right nudge degrees
Move forward bump units
Change size to be 4 units larger
Your drawing will look like this — you might have some different color choices, or number of colors, and your spiral might curve to the left, or to the right, but it should show some filled squares looking more or less similar to this:
Bonus + 1 point
Fill the color list by asking a user to name the colors to use.
3