show dbs
This file contains 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
num1 = 13 | |
num2 = 16 | |
# Tuple | |
print(("Odd", "Even")[num1 % 2 == 0]) | |
print(("Odd", "Even")[num2 % 2 == 0]) | |
# Dict | |
print({True: "Even", False: "Odd"}[num1 % 2 == 0]) | |
print({True: "Even", False: "Odd"}[num2 % 2 == 0]) |
This file contains 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 memory_profiler as mem_profile | |
import random | |
import time | |
names = ["John", "Corey", "Adam", "Steve", "Rick", "Thomas"] | |
majors = ["Math", "Engineering", "CompSci", "Arts", "Business"] | |
print(f"Memory (Before): {mem_profile.memory_usage()}Mb") | |
This file contains 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 functools import wraps | |
def my_logger(orig_func): | |
import logging | |
logging.basicConfig( | |
filename="{}.log".format(orig_func.__name__), level=logging.INFO | |
) | |
@wraps(orig_func) |