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 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