Difference between revisions of "Module:Playground"
Jump to navigation
Jump to search
(Created page with "local p = {} local function toCelsius(f) return (f - 32) * 5 / 9 end local function toFahrenheit(c) return c * 9 / 5 + 32 end function p.functions() local tempe...") |
(No difference)
|
Latest revision as of 10:54, 6 March 2020
Documentation for this module may be created at Module:Playground/doc
local p = {}
local function toCelsius(f)
return (f - 32) * 5 / 9
end
local function toFahrenheit(c)
return c * 9 / 5 + 32
end
function p.functions()
local temperature
local result
result = ';Fahrenheit to Celsius\n'
for temperature = 0, 100, 10 do
result = result .. ':' .. temperature .. ' °F is ' .. string.format('%.1f', toCelsius(temperature)) .. ' °C\n'
end
result = result .. ';Celsius to Fahrenheit\n'
for temperature = 0, 100, 10 do
result = result .. ':' .. temperature .. ' °C is ' .. string.format('%.1f', toFahrenheit(temperature)) .. ' °F\n'
end
return result
end
return p