10 Pts)
Assignment A: Setup Python (This assignment will setup your base Python enviroment. If you already have it, simply run challenges and answer questions (if any). If you cannot run challenges, set up the needed software.
Challenges
- Challenge 1: Terminal
- Challenge 2: Python3
- Challenge 3: pip
- Challenge 4: Test Python
1.) Challenge 1: Terminal
If you are using MacOS or Linux, skip steps for Windows.
For Windows,
-
Use a Unix emulator such as cygwin, the built-in Windows Subsystem for Linux WSL or a Linux VM.
- Windows CMD.EXE is no option. Powershell is not recommended since it is not compatible with Unix standards.
-
Follow instructions for setting up cygwin.
Open a terminal and type commands:
> ls -la
> pwd
> whoami
> cat ~/.profile
> cat ~/.bashrc
> echo $PATH
Explain commands. If you are not familiar, find out about these basic Unix shell (bash, zsh, ...) commands (e.g. from introduction or tutorial).
On Mac, refer to file .zshrc instead of .bashrc.
(4 Pts)
2.) Challenge 2: Python3
Check if you have Python 3 installed on your system. Name three differences between Python 2 and 3.
Run commands in terminal (exact version 3.x.x may vary):
> python --version
Python 3.12.0
(2 Pts)
3.) Challenge 3: pip
Check if you have a Python package manager installed (pip, conda, ... ). pip
is Python's default package manager needed to install additional python packages and libraries.
Follow instructions for installation:
-
download the
get-pip.py
file. - run
python get-pip.py
- or update pip to latest version:
python -m pip install --upgrade pip
Run commands in terminal:
> pip --version
pip 23.2.1 from C:\Users\svgr2\AppData\Local\Programs\Python\Python312\Lib\site-
packages\pip (python 3.12)
(2 Pts)
4.) Challenge 4: Test Python
Test Python:
> python
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello World')
Hello World
>>> help('modules')
...lists installed python packages
>>> 2+3*4
14
>>> x = 2+3*4
>>> x
14
Create a file print_sys.py with following content.
import platform
impl = platform.python_implementation()
ver = platform.version()
mach = platform.machine()
sys = platform.system()
print('Python impl: ' + impl)
print('Python version: ' + ver)
print('Python machine: ' + mach)
print('Python system: ' + sys)
print('Python version: ' + platform.python_version())
Run the file. Output varies depending on your system.
> python print_sys.py
Python impl: CPython
Python version: 10.0.19045
Python machine: AMD64
Python system: Windows
Python version: 3.12.0
(2 Pts)