セクション 1. 章 9
single
Challenge: Creating the Sensor
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
You are going to create a Sensor class to help keep track of numbers recorded by sensors. A sensor is a device that measures something, like temperature or light, and stores those measurements as a list of numbers called readings. Follow these steps to build your class:
- Add a method called
add_reading:- This method should take one value (a number).
- Add this value to the sensor's list of readings.
- Fill a method called
average_reading:- This method should return the average (mean) of all the numbers in the
readingslist. - If there are no readings, it should return
Noneinstead of causing an error.
- This method should return the average (mean) of all the numbers in the
- Add a method called
reset_readings:- This method should remove all readings from the
Sensor. - The
readingslist should become empty.
- This method should remove all readings from the
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 9
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください