##### function help
 function help Posts: 3,208 Threads: 44 Joined: Jan 2018 Reputation: Nov-08-2020, 07:32 AM Extending on bowlofred's code, you could use an extensible dictionary of units expressed in the International System of Units and use it to convert from one unit to an other. ```_si = { 'hour': 3600, 'minute': 60, 'second': 1, 'millisecond': 1e-3, 'microsecond': 1e-6, } def as_si(unit, value=1): return _si[unit] * value def set_si(unit, value): _si[unit] = value set_si('day', 24 * as_si('hour')) set_si('year', 365.25 * as_si('day')) def conversion(value, from_unit, to_unit): return as_si(from_unit, value)/as_si(to_unit) if __name__ == '__main__': number = 3 u1 = 'hour' u2 = 'minute' ans = conversion(number, u1, u2) print(f'There are {ans} {u2} in {number} {u1}')``` Reply

 Messages In This Thread function help - by Nickd12 - Nov-06-2020, 09:39 PM RE: function help - by Gribouillis - Nov-06-2020, 09:56 PM RE: function help - by jefsummers - Nov-07-2020, 07:35 PM RE: function help - by Nickd12 - Nov-08-2020, 01:44 AM RE: function help - by bowlofred - Nov-08-2020, 04:23 AM RE: function help - by Gribouillis - Nov-08-2020, 07:32 AM

Forum Jump:

### User Panel Messages

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