Question

USE PYTHON LANGUAGE

PLEASE FOCUS

YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT( TRUE/ FALSE)

QUIZ 8 Array Challenge Have the function ArrayChallenge(arr) take the array of numbers stored in arr and return the string true if any two numbers can be multiplied so that the answer is greater than double the sum of all the elements in the array. If not, return the string false. For example: if arr is [2, 5, 6, -6, 16, 2, 3, 6, 5, 3] then the sum of all these elements is 42 and doubling it is 84. There are two elements in the array, 16 * 6 = 96 and 96 is greater than 84, so your program should return the string true.

Examples

Input: [2, 2, 2, 2, 4, 1]

Output: false

Input: [1, 1, 2, 10, 3, 1, 12]

Output: true

Answer #1

I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments(read them for better understanding).

**Images of the Code:**

**Note: For indentation please refer code Images**

**Typed Code:**

# A function called ArrayChallenge with arr parameter

def ArrayChallenge(arr):

#calculating the sum of the arr using sum function

#And then doubled it by multiplying with 2

#and stored it in variable called double_sum

double_sum=sum(arr)*2;

#Accessing the all elements in arr

for i in range(0,len(arr)):

#Accessing elements after arr[i]

for j in range(i,len(arr)):

# multiplying the elements and checking

#whether it is greater than double_sum

if(arr[i]*arr[j]>double_sum):

#returning a string true

return "true"

#if any two numbers can be multiplied

#and that the answer is not greater than double_sum

return "false"

#Creating a list

arr=[2, 5, 6, -6, 16, 2, 3, 6, 5, 3]

#calling function ArrayChallenge

print(ArrayChallenge(arr))

#Creating a list

arr=[1, 1, 2, 10, 3, 1, 12]

#calling function ArrayChallenge

print(ArrayChallenge(arr))

#Creating a list

arr=[2, 2, 2, 2, 4, 1]

#calling function ArrayChallenge

print(ArrayChallenge(arr))

**#code ended here**

**Output:**

If You Have Any Doubts. Please Ask Using Comments.

Have A Great Day!

Please use Python 3
4). Write a program that asks the user to enter 10 numbers. The
program should store the numbers in a list and then display the
following data:
• The lowest number in the list •
The highest number in the list
•The total of the numbers in the list
• The average of the numbers in the list
Sample input & output:
(Prompt) Enter Number 1: (User enter) 4
(Prompt) Enter Number 2: (User enter) 7...

WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question,
DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER
QUESTION:
1) Fibonacci sequence is a sequence in which every number after
the first two is the sum of the two preceding ones. Write a C++
program that takes a number n from user and populate an array with
first n Fibonacci numbers.
For example:
For n=10
Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
2):
Write...

Write a program to determine the minimum element in an array of
ten elements. The program should have the following:
1. Class Name as ArrayProcessing. The main method should create
an array of size 10
2. There should be two methods besides the main method in the
class namely inputArray and MinimumElement
3. InputArray method should assign the ten elements in the
array. Use scanner to input these elements. The array of 10 numbers
in the method "InputArray" should be...

For each of the following Python programs P and input strings I,
give the output P(I), using the formal definition of P(I) given,
and employing any reasonable reference computer C:
Definition of P(I), the output of a Python program. Let P be a
Python program with respect to a reference computer system C.
Suppose P has main function M, and let I be a string of ASCII
characters that will be used as input to P. The output of P...

C++ program for :
1. Given an array of real numbers and the dimension n (n is
entered from the keyboard). B form an array, each element bi -
arithmetic mean of the array elements and excluding ai.
2. Given an array of integers dimension n. Change the array so that
all the elements of the module which is not equal to the maximum
element of the array, replaced by zero, and equal - unit.
3. Given an array of...

This is JAVA
Priscilla Perfect detests imperfection (hence the name). Write a
program to analyze a given array and return true if the array is
worthy of being presented to Priscilla.
An array is considered perfect if there are no empty slots. Empty
slots in the given array will have a value of 0.
Examples:
isPerfectArray({2, 3, 4, 5, 6}) -> true
isPerfectArray({1, 1, 4, 5, 6, 0, 0, 0, 0}) -> false
1
public boolean isPerfectArray(int[] arr)
2
{...

Please write the code
in Python.
Write a
program/function in any Object-Oriented programming language that
will implement Queue Abstract Data Type with the following
functions/methods. Any build-in/pre-defined Queue
function/library (e.g., java.util.Queue in Java) is
NOT allowed to use in your code.
push(Element): insert the
input Element (e.g., String or Integer in Java) to the end
of the queue.
pop(): remove
the head element of the queue and print the head element on
screen.
count(): return the total number of
elements in the queue...

Write the following program in MIPS:
a) declare an array A of the following numbers: 3, 5, 8, 10, 12,
2, 76, 43, 90, 44
b) declare a variable called size which stores the number of
element in array A, that is 10.
c) write a subroutine to search for a number stored in an array
and return true or false. In C++ the subroutine is as
follows:
search(array, size, number_To_Search)
e.g. search(A, 10, 12)
The subroutine should return 0...

C LANGUAGE CODE WITH COMMAND-LINE ARGUMENTS (NO
SCANF TO BE USED )
Q]. Write a program that displays all
the prime numbers in the given array with the following
constraint.
Constraint: Only those prime numbers should be
displayed whose location is a composite number.
Although you may have several prime numbers in the array, only
those prime numbers should be displayed which are stored at
non-prime locations. Remember that the first position in an array
corresponds to the location/index 0....

Language: Python
Write a program to simulate an experiment of tossing a fair coin
16 times and counting the number of heads. Repeat this experiment
10**5 times to obtain the number of heads for every 16 tosses; save
the number of heads in a vector of size 10**5 (call it
headCounts).
You should be able to do this in 1-3 lines of numpy code. (Use
np.random.uniform1 to generate a 2d array of 10**5 x 16 random
numbers between 0 and...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 2 minutes ago

asked 6 minutes ago

asked 11 minutes ago

asked 26 minutes ago

asked 44 minutes ago

asked 53 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago