fixes spelling mistakes

This commit is contained in:
waldek 2022-05-02 16:32:53 +02:00
parent 27a862bb77
commit f8e18a62c7
1 changed files with 21 additions and 9 deletions

View File

@ -1400,9 +1400,10 @@ if __name__ == "__main__":
</details> </details>
#Logical Operators # Logical Operators
There is three types of logical operators. All operators returns boolean. There is three types of logical operators.
All operators return boolean values, ie `True` or `False`.
| Operator | Result | | Operator | Result |
|-----------------|---------------------------------------------| |-----------------|---------------------------------------------|
@ -1421,13 +1422,15 @@ DealerName = "Paul"
DealerAgreement = True DealerAgreement = True
if CustomerAgreement and DealerAgreement : if CustomerAgreement and DealerAgreement :
print(f"Youpi !!! {CustomerName} and {DealerName} are agreed ") print(f"Youpi !!! {CustomerName} and {DealerName} agree")
else: else:
print(f"Oh no {CustomerName} and {DealerName} are disagreed ;( ") print(f"Oh no, {CustomerName} and {DealerName} don't agree... ;(")
``` ```
As you can guess, Jean and Paul are agreeing to the deal. If I had put 'False' in DealerAgreement boolean, the result will be inverse.
Let's show an another example with the `Or` operator. As you can guess, Jean and Paul are agreeing to the deal.
If I had put `False` in `DealerAgreement` boolean, the result would be reversed.
Let's show another example but this time with the `Or` operator.
````python3 ````python3
def Choice_cold_hot(Temperature): def Choice_cold_hot(Temperature):
@ -1436,13 +1439,18 @@ def Choice_cold_hot(Temperature):
else: else:
print("Let's go to the beach") print("Let's go to the beach")
if __name__ == "__main__": if __name__ == "__main__":
Temperature = int(input("What is the temperature")) Temperature = int(input("What is the temperature"))
Choice_cold_hot(Temperature) Choice_cold_hot(Temperature)
```` ````
Look at this code, if the temperature is smaller than 20° or bigger than 40°, you must stay home and don't go to the beach. So, if I put 35° for temperature, it will say that you should go to the beach.
Let's make an exercise. You have to take the previous code and use the `And` operator. Look at this code, if the temperature is smaller than 20° or bigger than 40°, you must stay home and don't go to the beach.
So, if I put 35° as temperature, it will say that you should go to the beach.
Let's try this out as an exercise!
Reuse the previous code but integrate the `And` operator.
The result should be identical.
<details> <details>
<summary>Spoiler warning</summary> <summary>Spoiler warning</summary>
@ -1453,13 +1461,15 @@ def Choice_cold_hot(Temperature):
print("Let's go to the beach") print("Let's go to the beach")
else: else:
print("Don't go outside") print("Don't go outside")
if __name__ == "__main__": if __name__ == "__main__":
Temperature = int(input("What is the temperature")) Temperature = int(input("What is the temperature"))
Choice_cold_hot(Temperature) Choice_cold_hot(Temperature)
```` ````
</details> </details>
Now, we have used that operators, we can use the last logical operator. The `Not` operator sends the reverse of the result. Now that we have discovered the base operators we can learn the last logical operator `not` which gives us the reverse of the expected result.
````python3 ````python3
if __name__ == "__main__": if __name__ == "__main__":
@ -1469,7 +1479,9 @@ if __name__ == "__main__":
else: else:
print("That will be expensive") print("That will be expensive")
```` ````
In this example, if you tap yes, the result will be reversed. In this example, if you tap yes, the result will be reversed.
# Lists # Lists
The different built-in objects we've seen until now, such as `str` and `int` are simple [text](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str) and [numeric](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex) types. The different built-in objects we've seen until now, such as `str` and `int` are simple [text](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str) and [numeric](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex) types.