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
The IT department has rejected the password you submitted for approval to join the network. Your suggestion was "bobbie." Why di
vodomira [7]

4. Although all of them could be true, this one is most acurate :)

8 0
2 years ago
Read 2 more answers
Can anyone help me with these assignments??? Hands On Assignments- Insertion of Symbols, Special Characters, and Images.... and
Alekssandra [29.7K]

Answer:

yes send me the worksheet

Explanation:

5 0
2 years ago
What is a programming method that provides for interactive modules to a website?
Veseljchak [2.6K]

Answer:

Java?

Explanation:

8 0
3 years ago
While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
Sphinxa [80]
<span>To verify the version of HTML being run on any given page, check the DOCTYPE declaration at the head of the file. Use "inspect element" to view the page source; the DOCTYPE is generally in the header.</span>
5 0
3 years ago
The keyboard,mouse, display,and system units are:​
Ymorist [56]

Answer:

input devices?

Explanation:

Keyboard: It is used to give input through typing of the keys in keyboard. Mouse: It is used to give input through clicking mouse or selecting the options. System unit: It collectively defines the motherboard and CPU of the computer.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Oliva was a sophomore thriving in college when her father was laid off from his job. Even with financial aid, the family could n
    12·1 answer
  • What are the types of action involving data base?
    14·1 answer
  • Using the Invert Selection tool while something is selected in Paint will __________.
    14·1 answer
  • Which of the following is true regarding data acquisition? Because data acquisition is often technical, the research team does n
    15·2 answers
  • 1. A green traffic sign means
    13·1 answer
  • The basic difference between RAM and ROM memory is: Question 5 options: A) RAM is nonvolatile while ROM is volatile. B) RAM is r
    11·1 answer
  • The function of anOR gate can best be described as a gate which provides an output of 1 only when
    10·1 answer
  • Corey wrote a code that will display his name every time he presses the down arrow key but there is a bug in it. Display letter
    13·1 answer
  • The memory capacity in bits for performing the operation y = f (x) using the table lookup method, where x is an 8-bit number and
    7·1 answer
  • Write a Pascal program that will prompt the user to enter the radius of a circle.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!