@@ -81,6 +81,17 @@ class change_function_name(VerbatimStep):
8181
8282program_in_text = False
8383
84+ hints = """
85+ You have to change the name in the function definition header, but that's not all.
86+ If you just change the name in the function definition header, what happens?
87+ You get an error. Look at the message. What is it telling you? Where does the error come from?
88+ If your function is called `say_hello`, what does `greet("Alice")` mean?
89+ You need to change exactly 3 lines of the program.
90+ In each line you change, change exactly one word.
91+ Don't touch the body of the function. It should still have `print("How are you?")`.
92+ You should still call the function twice after defining it, with arguments `"Alice"` and `"Bob"`.
93+ """
94+
8495def program (self ):
8596def say_hello (name ):
8697print ("Hello " + name + "!" )
@@ -89,14 +100,45 @@ def say_hello(name):
89100say_hello ("Alice" )
90101say_hello ("Bob" )
91102
103+ class change_parameter_name (VerbatimStep ):
104+ """
105+ Good! Now do a similar exercise: change the name of the parameter from `name` to `person_name`.
106+ """
107+
108+ program_in_text = False
109+
110+ hints = """
111+ You have to change the parameter name in the function definition header, but that's not all.
112+ If you just change the parameter name in the function definition header, what happens?
113+ You get an error. Look at the message. What is it telling you? Where does the error come from?
114+ If the parameter is called `person_name`, what does `print("Hello " + name + "!")` mean?
115+ You need to change exactly 2 lines of the program.
116+ In each line you change, change exactly one word.
117+ Don't touch the part after the function definition, i.e. `say_hello("Alice")` and `say_hello("Bob")`.
118+ You should still have two statements in the function body, including `print("How are you?")`.
119+ """
120+
121+ def program (self ):
122+ def say_hello (person_name ):
123+ print ("Hello " + person_name + "!" )
124+ print ("How are you?" )
125+
126+ say_hello ("Alice" )
127+ say_hello ("Bob" )
128+
92129class print_twice_exercise (ExerciseStep ):
93- """"
94- Here's an exercise: write a function called `print_twice` which accepts one argument `x` and prints that argument twice.
130+ """
131+ Well done!
132+
133+ Now write your own function called `print_twice` which accepts one argument `x` and prints that argument twice
134+ on two lines.
95135
96136For example, `print_twice("Hello")` should output:
97137
98138 Hello
99139 Hello
140+
141+ You can test your function by calling it after the function definition, but it's not required.
100142"""
101143function_name = "print_twice"
102144
@@ -110,7 +152,6 @@ class print_twice_exercise(ExerciseStep):
110152Use the parameter inside the function body.
111153Make sure the body is indented.
112154The body needs two statements or a very simple loop.
113- You can test your function by calling it after the function definition, but it's not required.
114155Make sure that you don't call your function inside the function body. Check your indentation.
115156"""
116157