Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
0890 - Nr Vocale
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Rezolvare == <syntaxhighlight lang="python" line="1"> # 0890 NrVocale def validare(propozitie): # functia de validare a datelor de intrare if len(propozitie) > 255: raise ValueError # daca dsatele de intrare nu corespund, ridicam eroarea ValueError print("Datele de intrare corespund restrictiilor impuse") return True def vocala(litera): # functia de verificare daca e vocala (include si majuscule) lista_vocale = "aeiouAEIOU" if litera in lista_vocale: return True else: return False def nrvocale(propozitie): # functia de rezolvare frecventa_litere = [] # ne creem un vector de frecventa pentru litere for i in range(128): # pana la 128 se afla ultimul cod ascii pentru litere frecventa_litere.append(0) for litera in propozitie: if vocala(litera): # daca e vocala crestem frecventa if litera >= 'a': frecventa_litere[ord(litera) - 32] += 1 # daca e vocala mica, crestem frecventa la exhivalentul ei in majuscule # deoarece in problema nu se tine cont daca e litera mare sau mica si le numaram pe toate la majuscule else: frecventa_litere[ord(litera)] += 1 aparitii_max = max(frecventa_litere) # gasim numarul cel mai mare de aparitii de vocale for i in range(len(frecventa_litere)): # parcurgem iar vectorul de frecventa if frecventa_litere[i] == aparitii_max: # daca am gasit vocala cu nr maxim de aparitii o afisam print(chr(i)) return # si incheiem programul if __name__ == '__main__': # din cauza datelor de intrare pot aparea 2 tipuri de erori, valueError sau IndexError pe care le tratam try: sir = input(f"Introduceti textul ") # citirea textului validare(sir) # apelul functiei de validare nrvocale(sir) # apelul functiei de rezolvare except ValueError: print("Datele de intrare nu corespund restrictiilor impuse") except IndexError: print("Datele de intrare nu corespund restrictiilor impuse") </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width