• Go to the Anaconda Website and select your computer’s operating system. • Locate your systems download Installing on Windows 1. Select and double click the 64-Bit Graphical Installer 2. When the...

1 answer below »
2 Python coding Assignments in total. DUE TIME: 5/7 AT 12PM Central standard time.Please install anaconda to use jupyter notebook to access the python assignment. (instruction attached)Please write out the python codes for each question according to the direction!


• Go to the Anaconda Website and select your computer’s operating system. • Locate your systems download Installing on Windows 1. Select and double click the 64-Bit Graphical Installer 2. When the screen below appears, click on Next 3. Read the license agreement and click on I Agree (If you agree ☺) https://www.anaconda.com/products/individual 4. Click on Next 5. Note your installation location and click Next 6. This is an important part of the installation process. The recommended approach is to not check the box to add Anaconda to your path. This means you will have to use Anaconda Navigator or the Anaconda Command Prompt (located in the Start Menu under "Anaconda") when you wish to use Anaconda (you can always add Anaconda to your PATH later if you don't check the box now). 7. Click on Next 8.Click on Next 8. Click on Finish 9. Congratulations you have successfully installed Anaconda ! State,State,State Capital Alabama,AL,Montgomery Alaska,AK,Juneau Arizona,AZ,Phoenix Arkansas,AR,Little Rock California,CA,Sacramento Colorado,CO,Denver Connecticut,CT,Hartford Delaware,DE,Dover Florida,FL,Tallahassee Georgia,GA,Atlanta Hawaii,HI,Honolulu Idaho,ID,Boise Illinois,IL,Springfield Indiana,IN,Indianapolis Iowa,IA,Des Moines Kansas,KS,Topeka Kentucky,KY,Frankfort Louisiana,LA,Baton Rouge Maine,ME,Augusta Maryland,MD,Annapolis Massachusetts,MA,Boston Michigan,MI,Lansing Minnesota,MN,St. Paul Mississippi,MS,Jackson Missouri,MO,Jefferson City Montana,MT,Helena Nebraska,NE,Lincoln Nevada,NV,Carson City New Hampshire,NH,Concord New Jersey,NJ,Trenton New Mexico,NM,Santa Fe New York,NY,Albany North Carolina,NC,Raleigh North Dakota,ND,Bismarck Ohio,OH,Columbus Oklahoma,OK,Oklahoma City Oregon,OR,Salem Pennsylvania,PA,Harrisburg Rhode Island,RI,Providence South Carolina,SC,Columbia South Dakota,SD,Pierre Tennessee,TN,Nashville Texas,TX,Austin Utah,UT,Salt Lake City Vermont,VT,Montpelier Virginia,VA,Richmond Washington,WA,Olympia West Virginia,WV,Charleston Wisconsin,WI,Madison Wyoming,WY,Cheyenne
Answered Same DayMay 07, 2021

Answer To: • Go to the Anaconda Website and select your computer’s operating system. • Locate your systems...

