Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

CMSC 201 – Computer Science I for Majors Page 1

CMSC 201 – Computer Science I for Majors Page 1 Homework AI – MakeupAssignment: Homework AI - Makeup Value: 80 pointsThis is a makeup homework for students who may have had an issue withacademic integrity this semester. Everything this semester is fair gameregarding content including classes/objects, file I/O, control structures, andanything else.Remember to enable Python 3 before you run your programs:/usr/bin/scl enable python33 bashInstructionsEach one of these exercises should be in a separate python file. For thisassignment, you may assume that all the input you get will be of thecorrect type (e.g., if you ask the user for a whole number, they will give youan integer).For this assignment, you'll need to follow the class coding standards, aset of rules designed to make your code clear and readable. The class codingstandards are on Blackboard under “Course Documents” in a file titled“CMSC 201 - Python Coding Standards.”You will lose major points if you do not following the 201 coding standards.A very important piece of following the coding standards is writing a completefile header comment block. Make sure that each file has a comment blockat the top (see the coding standards document for an example).NOTE: You must use main() in each of your files.CMSC 201 – Computer Science I for Majors Page 2DetailsHomework AI is broken up into three parts. Make sure to complete all 3parts.NOTE: Your filenames for this homework must matchthe given ones exactly.And remember, filenames are case sensitive.hwAI_part1.pyWrite a program to import a text file with data related to a hotel record. For thisassignment you are going to import the file and iterate through the file outputtingthe important information.Additionally, you need to use the following functions:getInput() – opens the file and returns the file objectcleanInput(yourList) – returns the list as a two-dimensional listoutput(yourList) – prints the output as belowmain() – acts as the driver for the programHere is some partial sample output (there are more than 100 lines of input),with the user input in blue.bash-4.1$ python hwAI_part1.pyWhat is the name of the file?: AI1.txtTom Lars stayed for 3 nights and paid $120.98 per nightfor a total of $362.94Eric Tall stayed for 2 nights and paid $149.54 per nightfor a total of $299.08Tim Can stayed for 2 nights and paid $113.54 per night fora total of $227.08Kathy Bo stayed for 1 nights and paid $92.29 per night fora total of $92.29Sam Ewes stayed for 2 nights and paid $200.18 per nightfor a total of $400.36Mo Bite stayed for 3 nights and paid $197.92 per night fora total of $593.76Van Sanch stayed for 1 nights and paid $89.26 per nightfor a total of $89.26CMSC 201 – Computer Science I for Majors Page 3The sample input file that was used to create the sample output above, AI1.txt, ismuch too long to include in this document. However, you can directly downloadthe file using the “cp” command.The command below will copy the file “AI1.txt” from Professor Gibson’s publicdirectory to your current directory. The period at the end (“.”) means that the filewill have the same name after you copy it, so AI1.txt will be the copied file’sname. Make sure to run the command from the folder you want the file to becopied into!cp /afs/umbc.edu/users/k/k/k38/pub/cs201/AI1.txt .CMSC 201 – Computer Science I for Majors Page 4hwAI_part2.py(WARNING: This part of the homework is the most challenging, so budgetplenty of time and brain power. And read the instructions carefully!)Mike is an accountant. During tax season, he is required to enter a widevariety of dollar amounts to file taxes. He often has to enter the dollaramounts manually. As part of a research project, we are trying to calculatehow far his fingers have to move to enter each dollar amount. He entersdollar amounts using a keypad which has the following layout:7 8 94 5 61 2 3. 0On his keypad, there is a measurable distance between each of the keys.The distance between each adjacent key (horizontal or vertical) is exactly oneinch. For example, the distance between the center of 7 and 4 would be oneinch. The distance between 8 and 0 would be three inches.Therefore, we can calculate the distance between each of the diagonalsusing the Pythagorean Theorem. The distance would be square root ofa2 + b2. As we know that a and b are going to be 1 in this case then we knowthat the distance between each diagonal is the square root of 1+1.For example, here is how Mike would type out the number 9851:1. He starts his finger at 9 and pushes the key.2. He moves his finger to the left 1 inch to 8 and pushes the key.3. He moves his finger downwards 1inch to 5 and pushes the key.4. He moves his finger diagonally downwards and left sqrt(2 inches) to 1 andpushes the key.Therefore the total distance that Mike moved his finger to type in 9851 is1 + 1 + sqrt 2 which is about 3.41 inches.CMSC 201 – Computer Science I for Majors Page 5For this part of the homework, your goal is to write a program that calculatesthe distance Mike must move his finger to type in arbitrary dollar amounts.Here is some sample output, with the user input in blue.bash-4.1$ python hwAI_part2.pyEnter a dollar amount: 1053.34Distance: 11.54 inchesbash-4.1$ python hwAI_part2.pyEnter a dollar amount: 80121.41Distance: 10.41 inches $HINTS:1. You may want to use a dictionary to map the locations of the keys.2. Don’t forget the decimal (.) is included in the distance!3. In order to calculate the square root, you will need to import the mathlibrary and use math.sqrt() for the diagonals.CMSC 201 – Computer Science I for Majors Page 6hwAI_part3.pyFor this assignment, you are going to be given a small data file. Here are thecontents of the data file AI2.txt:8 1 6 3 5 7 4 9 23 5 7 8 1 6 4 9 28 1 6 7 5 3 4 9 22 7 6 9 5 1 4 3 84 9 2 3 5 7 8 1 6Each of the 5 lines in the data file represents a 3x3 magic square. A magicsquare is a grid using the numbers 1 through 9 (exactly one of each) whereeach row, column, and diagonal adds up to 15.For example, line 1 above (8 1 6 3 5 7 4 9 2) looks like this:8 1 63 5 74 9 2Each of the three rows (in green above) need add up to 15.Each of the three columns (in red above) need to add up to 15.Each of the two diagonals (in blue above) need to add up to 15.Here is some partial sample output, with the user input in blue (There shouldbe 5 boards when you are finished).bash-4.1$ python hwAI_part3.pyBoard 1816357492Board 1 is a magic squareBoard 2357816492Board 2 is not a magic squareCMSC 201 – Computer Science I for Majors Page 7The sample input file that was used to create the sample output above, AI1.txt, isdifficult to copy and paste from a Windows-based environment. However, youcan directly download the file using the “cp” command.The command below will copy the file “AI2.txt” from Professor Gibson’s publicdirectory to your current directory. The period at the end (“.”) means that the filewill have the same name after you copy it, so AI2.txt will be the copied file’sname. Make sure to run the command from the folder you want the file to becopied into!cp afs/umbc.edu/users/k/k/k38/pub/cs201/AI2.txt .CMSC 201 – Computer Science I for Majors Page 8SubmittingOnce all three parts of your Homework are complete, it is time to turn them inwith the submit command.Don’t forget to complete the header block comment for each file! Make surethat you updated the header block’s file name and description for each file.You must be logged into your GL account, and you must be in the samedirectory as the Homework AI files. To double check this, you can type ls.linux1[3]% lshwAI_part1.py hwAI_part2.py hwAI_part3.pylinux1[4]% █To submit your files, we use the submit command, where the class iscs201, and the assignment is HWAI. Type in (all on one line)submit cs201 HWAI hwAI_part1.py hwAI_part2.pyhwAI_part3.pyand press enter.linux1[4]% submit cs201 HWAI hwAI_part1.py hwAI_part2.pyhw5AI_part3.pySubmitting hwAI_part1.py...OKSubmitting hwAI_part2.py...OKSubmitting hwAI_part3.py...OKlinux1[5]% █If you don’t get a confirmation like the one above, check that you have notmade any typos or errors in the command.You can double-check that all three homework files were submitted byusing the submitls command. Type in submitls cs201 HWAI and hitenter.And you’re done!

