This is similar to the last problem, except that the first number on a line is an ID number that identifies an account. The same ID number may appear on any number of lines. Use a Dictionary to accumulate, for each ID, the sum of all the numbers that are on all the lines with that ID number. Call the input file id_data.txt. Write an output file called ID_sums.txt. On each line of the output fille, print an ID number and the sum. Sort the lines by the numerical order of the IDs

Answers

Answer 1

Answer:

Following are the code to this question:

def getSum(ID):#defining a method getSum that accept an ID

   t= 0#defining a variable t

   while ID!= 0:#defining while loop to check ID not equal to 0

       t+= ID % 10# holding remainder value

       ID = ID // 10#holding quotient value

   return t#return total value

def readRecord(S):#defining a method readRecord that hold list  

   f_Read = open("idInfo.txt","r")#defining a variable f_Read to open file

   for C_ID in f_Read:#defining for loop to hold file value  

       C_ID = C_ID.replace('\n', '')#use replace method

       S[C_ID] = getSum(int(C_ID))#use list to method value

   f_Read.close()#close file

def sortRecord(ID_List, t_List):#defining a sortRecord

   for x in range(len(ID_List) - 1):#defining for loop to calculate the length of list  

       for y in range(0, len(ID_List) - x - 1):#defining for loop to calculate the length of list

           if ID_List[y] > ID_List[y+1]:#defining if block to check value is greater

               ID_List[y], ID_List[y+1] = ID_List[y+1], ID_List[y]#swap the value

               t_List[y], t_List[y+1] = t_List[y+1], t_List[y]#swap the value

def showReport(ID, t):#defining a method showReport that accept id and t

   for i in range(len(ID)):#defining for loop to hold index value

       print(ID[i]," ",t[i])#print index value

def writeRecord(ID_List, t_List):#defining a method writeRecord that accept two list

   f_Write = open("idSorted.txt","w")#defining a variable f_Write to hold store value in file

   for i in range(len(ID_List)):#defining a for loop to store value with index

       f_Write.write(ID_List[i])#hold list value

       f_Write.write(" ")    #for space

       f_Write.write(str(t_List[i]) + "\n")# add index value

   f_Write.close()#close file

def run():#defining method run

   S = {}#defining an empty list

   readRecord(S)#passing list into readRecord method

   ID_List = list(S.keys())#defining a variable that holds key value in list

   t_List = list(S.values())#defining a variable that holds values value in list

   sortRecord(ID_List, t_List)#calling a method sortRecord by passing value

   showReport(ID_List, t_List)#calling a method showReport by passing value

   writeRecord(ID_List, t_List)#calling a method writeRecord by passing value

if "run":

   run()

Output:

Please find the attached file.

Explanation:

In the above program code, 6 method getSum, readRecord, sortRecord,showReport, writeRecord, and run method is defined, in which getSum and readRecord is used a single list store value in parameters, and in other methods, it accepts two parameter to store value in key and values form and use a txt file to store and take value.    

In the run method, an empty list s is declared, that pass into the variable ID_List and t_List, and call the method, in this program two a text file "idInfo.txt" is used, that holds some value in the file, and create another file that is "idSorted.txt", in this file it stores the value in the numerical order of the ID's.

This Is Similar To The Last Problem, Except That The First Number On A Line Is An ID Number That Identifies

Related Questions

If you need to change the typeface of a document, which menu will you choose?

Answers

Format menu

Format menu is used to change typeface of a document

Consider the following Java program. Describe what it does in response to specific operations of the mouse, and how it does it. (You are encouraged to run the program for yourself to test its behavior. Then read through the program carefully to understand how that behavior arises.)
import java.awt.event.*;
import javax.swing.*;
public class MouseWhisperer extends JFrame implements MouseListener {
MouseWhisperer() {
super("COME CLOSER");
setSize(300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addMouseListener(this);
setVisible(true);
}
public void mouseClicked(MouseEvent e) { setTitle("OUCH"); }
public void mousePressed(MouseEvent e) { setTitle("LET GO"); }
public void mouseReleased(MouseEvent e) { setTitle("WHEW"); }
public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); }
public void mouseExited(MouseEvent e) { setTitle("COME CLOSER"); }
public static void main(String[] args) { new MouseWhisperer(); }
}

