Home › Forums › Grade 9 Python › Record Answers to Python Program 11.3
- This topic has 2 replies, 3 voices, and was last updated 3 years, 7 months ago by
aanya03.
- AuthorPosts
- March 14, 2022 at 6:49 am #7394
Eamonn
KeymasterRecord your answers to Python Program 11.3
March 15, 2022 at 3:40 am #7410Fine
ParticipantPYTHON PROGRAM 11.3
a. What is the output for the second line of code: print(gradebook)?
– The output of the code is the scores of Abbot and Barrava.
b. Examine the following code.
for x in gradebook:
print(x, end = ” “)
print()
i. What is being stored in x for each iteration of the loop in the following code?
ii. What is the output of this code?
– x stores the scores in the grade book. The output of the code is x(score) followed by ” “(name). It contains a FOR loop but does not use the range() function. In previous FOR loops the values resulting from the range() function were stored in x during each iteration of the loopMarch 15, 2022 at 3:45 am #7412aanya03
Participanta. output:
[‘Abbot’, 78, 79, ‘Barrava’, 97, 86]
b. the commas are being stored
otuput:
[‘Abbot’, 78, 79, ‘Barrava’, 97, 86]
Abbot 78 79 Barrava 97 86print((gradebook[1]+gradebook[2])/2)
= the output is 78.5 this is because 78+79=157/2= 78.5
print(gradebook[0]+gradebook[3])
= the output is AbbotBarrava because the 0 item on the list is Abbot name and third item on the list is Barrava name.
print(gradebook[2]+gradebook[3])
= the output is ah error because it is an name and number together. - AuthorPosts
- You must be logged in to reply to this topic.