Skip to content

Instantly share code, notes, and snippets.

View sonaalPradeep's full-sized avatar
🎯
Focusing

Sonaal Pathlai Pradeep sonaalPradeep

🎯
Focusing
View GitHub Profile
@sonaalPradeep
sonaalPradeep / classes_with_dunder_demo.py
Last active June 2, 2021 06:26
A simple python program to demonstrate creating a class and a few common dunder (double-underscore) functions that could be useful. The program was tested and worked on Google Colab.
class Temperature:
def __init__(self, reading = "0.0X"):
"""
Input : reading (string) : Takes the temperature reading entered by the user. The user needs to enter a temperature in either Celcius (C)
or Fahrenheit (F). There be no gap or degree symbol between the numeric value and the temperature unit.
"""
try:
self.unit = reading[-1].upper()
self.temp = float(reading[:-1])
self.is_valid = True
@sonaalPradeep
sonaalPradeep / han_w_modification.py
Last active September 18, 2020 12:47
Program for textual binary classification
import pandas as pd
import numpy as np
from tensorflow.keras.preprocessing.text import Tokenizer
# from tensorflow.keras.engine.topology import Layer
from tensorflow.keras import initializers as initializers, regularizers, constraints
from tensorflow.keras.callbacks import Callback, EarlyStopping
from tensorflow.keras.layers import Embedding, Input, Dense, LSTM, GRU, Bidirectional, TimeDistributed, concatenate, Add, Layer
from tensorflow.keras import backend as K
from tensorflow.keras.models import Model
@sonaalPradeep
sonaalPradeep / generate_time_plot.py
Last active July 8, 2020 05:14
Bogosort to retrieve running times and plot
import argparse
import random
import time
import pandas as pd
import seaborn as sns
sns.set(style = "whitegrid")
def generate_initial(num_of_elements):
'''
Generate a shuffled array of a given length
@sonaalPradeep
sonaalPradeep / bogoSort.py
Last active June 30, 2020 07:09
Python Program for Bogosort
import random
import time
def generate_initial(num_of_elements):
'''
Generate a shuffled array of a given length
'''
array = list(range(num_of_elements))
random.shuffle(array)
return array
print(colored('Twinkle Twinkle Little Star', 'yellow', 'on_blue', attrs=['blink', 'bold']))
cprint("A WILD WARNING HAS APPEARED", "yellow", "on_red")
print(Fore.YELLOW + Back.RED + "A WILD WARNING HAS APPEARED")
print(colored('Hello', 'red'), colored(' World', 'green'))
print(Fore.RED + "Hello" + Fore.GREEN + " World")
from termcolor import colored, cprint # For Termcolor
from colorama import init, Fore, Back
init(autoreset = True) # For colorama
print(f"{bcolors.WARNING}Warning: No active frommets remain. Continue?{bcolors.ENDC}")
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'