Skip to content

Commit

Permalink
Merge branch 'master' into langgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-martin authored Feb 3, 2025
2 parents e54ab48 + 4de2690 commit c16660d
Show file tree
Hide file tree
Showing 426 changed files with 11,235 additions and 714 deletions.
9 changes: 9 additions & 0 deletions basic-input-output-in-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Basic Input and Output in Python

This folder contains the code examples for the Real Python tutorial [Basic Input and Output in Python](https://realpython.com/python-input-output/).

You can run all of the scripts directly by specifying their name:

```sh
$ python <filename>.py
```
26 changes: 26 additions & 0 deletions basic-input-output-in-python/adventure_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import random

health = 5
enemy_health = 3

while health > 0 and enemy_health > 0:
# Normalize input to handle extra spaces and case variations.
action = input("Attack or Run? ").strip().lower()
if action not in {"attack", "run"}:
print("Invalid choice. Please type 'Attack' or 'Run'.")
continue

if action == "attack":
enemy_health -= 1
print("You hit the enemy!")
# Implement a 50% chance that the enemy strikes back.
enemy_attacks = random.choice([True, False])
if enemy_attacks:
health -= 2
print("The enemy strikes back!")
else:
print("You ran away!")
break
print(f"Your health: {health}, Enemy health: {enemy_health}")

print("Victory!" if enemy_health <= 0 else "Game Over")
2 changes: 2 additions & 0 deletions basic-input-output-in-python/greeter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = input("Please enter your name: ")
print("Hello", name, "and welcome!")
9 changes: 9 additions & 0 deletions basic-input-output-in-python/guess_the_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import random

number = random.randint(1, 10)
guess = int(input("Guess a number between 1 and 10: "))

if guess == number:
print("You got it!")
else:
print("Sorry, the number was", number)
4 changes: 4 additions & 0 deletions basic-input-output-in-python/improved_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import readline # noqa F401

while (user_input := input("> ")).lower() != "exit":
print("You entered:", user_input)
36 changes: 16 additions & 20 deletions celery-async-tasks/source_code_final/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
amqp==5.1.1
asgiref==3.5.2
async-timeout==4.0.2
billiard==3.6.4.0
celery==5.2.7
click==8.1.3
click-didyoumean==0.3.0
amqp==5.3.1
asgiref==3.8.1
billiard==4.2.1
celery==5.4.0
click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.2.0
Deprecated==1.2.13
Django==4.0.6
kombu==5.2.4
packaging==21.3
prompt-toolkit==3.0.30
pyparsing==3.0.9
pytz==2022.1
redis==4.3.4
click-repl==0.3.0
Django==5.1.3
kombu==5.4.2
prompt_toolkit==3.0.48
python-dateutil==2.9.0.post0
redis==5.2.0
six==1.16.0
sqlparse==0.4.2
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.1
sqlparse==0.5.2
tzdata==2024.2
vine==5.1.0
wcwidth==0.2.13
36 changes: 16 additions & 20 deletions celery-async-tasks/source_code_initial/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
amqp==5.1.1
asgiref==3.5.2
async-timeout==4.0.2
billiard==3.6.4.0
celery==5.2.7
click==8.1.3
click-didyoumean==0.3.0
amqp==5.3.1
asgiref==3.8.1
billiard==4.2.1
celery==5.4.0
click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.2.0
Deprecated==1.2.13
Django==4.0.6
kombu==5.2.4
packaging==21.3
prompt-toolkit==3.0.30
pyparsing==3.0.9
pytz==2022.1
redis==4.3.4
click-repl==0.3.0
Django==5.1.3
kombu==5.4.2
prompt_toolkit==3.0.48
python-dateutil==2.9.0.post0
redis==5.2.0
six==1.16.0
sqlparse==0.4.2
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.1
sqlparse==0.5.2
tzdata==2024.2
vine==5.1.0
wcwidth==0.2.13
9 changes: 0 additions & 9 deletions concurrency-overview/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions concurrency-overview/cpu_mp.py

This file was deleted.

20 changes: 0 additions & 20 deletions concurrency-overview/cpu_non_concurrent.py

This file was deleted.

21 changes: 0 additions & 21 deletions concurrency-overview/cpu_threading.py

This file was deleted.

35 changes: 0 additions & 35 deletions concurrency-overview/io_mp.py

This file was deleted.

17 changes: 0 additions & 17 deletions concurrency-overview/race_condition.py

This file was deleted.

35 changes: 0 additions & 35 deletions concurrency-overview/requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions contact-book-python-textual/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Build a Contact Book App With Python, Textual, and SQLite

This folder provides the code examples for the Real Python tutorial [Build a Contact Book App With Python, Textual, and SQLite](https://realpython.com/contact-book-python-textual/).
33 changes: 33 additions & 0 deletions contact-book-python-textual/source_code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RP Contacts

**RP Contacts** is a contact book application built with Python, Textual, and SQLite.

## Installation

1. Create a Python virtual environment

```sh
$ python -m venv ./venv
$ source venv/bin/activate
(venv) $
```

2. Install the project's requirements

```sh
(venv) $ python -m pip install -r requirements.txt
```

## Run the Project

```sh
(venv) $ python -m rpcontacts
```

## About the Author

Real Python - Email: office@realpython.com

## License

Distributed under the MIT license. See `LICENSE` for more information.
1 change: 1 addition & 0 deletions contact-book-python-textual/source_code/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
textual==0.75.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
11 changes: 11 additions & 0 deletions contact-book-python-textual/source_code/rpcontacts/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rpcontacts.database import Database
from rpcontacts.tui import ContactsApp


def main():
app = ContactsApp(db=Database())
app.run()


if __name__ == "__main__":
main()
Loading

0 comments on commit c16660d

Please sign in to comment.