summaryrefslogtreecommitdiff
path: root/9618-42-mj-2023/Question1_J2023.py
diff options
context:
space:
mode:
Diffstat (limited to '9618-42-mj-2023/Question1_J2023.py')
-rw-r--r--9618-42-mj-2023/Question1_J2023.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/9618-42-mj-2023/Question1_J2023.py b/9618-42-mj-2023/Question1_J2023.py
new file mode 100644
index 0000000..1e2e2bd
--- /dev/null
+++ b/9618-42-mj-2023/Question1_J2023.py
@@ -0,0 +1,29 @@
+#1a
+global Animals
+Animals = [None for i in range(10)] # String array, initialise to None to imply emptiness
+#1b
+Animals = [
+ "horse",
+ "lion",
+ "rabbit",
+ "mouse",
+ "bird",
+ "deer",
+ "whale",
+ "elephant",
+ "kangaroo",
+ "tiger"
+]
+#1c
+def SortDescending():
+ ArrayLength = len(Animals)
+ for x in range(0, ArrayLength):
+ for y in range(0, ArrayLength - x - 1):
+ if Animals[y][0] < Animals[y+1][0]:
+ Temp = Animals[y]
+ Animals[y] = Animals[y+1]
+ Animals[y+1] = Temp
+#1di
+SortDescending()
+for i in range(len(Animals)):
+ print(Animals[i]) \ No newline at end of file