Question

PYTHON Write a function to find out if school is closed (True) or not closed (False)....

PYTHON

Write a function to find out if school is closed (True) or not closed (False).

There are 2 input variables (inSession, snow):

inSession , if True, indicating school is supposed to be in session;

Snow, if True, indicating a snow day

School is closed when NOT in session.   During regular session, Schools is also closed when there is a snow day.

Example Function Calls:

schoolClosed(False, True)  # should return True 

schoolClosed(False, false) # should return True

schoolClosed(True, True) # should return True

schoolClosed(True, False)  # should return False 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def schoolClosed(inSession,snow): #function to check whether school is open or closed
if(inSession==False): #if inSession is false, no matter what school is closed
return True
if(inSession==True): #if inSession is True, then if it is snowing then school is closed else it is open
if(snow==True):
return True
else:
return False
inSession=bool(int(input("School is supposed to be in session? Enter 1 for true and 0 for false: ")))
snow=bool(int(input("It is a snow day? Enter 1 for true and 0 for false: ")))
if(schoolClosed(inSession,snow)==True):
print("School is closed")
else:
print("School is open")

output:

Add a comment
Know the answer?
Add Answer to:
PYTHON Write a function to find out if school is closed (True) or not closed (False)....
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
  • Write a function is_mirror(s) that takes as input a string s and returns True if s...

    Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored string (i.e., a string that could have been produced by your mirror function) and False otherwise. Examples: >>> is_mirror('baconnocab') result: True >>> is_mirror('baconnoca') result: False Warning Your function should return a boolean value – either True or False, without any quotes around them. If you see quotes around the result when you make the calls above from the console, you must...

  • in python A. Define a function called contains_only_integers() that takes a tuple, returns True if all...

    in python A. Define a function called contains_only_integers() that takes a tuple, returns True if all the items in the tuple are integers(2), and returns False otherwise. For example, contains_only_integers (3, 5, 17, 257, 65537) ), contains_only_integers( (-1,) ), and contains_only_integers( ) should all return True, but contains_only_integers (2.0,4.0)) and contains_only_integers (8, 4, "2", 1)) should both return false. Your function should use a while loop to do this calculation. 121 Hint: the is instance() built-in function provides the most...

  • Python Program 5. Write a Python program in a file named validTime.py. Include a function named...

    Python Program 5. Write a Python program in a file named validTime.py. Include a function named string parameter of the form hh:mm: ss in which these are numeric validTime that takes a values and returns True or False indicating whether or not the time is valid. The number of hours, minutes, and seconds must two digits and use a between 0 and 9). The number of hours must be between 0 and 23, the number of minutes and seconds must...

  • Intro to Programming and Logic: Python 2, Chapter 8 – Strings (so far have learned the...

    Intro to Programming and Logic: Python 2, Chapter 8 – Strings (so far have learned the way of a program, variables, expressions, statements, functions, interface design, conditional, recursion and iteration) Write a program that takes a string as a parameter. It will analyze the string and return True if it is a valid float number. It will return False if it is not a valid float value. Your function should return True in any of these cases: 0.17, .17, 5.27,...

  • QUESTION 21 while True: , in Python, can be used to create an infinite loop. True...

    QUESTION 21 while True: , in Python, can be used to create an infinite loop. True False 2 points    QUESTION 22 The Python Framework does inform you where an error occurred True False 2 points    QUESTION 23 ____ is a critical component to being able to store data and information long term. File Access Memory Print function with 2 points    QUESTION 24 Error handling is also known as ___ handling Result Recursion Exception Crash 2 points   ...

  • Assume that L is a list of Boolean values, True and False. Write a function longestFalse(L)...

    Assume that L is a list of Boolean values, True and False. Write a function longestFalse(L) which returns a tuple (start, end) representing the start and end indices of the longest run of False values in L. If there is a tie, then return the first such run. For example, if L is False False True False False False False True True False False 0 1 2 3 4 5 6 7 8 9 10 then the function would return...

  • Write a python function called "get_sma", that takes two input arguments, similar to the example provided....

    Write a python function called "get_sma", that takes two input arguments, similar to the example provided. First argument is the original prices of type list, and the 2nd input argument being the number of days we want to calculate SMA, like a 8 day sma or 35 day sma. This function should return a new list of sma price, based on the input day range, and should be able to handle any SMA calculation, like: sma200 for 200 days moving...

  • Write a function in python, index(arr, value) to find indices of elements equal to some value...

    Write a function in python, index(arr, value) to find indices of elements equal to some value in a Numpy array. The input arr is a 1-d numpy array, and input value is the value to search for. The function should return the index of the value. If the value occurs for multiple times, then all the indices should be returned as a 1-d numpy array. For example, if arr=[1 0 2 0 3 0 4 0 5 0 6 7...

  • 3. (4 pt) Write a Python program to find the longest common prefix string amongst an...

    3. (4 pt) Write a Python program to find the longest common prefix string amongst an array of strings. You are required to write a function max- Prefix, which when called by the main program would get the array of strings as input and return a single string that would either be the longest 1 common prefix or a string ”NULL” depending on the input. (Note: The array is input from the keyboard in the main program (930)) If there...

  • Pls help me write this function in python. (pls include commented explanation) Function name (7): class...

    Pls help me write this function in python. (pls include commented explanation) Function name (7): class writing Description: Write a class called "Burrito". A Burrito should have the following attributes (instance variables): meat, to_go, rice, beans, extra_meat (default: False), guacamole (default: False), cheese (default: False), pico (default: False), corn (default: False), Add a method called "get_cost" to the Burrito class. It should accept zero arguments (except for "self", of course) and it will return a float. Here's how the cost...

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