CS-A1113 - Basics in Programming Y1, Lecture, 14.9.2021-9.12.2021
This course space end date is set to 09.12.2021 Search Courses: CS-A1113
Översikt
-
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 Exam set-up will also use 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.
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)
PyCharm
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.
Notepad++
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").