1. Explain how enumerations work.
2. Describe the three problems that unscoped enumerations can cause.
While taking a viva in class, the teacher decides to take the viva of two roll numbers at a time. For this she calls out the roll numbers from the list of roll numbers as: One roll number from the first nth roll number and Second roll number from the nth last roll number. For example if the numbers are: rollnum=[21, 24, 45, 6, 7, 23, 9, 11, 15, 18], and n=4, then :One roll number called for viva is 6 and second roll number called for viva is 9.
You need to write a python function which take a list A and nth roll number as input and return first nth roll number and Second roll number from the nth last roll number as shown in example. If nth roll number is not lies in the range of list, then function will return "n is not in range" in place of first roll number and empty string (“”) in place of second roll number.
Example-1
Example-2
Input:
[21, 24, 45, 6, 7, 23, 9, 11, 15, 18]
20
Output:
n is not in range
Input:
[21, 24, 45, 6, 7, 23, 9, 11, 15, 18]
5
Output:
7
23
write a python function Separate_List(A) which take list A as input and return five lists, one contains all prime numbers in A, second one contains composite numbers in A, the third list contains all numbers in A which are neither divisible by 2, fourth and fifth list contains number divisible by 3 and 5 respectively.
Example-1
Example-2
Input:
1
2
3
4
5
10
15
20
30
Output:
[2, 3, 5]
[4, 10, 15, 20, 30]
[2, 4, 10, 20, 30]
[3, 15, 30]
[5, 10, 15, 20, 30]
Input:
1
3
5
6
7
8
9
10
Output:
[3, 5, 7]
[6, 8, 9, 10]
[6, 8, 10]
[3, 9]
[5, 10]
Given an array A of N integers and two integers X and Y, find the number of integers in the array that are both less than or equal to X and divisible by Y.
Create the following matrix by assigning vectors with constant spacing to the rows (use the linspace command for the third row). Do not type individual elements explicitly.
A =
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
7.0000 6.0000 5.0000 4.0000 3.0000 2.0000
2.0000 3.1667 4.3333 5.5000 6.6667 9.0000
the goal of this code is to quickly get you off the ground with the array method map().
input
the input will be single line containing an array myArray.
output
the output will be single line containing the newArray.
constaints
Strings should be given in quotes
input1
[ 1, 'David' 10, {'points':97}, 25, 'alphabet', true]
output1
[2, 'string' 20, 'object', 50, 'string', 'boolean']
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine().replace(/'/g, '"'));
// Write your code here
}
Bob a builder has come to you to build a program for his business. He needs to determine the square footage of a room in order to buy materials and calculate costs. Bob charges $125 per square metre. The program is going to ask the user to enter the name of a room. It will then ask for the width and length of the room (in meters) to be built. The program will calculate the room area and use this information to generate an approximate cost. Your program will display the room, the total area and the approximate cost to the screen.
Using Pseudocode, develop Javascript for this problem.
Solve the following system of six linear equations on MatLAB:
2a-4b+5c-3.5d +1.8 e + 4 f= 52.52
-1.5 a + 3b +4c-d-2e +5f= -21.1
5a+b-6c+3d -2e +2 f = -27.6
1.2a 2b +3c+4d-e+4f=9.16
4a+b-2c-3d-4e+1.5 f= - 17.9
3a+b-c+4d-2e-4 f= -16.2
Double the numbers
the goal of this code is to get quickly off the ground with array method map().
input
output
constraints
sample input1
[1, 'David', 10, {'points':97}, 25, 'alphabet', true]
sample output1
[2, 'string' 20, 'object', 50, 'string' 'boolean']
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine().replace(/'/g, '"'));
/* Please do not modify anything above this line */
// Write your code here
}
the goal of this code is to quickly get you off the ground with Creating and Consuming Promises.
input
output
based on inputs
sampleinput1
true
true
sampleoutput1
Taken Shower
Had Breakfast
Got to Work
function main() {
const isHotWaterReady = JSON.parse(readLine());
const isBreakfastReady = JSON.parse(readLine());
/* Please do not modify anything above this line */
// Write your code here
const takingShower = () => {
return new Promise((resolve,reject) => {
isHotWaterReady ? resolve("Taken Shower") : reject ("Hot Water Not Ready")
});
}
const breakFast = () => {
return new Promise((resolve,reject) => {
isBreakfastReady ? resolve("Had Breakfast") : reject ("Breakfast Not Ready")
});
}