This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In: 12345678.90 (Float) | |
# Out: 12,345,678.90 (String) | |
number = float(12345678.90) | |
n_digits = str(number).find('.') | |
z_groups = int(n_digits/3) | |
k_digits = n_digits % 3 | |
group_separator = ',' | |
print(f'Number: {number}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def decode_unixtime(utime): | |
utime = int(str(utime)[:10]) | |
res = datetime.fromtimestamp(utime) | |
return res.strftime('%a %Y-%m-%d %H:%M:%S') | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date | |
def format_date(plain_date): | |
sep_date = plain_date.split('/') | |
# Convert string numbers into int variables | |
# sep_date = [int(item) for item in sep_date] | |
sep_date = list(map(int, sep_date)) | |
# plain date is DD/MM/YYYY, so ... | |
day, month, year = sep_date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
image_path = 'IMG_01.jpg' | |
with open(image_path, 'rb') as image: | |
result = base64.b64encode(image.read()).decode('utf-8') | |
print(result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def paypal_fee() -> None: | |
""" | |
Paypal Fee Calculator | |
""" | |
FEE_RATE: float = 0.054 | |
TRANSACTION_CHARGE: float = 0.3 | |
print("Let's calculate a paypal transaction fee.") | |
amount = float(input("Amount ($): ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_vzla_date() -> str: | |
""" | |
Get Venezuela time in format DD/MM/YYYY. | |
:return: String with the date. | |
""" | |
dt = datetime.now(pytz.timezone("America/Caracas")) | |
day = dt.day if dt.day > 9 else f"0{dt.day}" | |
month = dt.month if dt.month > 9 else f"0{dt.month}" | |
return f"{day}/{month}/{dt.year}" |