Skip to content

Commit

Permalink
Focus
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jan 15, 2024
1 parent c2d9bf0 commit 30b72fc
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
87 changes: 87 additions & 0 deletions docs/afternoon_session/command_line_arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Command-line arguments

!!!- info "Learning objectives"

- Can read the command-line arguments
- Can run a Python script with command-line arguments

???- question "For teachers"

Teaching goals are:

* Learners have used sys.args
* Learners have run a Python script with command-line arguments

Lesson plan:

* 5 mins: prior knowledge
* 5 mins: presentation
* 15 mins: challenge
* 5 mins: feedback

## Overview

Sometime, also programs need input, for example
the name of the input file and the name of a results file:

```
python3 my_input.csv my_results.csv
```

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'.

## Exercises

### Exercise 1: Fail at running a first program

!!!- info "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](https://openbookproject.net/thinkcs/python/english3e/index.html):

* 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

!!!- info "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:

- [the UPPMAX documentation 'Loading Python packages'](http://docs.uppmax.uu.se/software/python/#loading-python-packages)
- [the UPPMAX documentation 'Modules'](http://docs.uppmax.uu.se/cluster_guides/modules/)

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'](http://docs.uppmax.uu.se/getting_started/login_rackham/)
and enable X-forwarding.

???- question "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](https://youtu.be/bnN-1uzsgvk)

## Links

* [How to Think Like a Computer Scientist: Learning with Python 3](https://openbookproject.net/thinkcs/python/english3e/index.html)
2 changes: 1 addition & 1 deletion docs/afternoon_session/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This module introduces the fundamentals of Python programming language.
|---------------|-------------------------------|
| 13:00-14:00 | [UPPMAX modules and Python packages](hello_little_turtles.md)
| 14:00-14:15 | Break |
| 14:15-15:00 | [File IO](files.md), command line arguments |
| 14:15-15:00 | [File IO](files.md), [command line arguments](command_line_arguments.md) |
| 15:00-15:15 | Break |
| 15:15-16:00 | Graphics, functions |

Expand Down
3 changes: 0 additions & 3 deletions lesson_plans/20240118/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ Teaching goals:
* Learners have used a free and online book they can use for future reference
* Learners have loaded Python using the module system
* Learners have used the Python interpreter
* Learners have seen IPython
* Learners have seen Jupyter
* Learners have seen VSCode
* Learners have used command-line arguments as input
* Learners have read a file
* Learners have written to a file
Expand Down

0 comments on commit 30b72fc

Please sign in to comment.