SHAD UBC 2017 Programming Workshop: Lessons

Watch the videos for each lesson then do the exercises for that lesson.

Lesson 1: Variables & Printing

EXERCISE

In interactive mode:

  • Create a variable that stores your current age in years.
  • Print the variable to display your age.

Lesson 2: Data Types

EXERCISE

In interactive mode:

  • Create a variable that stores 3.5. Print it.
  • Create a variable that stores the word SHAD. Print it.
  • Create a variable that stores the boolean value True. Print it.
  • See what happens when you omit a quotation mark when trying to store text in a variable.
  • See what happens when you forget an equals sign when trying to store a value in a variable.
  • See what happens when you use the wrong case when trying to store the value False in a variable.

Lesson 3: Math Operations

EXERCISE

In interactive mode:

  • Create a variable that stores your current age, in years.
  • Create a second variable that calculates the first digit of your age. Print it.
  • Create a third variable that calculates the second digit of your age. Print it.

Lesson 4: Script Mode

EXERCISE

Create a script that calculates the first and second digit of your age (as you did in lesson 3 exercises).

Lesson 5: String Concatentation

EXERCISE

In interactive mode:

  • Create three variables that store your first name, middle name, and last name.
  • Print the three variables on the same line, with no space between the values.
  • Print the three variables on the same line, with a space between the values.

Lesson 6: User Input

EXERCISE

Create a script that asks the user for their name and then prints a message greeting the user by their name (for example, "Hello Fred!"). Make sure the greeting ends with an exclamation point.

Lesson 7: Type Conversion

EXERCISE

Create a script that asks the user for their name, age, and a number of years in the future and then prints a message telling the user how old they will be that number of years in the future (for example, "Hello Wilma! In 13 years you will be 39.").

Lesson 8: Conditional Execution

EXERCISE

Create a script that:

  • asks the user for their name, age, a number of years, and whether they want to know their age in the future or the past.
  • prints a message telling the user how old they will be that number of years in the future or past (for example, "Hello Wilma! In 13 years you will be 39." or "Hello Barney! 9 years ago you were 22.").

Make sure the script works correctly when the users ask for the future and the past.

Lesson 9: Repetition

EXERCISE

Create a script that asks the user for a positive number and then prints out a countdown from that number down to 1. At the end of the countdown, print out "Blast off!"

Lesson 10: Functions

EXERCISE

Create a script that asks the user for a positive number and then calls a function to print out "SHAD" the specified number of times.

Lesson 11: Modules

EXERCISE

Create a script that asks the user for a word and prints out Yes if the word is a Python keyword (such as if, else, elif, while, etc.) and No otherwise.
HINT: Find a module that does most of the work for you.

Lesson 12: Help out!

EXERCISE

Help your fellow SHADs without typing for them. Walk around the room and provide assistance to those that need it.