Skip to content
Snippets Groups Projects
Commit b64de5c1 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add installation and 'Hello World' chapter

This commit adds a chapter about the installation of python3, numpy, scipy and
matplotlib and a chapter with a first 'Hello World'-like example.
parents
No related branches found
No related tags found
No related merge requests found
This repository consists of a collection of python examples intended as an
introduction on the usage of python in data analysis, especially for the
advanced laboratories in physics at the University of Freiburg. In previous
years code examples for [ROOT](https://root.cern.ch/) have been provided.
Material on the usage of python was missing. The code examples shown in this
repository follow the examples shown in the ROOT introductions.
# Installation
To get started with python for data analysis in the advanced laboratories you
need the python interpreter. In this document we will use `python3`. The
additional packages `numpy`, `scipy` and `matplotlib` are useful for data
analysis and data presentation. To install all the packages on Ubuntu, you
can run the following command line.
```bash
sudo apt-get install python3 python3-numpy python3-scipy python3-matplotlib
```
<!--
Doxec in a docker container needs a slightly different command, please keep them
in-sync.
-->
<!-- console
```bash
$ apt-get update
$ apt-get install -y python3 python3-numpy python3-scipy python3-matplotlib
```
-->
# 'Hello World' Example
The first example is basically a 'Hello World' script, to check whether python
is running correctly. Create a file named `hello_world.py` and add the following
content.
<!-- write hello_world.py -->
```python
import math
print("Example 1:")
print(" Square root of 2 = %g" % math.sqrt(2))
```
To run the example, open a terminal tell the python interpreter to run your
code.
<!-- console_output -->
```sh
$ python3 hello_world.py
Example 1:
Square root of 2 = 1.41421
```
Have you seen the expected output? Congratulations, you can move on to real-life
examples.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment