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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz