User avatar
bensimmo
Posts: 4336
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: if x < y then x = y

Mon Feb 26, 2018 2:07 pm

Lots of methods, I would pass the variables current_windchill and new_windchill in to a function and retrun it, removing globals.

But then it depends on other code around it and if anything else is in the function

Code: Select all

wind_chill_max = 0  #setup at start of python for variables, unless you get positive/negative windchill/feels like ?

def check_windchill_max(wind_max, wind_new):
   return max(wind_max, wind_new)


wind_chill = from_ardunio_data
wind_chill_max = check_windchill_max( wind_chill_max, wind_chill )

print("Max ",wind_chill_max)

User avatar
bensimmo
Posts: 4336
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: if x < y then x = y

Mon Feb 26, 2018 2:17 pm

Dangermoth wrote:
Mon Feb 26, 2018 2:04 pm
Sorry I got called away,

It's still not working, I'm kind of thinking I should do the calculation and comparison on the Arduino as I do with the max / min temperature, this looks to be a lot more in depth using Python than I thought.

Post your code up.

Dangermoth
Posts: 70
Joined: Wed Oct 25, 2017 7:34 am
Location: Sheffield

Re: if x < y then x = y

Mon Feb 26, 2018 4:37 pm

Thanks for your help guys, I was kind of hoping this would only take a couple of minutes as per my little 'C' example above but Python can be a very tricky and frustrating beast when your not used to it.

I don't have a internet connected to the Pi at the moment so can't post the code.

Return to “Beginners”