Answers

Answer:

Explanation:

This java code creates a windowed java application that is 300x100 pixels large. The title of the program which is located in the bar at the top of the program starts off by saying "Come Closer". If you move the mouse over the program the program detects it. Then if you press the program it changes the title to "Let Go". If you press the program and immediately let go it changes the title to "Ouch" but if you hold for 1 or 2 seconds and let go it changes the title to "Whew". Finally, if you move the mouse cursor away from the program it changes the title back to "Come Closer"

Review how to write a for loop by choosing the output of this short program.

for counter in range(3):
print(counter * 2)


Please explain it to me, I’m not learning Bc I don’t have a teacher.

Answers

Answer:

The output is:

0

2

4

Explanation:

First of all, the print statement must be indented with a tab, otherwise it is not part of the for loop.

The range(3) creates an array with values 0,1,2. The variable 'counter' gets those values one after another, and the print statement outputs this value doubled, hence the 0, 2 and 4 output.

Organize the steps involved in the colorization of an old black-and-white photo.

Use dodge, burn, and noise tools.
Restore the old photo.
Adjust the RGB (or CMYK) ratio.
Select the desired area.

Answers

Answer:

How to recolor black and white photos?

Learn how to colorize black and white photos in only 4 minutes

Cleaning the image. When you open the image in Photoshop, convert it to Smart Object and start by removing the scratches and dust. ...

Adjusting the image tones and contrast. If you're working with a sepia image, add a Black & White adjustment layer to neutralize the tones. ...

Converting the image to CMYK. ...

Adding color.

Explanation:

Answer:

1) restore the old photo

2) select the desired area

3) Adjust the RGB (or CMYK) ratio

4) Use dodge, burn, and noise tools

Explanation: correct on Edmentum

David bought 5.2 pounds of oranges for $1.20 per pound . how much did david spend ..................................................... explain to me how you did it

Answers

Answer:

David spent $6.24.

Explanation:

5.2 times 1.2

Please help this computer science question(Pseudocode and Trace table)

Answers

Answer:

can u explain more specific plz

Explanation:

Brainliest to right answer.
If you dare put an answer that does not relate to the question I swear.
Match the terms with their functions.
:)​

(2nd time posting this question)​

Answers

Answer:

1st is ambient noise

2nd is first person narration

3rd is dynamic microphone

4th is sound affects

5th is sound balance

6th is condenser microphone

Explanation:

hope this helped brainliest pls

The Boolean operators include which of the following?

A. and, or, not
B. to, for, from
C. a, an, the
D. is, are, not

Answers

Answer:

The answer is A. and, or, not

Explanation:

Using a Boolean search can help narrow your results. A Boolean search is a query that uses the Boolean operators AND, OR, and NOT, along with quotation marks, to limit the number of results. For example, searching the terms Alexander the Great AND conquests will provide results about Alexander, great, and their conquests.

Bradley is working on a program that uses different classes in specific relationships. Help him remember what these relationships are called.

(blank) is when a class uses objects of another class.

A. Aggregation
B. Inheritance
C. Dependency

(blank) is a special case in which one object “owns” another.

A. Dependency
B. Composition
C. Aggregation

Answers

Answer:

First one is INHERITANCE. Second one is AGGREGATION.

Which of the following are risks to a network?
a Sending emails
b. Granting administrator access to a non-administrator
c. Opening files from unknown senders
d. Unwanted advertisements

Answers

Answer:

option  b and c are correct answers.

Explanation:

Let see each option in detail.

a) Sending email is not a risk.

b) Granting access is a problem because the other person can undermine the network

