Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What is the range of values that random.random() can return? a) [0.0, 1.0] b) (0.0, 1.0] c) (0.0, 1.0) d) [0.0, 1.0) 2. What

1. What is the range of values that random.random() can return?

a) [0.0, 1.0]

b) (0.0, 1.0]

c) (0.0, 1.0)

d) [0.0, 1.0)

2. What happens if the base condition isn't defined in recursive programs?

a) Program gets into an infinite loop

b) Program runs once

c) Program runs n number of times where n is the argument given to the function

d) An exception is thrown

3. Which of the following will result in an error?

a)

>>> p = re.compile("d")

>>> p.search("door")

b) >>> p = re.escape('hello')

c) >>> p = re.subn()

d) >>> p = re.purge()

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

class A:

def test1(self):

print(" test of A called ")

class B(A):

def test(self):

print(" test of B called ")

class C(A):

def test(self):

print(" test of C called ")

class D(B,C):

def test2(self):

print(" test of D called ")

obj=D()

obj.test()

a)

test of B called

test of C called

b)

test of C called

test of B called

c) test of B called

d) Error, both the classes from which D derives has same method test()

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

def func(a, b=5, c=10):

print('a is', a, 'and b is', b, 'and c is', c)

func(3, 7)

func(25, c = 24)

func(c = 50, a = 100)

a)

a is 7 and b is 3 and c is 10

a is 25 and b is 5 and c is 24

a is 5 and b is 100 and c is 50

b)

a is 3 and b is 7 and c is 10

a is 5 and b is 25 and c is 24

a is 50 and b is 100 and c is 5

c)

a is 3 and b is 7 and c is 10

a is 25 and b is 5 and c is 24

a is 100 and b is 5 and c is 50

d) None of the mentioned

6. Correct syntax of file.readlines() is?

a) fileObject.readlines( sizehint );

b) fileObject.readlines();

c) fileObject.readlines(sequence)

d) none of the mentioned

7. What will be the output of the following Python function, assuming that the random module has already been imported?

random.uniform(3,4)

a) Error

b) Either 3 or 4

c) Any integer other than 3 and 4

d) Any decimal value between 3 and 4

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

import turtle()

t=turtle.Pen()

t.goto(50,60)

t1=t.clone()

t1.ycor()

a) 0.0

b) 50.0

c) 60.0

d) Error

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

def to_upper(k):

k.upper()

x = ['ab', 'cd']

print(list(map(to_upper, x)))

a) ['AB', 'CD']

b) ['ab', 'cd']

c) none of the mentioned

d) error

10. Suppose d = {"john":40, "peter":45}, to delete the entry for "john" what command do we use?

a) d.delete("john":40)

b) d.delete("john")

c) del d["john"]

d) del d("john":40)

11. What will be the output of the following Python function?

list(enumerate([2, 3]))

a) Error

b) [(1, 2), (2, 3)]

c) [(0, 2), (1, 3)]

d) [(2, 3)]

12. Which of the following functions does not accept any argument?

a) re.purge

b) re.compile

c) re.findall

d) re.match

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

y = 6

z = lambda x: x * y

print z(8)

a) 48

b) 14

c) 64

d) None of the mentioned

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

class student:

def __init__(self):

self.marks = 97

self.__cgpa = 8.7

def display(self):

print(self.marks)

obj=student()

print(obj._student__cgpa)

a) The program runs fine and 8.7 is printed

b) Error because private class members can't be accessed

c) Error because the proper syntax for name mangling hasn't been implemented

d) The program runs fine but nothing is printed

15. To open a file c:\scores.txt for writing, we use ________

a) outfile = open("c:\scores.txt", "w")

b) outfile = open("c:\\scores.txt", "w")

c) outfile = open(file = "c:\scores.txt", "w")

d) outfile = open(file = "c:\\scores.txt", "w")

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

odd=lambda x: bool(x%2)

numbers=[n for n in range(10)]

print(numbers)

n=list()

for i in numbers:

if odd(i):

continue

else:

break

a) [0, 2, 4, 6, 8, 10]

b) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

c) [1, 3, 5, 7, 9]

d) Error

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

=+Do the key operating policies address the goals?

Answered: 1 week ago