Learning Intentions
Demonstrate and explain the practice of commenting your code
Recap
In our last lesson you used the script below to create the foundations of an artificial intelligence program.
print("Please type your name in")
my_name = input ()
print("Nice to meet you " + my_name)
You should also have managed to add some questions of your own.
print("Please type your name in")
my_name = input ()
print("Nice to meet you " + my_name)
You should also have managed to add some questions of your own.
Starter
Find your program and open it. Next ask the user to name a place they have been on their holidays and then respond with an answer using the name of the holiday location, e.g.
Re-save your program with the name "holiday_question.py"
Task - Adding Comments
Still using Python go to "file new" to open a new window. As a class will will watch & complete the tasks on the power point.
|
Now you need to add comments to all your lines of code. Some questions for you to consider are:
( Try using the think – pair – share approach with these )
1. How could you add some information about the program, creator, date etc.?
2. Is it necessary to comment on every single line?
3. If the interpreter ignores everything after the #, how else could this be useful?
( Try using the think – pair – share approach with these )
1. How could you add some information about the program, creator, date etc.?
2. Is it necessary to comment on every single line?
3. If the interpreter ignores everything after the #, how else could this be useful?