feat: added examples_tutorials

This commit is contained in:
xpk
2025-11-26 23:20:41 +08:00
parent 96ef5cb42e
commit 9d044c20c9
16 changed files with 201 additions and 70 deletions
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
import logging
logging.basicConfig(level=logging.INFO, format="%(funcName)s %(levelname)s: %(message)s")
def while_loop() -> None:
"""
while loop which requires a counter
"""
counter: int = 1
while counter <= 5:
logging.info(counter)
counter += 1
def for_loop() -> None:
"""
for loop which puts the counter inline
"""
for i in range(5):
logging.info(i)
# Main function
def main() -> None:
"""
Both functions will log a message 5 times, but the for loop is so much simpler
"""
while_loop()
for_loop()
# Call main function
if __name__ == '__main__':
main()