Answer:
#section 1
def maxTemp(filename):
import pathlib
f = pathlib.Path(filename)
f.exists()
if f.exists():
f = open(filename, "r")
#section 2
next(f)
res = [int(sub.split(',')[1]) for sub in f]
maxdata = (res[0])
for i in range(len(res)-1):
if maxdata < res[i]:
maxdata = res[i]
index = res.index(maxdata)
f.close()
#section 3
li = []
a = open(filename, "r")
for line in a:
line = line.strip()
li.append(line)
a.close()
return (li[index+1])
else:
return -1
print(maxTemp("new.csv"))
Explanation:
#section 1:
The function maxTemp is defined. We import pathlib in other to check if the file exists, if it does we carry on with opening the file and if it doesn't the program returns -1.
#section 2:
We start splitting the sub-lists from the second line i.e <em>next(f)</em>. For each line we take the second index element and convert it to an integer.
<em>res = [int(sub.split(',')[1]) for sub in f]
</em>
The maximum number is gotten by using the if statement to compare all elements in the list. The index of the maximum item in the list is collected.
the file is then closed.
#section 3 :
The file is re-opened and all the lines are striped and passed into a new list and the index recovered from section 2, is used to get the day with the highest temperature and the line is returned.
Answer:
finalResult = (num1 + num2 ) / 3
Explanation:
finalResult, num1 and num2 are all variables and it is assumed that they have all been declared with their correct data types.
finalResult is said to be the result of the sum of the two other variables, num1 and num2 divided by 3.
i.e
(num1 + num2) / 3
<em>Note </em>: It is essential to put the sum of num1 and num2 in bracket so as to ensure that the addition operation is performed first before the division operation. Not putting in bracket will make the division operation to be performed first which will not be the solution to the problem at hand.
Once the operations (addition and division) have been performed, then the result is assigned to the variable, finalResult, as follows:
finalResult = (num1 + num2 ) / 3 --------- (1)
Therefore, if num1 = 4 and num2 = 5, finalResult according to the equation(1) above gives;
finalResult = (4 + 5) / 3
finalResult = 9 / 3
finalResult = 3
<em>Hope this helps!</em>
Answer:
false
Explanation:
According to my research on Information Technology, I can say that based on the information provided within the question this statement is actually false. A socket sniffer captures TCP/IP packets to analyze network traffic. The device that monitors data like the one mentioned in the question would just be called a sniffer.
I hope this answered your question. If you have any more questions feel free to ask away at Brainly.
You can place an insertion point by clicking in the field or by clicking F2 keyboard shortcut. Insertion point is usually characterized by a blinking vertical line that allows you to insert a next character that you wanted.