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
Name at least 3 different portable computer devices that can be purchased
rosijanka [135]

Answer:

Smart Phone

Cameras

Console Controller

Brainliest and please say if its right!!

3 0
3 years ago
Read 2 more answers
Which word did alexander graham bell want adopted as a telephone greeting instead of hello.
Alik [6]

Answer:

I believe it was Ahoy.

Explanation:

I could be wrong though.

7 0
3 years ago
Read 2 more answers
Maria wants to create a portfolio of her photography for college. She takes several pictures and submits them online in order to
max2010maxim [7]

As a JPEG, PNG, or GIF file.

8 0
3 years ago
Read 2 more answers
Is computer a machine?
Anit [1.1K]
Yes a computer works on many smaller items like a motherboard and a powersupply etc. to work in unison to be able to handle things you want to do on it.
8 0
3 years ago
1) In C++ which one of the following characters when used with the cout display the output on the next line?
olga2289 [7]

Answer:

\n,endl are used for the next line

Explanation:

Cout<<"    "<<endl;

cout<<"   " ;

-----------------------------OR------------------------------------------

cout<<"   anything   \n" ;

cout<<"  " ;

6 0
3 years ago
Other questions:
  • You do not need to use any functions beyond the main function in this problem. Initialize an array of int with the values: 4, 6,
    12·1 answer
  • How do the search methods differ for primary and secondary data?
    10·2 answers
  • Sandie is writing a report for her environmental science class. She has asked her older sister who is away at college to proof h
    13·2 answers
  • Advantages of purchasing a software package over developing software in-house include all of the following except ____. Group of
    13·1 answer
  • 1.2 Discuss each of the following terms: (a) data (b) database (c) database management system (d) database application program (
    12·1 answer
  • If you want to open the Navigation pane to do a Find, what should you first click on the Home tab? Paragraph, Editing, Styles, o
    15·1 answer
  • True or false mobile devices need to work within limited screen space
    6·2 answers
  • Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k's value
    13·1 answer
  • Write a program that defines an array of integers and a pointer to an integer. Make the pointer point to the beginning of the ar
    12·1 answer
  • Which of the following shows the correct order of inventions that helped the first computers make calculations?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!