A lunar robot explores the surface of the moon. Using sensors, it takes samples of temperature and stores the data in a simple text file. The data is recorded in degrees Celcius. Here is a sample file.
At the end of each day before the lunar bot shuts down, it runs a program to analyse the data.
It calculates:
Save the text file in your project folder. If you are using REPLIT (or similar), upload the file to your programming area.
Type this code into your IDE. It simply reads the file and stores the results in an array:
Here is an attempt at a solution. Some code is missing. Fill the blanks to complete the program:
count ←
min ← dataSet[0]
max ←
FOR i ← 0 TO LEN(dataSet)
IF dataSet[i] < THEN
min ←
IF > max THEN
max ← dataSet[i]
IF dataSet[i] > THEN
count ← count + 1
END WHILE
OUTPUT "MAX :",max,"; MIN: ",min,"; COUNT: ", count
Create a new file called dailyresult.txt.
Can you figure out how to write the results from Task B into this new file? Use the following format:
Python open file read selection loop sequence condition iteration assignment