0

Basically, I need help recreating this flow chart in Python. I can't figure out how to get the program to first check a variable against a condition, and then decide what to do. Ultimately it's the multiple if-else statements that are tripping me up.

The flowchart I need help completing

1
  • 5
    What do you have so far? Show us what you did, even if it does not make sense. We can help you better. Commented Nov 15, 2015 at 22:55

2 Answers 2

1

Your answer is a for loop.

From looking at your flow chart, I don't know what the for loop should look like though. But this seems to be what you have to do:

for <condition>: # You're most likely looking for something in the form "for n in range(<number>)", filling in <number>.
    if int(n)==n: # See flow chart from here on.
        if n%2==0:
            if n%3==0:
                print "%d is a multiple of 6."%n
            else:
                print "%d is even."%n
        else:
            print "%d is odd."%n
    else:
        print "%s is not an integer."%n
Sign up to request clarification or add additional context in comments.

Comments

1

I suggest you read up on control flows in python. https://docs.python.org/2/tutorial/controlflow.html

if, elif and else are the keywords you appear to be looking for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.