Question: Please answer each Given an array of real numbers greater than zero in form of strings. Find if there exists a triplet (a,b,c) such that

Please answer each

Given an array of real numbers greater than zero in form of strings.

Find if there exists a triplet (a,b,c) such that 1 < a+b+c < 2 .

Return 1 for true or 0 for false.

Example:

Given [0.6, 0.7, 0.8, 1.2, 0.4] ,

You should return 1

as

0.6+0.7+0.4=1.7

1<1.7<2

Hence, the output is 1.

O(n) solution is expected.

Note: You can assume the numbers in strings don't overflow the primitive data type and there are no leading zeroes in numbers. Extra memory usage is allowed.

Python code for above cp question and mcq questions explanation is must. code will be tested on large test cases

1. What will be the output of the following Python code?

x = [[0], [1]]

print(len(' '.join(list(map(str, x)))))

a) 2

b) 3

c) 7

d) 8

2. What will be the output of the following Python code?

sentence = 'we are humans'

matched = re.match(r'(.*) (.*?) (.*)', sentence)

print(matched.group(2))

a) 'are'

b) 'we'

c) 'humans'

d) 'we are humans'

3. What will be the output of the following Python code?

random.seed(3)

random.randint(1,5)

2

random.seed(3)

random.randint(1,5)

a) 3

b) 2

c) Any integer between 1 and 5, including 1 and 5

d) Any integer between 1 and 5, excluding 1 and 5

4. What will be the output of the following Python code?

import turtle

t=turtle.Pen()

for i in range(0,5):

t.left(144)

t.forward(100)

a) Trapezium

b) Parallelepiped

c) Tetrahedron

d) Star

5. What will be the output of the following Python code?

def to_upper(k):

return k.upper()

x = ['ab', 'cd']

print(list(map(upper, x)))

a) ['AB', 'CD']

b) ['ab', 'cd']

c) none of the mentioned

d) error

6. What does os.close(f) do?

a) terminate the process f

b) terminate the process f if f is not responding

c) close the file descriptor f

d) return an integer telling how close the file pointer is to the end of file

7. What is the length of sys.argv?

a) number of arguments

b) number of arguments + 1

c) number of arguments - 1

d) none of the mentioned

8. What will be the output of the following Python code?

>>> import collections

>>> a=dict()

>>> a=collections.defaultdict(str)

>>> a['A']

a) An exception is thrown since the dictionary is empty

b) ' '

c) 'A'

d) 0

9. Which of the following statements is true?

a) A non-private method in a superclass can be overridden

b) A subclass method can be overridden by the superclass

c) A private method in a superclass can be overridden

d) Overriding isn't possible in Python

10. Which of the following is false about "import modulename" form of import?

a) The namespace of imported module becomes part of importing module

b) This form of import prevents name clash

c) The namespace of imported module becomes available to importing module

d) The identifiers in module are accessed as: modulename.identifier

11. If a function doesn't have a return statement, which of the following does the function return?

a) int

b) null

c) None

d) An exception is thrown without the return statement

12. What will be the output of the following Python code?

import sys

sys.argv[0]

a) Junk value

b) ' '

c) No output

d) Error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!