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
Gre4nikov [31]
3 years ago
11

Write a program to read from std_info.txt.

Computers and Technology
1 answer:
slavikrds [6]3 years ago
6 0

Answer:

import pandas as pd

# loads the text file as a pandas dataframe

student_file = pd.read_fwf("std_info.txt")

# opens a new text file if the student_avg does not exist

# the file closes automatically at the end of the with statement

with open('student_avg.txt', 'w+') as file:

   for row in student_file.iterrows():

       file.write(row)

   ee = student_file[student_file['major'=='EE']]

   cpe = student_file[student_file['major'=='CPE']]

   file.write(f'EE average = {ee['EE'].mean()}')

   file.write(f'CPE average = {ee['CPE'].mean()}')

   file.write(f'Total average = {student_file['EE'].mean()}')

Explanation:

The python program gets the text file as a fixed-width file and loads the file as a pandas dataframe. The dataframe is used to get the total average GPA the student GPA and the average GPA of students in various departments. The results are saved in a new file called 'student_avg.txt'.

You might be interested in
Write a complete program to do the following: The main program calls a method to read in (from an input file) a set of people's
zmey [24]

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class Donor {

public static void main(String[] args){

int idNumbers[] = new int[50]; //created two array each of 50 size

int donations[] = new int[50];

int donorCount=readFile(idNumbers, donations); //calling readfile function

System.out.println("--------------------Original record--------------------");

printDetails(idNumbers,donations,donorCount); //printing details

sortByDonorId(idNumbers,donations,donorCount);

System.out.println("--------------------Sort by donor id--------------------");

printDetails(idNumbers,donations,donorCount);

sortByDonation(idNumbers,donations,donorCount);

System.out.println("--------------------Sort by donation amount--------------------");

printDetails(idNumbers,donations,donorCount);

}

private static void sortByDonation(int[] idNumbers, int[] donations, int donorCount) {

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

for(int j=i+1;j<=donorCount;j++){

if(donations[i]>donations[j]){ //comparison based on donations

int temp = idNumbers[i];

idNumbers[i] = idNumbers[j];

idNumbers[j] = temp;

temp = donations[i];

donations[i] = donations[j];

donations[j] = temp;

}

}

}

}

private static void sortByDonorId(int[] idNumbers, int[] donations, int donorCount) {

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

for(int j=i+1;j<=donorCount;j++){

if(idNumbers[i]>idNumbers[j]){ //comparison based on donor number

int temp = idNumbers[i];

idNumbers[i] = idNumbers[j];

idNumbers[j] = temp;

temp = donations[i];

donations[i] = donations[j];

donations[j] = temp;

}

}

}

}

public static void printDetails(int[] idNumbers, int[] donations, int donorCount){

System.out.printf("%-5s%s"," ","Donor information"); //using printf for format output

System.out.printf("\n%-20s%-20s","ID number","donations");

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

System.out.printf("\n%-20s%-20s",idNumbers[i],donations[i]);

}

System.out.println();

}

public static int readFile(int idNumbers[],int donations[]){

File file = new File("input.txt"); //reading data from this file

Scanner reader;

int donorIndex=-1; //keep track of number of records

try {

reader = new Scanner(file);

while(reader.hasNext()){

donorIndex++;

String line = reader.nextLine();

idNumbers[donorIndex] = Integer.parseInt(line.split(" ")[0]); //spliting line by space,0 is idnumber

donations[donorIndex] = Integer.parseInt(line.split(" ")[1]); //spliting line by space,1 is donations

}

reader.close();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return donorIndex;

}

}

3 0
3 years ago
Please help
koban [17]
1 . NT file system
Method of storing files used by Microsoft

2 . Installation
The process of putting software on the computer for use

3 . Boot partition
Section of the hard drive where the boot loader program is stored

4 . Upgrade
The process of installing a new version of software to improve performance

5 . File allocation system
Method of storing files used by many different types of computers

6 . Transmission Control Protocol/Internet Protocol
Two separate standards used together that define how data is sent and received across a network

7 . Device driver
Program that controls a piece of hardware

8. Partition
Section of a hard drive used for file storage

9. System partition
Section of the hard drive where the operating system program is stored
3 0
3 years ago
To play game, go inside the Grand Theft Auto V folder and right click and runGTAVLauncher as administrator.If you get any missin
yanalaym [24]

Answer and Explanation

The answer is true because when this error occurs, Microsoft Visual C++ is not installed in your PC, so firstly, download the 64bit version. Once installed restart your PC then open game software If still occur then follow the methods such as

If the error still exists then this software will be removed and fix all error.ensure that you have already installed we setup in your PC and both

Vcredist_x64_2012_x64 and

vcredist_x64_2012_x86

8 0
3 years ago
Henry is creating code In JavaScript to run calculations on extremely small numbers. How can he use MIN_VALUE as validation in t
QveST [7]

In creating code in JavaScript to run calculations on extremely small numbers, MIN_VALUE as validation in the program can be use to check the lowest value JavaScript can handle

Number.MIN_VALUE returns the smallest positive numeric value representable in JavaScript.  It is the number more closer to zero. The value is approximately 5e⁻³²⁴.

Using Number.MIN_VALUE, the value can be printed as follows:

val = Number.MIN_VALUE;

console.log(val); // 5e-324

Therefore, In creating code in JavaScript to run calculations on extremely small numbers, MIN_VALUE as validation in the program can be use to check the lowest value JavaScript can handle.

learn more on JavaScript here: brainly.com/question/13041378?referrer=searchResults

3 0
3 years ago
To lose weight, you must _______.
sweet [91]

Answer:

B

Explanation:

because you need to exercise and eat or drink less calories

8 0
3 years ago
Read 2 more answers
Other questions:
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • How often are computer and user policies applied after a user has logged into a computer?
    15·1 answer
  • "When you can control devices and appliances by apps installed on your smartphone or tablet, you are said to have"
    6·1 answer
  • Which of the following is NOT considered a step in the problem solving process. A Try B Discover C Prepare D Define
    12·1 answer
  • If you are logged on to Windows Live Messenger, why would you be unable to engage
    6·1 answer
  • A range check that can be used in Microsoft access to calculate the data collected which is date and time
    10·1 answer
  • The ___ function can be entered by clicking the cell where you want to add the funtion such as cell J6. Then click the arrow nex
    6·1 answer
  • The optical phenomenon that allows us to view rapidly changing still images as moving images is called _______.
    15·2 answers
  • David is preparing a report to show the percentage increase in population in the United States in the last five years. Which fea
    12·1 answer
  • each data mining technique has its advantages and limitations. which data mining technique mimics the neural structure of the br
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!