Modify your code to ask the user for the id of a restaurant

Assignment Help Python Programming
Reference no: EM131143275

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',\ ‘https://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( ‘https://xkcd.com/1319/' ) If the user answers 2, then open a browser window with Google maps showing the address of the business. webbrowser.open( ‘https://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( ‘https://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( https://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

Reference no: EM131143275

Questions Cloud

Determine whether no-smoking policies : You want to determine whether no-smoking policies have impacted employee morale in the United States among workers in companies that employ fewer that 50 workers in Fort Wayne, Indiana. Are any secondary data likely available? Why?
Management involvement is also very important : Based on the list of the seven concepts of TQM, One mentioned is employee empowerment. I have always said that the person actually doing the job should be involved in any type of continuous improvement. They know the job best. Management involvement ..
Creating applications for a change project communication : Analyzing and creating applications for a change project communication based on the change in one of your researched companies to include an analysis of a company change communication and writing an original change communication message. (2 new r..
Improve clinical practice through application of evidence : When reading quantitative research articles, how do you, a nurse wanting to improve clinical practice through application of best evidence, read a quantitative study? What do you look for as indicators that the study was a rigorous one? That the find..
Modify your code to ask the user for the id of a restaurant : 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).
Scorecard in diminishing and overcoming myopic behavior : In 2002, Worldclass Lighting launched an initiative to introduce the balanced scorecard into the Asia Pacific and Greater China regions, in order to provide a new management tool for its lighting business covering four perspectives-financial, custome..
What is that minimum cost : After an aggressive marketing campaign in the local community, Lumyn Electronics discovered that their cost can now be modeled by the equation: C(n) = 25n2 - 1,500n + 25,000, What is that minimum cost
How can these organizations relate top executive pay : How can these organizations relate top executive pay and company performance financially? How has HRL considered differences in the culture of top executives and their motivation to perform better when determining their pay?
Determine the deflection of the plate when p = 9 kips : The plastic block shown is bonded to a fixed base and to a horizontal rigid plate to which a force P is applied. Knowing that for the plastic used G = 55 ksi, determine the deflection of the plate when P = 9 kips.

Reviews

Write a Review

 

Python Programming Questions & Answers

  In this assignment you will write a program that does

in this assignment you will write a program that does simple packet routing. your program will take three command-line

  Assume an n × n matrix a is given

Assume an n × n matrix A is given, containing only 1's and 0's, such that, in each row, all 1's come before all 0's. Give an O(n log n) algorithm to count all 1's in A.

  Without using the system function to call any bash commands

without using the system function to call any bash commands write a python program that will implement a simple version

  Same directory as your program

In the same directory as your program, create a file FF1, and write into it Hello (with a space at teh end). Similarly, create a file FF2, and write into it world! (with a new line, i.e., an ENTER at the end). And create a file DD and write into i..

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Implement a simplified version of ssl

COMP 4337/9337 - Securing Wireless Networks - Implementation Assignment - Implement a simplified version of SSL/TLS (miniSSL) and a sim-plified application-layer protocol (miniGet) in this project.

  Fill in the python code

Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("--..

  Write a python program that generates a small web site

ICT112 Assignment. Your task in this assignment is to write a Python program that generates a small web site to inform Sunshine Coast people about some aspect of the local environment or a local sustainability issue

  Write a program that will input the name of five students

Write clearly with documentations where necessary as you write the program to solve the following problem.

  Function by sum of sines

code the program using an editor (DO NOT COMMAND LINE THE PROGRAM) and show the results

  Write a short program in python that turns on all leds

Write a short program in Python that turns on all LEDs, one at a time, in a looping fashion. When an LED is on, it should stay on for 1 second.

  Interaction between the customer and the machine

In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd