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
1423 - Vocale Vector
(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"> # 1423 VocaleVector def validare(nr_elemente, sir_litere): # functia de verificare a datelor de intrare # in cazul in care nu este respectata vreo restrictie, vom marca acest lucru prin eroarea ValueError if nr_elemente > 4000 or nr_elemente < 0: raise ValueError for litera in sir_litere: if litera < 'a' or litera > 'z': raise ValueError if nr_elemente != len(sir_litere): raise ValueError print("Datele de intrare corespund restrictiilor impuse") # functie care verifica daca o anumita litera este vocala def vocala(litera): if litera in "aeiou": return True return False def vocalevector(sir_litere): sir_vocale = [] # impartim sirul in 2 siruri, unul cu vocale si unul cu consoane sir_consoane = [] # astfel se va pastra ordinea for litera in sir_litere: if vocala(litera): sir_vocale.append(litera) # daca e vocala adaugam litera in sirul de vocale else: sir_consoane.append(litera) # altfel, adaugam in sirul de consoane for litera in sir_vocale: # intai afisam vocalele print(litera, end=" ") for litera in sir_consoane: # apoi consoanele print(litera, end=" ") if __name__ == '__main__': try: # in cazul in care apare vreo eroare, aceasta se datoreaza datelor de intrare n = int(input("Introduceti numarul n: ")) # citirea lui n si a sirului sir = input("Introduceti sirul: ") sir = sir.split() # transformam sirul intr-o lista formata din literele separate printr-un spatiu validare(n, sir) # apelam functia de validare vocalevector(sir) # apelam functia de rezolvare # ne asteptam la 2 tipuri de erori cauzate de datele de intrare, le tratam corespunzator 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