Have you ever wanted to plot an interesting fact about vaccinations in your country, but were frustrated that you were missing the skills to use the data? Or have you ever been annoyed with the time you spent to manually calculate your grades and credits, and would like to become more proficient with your programming skills, in order to apply them in your everyday life?
Then this course is exactly for you: Beginner's Python for Engineers. You will learn more about how to import and clean data, how to do scientific computation and how to plot and present your findings. The course starts on the 1st of March and involves lectures, exercises and a small group project. Welcome to our course! 😊
Lecture Zoom link:
Topic: Beginner`s Python for Engineers
Time: Every Tuesday starting from March 1st, 2022 14:15 (Helsinki time)
Join Zoom Meeting
Meeting ID: 610 5129 1374
Exercise Session Link:
Go to our Slack and choose the corresponding exercise session channel.
Post your Zoom-link during the Exercise Session: Every Wednesday 10:15-12:00 and one of our TAs will join you.
Course Slack Group:
A+ Platform (for exercises and course materials):(Note: The A+ course instance is being developed during the course. Among other things, the total "maximum points" listed on the A+ sidebar is subject to change.)
How to install Python:
How to use the Code Vault on A+
Course Expectations and Grading
- Participation in Zoom lectures is highly recommended. All lectures are recorded and can be reviewed here.
- A+ Exercises: 40 % of final grade
- Group project: 60 % of final grade
- Active participation (peer support and interactions): extra points
- Answering the course feedback questionnaire: +50 exercise points
Week 1 (February 28 – March 6)
Tue 1 March 14:00–16:15 Lecture: libraries and files: importing and reading Wed 2 March 10:15–12:00 Exercise session
Week 2 (March 7 - 13)
Mon 7 March 18:00 Homework 1 deadline at 18:00
Project group selection deadline at 18:00
Tue 8 March 14:00–16:15 Lecture: selecting and cleaning data Wed 9 March 10:15–12:00 Exercise session
Week 3 (March 14 – 20)
Mon 14 March 18:00 Homework 2 deadline at 18:00 Project topic plan deadline at 18:00 Tue 15 March 14:00–16:15 Lecture: Working on data with pandas Wed 16 March 10:15–12:00 Exercise session
Week 4 (March 21-27)
Mon 21 March 18:00 Homework 3 deadline at 18:00 Tue 22 March 14:00–16:15 Lecture: Handling sparse data with SciPy Wed 23 March 10:15–12:00 Exercise session
Week 5 (March 28 – April 03)
Mon 28 March 18:00 Homework 4 deadline at 18:00 Tue 29 March 14:00–16:15 Lecture: writing results, plotting results Wed 30 March 10:15–12:00 Exercise session
Week 6 (April 04 -10)
Mon 04 April 18:00 Homework 5 deadline at 18:00
Project Notebook deadline at 18:00
Tue 05 April 14:00–16:15 Lecture: Plots Part II
Project Presentations & Discussion
Wed 06 April 10:15–12:00 Exercise session
Week 7 (April 11 - 16)
Mon 11 April 18:00 Project peer review deadline at 18:00
The course project accounts for 60 % of the total course grade. It will be done in groups of 3–4 students. You will be given the chance to select your own groups here on MyCourses.
In the course project, you will use the tools covered in the lectures to analyze data. The project will be handed in as a Python Jupyter notebook (IPYNB-file) that includes all of the code used and a detailed written report of the analysis (as Markdown cells). The code (programming component) and the written report (project report) are graded separately, but they should be freely interspersed in the notebook.
The data you use must come in two separate parts (from different sources):
- A base dataset (larger) as a CSV or Excel file
- Some additional data (smaller) either manually written in the code or as a separate file
Your task is to combine these two groups of semi-related data into a single whole and analyze the results. The combining must be done as part of the code in your notebook. This means that the additional data should not be in your base dataset file, it should instead come from an entirely different source.
You can find the base dataset yourself OR choose one of the predefined datasets (see the PDF file below for the full description). You must find the additional data yourself. The selected data and a short topic plan must be sent in for approval prior to working on the project (see the Submissions section in the PDF file).
During the course, you will need to write and edit Python files (.py). This is best accomplished with an integrated development environment (IDE), which is a software application that can be used to write, debug, and run other computer programs. You can use whichever IDE you wish, but we highly recommend using PyCharm, as the course staff is best equipped to help with PyCharm.
This page describes how to install PyCharm. You can also follow these step-by-step instructions with screenshots here: https://www.guru99.com/how-to-install-python.html
In order to install PyCharm, you first need to install Python.
1. Install the Python interpreter (not required if you already have Python installed on your computer (version 3.5 or later): https://www.python.org/downloads/
- Download the latest version of Python (note that our course exercises use Python 3.7.3)
- Tick “Add to PATH” during the installation phase (if prompted)
2. Install PyCharm (Community version): https://www.jetbrains.com/pycharm/download/
- Select the download page for your operating system.
3. Launch PyCharm:
- When prompted, select “Do not import Settings”.
- Select “Create new project”.
- Make sure that Python 3.7.3. (or whichever version you installed) is selected as the interpreter. The version should be at least 3.5.
NOTE: If the interpreter is something other than the Python you want (e.g. Python 2.7 on macOS), do the following:
- New → Settings (Windows and Linux) OR Preferences (macOS) → Project: <project name> → Project interpreter → Select the correct option from the list.
To change the default interpreter for new projects (macOS):
- File → Other settings → Preferences for new projects.
If Python 3.8 is not found in the list, click on the Wheel icon → Add → System interpreter.
4. Create a file and run the code:
- From the project New → Python File → Named eg “test.py”
- Run the code you entered by right-clicking on the code → Run
- When the environment is enabled, make sure it is the correct version of Python: write the following lines in the coding environment:
import sys print(sys.version)
and run the code: check that the version is the one you just installed (e.g. 3.7.3; versions 3.5 upwards do not have big differences from the perspective of this course).
If you cannot download PyCharm to your computer
If, despite the instructions, you do not succeed in the installations, you can ask for advice in the Exercise Sessions or on Slack. Do note that the use of PyCharm (or any other IDE, such as Eclipse) is not strictly speaking mandatory for completing the course assignments. You can write programs with any editor that saves the written file as plain text (such as Notepad or Emacs). You can then test the program by running it with a Python interpreter, for example in a command line window. All you need to do is have a Python interpreter installed on your computer that uses a version of Python 3, so an IDE may not be needed.
Optionally, you can also install Notepad++. Notepad++ is a lightweight text editing program that launches quickly, which can be especially useful if you write programs in an environment with limited performance. Note: Notepad++ does not include the same functionality as the actual IDE, but it does emphasize the code in .py files with illustrative colors and helps with indents. Notepad++ is suitable, for example, for viewing and making small edits on ready-made python code. You can't run Python files directly from Notepad++, but you can, for example, go to the folder where this file is in the file manager, open a command line ("Terminal", "Command prompt") and type "python filename.py" (or "python3 filename.py" or "python3.8 filename.py").
You can ask for help with the weekly Exercises either in the Exercise Sessions or in the course's official Slack workspace.
Asking for help with a well-defined question
"My program does not work, please help." This is a very general statement, and it does not make for a good question. Questions like this one take a lot of time for the answerer to try to figure out what is happening.
There can be any number of reasons a program does not work. For example, it does not compile, it throws an error, or it does not do the right calculations. In order for us to help you efficiently, YOU need to give us a more detailed description of the problem at hand.
Use the following structure for your question:
- Start with the error. What kind of error is it? Try to be as precise as possible about the error. When does the error occur? Which input works, which input does not work?
- Describe, why you think the error occurs, or in which part of your code the error is.
- Describe what you have tried so far to solve the error.
Examples of well-defined questions
1. When I try to run my program main.py it does not run and I get the following error:
" File "C:/Users/me/pythonError/main.py", line 10
age := int(input("Enter your age\n"))
SyntaxError: invalid syntax.
2. I think that the syntax I am using on line 10 is not right.
3. I tried to first assign age to zero, but the same error kept popping up.
1. When I try to run my program main.py it starts running and asks for my input. After the input it throws the following error:
Traceback (most recent call last):
File "C:/Users/me/pythonError/main.py", line 42, in <module>
File "C:/Users/me/pythonError/main.py", line 9, in ageCalculation
NameError: name 'a' is not defined
2. I think the error is after the input handling (line 3-7) and before any calculations (line 10-21).
3. I tried to print a message to myself on line 8 and the message was printed, so I am pretty convinced everything works until line 8. I tried with the following inputs: 1998, 2020 and 1730,1798, and 2010,2012 but the error occurred for all the inputs in the same way.
1: When I calculate the age of a person with a given year of birth for a given year it gives the wrong result. For example, for the input (1999, 2010), it outputs 10 instead of 11 years.
2: I think something in my calculation (math) is not working as it should. I think it happens between line 5 and line 15
3. I tried different inputs. My program works correctly for the input (2012,2015), where I get the right answer of 3 years, but not for the input (1999, 2010), where the program calculates 10 instead of 11.
Lecture 1: 01.03.2022
We discuss the course structure, the project requirements as well as input: libraries, files how to import packages and how to read files
Lecture 2: 08.03.2022
We discuss how Pandas Dataframe and Series type and how to clean and select data
Lecture 3: 15.03.2022
We discuss how to use some Pandas Methods and we take a look at lambda
Lecture 4: 22.03.2022
We discuss comprehension, zip and map and Spare Matrices
Lecture 5: 29.03.2022
We discuss how to write to a file and what to consider as well as how to plot
Lecture 6: 05.04.2022
Group Project Presentations
Exercise Solution Recaps:
Week 1 Model solution recap