May-11-2017, 06:12 PM
Hi all,
Apologies in advance - I've just started to learn python and am struggling to grasp it so my question will be at a very "noobish" level.
Basically, I want to generate a random set of integers and then perform a bubble sort on those integers.
I have already implemented two separate programs - one that generates random integers, and one that performs a bubble sort on a specified list (code below) but I need to join them
somehow and this is where I'm lost.
If someone could kindly help me (in layman's terms) it'd be greatly appreciated
Random no. generator:
Apologies in advance - I've just started to learn python and am struggling to grasp it so my question will be at a very "noobish" level.
Basically, I want to generate a random set of integers and then perform a bubble sort on those integers.
I have already implemented two separate programs - one that generates random integers, and one that performs a bubble sort on a specified list (code below) but I need to join them
somehow and this is where I'm lost.
If someone could kindly help me (in layman's terms) it'd be greatly appreciated

Random no. generator:
import random def random_ints(num, lower=0, upper=100): return [random.randrange(lower,upper+1) for i in range(num)] print random_ints(10)Bubble sort:
def bubbleSort(listLetters): for passnum in range(len(listLetters)-1,0,-1): for i in range(passnum): if listLetters[i]>listLetters[i+1]: temp = listLetters[i] listLetters[i] = listLetters[i+1] listLetters[i+1] = temp listLetters = ['B', 'A', 'E', 'D', 'C', 'F',] bubbleSort(listLetters) print(listLetters)