GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #36 from DrAlias/master · Kowus/Source-Code-from-Tutorials@9baabf6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Python
    • 29_python.py
    • 30_python.py
    • 31_python.py
    • 32_python.py
    • 33_python.py
    • 34_python.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Python/29_python.py‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Enemy:
2+
life = 3
3+
4+
def attack(self):
5+
print("ouch!")
6+
self.life -=1
7+
8+
def checkLife(self):
9+
if self.life <= 0:
10+
print("I am dead")
11+
else:
12+
print(str(self.life) + " life left")
13+
14+
enemy1 = Enemy()
15+
enemy2 = Enemy()
16+
17+
enemy1.attack()
18+
enemy1.attack()
19+
enemy1.checkLife()
20+
enemy2.checkLife()
Collapse file

‎Python/30_python.py‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Enemy:
2+
def __init__(self, x):
3+
self.energy = x
4+
5+
def get_energy(self):
6+
print(self.energy)
7+
8+
jason = Enemy(5)
9+
sandy = Enemy(18)
10+
11+
jason.get_energy()
12+
sandy.get_energy()
Collapse file

‎Python/31_python.py‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Girl:
2+
3+
gender = 'female'
4+
5+
def __init__(self, name):
6+
self.name = name
7+
8+
r = Girl('Rachel')
9+
s = Girl('Stanky')
10+
print(r.gender)
11+
print(s.gender)
12+
print(r.name)
13+
print(s.name)
Collapse file

‎Python/32_python.py‎

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Parent:
2+
3+
def print_last_name(self):
4+
print('Roberts')
5+
6+
7+
class Child(Parent):
8+
9+
def print_first_name(self):
10+
print('Bucky')
11+
12+
def print_last_name(self):
13+
print('Snitzleberg')
14+
15+
bucky = Child()
16+
bucky.print_first_name()
17+
bucky.print_last_name()
Collapse file

‎Python/33_python.py‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Mario():
2+
3+
def move(self):
4+
print('I am moving!')
5+
6+
7+
class Shroom():
8+
9+
def eat_shroom(self):
10+
print('Now I am big!')
11+
12+
13+
class BigMario(Mario, Shroom):
14+
pass
15+
16+
bm = BigMario()
17+
bm.move()
18+
bm.eat_shroom()
Collapse file

‎Python/34_python.py‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import threading
2+
3+
4+
5+
class BuckysMessenger(threading.Thread):
6+
def run(self):
7+
for _ in range(10):
8+
print(threading.currentThread().getName())
9+
10+
x = BuckysMessenger(name='Send out messages')
11+
y = BuckysMessenger(name='Receive messages')
12+
x.start()
13+
y.start()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.