1.3 Write a function that returns True if a positive integer n is a prime number and False otherwise.
A prime number n is a number that is not divisible by any numbers other than 1 and n itself. For example, 13 is prime, since it is only divisible by 1 and 13, but 14 is not, since it is divisible by 1, 2, 7, and 14.
Hint: use the % operator: x % y returns the remainder of x when divided by y.
def is_prime(n): is_prime(10) False is_prime(7) if n 1: return False while k n: if n % k 0: return False return True
2.1 Use these rules to draw a simple diagram for the assignment statements below.
x 10 % 4
y x
x ** 2
2.2 Use these rules and the rules for assignment statements to draw a diagram for the
code below.
def double(x): return x * 2 def triple(x): return x * 3 hat double double triple
2.3 Let’s put it all together! Draw an environment diagram for the following code.
def double(x): return x * 2 hmmm double wow double(3) hmmm(wow)
2.4 Tutorial: Draw the environment diagram that results from executing the code
below.
def f(x): return x def g(x, y): if x(y): return not y return y x g(f, x) f g(f, 0)



