Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


Solució exercicis per python, Ejercicios de Informática

Primers noms, suma equilibrada i vowel cover solucionars

Tipo: Ejercicios

2022/2023

Subido el 13/12/2023

anna-anguera
anna-anguera 🇪🇸

2 documentos

1 / 3

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
def is_vowel_covered(s):
  '''
  >>> is_vowel_covered("AaaaA")
  True
  >>> is_vowel_covered("AaaA")
  False
  >>> is_vowel_covered("AeioUAeioU")
  True
  >>> is_vowel_covered("aAppAlAa")
  False
  >>> is_vowel_covered("AaaaaazZ")
  False
  '''
  if len(s) <= 4:
    return False
 
  if s[0].isupper () and s[-1].isupper:
    if s[1].islower and s[-2].islower:
      if s[0] == 'aeiouAEIOU' and s[-1] == 'aeiouAEIOU' and
s[2] == 'aeiouAEIOU' and s[-2] == 'aeiouAEIOU':
        return True
       
if __name__ == '__main__':
  import doctest
  print(doctest.testmod())
pf3

Vista previa parcial del texto

¡Descarga Solució exercicis per python y más Ejercicios en PDF de Informática solo en Docsity!

def is_vowel_covered(s): '''

is_vowel_covered("AaaaA") True is_vowel_covered("AaaA") False is_vowel_covered("AeioUAeioU") True is_vowel_covered("aAppAlAa") False is_vowel_covered("AaaaaazZ") False ''' if len(s) <= 4 : return False if s[ 0 ].isupper () and s[- 1 ].isupper: if s[ 1 ].islower and s[- 2 ].islower: if s[ 0 ] == 'aeiouAEIOU' and s[- 1 ] == 'aeiouAEIOU' and s[ 2 ] == 'aeiouAEIOU' and s[- 2 ] == 'aeiouAEIOU': return True if name == 'main': import doctest print(doctest.testmod())

def suma_equilibrada(f): '''

suma_equilibrada([1, 1, 1, 1]) 1 suma_equilibrada([10, 10, 7, 3, 30]) 3 suma_equilibrada([10, 20])

suma_equilibrada([-3, 5, -2]) 2 suma_equilibrada([0]) 0 suma_equilibrada([])

''' suma_total = sum(f) suma_parcial = 0 for index in range(len(f)): suma_parcial += f[index] if suma_parcial == suma_total - suma_parcial: return index return - 1 if name == 'main': import doctest doctest.testmod(verbose=True)