abh - HTMLify profile
files of /abh/def/
# ABHDEF
This is a series of function which I started through my instagram account [@abh.py](https://www.instagram.com/abh.py) a
This is a series of function which I started through my instagram account [@abh.py](https://www.instagram.com/abh.py) a
def are_anagrams(s1, s2):
if len(s1) != len(s2):
return False
for c in s1:
if s1.count(c) != s2.count(c)
if len(s1) != len(s2):
return False
for c in s1:
if s1.count(c) != s2.count(c)
def average(*nums):
s = 0
c = 0
for n in nums:
s += n
c += 1
return s / c
s = 0
c = 0
for n in nums:
s += n
c += 1
return s / c
def char_frequency(string):
freq = {}
for c in string:
freq[c] = freq.get(c,0)+1
return freq
freq = {}
for c in string:
freq[c] = freq.get(c,0)+1
return freq
def digital_sum(n: int):
s = 0
while n:
s += n % 10
n //= 10
return s
def digital_sum(n: int):
s = 0
while n:
s += n % 10
n //= 10
return s
def digital_sum(n: int):
def divisors(n: int):
ds = []
for i in range(1, n+1):
if not n % i:
ds.append(i)
return ds
def
ds = []
for i in range(1, n+1):
if not n % i:
ds.append(i)
return ds
def
def encrypt_caesar_cipher(text, shift):
cipher = ""
for char in text:
if char.isalpha():
offset = 65
cipher = ""
for char in text:
if char.isalpha():
offset = 65
def encrypt_rot13(text):
cipher = ""
for char in text:
if char.isalpha():
offset = 65 if char.isuppe
cipher = ""
for char in text:
if char.isalpha():
offset = 65 if char.isuppe
def encrypt_xor_cipher(text, key):
cipher = ""
for char in text:
cipher += chr(ord(char) ^ key)
return ciphe
cipher = ""
for char in text:
cipher += chr(ord(char) ^ key)
return ciphe
#Calculate the factorial of given number
def factorial(n: int) -> int:
if n == 0:
return 1
return factorial(n-1
def factorial(n: int) -> int:
if n == 0:
return 1
return factorial(n-1
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd(a, b):
while b:
a, b = b, a % b
if b == 0:
return a
return gcd(b, a % b)
def gcd(a, b):
while b:
a, b = b, a % b
def is_armstrong(n: int):
n = str(n)
p = len(n)
s = 0
for d in n:
s += int(d)**p
return int(n) == s
n = str(n)
p = len(n)
s = 0
for d in n:
s += int(d)**p
return int(n) == s
def is_consonant(char):
consonants = [
"b", "c", "d", "f", "g", "h",
"j", "k", "l", "m", "n", "p",
"
consonants = [
"b", "c", "d", "f", "g", "h",
"j", "k", "l", "m", "n", "p",
"
def is_divisible_by(num, div):
return num % div != 0
def is_divisible_by(num, div):
return num / div == 0
return num % div != 0
def is_divisible_by(num, div):
return num / div == 0
def is_even(n: int) -> bool:
if n == 1:
return False
if n == 0:
return True
return is_even(n-2)
def
if n == 1:
return False
if n == 0:
return True
return is_even(n-2)
def
def is_happy(n: int):
n = str(n)
while len(n) != 1:
s = 0
for d in n:
s += int(d)*int(d)
n = str(n)
while len(n) != 1:
s = 0
for d in n:
s += int(d)*int(d)
def is_isogram(s):
s = s.lower()
for c in s:
if s.count(c) > 1:
return False
return True
def is
s = s.lower()
for c in s:
if s.count(c) > 1:
return False
return True
def is
def is_leap_year(year):
if not year % 100:
return not year % 400
return not year % 4
if not year % 100:
return not year % 400
return not year % 4
def is_odd(n: int) -> bool:
if n == 1:
return True
if n == 0:
return False
return is_odd(n-2)
def i
if n == 1:
return True
if n == 0:
return False
return is_odd(n-2)
def i
#Check the given string, number or list is palindrome or not.
def is_palindrome(n: int) -> bool:
r = 0
t = n
while
def is_palindrome(n: int) -> bool:
r = 0
t = n
while
def is_pangram(text):
letters = "abcdefghijklmnopqrstuvwxyz"
for char in text:
if not char.lower() in letters:
letters = "abcdefghijklmnopqrstuvwxyz"
for char in text:
if not char.lower() in letters:
def is_perfect_square(n):
sqrt = int(n ** 0.5)
return sqrt * sqrt == n
sqrt = int(n ** 0.5)
return sqrt * sqrt == n
def is_prime(n):
if n < 2:
return False
devisors = 0
for i in range(1, n+1):
if n % i == 0:
if n < 2:
return False
devisors = 0
for i in range(1, n+1):
if n % i == 0:
def is_valid_email(email):
parts = email.split("@")
if len(parts) == 2:
username, domain = parts
if user
parts = email.split("@")
if len(parts) == 2:
username, domain = parts
if user
def is_vowel(char):
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
return char in vowels
def is_vowel(char
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
return char in vowels
def is_vowel(char
def lcm(a: int, b: int) -> int:
max = a if a > b else b
while True:
if not (max % a and max % b):
re
max = a if a > b else b
while True:
if not (max % a and max % b):
re
def len(obj) -> int:
c = 0
while obj:
c += 1
obj = obj[1:]
return c
def len(obj) -> int:
c = 0
while obj:
c += 1
obj = obj[1:]
return c
def len(obj) -> int:
def lower(s: str) -> str:
u = "QWERTYUIOPASDFGHJKLZXCVBNM"
l = "qwertyuiopasdfghjklzxcvbnm"
for c in s:
if c
u = "QWERTYUIOPASDFGHJKLZXCVBNM"
l = "qwertyuiopasdfghjklzxcvbnm"
for c in s:
if c
def median(series):
s = series.copy()
s.sort()
n = len(s)
if n % 2 == 1:
return s[n // 2]
return (s[
s = series.copy()
s.sort()
n = len(s)
if n % 2 == 1:
return s[n // 2]
return (s[
def mode(numbers):
if not numbers:
return []
mode = []
max_count = 0
for num in numbers:
count =
if not numbers:
return []
mode = []
max_count = 0
for num in numbers:
count =
def ncr(n, r):
numerator = 1
denominator = 1
for i in range(r):
numerator *= n - i
denominator *= i
numerator = 1
denominator = 1
for i in range(r):
numerator *= n - i
denominator *= i
def npr(n, r):
return factorial(n) // factorial(n-r)
def npr(n, r):
result = 1
for i in range(r):
result *=
return factorial(n) // factorial(n-r)
def npr(n, r):
result = 1
for i in range(r):
result *=
def roman_to_int(s):
romans = {'I': 1,
'V': 5,'X': 10,
'L': 50, 'C': 100,
'D': 500, 'M': 1000}
result = 0
romans = {'I': 1,
'V': 5,'X': 10,
'L': 50, 'C': 100,
'D': 500, 'M': 1000}
result = 0
def sqrt(n):
return n ** 0.5
def sqrt(n):
return n ** (1/2)
def sqrt(n :int):
i = 0
return n ** 0.5
def sqrt(n):
return n ** (1/2)
def sqrt(n :int):
i = 0
def sum(*nums):
s = 0
for i in nums:
s += i
return s
def sum(*nums: int):
s = 0
s = 0
for i in nums:
s += i
return s
def sum(*nums: int):
s = 0
def triangle_number(n):
t = 0
for i in range(1, n+1):
t += i
return t
def triangle_number(n):
return su
t = 0
for i in range(1, n+1):
t += i
return t
def triangle_number(n):
return su
def upper(s: str) -> str:
u = "QWERTYUIOPASDFGHJKLZXCVBNM"
l = "qwertyuiopasdfghjklzxcvbnm"
for c in s:
if c
u = "QWERTYUIOPASDFGHJKLZXCVBNM"
l = "qwertyuiopasdfghjklzxcvbnm"
for c in s:
if c