Show more
adelen
adelen
  • @
  • 1 order completed
ANSWER

Tutor has posted answer for $70.00. See answer's preview

$70.00

* ***** ************* Author: # ***** # ******** ** E-mail: * ************* **** **** ******** python **** **** **** ****** a **** ***** **** **** ******* ** a ***** recorddef getInput(file_name): ****** the **** *** ******* *** file ******* file_pointer * ************** **** ****** *************** cleanInput(file_pointer): ********* *** * ******* *** list ** * *************** ***** ******* = file_pointerreadlines() *** data ** ******** **** = ******************** col_data *** *********************** *********************** *********************** *********************** ************************* ****** list_datadef output(list_data): ******* the ****** ** ****** **** * ************** *** index in range(0 rows): ** ***************** ********* * ******************* * * " + list_data[index][1] **************** * **************************** / **************************** print( *********** ****** *** "+str(list_data[index][2])+" nights and **** $"+str("{:62f}"format(per_night_charge))+" *** ***** *** * total ** **************************** *** ******* ***** ** *** ****** for the program' ********* * * **** * * ] * 200 ********* * *********** is *** **** ** the file?:") ************ * ******************* ********* = ************************ output(list_data)#Run *** ***************

Click here to download attached files: new_folder.zip
or Buy custom answer
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question