0% found this document useful (0 votes)
26 views3 pages

JavaScript and Python Coding Test

The document contains questions about JavaScript syntax, functions, arrays, and HTML. It asks which syntax correctly displays an alert box, what the output of code samples evaluating a string and number concatenated together and iterating through an array to add elements to a string would be. It also asks about writing functions to check if value types are the same and sort an array in descending order, and includes multiple choice questions about HTML, CSS, Bootstrap, and Python concepts.

Uploaded by

FLOURDTRI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

JavaScript and Python Coding Test

The document contains questions about JavaScript syntax, functions, arrays, and HTML. It asks which syntax correctly displays an alert box, what the output of code samples evaluating a string and number concatenated together and iterating through an array to add elements to a string would be. It also asks about writing functions to check if value types are the same and sort an array in descending order, and includes multiple choice questions about HTML, CSS, Bootstrap, and Python concepts.

Uploaded by

FLOURDTRI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Which of the following is the correct syntax to display “Hi I am Shalini” in an

alert box using JavaScript?


1 point
alertbox(“Hi I am Shalini”);
msg(“Hi I am Shalini”);
msgbox(“Hi I am Shalini”);
alert(“Hi I am Shalini”);

What will be the output of the following JavaScript code?


<script type="text/javascript"> a = 4 + "2"; [Link](a); </script>
1 point
6
Compilation Error
42
Run Time Error

What will be the output of the following javacript code?


<script> var cars = ["blue", "red", "green", "orange"]; var text = ""; var i; for
(i = 0; i < [Link]; i++) { text += cars[i] +" "; }
[Link]("demo").innerHTML = text; </script>
1 point
blue red green orange
blue red green
Compilation Error
Run Time Error

Write a JavaScript function to check whether given value types are same or not.

Write a JavaScript program to sort the items of an array in descending order.

To enable slideshow, what should not be included in HTML?


1 point
[Link]
button
[Link]
[Link]

Which tag is used to allow control over the viewport in HTML5?


1 point
<meta>
<acronym>
<em>
<address>

What value should we set for background-size property in CSS such that image will
stretch to cover entire content area?
1 point
100%100%
cover
contain
100%

What does bootstrap not use from the following ?


1 point
HTML
JQuery
PHP
CSS

What creates a carat arrow icon?


1 point
.carousel
.caret
.carousel-caption
.caption

How to find the last element of list in Python? Assume `Whitehat` is the name of
list.
1 point
Whitehat[0]
Whitehat[-1]
Whitehat[pos]
Whitehat[:-1]

Find the output of the following Python code.


1 point
Captionless Image
a
b
c
d

Which statement is correct about Lists and Tuples in Python?


1 point
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both are Immutable
Both are Mutable.

Write a Python function which prints a list with square of all even numbers between
10 and 20 (both included).

Syntax of constructor in Python?


1 point
def _init_()
def __init__()
_init_()
def int()

In the image given consider there is a ball sprite then what will be the output of
this given control structure?
1 point
Captionless Image
The ball glides to a random position in 1 second
The ball glides to 10 random positions taking 1 second to reach each position
The ball glides to a random position and waits there for 10 seconds
The ball glides to 10 random positions within 1 second

What will be the output in Debug console of [Link] for the given code snippet?
1 point
Captionless Image
a=10 b=20
a=30 b=20
a=20 b=20
a=20 b=10
What will be the output of given code snippet?
1 point
Captionless Image
It will print the value of factorial of number 4 onto the label.
It will print the value of factorial of number 5 onto the label.
Code will run in infinite loop so it will generate a garbage value
It will print the integer value 1 onto the label

Consider the below code snippet for Password Checker. What should be added into the
Key-value pair of Data section of this code for getting a true value in an
if...else condition?
1 point
Captionless Image
KEY = paswd VALUE= "ABC"
KEY= password VALUE=White
KEY= password VALUE= "WHITE"
KEY= paswd VALUE= ABC

Which string operation will get executed on getting a true value of the if
condition for the given code snippet?
1 point
Captionless Image
String length.
String compare
String concatenation
Substring of a String.

Common questions

Powered by AI

The output of the provided JavaScript code snippet will be 'blue red green orange '. The code iterates over the array of colors and concatenates each to the 'text' string variable with a space in between.

To check whether two value types are the same in JavaScript, you can use the 'typeof' operator to compare their types. For example, function checkSameType(val1, val2) { return typeof val1 === typeof val2; }.

The <meta> tag is used to control the viewport properties in HTML5 for responsive design. This typically involves setting the viewport's width, initial scale, and other properties.

The primary difference between lists and tuples in Python is that lists are mutable, meaning their elements can be changed. In contrast, tuples are immutable, meaning their structures cannot be changed after creation.

A common method to sort an array in descending order in JavaScript is by using the 'sort()' method with a custom comparison function. For example: array.sort((a, b) => b - a)

When performing arithmetic operations with a number and a string, JavaScript will attempt to convert the number to a string and concatenate them. For example, 4 + "2" will result in "42" not an arithmetic sum.

The correct Python syntax to define a constructor in a class is def __init__(self):. The '__init__' method is a special method invoked when an object is instantiated.

To enable a slideshow without irrelevant elements, do not include 'jquery.js', 'button', or 'foundation.orbit.js', as only 'foundation.js' might be unnecessary.

To ensure an image will stretch to cover the entire content area, you should set the CSS background-size property to 'cover'.

The correct syntax to display a message in an alert box using JavaScript is alert("Hi I am Shalini")

You might also like