*PYTHON*
For this assignment, you will need to take the 4th assignment (code at bottom) and expand on your code. You will need to compile the highs and lows for 2017, showing the average for each month and the average high and low for the entire year. Output will be like this:
Average Low for month 1: 27
Average High for month 1: 49
Average Low for month 2: 28
Average High for month 2: 54
Average Low for month 3: 29
Average High for month 3: 53
Average Low for month 4: 39
Average High for month 4: 74
Average Low for month 5: 49
Average High for month 5: 76
Average Low for month 6: 56
Average High for month 6: 81
Average Low for month 7: 60
Average High for month 7: 85
Average Low for month 8: 56
Average High for month 8: 83
Average Low for month 9: 56
Average High for month 9: 78
Average Low for month 10: 43
Average High for month 10: 69
Average Low for month 11: 29
Average High for month 11: 54
Average Low for month 12: 21
Average High for month 12: 40
==============================
Average Low for the year: 41
Average High for the year: 66
...........................................
*4TH ASIGNMENT CODE*
"""Open a file"""
filedata = open('hours.txt',"r")
data = filedata.read()
"""read the file"""
data = data.split('\n')
final_list=[]
"""loop over data"""
"""loop over items of the file"""
for i in data:
if i:
sub_list=[]
all_data = i.split(',')
sum_i = sum(map(float,all_data[2:len(all_data)]))
data_id= all_data[0]
name = all_data[1]
weeklytotal = sum_i
sub_list.append(data_id)
sub_list.append(name)
sub_list.append(weeklytotal)
final_list.append(sub_list)
import csv
"""Write in csv"""
with open('hours.csv', 'w') as outcsv:
#configure writer to write standard csv file
writer = csv.writer(outcsv, delimiter=',', quotechar='|',
quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
writer.writerow(['id', 'name', 'hours'])
for item in final_list:
#Write item to outcsv
writer.writerow([item[0], item[1], item[2]])
"""Close the file"""
filedata.close()
"""tell the user its done"""
print("completed")
CODE:
sumLow = 0
sumHigh = 0
for i in range(12):
print("Average Low for month "+str(i+1)+": ",end="")
low = int(input())
sumLow += low
print("Average High for month " + str(i + 1) + ": ", end="")
high = int(input())
sumHigh += high
print()
print("==============================")
print("Average Low for the year:",(sumLow/12))
print("Average High for the year:",(sumHigh/12))
*PYTHON* For this assignment, you will need to take the 4th assignment (code at bottom) and exp...
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...
Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...
Python Programming 4th Edition: Need help writing this program below. I get an error message that says that name is not defined when running the program below. My solution: def main(): filename = "text.txt" contents=f.read() upper_count=0 lower_count=0 digit_count=0 space_count=0 for i in contents: if i.isupper(): upper_count+=1 elif i.islower(): lower_count+=1 elif i.isdigit(): digit_count+=1 elif i.isspace(): space_count+=1 print("Upper case count in the file is",upper_count) print("Lower case count in the file is",lower_count) print("Digit count in the file is",digit_count) print("Space_count in the file is",space_count)...
Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...
I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...
You have just been hired as an analyst for an investment firm. Your first assignment is to analyze data for stocks in the S&P 500. The S&P 500 is a stock index that contains the 500 largest publicly traded companies. You have been given two sources of data to work with. The first is an XML file that contains the Symbol (ticker), company name, sector, and industry for every stock in the S&P 500, as of summer 2016. The second...
Write a program that demonstrates use of programmer - defined
data structures. Please provide code! Thank you.
Here are the temps given:
January 47 36
February 51 37
March 57 39
April 62 43
May 69 48
June 73 52
July 81 56
August 83 57
September 81 52
October 64 46
November 52 41
December 45 35
Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...
Help writing MatLab code
Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...
I need help writing python code with following instructions. You will write a program that reads a data file. The data file contains ticket IDs and ticket prices. Your job is to read these tickets (and prices). find minimum, maximum and average ticket prices and output a report file. The report file should look exactly (or better than) the one attached (output.txt). Input: A31 149.99 B31 49.99 A41 179.99 F31 169.99 A35 179.99 A44 169.99 open "input.txt" file using open()...
I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...