+ 2
I need help to understand this python and I am a biggner
9 Antworten
+ 4
Can you be a little bit more specific and show us your attempt in code?
In general i would recommend you to go through the python lessons which are very helpful!
https://www.sololearn.com/learn/Python/2269/
+ 3
It seems that you already started the Python tutorial. What specifically don't you understand?
+ 3
Booleans are nothing very complicated.
Booleans can only have 2 different values: True or False.
You can create booleans by comparing values. The main comparison operators are: ==, !=, <=, >=, <, >, they are very similar to the comparison operators that were taught in school, but I mention their meanings here, if the result is True if the word result is true, the result is False if the word result is false.
a == b: a and b have equal value.
a != b: a and b don't have equal value.
a <= b: a don't have higher value than b.
a >= b: a don't have lower value than b.
a < b: a has higher value than b.
a > b: a has lower value than b.
Some examples:
5 > 2: True
8 <= 8: True
7 >= 9: False
1.0 == 1: True
False != True: True
You can use booleans to execute a certain block of code when an expression is True.
if True:
print("This would always be printed.")
else:
print("This would never be printed.")
if False:
print("This would never be printed.")
else:
print("This would always be printed.")
+ 3
To break this down simple for you. Let's use a real world example. So you are in a grocery store buying fruits for your child. If the oranges are cheap, you buy them, else you leave and go to another grocery store. So the if oranges are satisfying to u, you go with that (true), if it's not satisfying to you, you leave and go to another fruit store (false). Tell me if you understand the concept ?
+ 2
Boolean logic
I don't understand this topic
+ 2
and - returns true if both conditions are true
or - returns true if at least one condition returns true
not - "reverses" a boolean. True becomes False and vice-versa
+ 2
Very explanatory
+ 2
So you need help on if-else statements,here is some help:
If a statement is false,the else
section is always executed.
The syntax for if...else statements are as follows:
if 50 == 49:
print("Hello")
else:
print("world")
You can put any condition and any code to execute of course.
0
Next comes logical operators:
and, or, not
These should not be more complicated than the comparison operators.
Logical operators use booleans to return a new boolean.
The simple meaning of the logical operators.
a and b: a and b are both True.
a or b: atleast one of (a, b) is True.
not a: a is False.
Some examples:
True and True: True
True and False: False
False and True: False
False and False: False
True or True: True
True or False: True
False or True: True
False or False: False
not True: False
not False: True
Actually these logical operators have deeper meaning, but because I understood you are beginner, thats why it is not smart to tell yet.