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 do you do 3.4.5 Add parentheses for code hs? I need answers please
stich3 [128]
I don’t know but i hope someone gives u the answer
7 0
3 years ago
Read 2 more answers
If the supply of computer engineers increases at the same time that the demand for these workers decreases, what would be the MO
stiv31 [10]

Answer:

Option C is correct.

Explanation:

When the supply of system engineers rises while demand for such workers falls at the similar period, Wages will drop while competition for employment rises.

According to the law of demand, when the supply of one commodity is increased then the demand for other commodity falls. So, the following option  C is correct according to the following scenario.

Other options are incorrect because they are not relevant according to the following scenario.

5 0
3 years ago
What is one way to maintain Internet safety? a) avoid interacting with people on the Internet. B) avoid giving out information a
Anarel [89]
To be safe on the Internet, we must avoid giving out personal information.
4 0
3 years ago
Which describes the first step a crawler-based search engine uses to find information?
Orlov [11]
<span>Crawler-based search engines are what most of us are familiar with - mainly because that's what Google and Bing are. These companies develop their own software that enables them to build and maintain searchable databases of web pages (the engine), and to organise those pages into the most valuable and pertinent way to the user.</span>
5 0
3 years ago
Read 2 more answers
¿Cuales son las empresas mas exitosas que aún usan hoja de cálculo? porfa es urgentee
dem82 [27]

Answer:excel

Explanation:

6 0
2 years ago
Other questions:
  • How can you have a safe browser experience
    9·1 answer
  • Anyone wanna play Smash Ultimate. I'm a Link main (that doesn't mean I camp, thats young link) who plays competitve with legal s
    8·1 answer
  • Jane is creating a slide that will have a large heading and number of bullet points below it. What slide format should she use?
    12·1 answer
  • A personal computer (pc) or ____ is a small computer system designed to be used by one person at a time.
    12·1 answer
  • Can anybody answer this
    11·1 answer
  • Var1 = 1<br> var2 = 2<br> var3 = "3"<br> print(var1 + var2 + var3)
    5·1 answer
  • Use the drop-down menus to explain how to locate the Consolidate dialog box.
    6·1 answer
  • What is the extension of a Microsoft access database 2013​
    7·2 answers
  • To verify a Windows system meets the minimum processor and memory requirements to install software, use the ________.
    8·1 answer
  • List and describe four services that comprise IT infrastructure, beyond physical devices and software applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!