I am brand new to programming and I have two questions.
First question: I see this >>> in the examples of exercises and I do not understand what they should do.
Example from Boolean operators 7/13: ("" are only there to make the >>> visible in the post)
“>>>” (1 + 1 == 2) and (2 + 2 == 4)
“>>>” (1 + 1 == 2) and (2 < 1)
“>>>” (1 > 9) and (5 != 6)
“>>>” (0 == 10) and (1 + 1 == 1)
If I copy >>> (1 + 1 == 2) and (2 + 2 == 4) over and run it nothing happens.
Second question: Is my solution to the first task in Boolean operators 7/13 good?
The instruction is:
Set the variables
statement_two equal to the results of the following boolean expressions:
Statement one: (2 + 2 + 2 >= 6) and (-1 * -1 < 0)
Statement two: (4 * 2 <= 8) and (7 - 1 == 6)
statement_one = (2 + 2 + 2 >= 6) and (-1 * -1 < 0)
statement_two = (4 * 2 <= 8) and (7 - 1 == 6)
I have the feeling that they would expect to see
statement_one = True
statement_two = True
How do I let Python tell me if the expression is True or False and how do I then tell Python to put this value equal to the corresponding statement?
Thank you for helping such a total novice.
Perhaps you could link the lesson or guidance you’re working on as it makes it a lot easier for others to assist that way. I’d also suggest checking the following FAQ which details the best way to set up forum queries and covers how to format code on the forums (which is very very helpful ).
I think the
>>> is just a stand in for the standard interactive Python prompt. This would be the standard prompt if you just run
python via command line and you can run individual lines one by one instead of an entire script.
(1 + 1 == 2) and (2 + 2 == 4) just means run that line on it’s own (do not type the
>>>). If this was a script or a different interactive environment then it may be necessary to pass that expression
(1 + 1 == 2) and (2 + 2 == 4) to
print if you wanted to see the output.
I think that may also cover your second query (if not then say so). When you run that line that expression is evaluated and since you’re using a boolean
and operator it will return a boolean (
False). Alternatively if the point of the exercise was to work this out yourself then simply assign
False to the name e.g.
statement_x = True.
Note that you must use captials for the keywords
@tgrtim thank you very much for your help.
And for recommending the FAQs. I should have read them beforehand🤦
You answered all my questions.