First video for AE1205 course. To install Python:
- First remove any previous version of Python.
- Then use this video to install Python 3.
- After installing Python 3, start the Command Prompt with "Run as Admin" to use pip
- Type: pip install numpy scipy matplotlib pygame (required for course)
- Then: pip install spyder (required).
At 6:15 : Configuring IDLE
You can also Jupyter with pip (optional).
Separate install of PyCharm is recommended: https://www.jetbrains.com/pycharm/download

Views: 1070
Prof Hoekstra

Using numpy array and numpy matrix for linear algebra, vectors, and matrices.
0:41 Dot product on 1D numpy arrays (=inner product of vectors)
1:50 Length of a vector: norm( ) function
2:23 Project vector a on vector b
5:17 Use 2D arrays as a matrix
6:05 Solve Ax=b
6:35 Use 2D array as a vector (column orientation)
7:33 Transpose a vector/matrix/2D array: .T method
8:38 Matrix multiplication with arrays: using .dot( ) on 2D arrays
11:38 Matrix type in numpy (Note: voice says A.Y where it has to say A.I !)
12:48 Matrix multiplication with matrix type: "*" (works also with column vectors)
Not covered, but worth checking out: numpy's cross(a,b) function, det( ) function from numpy.linalg

Views: 822
Prof Hoekstra

Pygame animation: bouncing ball in a window, adding a controllable paddle as a start of a simple breakout game
0:15 Creating transparent background in image file
0:55 Start making the pygame script
1:18 Pygame reference guide
1:56 Import and initialize pygame
2:35 Create pygame window
4:54 Load a bitmap into a surface (and its rectangle rect)
7:30 Create simulation loop (timing, note how the second get_ticks also need a "*0.001" which is added later)
11:54 Blit a surface onto another surface/screen
14:07 Solve "Not responding" window: event pump
16:14 Colours, clearing screen
17:57 Event handling, e.g user closes window (QUIT-event)
22:28 Check keyboard/key status
25:55 Adding a controllable paddle

Views: 727
Prof Hoekstra

How to use the Python 3 print function with the sep(arator) and end option
5:00 Formatting floating point numbers and whole decimal numbers with the format method: using {:8.3f} and {:5d} etc. with the format.
Alternative (not shown in video) is not using the string-method but the format function:
x = 1/3
txt = format(x,"5.3f") # generates a string with formatted value of x

Views: 493
Prof Hoekstra

How to get user input and a short discussion on the basic variable types float, int, str and boolean (=logical) as well as methods to convert variable types (type casting):
0:00 - Using the input function for text
2:08 - Variable types: floats, integers, booleans and text strings
6:26 - Conversion functions (type casting): float, int functions
8:12 - Convert text to floats & int for use in input function
10:35 - Eval (evaluate) function used in input function

Views: 333
Prof Hoekstra

Plotting the result of a simulation of the falling mass
0:30 Making this simple simulation
3:34 Collecting results in lists
5:59 Plotting the results with matplotlib.pyplot
7:29 Multiple plots
8:58 Adding bells & whistles
10:44 Saving your plot as a figure in a file

Views: 212
Prof Hoekstra

Solving a 2nd order polynomial equation to demonstrate if, elif, else, math, sqrt and help
2:32 - Math module, Square root function sqrt()
3:55- Using Help function
5:00 - Import statement, different syntaxes
6:43 - Use of If-else and elif statement (incl. nested if)

Views: 296
Prof Hoekstra

How to make a for-loop, nested for loops and lists.
0:30 for loop
3:00 range (iterator) function
4:15 list variable type, use of indexes with a list, list in a list
6:30 using lists in a for-loop
8:32 nested loops and two dimensional lists

Views: 395
Prof Hoekstra

Using for and while loops to build a prime number generator
Also demonstrates the use of the modulo operator (%) and the append method of lists (e.g. lst.append(2) appends a 2 to list lst)
0:19 Modulo (%) operator
1:16 append list method (lst.append(..) )
2:14 Building a prime generator with for-loops
7:12 Improving efficiency with a while loop

Views: 295
Prof Hoekstra

0:31 Reading data with numpy's genfromtxt( ) and options
7:15 Getting individual columns from table
10:00 Select data with a condition as index
16:10 Using conditions in expressions (vectorizing with logic)
18:35 Difference numpy's max and maximum

