Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a non-negative number represented as an array of digits, add 1 to the number ( increment the number represented by the digits ). The

Given a non-negative number represented as an array of digits,

add 1 to the number ( increment the number represented by the digits ).

The digits are stored such that the most significant digit is at the head of the list.

Example:

If the vector has [1, 2, 3]

the returned vector should be [1, 2, 4]

as 123 + 1 = 124.

Code will be tested with large test case files please note it, Please don't copy. MCQs with proper explanation needed

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

def a(n):

if n == 0:

return 0

elif n == 1:

return 1

else:

return a(n-1)+a(n-2)

for i in range(0,4):

print(a(i),end=" ")

a) 0 1 2 3

b) An exception is thrown

c) 0 1 1 2 3

d) 0 1 1 2

2. The value returned when we use the function isoweekday() is ______ and that for the function weekday() is ________ if the system date is 19th June, 2017 (Monday).

a) 0,0

b) 0,1

c) 1,0

d) 1,1

3. What is the type of each element in sys.argv?

a) set

b) list

c) tuple

d) string

4. All modular designs are because of a top-down design process.

a) True

b) False

5. Which function is used to read single line from file?

a) Readline()

b) Readlines()

c) Readstatement()

d) Readfullline()

6. Overriding means changing behaviour of methods of derived class methods in the base class.

a) True

b) False

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

import sys

eval(sys.stdin.readline())

"India"

a) India5

b) India

c) 'India '

d) 'India'

8. Which of the following functions results in an error?

a) turtle.shape("turtle")

b) turtle.shape("square")

c) turtle.shape("triangle")

d) turtle.shape("rectangle")

9. What does the function math.frexp(x) return?

a) a tuple containing the mantissa and the exponent of x

b) a list containing the mantissa and the exponent of x

c) a tuple containing the mantissa of x

d) a list containing the exponent of x

10. The readlines() method returns ____________

a) str

b) a list of lines

c) a list of single characters

d) a list of integers

11. The special character \B matches the empty string, but only when it is _____________

a) at the beginning or end of a word

b) not at the beginning or end of a word

c) at the beginning of the word

d) at the end of the word

12. What does os.fchmod(fd, mode) do?

a) change permission bits of the file

b) change permission bits of the directory

c) change permission bits of either the file or the directory

d) none of the mentioned

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

def f1():

x=100

print(x)

x=+1

f1()

a) Error

b) 100

c) 101

d) 99

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

def maximum(x, y):

if x > y:

return x

elif x == y:

return 'The numbers are equal'

else:

return y

print(maximum(2, 3))

a) 2

b) 3

c) The numbers are equal

d) None of the mentioned

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Can a statutory and consensual lien coexist in the same collateral

Answered: 1 week ago

Question

Please Help fill out the table

Answered: 1 week ago