Answer:
- def average_num_in_file(fileName):
- with open(fileName) as file:
- rows = file.readlines()
-
- sum = 0
- count = 0
- for x in rows:
- sum += float(x)
- count += 1
-
- average = sum / count
- return average
-
- print(average_num_in_file("cans.txt"))
Explanation:
The solution code is written in Python 3.
Firstly create a function that take one parameter, fileName (Line 1).
Open the file stream and use readlines method to read the data from the file (Line 2-3). Create variable sum and count to tract the total of the number from text files and number of data from the file (Line 5-6). Use a for loop to loop over each row of the read data and add the current value of each row to sum and increment the count by one (Line 7-9).
After the loop, calculate the average (Line 11) and return the result (Line 12).
At last, we can test the function by passing the cans.txt as argument (Line 14).
Answer:
Non Related Data relationship
Explanation:
If one variable change and don's effect the other variable, there is no relationship between these two variable.
Direct relation means if data or value increase for on variable the value of other variable is also increases and if one decreases other is also decrease.
In indirect relation, if one value increase the other variable value decreases and vise versa.
In cyclic relationship the pattern repeats it self again and again with change in one variable.
So, if there is no effect on one variable by changing other variable there is non related relationship between them.
Answer:
Crawford's Fabrics, which wants to expand its operations, combines data from the purchasing and sales departments into a central database, to be divided into new data marts as needed.
Answer:
B. Displays a string value