Y or NO?


#1

I know what to do, bit I do not get the point, I dont get what makes me choose Yes or No.
Can someone explain. Since the beginning I feel I am lost.


#2

If you could please give us a little bit more information on the problem you are having with your code it would be well appreciated! If you could give us your code, error message, what lesson you are on, and tell us a little bit more about your troubles with your code then that will help us help you faster and more effectively! :smiley:


#3

Here it is, and I need your advice, generally I feel like I am walking in fog, I mean every step I made it I did without understanding what and why is that normal? should I read something first before having exercises here?
and thank you so much for your kind and respectful response :innocent:


#4

The result of the comparison is what makes the program choose one branch or another. Let’s go back to lesson 2…

Compare Closely!

Equal to (==)

In your code above, from Conditional Statement Syntax

if answer == "Left":

everything to the right of the if keyword is a comparison expression that yields a boolean, True or False. All comparisons are boolean expressions. The above compares for identity, which is to say, ‘are both objects identical?’

What makes it a conditional statement? Answer: the if keyword.

Consider a door.

if door_is_open:
    go through
else:
    don't go through

Conditional statements make decisions about which path to follow. This is called control flow. Programs work because they are able to make decisions on the fly based on given data values present in a comparison expresssion.

Back to your question… What makes us choose yes or no? The comparison. See the value assigned to the variable, answer?

answer = "Left"

The single = tells Python to assign the string value "Left" to the variable, answer. If we poll the variable,

print answer

we get its value, “Left”. Now when we compare that value to the string literal, "Left", we see they are identical. That means,

answer == "Left"

will yield True. Now rewriting that into the condtional,

if True:
   print "..."

Starting to make sense?


#5

Yes, I think I have something clear now to start thinking, the door example makes sense, although I need to re-read several time and compare to the exercise. Thank you so much :grinning:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.