Hello, little turtles!¶
Learning objectives
- Have a first 'Get stuff to work' experience
- Rehearse creating a script
- Experience when importing a Python package gives an error
- Search for an UPPMAX module that needs to be loaded
- Import a Python package successfully
For teachers
Teaching goals are:
- Learners have observed the error when importing a Python package without the needed UPPMAX module loaded
- Learners have search through the UPPMAX modules
- Learners may find out that X-forwarding is important
- Learners have gotten 'stuff to work'
Other goals are:
- Verify that learners indeed have learned how to login with X-forwarding. Redirect to remote desktop environment as a solution
Lesson plan:
- 5 mins: prior knowledge
- 5 mins: presentation
- 25 mins: challenge
- 5 mins: feedback
Overview¶
Sometime you need to get 'stuff to work', for example, code written by someone else. In this session, we practice this, going through the problems and errors that occur when you want to 'just want to run the stupid code'.
flowchart TD
python[[Python]]
%% Give a white background to all nodes, instead of a transparent one
classDef node fill:#fff,color:#000,stroke:#000
subgraph sub_programming_language[Programming language]
interpreted_language[Interpreted language]
programming_language[Programming language]
scripting_language[Scripting language]
interpreter[Interpreter]
scripts[Scripts]
text_files[Text files]
end
style sub_programming_language fill:#ccf,color:#000,stroke:#fcc
subgraph sub_programming_terms[Programming terms]
user_input[User input]
%% file_io[File I/O]
%% command_line_arguments[Command-line arguments]
variables[Variables]
operators[Operators]
%% functions[Functions]
python_packages[Python packages]
graphics[Graphics]
end
style sub_programming_terms fill:#cfc,color:#000,stroke:#fcc
subgraph sub_uppmax[UPPMAX]
uppmax[UPPMAX]
uppmax_modules[UPPMAX modules]
uppmax_clusters[UPPMAX clusters]
text_editors[Text editors]
x_forwarding[X-forwarding]
remote_desktop[Remote desktop]
end
style sub_uppmax fill:#fcc,color:#000,stroke:#fcc
python --> |is a| programming_language
python --> |is a| interpreted_language
python --> |is a| scripting_language
programming_language --> |uses| text_files
interpreted_language --> |has a| interpreter
scripting_language --> |is|interpreted_language
scripting_language --> |runs| scripts
scripts --> |are| text_files
%% scripts --> |can use| command_line_arguments
python --> |has| python_packages
python --> |has| variables
%%python --> |has| functions
python --> |has| operators
%%functions --> |use| variables
operators --> |work on| variables
python_packages --> |allow| graphics
python_packages --> |allow to use| user_input
%% python_packages --> |allow to do| file_io
%% python_packages --> |allow to use| command_line_arguments
uppmax --> |has| uppmax_clusters
uppmax_clusters --> |have| uppmax_modules
uppmax_clusters --> |have| text_editors
uppmax_clusters --> |allow| x_forwarding
uppmax_clusters --> |has| remote_desktop
uppmax_modules --> |allow the use of| python_packages
uppmax_modules --> |allow the use of| interpreter
text_editors --> |work on|text_files
x_forwarding --> |allows|graphics
remote_desktop --> |allows|graphics
variables ~~~ uppmax
Exercises¶
See the exercise procedure here.
Exercise 1: Fail at running a first program¶
Learning objectives
- Rehearse creating a script
- Try to import a Python package
- Observe errors when a package is absent
Read the following sections of How to Think Like a Computer Scientist: Learning with Python 3:
- 3.1. Our first turtle program
Copy-paste the first script in that section to a script.
Run the script and verify it will not run. Does the error message make sense?
Exercise 2: Running a first program¶
Learning objectives
- Import a Python package
- Practice to search for an UPPMAX module that needs to be loaded
- Get a script that requires an UPPMAX module to be loaded to work
Now we try to make this script work!
Read:
Now, try to get the script to work.
When running the code, there should be a visible pop-up window. If not, re-read the UPPMAX documentation page 'Login to Rackham' and enable X-forwarding. If X-forwarding does not work, use the Rackham remote desktop environment.
Need more hints?
The exercise is about practicing to search for an UPPMAX module, hence giving away the answer makes this session useless.
However, if you feel stuck too much, you can watch a video in which this exercise is done here