The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Part 1: write a single python program with Lists
Create a new Python script using PyScripter that performs the following tasks in this order:
1. Stores five items in a list.
2. Switches the first and last entries in the list.
3. Prints the following using a loop:
List item #1 = {item}
List item #2 = {item}
….
List item #5 = {item}
Part 2: The del and remove Command and Functions
Create a new Python script using PyScripter:
The del command is powerful in Python. It can delete variables, objects, list items, among other
things. To delete an item at index 2 from a list, you would enter del myList[2] and Python would
delete that item and resize the list.
GISC 2234 Design and Analysis of GIS Applications
Page 2 of 2
The remove command searches for an item in a list and removes the first matching item from the
list. For example, if myList = [1,2,3,4,3,3] and I issued the command myList.remove(3), the
resulting list would contain [1,2,4,3,3].
Using the del and remove commands, write a Python function that takes three arguments: a list, a
string or number, and the string “index” or “item”. The purpose of the function is to remove an item
from the passed list either by a specified index, or item passed. If the user wishes to remove an
item from the list using an index, the third argument passed will be “index”, if the user wishes to
remove the first item found in the list using the item passed, the second argument will be “{item}”.
For example, to remove the item at index 3 from a list, this would be the command
myFunction(myList,3,”index”)
to remove the item “Joe” from the list, this would be the command myFunction(myList,”Joe”,”item”)
Write code to call the function twice, where the first call removes an item by index, and the second
call removes an item by item.
Part 3: Reading and Splitting
Create a new Python script using PyScripter:
The goal here is to convert some input to a useful state and use it. You will read in states.csv, store
each line in a dictionary where the state abbreviation is the key, and the state name is the value, and
then print the state names for Kentucky and Flordia using the dictionary and key.
Rough sketch of program logic:
Read states.csv, sanitize the input, and split
Store key and value in dictionary
printstateDict[“KY”]
printstateDict[“FL”]
Attachments:
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly