Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Get All Weeks Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

In this final course, we’ll look at the JavaScript language and how it supports the Object-Oriented pattern, with a focus on the unique aspects of JavaScript’s approach to OO. We’ll provide an introduction to the jQuery library, which is widely used for in-browser manipulation of the Document Object Model (DOM) and event handling.

You’ll also learn about JavaScript Object Notation (JSON), which is commonly used as a syntax to exchange data between code running on the server (i.e., in Django) and code running in the browser (JavaScript/jQuery). You will continue to develop your classified ads application, adding features that make use of JavaScript, JQuery, and JSON. This course assumes you have completed the first three courses in the specialization.

Enroll on Coursera

Week 01: Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Quiz 1: JavaScript

Q1. Where does the following JavaScript code execute?

<p>One Paragraph</p>

<script type="text/javascript">
 document.write("<p>Hello World</p>") 
</script> 

<p>Second Paragraph</p> 
  • In the database server
  • In the web server
  • On the network
  • In the browser

Q2. What happens when JavaScript runs the alert() function?

  • JavaScript checks to see if there are any unprocessed events
  • A message is sent back to the Django code to be logged on the server
  • JavaScript pops up a dialog box and execution continues until the tag is encountered
  • JavaScript execution is paused and a dialog box pops up

Q3. Which of the following is NOT a way to include JavaScript in an HTML document?

  • By including the code between <script> and </script> tags
  • By including a file containing JavaScript using a <script> tag
  • By including the code the <?javascript and ?> tags
  • On a tag using an attribute like onclick=””

Q4. In the following code, what does the “return false” accomplish?

<a href="js-01.htm" onclick="alert('Hi'); return false;">Click Me</a> 
  • It suppresses the pop-up dialog that asks “Are you sure you want to navigate away from this page?”
  • It keeps the browser from following the href attribute when “Click Me” is clicked
  • It is necessary to insure that the onclick code is at least two lines of code
  • It sets the default for the alert() dialog box

Q5. What happens in a normal end user’s browser when there is a JavaScript error?

  • JavaScript logs the error to the Django error log
  • JavaScript prints a traceback indicating the line in error
  • JavaScript skips the line in error and continues executing after the next semicolon (;)
  • Nothing except perhaps a small red error icon that is barely noticeable

Q6. Where can a developer find which line in a web page of JavaScript file is causing a syntax error?

  • By doing a “View Source” to see the HTML source code
  • In the developer console in the browser
  • By looking at a file on the hard disk of the system where the browser is running
  • In the Django error log

Q7. What does the following JavaScript do?

  • console.log(“This is a message”);
  • Puts the message in the Django console log
  • Puts the message in the browser developer console and continues JavaScript execution
  • Puts the message in the browser console and pauses JavaScript execution
  • Sends the message to console.log.com

Q8. Which of the following is not a valid comment in JavaScript?

  • /* This is a comment */
  • // This is a comment
  • #This is a comment

Q9. Which of the following is not a valid JavaScript variable name?

  • _data
  • $_data
  • 3peat
  • $data

Q10. What is the difference between strings with single quotes and double quotes in JavaScript?

  • Single-quoted strings do not treat \n as a newline
  • Double-quoted strings cannot be used in JavaScript
  • There is no difference
  • Double-quoted strings do variable substitution for variables that start with dollar sign ($)

Q11. What does the following JavaScript print out?

toys = [‘bat’, ‘ball’, ‘whistle’, ‘puzzle’, ‘doll’]; console.log(toys[1]);

  • whistle
  • puzzle
  • doll
  • ball
  • bat

Q12. What value ends up in the variable x when the JavaScript below is executed?

x = 27 % 2;

  • 1
  • 0
  • 2
  • 13.5
  • 27
  • 54

Q13. What is the meaning of the “triple equals” operator (===) in JavaScript?

  • Both sides of the triple equals operator are converted to integers before comparison
  • Both sides of the triple equals operator are converted to boolean before comparison
  • The values being compared are the same without any type conversion
  • Both sides of the triple equals operator are converted to strings before comparison

Q14. How do you indicate that a variable reference within a JavaScript function is a global (i.e., not local) variable?

  • Declare the variable globally before the function definition in the code
  • Use the keyword “global” when declaring the variable outside the function
  • Use the keyword “global” to declare the variable in the function
  • Use the keyword “var” to declare the variable in the function

Week 2: Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Quiz 1: JavaScript OO

Q1. Which of the following is a template that defines the shape of an object that is created?

  • Message
  • Class
  • Instance
  • Method
  • Inheritance

