Record Answers to Python Program 11.3

Home Forums Grade 9 Python Record Answers to Python Program 11.3

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7394
    Eamonn
    Keymaster

    Record your answers to Python Program 11.3

    #7410
    Fine
    Participant

    PYTHON 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 loop

    #7412
    aanya03
    Participant

    a. 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 86

    print((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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Scroll to Top