Record Answers to Python Activity 11.2

Home Forums Grade 9 Python Record Answers to Python Activity 11.2

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #7391
    Eamonn
    Keymaster

    Record answers here

    #7396
    Rafael
    Participant

    a. Instead of print(compoundClass[3]), type print(compoundClass[4]). If you put compoundClass[5]), it won’t work since there is no compoundClass as it starts from compoundClass[0].
    b. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[5]) I add “alkynes” so there is compoundClass[5].
    c. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-1]) I could observe that it starts count from the back. So it prints “alkynes”.
    e. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-2]) It prints out alkyl halides.
    f. Positive starts from the alkanes and goes on, and negative is the opposite of positive. It goes from back to forward.
    g. It prints out all the compoundClass written.

    #7397
    Peam1223
    Participant

    1. would change compoundClass[3] to compoundClass[4]. alkyl halides will print since its 4th down the list.
    2. compoundClass[5] will print nothing because the list starts with 0 so the list will only go up to 4.
    3. alkyl halides is printed.
    4. ketones is printed.
    5.if the number is positive the list will start at the beginning or on the left. if the number is negative the list will start at the end or the right.
    6.the whole list is printed. the list starts from the left beginning with alkanes and ending with alkyl halides

    #7398
    Karan123
    Participant

    a. How would you change the code so that the output is “alkyl halides”? compoundClass[5]. What is printed? Why?
    b. Edit the print statement in the programs so that it prints compoundClass[5]. What is printed? Why?
    c. Edit the print statement in the programs so that it prints compoundClass[-1]. What is printed?
    e. Change -1 to -2 in “c.” above. What is printed?
    f. Explain how the positive and negative indexes locate the desired elements.
    g. What is printed with the following print statement:

    A. Instead of print(compoundClass[3]), type print(compoundClass[4]). If you put compoundClass[5]), it wouldn’t work because as you can clearly see, there is no compoundClass as it starts from compoundClass[0].
    B. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[5]) I add “alkynes” so there is compoundClass[5].
    C. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-1]) I could observe that it starts count from the back. So it prints “alkynes”.
    E. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-2]) It prints out alkyl halides.
    F. As you can see, the positive starts from the alkanes and then goes on and on whereas the negative is complete opposite of its positive so it means that it goes from back to forward
    G. It prints out everything that the compound class has written in the code.

    #7399
    Peam1223
    Participant

    1. it will print the whole list.
    2. a) the names are being stored in x.
    b) the out put are Abbot 78 89 Barrava 97 86

    print((gradebook[1]+gradebook[2])/2) combines the two and divides it in half.
    print(gradebook[0]+gradebook[3]) prints the two names on the list.
    print(gradebook[2]+gradebook[3]) causes an error.

    #7400
    Karan123
    Participant

    a. What is the output for the second line of code: print(gradebook)?

    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?

    A. It prints the gradebook and shows the score.
    B. In x, is the person’s score. The output is each person’s score after their name

    #7401
    Chien493
    Participant

    1)[“Abbot”, 78, 89, “Barrava”,97,86]
    2)for x in gradebook:
    print(x, end = ” “)
    3)print((gradebook[1]+gradebook[2])/2)
    print(gradebook[0]+gradebook[3])
    print(gradebook[2]+gradebook[3])

    output, Abbot 78 89 Barrava 97 86

    #7402
    Fine
    Participant

    PYTHON 11.2

    a. Instead of print(compoundClass[3]), type print(compoundClass[4]). If you put compoundClass[5]), it would not work because there is no compoundClass as it starts from compoundClass[0].
    b. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[5]) “alkynes” added to make compoundClass[5].
    c. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-1]) We can see that it starts counting from the back, printing “alkynes”.
    e. compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-2]) Prints out alkyl halides.
    f. Positive will start at the front of the line while negative number starts at the end of the line.
    g. It prints out all the compoundClass written in the list, starting from alkynes and ending with alkynes.

    #7403
    aanya03
    Participant

    my list: compoundClass=[“math”,”science”,”history”,”La”,”Thai”]
    a. It will show error because the list start from 0. The step compoundClass[5] is out of range.
    list after adding another subject: my list: compoundClass=[“math”,”science”,”history”,”La”,”Thai”,”drama”]
    b. Now that I add another subject in the list which was drama, it will print “drama” because that is compoundClass[5]
    c. If my print statement is compoundClass[-1] my answer will be “drama”
    e. If my print statement changes from compoundClass[-1] to cpmpoundClass[-2] then my answer will be “Thai”
    f. The positive number starts from the front of the list whereas the negative number start from the back of the list.
    g. The who list of the subject is displayed and it looks like [‘math’, ‘science’, ‘history’, ‘La’, ‘Thai’, ‘drama’] this.

    #7404
    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).

    #7405
    Fine
    Participant

    PYTHON PROGRAM 14.4

    elements = [‘hydrogen’, ‘helium’ ,’lithium’, ‘beryllium’, ‘boron’, ‘carbon’]

    print(elements)
    elements.append(‘nitrogen’)
    print(elements)

    a. Explain what the following line of code does:

    elements.append(‘nitrogen’)
    – The code above adds the element ‘nitrogen’ into the list.

    b. Write a line of code that would add the element oxygen to the list.
    – On line 6-7 add

    elements.append(‘oxygen’)
    print(elements)

    to print oxygen in the list.

    #7409
    VashiTokyo
    Participant

    list = [‘PlayStation’, ‘Xbox’]
    list2 = [‘Ps4’, ‘Ps5’]
    list3 = [‘Xbox360’, ‘Xboxone’]

    print(list[0], ‘or’, list[1])
    pick = input(‘Pick one: ‘)

    if pick == list[0]:
    print(‘Smart choice’)
    print(list2[0], ‘or’, list2[1])
    pick2 = input(‘Pick again: ‘)
    print(‘Both choices are good’)
    print(‘Genius’)

    elif pick == list[1]:
    print(‘Bad choice’)
    print(list3[0], ‘or’, list3[1])
    pick3 = input(‘Pick again: ‘)
    print(‘Both choices are bad’)
    print(‘Failure’)

    #7411
    Matthew Sparrow
    Participant

    You will need to need another compound class to make it 5 because it starts with a zero, or you can write “print(compoundClass[4)]” because alkyl halides is on the fourth line.
    If you program it to print compoundclass 5 it won’t print anything and it will give you an error message because they is nothing after compound 4, and this doesn’t start with a one, but a zero.
    If you put print(compoundClass[-1]) it will print alkyl halides because it is the last one in the message, so it is going backwards. [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”] backwards. starts with alkyl halides
    When you put print(compoundClass[-2]) instead of print(compoundClass[-1]) it will come back to being a ketones again, and it is the same as print(compoundClass[3]) from the start. [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”] starts with ketones.
    The positive numbers will start from 0-infinite you add in, and the negative numbers will start with the last thing on the list to the first thing on the list.
    This “compoundClass = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”]”

    #7413
    Andrew
    Participant

    1. print(compoundClass[3]), type print(compoundClass[4])
    2. compoundClass[5] will print nothing
    3. compound class = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-1]
    4. Prints compound class = [“alkanes”, “alkenes”, “alcohols”, “ketones”, “alkyl halides”, “alkynes”]
    print(compoundClass[-2] alkyl
    5. A positive number starts and progresses from an alkane, whereas a negative number is the exact opposite of a positive number, so it moves back and forth.
    6. Prints out everything in compound class.

    #7420
    Fine
    Participant

    name = input(“Enter name: “)
    ID = input(“Enter your student ID number: “)
    course = input(“Enter your course number: “)
    print(name + “‘s ID is” + ID + “\nand is enrolled in “+ course)

    State what is displayed on the screen when you executed the program.
    – Displayed on the screen is a place to enter your name, student ID, and course number. The final result is name+student ID+course number.

    The \n is a “string literal escape sequence” in python. What does this do?
    – In Python, the new line character “\n” is used to create a new line. When inserted in a string all the characters after the character are added to a new line.

    Change the \n to \t and describe what happens to the program output.
    – Replacing /t with /n will replace a line with a tab.

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