cs1315_homework1 - CS 1315 Homework 1 Due: Friday, 2009...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 1315 Homework 1 Due: Friday, 2009 before midnight. File to submit: • hw1.py And yes, we do mean literally that filename. Lowercase letters and all. Also each function must be named exactly as specified – again with upper and lowercase correct and all. Be exact! • Turn in the correct file; It matters! JES generates many files. Make sure you really submit the hw1.py file and not mistakenly the hw1.pylog or hw1.bak file. This is your responsibility. Pay attention to the file you upload, the name T-Square shows as the name of the file you have uploaded, and the file the email confirmation says you have uploaded to T-Square. • Do not turn in a Word document, but literally the file that is created by JES. • We will grade only the file you submit to T-Square. • There are no do-overs, re-submits, etc! • Safe Submission: • 1) You will receive a confirmation email from T-Square saying which files you submitted. If you do not receive that email, then trust that your submission did not work. 2) Read that email! Double check the filename(s) submitted. 3) Also, go back to the assignments page on T-Square and double check what you have turned in. Download a copy of it from T-Square and verify that it is exactly what you intended to submit. Turning in the correct file and validating that you have done that correctly is solely your responsibility. Seriously. It is solely your responsibility. Correct submission is something you are required to do. It is your job to verify it. You can submit your hw1.py file multiple times on T-Square until the cut-off time. We will grade the last one you submit. Collaboration policy: Do your own work. You are allowed to discuss your homework with other people, but you are not allowed to share files nor copy each other's code. Rule: Never give or take code from another student. Period. Working together is not equivalent to copying another person's work and passing it off as your own as that is by definition cheating. Do not take another person's work, nor give your work to another student (equally considered cheating). How do you prevent others from copying your work? Never, ever, under any circumstances give someone else (not even your best friend) a copy of your homework solution/code. And by never, we mean never. Not when they want to "see how you did it" nor when "I lost mine" nor when "I just need an idea of how to do it". Students are sent to the Office of Student Integrity over cheating on homework. If you give your homework to someone that is a free opportunity to turn it in as their own. If they do, you are as guilty as they are of cheating. Period. Grace period, lateness, T-Square, and you: This assignment has a due date (before 8 p.m.) and a grace period (up to but not including 2 a.m.) 2 a.m. is a hard (non-flexible) deadline. You will not be able to complete a submission at or after 2 a.m. Use the grace period to resolve upload issues, internet issues, and all others issues. The purpose of the grace period to serve as a buffer for when something has gone wrong while turning in the assignment before the published due date. Running out of time during the grace period for any reason will result in a 0 for the assignment. Your assignment will be marked late on T-Square if you turn it in during the grace period. You will not lose credit because of lateness during the grace period. The due date is before 8 p.m., and the grace period ends just before 2 a.m. Even if you are in the middle of the submission process, just before 2 a.m. T-Square stops all submission. Think of the due date as the time your plane LEAVES the ground - with or without you. And seriously even if you were still on the tarmac, the stairs up into the plane, or in the passenger loading bridge. (Think action movie, and this is a getaway jet.) Do not play around with the due date, a.k.a. deadline. It is real. Things to include in a single file called hw1.py (and be sure your function names match these exactly): 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. A comment that includes your name: milesToKilometers() inchesToMeters() sphereVolume() timeCleanUp() milesPerGallon() eurosToDollars() nameGenerator() bodyMassIndex() and the function you make up Start JES. All the functions required for this homework will need to be in one file named specifically hw1.py. (Not HW1.py, not homework1.py, not hw_1.py, not hw1_ver1.py, but literally hw1.py.) Include your name as a comment in your hw1.py file. Once you have one function typed within JES, save your hw1.py file to a convenient place on your computer so you can easily find it. Test that function. Once it is working, go back and add code for another function. All the definitions for the functions are to be in one single file. 1: Not really a function, but include your name as a comment in the hw1.py file. Literally like this, but with your name: # Monica Sweat Also make sure you are saving your file as hw1.py 2: Write a user-interactive function to convert miles to kilometers. a. name the function milesToKilometers (NOTE: jython is case-sensitive!) b. the function has no parameters (nothing in the parentheses) c. get the number of miles from the user using the requestNumber function d. use a good prompt with requestNumber so the user knows what you are asking them to enter e. formula: 1 mile = 1.609344 kilometers f. display the calculated kilometers using the showInformation function (or for partial credit, use print) g. be sure to label the value when displaying it with showInformation so the user knows what the value means 3: Write a user-interactive function to convert inches to meters. a. name the function inchesToMeters b. the function has no parameters c. get the numbers of inches from the user using the requestNumber function d. use a good prompt with requestNumber so the user knows what you are asking them to enter e. formula: 1 inch = 0.0254 meters f. display the calculated meters using the showInformation function (or for partial credit, use print) g. be sure to label the value so the user knows what it is 4: Write a user-interactive function to calculate the volume of a sphere. a. name the function sphereVolume b. the function has no parameters c. get the radius from the user using requestNumber d. use a good prompt with requestNumber so the user knows what you are asking them to enter e. formula: volume of a sphere is (4/3)πr3 , where r is the radius. (Be careful programming the 4/3 part and also use math.pi in the equation!) f. display the calculated volume using the showInformation function (or for partial credit, use print) g. be sure to label the value so the user knows what it is 5: Write a user-interactive function to convert seconds to the equivalent number of hours, minutes, and seconds. a. name the function timeCleanUp b. the function has no parameters c. get the integer number of seconds from the user using the requestInteger function d. use a good prompt with requestInteger so the user knows what you are asking them to enter e. formulas and facts: a. There are 60 seconds in a minute. b. 60 minutes in an hour. c. The mod or remainder operator in python is % and will show the remainder left after an integer division. It IS useful for this problem! f. display the calculated equivalent integer number of hours, minutes, and seconds using the showInformation function (all in one window, not three) g. be sure the three values are all labeled so the user will know what the values mean 6: Write a user-interactive function to calculate miles per gallon. a. name the function milesPerGallon b. the function has no parameters c. get the number of miles from the user using requestNumber (why is this better than requestInteger for this problem?) d. get the number of gallons from the user using requestNumber (why is this better than requestInteger for this problem?) e. use good prompts for both of those requestNumber function calls f. formula: mpg = miles/gallon g. display the calculated mpg using showInformation (use print for partial credit) h. be sure to label the output so that the user knows what the value means 7: Write a user-interactive function to convert euros to dollars. a. name the function eurosToDollars b. the function has no parameters c. get the number of euros from the user using requestNumber d. use a good prompt with requestNumber so the user knows what you expect e. formula: currently 1 Euro = 1.3474 U.S. dollars so use that to do the conversion f. display the calculated quantity of dollars with showInformation (or use print for partial credit) g. be sure to label the answer with a dollar sign so the user knows that the value means, like $100.95 h. we'll show you in class how to limit that to two post-decimal places 8: Write a user-interactive program to ask a user for their name and then for their favorite number under 100. The program then displays their name that many times. a. name the function nameGenerator b. the function has no parameters c. ask for the person's name using requestString d. ask for the favorite number using requestInteger e. use good prompts with both of those requests f. display the name as a huge string back to the user using showInformation g. example: Burdell and 3 would display BurdellBurdellBurdell 9: Write a user-interactive program to calculate a person's BMI, body mass index. Here is the formula for BMI. BMI = a. b. c. d. e. f. g. pounds × 703 inches2 name the function bodyMassIndex (that style is called camelcase) the function has no parameters ask for the persons weight using requestNumber ask for the persons height in inches using requestNumber use good prompts for both of those requestNumber calls calculate the BMI using the information from the formula above (you will need to convert that formula into a legal python equation!) display the result labeled this way "Your BMI is 24.9." € 10. Make up and write a function similar to one of these homework problems. Be sure it uses user input via requestString, requestNumber, or requestInteger. It must have no parameters. It must calculate something correctly and then display the result using showInformation with the result being labeled nicely so the use knows what was calculated. :) Start early! If a particular problem is giving you trouble, you can comment out all the lines for that function and move on to the next problem leaving the problematic one for later. Please see TA Office Hours posted on T-Square->cs1315->wiki for the schedule. All "Office Hours" are in the College of Computing Commons Area (that's the big open area with all the tables and chairs). HELP! Look for the cones!!! CS1315 TAs are the ones with the orange cones! ...
View Full Document

This note was uploaded on 01/26/2012 for the course CS 1315 taught by Professor Sweat during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online