# Texte à analyser : # Paragraphe "History" de la page Wikipedia anglaise sur "Computer Science". # Choix de l'anglais pour ne pas avoir d'accents. texte = "The earliest foundations of what would become computer science predate the invention of the modern digital computer. Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity, aiding in computations such as multiplication and division. Algorithms for performing computations have existed since antiquity, even before the development of sophisticated computing equipment. Wilhelm Schickard designed and constructed the first working mechanical calculator in 1623. In 1673, Gottfried Leibniz demonstrated a digital mechanical calculator, called the Stepped Reckoner. He may be considered the first computer scientist and information theorist, for, among other reasons, documenting the binary number system. In 1820, Thomas de Colmar launched the mechanical calculator industry when he released his simplified arithmometer, which was the first calculating machine strong enough and reliable enough to be used daily in an office environment. Charles Babbage started the design of the first automatic mechanical calculator, his Difference Engine, in 1822, which eventually gave him the idea of the first programmable mechanical calculator, his Analytical Engine. He started developing this machine in 1834, and 'in less than two years, he had sketched out many of the salient features of the modern computer' A crucial step was the adoption of a punched card system derived from the Jacquard loom making it infinitely programmable. In 1843, during the translation of a French article on the Analytical Engine, Ada Lovelace wrote, in one of the many notes she included, an algorithm to compute the Bernoulli numbers, which is considered to be the first published algorithm ever specifically tailored for implementation on a computer. Around 1885, Herman Hollerith invented the tabulator, which used punched cards to process statistical information; eventually his company became part of IBM. In 1937, one hundred years after Babbage's impossible dream, Howard Aiken convinced IBM, which was making all kinds of punched card equipment and was also in the calculator business to develop his giant programmable calculator, the ASCC/Harvard Mark I, based on Babbage's Analytical Engine, which itself used cards and a central computing unit. When the machine was finished, some hailed it as 'Babbage's dream come true'. During the 1940s, as new and more powerful computing machines such as the Atanasoff–Berry computer and ENIAC were developed, the term computer came to refer to the machines rather than their human predecessors. As it became clear that computers could be used for more than just mathematical calculations, the field of computer science broadened to study computation in general. In 1945, IBM founded the Watson Scientific Computing Laboratory at Columbia University in New York City. The renovated fraternity house on Manhattan's West Side was IBM's first laboratory devoted to pure science. The lab is the forerunner of IBM's Research Division, which today operates research facilities around the world. Ultimately, the close relationship between IBM and the university was instrumental in the emergence of a new scientific discipline, with Columbia offering one of the first academic-credit courses in computer science in 1946. Computer science began to be established as a distinct academic discipline in the 1950s and early 1960s. The world's first computer science degree program, the Cambridge Diploma in Computer Science, began at the University of Cambridge Computer Laboratory in 1953. The first computer science department in the United States was formed at Purdue University in 1962. Since practical computers became available, many applications of computing have become distinct areas of study in their own rights. Although many initially believed it was impossible that computers themselves could actually be a scientific field of study, in the late fifties it gradually became accepted among the greater academic population. It is the now well-known IBM brand that formed part of the computer science revolution during this time. IBM (short for International Business Machines) released the IBM 704 and later the IBM 709 computers, which were widely used during the exploration period of such devices. 'Still, working with the IBM [computer] was frustrating […] if you had misplaced as much as one letter in one instruction, the program would crash, and you would have to start the whole process over again'. During the late 1950s, the computer science discipline was very much in its developmental stages, and such issues were commonplace. Time has seen significant improvements in the usability and effectiveness of computing technology. Modern society has seen a significant shift in the users of computer technology, from usage only by experts and professionals, to a near-ubiquitous user base. Initially, computers were quite costly, and some degree of humanitarian aid was needed for efficient use—in part from professional computer operators. As computer adoption became more widespread and affordable, less human assistance was needed for common usage." # On passe le texte en majuscule pour ne pas faire de distinction entre majuscules et minuscules. # Il est à noter que ces choix ont été faits car nous désirions uniquement obtenir les fréquences d'apparition des lettres, indépendamment # de leur casse. Il est évident que le programme pourrait gérer et les minuscules et les accents. texte = texte.upper() # On parcourt le texte et on crée une liste de listes comportant un caractère et le nombre d'occurences dans le texte. liste = [] for i in range(len(texte)): # On extrait le i ème caractère caractere = texte[i:i+1] trouve = False # Le caractère en question se trouve-t-il dans la liste des caractères déjà rencontrés ? j = 0 while (j < len(liste) and not(trouve)): element = liste[j][0] # Si oui, on augmente son nombre d'occurence de 1 if element == caractere: liste[j][1] += 1 trouve = True j += 1 # Si non, on le rajoute à la liste avec un nombre d'occurence de 1 if not(trouve): liste.append([caractere, 1]) print("Liste non triée :") print(liste) # On trie la liste des caractères trouvées par nombre d'occurences croissant # Il s'agit d'un algorithme de tri par sélection classique for i in range(len(liste)-1): iMin=i for j in range(i+1,len(liste)): if liste[j][1] < liste[iMin][1]: iMin = j if iMin != i : aux = liste[i] liste[i] = liste[iMin] liste[iMin] = aux print(" ") print("Liste triée :") print(liste)