Syllabus: [pdf] [tex]
Syllabus (post-virus): [pdf] [tex]
link to internal Fairmont State Jupyter notebook instance (not accessible from off campus)
Link for doing code in-browser

Homework
Homework 1 (due 22 January, graded 5 February): Section 2.3 checkpoint: #2.7, 2.8, 2.9; Section 2.5 checkpoint: #2.11, 2.15; Section 2.6 checkpoint: #2.18 and the following problem:
Problem A: Think about three broad topics (e.g. music, etc) you are interested in. Write a program that asks the user to input their favorite example from each of those topics and display the results appropriately.
Homework 2 (due 27 January, graded 23 February): section 2.7 checkpoint: #2.19, 2.20, 2.21; section 2.8 checkpoint: #2.23, 2.26, 2.27, and the following problem:
Problem A: Consider the ideal gas law from chemistry: $pV=NRT$, where $p$ represents pressure, $V$ represents volume, $N$ represents the amount of a substance, $R$ is the gas constant, and $T$ is the temperature. This equation can be algebraically rearranged to obtain $R=\dfrac{pV}{NT}$. Write a program to ask a user to input values for the variables $p$, $V$, $N$, and $T$ and then calculate and print the value of $R$ in response.
Homework 3 (due 3 February; graded 9 March): section 2.8 checkpoint: #2.23, and the following problems:
Problem A: Modify the following code by only adding end and sep options to the existing print commands to get the output
A.B;C:E--
Here is the code to modify:
print("A","B") print("C") print("E")
Problem B: Use the turtle graphics package to make the turtle draw the first letter of your first name and the first letter of your last name, each in a different color. Be sure that the two letters are separated by a space and are not connected with a line.

Homework 4 (due 10 February):
Problem A: Write a program that asks the user for a number. The program should respond with "positive" if the number is greater than 0, "negative" if the number is less than 0, or "zero" if the number is equal to zero.

Problem B: Write a program that asks the user for an integer between 1 and 10. The program should reply with the Roman numeral of that integer.
recall Roman numerals:
 Integer Roman Numeral 1 I 2 II 3 III 4 IV 5 V 6 VI 7 VII 8 VIII 9 IX 10 X

Problem C: (A simple game) Write a program that asks a user to insert some number of pennies, nickels, dimes, and quarters. First, the program should tell the user how many total cents this is. If the total value of the coins is equal to one dollar (i.e. 100 cents), then the program should congratulate the user for winning the game. Otherwise, the program should display a message saying that the total amount is greater than or less than one dollar (depending on what was inserted).

Homework 5 (due 19 February):
Problem A: In mathematics, the notation $n!$ represents the factorial of the nonnegative integer $n$. The factorial of $n$ is the product of all the nonnegative integers from $1$ to $n$. For example, $$4! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot = 24$$ and $$7! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 \cdot 6 \cdot 7 = 5040.$$ Write a program that lets the user enter a nonnegative integer then uses a loop to calculate the factorial of that number. Display the factorial.

Problem B: Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies.

Problem C: Write a program that predicts the approximate size of a population of organisms. The application should use text boxes to allow the user to enter the starting number of organisms, the average daily population increase (as a percentage), and the number of days the organisms will be left to multiply. For example, assume the user enters the following values:
Starting number of organisms: 2
Average daily increase: 30%
Number of days to multiply: 10
The program should display the following table of data:
Day	Population
1	2
2	2.6
3	3.38
4	4.394
5	5.7122
6	7.42586
7	9.653619
8	12.5497
9	16.31462
10	21.209

Homework 6 (due 26 February):
Problem A: A "sleep debt" represents the difference between a person's desirable and actual amount of sleep. Write a program that prompts the user to enter how many hours they slept each day over a period of seven days. Using 8 hours per day as the desirable amount of sleep, determine their sleep debt by calculating the total hours of sleep they got over a seven-day period and subtracting that from the total hours of sleep they should have gotten. If the user does not have sleep debt, display a message expressing your jealousy.

Problem B: The len function returns the length of a string. Consider
message="abcd" print(len(message))
which will print "4". Use this function to write a program with a loop that repeatedly asks the user to enter a string. The user should enter nothing (i.e. hit "Enter" without inserting any text) to signal the end of the loop. Once the loop ends, the program should display the average length of the words entered.

Problem C: Write a program that uses nested loops to draw this pattern:
##
# #
#  #
#   #
#    #
#     #

Problem D: Draw the following picture (or something very similar to it) using the turtle package:

Homework 7 (due 2 March): Problem A: Write a function named max that accepts two float values as arguments and returns the larger of the two values. For instance, if 1.3 and 3.9 are given, then it should return 3.9.

Problem B: (Rock, paper, scissors game) Write a program that lets the user play rock, paper, scissors against the computer. Here is how it should work:
1. A random number between 1 and 3 should be generated at the start of the game. If that number is 1, then the computer will play "rock", if it is 2, then the computer will play "paper", and if it is 3 then the computer will play "scissors" (but do not display this choice to the user).
3. The computer's choice is shown after the user enters their choice.
4. The winner is selected by the following rules:
• if one chooses rock and the other scissors, the player choosing rock wins
• if one chooses scissors and the other chooses paper, the play choosing scissors wins
• if one chooses paper and the other chooses rock, the player choosing paper wins
• if both players choose the same, then the game is a tie and must be played again
5. The entire gameplay steps 1 through 3 should be built into a function named
play_game()
. Based on step 4, the function should either print the winner and return a 1 OR it should print "There is a tie" and return a 0. Returning a zero should cause a loop running the game function to be run again until a 1 is returned. (hint: something like
while gamereturn!=1:
gamereturn=play_game()
is what you want to do here
)

Problem C: Please give a preliminary idea for your major project. In my repsonse to your submission in this homework, I will tell you within Blackboard what you should do next as part of the project. Accomplishing that goal will constitute your first "project homework assignment". If the project is not appropriate, then I will let you know and you will have until the end of the week (6 March) to make another suggestion. If you fail to do that, then I will give you a project and you will have to do that one for the remainder of the semester.

Notes from class
15 January
17 January
22 January
24 January
29 January
31 January
3 February
5 February
7 February
10 February
12 February
14 February
17 February
19 February
21 February
24 February
26 February
28 February

Other stuff
Homework guidelines