Video 2 : Meta Information and Basics
All the examples here are chosen carefully so that you all get a broad exposure to a variety of programming tools and useful functions and libraries.
Source: http://xkcd.com/353/
No! Beacuse no programming language is perfect. Then why to choose Python?,
Bottom line : Python is good, but not undisputed.
Other programming languages that are good : R, Julia, Sage, Mathematica, Maple, Matlab, Fortran, C, C++, IDL, Java, JavaScript, etc,
As of 2019, there are two versions of the Python Language: The Legacy 2.x series and the future 3.x series. Python 3.x came to existence because the founder of Python, Guido van Rossum wanted to add more features to the language. The problem was that adding those features meant dismantling the major framework of Python 2.x and rewrite a significant portion of the language. Consequently, to make sure that the already exisiting programs work well and to make sure the new features get implemented, the old version of python, namely 2.x remained as it is for backward compatibility, while the newer version of python namely 3.x has the new features added to it.
The result of this decision is the exisitence of 2 distinct versions of python with a lot of similarities on the top, with many differences underneath.
We are in the transition period wherein we have access to use both the versions of Python. In the future, Python 2 will be obsolete, and in this transition period, almost all the libraries are being converted from Python 2 to Python 3. Infact, new libraries are being made in Python 3 extensively.
Consequently, as of 2019, Python 2.x series is stopping all major releases and releasing only sub releases for maintenance purposes. Other than that, the most active development is focussed on Python 3. The support and maintenance is only for people to transition from python 2.x to 3.x soon.
This is a (personal) checklist to keep in mind to pick a programing language for scientific computation.
Open up a Text Editor and save a file with the extension .py
"""
Program to ask the name, temperature, and rainfall of a place and print it.
"""
# This is a variable to save the place
= input("Enter the name of the place:")
place
# Rainfall variable
= input("Enter the rainfall recorded today in mm:")
rainfall
# Temperature variable
= float(input("Enter the temperature recorded today in Celsius:"))
temperature
# Print statement
print("In ", place, " today it rained ", rainfall, " mm and the temperature is", temperature, " degree celsius")
Comment - Lines that are ignored when the program is run. Used for excluding codes and for including messages.
# This is a single line comment
# Comment begins with a hash # symbol
Docstrings - Document strings. Multi-line comments. But more useful for including help/direction messages that appear when help utilities are called. In libraries, this is used as a documentation/help message for functions and classes.
"""
This is a Docstring. It starts and ends with
triple " or triple ' quotes. Mix and match does not work!
"""
'''
This is also a DocString
'''
Input command - Used for getting input from user to a variable.
= input('Enter the value for n') # Default string input
n = float(input('Enter the value for n')) # Type casted input n