Question

Coding Problem 2.4.7 (Advanced) (External resource) (1.0 points possible) CoughSyrup.py Submit tRun G Grades Reset I dosage 100 Console output will be displayed here 2 time since last dose 7 3 is nighttimeFalse 4 took_something_cross_reactiveFalse 5 6#You may modify the lines of code above, but dont move them! 7 #When you submit your code, well change these lines to 8#assign different values to the variables. 10 #Lets try to use our mathematical operators and logical 111#operators together. 12|# 13#Imagine youve been battling a cold. Youre 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 its been, 18 #youre allowed to have one dose 19|# 20 #If its nighttime (is nighttime), then you may double 21 #your dose since you wont be taking any until morning 22 | # 23#However, if youve taken something cross-reactive 24 #1 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 times a 31 #boolean, Python treats False as 0 and True as I. There are 32#other ways to do this, though. 34 35#Add your code here! 36 37 3 8 39python math operator help

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#****Code*************

dosage = 100

time_since_last_done = 7

is_nighttime = False

took_something_cross_reactive = False

#initialise variable for dose day and night

dose_day =1

dose_night =2

#if took some thing wrong then print message not to take syrup

if(took_something_cross_reactive==True):

print("You should not take any please cough syrup.")

else:

if(is_nighttime==False): #if its day time, then take 1 dose for every hour

dosage = time_since_last_done*dose_day

else:

dosage = time_since_last_done*dose_night # else take 2 dose for every hour

print("You should take cough syrup and take "+ str(dosage) + " dose") #output

#*****Output(left) and corresponding modified code to test code(right)****

Text Editor 00 dosage.py Ichg/python)-gedit abhayğabhay-Lenovo-Z51-70:/chg/pythons python dosage.py Open Yau shauld abhaygabh

Text Editor 00 dosage.py Ichg/python)-gedit abhayğabhay-Lenovo-Z51-70:/chg/pythons python dosage.py Yau shauld Open take cougText Editor e dosage.py (-/chg/python) gedit abhayğabhay-Lenovo-Z51-70:/chg/pythons python dosage.py Yau shauld take cough sy4

#***Please do let me know if you have any doubts or want me to modify the code*****

Add a comment
Know the answer?
Add Answer to:
python math operator help Coding Problem 2.4.7 (Advanced) (External resource) (1.0 points possible) CoughSyrup.py Submit tRun...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am stuck with this coding problem from edx coding python 4.4.6: #This is a long...

    I am stuck with this coding problem from edx coding python 4.4.6: #This is a long one -- our answer is 20 lines of code, but #yours will probably be longer. That's because it's one of the #more authentic problems we've done so far. This is a real #problem you'll start to face if you want to start creating #useful programs. # #One of the reasons that filetypes work is that everyone #agrees how they are structured. A ".png" file,...

  • Could I get some help with this assignment In this assignment, you'll write a program which...

    Could I get some help with this assignment In this assignment, you'll write a program which reads a text file, and prints a histogram of its word sizes. So, for example, the historgram should show the number of words of length 1, of length 2, etc., up to the number of words of length n, where n is some constant defined in your program. To obtain text files that are suitably long, you could try Project Gutenberg, a site containing...

  • Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...

    Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions. The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this...

  • Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException;...

    Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class SongsReport {    public static void main(String[] args) {               //loading name of file        File file = new File("songs.csv"); //reading data from this file        //scanner to read java file        Scanner reader;        //line to get current line from the file        String line="";       ...

  • i really need help with the graphs Driving Can Be Dangerous to Your Health: An Interrupted...

    i really need help with the graphs Driving Can Be Dangerous to Your Health: An Interrupted Case Study in Physiology Phil Stephens Department of Biology Villanova University Part 1-The Grandparents Arrive Dave pulled the cell phone out of his pocket, cursing himself for not putting it on vibrate. The children, Jason and Laura, were both asleep, and he knew that the rest of the day would not be fun if they were awakened from their naps. "Hi, Dave. We're just...

  • Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data...

    Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...

  • Question 1: Comment on each of the three source attributes that contribute to a celebrity's potential...

    Question 1: Comment on each of the three source attributes that contribute to a celebrity's potential effectiveness as an endorser (credibility, attractiveness, and power) and how the proposed Chinese celebrity measures up in each of those attributes. Wei Song noticed the fashion models first, preening in their chiffon- and-lace gowns. STEPHEN MASON and JOSEPH SAIVACRUZ are professors of business practice at HKUST Business School. LP. STEVENSON is a manager of competitive intelligence at the Fung Group. This fictionalized case study...

  •    Available Feb 11 at 12am - Mar 8 at 11:59pm 26 days Not for IV...

       Available Feb 11 at 12am - Mar 8 at 11:59pm 26 days Not for IV Use: The Story of an Enteral Tubing Misconnection The Story of Robin and Addison Lowe (United States) LEARNING OBJECTIVES After completing this case study, you will be able to: 1. Explore the scientific feld of human factors and how errors like tubing misconnections can be prevented. 2. Discuss the complexity of having two patients to treat, a mother and her fetus. 3. Describe suitable...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT