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
Lynna [10]
3 years ago
15

Make a Backwards Phonebook from a Regular Phonebook

Computers and Technology
1 answer:
Dima020 [189]3 years ago
7 0

Answer:

Code in Python is given. Take note of the instruction in bold font

Explanation:

You will need to update the below two lines in your system based on the file path -

backward_phone_number('F:\\phone_number_input.txt','F:\\phone_number_output.txt')

def backward_phone_number(input_file,output_file):

   ph_num_dictionary={}

   entries=[]

   #########################################################

   with open(input_file,'r') as read_file:

       entries=read_file.readlines()[1:]

   for entry in entries:

       ph_num_name=entry.split()

       ph_number=ph_num_name[1].strip()

       name=ph_num_name[0].strip()

       if ph_num_dictionary.get(ph_number)==None:

           name_list=[name]

           ph_num_dictionary[ph_number]=name_list

       else:

           ph_num_dictionary.get(ph_number).append(name)

   #########################################################

   ph_num_dictionary = dict(sorted(ph_num_dictionary.items(),key=lambda pair:pair[0]))

   with open(output_file,'w+') as write_file:

       write_file.write('Telephone Number\tName\r\n')

       for num,name in ph_num_dictionary.items():

           if len(name)==1:

               write_file.write(num+'\t'+name[0]+'\r\n')

           else:

               name.sort()

               for person in name:

                   write_file.write(num + '\t' + person + '\r\n')

backward_phone_number('F:\\phone_number_input.txt','F:\\phone_number_output.txt')

You might be interested in
In computer science, what is the name for a series of steps used to solve a problem?
liraira [26]

Answer:

Algorithm

Explanation:

It is the step by step procedure,which defines a set of instructions which is to be carried out by the computer

5 0
2 years ago
Giving 5 stars, a Thanks, 80 points, and Branliest to whoever answers them correctly.
Mrac [35]

Answer:

Explanation:

The answer is ludonarrative.

Please mark me brainliest.

4 0
2 years ago
The ____ command will confirm the system directory that you are currently in
stira [4]
Im pretty sure the answer is PWD
7 0
3 years ago
Big Data _______________. Relies on the use of unstructured data imposes a structure on data when it is captured relies on the u
kifflom [539]

Answer:

captures data in whatever format it naturally exists

Explanation:

quizletBig Data _______________. Relies on the use of unstructured data imposes a structure on data when it is captured relies on the use of structured data captures data in whatever format it naturally exists

4 0
2 years ago
Input 3 positive integers from the terminal, determine if tlrey are valid sides of a triangle. If the sides do form a valid tria
butalik [34]

Answer:

In Python:

side1 = float(input("Side 1: "))

side2 = float(input("Side 2: "))

side3 = float(input("Side 3: "))

if side1>0 and side2>0 and side3>0:

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

       if side1 == side2 == side3:

           print("Equilateral Triangle")

       elif side1 == side2 or side1 == side3 or side2 == side3:

           print("Isosceles Triangle")

       else:

           print("Scalene Triangle")

   else:

       print("Invalid Triangle")

else:

   print("Invalid Triangle")

Explanation:

The next three lines get the input of the sides of the triangle

<em>side1 = float(input("Side 1: ")) </em>

<em>side2 = float(input("Side 2: ")) </em>

<em>side3 = float(input("Side 3: ")) </em>

If all sides are positive

if side1>0 and side2>0 and side3>0:

Check if the sides are valid using the following condition

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

Check if the triangle is equilateral

<em>        if side1 == side2 == side3: </em>

<em>            print("Equilateral Triangle") </em>

Check if the triangle is isosceles

<em>        elif side1 == side2 or side1 == side3 or side2 == side3: </em>

<em>            print("Isosceles Triangle") </em>

Otherwise, it is scalene

<em>        else: </em>

<em>            print("Scalene Triangle") </em>

Print invalid, if the sides do not make a valid triangle

<em>    else: </em>

<em>        print("Invalid Triangle") </em>

Print invalid, if the any of the sides are negative

<em>else: </em>

<em>    print("Invalid Triangle")</em>

4 0
2 years ago
Other questions:
  • 1. What arguments can you make for the idea of a single language for all programming domains
    10·1 answer
  • An enterprise system is a packaged software application that helps integrate various ___________ in a company.
    15·2 answers
  • What dose AUP stand for??????????
    15·2 answers
  • Consider the class ScopeTest defined this way:
    15·1 answer
  • Dorothy needs to edit JPEG and GIF files in a multimedia application. Which software can Dorothy use to edit these files?
    8·2 answers
  • You have created a PivotChart showing sales by quarter by sales rep. Before presenting it to management, you notice thename of a
    7·1 answer
  • Is it true or false and incomplete doing can be saved in Paint​
    15·1 answer
  • Write a method, findMax(), that takes in two integers and returns the largest value. Ex: If the program input is: 4 2 the method
    8·1 answer
  • Old systems can be useful when designing new computer software.<br> True or False
    7·2 answers
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!