Tag: Python

<em>Bad Code</em>

Bubble Sort | <em>Bad Code</em> [3]

What It Does This is my own version of the simple sorting algorithm bubble sort. The function takes the numbers 1 to 9  in a random order, and re-sorts them into ascending order. The first value is compared with the second value: if the first is greater than the second, their locations in the list …

<em>Bad Code</em>

Fibonacci Sequence & Pascal’s Triangle | <em>Bad Code</em> [2]

The first 15 rows of Pascal's Triangle

  Two short pieces of code – one for generating the first n terms of the Fibonacci Sequence, the other for generating the first n rows of Pascal’s Triangle.     #Function to generate the Fibonacci sequence to the nth term index = int(input(“Please enter the number of terms in the Fibonacci sequence to display:\n”)) …

<em>Bad Code</em>

Cambridge Colleges and Founding Years, Re-Designed | <em>Bad Code</em> [1.5]

New and Improved Here’s a drastically modified version of the program that I wrote yesterday, using dictionaries instead of arrays. # Alistair Bhatti # 31/01/2017 data = {“Christ’s College”:”1505″, “Churchill College”:”1960″, “Clare College”:”1326″, “Clare Hall”:”1965″, “Corpus Christi College”:”1352″, “Darwin College”:”1964″, “Downing College”:”1800″, “Emmanuel College”:”1584″, “Fitzwilliam College”:”1869″, “Girton College”:”1869″, “Gonville & Caius College”:”1348″, “Homerton College”:”1768″, “Hugh’s …

<em>Bad Code</em>

Cambridge Colleges & Founding Years | <em>Bad Code</em> [1]

What It Does This is a program that allows the user to input the name of one of the colleges of Cambridge, such as Clare College for instance, and the year that College was founded, ie 1326, is output. # Alistair Bhatti # 30/01/2017 names = [“Christ’s College”,”Churchill College”,”Clare College”,”Clare Hall”, “Corpus Christi College”,”Darwin College”,”Downing …