Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer each Given a string, find the rank of the string amongst its permutations sorted lexicographically. Assume that no characters are repeated. Example :

Please answer each

Given a string, find the rank of the string amongst its permutations sorted lexicographically.

Assume that no characters are repeated.

Example :

Input : 'acb'

Output : 2

The order permutations with letters 'a', 'c', and 'b' :

abc

acb

bac

bca

cab

cba

The answer might not fit in an integer, so return your answer % 1000003

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 function?

len(["hello",2, 4, 6])

a) 4

b) 3

c) Error

d) 6

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

class A:

def str(self):

return '1'

class B(A):

def init(self):

super().init()

class C(B):

def init(self):

super().init()

def main():

obj1 = B()

obj2 = A()

obj3 = C()

print(obj1, obj2,obj3)

main()

a) 1 1 1

b) 1 2 3

c) '1' '1' '1'

d) An exception is thrown

3. Which of the following statements create a dictionary?

a) d = {}

b) d = {"john":40, "peter":45}

c) d = {40:"john", 45:"peter"}

d) All of the mentioned

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

re.split('mum', 'mumbai*', 1)

a) Error

b) [", 'bai*']

c) [", 'bai']

d) ['bai*']

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

class A:

def init(self, x= 1):

self.x = x

class der(A):

def init(self,y = 2):

super().init()

self.y = y

def main():

obj = der()

print(obj.x, obj.y)

main()

a) Error, the syntax of the invoking method is wrong

b) The program runs fine but nothing is printed

c) 1 0

d) 1 2

6. Which of the following functions can help us to find the version of python that we are currently working on?

a) sys.version

b) sys.version()

c) sys.version(0)

d) sys.version(1)

7. The expression a{5} will match _____________ characters with the previous regular expression.

a) 5 or less

b) exactly 5

c) 5 or more

d) exactly 4

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

x=1

def cg():

global x

x=x+1

cg()

x

a) 2

b) 1

c) 0

d) Error

9. What is displayed on executing print(math.fabs(-3.4))?

a) -3.4

b) 3.4

c) 3

d) -3

10. A class in which one or more methods are only implemented to raise an exception is called an abstract class.

a) True

b) False

11. What is the order of namespaces in which Python looks for an identifier?

a) Python first searches the global namespace, then the local namespace and finally the built-in namespace

b) Python first searches the local namespace, then the global namespace and finally the built-in namespace

c) Python first searches the built-in namespace, then the global namespace and finally the local namespace

d) Python first searches the built-in namespace, then the local namespace and finally the global namespace

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

def f1(x):

global x

x+=1

print(x)

f1(15)

print("hello")

a) error

b) hello

c) 16

d)

16

hello

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

m = re.search('a', 'The blue umbrella')

m.re.pattern

a) {}

b) 'The blue umbrella'

c) 'a'

d) No output

14. What is the output of the function complex()?

a) 0j

b) 0+0j

c) 0

d) Error

15. Which function is used to read all the characters?

a) Read()

b) Readcharacters()

c) Readall()

d) Readchar()

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

1. Solve for r: A = P + Prt. 2. Solve for b: A = 1/2(a + b)h.

Answered: 1 week ago