Python Questions and Answers – While and For Loops – 4

This set of Python Questions and Answers for Freshers focuses on “While and For Loops – 4”. 1. What will be the output of the following Python code? x = 123 for i in x: print(i) a) 1 2 3 b) 123 c) error d) none of the mentioned 2. What will be the output … Read more

advertisement

Python Questions and Answers – While and For Loops – 3

This set of Tough Python Questions & Answers focuses on “While and For Loops – 3”. 1. What will be the output of the following Python code? x = ‘abcd’ for i in x: print(i) x.upper() a) a B C D b) a b c d c) A B C D d) error 2. What … Read more

advertisement

Python Questions and Answers – While and For Loops – 2

This set of Advanced Python Questions & Answers focuses on “While and For Loops – 2”. 1. What will be the output of the following Python code? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) a) 0 1 2 0 b) 0 1 2 c) … Read more

advertisement

Python Multiple Choice Questions – While and For Loops

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “While and For Loops”. 1. What will be the output of the following Python code? x = [’ab’, ‘cd’] for i in x: i.upper() print(x) a) [‘ab’, ‘cd’] b) [‘AB’, ‘CD’] c) [None, None] d) none of the mentioned 2. What will be … Read more

advertisement

Python Questions and Answers – Decorators

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Decorators”. 1. What will be the output of the following Python code? def mk(x): def mk1(): print("Decorated") x() return mk1 def mk2(): print("Ordinary") p = mk(mk2) p() a) Decorated Decorated b) Ordinary Ordinary c) Ordinary Decorated d) Decorated Ordinary    2. In the … Read more

advertisement

Python Questions and Answers – Advanced Formatting Tools

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Advanced Formatting Tools”. 1. What will be the output of the following Python code? l=list(’HELLO’) ‘first={0[0]}, third={0[2]}’.format(l) a) ‘first=H, third=L’ b) ‘first=0, third=2’ c) Error d) ‘first=0, third=L’ 2. What will be the output of the following Python code? l=list(’HELLO’) p=l[0], l[-1], l[1:3] … Read more

advertisement

Python Question and Answers – Formatting – 2

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Formatting – 2”. 1. What will be the output of the following Python code snippet? ‘%d %s %g you’ %(1, ‘hello’, 4.0) a) Error b) 1 hello you 4.0 c) 1 hello 4 you d) 1 4 hello you 2. The output of … Read more

advertisement

Python Question and Answers – Formatting – 1

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Formatting – 1”. 1. What will be the output of the following Python code snippet? X=”hi” print(“05d”%X) a) 00000hi b) 000hi c) hi000 d) error 2. What will be the output of the following Python code snippet? X=”san-foundry” print(“%56s”,X) a) 56 blank spaces … Read more

advertisement

Python Questions and Answers – Boolean

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Boolean”. 1. What will be the output of the following Python code snippet? bool(‘False’) bool() a) True True b) False True c) False False d) True False    2. What will be the output of the following Python code snippet? [’hello’, ‘morning’][bool(”)] a) … Read more

advertisement

Python Questions and Answers – Bitwise – 2

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Bitwise – 2”. 1. It is not possible for the two’s complement value to be equal to the original value in any case. a) True b) False 2. The one’s complement of 110010101 is: a) 001101010 b) 110010101 c) 001101011 d) 110010100 3. … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.