BBM103 PROGRAMMING ASSIGNMENT 2 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Problem 1(45 points): In this problem, you are expected to write a Python program “problem1.py”. You should implement a Python function avgFirstThreeDigit() that, when a given list of 3-4 or 5 digit integers, returns the average of sum of the first three digits of each integers in the reversed order. Read data from “Integers.txt”, and put them in a list named ListIntegers. Please do not forget use semicolon as delimiter. A sample input-output is provided below: #Read data from file, do not implement list shown below. It is just a sample. ListIntegers = [18957, 30647, 4653, 1230, 168, 501, 99985, 87965, 534] output= avgFirstThreeDigit(ListIntegers) print(output) This program should output: Problem 2(55 points) Mr. McCarthy and his family want to buy a new house. There are five houses they like, but they must consider several factors to decide which the best one is. These factors are the initial cost of the house, the estimated annual fuel costs, and annual tax rate. In this problem, you are expected to write a Python program “problem2.py” that will determine the total cost after a 10 year period for each set of a house data in “HouseData.txt” file. You should read the costs from file and put them in a two-dimensional list named bulletList. Use “ ” (keyboard space bar) as delimiter. Implement three functions whose names are calculateTotalCost(), displayCosts() and selectBestBuy().  calculateTotalCost() function should calculate the total cost after 10 year period for each house and put the results in a list named ResultList. HINT: To calculate the total house cost, add the taxes for 10 years and the fuel cost for 10 years to initial house cost. Taxes for 10 years can be calculated by multiplying initial house cost by tax rate and 10.  displayCosts() function should display the total costs of all houses calculated in CalculateTotalCost() function. Fall 2016 BBM103: Introduction to Programming Laboratory I  selectBestBuy() function should determine which house they should buy, of course, it should be the cheapest one in the overall.  calculateTotalCost() function should be called by other functions. “HouseData.txt” 118920 2420 0.045 343600 1660 0.072 226250 9876 0.027 127500 2670 0.025 529600 26922 0.052 In “HouseData.txt” file, each row holds necessary data (initial house cost, the estimated annual fuel cost and annual tax rate) for one house. Initial house costs are hold in first colon, the estimated annual fuel costs are hold in second colon and the last column holds annual tax rates. A sample input-output is provided below: This program should output: Fall 2016 BBM103: Introduction to Programming Laboratory I NOTES:  Your programs will be executed in DEV machine, please make it work on dev before submitting. For example, you should use python3 problem1.py syntax to execute your first program in DEV machine. If you use “pyton problem1.py” syntax, DEV machine executes your program according to python 2.7.  Do not miss the submission date.  Please do not make any change in input text files, only read data from them.  Input file names will be fixed, you can hardcode them into your program.  Save all your work until the assignment is graded.  The assignment must be original, individual work. Duplicate or very similar assignments are will be threated according to regulations. General discussion of the problem is allowed, but do not share answers, algorithms or source codes. Keep in mind that you will get points for every little thing you do.  You can ask your questions about the assignment via Piazza and you are supposed to be aware of everything discussed in Piazza. (https://piazza.com/hacettepe.edu.tr/fall2016/bbm101)  Questions sending to my e-mail address will not be taken into account.  You will submit your work from https://submit.cs.hacettepe.edu.tr/index.php with the file hierarchy as below:  problem1.py problem2.py  This file hierarchy must be zipped before submitted (Not .rar, only .zip files are supported by the system)  Assignments which don’t have the wanted directory structure will not be evaluated.  You can get punishment points if you don’t follow the rules defined above.