Python Forum
Working with Dictionaries - logic seems backward...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with Dictionaries - logic seems backward...
#5
def compost(soil):
  if soil < 15:
    return soil + 10
  else:
    return soil + 5

def mulch(soil):
  new_soil = soil + 3
  if new_soil > 25:
    new_soil *= 1.2
  return round(new_soil)

def final_soil(soil):
    final = mulch(compost(soil))
    return round(final)

final = final_soil(20)

print("Final soil value:", final)
hmmm - this does not appear to work. I copied some code from a working python script in IDLE. Replied via this message. Clicked the python inserts. Pasted my code between them. Viewing it in Preview, it does not appear to have formatted correctly- everything is left justified, and no colours.
Reply


Messages In This Thread
RE: Working with Dictionaries - logic seems backward... - by DevelopingBoomer - Mar-12-2025, 04:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Backward Calculation QuentinL 0 1,985 Nov-15-2019, 01:58 PM
Last Post: QuentinL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020