Introduction to Python for Engineers
Main.PythonIntroduction History
Hide minor edits - Show changes to output
Changed line 56 from:
title='Programing Language Popularity',
to:
title='Programming Language Popularity',
Changed line 7 from:
%width=15px%Attach:download.png [[Attach:programming_languages.csv|Data File (CSV Format)]]
to:
%width=15px%Attach:download.png [[Attach:programming_languages.csv|Data File (CSV Format)]] from [[https://www.kaggle.com/datasets/muhammadkhalid/most-popular-programming-languages-since-2004|Kaggle]]
Deleted lines 154-157:
This same tutorial is also show in a [[Main/MatlabIntroduction|MATLAB]] introduction.
Added lines 156-157:
This same tutorial is also show in a [[Main/MatlabIntroduction|MATLAB]] introduction.
Changed lines 5-76 from:
to:
Python is a high-level and general-purpose programming language. According to several survey results or search engine queries such as the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy.
%width=15px%Attach:download.png [[Attach:programming_languages.csv|Data File (CSV Format)]]
(:toggle hide bar_chart button show="Show Bar Chart Source":)
(:div id=bar_chart:)
(:source lang=python:)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import datetime as datetime
from datetime import timedelta
from plotly.subplots import make_subplots
#pip install bar_chart_race
import bar_chart_race as bcr
url = 'http://apmonitor.com/che263/uploads/Main/'
data = pd.read_csv(url+'programming_languages.csv')
data['Date'] = pd.to_datetime(data['Date']).dt.strftime('%Y-%m')
df=data.copy()
df.index=df['Date'].tolist()
df=df.drop('Date',axis=1)
def make_bcr(df):
bcr.bar_chart_race(
df=df,
filename='programming_languages.mp4',
orientation='h',
sort='desc',
n_bars=20,
fixed_order=False,
fixed_max=False,
steps_per_period=6,#speed control
interpolate_period=False,
label_bars=True,
bar_size=.95,
period_label={'x': .99, 'y': .25, 'ha': 'right', 'va': 'center'},
#period_fmt='%B %d, %Y',
period_summary_func=lambda v, r: {'x': .99, 'y': .18,'s': '',
'ha': 'right', 'size': 8,
'family': 'Courier New'},
period_length=400,
figsize=(5,3),
dpi=500,
cmap='dark24',
title='Programing Language Popularity',
title_size=10,
bar_label_size=7,
tick_label_size=5,
shared_fontdict={'color' : '.1'},
scale='linear',
writer=None,
fig=None,
bar_kwargs={'alpha': .7},
filter_column_colors=True)
make_bcr(df)
(:sourceend:)
(:divend:)
(:html:)
<video width="550" controls autoplay muted>
<source src="/che263/uploads/Main/programming_languages.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
(:htmlend:)
%width=15px%Attach:download.png [[Attach:programming_languages.csv|Data File (CSV Format)]]
(:toggle hide bar_chart button show="Show Bar Chart Source":)
(:div id=bar_chart:)
(:source lang=python:)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import datetime as datetime
from datetime import timedelta
from plotly.subplots import make_subplots
#pip install bar_chart_race
import bar_chart_race as bcr
url = 'http://apmonitor.com/che263/uploads/Main/'
data = pd.read_csv(url+'programming_languages.csv')
data['Date'] = pd.to_datetime(data['Date']).dt.strftime('%Y-%m')
df=data.copy()
df.index=df['Date'].tolist()
df=df.drop('Date',axis=1)
def make_bcr(df):
bcr.bar_chart_race(
df=df,
filename='programming_languages.mp4',
orientation='h',
sort='desc',
n_bars=20,
fixed_order=False,
fixed_max=False,
steps_per_period=6,#speed control
interpolate_period=False,
label_bars=True,
bar_size=.95,
period_label={'x': .99, 'y': .25, 'ha': 'right', 'va': 'center'},
#period_fmt='%B %d, %Y',
period_summary_func=lambda v, r: {'x': .99, 'y': .18,'s': '',
'ha': 'right', 'size': 8,
'family': 'Courier New'},
period_length=400,
figsize=(5,3),
dpi=500,
cmap='dark24',
title='Programing Language Popularity',
title_size=10,
bar_label_size=7,
tick_label_size=5,
shared_fontdict={'color' : '.1'},
scale='linear',
writer=None,
fig=None,
bar_kwargs={'alpha': .7},
filter_column_colors=True)
make_bcr(df)
(:sourceend:)
(:divend:)
(:html:)
<video width="550" controls autoplay muted>
<source src="/che263/uploads/Main/programming_languages.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
(:htmlend:)
Changed line 38 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z_Kxg-EYvxM" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z_Kxg-EYvxM" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Changed line 91 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/p2Dyx9DyQWw" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/p2Dyx9DyQWw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Changed lines 5-11 from:
Python is a high-level and general-purpose programming language. According to several survey results or search engine queries such as the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses the latest release of Python that is currently at version 3.7.
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/LfodqSAgEqg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
There are several resources for learning Python online. For a good start, look at [[https://www.codecademy.com/tracks/python|Code Academy (Python track)]] or view the documentation at [[https://www.python.org/|Python.org]]. For users with a foundation in MATLAB, there are excellent resources that demonstrate [[https://wiki.scipy.org/NumPy_for_Matlab_Users|equivalent Python (Numpy) commands]].
<iframe width="560" height="315" src="https://www.youtube.com/embed/LfodqSAgEqg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
There are several resources for learning Python online
to:
Python is a high-level and general-purpose programming language. According to several survey results or search engine queries such as the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses the latest release of Python that is currently at version 3.9.
There are [[https://youtu.be/LfodqSAgEqg|several resources for learning Python online]]. For a good start, look at [[https://www.codecademy.com/tracks/python|Code Academy (Python track)]] or view the documentation at [[https://www.python.org/|Python.org]]. For users with a foundation in MATLAB, there are excellent resources that demonstrate [[https://wiki.scipy.org/NumPy_for_Matlab_Users|equivalent Python (Numpy) commands]].
There are [[https://youtu.be/LfodqSAgEqg|several resources for learning Python online]]. For a good start, look at [[https://www.codecademy.com/tracks/python|Code Academy (Python track)]] or view the documentation at [[https://www.python.org/|Python.org]]. For users with a foundation in MATLAB, there are excellent resources that demonstrate [[https://wiki.scipy.org/NumPy_for_Matlab_Users|equivalent Python (Numpy) commands]].
Changed lines 15-16 from:
!!!! Option #1: Install Python from Python.org
to:
!!!! Install Python on Windows
Changed line 18 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/bXWlyOMYpRE" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/_BHsM452vK0" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Changed lines 21-26 from:
!!!! Option #2: Install Anaconda
Anaconda includes the Jupyter Notebook and the Spyder IDE. Anaconda is [[https://www.anaconda.com/products/individual|available for download here]].
to:
!!!! Install Python on MacOS
Changed line 24 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/LrMOrMb8-3s" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/2VECcPofhP8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Changed lines 27-33 from:
!!!! Option #3: Online Platforms
to:
!!!! Install Python on Linux
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/eUq-6ZuwC_A" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
(:htmlend:)
!!!! Online Platforms
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/eUq-6ZuwC_A" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
(:htmlend:)
!!!! Online Platforms
Changed line 25 from:
Anaconda includes the Jupyter Notebook and the Spyder IDE. Anaconda is [[https://www.continuum.io/downloads|available for download here]].
to:
Anaconda includes the Jupyter Notebook and the Spyder IDE. Anaconda is [[https://www.anaconda.com/products/individual|available for download here]].
Deleted lines 118-136:
----
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
Changed lines 33-35 from:
There are several online platforms that allow Python through a web-browser including try.jupyter.org and repl.it. An example of using repl.it is here:
https://repl.it/classroom/invite/FS5LV0W
https://repl.it/classroom/invite/FS5LV0W
to:
There are several online platforms that allow Python through a web-browser including [[https://try.jupyter.org|Try Jupyter]] and [[https://colab.research.google.com|Google Colab]].
Changed lines 5-7 from:
Python
to:
Python is a high-level and general-purpose programming language. According to several survey results or search engine queries such as the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses the latest release of Python that is currently at version 3.7.
Changed line 7 from:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]] and [[https://blog.codeeval.com/codeevalblog/2014|CodeEval]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 or Python 3.6+.
to:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]] and [[https://blog.codeeval.com/codeevalblog/2014|CodeEval]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 or Python 3.7.
Changed lines 47-52 from:
Below is an example on how to install [[https://apmonitor.com/wiki/index.php/Main/PythonApp|APMonitor Optimization Suite]] from the command line (start ''cmd'').
pip installAPMonitor
The ''APMonitor'' package name can be replaced with any available package name such as [[https://www.numpy.org|NumPy]].
pip install
The ''
to:
Below is an example on how to install [[https://gekko.readthedocs.io/en/latest/|GEKKO Optimization Suite]] from the command line (start ''cmd'').
pip install gekko
The ''GEKKO'' package name can be replaced with any available package name such as [[https://www.numpy.org|NumPy]].
pip install gekko
The ''GEKKO'' package name can be replaced with any available package name such as [[https://www.numpy.org|NumPy]].
Changed lines 59-60 from:
'''Load and Optionally Install APMonitor Package'''
to:
'''Load and Optionally Install GEKKO Package'''
Added line 62:
module='gekko'
Changed line 64 from:
from APMonitor.apm import *
to:
from pip import main as pipmain
Changed lines 66-68 from:
from APMonitor.apm import *
to:
from pip._internal import main as pipmain
pipmain(['install',module])
pipmain(['install',module])
Added line 73:
module='numpy'
Changed line 75 from:
to:
from pip import main as pipmain
Changed lines 77-79 from:
import numpy as np
to:
from pip._internal import main as pipmain
pipmain(['install',module])
pipmain(['install',module])
Changed line 81 from:
The ''APMonitor'' or ''NumPy'' package names can be replaced with any available package. The pip package manager connects to an online repository to retrieve the latest version of the package and install it. Sometimes a package is needed on a computer that isn't connected to the internet or the package isn't available through pip. Below is information on installing a package wheel (''whl'') file.
to:
The ''GEKKO'' or ''NumPy'' package names can be replaced with any available package. The pip package manager connects to an online repository to retrieve the latest version of the package and install it. Sometimes a package is needed on a computer that isn't connected to the internet or the package isn't available through pip. Below is information on installing a package wheel (''whl'') file.
Changed line 20 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ju6zw83PoKo" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/bXWlyOMYpRE" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Changed lines 102-120 from:
to:
(:source lang=python:)
R = 0.0821 # L-atm/K
T = 500 # K
V = 5 # L/mol
Pc = 37.2 # atm
Tc = 132.5 # K
a = 0.427 * pow(R,2) * pow(Tc,2.5) / Pc
b = 0.0866 * R * Tc / Pc
# Compute in atm
P_ig = R * T / V
P_rk = R * T / (V-b) - a/(V*(V+b)*pow(T,0.5))
# Convert to Pascals
P_ig = P_ig * 101325
P_rk = P_rk * 101325
print("The ideal gas pressure: " + str(P_ig) + " Pa")
print("The Redlich-Kwong pressure: " + str(P_rk) + " Pa")
(:sourceend:)
R = 0.0821 # L-atm/K
T = 500 # K
V = 5 # L/mol
Pc = 37.2 # atm
Tc = 132.5 # K
a = 0.427 * pow(R,2) * pow(Tc,2.5) / Pc
b = 0.0866 * R * Tc / Pc
# Compute in atm
P_ig = R * T / V
P_rk = R * T / (V-b) - a/(V*(V+b)*pow(T,0.5))
# Convert to Pascals
P_ig = P_ig * 101325
P_rk = P_rk * 101325
print("The ideal gas pressure: " + str(P_ig) + " Pa")
print("The Redlich-Kwong pressure: " + str(P_rk) + " Pa")
(:sourceend:)
Changed lines 39-40 from:
!!!! Manage Python Packages
to:
!!!! Install Packages with '''pip''' (Command Line)
Sometimes a script uses a package that is not yet installed. Once Python is installed, a package manager such as ''pip'' or ''conda'' can be used to install, remove, or update packages.
Sometimes a script uses a package that is not yet installed. Once Python is installed, a package manager such as ''pip'' or ''conda'' can be used to install, remove, or update packages.
Changed lines 47-53 from:
The following tutorial is a "Hello, World!" (introductory) example of writing a simple Python script, running the script in debug mode, and basic programming constructs.
(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/lnNqRCXZ2cw?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
to:
Below is an example on how to install [[https://apmonitor.com/wiki/index.php/Main/PythonApp|APMonitor Optimization Suite]] from the command line (start ''cmd'').
pip install APMonitor
The ''APMonitor'' package name can be replaced with any available package name such as [[https://www.numpy.org|NumPy]].
pip install numpy
!!!! Install Packages with '''pip''' (Python Script)
Packages can also be managed from a Python script by attempting to load the package with ''try''. If the import fails, the ''except'' section imports ''pip'' and installs the package.
'''Load and Optionally Install APMonitor Package'''
(:source lang=python:)
try:
from APMonitor.apm import *
except:
import pip
pip.main(['install','APMonitor'])
from APMonitor.apm import *
(:sourceend:)
'''Load and Optionally Install NumPy Package'''
(:source lang=python:)
try:
import numpy as np
except:
import pip
pip.main(['install','numpy'])
import numpy as np
(:sourceend:)
The ''APMonitor'' or ''NumPy'' package names can be replaced with any available package. The pip package manager connects to an online repository to retrieve the latest version of the package and install it. Sometimes a package is needed on a computer that isn't connected to the internet or the package isn't available through pip. Below is information on installing a package wheel (''whl'') file.
!!!! Install Package Wheels (whl) Offline
The pip package manager can also be used to install local (previously downloaded) wheel (''.whl'') files but dependencies may not be automatically installed if not connected to the internet. Below is an example wheel file installation for NumPy version 1.13.1 and SciPy version 0.19.1 for Python 3.6 with 64-bit Python.
pip install numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
pip install scipy-0.19.1-cp36-cp36m-win_amd64.whl
Use [[https://www.lfd.uci.edu/~gohlke/pythonlibs/|Christoph Gohlke's whl files]] for Windows installations. Many of the packages depend on the [[https://www.microsoft.com/en-us/download/details.aspx?id=53587|Visual C++ 2015 Redistributable]] (x64 and x86 for CPython 3.5 and 3.6) that is available from Microsoft. After installing the Visual C++ redistributable, download and install [[https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy|NumPy]] and [[https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy|SciPy]] packages (in that order) for Python 3.6 on Windows. The downloaded wheel file names should not be changed because the wheel file name verifies compatibility with the current Python version.
pip install APMonitor
The ''APMonitor'' package name can be replaced with any available package name such as [[https://www.numpy.org|NumPy]].
pip install numpy
!!!! Install Packages with '''pip''' (Python Script)
Packages can also be managed from a Python script by attempting to load the package with ''try''. If the import fails, the ''except'' section imports ''pip'' and installs the package.
'''Load and Optionally Install APMonitor Package'''
(:source lang=python:)
try:
from APMonitor.apm import *
except:
import pip
pip.main(['install','APMonitor'])
from APMonitor.apm import *
(:sourceend:)
'''Load and Optionally Install NumPy Package'''
(:source lang=python:)
try:
import numpy as np
except:
import pip
pip.main(['install','numpy'])
import numpy as np
(:sourceend:)
The ''APMonitor'' or ''NumPy'' package names can be replaced with any available package. The pip package manager connects to an online repository to retrieve the latest version of the package and install it. Sometimes a package is needed on a computer that isn't connected to the internet or the package isn't available through pip. Below is information on installing a package wheel (''whl'') file.
!!!! Install Package Wheels (whl) Offline
The pip package manager can also be used to install local (previously downloaded) wheel (''.whl'') files but dependencies may not be automatically installed if not connected to the internet. Below is an example wheel file installation for NumPy version 1.13.1 and SciPy version 0.19.1 for Python 3.6 with 64-bit Python.
pip install numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
pip install scipy-0.19.1-cp36-cp36m-win_amd64.whl
Use [[https://www.lfd.uci.edu/~gohlke/pythonlibs/|Christoph Gohlke's whl files]] for Windows installations. Many of the packages depend on the [[https://www.microsoft.com/en-us/download/details.aspx?id=53587|Visual C++ 2015 Redistributable]] (x64 and x86 for CPython 3.5 and 3.6) that is available from Microsoft. After installing the Visual C++ redistributable, download and install [[https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy|NumPy]] and [[https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy|SciPy]] packages (in that order) for Python 3.6 on Windows. The downloaded wheel file names should not be changed because the wheel file name verifies compatibility with the current Python version.
Changed lines 17-18 from:
!!!! Option #1: Install Python
to:
!!!! Option #1: Install Python from Python.org
Changed line 20 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/7HVOP-VfU0M" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ju6zw83PoKo" frameborder="0" allowfullscreen></iframe>
Changed lines 23-24 from:
The following instructions are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order with the utility PIP or by downloading the installer package from the appropriate web-site.
to:
The instructions are for the Windows OS but Python can be installed on most operating systems. The Python base program should be installed first and then the other packages can be installed in any order with the utility PIP or by downloading the installer package from the appropriate web-site.
!!!! Option #2: Install Anaconda
Anaconda includes the Jupyter Notebook and the Spyder IDE. Anaconda is [[https://www.continuum.io/downloads|available for download here]].
!!!! Option #2: Install Anaconda
Anaconda includes the Jupyter Notebook and the Spyder IDE. Anaconda is [[https://www.continuum.io/downloads|available for download here]].
Changed line 30 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/FKwicZF7xNE" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/LrMOrMb8-3s" frameborder="0" allowfullscreen></iframe>
Deleted lines 32-39:
The iPython platform installation instructions are given [[https://www.continuum.io/downloads|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy.
(:html:)
<iframe width="420" height="315" src="https://www.youtube.com/embed/-llHYUMH9Dg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 35 from:
There are several online platforms that allow Python through a web-browser including try.jupyter.org and repl.it. Join the ChE263 course exercises at:
to:
There are several online platforms that allow Python through a web-browser including try.jupyter.org and repl.it. An example of using repl.it is here:
Changed line 7 from:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]] and [[https://blog.codeeval.com/codeevalblog/2014|CodeEval]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility.
to:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]] and [[https://blog.codeeval.com/codeevalblog/2014|CodeEval]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 or Python 3.6+.
Added lines 36-41:
!!!! Option #3: Online Platforms
There are several online platforms that allow Python through a web-browser including try.jupyter.org and repl.it. Join the ChE263 course exercises at:
https://repl.it/classroom/invite/FS5LV0W
Added lines 8-11:
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/LfodqSAgEqg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 25 from:
!!!! Option #3: Anaconda (includes most packages)
to:
!!!! Option #2: Anaconda (includes most packages)
Added lines 31-36:
(:htmlend:)
!!!! Manage Python Packages
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z_Kxg-EYvxM" frameborder="0" allowfullscreen></iframe>
!!!! Manage Python Packages
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z_Kxg-EYvxM" frameborder="0" allowfullscreen></iframe>
Deleted lines 24-27:
Another option for installing Python is the [[https://portablepython.com/wiki/Download/|Portable Python]] package. This can be installed on a Flash USB drive and run directly from the external drive.
Changed lines 27-31 from:
The iPython platform installation instructions are given [[https://www.continuum.io/downloads|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
sudo easy_install -U Numpy
The module name of Numpy can be replaced by other modules such as Scipy, Matplotlib, and others if not included by default.
sudo easy_install -U Numpy
The module name of Numpy can be replaced by other modules such as Scipy, Matplotlib, and others if not included by default.
to:
The iPython platform installation instructions are given [[https://www.continuum.io/downloads|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy.
(:html:)
<iframe width="420" height="315" src="https://www.youtube.com/embed/-llHYUMH9Dg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
(:html:)
<iframe width="420" height="315" src="https://www.youtube.com/embed/-llHYUMH9Dg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 11 from:
[[https://docs.google.com/document/d/1zog9YSX-HTwmwDd3dN-yXUDePFXU0GaJWKTZsA6U5lg/edit | Python Resources]]
to:
* [[https://docs.google.com/document/d/1zog9YSX-HTwmwDd3dN-yXUDePFXU0GaJWKTZsA6U5lg/edit | List of Python Resources]]
Added lines 10-11:
[[https://docs.google.com/document/d/1zog9YSX-HTwmwDd3dN-yXUDePFXU0GaJWKTZsA6U5lg/edit | Python Resources]]
Changed lines 17-27 from:
The following are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order.
* Download and Install [[Attach:python-2.7.6.msi|python-2.7.6.msi]]
* Download and Install [[Attach:numpy-1.8.1.exe|numpy-1.8.1.exe]]
* Download and Install [[Attach:matplotlib-1.3.1.exe|matplotlib-1.3.1.exe]]
* Download and Install [[Attach:scipy-0.13.3.exe|scipy-0.13.3.exe]]
* Download and Install [[Attach:pyparsing-2.0.2.exe|pyparsing-2.0.2.exe]]
* Download and Install [[Attach:pyserial-2.7.exe|pyserial-2.7.exe]]
* Download, Extract, and Copy dateutil folder to "C:\Python27\Lib\"
** [[Attach:dateutil.zip|Download dateutil.zip]]
* Download and Install [[Attach:python
* Download and Install [[Attach
* Download and Install [[Attach
* Download and Install [[Attach
* Download and Install [[Attach:pyparsing-2.0.2.exe|pyparsing-2.0.2.exe]]
* Download and Install [[Attach:pyserial-2.7.exe|pyserial-2.7.exe]]
* Download, Extract, and Copy dateutil folder to "C:\Python27\Lib\"
** [[Attach:dateutil.zip|Download dateutil.zip]]
to:
The following instructions are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order with the utility PIP or by downloading the installer package from the appropriate web-site.
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/FKwicZF7xNE" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/FKwicZF7xNE" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed lines 27-29 from:
!!!! Option #3: Other Platform Options
The iPython platform installation instructions are given [[https://ipython.org/install.html|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
The
to:
!!!! Option #3: Anaconda (includes most packages)
The iPython platform installation instructions are given [[https://www.continuum.io/downloads|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
The iPython platform installation instructions are given [[https://www.continuum.io/downloads|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
Changed lines 11-12 from:
!!!! Option #1: Install Individual Packages
to:
!!!! Option #1: Install Python
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/7HVOP-VfU0M" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/7HVOP-VfU0M" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Deleted lines 76-81:
!!!! Introduction to Python and iPython
(:html:)
<iframe width="420" height="315" src="https://www.youtube.com/embed/hDmfZCVgShc" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 1 from:
(:title Introduction to Python for Engineers and Scientists:)
to:
(:title Introduction to Python for Engineers:)
Changed lines 46-47 from:
!!!! Introduction to Python and iPython
to:
!!!! Non-Ideal Gas Equation
Added lines 51-74:
!!!! Source Code
R = 0.0821 # L-atm/K
T = 500 # K
V = 5 # L/mol
Pc = 37.2 # atm
Tc = 132.5 # K
a = 0.427 * pow(R,2) * pow(Tc,2.5) / Pc
b = 0.0866 * R * Tc / Pc
# Compute in atm
P_ig = R * T / V
P_rk = R * T / (V-b) - a/(V*(V+b)*pow(T,0.5))
# Convert to Pascals
P_ig = P_ig * 101325
P_rk = P_rk * 101325
print("The ideal gas pressure: " + str(P_ig) + " Pa")
print("The Redlich-Kwong pressure: " + str(P_rk) + " Pa")
!!!! Introduction to Python and iPython
Added lines 47-50:
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/p2Dyx9DyQWw" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 30 from:
Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
to:
The iPython platform installation instructions are given [[https://ipython.org/install.html|here]]. Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
Added lines 45-50:
!!!! Introduction to Python and iPython
(:html:)
<iframe width="420" height="315" src="https://www.youtube.com/embed/hDmfZCVgShc" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Added line 20:
* Download and Install [[Attach:pyserial-2.7.exe|pyserial-2.7.exe]]
Added lines 8-9:
There are several resources for learning Python online. For a good start, look at [[https://www.codecademy.com/tracks/python|Code Academy (Python track)]] or view the documentation at [[https://www.python.org/|Python.org]]. For users with a foundation in MATLAB, there are excellent resources that demonstrate [[https://wiki.scipy.org/NumPy_for_Matlab_Users|equivalent Python (Numpy) commands]].
Changed line 7 from:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility.
to:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]] and [[https://blog.codeeval.com/codeevalblog/2014|CodeEval]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility.
Changed lines 18-19 from:
* Download, Extract, and Copy to "C:\Python27\Lib\"
** [[Attach:dateutil.zip|Dateutil.zip]]
** [[Attach:dateutil.zip|
to:
* Download, Extract, and Copy dateutil folder to "C:\Python27\Lib\"
** [[Attach:dateutil.zip|Download dateutil.zip]]
** [[Attach:dateutil.zip|Download dateutil.zip]]
Changed lines 9-10 from:
!!!! Install Individual Packages
to:
!!!! Option #1: Install Individual Packages
Changed lines 21-22 from:
!!!! Install Portable Python
to:
!!!! Option #2: Install Portable Python
Added lines 25-32:
!!!! Option #3: Other Platform Options
Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
sudo easy_install -U Numpy
The module name of Numpy can be replaced by other modules such as Scipy, Matplotlib, and others if not included by default.
Some platforms like MacOS typically include Python pre-installed but may be missing some of the packages such as Numpy. One method to include packages such as Numpy is to use the easy_install utility such as:
sudo easy_install -U Numpy
The module name of Numpy can be replaced by other modules such as Scipy, Matplotlib, and others if not included by default.
Added line 34:
Changed lines 7-8 from:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility. The following are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order.
to:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility.
!!!! Install Individual Packages
The following are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order.
!!!! Install Individual Packages
The following are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order.
Added lines 21-25:
!!!! Install Portable Python
Another option for installing Python is the [[https://portablepython.com/wiki/Download/|Portable Python]] package. This can be installed on a Flash USB drive and run directly from the external drive.
!!!! "Hello, World!" Tutorial
Another option for installing Python is the [[https://portablepython.com/wiki/Download/|Portable Python]] package. This can be installed on a Flash USB drive and run directly from the external drive.
!!!! "Hello, World!" Tutorial
Changed line 14 from:
* Download, Extract, and Copy to C:\Python27\Lib\
to:
* Download, Extract, and Copy to "C:\Python27\Lib\"
Added lines 14-15:
* Download, Extract, and Copy to C:\Python27\Lib\
** [[Attach:dateutil.zip|Dateutil.zip]]
** [[Attach:dateutil.zip|Dateutil.zip]]
Changed line 7 from:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages. The following are for the Windows OS:
to:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages although the newer 3.x versions are making progress with compatibility. The following are for the Windows OS. The Python base program should be installed first and then the other packages can be installed in any order.
Added lines 6-15:
Python is a high-level and general-purpose programming language. According to the [[https://www.tiobe.com/index.php/content/paperinfo/tpci/index.html | TIOBE index]], it is one of most popular programming languages. Part of the reason that it is a popular choice for scientists and engineers is the language versatility, online community of users, and powerful analysis packages such as Numpy and Scipy. This course uses Python 2.7 because of compatibility with the scientific computing packages. The following are for the Windows OS:
* Download and Install [[Attach:python-2.7.6.msi|python-2.7.6.msi]]
* Download and Install [[Attach:numpy-1.8.1.exe|numpy-1.8.1.exe]]
* Download and Install [[Attach:matplotlib-1.3.1.exe|matplotlib-1.3.1.exe]]
* Download and Install [[Attach:scipy-0.13.3.exe|scipy-0.13.3.exe]]
* Download and Install [[Attach:pyparsing-2.0.2.exe|pyparsing-2.0.2.exe]]
The following tutorial is a "Hello, World!" (introductory) example of writing a simple Python script, running the script in debug mode, and basic programming constructs.
Added lines 1-30:
(:title Introduction to Python for Engineers and Scientists:)
(:keywords tutorial, introduction, Python, university course:)
(:description Introduction to Python - Problem-Solving Techniques for Chemical Engineers at Brigham Young University:)
!!!!Python Introduction
(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/lnNqRCXZ2cw?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
This same tutorial is also show in a [[Main/MatlabIntroduction|MATLAB]] introduction.
----
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
(:keywords tutorial, introduction, Python, university course:)
(:description Introduction to Python - Problem-Solving Techniques for Chemical Engineers at Brigham Young University:)
!!!!Python Introduction
(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/lnNqRCXZ2cw?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
This same tutorial is also show in a [[Main/MatlabIntroduction|MATLAB]] introduction.
----
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)