58 lines
2.6 KiB
Python
Executable File
58 lines
2.6 KiB
Python
Executable File
## 1
|
|
a = 1
|
|
b = 2
|
|
c = -3
|
|
|
|
# a
|
|
# ((a<b) or (a>=c)) and (a==1)
|
|
# a is less than b, and a is greater than or equal to 3, so the or is true. a also equals 1, so the and is true. overall, this statement is true.
|
|
|
|
# b
|
|
# ((a != b) and (a <= c)) or (a <= c)
|
|
# a does not equal b, but a is not less than or equal to c, so the and is false.
|
|
# a is still not less than or equal to c, so the or is also false, making the statement as a whole false.
|
|
|
|
# c
|
|
# ((a == c) or (b > c)) and (-a*b < c)
|
|
# a does not equal c, but b is greater than c, so the or is true. -a*b=-2 which is greater than c, so the and is false, making the whole statement false.
|
|
|
|
# d
|
|
# (a <= 1) and ((b != c*a) or (b == a*b))
|
|
# a is less than or equal to 1. b does not equal c*a, but b does equal a*b, overall true
|
|
|
|
## 2
|
|
|
|
import numpy as np
|
|
|
|
data = np.zeros((4,3))
|
|
data = np.array([[7.6, 288.3, 278.4], [6.3, 278.6, 271.3], [5.2, 272.1, 265.3],[3.7, 250.3, 230.4]])
|
|
|
|
def atmo(x):
|
|
hpa = x[0:5,0]*133.322
|
|
dew = np.zeros((4))
|
|
dewdep = x[0:5,1]-x[0:5,2]
|
|
for i in range(len(dewdep)):
|
|
z = dewdep[i]
|
|
if z < 0:
|
|
raise ValueError('dewpoint depression negative, check temp and dewpoint values')
|
|
return hpa,dewdep
|
|
|
|
|
|
print(np.array(atmo(data)))
|
|
|
|
# row 0 is pascals conversion, row 1 is dewpoint depression
|
|
# note: the given conversion factor seems to be from mmHg to pascals, instead of hectopascals. maybe im wrong.
|
|
|
|
# 2(g)
|
|
# in order to account for 10 rows instead of 4, the only change needed would be to initialize an array 10 deep, and then actually populate it with the extra data.
|
|
# all operations within my function "atmo" are only dependent on start locations, so making the end of the array further away wouldnt matter.
|
|
# as for the for loop looking for negative dewdeps, that is iterative (slow i know) but can (and will) adapt to the length (depth) of the resulting array of dewdep values.
|
|
# ok no theres one more thing, I would also need to initialize a deeper array (10 instead of 4, this is inside of "atmo") for the dewdep values to be inserted into. theres probably a way to do this that gets the amount of rows in the actual data array, but i dont know how to do it yet.
|
|
|
|
# 2(h)
|
|
# the only real problem that could plague the data is it either being zero or negative, and one way of verifying the datas integrity would be to iterate through all of it in a for loop before (next line)
|
|
# doing any calculations with it, looking for values less than or equal to 0.
|
|
|
|
# BONUS
|
|
# I didnt actually study,(mb bro) I just reviewed the nonsensical syntax of numpy.zeros and how it needs two sets of parentheses. unthinkable.
|
|
# I use a 3440x1440 (21:9) monitor, sorry if alot of the text goes off screen |