-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into langgraph
- Loading branch information
Showing
426 changed files
with
11,235 additions
and
714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
textual==0.75.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.1.0" |
11 changes: 11 additions & 0 deletions
11
contact-book-python-textual/source_code/rpcontacts/__main__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.