Coding Curriculum - Python

Decision

Now, you have a clear idea what are the steps involved during an interaction. First your ask a question, in Python, you print the question. Then you list the options, print them too. And you wait for an answer, you do so by asking for an input in Python.

But, not everyone give a proper answer. You have to decide what is a valid answer. In programming, we use conditional statements, if and else to make decision.

print "What kind of cuisine do you prefer for lunch?"
print "Thai?"
print "Chinese?"
print "Korean?"
answer = int(raw_input())
if answer == "Thai" or answer == "Chinese" or answer == "Thai"
print "Valid Answer"
else
print "Invalid Answer"

With the ability to create interaction, we will work on adding this interaction to allow you to choose the questions stored in the previous lesson.

The next steps that you need to take are:

  1. Ask what subject to study
  2. List the subjects available
  3. Get an input
  4. Decide if answer is valid
  5. If answer is not valid, print an error message
  6. Get an input again