In [4]:
s = """Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation via the off-side rule.
Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library.
Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0.[36] Python 2.0 was released in 2000. Python 3.0, released in 2008, was a major revision not completely backward-compatible with earlier versions. Python 2.7.18, released in 2020, was the last release of Python 2.
Python consistently ranks as one of the most popular programming languages."""
In [7]:
s = s.lower()
In [6]:
s.count("a")
Out[6]:
64
In [8]:
ord('a')
Out[8]:
97
In [9]:
chr(97)
Out[9]:
'a'
In [13]:
a2z = [chr(i) for i in range(97, 123)]
In [15]:
for i in a2z:
print(i, s.count(i))
a 65 b 10 c 21 d 29 e 71 f 9 g 29 h 23 i 55 j 2 k 3 l 36 m 20 n 54 o 48 p 31 q 0 r 47 s 49 t 51 u 21 v 6 w 7 x 0 y 18 z 1
In [ ]:
No comments:
Post a Comment