programming-fundamentals
  • Introduction
  • Lesson 1
    • Writing Your First Program
    • Data Types
    • Built In Functions
    • If Statements
    • Using Git and Github
    • Primer
    • Questions
    • Tip Calculator
    • GPA Calculator (optional)
  • Lesson 2
    • Modules
    • Lists
    • Data Structures
    • More On Data Structures
    • Questions
    • Madame Zamad
    • Mad Libs
  • Lesson 3
    • While Loops
    • For Loops
    • Loops and Lists
    • Special Commands
    • Questions
    • TODO List
    • Fibonacci (optional)
  • Lesson 4
    • Functions
    • More Functions
    • Error Handling
    • File I/O
    • Questions
    • Sudoku
Powered by GitBook
On this page
  • Setup
  • Requirements
  • Turn It In
  • Tips

Was this helpful?

  1. Lesson 1

Tip Calculator

PreviousQuestionsNextGPA Calculator (optional)

Last updated 5 years ago

Was this helpful?

You have already written your first program but now you will write one that has a real-world application. The requirements for accomplishing this assignment will be given.

Setup

Fork the lesson one homework repository.

Clone your remote repository (replacing reedcwilson with your username).

git clone https://github.com/reedcwilson/lesson1.git

Change directories in your terminal to your newly cloned repository.

cd lesson1

Open the tip-calculator.py file in your text editor.

Requirements

Write a program that receives the following inputs from the user:

  • the server's name

  • how much the meal cost

  • the tax rate as a floating point (e.g. 6.5)

  • the tip percent as an integer (e.g. 15 or 20)

Print out the following results:

  • The amount to tip

  • The total amount for the meal

  • A thank you for the server

Turn It In

When you are finished, stage your changes:

git add .

Then create a commit:

git commit -m "replace this string with your commit message"

Push your changes back to GitHub:

git push origin master

And, finally, email me the URL to your repository.

Tips

  • Remember that percentages are often represented as numbers like 6.5% but the

    real value is 0.065.

  • The user's input will always be a string. You will need to convert the

    user's numerical inputs into numbers.

Lesson 1 Homework