pastebin - collaborative debugging tool RSS

Map Function
Posted by Anonymous on Tue 18th Feb 2020 17:29
raw | new post

  1. #Using Map function to convert F to C
  2. def map(value, fromLow, fromHigh, toLow, toHigh):
  3.     fromRange = fromHigh - fromLow
  4.     toRange = toHigh - toLow
  5.     scaleFactor = toRange / fromRange
  6.     tmpValue = value - fromLow
  7.     tmpValue *= scaleFactor
  8.     return tmpValue + toLow
  10. for tempF in range(-100,220,2):
  11.     tempC=map(tempF,32,212,0,100)
  12.     print(F"F={tempF} tempC={tempC}")

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}

All content is user-submitted.
The administrators of this site ( are not responsible for their content.
Abuse reports should be emailed to us at