Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

Checkpoint 1

Let's use the given module to read this file into a list. Create a new file called check1.py in the same folder as the files from the zip folder and include the following code inside: import lab03_util restaurants = lab03_util.read_yelp(‘yelp.txt') Use a few print statements to see the contents of the list. As the list is large, let's look at the first element: print restaurants[0] We will get: ["Mekas Lounge", 42.74, -73.69, \ ‘407 River Street+Troy, NY 12180',\ ‘http://www.yelp.com/biz/mekas-lounge-troy', \ ‘Bars', \ [5, 2, 4, 4, 3, 4, 5]] The variable restaurants contains a list. Each element of this list corresponds to a specific restaurant. From the above example, we see that the first element of the restaurants list is also a list. The information provided for each restaurant is: name, latitude, longitude, street address, URL, the restaurant category, and a list of scores given by Yelp users. Yes, the last element here is yet another list!

Your job in the first checkpoint is to print information for a single restaurant by writing a function called print_info(). Below is the result of printing the first two restaurants in the list: Mekas Lounge (Bars) 407 River Street Troy, NY 12180 Average Score: 3.86

Tosca Grille (American (New)) 200 Broadway Troy, NY 12180 Average Score: 2.50 The first line shows the name and the category in parentheses. The second and third lines both come from the address (note the use of the TAB here). The final line is the average score, obtained by taking the average of the last entry in the restaurant. How do we split the address into two lines? There is a very useful function called split() that splits a string into a list based on a given delimiter. For example: >>> title = "The,Old,Man,and,the,Sea" >>> title.split( "," ) [‘The', ‘Old', ‘Man', ‘and', ‘the', ‘Sea'] >>> title =

"The!Old!Man!and!the!Sea" >>> title.split( "!" ) [‘The', ‘Old', ‘Man', ‘and', ‘the', ‘Sea'] To get you started, here is the basic organization for printing just the name of a restaurant. import lab03_util def print_info( restaurant ): print restaurant[0] ####### main code starts here restaurants = lab03_util.read_yelp( ‘yelp.txt' ) print_info( restaurants[0] ) To complete Checkpoint 1, show a mentor the code and the output.

Checkpoint 2

Copy check1.py to check2.py and continue to work on check2.py. Modify your code to ask the user for the id of a restaurant between 1 and 155 (humans don't need to know about list ids starting at 0).

Assume the user enters a number. If the user enters a value outside of the range 1-155, print a warning and do nothing else.

If the user entered a valid index, print the information for the restaurant corresponding to this index (remember that index 1 corresponds to list index 0). Test your code well to make sure that you only print a restaurant for a valid index.

The second task in this part is to improve on the print function by changing the average score computation. Given the scores for a list, drop the max and the min, calculating the average of the rest. Note that you do not actually have to explicitly remove the max, min, just subtract them from the sum.

Given this average of the remaining scores, print one of the following based on the score:

Score Output 0 up to 2 This restaurant is rated bad, based on x reviews. 2 up to 3 This restaurant is rated average, based on x reviews. 3 up to 4 This restaurant is rated above average, based on x reviews. 4 up to 5 This restaurant is rated very good, based on x reviews. Note that x is the real number of reviews for this restaurant that are used in calculating the average. Beware! It does not make sense to remove max and min if there are less than three reviews for a restaurant. In that case, we should use the average of all the values (another if statement!).

To complete Checkpoint 2, show a mentor the code and the output. Please check to make sure your code follows the structure we require: first imports, then functions, then the actual code. Test your code with values 8, 22, 33, 44, and other valid and invalid values.

Checkpoint 3

Copy check2.py to check3.py and continue to work on check3.py. We will add a final flair in this part to your program from part 2.

Your program should work exactly as it did in part 2. After printing the restaurant info, ask the user the following: What would you like to do next? 1. Visit the homepage 2. Show on Google Maps 3. Show directions to this restaurant Your choice (1-3)? ==> For all of these options, using formatted strings will really simplify your life!

If the user answers 1, then open a browser window using the following command (but use the URL for the business instead of this address). Remember to import module webbrowser first of course. webbrowser.open( ‘http://xkcd.com/1319/' ) If the user answers 2, then open a browser window with Google maps showing the address of the business. webbrowser.open( ‘http://www.google.com/maps/place/business-address-goes-here' ) If the user answers 3, then open a browser window with Google maps with the address of the business and Rensselaer. Here is an example call: webbrowser.open( ‘http://www.google.com/maps/dir/business-address/rpi-address' ) For example, to find the location of Rensselaer, you can use the following call: webbrowser.open( http://www.google.com/maps/place/110 8th Street Troy NY 12180 )

Luckily, Google can handle spaces or even pluses in an address. If the user answers anything else, your program does nothing.

Attachment:- yelp_programs.zip

Python, Programming

  • Category:- Python
  • Reference No.:- M91898764
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Python

Python programming assignment -you first need an abstract

Python Programming Assignment - You first need an abstract base class, called, Account which has the following attributes and methods: accountID: This attribute holds the ID assigned the account , if not provided set to ...

Question a software company sells a package that retails

Question : A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program usi ...

Question research pythons dictionary data type dictdiscuss

Question : Research Python's dictionary data type (dict). Discuss its interface and usage. Include examples. Discuss practical applications of dictionaries.

The second task in this assignment is to create a python

The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes after a series of flips.(PYTHON 3) Problem Task In this problem, your input w ...

Homework -this homework will have both a short written and

Homework - This homework will have, both a short written and coding assignment. The problems that are supposed to be written are clearly marked. 1) (Written) Make heuristics Describe two heuristics for the slide problem ...

Question write a python program with a graphical user

Question: Write a python program with a graphical user interface that will allow a user to create a custom pizza which they wish to order. At minimum, the user should be able to choose the size of the pizza, the type of ...

Project reconnaissance and attack on ics

Project: Reconnaissance and Attack on ICS NetworksEnvironment Setup The second mini project will be based on Industrial Network Protocols, specifically the Modbus protocol. Please follow the instructions carefully to set ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Lab assignment -background - we have discussed in detail

Lab Assignment - Background - We have discussed, in detail, the function of Stacks and Queues and how they are specifically implemented in Python. To get a better understanding of the utility of these data structures, we ...

Tasksdemonstrate data scraping of a social network of

Tasks Demonstrate data scraping of a social network of choice. Develop technical documentation, including the development of the code & detailing the results. Provide a report on the findings, that includes research into ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As