Created
February 12, 2019 13:53
-
-
Save neila/f878c2bf6cbaa1483c6395e14e84f709 to your computer and use it in GitHub Desktop.
CS110 5.1 Preclass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def check(list): | |
for i in range(len(list) - 1): | |
if list[i] > list[i + 1]: | |
return False | |
return True | |
def badsort(list): | |
while not check(list): | |
random.shuffle(list) | |
return list | |
list = [int(100*random.random()) for i in range(10)] | |
badsort(list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment