2nd Semester Intro to Computer Science

What you will learn

Project

Using variables, functions, and conditionals in Python, students will create an Oregon Trail game.

Overview

We will be recreating Oregon Trail! The goal is to travel from Independence, Missori to Oregon City, Oregon (2000 miles) by Dec 31st. However, the trail is arduous. Each day costs you food and health. You can hunt and rest, but you have to get there before winter!

Details

Behavior

Implementation details

Bonus

  1. Make the rate of food consumption be a function of activity. So if a player hunts for a turn they take up more food, but if they rest they take up less food.
  2. Create a random event that occurs randomly once a month, like a river crossing or a dysentery, that will take up a range of 1-10 food, 1-10 days and 0-1 health.

Alternate Project

Created by Brian Weinfeld

Using variables, functions, and conditionals in Python, you will create a daily planner program.

Overview

In this project, you will be creating a daily planner program. A daily planner helps a user track what they need to do today and when they need to do it. This can be thought of as a TODO list that pairs each action with a time when the action is done. A planner can help make sure a person doesn’t accidentally book two things for the same time. Do you add events to your phone’s calendar?

Details

Behavior

Welcome to your Daily Planner
What would you like to do? (add, clear, display, exit) add
What event would you like to add? go to school
What time? 8
Is this event critical? no
Added go to school at 8
['', '', '', '']
['', '', '', '']
['go to school', '', '', '']
['', '', '', '']
['', '', '', '']
['', '', '', '']

What would you like to do? (add, clear, display, exit) add
What event would you like to add? wake up
What time? 6
Is this event critical? no
Added wake up at 6
['', '', '', '']
['', '', 'wake up', '']
['go to school', '', '', '']
['', '', '', '']
['', '', '', '']
['', '', '', '']

What would you like to do? (add, clear, display, exit) add
What event would you like to add? do homework
What time? 6
Is this event critical? no
Conflict with wake up

What would you like to do? (add, clear, display, exit) display
['', '', '', '']
['', '', 'wake up', '']
['go to school', '', '', '']
['', '', '', '']
['', '', '', '']
['', '', '', '']

What would you like to do? (add, clear, display, exit) add
What event would you like to add? eat breakfast
What time? 6
Is this event critical? yes
Replacing wake up at 6 with eat breakfast
['', '', '', '']
['', '', 'eat breakfast', '']
['go to school', '', '', '']
['', '', '', '']
['', '', '', '']
['', '', '', '']

What would you like to do? (add, clear, display, exit) clear
What time to start clearing? 5
What time to end clearing? 7
Clearing ['', 'eat breakfast']
['', '', '', '']
['', '', '', '']
['go to school', '', '', '']
['', '', '', '']
['', '', '', '']
['', '', '', '']

What would you like to do? (add, clear, display, exit) exit
Goodbye

Implementation Details

The planner is a list that has 24 empty strings in it. (The empty string is ‘’). Each of the 24 indexes represents 1 hour of time in a day. For example, index 0 represents 12:00AM to 12:59AM, index 1 represents 01:00AM to 01:59AM and index 23 represents 11:00PM to 11:59PM. Your program will allow a user to add events at certain times of the day and prevent conflicts from occurring. All of the events will take exactly 1 hour.

Think back to the previous project where you created a TODO list program. All of the code in that program was put into a single script. This is OK when the program is small, but it gets harder and harder to code as the project gets bigger. Did you find the end of that project to be more challenging than the beginning? You can help mitigate this problem by creating functions to handle large amounts of work.

Begin this project by creating your 24 length list of empty strings and the following three functions. Do your best to ensure that these functions work properly before moving onto the rest of the project.

def add_event(planner, event, time, critical):
  # finish function
def display_planner(planner):
  # finish function
def clear_timeframe(planner, timeframe):
  # finish function

Challenge

This section contains additional components you can add to the project. These should only be attempted after the project has been completed.

Super Challenge

The super challenge will require knowledge that has not been taught yet. You will need to do additional research on your own. Good luck!

Sometimes the time the event is scheduled for is less important than making sure the event is on the schedule. Add a parameter to the functions that add an element to the schedule called force. If force is true, the event must be scheduled. If it can’t be scheduled at the expected time, find the closest available timeslot in the future and schedule it there instead. If the event is critical, then the displaced event should be moved forward. Be sure to alert the user that the event has been scheduled, but at a different time than expected! The placement will still fail if there are no available timeslots to place the event.

Rubric

Student Name: __________ Date: _________

Student correctly identifies data types (2.01)

3 2 1 0 Points
Student correctly identifies all data types Student correctly identifies most data types Student identifies a few data types No evidence that the student can correctly identify data types  
      Sub Total  

Student correctly uses lists (2.04, 2.05)

3 2 1 0 Points
Student programs uses lists of multiple types Student program uses lists of one type __ No evidence that they student can create a list using multiple types  
      Sub Total  

Student correctly uses built in functions (3.01)

3 2 1 0 points
Student correctly uses a built in function that returns a value Student uses a built in function, but only prints that value Student uses build in functions incorrectly No evidence the student can use built in functions  
      Sub Total  

Student can program using user-defined functions (3.02, 3.03, 3.04)

3 2 1 0 points
Student created at least four user designed functions with the correct syntax uses created 3 user-defined functions with the correct syntax Student creates one or two user- defined functions with correct syntax No evidence the student can program user-defined functions  
Student’s user-defined functions always decrease the complexity of the code Student’s user-defined functions usually decrease the complexity of the code Student’s user-defined functions rarely reduce complexity No evidence the student can create user-defined functions to decrease complexity  
Student always uses a returned value correctly Student usually uses a returned value correctly Student sometimes uses a returned value correctly No evidence the student understands how to use the a returned value  
Student always scopes their variables correctly Student usually scopes their variables correctly Student sometimes scopes their variables correctly No evidence the student understands how to scope their variables  
      Sub Total  

Student can decompose a problem to create a program from a brief

3 2 1 0 Points
Student program runs without error The students program has a few errors, but it does not impact the program’s functionality Student program has errors that impact the program’s functionality Student program is not functional  
__ Students submitted documentation showing planning for most variables and functions. Students submitted documentation showing planning for a few variables and functions. No evidence of planning  
      Sub Total  

Student uses naming/ syntax conventions and comments to increase readability

2 1 0 Points
Syntax conventions are generally used Sometimes syntax conventions are used No evidence of syntax conventions to aid in code readability  
All variables have clear names Some variables have clear names No evidence of using variable names to aid in code read ability  
__ Student comments aid code readability No evidence of using comments to aid in code readability.  
    Sub Total  

Final Grade

Points Possible Points Earned x Weight Total Points
31 __ X ___  

Check your understanding

Pick an answer for each question. You can try again until you get it right.

1. Why is it helpful to split a longer program into functions?

  • Python requires it
  • It makes the program run faster
  • Each function does one job, so the code is easier to read, test, and reuse
  • It removes the need for variables

Functions organize code and decrease its complexity.

2. Why plan out your variables and functions before writing code?

  • It helps you decompose the problem and catch design problems early
  • It makes comments unnecessary
  • It is only needed for programs under 10 lines
  • It guarantees there will be no bugs

Planning helps you break a larger problem into smaller pieces before coding.

3. A function’s contract says Returns: none. What does that tell you?

  • It returns a number
  • It returns the string none
  • It cannot use any arguments
  • It does not give back a value; it only does something such as printing or updating data

A function that returns none is used for its effects, not for a result.

Downloads