Any ATS python coders? Need help with my code. Thanks, page 1


Pages:
ATS Members have flagged this thread 0 times
Topic started on 11-10-2012 @ 10:28 AM by Manhater
Trying to figure out how to get the maximum and minimum values of the random numbers that are displayed when the user inputs their numbers. I have everything done, I just can't figure out my last two. ** means where I'm having my problem. Where I'm stuck at. When the user chooses the four numbers the program should be able to try to find the lowest and highest values after the conversion. Been working on it all night and I'm pretty much stuck right here.

Thanks for the help.

def convertFahtoCel(x):
return( x - 32 ) * 5 / 9

def convertCeltoFah(x):
return( x + 32 ) * 9 / 5

def colorcode(x):
if x >= 110:
print("Red")
elif x >=90:
print("Orange")
elif x >= 32:
print("Yellow")
else:
print("Blue")
** def low(x):
fah1, fah2, fah3, fah4

** def high(x):
fah1, fah2, fah3, fah4


def main():
fah1, fah2, fah3, fah4 = eval(input("Enter 4 tempertures in degrees Fahrenheit seperated by a comma: "))

#Start of Fahreheit to Celcius variable table

print("Farenheit ", end="t")
print("Celsius ", end="t")
print("Color Code")
print("_____________________________________________")
print(fah1, end="tt")
print(format(convertFahtoCel(fah1), "0.1f"), end="tt")
colorcode(fah1)

print(fah2, end="tt")
print(format(convertFahtoCel(fah2), "0.1f"), end="tt")
colorcode(fah2)

print(fah3, end="tt")
print(format(convertFahtoCel(fah3), "0.1f"), end="tt")
colorcode(fah3)

print(fah4, end="tt")
print(format(convertFahtoCel(fah4), "0.1f"), end="tt")
colorcode(fah4)
print("______________________________________________")

#End Table
#Start of second table
print()
print("Low/High ", end="t")
print(" Fahreheit ", end="t")
print(" Celsius ", end="t")
print("Color Code")
print("______________________________________________")
print("Low", end="t")
print(low, end="tt")
** print(format(convertFahtoCel(low), "0.1f"), end="tt")
** print(format(convertCeltoFah(low), "0.1f"), end="tt")
colorcode(low)

print("High", end="t")
print(high, end="tt")
** print(format(convertFahtoCel(high), "0.1f"), end="tt")
** print(format(convertCeltoFah(high), "0.1f"), end="tt")
colorcode(high)

main()

edit on 11-10-2012 by Manhater because: (no reason given)
edit on 11-10-2012 by Manhater because: (no reason given)



reply posted on 11-10-2012 @ 10:40 AM by melek76
Hello,

I am not well versed in python, but I will attempt at giving a solution.

First create a list of the entered arguments (i.e. fah1, fah2, fah3, fah4)

temps = [fah1,fah2,fah3,fah4]

effbot.org...
docs.python.org...

Then use these built in functions of python to capture the max and min of the list.

where x is the list created of the capture temperatures

def high(x)
return max(x)

def low(x)
return min(x)

docs.python.org...
docs.python.org...

Melek76


reply posted on 11-10-2012 @ 10:55 AM by jhn7537
reply to post by Manhater



If someone said, "John, I'll pay for $10 Billion if you can explain this to me" I would be SOL.....

Pages:     ^^TOP^^



How to browse the Internet safely like an IT pro!
  Posted 16 days ago with 38 member flags
Problems with software restriction Policies in windows 7
  Posted 19 days ago with 2 member flags
Need I Ask?: How can the "ask" toolbar be removed manually.
  Posted 1 days ago with 2 member flags
JAVA Update #35 Causing Browser Slowdown/Crashes?
  Posted 9 days ago with 1 member flags
Any Beginner Python Sites available?
  Posted 1 days ago with 1 member flags
Laptop charger wont charge.
  Posted 16 days ago with 0 member flags
Problem with youtube?
  Posted 19 days ago with 0 member flags