### 2018-02-02 HW

posted Feb 2, 2018, 6:25 AM by Konstantinovich Samuel   [ updated Feb 3, 2018, 4:25 PM ]
 Goal: Solve basic python problemsVariables in python:There is no distinction between create/change variables in Python (like  set / let in Netlogo)To create or change a variable in python we use the assignment operator the equals sign:x = 3 #create a variable x make it store the value 3name = "bob" pi = 3.14159x = x + 1 #change x to: the old value of x plus 1pi = 3 #change the value of piBooleans in python:Python booleans are written as True and False. Capitalization matters.The logical operators are:  and , or (they only work on booleans!)The comparative operators:       < , >       <= , >=       == (equals)       !=  (not equals)   QUESTION: Notice equals is written with two equal signs, why is this? Functions in python :There is no distinction between functions/procedures in python (like to / to-report)def ( ) :    return e.g.#this is a simple functiondef  foo(a,b):    return a + b#this shows you can have multiple statements in a functiondef bar(nom):    x = 3 * nom    return  x == 12 #this is how you return a boolean#this does not return a value explicitly. The function call has a special value when this happens.def bah(name):    print "Hello " + nameClasswork:Boolean functions:  Tend to be tricky to students at first. They are not so bad after you practice a while.Write a function between(number,a,b) that returns true when the number is between a and b. Assume a < b. Do not use   a