Skip to content

Commit aaea7a3

Browse files
author
hfhoffman1144
committed
Merge branch 'langgraph' of https://github.com/realpython/materials into langgraph
2 parents 993674e + 1db655f commit aaea7a3

File tree

430 files changed

+11345
-1587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

430 files changed

+11345
-1587
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Basic Input and Output in Python
2+
3+
This folder contains the code examples for the Real Python tutorial [Basic Input and Output in Python](https://realpython.com/python-input-output/).
4+
5+
You can run all of the scripts directly by specifying their name:
6+
7+
```sh
8+
$ python <filename>.py
9+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import random
2+
3+
health = 5
4+
enemy_health = 3
5+
6+
while health > 0 and enemy_health > 0:
7+
# Normalize input to handle extra spaces and case variations.
8+
action = input("Attack or Run? ").strip().lower()
9+
if action not in {"attack", "run"}:
10+
print("Invalid choice. Please type 'Attack' or 'Run'.")
11+
continue
12+
13+
if action == "attack":
14+
enemy_health -= 1
15+
print("You hit the enemy!")
16+
# Implement a 50% chance that the enemy strikes back.
17+
enemy_attacks = random.choice([True, False])
18+
if enemy_attacks:
19+
health -= 2
20+
print("The enemy strikes back!")
21+
else:
22+
print("You ran away!")
23+
break
24+
print(f"Your health: {health}, Enemy health: {enemy_health}")
25+
26+
print("Victory!" if enemy_health <= 0 else "Game Over")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = input("Please enter your name: ")
2+
print("Hello", name, "and welcome!")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import random
2+
3+
number = random.randint(1, 10)
4+
guess = int(input("Guess a number between 1 and 10: "))
5+
6+
if guess == number:
7+
print("You got it!")
8+
else:
9+
print("Sorry, the number was", number)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import readline # noqa F401
2+
3+
while (user_input := input("> ")).lower() != "exit":
4+
print("You entered:", user_input)
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
amqp==5.1.1
2-
asgiref==3.5.2
3-
async-timeout==4.0.2
4-
billiard==3.6.4.0
5-
celery==5.2.7
6-
click==8.1.3
7-
click-didyoumean==0.3.0
1+
amqp==5.3.1
2+
asgiref==3.8.1
3+
billiard==4.2.1
4+
celery==5.4.0
5+
click==8.1.7
6+
click-didyoumean==0.3.1
87
click-plugins==1.1.1
9-
click-repl==0.2.0
10-
Deprecated==1.2.13
11-
Django==4.0.6
12-
kombu==5.2.4
13-
packaging==21.3
14-
prompt-toolkit==3.0.30
15-
pyparsing==3.0.9
16-
pytz==2022.1
17-
redis==4.3.4
8+
click-repl==0.3.0
9+
Django==5.1.3
10+
kombu==5.4.2
11+
prompt_toolkit==3.0.48
12+
python-dateutil==2.9.0.post0
13+
redis==5.2.0
1814
six==1.16.0
19-
sqlparse==0.4.2
20-
vine==5.0.0
21-
wcwidth==0.2.5
22-
wrapt==1.14.1
15+
sqlparse==0.5.2
16+
tzdata==2024.2
17+
vine==5.1.0
18+
wcwidth==0.2.13
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
amqp==5.1.1
2-
asgiref==3.5.2
3-
async-timeout==4.0.2
4-
billiard==3.6.4.0
5-
celery==5.2.7
6-
click==8.1.3
7-
click-didyoumean==0.3.0
1+
amqp==5.3.1
2+
asgiref==3.8.1
3+
billiard==4.2.1
4+
celery==5.4.0
5+
click==8.1.7
6+
click-didyoumean==0.3.1
87
click-plugins==1.1.1
9-
click-repl==0.2.0
10-
Deprecated==1.2.13
11-
Django==4.0.6
12-
kombu==5.2.4
13-
packaging==21.3
14-
prompt-toolkit==3.0.30
15-
pyparsing==3.0.9
16-
pytz==2022.1
17-
redis==4.3.4
8+
click-repl==0.3.0
9+
Django==5.1.3
10+
kombu==5.4.2
11+
prompt_toolkit==3.0.48
12+
python-dateutil==2.9.0.post0
13+
redis==5.2.0
1814
six==1.16.0
19-
sqlparse==0.4.2
20-
vine==5.0.0
21-
wcwidth==0.2.5
22-
wrapt==1.14.1
15+
sqlparse==0.5.2
16+
tzdata==2024.2
17+
vine==5.1.0
18+
wcwidth==0.2.13

concurrency-overview/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

concurrency-overview/cpu_mp.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

concurrency-overview/cpu_non_concurrent.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)