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
We initialize the parameters to all zero values and run the linear perceptron algorithm through these points in a particular ord
Usimov [2.4K]

The main aim of running the parameters in the linear perceptron algorithm is to be able to develop a machine learning algorithm for binary classification tasks.

<h3>What is a linear perceptron algorithm?</h3>

This refers to the linear classification algorithm that is used in machine learning.

This is done in order to learn a decision boundary that divides different classes using a hyperplane.

Hence, we can see that your question is incomplete because the parameters are not included, hence a general overview was given to give you a better understanding of the concept.

Read more about machine learning here:

brainly.com/question/25523571

#SPJ1

7 0
2 years ago
On which tab are the print commands in Excel 2016 accessed?
galina1969 [7]

Answer:

file (backstage)

Explanation:

edginuity 2020

3 0
3 years ago
Read 2 more answers
Read the following example cover letter:
enot [183]

Answer:

All should be added.

Explanation:

All of these are important to your cover letter to make it seem professional.

Hope this helped

3 0
3 years ago
Read 2 more answers
What type of desktop system is Sarah using in the following scenario? Sarah types the phrase “Open Document 3” onto a black scre
Vedmedyk [2.9K]

I'd go with command-line interface.

A CLI enables users to type commands in a console or a terminal window expressed as a sequence of characters and presses the enter key on the keyboard to execute that command. And in this case, Sarah is typing an “open document 3” command to the command-line interface to open a file in her computer.

4 0
3 years ago
Which of the following would not be considered a polymer?
miskamm [114]
Correct answer would be <span>A) <u>quartz</u></span>.  Plastic, nylon, and rubber can all be broken down or heated to make it expand, and be used in common products.

Hope this helped :)
3 0
3 years ago
Read 2 more answers
Other questions:
  • Consider the two computers A and B with the clock cycle times 100 ps and 150 ps respectively for some program. The number of cyc
    5·2 answers
  • rob just got a new idea for the movie he's making, and he wants to put in late hours to get it done. Which of the following stat
    10·1 answer
  • What is the next series of dragon ball super
    6·2 answers
  • The ability for a protocol or program to determine that something went wrong is known as_________.
    15·1 answer
  • "Managers and department heads across the nation strategize on a weekly, if not daily, basis. For the past three quarters, telep
    6·1 answer
  • The way a program is proceed is know as control flow and are :Sequence(one line after the other), Decision-making(either this or
    8·1 answer
  • Suppose we are comparing the implementations of insertion sort and merge sort on the same machine(You don’t need to know the alg
    13·1 answer
  • Write a program to find the sum of first 10 even numbers in qbasic​
    15·1 answer
  • What are the two biggest strength as a student
    7·2 answers
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!