Any questions about anything?
This week :
Tutoring!
I'll do a few demos.
I can give access to jupyter.marlboro.college , including a shell, to anyone who wants that - let me know.
Depending on the assignment, typically you should turn in
The best way to submit work is through the course website - I'll do a demo of how this works.
If that isn't working, email me (mahoney@marlboro.edu) with your code as attachments.
Full credit for a homework assignment is "1.0". For a submission that only does some of what was assigned, especially if I can't see evidence of a real effort, you'll get a fraction of that. There's one term letter grade (A=excellent,B=good,C=fair) for all the homework together.
Python programs can be written in several styles including imperative, object oriented, or functional. This term we'll be doing mostly the first two ... and a little of the third.
Some important ideas:
# an example of a function with an input
# Jim M | Sep 3 2018
def echo(message):
print("you said '", message, "'.")
echo('Hello there')
Run this and discuss it.
variables - named "boxes" to put data in
assignment statement (i.e. how to put data into a variable)
name = "Jim Mahoney"
age = 57
data = [2.3, 3.2, 16.23]
The part on the RIGHT is evaluated first. Then that is put INTO the thing on the left. Consider
x = x + 1
What is going on? Run this pythontutor.com to see.
# convert.py
# A program to convert Celsius temps to Fahrenheit # by: Susan Computewell
def main():
celsius = eval(input("What is the Celsius temperature? "))
fahrenheit = 9/5 * celsius + 32
print("The temperature is", farenheit, "degrees Fahrenheit.")
main ()
# futval.py
# A program to compute the value of an investment
# carried 10 years into the future
def main() :
print("This program calculates the future value")
print("of a 10-year investment.")
principal = eval(input("Enter the initial principal: "))
apr = eval(input("Enter the annual percent interest rate : "))
for i in range(10):
principal = principal * (1 + apr/100)
print("The value in 10 years is: ", principal)