A Little Bit of Reaction Engineering.

This post will be a little (just a little…) intensive on the physical chemistry side of things as I explore the other functions of the Python Programming Language, using an example on reaction kinetics.Let’s consider the following reaction scheme showing the elementary reactions, where the starting material A gets converted to B with a rate […]

Multiprocessing.

Previously, we had shown that blocks of code could be executed in parallel using the threading module (see here and here) within Python. Let’s consider the code below. Line 5 to 10 defines the print_rand() function where one million random numbers between 1 to 100 will be generated and each stored in the ran_list using […]

Threading. Part II – Locks & Timer

Let us consider the block of code below. The threading module and time module would be used for the following example.One function, odd_print(), has been defined to print a number ‘1’, pause for one second, and print the next odd number. This for loop would be repeated five times. Two threads are then started by […]

Threading.

Suppose we have the following code consisting of two functions. Line 3 to 8 defines the odd_print function where it uses a for loop to iterate five times, by first printing the number ‘1’ (Line 6), pauses for one second (Line 7), and adds two to the previous number giving us the next odd number. […]

Guessing game. Part II – Monte Carlo Simulation

We’ve created a simple game in the previous post (see Guessing Game) where the positions of ‘O’ and ‘X’ are shuffled randomly, and the player gets a point for making a correct guess. Let’s consider the scenario where someone wanted to monetise this game. Some of the considerations might be as follows:– how much should […]

Guessing game.

Let’s create a guessing game with a list of five objects containing three ‘O’ and two ‘X’ which would be shuffled randomly. The player would then be asked to choose a position (Left to right – numbered 1 to 5) that do NOT contain an ‘X’. This is equivalent to a probability of 0.6 of […]

Let’s play dice.

I am sure you are familiar with a typical six-sided dice, and if all else remains equal, the probability of rolling any of the numbers is simply 1 out of 6, or a probability of 0.167. In this post, we’ll create a simple programme that mimic the random dice roll, collate the results of each […]

Something for amino acid sequences. Part II.

In the previous post, we had a programme that can identify the position and occurrence of a single amino acid (represented by a letter) within a given sequence (represented by a string of letters). Let’s modify the code to enable us to search for a block consisting of multiple amino acids within the sequence provided. […]

Something for amino acid sequences.

The amino acid sequence of a protein can be written as a string of letters, each representing a corresponding amino acid residue. For example, human insulin is a protein consisting of 51 amino acid residues, present as a dimer consisting of the A-chain and the B-chain with their amino acid sequences as follows: A-Chain – […]