First of all you didn't provide a presidents_age.txt file you mentioned as a picture in question but using some technology i made it to a text file my own
And here is your Python Program :
Output:
Raw code:
def getAges():
f=open('presidents_age.txt','r').read()
g=f.split('\n')
lt=[]
for i in g:
lt.append(i.split(','))
lt.pop()
dic = dict((x[0],round(float(x[1]))) for x in lt)
return dic
dctPresidents = getAges()
print(dctPresidents)
---------------------------------------------------------------------------------------------------------------------------------------
I clearly made comments in code ..
I take the file and split it into list by '\n' a new line
then again split the list by ',' comma and append it into another list
then I take list[0] and list[1] add to the dictionary as you mentioned that age be a round ..
Thank You ,Hope you Get it ..Give a thumps up .. (Like)
in python please PROBLEM : (15 POINTS Use the file 'presidents age, txt You can download...
Can you solve this in python. Thank you n Exercises 11 through 14, use the file Justices.txt that contains data abou Supreme Court justices, past and present as of Janua 015. Each record of the file the state from which thy ry 2 contains six fields -first name, last name, appointing president, the state from which the were appointed, year appointed, and the year the justice left the court. (For current justices the last field is set to 0.) The...
Write a python code using pandas for this following problem and do not forgot to add comments in your code. Suppose you have a text file called “President.txt” (which is shown below), you have to import this text file in code and using the data of this file, you have to create a new file called “NewPreFile.txt” where you will only show the only selected data of old “president.txt” file. In “NewPreFile.txt” file you need to show the presidents name,...
Based on the data provided of the last 15 presidents amd their ages upon taking office, I need assistance with standard devation and frequency distribution. also need help with drawing a histogram, box-plot, line or bar graph, and a pictogram. thanks so much! Contemporary Mathematics Project - Statistics WORK MUST BE NEATLY WRITTEN OR TYPED S D 1 O b. Collect 15-20 pieces of data from a reputable source. For example, you could find the asking prices of 15-20 houses...
C++ Create an application that searches a file of male and female first names. A link to the file is provided on the class webpage. "FirstNames2015.txt" is a list of the most popular baby names in the United States and was provided by the Social Security Administration. Each line in the file contains a boy's name and a girl's name. The file is space-delimited, meaning that the space character is used to separate the boy name from the girl name....