c) Unknow senders can send virus or other malicious code to corrupts you data.

d) Unwanted advertisement is not a big deal.

Answer:

Granting administrator access to a non-administrator  

 Opening files from unknown senders

Explanation:

Psst those are the answers

Show the dynamic and speculation execution for the following code

Add F2,F3,F4
Loop : Lw F2,0(R1)
Subi R1,R1,8
Div F9,F10,F11
Sw F9,5(R2)
Bne R1,Loop




- 1 Fp & 1 Int operation can issue at the same cycle
- 3 execution stage
- 2 commit stage
- FP : 2 cycle
- Lw : 2 cycle
- ALU : 3 cycle
- Two iteration

Answers

Answerf9,f10,fll

Explanation:

What is cybercrime?
Describe some of the various cybercrimes?
What are the laws that govern cybercrimes?
What can we do to prevent being a victim?

Remember to provide examples.

Answers

Answer:

criminal activities carried out by means of computers or the internet is known as cyber crime.




Predict the output
int ma3, n = 5, p=4
if(m==n&&n!=p)
{
System.out.println (m*n) ;
system.out.println(n%p);
}
if (m!=n) " (n==p)

System, out println (m+n)
System.out printen (m-n))
}​

Answers

Answer:

the output will be "hello word"

Any one know 23 24 25?

Answers

23- B
24- C
25- i’m not sure what it is but the definition to it is that it represents a range of text that has been deleted from a document. so which ever one is closest to it.

Helen is working on her colleague’s photos. She came across this particular photo and was confused about which effect the photographer had used in the photo. Can you help her figure out the effect?
The effect used in the photo is

Answers

Answer:

it could be Tilt-shift - Tilt-shift effect - or Miniature faking.

Explanation:

Fill in the blank are always hard when the system has a set answer. But photographers commonly use the tilt-shift effect to focus on a certain part of the image while blurring the rest of the photograph. They refer to this as selective focus. You can use the tilt-shift effect and selective focus for miniature faking. This is where the subjects in the photograph appear miniaturized. Hope this helps

Answer: tilt-shift

Explanation:

PLS HELP ME!! WILL GIVE BRAINLIEST

Read the following block of CSS code, and then answer the question.


body

{

position: relative;

left: 50px;

top: 50px;

}


What effect would this code have on the display of a box?

All content would be placed 50 pixels to the left of the current box.

The current box would be located 50 pixels to the left of the page border.

The current box would be located 50 pixels to the left of the next page element.

The current box would be located 50 pixels to the left of the first textual element.

Answers

B i think sorry if I’m wrong

Answer:

it is maybe:

A.  All content would be placed 50 pixels to the left of the current box.

Explanation:

Write a version of the sequential search algorithm that can be used to search a sorted list. Write a program to test the sequential search algorithm. Use either the function bubbleSort or insertionSort to sort the list before the search. Your program should prompt the user to enter 10 digits and then prompt the user to enter a digit to search - if the list contains this digit, output its position to the console:

Answers

Answer:

#include <iostream>

using namespace std;

void insertionSort(int myArr[]){

  int currentvalue, position;

  for (int i = 1; i < myArr.size(); ++i){

    currentvalue = myArr[i] ;

    position = i;

    while (position>0 and myArr[position-1]>currentvalue){

        myArr[position]= myArr[position-1] ;

        position = position-1 ;

     }

    myArr[position]= currentvalue;

  }

}

int main(){

   int numberList[10], search;

   for (int x = 0; x < 10; ++x){

       cin>> numberList[x];

   }

   insertionSort(numberList);

   cout << "Enter the search term/number: ";

   cin>> search;

   for (int i = 0; < 10; ++x){

       if (search == number[i]){

           cout<< i;

           break;

       } else {

           cout<< "Number does not exist.";

       }

}

}

Explanation:

