Starting from:
$35

$29

Project 2 Solution

Use Python 3 for all projects this term.




Submit your Python 3 .py programs to Canvas.




Submit each program as a separate file.




20 points




General Hint




Look in Canvas for Files Examples







P2_list.py 5 points




2 points




Create a list called majors_list



Assign a list of 4 to 6 majors to majors_list. Examples




CIS, Business, Chemistry, Journalism Digital Art, Math, Music




1 point




Use the len function to assign the length (number of items) in your majors_list list to the variable n_majors



Print the variable n_majors with a suitable message.




2 points




Create a for loop that can access each item in the majors_list. The for loop will print each of the majors in the list.



Your output should look somewhat like this:























































P2_listadd.py 9 points




Start with an empty name_list.




2 points

Use the input(hint) function to ask a user for a name or "Quit" to stop.




3 points

While the user has not typed "Quit", use

name_list.append(name ) to add the name to the list.




2 points




After getting all the names, print a list of each name in the list.




Check out Canvas Modules Week2 for a .pdf of code to do similar tasks. You'll need to adapt it to work with this list of friends.




Here is an example of asking for the data, then displaying the list of friends.




















































Bonus + 1 Sort the names before printing them.




After collecting the names, sort them before printing them.




Your results will look something like this:








































Notice that the names




are now in alphabetic




order
















P2_Spiral.py 6 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.




2 points




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




The 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




2 points




Draw a square with side length size 1 point




Turn the turtle left nudge degrees




Move forward bump units




Change size to be 4 units larger




1
Your drawing will look like this:



















































































































































































































2

More products