Report Bug

Qus

What will be the output of the following Python code?

  s=["pune", "mumbai", "delhi"]  [(w.upper(), len(w)) for w in s]
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. Error
B. [‘PUNE’, 4, ‘MUMBAI’, 6, ‘DELHI’, 5]
C. [PUNE, 4, MUMBAI, 6, DELHI, 5]
D. [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)]


Solution
D. [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)]



Explanation
If we need to generate two results, we need to put it in the form of a tuple. The code shown above returns each word of list in uppercase, along with the length of the word. Hence the output of the code is: [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)].
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad