python_notes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python_notes [2023/09/08 19:15] – [useful links] raju | python_notes [2024/01/03 22:15] (current) – [useful links] raju | ||
---|---|---|---|
Line 8: | Line 8: | ||
* [[https:// | * [[https:// | ||
+ | ==== links to documentation ==== | ||
+ | |||
+ | * os.path.basename - https:// | ||
+ | * continue statement - https:// | ||
==== validate inputs ==== | ==== validate inputs ==== | ||
Sample snippet: | Sample snippet: | ||
Line 117: | Line 121: | ||
</ | </ | ||
+ | ==== check if something is float ==== | ||
+ | < | ||
+ | % python | ||
+ | Python 3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0] on linux | ||
+ | Type " | ||
+ | >>> | ||
+ | True | ||
+ | >>> | ||
+ | False | ||
+ | >>> | ||
+ | False | ||
+ | </ | ||
+ | |||
+ | ==== check if something is int ==== | ||
+ | < | ||
+ | % python | ||
+ | Python 3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0] on linux | ||
+ | Type " | ||
+ | >>> | ||
+ | True | ||
+ | >>> | ||
+ | False | ||
+ | >>> | ||
+ | False | ||
+ | </ | ||
+ | |||
+ | ==== Python comparisons ==== | ||
+ | |||
+ | < | ||
+ | $ python | ||
+ | Python 3.9.17 (main, Jul 5 2023, 20:47:11) [MSC v.1916 64 bit (AMD64)] on win32 | ||
+ | Type " | ||
+ | >>> | ||
+ | False | ||
+ | >>> | ||
+ | True | ||
+ | </ | ||
+ | |||
+ | ==== Chained comparisons ==== | ||
+ | Q: In Python '' | ||
+ | |||
+ | < | ||
+ | $ python | ||
+ | Python 3.9.17 (main, Jul 5 2023, 20:47:11) [MSC v.1916 64 bit (AMD64)] on win32 | ||
+ | Type " | ||
+ | >>> | ||
+ | False | ||
+ | </ | ||
+ | |||
+ | Why? | ||
+ | |||
+ | A: The ''<'' | ||
+ | |||
+ | So '' | ||
+ | |||
+ | Ref:- | ||
+ | * https:// | ||
+ | |||
+ | ==== List of comparison operators ==== | ||
+ | < | ||
+ | "<" | ||
+ | | " | ||
+ | </ | ||
+ | Ref:- https:// | ||
===== tasks ===== | ===== tasks ===== | ||
* [[get urls in a url]] | * [[get urls in a url]] | ||
Line 271: | Line 339: | ||
print(lines) | print(lines) | ||
[' | [' | ||
+ | </ | ||
+ | |||
+ | ===== programming notes ===== | ||
+ | ==== which python executable am I running? ==== | ||
+ | < | ||
+ | import sys | ||
+ | print(sys.executable) | ||
+ | </ | ||
+ | |||
+ | For example | ||
+ | |||
+ | < | ||
+ | $ python | ||
+ | Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32 | ||
+ | Type " | ||
+ | >>> | ||
+ | >>> | ||
+ | C: | ||
</ | </ | ||
python_notes.1694200553.txt.gz · Last modified: 2023/09/08 19:15 by raju