The C++ source code defines the insertionSort void function, then prompts the user ten times to fill the array numberList. It uses the insertion sort algorithm to sort the array of ten items and then a number is searched using a sequential search algorithm.

Most slide layouts include at least one ________ by default.
Question 2 options:

placeholder

action button

transition

animation

Answers

Hey

I think that the answer placeholder :)

Sry if im wrong tho

Answer:

The answer is placeholder.

CPU is an abbbreviation for
1.Central processing unit
2.Computer processing unit
3.Control processing unit

Answers

Answer:

1.Central processing unit

Explanation:

CPU is an abbreviation for Central processing unit.

who here plays overwatch or paladins ps4? I'm getting overwatch soon and need people to play with. please don't report this.​

Answers

Answer:

I'm down to play

Explanation:

PLS HELP ASAP- Select the correct text in the passage.
Which concept explained in the paragraph below means that data always remains consistent?

Specific programs have some tasks that a computer must perform in parallel with others. These tasks (such as the performance of the same set of operations on different data sets) often work in parallel clusters. In such cases, a separate thread of execution handles each separate task. You can think of a thread as a sequence of instructions that computers can manage independently.
It is possible for different threads to access the same data elements and change their values, and this can lead to an inconsistent state of information. For instance, if multiple programs access a shared variable x and change its value, the variable will not contain the correct value at the end of the programs. We can prevent such inconsistencies by using locks. A thread puts a lock on shared data, and releases this lock only after completing its operations.

Answers

Answer:

reread the text

Explanation:

I do it it helps

Answer:

A thread puts a lock on shared data, and releases this lock only after completing its operations.

The last sentance

Explanation: TRUST ME ISTG THATS THE ANSWER

What is a segment?
1. a set of data or information
2. the main piece of cable in the network
3. a piece of hardware connecting pieces of cable
4. a length of uninterrupted cable connecting two devices

Answers

Segmentation divides a computer network into smaller parts. The purpose is to improve network performance and security.

Hope this helps!!

Name the application used for creating Presentations___
1.MS PowerPoint
2.MS Word
3MS Excel

Answers

Keynote is great for presentation

Answer:

1.MS PowerPoint

how ssd is better than normal sata and pata HDD​

Answers


The HDD offers high storage capacities at a low price, while the SSD provides blazing fast access speeds at a higher cost.

what is a Tiny Area Network?

Answers

Tiny area network is a small LAN(land area network )that only has a small nodes and is typically found in home or small office environment.

Create a Java program that takes input of a list of integers from the user, stores them into an array and then finally uses the array contents to output the list of integers in reverse. The user's input begins with the number of integers to be stored in the array. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers.

Answers

Answer:

This question is answered using Java

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 System.out.print("Length of array: ");

 int len = input.nextInt();

 int[] intArray = new int[len];

 for(int i = 0; i<len;i++){

     intArray[i] = input.nextInt();

 }

 for(int i = len-1; i>=0;i--){

     System.out.print(intArray[i]+" ");

 }

}

}

Explanation:

This line prompts user for length of array

 System.out.print("Length of array: ");

This gets the length of the arrau

 int len = input.nextInt();

This declares the array as integer

 int[] intArray = new int[len];

The following iteration gets input to the array

 for(int i = 0; i<len;i++){

     intArray[i] = input.nextInt();

 }

The following iteration prints the array in reversed order

 for(int i = len-1; i>=0;i--){

     System.out.print(intArray[i]+" ");

 }

The inside color of a shape or object is it’s

Answers

Answer:

A.

Explanation:

If I am working in a document and wish to follow a hyperlink, what should I do?
Copy the link and paste it in your web browser.
Hold the Control key and click on the link.
Click on the link.
Select Ctrl+K.

Answers

Answer:

Click on the link or copy and paste it to your browser

Explanation:

The system where the unit of measurement is centimeter

Answers

Answer:

International System of Units

Explanation:

