Frequently asked questions#
This page offers some explanations to frequent questions and common problems encountered by beginners in programming. This page is here to help!
What is the “python interpreter”?#
The python interpreter is a program that is able to understand and execute python commands. It needs to be installed on your computer. In this class, we recommend to install python using the mambaforge installer, but other installers exist as well. Once python is installed, the interpreter can be called in two main ways:
the first, maybe most intuitive, is to read and interpret a file containing lines of code (e.g.
myprogram.py
), with the commandpython myprogram.py
in the command prompt (if you forgot what the command prompt is, read this explanation one more time). When using the python interpreter in this way (python myprogram.py
), the interpreter is opened once, it interprets the program line by line, and then closes. If the program instructs to print something on screen or write a file to disk, it will do it.the second way to use an interpreter is in “interactive mode”. To open the interpreter in interactive mode, just type
python
in the command prompt. In interactive mode, the interpreter is waiting for your instructions: instead of reading them from a file, it waits for you to type commands and interprets them after you type “enter”. You can exit the interactive interpreter with the python commandexit()
.
What is a “python script”?#
A python script is a series of valid python commands, often organized in lines (one line is one python command). To execute a script, one can use the python interpreter.
What is a “jupyter notebook”?#
A “jupyter notebook” is a mix of python commands with other elements (text or images). Jupyter notebooks are organized in “cells”, and one cell can only be of one type: “code” or “text” (no exception!). This is important because when a jupyter notebook is opened (in jupyterlab), a python interpreter is also opened in the background (this is called a “kernel” in the jupyter jargon). This python interpreter is there to interpret the code cells in the notebook “on demand”, i.e. when the user asks for it. Text cells, in turn, are not interpreted, they are just displayed.
Jupyter notebooks are widely used for scientific applications. Scientists like the possibility to mix code with other content, in so-called “computational documents”. For beginners however jupyter notebooks can be a bit surprising to use, which is why we don’t recommend their use until week 05 in the class.
Can I use ChatGPT or Copilot in this class?#
The answer is complicated: Learning with artificial intelligence.
I haven’t decided yet if I want to allow ChatGPT in exams, but the answer will probably be no - don’t rely on it!