Skip to content

Instantly share code, notes, and snippets.

View chinbrow's full-sized avatar

Luis Gonzalez chinbrow

View GitHub Profile
def correcto(string):
result = ""
for i in string:
if i == " ":
if result[-1:] != " ":
result += i
elif result[-1:] == ".":
if i == " ":
result += i
else:
key = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(n, plaintext):
result = ''
for l in plaintext.lower():
try:
i = (key.index(l) + n) % 26
result += key[i]
except ValueError:
result += l
return result.lower()
def gcd(a, b):
while b:
a, b = b, a%b
return a
string1 = int(input("Give me a number for the gratest common denominator: "))
string2 = int(input("Give me the second for the gratest common denominator: "))
y = gcd(string1, string2)
print(y)
def banana_string(n):
return n.lower().count("banana")
string = input("Give me a string? ")
y = banana_string(string)
print(y)
def square_test(n):
summ = 0
add = 0
for i in n:
summ = i**2
add += summ
return add
a_list = []
num_nums = int(input("How many numbers? "))
def smallest_of(nummerals):
smallest = nummerals[0]
for i in nummerals:
if i < smallest:
smallest = i
return smallest
a_list = []
def mean(liston):
a = 0
b = 0
for i in liston:
a += i
b += 1
return a/b
a_list = []
def facto(a):
if a == 0:
return 1
else:
return a * facto(a-1)
a=int(input("Dame el numero para factorializar: "))
c = facto(a)
print(c)
def triangulo(a):
b = 0
while b != a:
b += 1
print ("T"*b)
while b != 0:
b -= 1
print("T"*b)
a=int(input("Dame el tamaño del triangulo: "))
def char_freq(string):
import collections
letters = collections.Counter(string)
return letters
string = input("GIVE ME THE STRING: ")
y = char_freq(string)
print(y)