CS21 Lab 1: First programs

Due Saturday, February 2, before midnight

Make sure all programs are saved to your cs21/labs/01 directory! Files outside that directory will not be graded.

$ update21
$ cd ~/cs21/labs/01/
$ pwd
$ ls

Programming Tips

As you write your first programs, start using good programming practices now:

1. Movie Pitch Generator

You are in charge of pitching the next movie blockbuster for a big hollywood studio. Your movie pitch needs to be fast and attention grabbing. In movie.py, write a program that will ask for four pieces of information: the title of your new movie, a movie it is like, a second movie your movie is similar to, and a plot twist that makes your movie special. Your program should then use this information to generate a short pitch for the movie you want to make (i.e. a movie madlib).

Here are two examples (user input in bold):

$ python3 movie.py
Movie Title: Cats on a Plane!
Movie it is like: Snakes on a Plane!
Second movie: La La Land
Plot Twist: singing cats

Our movie is called: Cats on a Plane!
It's like Snakes on a Plane! meets La La Land,
but with singing cats!!!

$ python3 movie.py
Movie Title: Saving Will Hunting
Movie it is like: Saving Private Ryan
Second movie: Good Will Hunting
Plot Twist: more Matt Damon

Our movie is called: Saving Will Hunting
It's like Saving Private Ryan meets Good Will Hunting,
but with more Matt Damon!!!

Note: you can use print() with no arguments to print a blank line.

2. Currency Converter

When traveling overseas, it is easy to exchange currency at the airport, but this comes at a price. Many airport foreign exchange kiosks charge both a fixed fee, as well as a percentage of the amount exchanged.

In currency.py, write a simple program that asks the user for an amount of dollars to be exchanged, and outputs how many euros (1 Dollar == 0.87 euros), Mexican pesos (1 dollar == 19.22 pesos), or Chinese yuan (1 dollar = 6.82 yuan) can be purchased with these dollars.

Assume the foreign exchange kiosk charges $10 per transaction, plus 5% of the amount being exchanged. Don't worry if you end up "purchasing" a negative amount of currency because of the transaction fees.

Here's a few quick examples (user input in bold):

$ python3 currency.py
How many dollars? 100

$100.0 will buy you:
73.95 euros.
1633.6999999999998 pesos.
579.7 yuan.

$ python3 currency.py
How many dollars? 20.50

$20.5 will buy you:
8.243249999999998 euros.
182.10949999999994 pesos.
64.61949999999999 yuan.

3. Calculating Heights

In height.py, write a short program that helps convert heights into different units of distance. Your program should ask the user for their height in feet and inches. Your program should then output three calculations: The user's total height in inches, feet, and centimeters (assume one foot equals 30.48 centimeters).

Here are two examples (user input in bold):

$ python3 height.py
Number of feet: 5
Number of inches: 11

You are: 71 inches tall.
You are: 5.916666666666667 feet tall.
You are: 180.34 cm tall.

$ python3 height.py
Number of feet: 7
Number of inches: 6

You are: 90 inches tall.
You are: 7.5 feet tall.
You are: 228.6 cm tall.

4. Answer the Questionnaire

Each lab has a short questionnaire at the end. Please edit the QUESTIONS-01.txt file in your cs21/labs/01 directory and answer the questions in that file.

Turning in Your Labs

Don't forget to run handin21 to turn in your lab files! You may run handin21 as many times as you want. Each time it will turn in any new work. We recommend running handin21 after you complete each program or after you complete significant work on any one program.