Sei sulla pagina 1di 2

Ejercicio numero 8:

def front_times(x, y):


front_len = 3
if front_len > len(x):
front_len = len(x)
front = x[:front_len]
result = ""
for i in range(y):
result = result + front
return result
print(def front_times(chocolate,2)
print(def front_times(chocolate,3)
print(def front_times(abc,3)
Ejercicio numero 9:
def string_bits(j):
result = ""
for i in range(len(j)):
if i % 2 == 0:
result = result + str[i]
return result
print(string_bits('Hello'))
print(string_bits('Hi'))
print(string_bits('Heeololeo'))
Ejercico numero 10:
def string_match(a, b):
shorter = min(len(m), len(n))
count = 0
# Loop i over every substring starting spot.
# Use length-1 here, so can use char str[i+1] in the loop
for i in range(shorter-1):
m_sub = m[i:i+2]
n_sub = n[i:i+2]
if a_sub == n_sub:
count = count + 1
print(string_match('xxcaazz', 'xxbaaz'))
print(string_match('abc', 'abc'))

print(string_match('abc', 'axc'))
Ejercicio numero 11:
def sumas(a,b,c):
sum=0
if a==b and b==c:
sum=0
elif a!=b and b!=c and c!=a:
sum=a+b+c
elif a==b:
sum=c

#sign existe dos o

elif a==c:
sum=b
else:
sum=a
return sum

a=int(input("Ingrese primer : "))


b=int(input("Ingrese segundo : "))
c=int(input("Ingrese tercer : "))
print("Suma :",lone_sum(a,b,c))

mas var iguales

Potrebbero piacerti anche