Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

Computer Science Homework - Loops and Lists

Part 1: Words with alternating vowels and consonants

Here's a short, easy one to get started! Write a program that reads in words entered by the user and checks whether:

  • the word has at least 8 characters,
  • has alternating consonants and vowels, and
  • the vowels are in non-decreasing alphabetical order.

The program should loop reading additional words until the user enters an empty string. Note that you can check letters for alphabetical order using <.

Your program should work for words entered upper or lower case, and must use a function is_alternating(word) that returns True if the word has the above pattern, and False otherwise. You are welcome to use additional functions if you would like. Hint. Remember to write a loop that goes through each letter and checks for the necessary conditions. Using indexing is important here as you need to compare letters in different positions.

When you have tested your code, please submit it as hw4Part1.py. Be sure you use the correct filename, otherwise, Submitty will not be able to grade your submission.

Part 2: ZIP code look up and distance calculation

As part of an Open Data Policy, the U.S. Government released a large number of datasets \to conduct research, develop web and mobile applications, design data visualizations" [1]. Among these is a dataset that provides geographic coordinates for U.S. 5 digit ZIP codes. For this assignment, we will be using a slightly improved version of the ZIP dataset available at [2]. For each ZIP code, this dataset lists geographic coordinates (latitude and longitude), city, state, and county. Our goal is to use available data to develop a new data product that would allow users not only to query and search the existing data source but also to access additional functionality such as computing the distance between two locations.

Write a program that would allow users to lookup locations by ZIP code, lookup ZIP codes by city and state, and determine the distance between two locations designated by their ZIP codes. The program interacts with the user by printing a prompt and allowing them to enter commands until they enter end at which point the program prints Done and finishes. If an invalid command is entered, the program prints Invalid command, ignoring and is ready to take the next command.

The following commands are recognized:

1. loc allows the user to enter a ZIP code, then looks up city, state, county, and geographic coordinates that correspond to the ZIP code and prints this data; If a ZIP code is invalid or not found in the dataset, the program prints a error message instead.

Note that coordinates are enclosed in parentheses and are separated by a comma; each coordinate is printed in integer degrees (three digits), followed by the symbol, integer minutes (two digits), followed by the character, integer and fractional seconds (two integer and two decimal digits), followed by the " character, and a cardinal direction letter (N, S, W, or E) with no spaces anywhere in the coordinate representation.

2. zip allows the user to enter city and state, then looks up the ZIP code or codes (some cities have more than one) which correspond to this location and prints them; if city and/or state are invalid or not found in the dataset, it prints an error message instead.

3. dist allows the user to enter two ZIP codes and computes the geodesic distance between the location coordinates ; if any of the ZIP codes entered is invalid or not found in the dataset, it prints a corresponding error message instead.

4. end stops fetching new commands from the user and ends the program.

The utility module provided for this part of homework will give you some help. It provides a function read_zip_all() that returns a list each element of which is, in turn, a list that contains data about one zip code.

Implementation Details

You will need to define two functions that should strictly follow specifications outlined below:

1. zip_by_location(zip_codes, location) which finds the ZIP code for a given location.

Parameters:

zip_codes a list of ZIP codes data in the format, returned by read_zip_all() location a two-element tuple where the first element is the city name and the second element is the state abbreviation, e.g. ( trOy , nY ). Both elements are string values. City names and state abbreviations can be written using any case or a mixture of lower and upper case.

Return value:

A list which contains ZIP code or codes for the specified location. Each ZIP code is a string value. If the location is invalid, an empty list is returned. E.g., [ 12179 , 12180 , 12181 , 12182 , 12183 ]

2. location_by_zip(zip_codes, code) which finds location information corresponding to the specified ZIP code.

Attachment:- Assignment Files.rar

Python, Programming

  • Category:- Python
  • Reference No.:- M92715475
  • Price:- $110

Guranteed 48 Hours Delivery, In Price:- $110

Have any Question?


Related Questions in Python

Simple python traffic lightswrite a program that simulates

Simple Python (Traffic lights) Write a program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green. When a radio button is selected, the light is turned on, and onl ...

Below zero - ice cream storethe local ice-cream store needs

Below Zero - ice cream store The local ice-cream store needs a new ordering system to improve customer service by streamlining the ordering process. The manager of the store has found that many orders are incorrect and s ...

Assignment1 utilising python 3 build the following

Assignment 1. Utilising Python 3 Build the following regression models: - Decision Tree - Gradient Boosted Tree - Linear regression 2. Select a dataset (other than the example dataset given in section 3) and apply the De ...

Question why is software configuration management

Question : Why is software configuration management considered an umbrella activity in software engineering? Please include examples and supporting discussion. The response must be typed, single spaced, must be in times ...

Environment setupthe first mini project will be based on

Environment Setup The first mini project will be based on Ladder Logic programming. We will be using Schneider Electric's IDE called SoMachine Basic to do the programming. The latest ver- sion of SoMachine Basic for Wind ...

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 ...

Part i the assignment filesone of the most important

Part I: The Assignment Files One of the most important outcomes of this assignment is that you understand the importance of testing. This assignment will follow an iterative development cycle. That means you will write a ...

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 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 ...

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 ...

  • 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