Skip to content

Commit f8756a2

Browse files
author
William Lubanovic
committed
First files for example repo
1 parent 7fa2f91 commit f8756a2

Some content is hidden

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

95 files changed

+959
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
introducingpython
22
=================
33

4-
An introduction to Python
4+
5+
This repository contaisn the programs featured in
6+
"An introduction to Python".
7+
8+
dir chapter
9+
--- -------
10+
intro 1. A taste of Py
11+
2. Py ingredients: numbers, strings, and variables
12+
3. Py filling: lists, tuples, dictionaries, and sets
13+
4. Py crust: code structures
14+
boxes 5. Py boxes: modules, packages, and programs
15+
6. Oh oh: objects and classes
16+
7. Mangle data like a pro
17+
storage 8. Data has to go somewhere
18+
web 9. The web, untangled
19+
sys 10. Systems
20+
net 11. Concurrency and networks
21+
dev 12. Be a pythonista
22+
art A. Py art
23+
bus B. Py at work
24+
C. Py sci
25+
D. Install Python 3
26+
E. Answers to exercises
27+
F. Cheatsheets

art/matplotlib1.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import matplotlib.pyplot as plot
2+
import matplotlib.image as image
3+
4+
img = image.imread('oreilly.png')
5+
plot.imshow(img)
6+
plot.show()

art/panda1.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from direct.showbase.ShowBase import ShowBase
2+
3+
class MyApp(ShowBase):
4+
5+
def __init__(self):
6+
ShowBase.__init__(self)
7+
8+
# Load the environment model.
9+
self.environ = self.loader.loadModel("models/environment")
10+
# Reparent the model to render.
11+
self.environ.reparentTo(self.render)
12+
# Apply scale and position transforms on the model.
13+
self.environ.setScale(0.25, 0.25, 0.25)
14+
self.environ.setPos(-8, 42, 0)
15+
16+
app = MyApp()
17+
app.run()

boxes/report.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def get_description(): # see the docstring below?
2+
"""Return random weather, just like the pros"""
3+
from random import choice
4+
possibilities = ['rain', 'snow', 'sleet', 'fog', 'sun', 'who knows']
5+
return choice(possibilities)

boxes/report2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def get_description():
2+
import random
3+
possibilities = ['rain', 'snow', 'sleet', 'fog', 'sun', 'who knows']
4+
return random.choice(possibilities)

boxes/test1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("This standalone program works!")

boxes/test2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import sys
2+
print('Program arguments:', sys.argv)

boxes/test3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import report
2+
3+
description = report.get_description()
4+
print("Today's weather:", description)

boxes/weatherman2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import report as wr
2+
description = wr.get_description()
3+
print("Today's weather:", description)

boxes/weatherman3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from report import get_description
2+
description = get_description()
3+
print("Today's weather:", description)

0 commit comments

Comments
 (0)