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
N = 50 | |
a1 = 2 | |
for i in range(2,N): | |
if (i % 2 ) == 0: | |
a1 = a1+3 | |
print(','.join(map(str, [a1, i]))) | |
else: |
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
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)) |
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
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 |
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
% 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 |
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
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 |
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 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 | |
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 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 |
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
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] |
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 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]] |
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 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) |
OlderNewer