# SHAD UBC 2015 Programming Workshop: Lessons

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

When doing the exercises on MacOS, type python3 instead of python.

## Lesson 1 Exercise

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

## Lesson 2 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.

## Lesson 3 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 Exercise

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

## Lesson 5 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 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 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 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 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 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 Exercise

• Exercise 11: 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 Exercise

Help your fellow SHADs without typing for them. Act like a PA, walk around the room, and provide assistance to those that need it.