Dhairya answered on May 07 2021
155 Votes
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Instructions\n",
"\n",
"* Fill in the code and markdown cells. Please don't change the order of the questions, or move the question cells.\n",
"* Feel free to add code and markdown cells if you need them.\n",
"\n",
"* **KEEP SAVING YOUR WORK**\n",
"* Submit to Canvas at the end.\n",
"* Good Luck !\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 1 : \n",
"### 5 pts \n",
"Store all of the words with more than 4 letters in a list. Use the **append** method for lists and the **strip** method for strings to get rid of punctuation. "
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [],
"source": [
"sentence = \"\"\"S
now White likes to eat apples. So, she went to the forest to acquire some. \n",
"She got attacked by a wolf and almost died of food poisoning because of an evil witch. She however declared: I love apples.\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['White',\n",
" 'likes',\n",
" 'apples',\n",
" 'forest',\n",
" 'acquire',\n",
" 'attacked',\n",
" 'almost',\n",
" 'poisoning',\n",
" 'because',\n",
" 'witch',\n",
" 'however',\n",
" 'declared',\n",
" 'apples']"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# write your code here\n",
"list_all_words = sentence.split(' ')\n",
"list_words_length_greater_than_4 = []\n",
"for word in list_all_words:\n",
" stripped_word = word.strip(',.:')\n",
" if len(stripped_word) > 4:\n",
" list_words_length_greater_than_4.append(stripped_word)\n",
"list_words_length_greater_than_4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 2A : \n",
"### 5 pts \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a program that asks the user to enter a message that they would like to code, and then output the coded message.\n",
"The coding process is the following: insert the characters 'ay' between every letter of the given message.\n",
"\n",
"For example: \n",
"\n",
"Input: hello \n",
"Output: hayeaylaylayoay\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a message that you would like to code: hello\n"
]
},
{
"data": {
"text/plain": [
"'hayeaylaylayoay'"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# write your code here\n",
"message = input('Enter a message that you would like to code: ')\n",
"output = ''\n",
"for char in message:\n",
" output += char + 'ay'\n",
"output"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 2B: \n",
"### 10 pts \n",
"\n",
"Write a coder function that takes a string input and adds 'ay' after the first char and then every other two. Or in other words adds 'ay' after every even-indexed character of the given string. \n",
"\n",
"Include a docstring to the function and illustrate its use by calling help on it.\n",
"\n",
"For example: \n",
"\n",
"Input: hello \n",
"Output: hayelayloay "
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a message that you would like to code: hello\n",
"Help on function coder_function in module __main__:\n",
"\n",
"coder_function(input_str: str)\n",
" Returns a coded message for your input message by adding 'ay' after every even-indexed character of the given string.\n",
"\n"
]
}
],
"source": [
"# write your code here\n",
"def coder_function(input_str:str):\n",
" '''Returns a coded message for your input message by adding 'ay' after every even-indexed character of the given string.'''\n",
" output = ''\n",
" for i in range(len(input_str)): # looping for each character in message\n",
" if i % 2 == 0: # if even index\n",
" output += input_str[i] + 'ay'\n",
" else: # else odd index\n",
" output += input_str[i] \n",
" return output \n",
" \n",
"message = input('Enter a message that you would like to code: ')\n",
"help(coder_function) # calling help\n",
"\n",
"ouptut = coder_function(message)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 3: \n",
"### 20 pts \n",
"Write a function that takes three arguments: a principal amount, annual rate of return, and number of years and displays the year on year growth of an initial investment.\n",
"\n",
"Input1: \n",
"invest(100,0.04,1) \n",
"\n",
"Desired output1: \n",
"year 1: 104.00 dollars \n",
"\n",
"Input2: invest(100,0.04,3) \n",
"\n",
"Desired output1: \n",
"year 1: 104.00 dollars \n",
"year 2: 108.16 dollars \n",
"year 3: 112.49 dollars \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Year 1: 104.00 dollars\n",
"Year 2: 108.16 dollars\n",
"Year 3: 112.49 dollars\n"
]
}
],
"source": [
"# write your code here\n",
"def invest(principal, rate_return, years):\n",
" '''Returns the year on year growth of the initial investment.'''\n",
" \n",
" for year in range(years):\n",
" principal += principal * rate_return \n",
" print('Year {}: {:.2f} dollars'.format(year + 1, principal))\n",
"\n",
"invest(100, 0.04, 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 4A : \n",
"### 20 pts \n",
"\n",
"To answer this question you will be required to read with Python the given text file 'us_state_info.txt' and perform manipulations to extract the data and answer the following questions. \n",
"\n",
"The given file contains in order, for each US state,its name, its two letter abbreviation and its capital city.\n",
"\n",
"1) Extract the State name and the state abbreviation from the provided text file and create a dictionary that will have for keys the state names and for values the respective state abbreviation.\n",
"\n",
"2) Extract the State name and the state capital from the provided text file and create another dictionary that will have for keys the state names and for values the respective state capital."
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Alabama': 'AL', 'Alaska': 'AK', 'Arizona': 'AZ', 'Arkansas': 'AR', 'California': 'CA', 'Colorado': 'CO', 'Connecticut': 'CT', 'Delaware': 'DE', 'Florida': 'FL', 'Georgia': 'GA', 'Hawaii': 'HI', 'Idaho': 'ID', 'Illinois': 'IL', 'Indiana': 'IN', 'Iowa': 'IA', 'Kansas': 'KS', 'Kentucky': 'KY', 'Louisiana': 'LA', 'Maine': 'ME', 'Maryland': 'MD', 'Massachusetts': 'MA', 'Michigan': 'MI', 'Minnesota': 'MN', 'Mississippi': 'MS', 'Missouri': 'MO', 'Montana': 'MT', 'Nebraska': 'NE', 'Nevada': 'NV', 'New Hampshire': 'NH', 'New Jersey': 'NJ', 'New Mexico': 'NM', 'New York': 'NY', 'North Carolina': 'NC', 'North Dakota': 'ND', 'Ohio': 'OH', 'Oklahoma': 'OK', 'Oregon': 'OR', 'Pennsylvania': 'PA', 'Rhode Island': 'RI', 'South Carolina': 'SC', 'South Dakota': 'SD', 'Tennessee': 'TN', 'Texas': 'TX', 'Utah': 'UT', 'Vermont': 'VT', 'Virginia': 'VA', 'Washington': 'WA', 'West Virginia': 'WV', 'Wisconsin': 'WI', 'Wyoming': 'WY'}\n",
"{'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', 'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver', 'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee', 'Georgia': 'Atlanta', 'Hawaii': 'Honolulu', 'Idaho': 'Boise', 'Illinois':...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here