🚀 Basics Day 2: Pre-Class Exercises 🚀

Pre-Class In-Class

Orange Juice Calculator (Functions II)

  1. Write a program that takes in as input the number of expected guests for a party, and outputs the number of oranges required to make enough Orange Juice for all guests.
  2. To begin, assume:
    1. It takes 4 oranges to make a glass of orange juice.
    2. Each guest will drink 2 glasses of Orange Juice on average.
  3. Subsequently, edit the functions written such that it takes in both the number of guests as well as the number of glasses per guest as input, and produces the same output: oranges required.

Input:


Output:

House Paint (Functions II)

Estimate the price of painting the interior of your home. The user will enter a dollar amount of paint per litre and the app will calculate how much it will cost.

  1. To begin, assume:
    1. Each room in your 6-room house has the same area to be painted: 3m x 3m.
    2. Paint will cover 300 square meters per litre.
    3. You want to apply 2 coats of paint.
  2. Edit the function(s) such that the number of rooms, and the number of coats to be painted are also variables that are taken in as input.

Input:


Output:

Random Dice Rolls (Intro to Logic and Control Flow)

Follow along the Random Dice Rolls example in the Intro to Logic and Control Flow module.


Input:


Output:

Secret Phrase (If, Else, Else If)

Follow along the Secret Phrase example in the If, Else, Else If module.


Input:


Output:

Dice Game (If, Else, Else If)

Follow along the Dice Game example in the If, Else, Else If module.


Input:


Output:

Twice the Guess (If, Else, Else If)

Update our dice game logic such that the user wins if the dice roll is 2 times the guess, e.g. a guess of 1 and roll of 2, a guess of 2 and roll of 4, etc. To win this updated game for a 6-sided dice, the user should only guess numbers between 1 and 3, but the game does not restrict what the user can guess.


Input:


Output: