Csci 1100 computer science homework - loops and lists write


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

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Csci 1100 computer science homework - loops and lists write
Reference No:- TGS02682619

Expected delivery within 24 Hours