For this assignment we are to make a program that prompts the user for two temperature values between -20 and 50. The second one must be bigger than the first. Then two table looking things are to be formatted. The first one has all of the wind speed values from 5mph - 40 by 5s. The second table displays the values for the temperatures after the heat index is applied. If the fahrenheit temp is over 50 for wind chill, and "X" is displayed there. If the heat index temp is under 80, the same thing happens.
They look something like this
wind chill
celsius--- fahrenheit--- 5mph--- 10mph--- 15mph.....
12------------ 50------------ X------------ X------------ X
(Without the dashes of course)
Also some times for my wind chill index the numbers do something weird. If you put in the numbers 12 and 15, at number 13 you'll see what I mean. I'd also like to know whats happening there.
The main problem I'm having is with my second table. I am only attempting to print the first 3 columns, byt I'm getting
TypeError: 'int' object is not iterable
I'd like to know why cause I have no idea.
Thanks for reading all that
this is my main function:
They look something like this
wind chill
celsius--- fahrenheit--- 5mph--- 10mph--- 15mph.....
12------------ 50------------ X------------ X------------ X
(Without the dashes of course)
Also some times for my wind chill index the numbers do something weird. If you put in the numbers 12 and 15, at number 13 you'll see what I mean. I'd also like to know whats happening there.
The main problem I'm having is with my second table. I am only attempting to print the first 3 columns, byt I'm getting
TypeError: 'int' object is not iterable
I'd like to know why cause I have no idea.
Thanks for reading all that
this is my main function:
from functions import compute_wind_chill, compute_heat_index xy_list = [] fahr_list = [] if __name__ == '__main__': x, y = [int(x) for x in input("Enter two numbers here seperated by space: ").split()] x = int(x) y = int(y) y = y + 1 Twc_list5, Twc_list10, Twc_list15, Twc_list20, Twc_list25, Twc_list30, Twc_list35, Twc_list40 = compute_wind_chill(x, y) Hi_list40 = compute_heat_index(x, y) for i in range(x, y): xy_list.append(i) for i in xy_list: fahrx = (i * 1.8) + 32 fahr_list.append(fahrx) print("Wind Chill temperatures") print("Celsius", "%13s" % "Fahrenheit", "%8s" % "5mph" "%12s" % "10mph" "%12s" % "15mph" "%12s" % "20mph" "%12s" % "25mph" "%12s" % "30mph" "%12s" % "35mph" "%10s" % "40mph") zipped = zip(xy_list, fahr_list) for xy_list, fahr_list, Twc_list5, Twc_list10, Twc_list15, Twc_list20, Twc_list25, Twc_list30, Twc_list35, Twc_list40 in zip(xy_list, fahr_list, Twc_list5, Twc_list10, Twc_list15, Twc_list20, Twc_list25, Twc_list30, Twc_list35, Twc_list40): print(f'{xy_list}' "%17s" % f'{fahr_list}' "%14s" % f'{Twc_list5}' "%12s" % f'{Twc_list10}' "%12s" % f'{Twc_list15}' "%12s" % f'{Twc_list20}' "%12s" % f'{Twc_list25}' "%12s" % f'{Twc_list30}' "%12s" % f'{Twc_list35}' "%8s" % f'{Twc_list40}') for xy_list, fahr_list, Hi_list40 in zip(xy_list, fahr_list, Hi_list40): print(f'{xy_list}' "%17s" % f'{fahr_list}' "%14s" % f'{Hi_list40}')this file does all the math and I import this in my main function:
def compute_wind_chill(x, y): Twc_list5 = [] Twc_list10 = [] Twc_list15 = [] Twc_list20 = [] Twc_list25 = [] Twc_list30 = [] Twc_list35 = [] Twc_list40 = [] fahr_list = [] for i in range(x, y): fahr_val = (i * 1.8) + 32 fahr_list.append(fahr_val) for i in fahr_list: if i > 50: Twc_list5.append("X") else: Twc5 = 35.74 + (0.6215 * i) - (35.75 * (5 ** 0.16)) + (0.4275 * i * (5 ** 0.16)) Twc_list5.append("{:,.2f}".format(Twc5)) for i in fahr_list: if i > 50: Twc_list10.append("X") else: Twc10 = 35.74 + (0.6215 * i) - (35.75 * (10 ** 0.16)) + (0.4275 * i * (10 ** 0.16)) Twc_list10.append("{:,.2f}".format(Twc10)) for i in fahr_list: if i > 50: Twc_list15.append("X") else: Twc15 = 35.74 + (0.6215 * i) - (35.75 * (15 ** 0.16)) + (0.4275 * i * (15 ** 0.16)) Twc_list15.append("{:,.2f}".format(Twc15)) for i in fahr_list: if i > 50: Twc_list20.append("X") else: Twc20 = 35.74 + (0.6215 * i) - (35.75 * (20 ** 0.16)) + (0.4275 * i * (20 ** 0.16)) Twc_list20.append("{:,.2f}".format(Twc20)) for i in fahr_list: if i > 50: Twc_list25.append("X") else: Twc25 = 35.74 + (0.6215 * i) - (35.75 * (25 ** 0.16)) + (0.4275 * i * (25 ** 0.16)) Twc_list25.append("{:,.2f}".format(Twc25)) for i in fahr_list: if i > 50: Twc_list30.append("X") else: Twc30 = 35.74 + (0.6215 * i) - (35.75 * (30 ** 0.16)) + (0.4275 * i * (30 ** 0.16)) Twc_list30.append("{:,.2f}".format(Twc30)) for i in fahr_list: if i > 50: Twc_list35.append("X") else: Twc35 = 35.74 + (0.6215 * i) - (35.75 * (35 ** 0.16)) + (0.4275 * i * (35 ** 0.16)) Twc_list35.append("{:,.2f}".format(Twc35)) for i in fahr_list: if i > 50: Twc_list40.append("X") else: Twc40 = 35.74 + (0.6215 * i) - (35.75 * (40 ** 0.16)) + (0.4275 * i * (40 ** 0.16)) Twc_list40.append("{:,.2f}".format(Twc40)) return(Twc_list5, Twc_list10, Twc_list15, Twc_list20, Twc_list25, Twc_list30, Twc_list35, Twc_list40) def compute_heat_index(x, y): Hi_list40 = [] Hi_list50 = [] Hi_list60 = [] Hi_list70 = [] Hi_list80 = [] Hi_list90 = [] Hi_list100 = [] fahr_list = [] for i in range(x, y): fahr_val = (i * 1.8) + 32 fahr_list.append(fahr_val) for i in fahr_list: if i < 80: Hi_list40.append("X") else: Hi40 = -42.379 + (2.04901523 * i) + (10.14333127 * .4) + (-.22475541 * i * .4) + (-6.83783 * 10 ** -3 * (i ** 2)) + (-5.481717 * 10 ** -2 * (.4 ** 2)) + (1.22874 * 10 ** -3 * (i ** 2) * .4) + (8.5282 * 10 ** -4 * i * (.4 ** 2)) + (-1.99 * 10 ** -6 * (i ** 2) * (.4 ** 2)) Hi_list40.append(Hi40) return(Hi_list40)