✒️
Computer Science Principles
  • Introduction
  • Overview
  • Course at a Glance
  • Course Exam Description
  • Create Performance Task
  • Reference Sheet
  • Resources
  • Big Idea 1
    • 1.1 Collaboration
    • 1.2 Program Function and Purpose
    • 1.3 Program Design and Development
    • 1.4 Identifying and Correcting Errors
  • Big Idea 2
    • 2.1 Binary Numbers
    • 2.2 Data Compression
    • 2.3 Extracting Information from Data
    • 2.4 Using Programs with Data
  • Big Idea 3
    • 3.1 Variables and Assignments
    • 3.2 Data Abstraction
    • 3.3 Mathematical Expressions
    • 3.4 Strings
    • 3.5 Boolean Expression
    • 3.6 Conditionals
    • 3.7 Nested Conditionals
    • 3.8 Iteration
    • 3.9 Developing Algorithms
    • 3.10 Lists
    • 3.11 Binary Search
    • 3.12 Calling Procedures
    • 3.13 Developing Procedures
    • 3.14 Libraries
    • 3.15 Random Values
    • 3.16 Simulations
    • 3.17 Algorithmic Efficiency
    • 3.18 Undecidable Problems
  • Big Idea 4
    • 4.1 The Internet
    • 4.2 Fault Tolerant
    • 4.3 Parallel and Distributed Computing
  • Big Idea 5
    • 5.1 Beneficial and Harmful Effects
    • 5.2 Digital Divide
    • 5.3 Computing Bias
    • 5.4 Crowdsourcing
    • 5.5 Legal and Ethical Concerns
    • 5.6 Safe Computing
  • Code
    • Week 10
    • Week 11
    • Week 12
    • Week 13
    • Week 14
    • Week 15
    • Week 16
    • Week 17
    • Week 18
    • Week 19
    • Week 20
    • Week 21
    • Week 22
Powered by GitBook
On this page
  • Source Code
  • w13problem1.lua
  • w13problem2.lua
  • w13problem3.lua
  • w13problem4.lua
  • w13problem5.lua
  • w13problem6.lua
  • w13problem7.lua
  • w13problem8.lua
  • w13problem9.lua
  • project1.lua

Was this helpful?

Export as PDF
  1. Code

Week 13

Source Code

local myName = ""
print("Name: " .. myName)

-- Example 1


-- Example 2 and 3 inputs


-- Example 2


-- Example 3


-- Example 4


-- Example 5


-- Example 6


-- Example 7


-- Example 8


-- Example 9


-- Example 10

w13problem1.lua

print("Problem 1")

w13problem2.lua

print("Problem 2")

w13problem3.lua

print("Problem 3")

w13problem4.lua

print("Problem 4")

w13problem5.lua

print("Problem 5")

w13problem6.lua

print("Problem 6")

w13problem7.lua

print("Problem 7")

w13problem8.lua

print("Problem 8")

w13problem9.lua

print("Problem 9")

project1.lua

print("Name: ") -- add your name here
print("Project 1")
print("Title: Jungle Run")
local health = 80 -- initial health (physical or mental?)

print("Your plane has crashed and when you exit, you find yourself in a humid jungle,")
print("unsure if there are other people around.")
print()
print("Do you re-enter the plane or seek shelter elsewhere?")
print("1 - re-enter")
print("2 - seek shelter")
io.write("> ")
local choice=io.read("*n")
io.read() -- consuming new line
if choice == 1 then
    print("you chose to re-enter")
    health = health + 5
    print("Current Health: " .. health)
elseif choice == 2 then
    print("you chose to seek shelter")
    health = health + 10
    print("Current Health: " .. health)
else
    print("invalid choice")
end
PreviousWeek 12NextWeek 14

Last updated 4 months ago

Was this helpful?