Question: how do I solve this mathematical problem using simple mathematical and logical operators? [Executed at: Fri Jan 28 17:2 1:35 PST 2022] We found a
how do I solve this mathematical problem using simple mathematical and logical operators?

![operators? [Executed at: Fri Jan 28 17:2 1:35 PST 2022] We found](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f459523e457_68166f45951b4585.jpg)
[Executed at: Fri Jan 28 17:2 1:35 PST 2022] We found a few things wrong wi th your code. The first one is shown below, and the rest can be found in full_results.txt i n the dropdown in the top lef We tested your code with dosag e = 100, time_since_last_dose = 7, is_nighttime = False, too k_something_cross_reactive = F alse. We expected your code to print this: 1 dosage = 100 2 time since_last_dose = 7 3 is_nighttime = False 4 took_something_cross_reactive = False 6 #You may modify the lines of code above, but don't move them! 7 #When you Submit your code, we'll change these lines to 8 #assign different values to the variables. 9# 10 #Let's try to use our mathematical operators and logical 11 #operators together. 12# 13 #Imagine you've been battling a cold. You're deciding whether 14 #to take cough syrup or not, and if so, how much to take. 15 # 16 #time_since_last_dose represents the number of hours since 17 #you last took some cough syrup. For every hour it's been, 18 #you're allowed to have one dose. 19 # 20 #If it's nighttime (is_nighttime), then you may double 21 #your dose since you won't be taking any until morning. 22 # 23 #However, if you've taken something cross-reactive 24 #(took_something_cross reactive), then you should not take 25 any cough syrup. 26 # 27 Write a program that will print how large a dose of cough 28 #syrup to take. 29 30 HINT: Remember, if you try to multiply a number a 31 boolean, Bythen treats False as eand, True as There are 32 other ways to do this, though. 33 34 35 Add your code here 36 dosage_per_hour = dosage * time_since_last_dose 37 38 dose = dosage_per_hour * (not(is_nighttime) + took something_cross_reactive) + dosage_per_hour *(not(is_nighttime) + took something_cross_reactive) 39 print (dose) 40 789 However, it printed this: 1400 INNON 000 There are several ways to do this next problem, but you'll probably find it easiest if you note that Python lets you multiply by booleans. It treats False as o, and True as 1. So... 5 True = 5 5 * False = 5* (True + True) 5 + (True + False)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
