3. LEARNING OUTCOMES
ï±I can save code in Pythonâs script mode...
ï±I can get keyboard input from users...
4. [ slide 3 ]
STARTER
Up until now we have not saved any files. We have
worked in interactive mode.
We can also save and run files too â in script mode.
To open a new script mode window:
1. Open IDLE and then from the File menu choose New
Window
2. To save this file choose Save from the File menu.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...
5. [ slide 6 ]
#COMMENTING
#Comments are used in Python to indicate what some part of the
code does.
#Comments always appear in red.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...
6. [ slide 1 ]
MAIN TASK 1
1. Log in to your computer
2. Open Python IDLE
3. Copy the code below to get the program to count to 10
>>> number=1
>>> while number < 11:
print(number)
number = number+1
4. Now in interactive mode, re-write the code so it prints the first 10 square
numbers e.g. 1, 4, 9, 16, 25, 36 ...
Donât forget to add #Comments to indicate what the code does.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...
7. MINI PLENARY
Feedback your solution to the
rest of the class.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...
8. [ slide 9 ]
MAIN TASK 2
Write a Python file called friendly_computer.py
When run it should:
ï± ask the user for their name and store it in a variable
ï± say Hello to the user using the userâs name
ï± tell the user that it was nice talking to them
ï± say âBye [name]â
Hint: You have done most of this in interactive mode.
Do not forget to save your file and send it to your teacher.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...
9. PLENARY
Why add a comment to the beginning of your
code?
In which two modes can you write code in
Python?
Donât forget to upload your work to Moodle.
Lesson outcomes:
ï± I can save code in Pythonâs script
mode...
ï± I can get keyboard input from
users...