Question

In: Computer Science

(Python) In a weather station, there is a sensor that measures the temperature three times a...

(Python) In a weather station, there is a sensor that measures the temperature three times a
day (in Celsius). Write a program that asks the user to input three numbers, corresponding to the
sensor's three readings for a particular day. Then, print the minimum, maximum and average value
of the three numbers.
Note: If one or two inputs are either less than -70, or greater than +50 degrees, you should ignore
those one or two inputs, and calculate the minimum, maximum and average using only the other
inputs. If all 3 inputs are either less than -70 or greater than 50, your code should print "Broken
sensor!" and not perform any calculations.
For this question, you must not use any built-in functions or functions from math
module except print(), input() or oat(). You must compute the minimum, maximum
and average values using if statement and arithmetic operators. This means that you
cannot use the built-in max() or min() functions.

Solutions

Expert Solution

Code -

#variable declare
flag1 = 0
flag2 = 0
flag3 = 0
#maximum and minimum temperature to be stored
maximum = 100
minimum = 100
#ask user to enter temperature first
print("Enter temperature first ")
num1 = int(input())
if num1>50 or num1<(-70) :
flag1 = 1
num1 = 0
  
#ask user to enter temperature second
print("Enter temperature second ")
num2 = int(input())
if num2>50 or num2<(-70) :
flag2 = 1
num2 = 0
  
#ask user to enter temperature third
print("Enter temperature third ")
num3 = int(input())
if num3>50 or num3<(-70) :
flag3 = 1
num3 = 0
#if conditon to get the maximum temperature
if num1>num2 and num1 > num2 and flag1==0 :
maximum = num1
elif num2>num1 and num2 > num3 and flag2==0 :
maximum = num2
elif flag3==0 :
maximum = num3
  
#if conditon to get the minimum temperature
if num1<num2 and num1 < num2 and flag1 == 0 :
minimum = num1
elif num2<num1 and num2 < num3 and flag2==0 :
minimum = num2
elif flag3==0 :
minimum = num3
#do total
total = num1+num2+num3
#calculate average
avg = total/3
#print result
if maximum != 100:
print("Maximum temperature is "+str(maximum))
else:
print("Broken Sensor!")

if minimum != 100:
print("Minimum temperature is "+str(minimum))
  
if maximum != 100:
print("Average temperature is "+str(avg))

Screenshot -


Related Solutions

For a national weather service station in Ohio, the distribution of high temperature readings for the...
For a national weather service station in Ohio, the distribution of high temperature readings for the months of July & august is approximately normal, with a mean of 87.5 degrees F, and standard deviation of 6.8 degrees F. What % of days during July & August will have high temperatures: a. between 87.5 and 95 degrees F b. above 95 degrees F c. between 78 and 90 degrees F d. less than 75 degrees F
This is an abstract class to represent a weather sensor. Weather sensors * report weather parameters...
This is an abstract class to represent a weather sensor. Weather sensors * report weather parameters to a weather station. Sensor readings are pulled by * calling the method read. Each sensor has a fixed failure rate that switches * the sensor state to damaged and needs to be fixed. A damaged sensor will * throw an exception when trying to get its reading. * */ public abstract class WSensor {    /*    * Your Task: Declare attributes to...
A weather balloon measures a temperature of 11°C and a mixing ratio of 12.5 g kg^-1...
A weather balloon measures a temperature of 11°C and a mixing ratio of 12.5 g kg^-1 at 850 hPa. Twenty-four hours later, the passage of a dryline has left the same location with the same temperature but a mixing ratio of 6 g kg^-1. What is the change in the density of the air during this period? You may assume an ideal gas.
Discuss how you could use a resistor as a temperature sensor.
Discuss how you could use a resistor as a temperature sensor.
Suppose you were the project manager who is in charge of developing the Weather Station system...
Suppose you were the project manager who is in charge of developing the Weather Station system described and you have to make a decision on whether to use Waterfall or Agile for developing it. Q1. Evaluate the likelihood of the availability of requirements/specifications at the start. Explain which one is more suitable for developing it with reference to this aspect. Q2. Evaluate the likelihood of changes to requirements. Explain which one is more suitable for developing it with reference to...
Suppose the Kelvin temperature (as measured by a reliable sensor) of a 9.0000 mol sample of...
Suppose the Kelvin temperature (as measured by a reliable sensor) of a 9.0000 mol sample of gas in a rigid 5L tank is doubled. It is observed that the pressure increased to 2.1 times its original value. Which of the following statements could explain the observed result. (select all that apply) No gas escapes and the gas obeys the ideal gas law. The pressure reading for the final pressure is too high due to instrument malfunction Some of the gas...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO board. The LCD should simply display the temperature and humidity reading from the DHT11 sensor. We must do this without the use of arduino or lcd libraries, and only use raw c code. For example we need to use PORTD |= (1<<5); to set the pin to 5. The LCD is connected to pins A0 and A1, and it is using I2C. The temperature...
Your spaceship has docked at a space station above Mars. The temperature inside the space station...
Your spaceship has docked at a space station above Mars. The temperature inside the space station is a carefully controlled 24 ∘C at a pressure of 735 mmHg . A balloon with a volume of 515 mL drifts into the airlock where the temperature is -83 ∘C and the pressure is 0.120 atm . What is the final volume, in milliliters, of the balloon if n remains constant and the balloon is very elastic?
Run the  Python Queue Line Simulator  three times Python Queue Line """ File: pyQueueSim.py Author: JD """ import...
Run the  Python Queue Line Simulator  three times Python Queue Line """ File: pyQueueSim.py Author: JD """ import random print("Queue as a customer line\n") queue = []              # Empty que y = int(0) # Queue up some customers for i in range(1,20):     x = random.randint(1, 20)     if x >= 2 and x<= 8:       queue.append(x)      # Add to the front        # Simulate cumstomer line processing while True:    x = random.randint(1, 20)    if x >= 2 and x<= 8:       queue.append(x *2)      # Add to the front...
7.21 The Weather Channel reports that it is a hot, muggy day with an air temperature...
7.21 The Weather Channel reports that it is a hot, muggy day with an air temperature of 90°F, a 10 mph breeze out of the southwest, and bright sunshine with a solar insolation of 400 W/m2. Consider the wall of a metal building over which the prevailing wind blows. The length of the wall in the wind direction is 10 m, and the emissivity is 0.93. Assume that all the solar irradiation is absorbed, that the surroundings are at Tsur...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT