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
According to Ernest Hilgard, hypnosis is the result of __________.
goldfiish [28.3K]
The effects of a hidden observer
4 0
3 years ago
Read 2 more answers
How do power strips work?
lapo4ka [179]
What are power strips please
3 0
3 years ago
YO WAS Y’ALLS INSTA/SNAP :3?
FinnZ [79.3K]
Ig : Vxrgxsv & sc : vargas.vv
7 0
2 years ago
Read 2 more answers
Which web application attack is more likely to extract privacy data elements out of a database?
klasskru [66]
<span>The answer is SQL Injection
</span>
This kind of attack is the most prone to extract privacy data elements out of a database. An SQL injection like any other attack may take several attempts to pull it off and is more likely to extract private data. With admin rights or escalated priviledges, SQL injections can be used to enter the database.







6 0
3 years ago
A critical path refers to:
Hatshy [7]

Answer:

A critical path refers to a sequence of task activities whose order and durations directly affect the completion date of a project.

Explanation:

A critical path refers to a sequence of task activities whose order and durations directly affect the completion date of a project. The sequence of task and activities can be either parallel or serial which leads to completion of project at the earliest. Option (a) is false as the critical path directly affects the completion date but not indirectly. Option (c) is false as the tasks can be either serial but not parallel always. Option (d) is false as critical path directly effects the completion date which means 100% of the completion of the project not the 40% of the completion of the project. Option (e) none of these is false as the answer is option (b).

3 0
3 years ago
Other questions:
  • 1. Data in a smart card can be erased
    6·2 answers
  • A food web is shown below. In this food web, energy is transferred directly from the to the
    11·1 answer
  • A system developer needs to provide machine-to-machine interface between an application and a database server in the production
    6·1 answer
  • Explain the ten characteristics of a digital computers​
    14·1 answer
  • Yolanda lost her left foot during her military service, but she has been issued a prosthetic that enables her to walk normally,
    13·1 answer
  • A coffee shop is considering accepting orders and payments through their phone app and have decided to use public key encryption
    10·1 answer
  • What is networking??????????????????????
    8·1 answer
  • Prokaryotes are __________________ and include ________________________.
    8·1 answer
  • A friend asks you to look over the code for an adventure game and help figure out why it won’t work. Which of these options is s
    5·2 answers
  • Mario is designing a page layout for a sports magazine, and he decides to add the image of a cyclist. Which principle of page la
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!