



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Files to submit: 1. face.py
2. tipCalculator.py For Help:
So you’re sitting there, looking at your Python window, and you find it to be, well, impersonal. So why don’t we add a little personality to it? How about…a face! Hey! That looks much friendlier. And you can do it all with python! Specifically, that infamous myro thing you’ve installed. Myro contains a multitude of commands for programming your robot. See the documentation here: http://wiki.roboteducation.org/Myro_Reference_Manual For this assignment, we will be focusing on the graphics aspect of myro, so you won’t need your robot. Both the link given above, as well as the PDF for the Myro Graphics
Reference will be rather helpful.
Your mission, should you choose to accept it (and we recommend that you do), is to make a face in Python. You need to create a program that initializes a graphics window, and draws the face. When you are done, save your program as “face.py”. Make sure that your filename matches this exactly, or you will lose points! Don’t forget to include any necessary import statements needed to use myro functions. The face should contain:
Python is full of all kinds of useful functions, used from everything to user input to number manipulation to creating directories and reading files. For this homework, you will need to use functions that gather information from the user, cast values to the correct type, and print things out to user’s screen. First, let’s look at the two functions for gathering user input, raw_input() and input(). raw_input() takes a response from the user and saves it as a string. It accepts all types of input, but keep it mind it will always be saved as a string. The parameter for this function (the stuff inside the parenthesis) is an optional prompt that you can display to the user so they know what kind of input you want. input() works almost the same, except that input is used only to take in numbers. You can pass it either ints or floats, and it will save the values appropriately. Sample:
x = raw_input("Age? ") Age? 6 type(x) <type 'str'> y = input("Age? ") Age? 4
Resultant Output:
Hello
Your age is: 21 Your age is: 21 Your age is: 21 You can also use the % operator (string formatting) if you need to trim decimal places off to create neater output. Sample Code: x = 23. print "Number: %.2f" % x Output:
Number: 23.
So you’ve been up all night playing Rock Band™ with your friends. Well, rocking out hardcore always makes one tired, so you decide to go grab some food. It being nearly 3 am, the only place is the great institution of Waffle House. However, you’re spent from a night of constant awesomeness, and realize you just won’t be able to compute the appropriate tip amount for the waitress in your head. For some reason, though, the part of your brain that writes Python scripts is super focused and ready to go, so you decide to whip out your laptop and write a Python program to handle the tip calculations for you. (Yes, you brought your laptop to Waffle Hours with you. You are a Tech student, after all.) You program will also need to be able to handle tax. -Write a script that prompts the user for the bill amount and the percent that they want to leave for the tip. Do not include the dollar sign or percent sign when entering the numbers! -Calculate the tax ( always 8% ), the tip (percent of bill amount, excluding tax), and the total bill. -Remember to divide the percentages by 100 when multiplying. Here, it is important to remember how Python handles division. -You are expected to round the your tip to the next dollar by use of the math.ceil() function. Basically, math.ceil() always rounds the number up to the next integer. Do not forget to import math when using functions from the math module!
For example:
math.ceil(4.51)
math.ceil(6.7)
math.ceil(3.2)
-Round the tax to the nearest cent by use of string formatting. Remember, you’re working with money, so how are dollar amounts usually presented? Sample output:
How much is the bill before tax and tip? 7. What percent tip do you want to leave? 15 Tax is $0. Tip is $2. Total is $10. Save your script in a file called “tipCalculator.py”. Again, save your file with this exact name, or you will lose points!
Once you’re done, please submit face.py and tipCalculator.py to T-Square. The assignment is due Friday, Jan 16th^ before 6pm. If you’re late, but turn it in before 6pm on Monday, you will lose 10%. We will not accept submissions after Monday.
Part 1 – Face – 50 points File named correctly (face.py) – 5 points Creates a graphics window – 10 Draws a head – 6 Draws 2 eyes – 6 Draws a nose – 6 Draws a mouth – 6 Uses at least 2 different colors - 6 The facial features are properly aligned – 5 Total for part 1: 50 points Part 2 – Tip Calculator – 50 points