Skip to content

Instantly share code, notes, and snippets.

@theishiopian
Created November 13, 2019 06:20
Show Gist options
  • Save theishiopian/4c04617967f72956f1e130d53fe55ee9 to your computer and use it in GitHub Desktop.
Save theishiopian/4c04617967f72956f1e130d53fe55ee9 to your computer and use it in GitHub Desktop.
'''
Created on Oct 17, 2019
@author: Andrew
'''
#draw function, x and y are lists of numbers for the x and y axes, respectively
def draw_graph(x,y):
#import plotting library
from bokeh.plotting import figure, output_file, show
#create output file
output_file("line.html")
#create graph
p = figure(plot_width=400, plot_height=400)
# add a line with the datapoints
p.line(x,y, line_width=2)
#label axes
p.xaxis.axis_label = 'Time (Days)'
p.yaxis.axis_label = 'Temperature (Reamur)'
#render graph to html file
show(p)
#input storage
input_array = []
#get enum library
from enum import Enum
#days of the week, enumerated in an enum
class Day(Enum):
MONDAY = 1
TUESDAY = 2
WEDNSDAY = 3
THURSDAY = 4
FRIDAY = 5
SATURDAY = 6
SUNDAY = 7
#get input from user
for i in range(1,8):
input_array.insert(i, input("enter temp for " +Day(i).name))
#debug print
for i in input_array:
print(i)
#minimum temp
mintemp = min(input_array)
mintempindex = input_array.index(min(input_array))
print('The coldest day was ' + str(Day(mintempindex+1).name) + ', with a temperature of ' + str(mintemp))
#maximum temp
maxtemp = max(input_array)
maxtempindex = input_array.index(max(input_array))
print('The hottest day was ' + str(Day(maxtempindex+1).name) + ', with a temperature of ' + str(maxtemp))
#average temp
from statistics import mean
print("The average temperature was "+str(round(mean(list(map(float, input_array))),1)))
l = list(range(1,8))
draw_graph(l, input_array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment