Question
Hello, just need help with some modifications to my code! I will post my original solution below and assignment requirements. It is pretty plain and
Hello, just need help with some modifications to my code!
I will post my original solution below and assignment requirements. It is pretty plain and straight to the point. What I want to do is to be able to utilize parameters in my function.
I am not sure how I would go about doing this and would really appreciate some guidance. Also, I feel like my code looks weird because of the mix between the y/n and 0/1. I would like to polish this too, but it is not a necessity. If it is necessary to make everything work, please go ahead and change what needs to be changed.
Please provide feedback, I am new to coding and I know my codes are pretty unpolished, but I really would like to learn so I can be better.
I appreciate any help and TIA!
Assignment requirements:
---needs to be written in Python
---needs to include a function with parameters
----needs to include a list
----needs to contain either of the choices below:
----- 2 ANDs + 1 OR
----- 2 ORs + 1 AND
(Add more if necessary this is just the minimum requirement)
THIS IS MY SOLUTION BELOW:
day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] clubOpen = ['y', 'n'] goPool = ['y', 'n']
club_house = input('Is the club house open? y/n: ') week_day= input('What day of the week is it?: ') go_swim = input('Do the kids want to swim? y/n: ')
if week_day in (day[2], day[6]): week_day = 1 else: week_day = 0
def goSwimming(): if clubOpen[0] and week_day == 1 and goPool[0]: print("It is Wednesday or Sunday, so the pool is open. The kids want to go swim.") elif clubOpen[0] and week_day == 1 and goPool[1]: print('Today is Wednesday or Sunday and the club pool is open, but the kids do not want to swim') elif (clubOpen[1] or week_day == 0) and goPool[0]: print('The club pool is closed, but the kids want to swim. Should we take them to do something else?') elif (clubOpen[1] or week_day == 0) and goPool[1]: print('The club and pool are closed, but I do not think the kids wanted to swim anyway.') else: print('The club is open, but the pool is closed. I do not think the kids wanted to go swimming anyway.')
goSwimming()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started