Writea SELECT statement that uses the ranking functions to rank products by the total quantity sold. Returnthese columns:The product_name column from the Products tableA column named total_quantity that shows the sum of the quantity for each product in theOrder_Items tableA column named rank that uses the RANK function to rank the total quantity in descending sequenceA column named dense_rank that uses the DENSE_RANK function to rank the total quantity in descending sequence

Answers

Answer:

SELECT  product_name, SUM(DISTINCT quantity) AS total_quantity

RANK() OVER (PARTITION BY total_quantity ORDER BY product_name) AS rank,

DENSE_RANK () OVER (ORDER BY quantity DESC) AS dense_rank

FROM Order_items

JOIN products ON Order_items.product_id = products.product_id

GROUP BY product_id

Explanation:

The SQL query returns four columns namely, product name, total quantity, rank and dense rank. The query uses the rank and the dense rank function to return the rows according to numeric ranks.

Other Questions
whats the answer to this question? PLEASE SOMEONE ACTUALLY HELP I WILL MARK BRAINLIEST Which organ is responsible for storing urine?kidneylarge intestineanusbladder Despus del verano sin lluvia, solo podamos usar agua para los jardines los lunes. A) La inundacinDos das despus del huracn, todava no podan ver por las noches en su casa. B) La sequaTuvieron muchas lluvias en una ciudad y no podan conducir. C) El humoCuando estbamos de vacaciones, vimos los incendios en el bosque. D) La falta de electricidadHace mucho viento; el viento es muy fuerte cuando viene ________. un terremoto un huracn una avalancha una vegetacin what dose the nucleus control Sedimentary rock is made from sediments that come from other rocks. These sediments form from _____ of the rocks. An envelope is 60 centimeters wide. About how many inches wide is the envelope? (1 inch 2.5 centimeters) i suck at word problems i dont understand both of these The Odyssey Anticipation GuideAgree or Disagree about the statement "You should take care of yourself and your family first, then worry about the rest of the world"-Why do you feel that way about that statement?-What personal experience in your life do you have with that idea? Is 218 the correct answer, please this is worth a lot How fast is the Australian plate moving towards the sunda plate?A) 37 mm/yearB) 64 mm/yr C) 67 mm/yr help me please :( There are 5 hockey games and 7 football games happening in the upcoming month. You decide to attend 3 games by picking at random. What is the probability that you pick 3 football games? Leave your answer as a simplified fraction. Considering 2N2H4(g) + N2O4(g) -> 3N2(g) +4H2O(g) How many grams of N2H4 will be needed to produce 121.3g of H2O Read the excerpt from "Tools of the Spymaster." The author's main purpose in this excerpt is to The idea of invisible ink had been around for a long time. Write using lemon juice as ink, for instance, and the writing will be invisible. Heat the paper, and the writing will appear, looking as if it were written in brown ink. British agents used two types of ink. One could be made visible by holding the paper over the flame of a candle; the other could be read by applying a common chemical. Major John Andre, the chief British intelligence officer in New York, told his agents to put an Fin the corner of letters containing invisible ink needing fire to read and A for those needing acid, O explain the use of invisible ink during the American Revolution. O expose unsuccessful spying tactics used by the British during the American Revolution. O teach readers how to create secret documents using common chemicals. O tell an interesting story about the British intelligence officer Major John Andre. We (leave)______on 5 July.The plane (take off)______at 11a.m. Hey everyone, Im from Tunisia (north Africa) and I need some to help me with my GED tests. Im gonna pass the GED this summer so then I can go finish my studies in USA next fall. Id really appreciate it, thank you. Where was King John of England forced to sign the Magna Carta? Which best describes the goal of feminist art?to help de-gender art and other issuesto initiate social and political changeto help women gain equal treatment and opportunityall of the above A ferris wheelcompletes onerotation in 495seconds. How manyseconds will it taketo make 25rotations? Madeline took friends out fordinner. The cost of the mealwas $64.50. She left a 20%tip. What was the total costincluding tip?