Abdullah Haris 11-D Q01c
Abdullah Haris 11-D Q01c
Q01c
# Q01c
count = 0
constantValue = 7
maxValue = 5
count = count + 1
Q01f
# Q01f
assistantSalary = 1000.00
shopIncome = pair[0]
assistantSales = pair[1]
else:
Q02a
import random
#initialise variables
counter = 1
answer = random.randint(1,10)
guess = 0
counter += 1
else:
#Report the correct answer to the user and display the number of guesses
Q03a
# Q03a
# Subprogram to get and validate the month number-----------------------------------------------------
def display():
monthNumber = 0
return monthNumber
# Subprogram to show the name of the month and the number of days in the month
-----------------------
def showMonthNameAndDays(pMonth):
monthAndDays = [
count = 0
found = False
while count < len(monthAndDays) and found == False:
if monthAndDays[count][0] == pMonth:
found = True
count = count + 1
monthInput = display()
showMonthNameAndDays(monthInput)
Q03c
# Q03c
# Input requested
else:
Q4
scores = [12, 5, 19, 3, 8, 15, 7]
def bubble_sort(array):
return array
new_scores = bubble_sort(scores)
print(new_scores)
Q5
# Athlete's performance data
else:
truckDistances = [
["T101", "John", "Doe", 120, 150, 180, 200, 90, 140, 160],
["T102", "Sarah", "Smith", 130, 145, 160, 170, 100, 135, 155],
["T103", "Michael", "Johnson", 110, 120, 140, 150, 80, 125, 130],
["T104", "Emily", "Davis", 140, 160, 175, 190, 95, 145, 165],
["T105", "Robert", "Brown", 125, 135, 155, 165, 85, 130, 150]
#--------------------------------------------------------------------------
distance = []
for i in truckDistances:
distance.append(sum(i[3:]))
print(i[0],"covered", sum(i[3:]))
for x in range(len(distance)):
# outputing the the values of the two trucks with the highest distance
for x in range(2):
num = distance[x][0]
print("\nTruck Id:",truckDistances[num][0],
"\nDriver name:",truckDistances[num][1],truckDistances[num][2],