summaryrefslogtreecommitdiff
path: root/basic_python/README.md
blob: 54066b7b650291db281fb917368a8e6161ec8fa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Basic Python Programming

This is a fairly intense two day workshop on learning basic Python
programming. The course is completely hands-on and requires each student to
have access to a computer with the necessary software installed and with
internet access.

The workshop is designed to be taken with our online testing platform called
[yaksh](http://yaksh.fossee.in). After every hands-on lecture, we have a
practice session where students are expected to solve the given problem on our
online platform. The solutions to each problem will be shown and students will
proceed to the next problem. Close to 60 exercises will be solved by the
students over the course of this workshop.

Students will also need to take a programming test to be assessed and receive
certificates.

The course only covers basic Python programming. See the outline of the course
below to see what is covered.



## Intended audience and pre-requisites

This course requires that students have completed our "Introductory Scientific
Computing with Python" course and passed it.

This course is designed to be taken by folks who do not have any significant
programming experience. The students should be comfortable using a computer
and editing text files.

## Software and hardware requirements

A laptop or reasonably configured desktop is recommended since this will be a
hands-on session.

Please install Python 3.x (or 2.7.x if 3.x is not available) for this course.

On Linux, Windows and Mac OS X it is easiest to install Python and many other
useful packages by installing Anaconda. Download the Anaconda Python distribution
for your OS and architecture from here: https://www.anaconda.com/products/individual. The instructions to install are available here https://docs.anaconda.com/anaconda/install/

You can use Anaconda or Conda along with the Spyder editor or the VSCode editor.

On many Linux distributions, Python is already available. We suggest that you
install Python 3.x and are comfortable with any text editor. Editors that
integrate with Python would be better.


## Outline of the course

- Python Basics:
  - Basic datatypes: numbers, booleans, and strings
  - Basic operators: arithmetic, string operators, and string methods.
  - Relational and logical operators.
  - `assert` statements and built-ins.
  - Simple input and output with `input` and `print`.
  - Simple Exercises.

- Practice exercises for the basics.

- Basic control flow in Python:
  - Conditional flow with `if/elif/else`.
  - The ternary operators.
  - Looping with `while`.
  - Solving a simple problem.
  - Looping with `for` and `range`.
  - Using `break`, `continue`, and `pass`.
  - Exercises

- Practice exercises for control flow.

- Core data structures in Python:
  - Lists
  - Tuples
  - Dictionaries
  - Sets
  - Some exercises.

- Practice exercises for the core data structures.

- Writing functions.
  - Simple functions taking no arguments, returning `None`.
  - Functions taking arguments and returning values.
  - Docstrings.
  - Returning multiple values.
  - Default arguments.
  - Keyword arguments.
  - Variable scope when defining functions.
  - Mutable vs immutable arguments.
  - Example functions to read for practice.
  - Nested functions.
  - Returning functions.

- Practice exercises for functions.

- Python modules.
  - Creating modules
  - Importing modules.
  - `sys.path`, `PYTHONPATH`
  - Running modules as scripts
  - The use of `__name__`.

- Reading and writing files.
  - Reading files.
  - Writing files, using `.write` and using `print`
  - Example: parsing data from a file.

- Python exceptions:
  - Standard exception examples.
  - Catching exceptions with `try/except`
  - Catching multiple exceptions.
  - Cleanup with `finally`
  - Raising one's own exceptions.

- Practice exercises for files and exceptions.