No Result
View All Result
Sunday, June 4, 2023
  • Login
Getting Placed
  • Home
  • Jobs
  • Exam
  • Admit Card
  • Result
  • Internship
  • Home
  • Jobs
  • Exam
  • Admit Card
  • Result
  • Internship
No Result
View All Result
Getting Placed
No Result
View All Result

Python MCQ’s on Function: SET 3

Badal Yadav by Badal Yadav
April 28, 2021
in Python
0
python

21. Which of the following functions accepts only integers as arguments?

a) ord()

b) min()

c) chr()

d) any()

Check Answer

Answer: c
The function chr() accepts only integers as arguments. The function ord() accepts only strings. The functions min() and max() can accept floating point as well as integer arguments.

22. Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

a) reverse(l)

b) list(reverse[(l)])

c) reversed(l)

d) list(reversed(l))

Check Answer

Answer: d
The built-in function reversed() can be used to reverse the elements of a list. This function accepts only an iterable as an argument. To print the output in the form of a list, we use: list(reversed(l)). The output will be: [4,3,2].

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

float(‘ -12345\n’)

(Note that the number of blank spaces before the number is 5)

a)   -12345.0 (5 blank spaces before the number)

b) -12345.0

c) Error

d) -12345.000000000…. (infinite decimal places)

Check Answer

Answer: b
The function float() will remove all the blank spaces and convert the integer to a floating point number. Hence the output will be: -12345.0.

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

ord(65)

ord(‘A’)

a)

A
65

b)

Error
65

c)

A
Error

d)

Error
Error

Check Answer

Answer: b
The built-in function ord() is used to return the ASCII value of the alphabet passed to it as an argument. Hence the first function results in an error and the output of the second function is 65.

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

float(‘-infinity’)

float(‘inf’)

a)

–inf
inf

b)

–infinity
inf

c)

Error
Error

d)

Error
Junk value

Check Answer

Answer: a
The output of the first function will be –inf and that of the second function will be inf.

26. Which of the following functions will not result in an error when no arguments are passed to it?

a) min()

b) divmod()

c) all()

d) float()

Check Answer

Answer: d
The built-in functions min(), max(), divmod(), ord(), any(), all() etc throw an error when no arguments are passed to them. However there are some built-in functions like float(), complex() etc which do not throw an error when no arguments are passed to them. The output of float() is 0.0.

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

hex(15)

a) f

b) 0xF

c) 0Xf

d) 0xf

Check Answer

Answer: d
The function hex() is used to convert the given argument into its hexadecimal representation, in lower case. Hence the output of the function hex(15) is 0xf.

28. Which of the following functions does not throw an error?

a) ord()

b) ord(‘ ‘)

c) ord(”)

d) ord(“”)

Check Answer

Answer: b
The function ord() accepts a character. Hence ord(), ord(”) and ord(“”) throw errors. However the function ord(‘ ‘) does not throw an error because in this case, we are actually passing a blank space as an argument. The output of ord(‘ ‘) is 32 (ASCII value corresponding to blank space).

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

len([“hello”,2, 4, 6])

a) 4

b) 3

c) Error

d) 6

Check Answer

Answer: a
The function len() returns the length of the number of elements in the iterable. Therefore the output of the function shown above is 4.

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

oct(7)

oct(‘7’)

a)

Error
07

b)

0o7
Error

c)

0o7
Error

d)

07
0o7

Check Answer

Answer: c
The function oct() is used to convert its argument into octal form. This function does not accept strings. Hence the second function results in an error while the output of the first function is 0o7.

Page  1  2  3  4  5  6  7

Python Interview Questions (MCQs)

We have divided these Python Questions and Answers into various parts based on the topics. Open the Topic of your choice and Practice these MCQs.

Python MCQs on Variables and Operators Python MCQs on Precedence and Associativity
Python MCQs on Data Type Python MCQs on Boolean
Python MCQs on Bitwise Operators Python MCQs on Formatting and Advance Formatting
Python MCQs on Decorators Python MCQs on While and For Loops
Python MCQs on List Python MCQs on List Comprehension
Python MCQs on String Python MCQs on Tuple
Python MCQs on SET Python MCQs on Dictionary
Python MCQs on Functions Python MCQs on Argument Parsing
Python MCQs on Global and Local Variables Python MCQs on Recursion
Python MCQs on Mapping Functions Python MCQs on Modules
Python MCQs on Regular Expressions Python MCQs on Files
Python MCQs on Overloading Python MCQs on Classes and Objects
Python MCQs on Inheritance Python MCQs on Polymorphism and Encapsulation
Python MCQs on Exception Handling
Previous Post

Python MCQ’s on Function: SET 2

Next Post

Python MCQ’s on Function: SET 4

Badal Yadav

Badal Yadav

Next Post
python

Python MCQ's on Function: SET 4

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us on Google News
No Result
View All Result

Recent Posts

  • Foreign Travel without Passport: Big News! Now passport is not required to go abroad, travel will be done with Aadhaar card
  • IRCTC Recruitment 2023: Golden chance to work with IRCTC without exam, application started, will get good salary
  • New List of Safest Banks: RBI released list of safest banks in India, see list here
  • Do not make these mistakes while filling ITR, you may get income tax notice
  • Post Office MIS: Interest is given every month in this scheme, know every detail related to it

Recent Comments

  • Abhishek on Win 11 Download Links

Archives

  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • August 2022
  • July 2022
  • October 2021
  • July 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • April 2020
  • February 2020

Categories

  • Admit Card
  • Algorithm and Programs
  • Exam
  • Internship
  • Java
  • Jobs
  • latest
  • politics and entertainment
  • Python
  • Result
  • Trademark
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
  • Privacy Policy
  • DMCA
  • Terms of Use
  • Sitemap

© 2020 Getting Placed

No Result
View All Result
  • Home
  • Jobs
  • Exam
  • Admit Card
  • Result
  • Internship

© 2020 Getting Placed

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In