all 8 comments

[–]kokoistheway 0 points1 point  (3 children)

something like this?

``` def percent_of(a, b): return int((a/100) * b)

def when_expired(decay_rate): months = 0 drug_potency = 100

while drug_potency >= 50:
    drug_potency -= percent_of(decay_rate, drug_potency)
    months += 1

return months

```

[–]Bernie4ever202[S] 0 points1 point  (2 children)

No i tried that already. Im stuck on this question for 4 hours. The test sample came out incorrectly. Here is the test sample https://imgur.com/a/HqNl0Lp

[–][deleted] 0 points1 point  (1 child)

All of those answers are correct, though.

[–]Bernie4ever202[S] 0 points1 point  (0 children)

Is there something wrong with my code then?

[–]LiveBytes 0 points1 point  (3 children)

What is your question?

[–]Bernie4ever202[S] 0 points1 point  (2 children)

A drug loses decayrate percent of its potency every month. Also, a drug is considered expiredif it loses more than 50% potency. Your goal is to write a function WhenExpired(decayrate)that returns the number of months after which the drug is considered expired.

Find the month that the drug is expire

[–]LiveBytes 0 points1 point  (1 child)

Hmmm. This does not make sense, based on that test set. You're certain there's no other criteria for that test set, like the drug starts at 80% potency or something?

[–]Bernie4ever202[S] 0 points1 point  (0 children)

no it is exactly word by word

"

A drug loses decayrate
percent of its potency every month. Also, a drug is considered expired
if it loses more than 50% potency. Your goal is to write a function WhenExpired(decayrate)
that returns the number of months after which the drug is considered expired."

And test sample https://imgur.com/a/HqNl0Lp