Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help me ans in python , i couldnt post the csv but if you were to answer what would the codes be for the ...

image text in transcribed
image text in transcribed
image text in transcribed
help me ans in python , i couldnt post the csv but if you were to answer what would the codes be for the ...
localhost Favorites Download midten Midterm Jupyer Notebook Midtempter Net apyter Midterm Last Checkpoint: 00/25/2001 (autosaved) Logout Edit View Insert Cell Korrol Widgets Help Trusted Python 30 Q Run Code 2.3 President age As of this writing the US has had 43 Presidents, and 38 are deceased. Let's figure out how long they lived. First, a note. These exercises are designed to give you practice computing with arrays. Since there are only 38 Presidents, you could avoid using arrays by copying each computation 38 times. You wouldn't learn much, so don't do that. Our data from PresidentsUSA.net tell us the birth and death date of each President. The cell below loads these data, along with the Presidents' names. (We've used a table for presentation purposes; you don't need to know about tables to do this exercise.) Note that the Presidents are presented in order by birth date, so for example John F Kennedy (President from 1961-1963) comes after Richard M. Nixon President from 1969-1974) because he was born earlier Question 2.3.1. Compute the number of years between each President's birth and death (their longevity). Put your answers in an array called longevity The first item of longevity should be the longevity of the first president in dead_presidents_years, and so on. Use the arrays death_years and birth years, which are loaded in the cell above. 1. Just run this cell. presidente - Table,read_table('presidents.csv").select("Mamerth Year's Death Year" This is an array of the birth years of the dead presidents. It's the data you see displayed in the Birth Year" column below. birth_years - presidents.column ("Birth Year") This is an array of the death years of the dead presidents. It's the data you see displayed in the "Death Year" column below. The first element of this array describes the same president as the first element of birth years, and so on. death_years - presidents.column("Death Year") presidents.show() It longevity... ka for har Favorites focalhost Downloader pyter Midterm Last Checkpoint: 02/25/2021 (autosaved) Edit View Insert Cell Kernel Widgets Help ch Run Code pynons o [ ]: longevity-... This piece of code puts your results into a table for better display. You can ignore it. presidents.with_column("Longevity", longevity).show() This cell is for me to grade for you, do not change. Question 2.3.2. Suppose each President were still alive in 2021. How old would each one be? I 1: ages today -... This piece of code puts your results into a table for better display. You can ignore it. presidents.with_column ("Age Today, ages_today).show() This coll is for me to grade for you do not change, Question 2.3.3. A colleague points out that John Adams died at age 90, but your answer to Question 1 probably says that he lived 91 yearl John Adams wm born October 30, 1735, and died July 4, 1826. Explain the discrepancy Question 2.3.4. For each President, compute how many more days passed before their death in their year of death than before their birth in the year at tim, For example, that number for George Washington is 295, and for John Adams it's -118. We'l call this number the net additional the day 1: net_additional_life_days - This piece of code puts your resulta into a table for better display You can ignore It. detailed ages.with_column("Net Additional Life Daye", net_additional life_days)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions