Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Which of the following data structures is returned by the functions globals() and locals()? a) list b) set c) dictionary d) tuple 2. What

1. Which of the following data structures is returned by the functions globals() and locals()?

a) list

b) set

c) dictionary

d) tuple

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

x = [[0], [1]]

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

a) ('[0] [1]',)

b) ('01',)

c) [0] [1]

d) 01

3. Which of the following functions can be used to find the coordinated universal time, assuming that the datetime module has already been imported?

a) datetime.utc()

b) datetime.datetime.utc()

c) datetime.utcnow()

d) datetime.datetime.utcnow()

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

def f(x):

print("outer")

def f1(a):

print("inner")

print(a,x)

f(3)

f1(1)

a)

outer

error

b)

inner

error

c)

outer

inner

d) error

5. What will be the output of the following Python code and state the type of copy that is depicted?

l1=[2, 4, 6, 8]

l2=[1, 2, 3]

l1=l2

l2

a) [2, 4, 6, 8], shallow copy

b) [2, 4, 6, 8], deep copy

c) [1, 2, 3], shallow copy

d) [1, 2, 3], deep copy

6. The function re.error raises an exception if a particular string contains no match for the given pattern.

a) True

b) False

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

str = raw_input("Enter your input: ");

print "Received input is : ", str

a)

Enter your input: Hello Python

Received input is :Hello Python

b)

Enter your input: Hello Python

Received input is :Hello

c)

Enter your input: Hello Python

Received input is :Python

d) None of the mentioned

8. What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

import turtle

t=turtle.Pen()

t.goto(100,0)

t.towards(0,0)

a) 0.0

b) 180.0

c) 270.0

d) 360.0

9. Which is the most appropriate definition for recursion?

a) A function that calls itself

b) A function execution instance that calls another execution instance of the same function

c) A class method that calls another class method

d) An in-built method that is automatically called

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

def f(x, y, z): return x + y + z

f(2, 30, 400)

a) 432

b) 24000

c) 430

d) No output

11. What will be the output shape of the following Python code?

import turtle

t=turtle.Pen()

for i in range(0,4):

t.forward(100)

t.left(120)

a) square

b) rectangle

c) triangle

d) kite

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

>>> import collections

>>> a=collections.Counter([3,3,4,5])

>>> b=collections.Counter([3,4,4,5,5,5])

>>> a&b

a) Counter({3: 12, 4: 1, 5: 1})

b) Counter({3: 1, 4: 1, 5: 1})

c) Counter({4: 2})

d) Counter({5: 1})

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

l=[1, -2, -3, 4, 5]

def f1(x):

return x<-1

m1=map(f1, l)

print(list(m1))

a) [False, False, False, False, False]

b) [False, True, True, False, False]

c) [True, False, False, True, True]

d) [True, True, True, True, True]

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

a={1:"A",2:"B",3:"C"}

print(a.get(1,4))

a) 1

b) A

c) 4

d) Invalid syntax for get method

15. 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

16. What is output of print(math.pow(3, 2))?

a) 9

b) 9.0

c) None

d) None of the mentioned

17. Which of the following functions can be used to read data from a file using a file descriptor?

a) os.reader()

b) os.read()

c) os.quick_read()

d) os.scan()

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

Write a note on AGMARK.

Answered: 1 week ago

Question

Plan merit and demerits ?

Answered: 1 week ago

Question

Essential Elements of map ?

Answered: 1 week ago

Question

Evaluate common feachers of social reform movement in Kerala?

Answered: 1 week ago