Computer Science Quiz Unit 5. Assessment 1
a year ago
jlay
Save
Edit
Host a game
Live GameLive
Homework
Solo Practice
Practice
14 QuestionsShow answers
  • Question 1
    900 seconds
    Report an issue
    Q.

    Which of the following is FALSE about event-driven programs?

    answer choices

    Event-driven programs do not implement algorithms.

    Some portions of an event-driven program may never execute while the program is running.

    An event-driven program is written to respond to specified events by executing a block of code or function associated with the event.

    The order in which an event-driven program will run cannot always be known ahead of time.

  • Question 2
    900 seconds
    Report an issue
    Q.

    Which of the following is FALSE about element IDs?

    answer choices

    An element with a unique ID must always have an event handler associated with it.

    Any element that needs to be triggered by onEvent must have a unique ID.

    Two or more onEvent calls may reference the same ID.

    While not a requirement, IDs should be meaningful and descriptive.

  • Question 3
    900 seconds
    Report an issue
    Q.

    Which of the following are actions a programmer could take when debugging a segment of code that would most likely lead to finding a problem and fixing it? (choose two)

    answer choices

    Change the names of variables within the program and run the program again.

    Display the value of variables at various points during the program.

    Ask a friend or collaborator to look over the code segment to see if they are able to find any errors.

    Delete the code and re-type it to make sure there were no spelling errors and that it was written correctly.

  • Question 4
    900 seconds
    Report an issue
    Q.

    Two students, Kaleb and Hunter, are arguing in class about an App Lab project. Kaleb states, “Huh, a button and an image are basically the same thing!”. Hunter replies, “That doesn’t make any sense at all!”. Explain what Kaleb may have meant by that statement.

    answer choices

    Short Answer Question. Be able to explain using terms and elements from lessons 1-5 in code.org.

    Short Answer Question. Be able to explain using terms and elements from lessons 1-5 in code.org.

  • Question 5
    900 seconds
    Report an issue
    Q.

    Consider the code segment below:


    What are the values of a, b, and c after this code segment has been run?

    answer choices

    a-4;b-4;c-4

    a-4;b-8;c-8

    a-0;b-3;c-4

    a-4;b-8;c-16

  • Question 6
    900 seconds
    Report an issue
    Q.

    Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every time someone clicks the "addItemButton", she would like the variable to increase by 1.


    What code should Jasmine insert where it says <missing code> in order for her app to work?

    answer choices

    cart total = 1;

    cartTotal + 1;

    cartTotal = cartTotal +1;

    var cartTotal = cartTotal + 1;

  • Question 7
    900 seconds
    Report an issue
    Q.

    Jose is writing a reply function for a text messaging app. He'd like to swap the sender and receiver so that the value currently in variable From ends up as the value in To and To ends up in From


    Which of the following code segments will correctly swap the values as described?

    answer choices

    to=from;

    from=to;

    from=var temp;

    to=temp;

    from=to;

    var temp=from;

    from=to;

    to=from;

    var temp=from;

    from=to;

    to=temp;

  • Question 8
    900 seconds
    Report an issue
    Q.

    A programmer wrote an essay for his history class, and realized he has confused the names of Benjamin Franklin and Alexander Graham Bell. Instead of going through the whole paper and changing the names, he used the following incorrect algorithm in an attempt replace every occurrence of "Benjamin Franklin" with "Alexander Graham Bell" and vise versa:


    First, change all occurrences of "Benjamin Franklin" to "apple"


    Then, change all occurrences of "apple" to "Alexander Graham Bell".


    Then, change all occurrences of "Alexander Graham Bell" to "Benjamin Franklin".


    Here is an example of one of the sentences from the paper: Alexander Graham Bell was born 141 years before Benjamin Franklin, so he was never able to telephone his neighbors.


    Which of the following is the result of running the described incorrect algorithm on the sentence above?

    answer choices

    Benjamin Franklin was born 141 years before Alexander Graham Bell, so he was never able to telephone his neighbors.

    apple was born 141 years before Benjamin Franklin, so he was never able to telephone his neighbors.

    Alexander Graham Bell was born 141 years before apple, so he was never able to telephone his neighbors.

    Benjamin Franklin was born 141 years before Benjamin Franklin, so he was never able to telephone his neighbors.

  • Question 9
    900 seconds
    Report an issue
    Q.

    Consider the code segment below:


    Which of the following images is the most likely outcome of the drawing?

    answer choices
  • Question 10
    900 seconds
    Report an issue
    Q.

    What is displayed by the console.log statement after the following code segment executes?

    answer choices

    value is: 2

    value is: 2.3333333

    value is: 3

    value is: 4

  • Question 11
    900 seconds
    Report an issue
    Q.

    A student decides to draw a series of three dots (sort of like a snowman) as shown in the diagram. She wants each dot to be half the radius of the previous dot, and for the center to be on the edge of the dot below it. She writes the following code segment to do it:


    She is not sure about the size though, and wants to be able to quickly experiment with the drawing by changing only one number - the radius of the bottom dot - and for the rest of the code to size and scale the drawing accordingly. How should she adjust lines 2 and 3 of her code to implement this change?

    answer choices

    var middle =100/2;

    var top=50/2;

    var middle =100-50;

    var top=50-25;

    var middle =bottom/2;

    var top=middle/2;

    var middle =bottom-50;

    var top=middle-25;

  • Question 12
    900 seconds
    Report an issue
    Q.

    What is the output to the console after the following code segment is executed?

    answer choices

    3

    5

    -2

    Error.Unknown Identifier:x

  • Question 13
    900 seconds
    Report an issue
    Q.

    What is the output to the console after the following code segment is executed?

    answer choices

    13

    8

    10

    Error. Cannot make a new variable x inside function increase()

  • Question 14
    900 seconds
    Report an issue
    Q.

    When might a programmer create a global variable instead of a local variable?

    answer choices

    Essay question #2. Be able to describe the difference between a local and global variable; explain why a global variable may be necessary and use an example to support their explanation.

    Essay question #2. Be able to describe the difference between a local and global variable; explain why a global variable may be necessary and use an example to support their explanation.

Report an issue
Why show ads?
Report Ad
Join a game