Skip to content
Snippets Groups Projects
Commit 9eff39cd authored by Robert Lanzafame's avatar Robert Lanzafame
Browse files

Merge branch 'pa-1-material' into 'main'

Pa 1 material

See merge request !81
parents c8644891 5c57f0b5
No related branches found
No related tags found
2 merge requests!90Publish Week 1,!81Pa 1 material
Pipeline #207295 passed
......@@ -49,10 +49,11 @@ parts:
title: Overview
- file: programming/golden_rules.ipynb
title: The Golden Rules
- file: programming/computers/overview
title: Computers
- file: programming/code/overview
title: Code
title: Computers & Code
sections:
- file: programming/code/packages
- file: programming/code/environments
- file: programming/programs/overview
title: Programs
- file: programming/communication/overview
......
# Environments
Sets of packages. How they work and how you can manage them (with examples).
\ No newline at end of file
# Code
# Computers & Code
text. Matlab also high level and multi-purpose like Python.
Things that will definitely go here:
- functions (a brief overview/highlight of features, then link to the object part of programs)
- complexity: where does it come from and why is it important (work backwards to know which concepts need to be included (e.g., bits and flops etc)); can find good reference rather than repeat chapters of numerical analysis textbook material
\ No newline at end of file
- complexity: where does it come from and why is it important (work backwards to know which concepts need to be included (e.g., bits and flops etc)); can find good reference rather than repeat chapters of numerical analysis textbook material
## Python language
There are some things included here, but we will need much more
# Packages
Python only has some basic functionality
Standard packages
Need to do other stuff: add more!
This comes with a downside: keeping all of these packages up to date. The suite of packages together creates an **environment,** which is the subject of the next Section.
## Packages
**package** defined
there are many sources. common ones are PyPI and conda forge
We can also have local packages! we will learn about those later
### Installing Packages
How to install packages
Use conda. Always do it this way:
```{admonition}
code
```
A bit of a note about packages/modules and methods, with example of `matplotlib.pyplot` and a method.
```{note}
you may ave used pip install in the past, but it's not good practice since it can mess with your stuff...
```
\ No newline at end of file
# Computers
text.
......@@ -17,6 +17,63 @@ Riccardo ideas. For now, when in doubt add content to the JB. Can move text to w
8. Some handy tricks (we can make a special page on the website to quickly illustrate things described above, and provide links to the theory, explanation and case studies in the textbook)
## Why do you need Python?
Python is a computer programming language that is widely used in both academia and industries related to Civil Engineering, Environmental Engineering and Applied Earth Sciences. Being skilled in Python will help you on multiple occasions, including in your master courses.
## What can computers do for us?
As an engineer or scientist, you will deal with units of information which are called <b>data</b>. The most important tasks that a computer can do for us are:
1. Reading data
2. Processing data
3. Visualizing data
These are tasks that require many repetitions and high precision.
_1. Reading data_
Reading data means the computer acquires data from a source and places it into its volatile memory for processing. Volatile memory keeps the data stored until the power supply is interrupted. The way data is stored in a computer determines how the computer will be able to use it.
_2. Processing data_
Data processing is the manipulation of the stored data in a system. After processing data by performing transformations, calculations, and more, you get an output; results.
_3. Visualizing data_
We map data (original or found) to graphic elements to communicate clearly and efficiently the information contained in the data. A graphic element is an element of a chart, such as a line or a point in the chart.
## What is programming?
Programming is giving your computer a list of instructions for computations in a language it can understand. In your case, this language is Python. A computation is a series of arithmetical ("math") and non-arithmetical ("non-math") steps that transform input to output (result).
There are five different kinds of instructions for computations you use. By ordering and combining them, the computer can achieve results that fulfill the three tasks described earlier. The five kinds of instructions are:
<b>input:</b>
Insert data from a file, the network, other devices, or simply by typing it in.
<b>output:</b>
Display data on the screen, save them in a file, send it over the network, etc.
<b>math:</b>
Perform basic mathematical operations like addition and multiplication.
<b>conditional execution:</b>
Check for certain conditions before further instruction.
<b>repetition:</b>
Perform instructions repeatedly, usually with some variation.
## Introduction to Python
The features of Python are what make it so popular. From the definition available on the corresponding Wiki page: <i> "Python is an <b>interpreted</b> <b>high-level</b> <b>general-purpose</b> <b>programming language</b>. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs, as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects."</i>. Quite a simple, yet concise description due to the meaning hidden behind each buzzword:
<ul>
<li> <b>Interpreted</b> means that there is an <b>interpreter</b>, a software tool, which reads and performs instructions written in Python. If your laptop, phone, or refrigerator has the interpreter, it can run most of the Python scripts!
<li> <b>High-level</b> means that the programming language operates with abstract and more easily understandable concepts. In other words, you don't have to write or understand, code related to the hardware part of your machine (like binary code or assembly).
<li> <b>General-purpose</b> means that the amount of Python application fields are endless. You can write Python scripts to manage and automate some primitive tasks for yourself, you can use it for data science, create your own machine / deep learning project, write your personal web application or even develop a game.
<li> <b> Programming language </b>means a set of specific predefined semantics, instructions, and syntax rules, which are used for writing necessary instructions. It is strictly defined, meaning that 99.99% of all errors in the code are made by the coder, not by the computer.
</ul>
Python scripts run with the help of a Python interpreter, but they can be written by using different software tools. Just like as you write your essay (you can type it in Word, Google Docs, Overleaf, or even on plain paper) you can write your Python code with different editors. You could use the default notepad, notepad++, find a proper website with an inbuilt code editor & interpreter (<a href="https://ideone.com/">IDEone</a>, for example), or use specialized Python code editors (Spyder, PyCharm, Visual Studio, etc). In all cases you will produce a set of instructions, which are stored in a file with the <b>*.py</b> extension and the interpreter will run it completely (from top to bottom).
For this course we will use a slightly different approach to developing a Python script: <b>IPython</b> and <b>Jupyter Notebooks</b>. Think of these as two freely-available tools that add extra functionality to the basic Python programming language. As an example, imagine the camera built into your phone: on it's own it can take pictures, but there are many apps that add filters or sharing via social media that make the impact of your photos much more powerful. This is exactly what IPython and Jupyter Notebooks do for Python, and why they are such important tools in the toolbox of modern engineers. The next Chapter will introduce you to your Python Toolbox for this course!
Loosely broken down into 4 Chapters, with some ideas for possible contents (will fine tune location as we create it!):
......
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