Q2. Which of the following describes a feature which we would expect from a programming language that supported first class functions?

  • The ability to define a function and assign the function to a variable
  • The ability to omit parameters and have the omitted parameters default to a value
  • The ability to have a variable number of parameters when calling a function
  • The ability for a function not to return a value (i.e., void functions)
  • The ability to return a value from a function

Q3. What keyword / predefined variable is used in a JavaScript class definition to refer to the “current instance” of the class?

  • this
  • $this
  • me
  • _self
  • self

Q4. What do these two statements in JavaScript accomplish?

data.stuff = "hello"; data['stuff'] = "hello";
  • These two statements accomplish the same thing
  • The first statement creates an object and the second creates a dictionary
  • The first statement is a syntax error in JavaScript
  • The second statement is a syntax error in JavaScript

Q5. How is the constructor defined in a JavaScript class compared to how the constructor is defined in a Python class?

  • The Python and JavaScript constructor patterns are the same
  • A Python constructor is a method named init() and a JavaScript constructor is code in the outer function definition
  • The Python constructor method is called _construct() and the JavaScript constructor method is called construct()
  • JavaScript does not support the notion of running a “constructor” when objects are created

Week 3: Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Quiz 1: jQuery

Q1. What is the purpose of the following JQuery ready() call?

$(document).ready(function(){ window.console && console.log('Hello JQuery..'); });
  • Enable the retrieval of data in the JSON format
  • Ascertain if the document is ready to load
  • Clear the browser window so drawing can start in the upper left hand corner
  • Register a function that will be called when the HTML document is completely loaded

Q2. What portion of the DOM (Document Object Model) will be affected by the following JQuery statement:

$('#para').css('background-color', 'red');
  • All tags with a class attribute of “para”
  • All elements in the DOM
  • A tag with an id attribute of “para”
  • A tag with a class attribute of “para”

Q3. What does the following JQuery code do?

$('#spinner').toggle();
  • Call the global JavaScript function toggle with the spinner tag as its parameter
  • Indicate that page loading has completed
  • Switch the spinner.gif with the image spinner_toggle.gif
  • Hide or show the contents of a tag with the id attribute of “spinner”

Q4. What would the following JavaScript print out?

data = {‘one’:’two’, ‘three’: 4, ‘five’ : [ ‘six’, ‘seven’ ], ‘eight’ : { ‘nine’ : 10, ‘ten’ : 11 } };
alert(data.eight.nine);

  • six
  • 10
  • seven
  • 11
  • nine

Q5. Which of the following JQuery statements will hide spiner.gif in this HTML?

 <div id="chatcontent"> <img src="spinner.gif" alt="Loading..."/> </div> 
  • $(“.chatcontent”).off();
  • $(“#chatcontent”).hide();
  • $(“spinner.gif”).alt = -1;
  • $(“spinner.gif”).suppress();
  • $(“img>spinner.gif”).hide();

Week 4: Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Quiz 1: JSON

Q1. What is the act of converting a Python dictionary into a string format so it can be translated across a network?

  • USB
  • ASN.1
  • pickling
  • serialization

Q2. What is the preferred variable type for the first parameter to JsonResponse? This is also the type that does not require “safe=False” to be set on the JsonResponse statement.

  • object
  • dictionary
  • list
  • function
  • method

Q3. Which of the following is not a primitive type supported in JSON?

  • array
  • url
  • string
  • boolean
  • integer

Q4. In the following JSON, how would you print the value “six”?

data = {'one':'two', 'three': 4, 'five' : [ 'six', 'seven' ], 'eight' : { 'nine' : 10, 'ten' : 11 } }
  • alert(data.eight.nine)
  • alert(data[‘six’])
  • alert(five.six)
  • alert(five)
  • alert(data.five[0])

Q5. What does the Django’s JsonResponse do?

  • Reads a JSON string representation and converts it to a PHP object or list
  • Takes a Python object or list and serializes it into a JSON string representation
  • Encodes all non-printing characters with their hexadeciamal equivalents
  • Encodes the less-than and greater-than characters to make a string safe for JSON

Q6. What is the jQuery call to retrieve a JSON document from the server?

  • json_encode()
  • xHttpRequest()
  • getJSON()
  • fetch()
Conclusion:

I hope these Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answer would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Keep Learning!

Get All Course Quiz Answers of Django for Everybody Specialization

Web Application Technologies and Django Quiz Answers

Building Web Applications in Django Coursera Quiz Answers

Django Features and Libraries Coursera Quiz Answers

Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!