Report Bug

Qus

What will be the output of the following Python code?

[ord(ch) for ch in 'abc']
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. [97, 98, 99]
B. [‘97’, ‘98’, ‘99’]
C. [65, 66, 67]
D. Error


Solution
A. [97, 98, 99]



Explanation
The list comprehension shown above returns the ASCII value of each alphabet of the string ‘abc’. Hence the output is: [97, 98, 99]. Had the string been ‘ABC’, the output would be: [65, 66, 67].
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