Merge pull request 'first changes' (#8) from Yousri/python_course_doc:master into master

Reviewed-on: https://gitea.86thumbs.net/waldek/python_course_doc/pulls/8
This commit is contained in:
waldek 2022-04-14 16:47:19 +02:00
commit 1d595b14fe
1 changed files with 30 additions and 2 deletions

View File

@ -518,7 +518,7 @@ else:
## Some links to read up on ## Some links to read up on
* how to to [str.isfloat()](https://stackoverflow.com/questions/736043/checking-if-a-string-can-be-converted-to-float-in-python)? * how to convert string to float, Look at the response here: [str.isfloat()](https://stackoverflow.com/questions/736043/checking-if-a-string-can-be-converted-to-float-in-python)?
# A text based adventure game # A text based adventure game
@ -711,7 +711,7 @@ function_scope(300, 400)
print("outside the function", total) print("outside the function", total)
``` ```
Here `total` outside of the function references a different object from the `total` inside of the function. Here, there is a variable `total` outside the function references.But, it is a different object from the `total` inside the function.
Python is very *nice* and will try to fix some common mistakes or oversights by itself. Python is very *nice* and will try to fix some common mistakes or oversights by itself.
For example. For example.
@ -1369,6 +1369,34 @@ if __name__ == "__main__":
</details> </details>
#Logical Operators
There is three types of logical operators. All operators returns boolean.
| Operator | Result |
|-----------------|----------------------------------------------|
| **And** | It send 'True' if all conditions are true |
| **Or** | It send 'True' if one of conditions are true |
| **Not** | It reverse the boolean result |
Let's start example with 'And' operator!
```python3
CustomerName = "Jean"
CustomerAgreement = True
DealerName = "Paul"
DealerAgreement = True
if CustomerAgreement and DealerAgreement :
print(f"Youpi !!! {CustomerName} and {DealerName} are agreed ")
else:
print(f"Oh no {CustomerName} and {DealerName} are disagreed ;( ")
```
As you can guess, Jean and Paul are agreeing to the deal. If I had put 'False' in DealerAgreement, the result will be inverse.
# 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.