I need help to calculate the sum of this, i just don't know how......
file_name = input("What is the value-probability file? ")
with open(file_name , "r") as final:
for numbers in final:
split_function = numbers.split()
num_one = float(split_function[0])
num_two = float(split_function[1])
final = num_one * num_two
final_line = final
So when my code runs the output looks like this :
What is the value-probability file? hw3_part2_test1.txt
-0.567032
-17.630715000000002
3.194056
4.398823
13.990935
I need all these numbers now to add to the next line and next line and give me sum..
I need the output answer to be : 3.386066999999997
#assuming each line has 2 numbers separated by space, and you
want the sum of product of these 2 numbers from all the lines
#below code will store that sum in the variable final_line
file_name = input("What is the value-probability file? ")
final_line=0
with open(file_name , "r") as final:
for numbers in final:
split_function = numbers.split()
num_one = float(split_function[0])
num_two = float(split_function[1])
final = num_one * num_two
final_line = final_line + final
print(final_line)
I need help to calculate the sum of this, i just don't know how...... file_name =...
Python function:
This is my code and I don't know how to add the column to the
csv file:
def write_with_averages(read,write):
with open (read,'r') as f_in:
header = f_in.readline()
reader=csv.reader(f_in)
with open (write,'w') as f_out:
writer=csv.writer(f_out)
New_data=[]
for Name, Test1, Test2, Test3 in reader:
Total=(float(Test1)+float(Test2)+float(Test3))
average=Total/3
New_data.append(average)
Hint: Skip the first line of the file as it is a header line Hint: All values come in as strings, so convert to floats before mathematical comparisons and calculations. File Format Name,Test1,Test2,Test3...
I need python help .. I need to know if a user were to input 3 commands to a program and run it such as specify: Usage: ./filemaker INPUTCOMMANDFILE OUTPUTFILE RECORDCOUNT (./filemaker is the program)( (INPUTCOOMANDFUILE= a text file that contains key words that need to be searched through then decided what to do ) (RECORDCOUNT= number) Given an input file that contains the following: That specifies the text, then the output, and the number of times to be repeated...
I need help with this program. Im trying to use C++ programming language. I want to include my ifstream SimpleCal6.txt and my outFile. CS 317 Calculator Program Write a program to input three values, two floats and an operator print out what were read and the resulting evaluation. The operators to handle are +, -, *, / and ^. The floats are one or more digits in length. The last input is sentinel value 0 + 0; Read a float,...
Hi I was hoping to get some help with my code for this problem. I don't know how to correctly read a txt file and the difference between using string and cstring. My code is at the bottom please help thanks. 1. Create the following “data.txt” file. Each record consists of customer's name and their balance: Maria Brown 2100.90 Jeffrey Jackson 200.20 Bernard Smith 223.10 Matthew Davenport 1630.20 Kimberly Macias 19100.90 Amber Daniels 2400.40 The records in the file will...
I dont know how to get this code working??? this is my code: # read_running_times.py # Chapter 6.2 Page 258 def main(): # Open the video_times.txt file for reading. video_file = open('video_times.txt', 'r') # Initialize an accumulator to 0.0 total = 0.0 # Initialize a variable to keep count of the videos. count = 0 print('Here are the running times for each video:') # Get the values from the file and total them. for line in video_file: # Error 1:...
When I run my program it gives me these exceptions and I don't know what it means by it : Exception in thread "main" java.lang.NumberFormatException: For input string: "Code" Does anyone know what I need to change for this to work?
I am having a hard time with my program to assignment 4.12. Here
are the instructions:
The Payroll Department keeps a list of employee information for
each pay period in a text file. The format of each line of the file
is the following: <last name> <hours worked> <hourly
wage>
Write a program that inputs a filename from the user and prints
to the terminal a report of the wages paid to the employees for the
given period.
The report...
I need help writing this C code. Here is the description: Let's say we have a program called smart typing which does two things: The first letter of a word is always input manually by a keystroke. When a sequence of n letters has been typed: c1c2...cn and the set of words in the dictionary that start with that sequence also have c1c2...cnc then the smart typing displays c automatically. we would like to know, for each word in the dictionary,...
Compute sum of the four digits in your AccessID and print it out. Please initialize your access ID as input data by using “DC” syntax. Your output should be in this format: My AccessID is ab1234 The sum is 10 Paste your code and screenshot of the output. . . Please create a very, very simple program as I am only a beginner. You don't need to store the four digits as variables. This is what I have so far....
Hi I need some help with this I just need the code and the collection name is research only the code I dont need any screenshots of the output. it should be for companies.json using the research collection as like this db.research.aggregate({}) but I don't know how to do the rest. This is the database but it is hard to paste it all so I will paste some and it should be create. Please I need this to be done...