Module:Sandbox/DM224b explained

--Gammaburst_3000 Google Code-in 2017, Introduction to Lua in Wikipedia.--[Lua task #03] Create your own Lua module on English Wikipedia: Google code-inlocal p = -- p stands for package

function p.hello(frame) return "Hello, world!"end

--[Lua task #4] GCIp.Hi = function(frame) strName = frame.args.name or "Jimbo" return "Hello from Lua to my friend " .. strName .. ".
"end--[Lua task #5 and #6] GCI

function p.temperature(frame) cel = frame.args.celsius or 0 fah=(cel*9/5)+32 msg = cel .. " degree celsius is "..fah.." degrees fahrenheit.
" if tonumber(cel)>9 then msg = msg .. " It is warm." else msg = msg .. " It is cold." end return msg end--[Lua task #7] GCI

p.times = function(frame) local num = tonumber(frame.args.num) or 2 local out = "" .. num .. " times table
" .. "
" for i = 1, 10 do out = out .. i * num .. "
" end return outend --edit1p.times1 = function(frame) local num = tonumber(frame.args.num) or 2 local out = "" .. num .. " times table
" .. "
" for i = 1, 10 do out = out .. num .. " times " .. i .. " is " .. i * num .. "
" end return outend --edit2p.times2 = function(frame) local num = tonumber(frame.args.num) or 2 local out = "" .. num .. " times table
" .. "
" for i = 1, 12 do out = out .. num .. " times " .. i .. " is " .. i * num .. "
" end return outend

----[Lua Task #8] GCI--

p.mum = function(frame) local family = local msg = "" msg = msg .. "Hello " .. family[2] .. "
" return msgend

--edit1: change to first memberp.mum1 = function(frame) local family = local msg = "" msg = msg .. "Hello " .. family[1] .. "
" return msgend

--edit2: loop 5 timesp.mum2 = function(frame) local family = local msg = "" for i=1, 5 do msg = msg .. "Hello " .. family[i] .. "
" end return msgend

--edit3: add two membersp.mum3 = function(frame) local family = family[6]="James" family[7]="Tabby" local msg = "" for i=1, 5 do msg = msg .. "Hello " .. family[i] .. "
" end return msgend

--edit4: change loop count to size of tablep.mum4 = function(frame) local family = local msg = "" for i=1, #family do msg = msg .. "Hello " .. family[i] .. "
" end return msgend

--edit5: add another member to the tablep.mum5 = function(frame) local family = family[8]="Brienne" local msg = "" for i=1, #family do msg = msg .. "Hello " .. family[i] .. "
" end return msgend

return p