Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Nested IF Statement Homework help

How would I go about doing this:

Quote:You are a Psychology major who has agreed to help Kim Kardashian deal with the press. Kim's getting ready to step out for the evening and she needs you to write a Python program to make sure that she makes the right fashion decisions.
Shoes: If Kim is wearing her white pants then she can wear her white stilettos. If she is wearing her black pants, then she can wear her blue wedges. If she is wearing her green pants then she'll wear her green Mary Jane shoes. If she decides to wear her yellow pants she'll wear her orange pumps. If she is going to wear any other color pants than she'll wear her brown flats.
Destination: If it is before 1pm, then she'll go to the beach, if it's before 2pm, she'll go for lunch at "La Petite", if it's before 4pm, she'll have her nails done at "Tips R Us", if it's before 6pm, she'll go to the "Flat Tummy" gym, if it's before 8pm she'll go home to get ready to go out, if it's before 9pm, she'll go to dinner at "Racks & Stacks BBQ", if it's before 11pm, she'll go see a movie at "The 24 Multiplex" and if it's before 12am, she'll hit the club at "The Backdoor".
Create a Python program that will ask the user what color pants Kim will be wearing and what time it is. The program will then tell Kim what color shoes to wear and where she should go.

Using only if, elif and else statements

Thanks :)
How do I downvote this? I'm triggered.
Microsoft Word is the best IDE for programming
Just get input from the user, in Python you can use the input() function. Store those in two variables. Then you can just use if, elif, else.

This program would be extraordinarily easy. If this is for some intro school program, you should honestly learn how to think out the steps logically yourself. If else and loops are fundamental to understanding how to program. If this isn't for school, I can do this for you when I get the time.

In python, I think of if, elif, else as if, otherwise if, and otherwise.
[Image: Iu0EfTL.gif]
(Oct 4, 2021 01:31 PM)Lindros Wrote:  Just get input from the user, in Python you can use the input() function. Store those in two variables. Then you can just use if, elif, else.

This program would be extraordinarily easy. If this is for some intro school program, you should honestly learn how to think out the steps logically yourself. If else and loops are fundamental to understanding how to program. If this isn't for school, I can do this for you when I get the time.

In python, I think of if, elif, else as if, otherwise if, and otherwise.

That person didn't even try. It's a do my homework for me request. Better not support it to avoid getting more.
Microsoft Word is the best IDE for programming
I'm trying to learn programing, so happy to work a practice problem. If this is for a formal education, you should take full advantage of that learning process. Not everyone has that opportunity, don't waste it.

Code
# You are a Psychology major who has agreed to help Kim Kardashian deal with the press.
#  Kim's getting ready to step out for the evening and she needs you to write a
#  Python program to make sure that she makes the right fashion decisions.

# Shoes:
# If Kim is wearing her white pants then she can wear her white stilettos.
# If she is wearing her black pants, then she can wear her blue wedges.
# If she is wearing her green pants then she'll wear her green Mary Jane shoes.
# If she decides to wear her yellow pants she'll wear her orange pumps.
# If she is going to wear any other color pants than she'll wear her brown flats.

# Destination:
# If it is before 1pm, then she'll go to the beach,
# if it's before 2pm, she'll go for lunch at "La Petite",
# if it's before 4pm, she'll have her nails done at "Tips R Us",
# if it's before 6pm, she'll go to the "Flat Tummy" gym,
# if it's before 8pm she'll go home to get ready to go out,
# if it's before 9pm, she'll go to dinner at "Racks & Stacks BBQ",
# if it's before 11pm, she'll go see a movie at "The 24 Multiplex" and
# if it's before 12am, she'll hit the club at "The Backdoor".

# Create a Python program that will ask the user what color pants Kim will be wearing
#  and what time it is. The program will then tell Kim what color shoes to wear and where she should go.


shoes = {"white": "white stilettos",
        "black": "blue wedges",
        "green": "green Mary Jane shoes",
        "yellow": "orange pumps"}


def kimShoes(colorPants):
    """
    This function takes in the string colorPants. It
        then prints what shes Kim will be wearing.
    """

    # In this case colorPants acts as the key to the dictionary "shoes",
    #  and then returns the value assigned to it.
    print("Kim will be wearing her", shoes[colorPants])


def kimDest(time):
    """
    This function takes in the int time. It then
        prints out what destination Kim will go to.
    """
   
    # These are nested loops
    if time <= 1:
        print("To go to the beach")
       
    elif time <= 2:
        print("To go for lunch at 'La Petite'")
   
    elif time <= 4:
        print("To have her nails done at 'Tips R Us'")
       
    elif time <= 6:
        print("To go to the 'Flat Tummy' gym")
       
    elif time <= 8:
        print("To go home to get ready to go out")
       
    elif time <= 9:
        print("To go to dinner at 'Racks & Stacks BBQ'")
       
    elif time <= 11:
        print("To go see a movie at 'The 24 Multiplex'")
   
    # Use an else case here since all other times are "before" 12am
    else:
        print("To hit the club at 'The Backdoor'")


# testing

#TestCase_1
time = 1
colorPants = "white"

print("\nShould be, 'white stilettos'.")
kimShoes(colorPants)

print("\nShould be, 'To go to the beach'.")
kimDest(time)
     
#TestCase_2
time = 4
colorPants = "black"

print("\nShould be, 'blue wedges'.")
kimShoes(colorPants)

print("\nShould be, 'To have her nails done at 'Tips R Us''.")
kimDest(time)

#TestCase_3
time = 7
colorPants = "green"

print("\nShould be, 'green Mary Jane shoes'.")
kimShoes(colorPants)

print("\nShould be, 'To go home to get ready to go out'.")
kimDest(time)

#TestCase_4
time = 12
colorPants = "yellow"

print("\nShould be, 'orange pumps'.")
kimShoes(colorPants)

print("\nShould be, 'To hit the club at 'The Backdoor'.")
kimDest(time)
If you transfer me 1 Bitcoin i'll solve this for you, DM me.
I'll do all of your Python homework like this for $35-55/hr (depending on volume). Let me know if you do need help, but for now it looks like others have helped you out already!

Their solutions look accurate to me, but there's a lot of manual checking to do.
(Jan 4, 2022 01:38 PM)Hackers Wrote:  I'll do all of your Python homework like this for $35-55/hr (depending on volume). Let me know if you do need help, but for now it looks like others have helped you out already!

Their solutions look accurate to me, but there's a lot of manual checking to do.

Disagree!

It's such a simple python program and you shouldn't promote that, you should instead encourage him to try learning!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by lockheadApr 22, 2021 07:10 AM 0 145 Apr 22, 2021 07:10 AM
Last Post: lockhead
[Python] by Will PattersonOct 13, 2017 07:35 AM 3 184 Oct 13, 2017 07:35 AM
Last Post: TheMarkMan
[C#] by severosJul 14, 2017 11:02 AM 16 411 Jul 14, 2017 11:02 AM
Last Post: severos