Module 1 Lab Exercise

Learning Outcomes

Practice with the Command Line

print("Hello World")
$ python3 hello.py
# NOTE: You must specify the *path* to your program file

Practice with Python’s Interactive Mode

$ python3
Python 3.7.0 (default, Jul 23 2018, 20:22:55) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
s = "Open the pod bay doors, Hal"

# check the type of the variable s
type(s)

# see a list of string methods
dir(s)

# see built-in help on string objects
help(str) 

Challenges

  1. Write a program that takes a two-character string representing the day of the week (mo, tu, we, th, fr, sa, su) as input and uses a conditional to output “Happy [day of week]!”:
enter day: mo
Happy Monday!
  1. Write a “banner printing” program that takes a string as input and outputs the string in uppercase, surrounded by a box made of stars. When run the output should look like this:
Enter text for banner: It's full of stars
**********************
* IT'S FULL OF STARS *
**********************