Professional Documents
Culture Documents
Anaconda and Python Setup (DSC551, IsP560, IsP781)
Anaconda and Python Setup (DSC551, IsP560, IsP781)
Anaconda and Python Setup (DSC551, IsP560, IsP781)
System requirements
License: Free use and redistribution under the terms of the End User License Agreement -
Anaconda® Individual Edition.
Operating system: Windows 8 or newer, 64-bit macOS 10.13+, or Linux, including Ubuntu, RedHat,
CentOS 6+, and others.
If your operating system is older than what is currently supported, you can find older versions of the
Anaconda installers in our archivethat might work for you. See Using Anaconda on older operating
systemsfor version recommendations.
System architecture: Windows- 64-bit x86, 32-bit x86; MacOS- 64-bit x86; Linux- 64-bit x86, 64-bit
Power8/Power9.
Minimum 5 GB disk space to download and install.
On Windows, macOS, and Linux, it is best to install Anaconda for the local user, which does
not require administrator permissions and is the most robust type of installation. However,
if you need to, you can install Anaconda system wide, which does require administrator
permissions.
For detailed instruction for Anaconda installation refer
to: https://docs.anaconda.com/anaconda/install/
1. Install Anaconda – while installing using the wizard. Please choose add to path. The text will
turn red as warning but please proceed.
2. After a successful installation of Anaconda we can start using Anaconda prompt by typing it
in the windows menu.
3. Use the anaconda command to create a new environment. (Refer to conda cheat sheet)
4. Creating new environment
- conda create -n razif_27 (razif_27 is the preferred environment name)
or
- conda create --name razif_27
or
- conda create --prefix c:\Users\user\Documents (c:\Users\user\Documents is the
preferred path name)
or
- conda create -p c:\Users\user\Documents
5. Activate our environment (make sure that you are using the correct environment)
6. List of other useful conda commands.
- conda install
- conda activate / activate
- conda list
- conda env list
7. while using your preferred environment. Install the correct libraries. In this example we will
be using:
- python 3.7
- jupyter
- numpy
- matplotlib
- pandas
- tensorflow (later)
8. You can either type a full installation command such as:
- conda install python=3.7 jupyter numpy matplotlib pandas tensorflow (all this will be
installed in the current activated environment)
9. You can now do your exercise either in python shell (python) or jupyter notebook (jupyter
notebook)
10. Another way of executing a python script is to create a <filename>.py file. And execute it by
typing python <filename>.py (bear in mind the file must be in the current active directory)
11. Dos commands to manage file/directories and browse trough the windows drive path.
- cd <PATH> (example <PATH> is C:\Users\USER\Documents\razif)
- cd.. (back one directory path)
- cd\ (change to root path)
- c: or d: (change between drives)
- dir (list all the files in the directory)
- help (list all the available dos command and its descriptions)
- help <dos command>
Pyhton commands
1. initially the most important part of any programming language is to be able to create a
variable. In python we simply assign a variable with any values that we preferred.
Ex:
- variable_01 = 1
- variable_02 = 2.45
- variable_03 = “HELLO WORLD”
- variable_04 = ‘A’
(the created variable can be either, integers, floating values, texts, characters, list, tuple,
dictionary. In some cases the variable can contain objects)
- import numpy as np (np is a variable that carries the functions that is contained in the
object numpy *objects can be a library that is imported from the environment)
2. More example on the basic syntax can be reffered to the iPython notebook files 03-python-
basic-syntax.ipynb
3. You can use basic mathematical operators such as + - * / = to perform calculations
Ex:
- y = m*x+c (the variable m, x and c must be assigned with either an integer or floating
values to produce y)
4. There are other useful mathematical operators that can be used to do other complex
operations.
Ex: >, <, >=, <=, !=, ==, and, or, not.
5. There are three complex datatypes in python.
Lists
Tuples
Dictionary
Python Dictionary¶
1 cmp(dict1, dict2)
2 len(dict)
Gives the total length of the dictionary. This would be equal to the number of items in
the dictionary.
3 str(dict)
4 type(variable)
Returns the type of the passed variable. If passed variable is dictionary, then it would
return a dictionary type.
1 dict.clear()
2 dict.copy()
3 dict.fromkeys()
Create a new dictionary with keys from seq and values set to value.
4 dict.get(key, default=None)
5 dict.has_key(key)
7 dict.keys()
Similar to get(), but will set dict[key] = default if key is not already in dict
9 dict.update(dict2)
10 dict.values()