Week 20
Source Code
-- define main function
function main()
print("Main Function")
local done = false
local choice = nil
while not done do
print("Menu")
print("E1 - Example 1")
print("Q - Quit")
io.write("Choice: ")
choice = io.read()
if choice == "E1" then
-- call Example 1 Function
example1()
elseif choice == "E2" then
example2()
elseif choice == "E3" then
example3()
elseif choice == "E4" then
example4()
elseif choice == "E5" then
example5()
elseif choice == "Q" then
done = true
else
print("Invalid Choice")
end
end
end
-- define Example 1 Function
function example1()
-- double quotes
-- single quotes
-- \n is a newline
-- Lua multi-line string using double brackets
-- length
-- .upper()
-- .lower()
end
-- define Example 2 Function
function example2()
local major = "Computer Science"
print(major)
-- .sub()
-- .find()
-- loop and print every character
end
-- define Example 3 Function
function example3()
-- names list
-- ages list
-- print the names and corresponding ages
-- add a new name and age
-- print the last student's name and age
end
-- define Example 4 Function
function example4()
-- empty list of programming languages
-- add programming languages
-- the number of elements in the dictionary
-- call printDictionary function
-- delete a language
-- add a language
-- call printDictionary function (again)
end
-- define Example 5 Function
function example5()
local csTerms = {
["Algorithm"] = "A step-by-step procedure or formula for solving a problem or accomplishing a task.",
["API"] = "Application Programming Interface; a set of rules and protocols that allows different software applications to communicate with each other.",
["AI"] = "The simulation of human intelligence in machines that are programmed to think and learn like humans.",
["Binary"] = "A number system that uses only two digits, 0 and 1, which computers use to process and store data.",
["Blockchain"] = "A distributed, immutable ledger technology that records transactions across many computers to ensure data security and transparency.",
["Bug"] = "An error, flaw, or fault in a computer program that causes it to produce unexpected results or behave in unintended ways.",
["Debugging"] = "The process of finding and resolving defects or problems within a computer program.",
["Encryption"] = "The process of converting information or data into a code to prevent unauthorized access.",
["Firewall"] = "A network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules.",
["Machine Learning"] = "A subset of AI focused on building systems that learn from data rather than following explicit programming.",
["Network"] = "A collection of computers, servers, mainframes, or other devices connected to allow data sharing.",
["Open Source"] = "Software whose source code is available for modification or enhancement by anyone.",
["URL"] = "Uniform Resource Locator; the address of a resource on the Internet.",
["Wi-Fi"] = "A wireless networking technology that allows devices to interface with the Internet or communicate with one another without requiring a wired connection.",
["Zero-day"] = "A previously unknown software vulnerability that hackers can exploit before it is patched or mitigated."
}
-- access a particular element
-- update an element
-- access a particular element
-- check if key exists
-- call printDictionary
end
-- define dLength Function
-- define printDictionary Function
-- call main function
main()w20problem1.lua
w20problem2.lua
w20problem3.lua
w20problem4.lua
w20problem5.lua
w20problem6.lua
w20problem7.lua
w20problem8.lua
w20problem9.lua
project3.lua
Last updated
Was this helpful?