diff --git a/cs171/lect09/greet.py b/cs171/lect09/greet.py new file mode 100644 index 0000000000000000000000000000000000000000..edcfd835dc2c4234a501ab22d97b6b42c1933a67 --- /dev/null +++ b/cs171/lect09/greet.py @@ -0,0 +1,26 @@ +def greet(name, timeOfDay=None): + if timeOfDay == None: + return f"Hey, {name}" + else: + return f"Good {timeOfDay}, {name}" + +returnValue = greet("Bob") +print(returnValue) + +returnValue = greet(timeOfDay="morning", name="Kim") +print(returnValue) + +# returnValue = greet("Daisy", "afternoon") +# print(returnValue) + + + + + + + +def positiveNegative(value): + return value, value * -1 +# a1, a2 = positiveNegative(5) +# print(a1) +# print(a2) \ No newline at end of file diff --git a/cs171/lect09/scope.py b/cs171/lect09/scope.py new file mode 100644 index 0000000000000000000000000000000000000000..cc65d92504e532db6b25cb02332e085b7de2ee9b --- /dev/null +++ b/cs171/lect09/scope.py @@ -0,0 +1,22 @@ + +def func(a, b, listC): + ''' + Go away. + ''' + x = 17 + a = a + x + b = b - x + c[0] = x + c[1] = a + c[2] = b + print(f"In func(), the value of a is {a}") + print(f"In func(), the value of b is {b}") + print(f"In func(), the value of c is {listC}") + +a = 10 +b = 20 +c = [0, 0, 0] +func(b, a, c) +print(f"In main, the value of a is {a}") +print(f"In main, the value of b is {b}") +print(f"In main, the value of b is {c}")