subject

# 35.3) Hot and Cold A scientist has been recording observations of the temperature for the past
while. On hot days, they write "H", and for cold days, they write "C". Instead
of using a list, they kept all of these observations in a single long string
(e. g., "HCH" would be a hot day, followed by a cold day, and then another hot
day).

Write a function `add_hot_cold` that consumes a string of observations and
returns the number of hot days minus the number of cold days. To accomplish
this, you should process each letter in turn and add 1 if it is hot, and -1 if
it is cold. For example, the string "HCH" would result in 1, while the string
"CHCC" would result in -2.

You cannot use the built-in `.count()` method or the `len()` function for this
problem.

Don't forget to unit test your function.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:00, EhHannuh6865
Let r be a robotic arm with a fixed base and seven links. the last joint of r is a prismatic joint, the other ones are revolute joints. give a set of parameters that determines a placement of r. what is the dimension of the configuration space resulting from your choice of parameters?
Answers: 3
image
Computers and Technology, 23.06.2019 16:30, jessisjawsome
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, cyn95xx
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
image
Computers and Technology, 23.06.2019 21:30, mariah10455
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
You know the right answer?
# 35.3) Hot and Cold A scientist has been recording observations of the temperature for the past

Questions in other subjects:

Konu
Business, 06.12.2021 18:00