Views: 261
Prof Hoekstra

Opening a file, writing to it, or reading from it. Use file methods. Then process the lines read using string methods.
0:20 Opening a file
1:34 Writing to a text file
4:45 Creating a text file (CSV) from Excel to read in Python
7:20 Reading the CSV file, i.e. the text file, in Python
9:42 Interpreting & splitting the lines from the file
Then as an example:
16:22 Creating a table with the data
20:00 Processing the data in the table
22:41 Create a results file
(note how "f.open(" is corrected to "f = open(") )
There are shorter, but more advanced ways, to do the same. Python has a library to read CSV files (import csv), or to read directly from the web (import urllib). And using the "with" statement automatically closes the file.
Also there is xlrd and xlwt to read and write excel files (pip install xlrd xlwt, then import xlrd or import xlwt)
Here the goal is to show basic Python functions to write, read and process text files with a minimum of prerequisite knowledge of libraries and modules.

Views: 251
Prof Hoekstra

Defining your own functions, with multiple input/output variables, namespaces, global statement, using functions and variables from multiple files, organizing your project
0:00 DEF defining a function & namespace
6:11 Access to global namespace from within function
7:59 Mutable/immutable (see also video 8 at 6 min ans 41sec)
9:05 global statement
15:28 Getting more than one output: multiple ways
20:52 Using multiple source files, import your functions and organize your project
Multiple files, importing your functions

Views: 131
Prof Hoekstra

Solving an exam problem with lists & loops: find all numbers of which the treble has the same 5 digits
1:55 Using % and / to get digits of an integer number
3:05 Using str, list, sorted functions and count, sort methods
6:35 Using def , function definition and an alternative (easier) method

Views: 263
Prof Hoekstra

Quick walk-through of the Bounce assignment

Views: 403
Prof Hoekstra

Slicing, adding multiplying lists & strings, Mutable & Immutable variables
Immutable = floats, ints, strs, bools: non-modifiable in parts, passed on by value
Mutable = lists, and all other types: modifiable, passed by memory location
0:00 - List slicing
1:34 - Changing a part of a list
2:13 - String slicing
2:50 - Changing a part of a string
3:37 - Concatenation of lists and strings with "+"
4:24 - Multiplying lists and strings with "*"
4:50 - More inputs for input prompt text
6:41 - Mutable vs Immutable variables
9:10 - Still get a copy of value of mutable variable (workaround)
9:58 - Functions: mutable vs immutable inputs
12:20 - Two dimensional list: rows are same list! (problem)
14:35 - Two dimensional list with independent rows (workaround)

Views: 234
Prof Hoekstra

Create an array from a list, use indices a[i,j] i.s.o. a[i][j], etc.
0:00 Numpy
1:00 Lists vs Numpy Arrays
2:59 Array-function: creating an array from a list
5:06 Using math fucntions from numpy
7:00 Spanning axes: arange and linspace
12:00 Using numpy i.s.o. math
13:40 Array creation with zeros() and ones(), 2D arrays
14:23 Array shape
16:29 Slicing arrays: slect rows & columns
18:44 Stacking columns or rows

Views: 261
Prof Hoekstra

Overview of a selection of string & list methods (I've put the File I/O in a separate video)
0:00 - What are methods?
3:28 - How to find them and their help information
4:20 - Some useful methods for data reading, a.o.:
5:15 - Splitting & joining strings into or from a list of strings
8:37 - Testing a string and combining methods in one expression

Views: 187
Prof Hoekstra

Lists, tuples, sets and dict - definition, assignment, use, methods
0:21 Lists and at 1:25 list methods
8:53 Tuples, difference with lists, one element tuple
14:34 Sets - assigning one, use and using sets (methods & operators)
23:09 Dictionaries - assigning dicts, use, getting keys or values

Views: 152
Prof Hoekstra

How a while loop is different from a for loop
0:00 - Using while loop just like a for-loop
2:20 - Simulating a falling ball with a while loop (numerical integration)

Views: 256
Prof Hoekstra

Brief explanation of data file, coordinates, axes and reference frames as walk through of the Out-of-the-Wind view (otwv) assignment

Views: 339
Prof Hoekstra