Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Latest commit

 

History

History
33 lines (20 loc) · 1.49 KB

File metadata and controls

33 lines (20 loc) · 1.49 KB

Intro to Python

Welcome to the Intro to Python exercise! This tutorial assumes only the ability to install software and read.

Installation

Please download Python (version 3.4.0 or higher) for your operating system from here.

Basics

AutomateTheBoringStuff has a great online booklet for learning the basics of Python. Read the following chapters:

Chapter 1: Python Basics

Chapter 2: Flow Control

Chapter 3: Functions

Exercise

Alice has three dogs. For each meal, Riley needs 50 pieces of dog food, Abby needs 100 pieces, and Luna needs 150 pieces. Write a function mealsLeft which takes the integer dogfood as the total remaining pieces of dog food. mealsLeft should return an integer telling how many "full meals" Alice can serve to her dogs.

Hints

Click To Open
  • Consider how many total pieces it takes to feed all three dogs
  • Use integer division to your advantage

Extra Credit

  • Write a function howMuchDogFood which takes an argument meals and returns how much dog food Alice should buy to have enough for that many meals
  • Set a price for dog food pieces. Rewrite the howMuchDogFood function to accept the argument money and return how much dog food Alice can afford