1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erastova [34]
3 years ago
6

Write a program that requests a state abbreviation as input and displays the justices appointed from that state. The justices sh

ould be ordered by their years served. The output should also display the last name of the appointing president and the length of time served. (Note: For current justices, use 2015 - yrAppointed as their time of service. Otherwise, use yrLeft - yrAppointed.) Also, the program should inform the user if no justices have been appointed from the requested state.
Computers and Technology
1 answer:
ololo11 [35]3 years ago
8 0

Answer:

justice_dict = {}

with open("justices.txt", "r") as fh:

for line in fh:

data = line.split(",")

if int(data[-1]) == 0:

continue

 

yearServed = int(data[-1]) - int(data[-2])

state = data[-3]

president = data[2].split()[-1]

justice = data[0] + " " + data[1]

if state in justice_dict:

current_data = [justice, president, yearServed]

i = 0

inserted = False

for data in justice_dict[state]:

i += 1

if yearServed > data[2]:

inserted= True

justice_dict[state].insert(i, current_data)

break

if not inserted:

justice_dict[state].append(current_data)

 

else:

justice_dict[state] = [[justice, president, yearServed]]

state = input("Enter a state abbreviation: ")

if state in justice_dict:

print("")

print("Justice\t\tAppointing Pres\t\tYrs Served")

for data in justice_dict[state]:

print(data[0] + "\t" + data[1]+ "\t\t\t" + str(data[2]))

else:

print("No justices have been appointed from the requested state")

Explanation:

You might be interested in
How can a user access the Mailbox Cleanup tools?
antiseptic1488 [7]

Answer:

Sorry this isn’t an answer but does anyone know of a quizlet for the Microsoft Office course because I can’t find anything anywhere. Help a fellow student out. I need answers.

Explanation:

8 0
2 years ago
Read 2 more answers
What are 2 plants that grow best in our soil type ​
ser-zykov [4K]

Answer:

Explanation: What type of soil?

3 0
3 years ago
Brenda wants to finish her presentation with a summary slide . She wants three key messages to appear on each of the photo clips
Sav [38]

Brenda can first include an image and then include text. Lastly she can just provide an enhanced effect to the text to appear one by one each photo clip.

4 0
3 years ago
Read 2 more answers
What is the way to discover requirments for software projects ?
Sav [38]

Learn about requirement analysis by knowing how to identify business requirements and software requirements with ... Here are the objectives for performing requirement analysis in the early stage of a software project:.

6 0
2 years ago
A _____ is one in which the size of the web page and the size of its elements are set regardless of the screen resolution..
mixas84 [53]

Answer: Fixed layout

Explanation:

Fixed layout  is the arrangement of any website page or webpage that is featured with fixed size on any screen resolution .Fixed layout displays all the components and tools of the page with a fixed percentage.

  • The width or percentage cannot be changed or altered as it is fixed.The user experiences same width of the page and elements in any computing resolution.

7 0
3 years ago
Other questions:
  • What is the final step used when designing an algorithm?
    14·1 answer
  • Which of the following is something that scientists often seek by using computer models and simulations?
    8·2 answers
  • 3. Assume a disk drive from the late 1990s is configured as follows. The total storage is approximately 675MB divided among 15 s
    11·1 answer
  • B) If you send me an email, then I will finish my program. If you do not send me an email, then I will go to sleep early. Theref
    10·1 answer
  • Which of the following is the correct ordering of operating systems, oldest to newest?
    5·2 answers
  • For some reason, Danica's classmate George could not find the registered symbol in the symbol gallery. He is selling
    14·1 answer
  • Assume that strikeCounter has already been declared to be a "pointer to int". Assume further that strikeCounter has been initial
    7·1 answer
  • Why we call the standard deviation of the sample statistic asstandard error of the statistic?
    14·1 answer
  • Lori Redford, who has been a member of the Project Management group, was recently promoted to manager of the team. She has been
    12·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!