Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Product of Array Items

given array of integers, write a JS program to get the product of the integers in the given array.Input The input will be a single line containing an array integersOutput:The output should be a single line string containing the product as shown in sample outputs

Testcase1 :Sample Input 1

[1, 2, 3]

Sample Output 1

1 * 2 * 3 = 6

Testcase2 :Sample Input 2

[-1, -2, -3]

Sample Output 2

-1 * -2 * -3 = -6

note : it must satisfy any input given with different cases

"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() {

 let integers = JSON.parse(readLine());

/* Write your code here



Product of array Items

given an array integers,write JS program to get the product of the integers in the given array.

input

the input will be containing single line integers.

output

the output should be single line containing the product as shown in sample outputs.


input1

[1,2,3]

output1

[1 * 2 * 3 = 6]

input2

[-1, -2, -3]

output2

[-1*-2*-3 = -6]


Note: The Output should be displayed as [1 * 2 * 3 = 6]



given a list of M numbers and a positive integers N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N


INPUT:

the first line contains two-spaced integers N, M

the second line contain M space-separated integers.


output:

print a single integer representing the required sum


explanation:

Sample Output1

Given N=1 , M=7

and the number list = [4,8,6,6,7,9,3]

As every position is divisible by 1,

4+8+6+6+7+9+3=43

so the output should be 43


Write a function(preLetterCase) that accepts two parameters ( a string ,and a letter). The function must return the string with all characters before the first instance of the letter converted to lowercase and all other characters converted to uppercase. Hence, if the specified letter is the first character of the string then the entire string will be converted to uppercase. The new string should be returned by the function.


e.g.

  1. preLetterCase ("CAtCHa","a") -> "cATCHA",
  2. preLetterCase ("Preteen","e") -> "prETEEN"
  3. preLetterCase ("You've got this", "m") -> "you've got this"
  4. preLetterCase ("Keep trying", "k") -> "KEEP TRYING"

Create a 2D array of size m x n where m is the number of employees working and n is the

number of weekdays (mon – fri). Populate the array with the hours the employees have worked

for 1 week (random values between 5 and 10).


Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.


Input

The input will be a single line containing a positive integer (N).

Output

The output should be N rows with numbers.

For example: If the given number is 4 --

1

121

12321

1234321


If given number is 7 --

1

121

12321

1234321

123454321

12345654321

1234567654321


Note: In left hand side there will be no gap ,it should look like Right Triangle.

Coloring the blocks question :


Find total cost of coloring each block out of 3 colors such that cost should be minimum and not adjacent


B. There are n blocks placed in a row. Each block must be covered with one of the three colors available, but no two adjacent blocks can be the same color. The cost of coloring each block varies and is given in an array. Given the cost of using each color on each block, determine the minimum cost to color all the blocks.


C. Given colors price in rows, select a min price from the row and no two adjacent rows should have the same minimum price .


input = 3


1 2 3


4 3 2


8 3 2


output: 1+2+3 = 6



D. colored blocks


input = 3


1 2 2


1 2 2


1 2 1


output= 4


E. color cost picker


Input :[1 2 3]


[2 1 3]


[2 1 1]


Output : 1+2+1= 4


Finding the cheapest color and add them





1. Create a button control that has the caption Close. Now write the code which will ask the user to confirm whether he wants to close the program when he clicks on the Close button.



2. Write a program that requests the user to input two numbers and select an arithmetic operator. The program will then perform the calculation using the selected operator. (Use the Switch construct)



This is the code and it doesn't run completely, I don't know what's wrong because it also says that there is no error/s at all. Hope you help me with this.



ign = input("Pick an In Game Name!: ")


print(" Welcome to the guessing game ", ign ,"! ")



import random


def guess_number(s):


randomnum = random.randint (1, s )


guessnum = 0


while guessnum != randomnum:


guessnum = int(input(f"Guess the number, choose an integer from 1 -{s}:"))



if guessnum < randomnum:


print ("Guess again the value is low!!")



elif guessnum > randomnum:


print ("Guess again the value is high!!")



print (" Congratulations! You guessed ",randomnum," Right! ")



guess_number= 10

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS