Skip to content

Instantly share code, notes, and snippets.

View Shogun89's full-sized avatar

Shogun89

  • New York, New York
View GitHub Profile
N = 50
a1 = 2
for i in range(2,N):
if (i % 2 ) == 0:
a1 = a1+3
print(','.join(map(str, [a1, i])))
else:
days = ['Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday','Saturday','Sunday']
food = []
gas = []
for d in days:
f = input("Please enter the amount spent on food on {day}:".format(day = d))
g = input("Please enter the amount spent on gas on {day}:".format(day = d))
food.append(f)
gas.append(g)
food = list(map(float, food))
days = ['Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday','Saturday','Sunday']
food_count = 0
gas_count = 0
for d in days:
f = input("Please enter the amount spent on food on {day}:".format(day = d))
g = input("Please enter the amount spent on gas on {day}:".format(day = d))
if (float(f) >= 20):
food_count += 1
if (float(g) >= 20):
gas_count += 1
% Here are some test values
a=1
b=2
c=3
d=4
% calling the trial function with the test values
result = trial_function(a,b,c,d)
% displaying the result, note that it is disp not print
def find_max(my_list):
my_set = set(my_list)
my_dict = {}
for item in my_set:
my_dict[item] = my_list.count(item)
my_max = max(my_dict.keys(), key=(lambda k: my_dict[k]))
return my_max
import numpy as np
A = np.array([[1,2],[4,3]])
x0 = np.array([[1],[0]])
def iterate(A,x):
rho = np.dot(A,x)
nk = np.max(np.absolute(rho))
xk = 1/nk* rho
@Shogun89
Shogun89 / body_fat.py
Last active September 12, 2019 01:29
Body_Fat
import pandas as pd
current_weight = 212
body_fat_percentage = .3
fat_pounds = current_weight* body_fat_percentage
def get_fat_percent(weight_lost, current_weight, fat_percentage):
new_fat = (current_weight*fat_percentage) - 2/3*weight_lost
def convert_km_to_miles(distance):
miles = distance/1.60934
return miles
min_distance = 54.6*10**6
max_distance = 401*10**6
avg_distance = 225*10**6
distances = [min_distance, max_distance, avg_distance]
from datetime import datetime
from datetime import timedelta
from datetime import date
today = date.today()
dif = timedelta(days=14)
add_time =today+dif
import pandas as pd
my_times = [[today, add_time]]
@Shogun89
Shogun89 / query_map.py
Created March 14, 2020 02:15
query_mapping
import pandas as pd
import os
import mysql.connector
def basic_data(data):
query= data[0]
cursor = data[1]
cursor.execute(query)
df = pd.DataFrame(cursor.fetchall(),columns=cursor.column_names)