浏览代码

Merge pull request #1053 from michael-k/python

Use python examples that work
Alexandru Dima 6 年之前
父节点
当前提交
d8409c7f1f
共有 2 个文件被更改,包括 20 次插入18 次删除
  1. 10 9
      test/samples/sample.python.txt
  2. 10 9
      website/index/samples/sample.python.txt

+ 10 - 9
test/samples/sample.python.txt

@@ -1,12 +1,13 @@
-from banana import *
+import banana
+
 
 class Monkey:
-	# Bananas the monkey can eat.
-	capacity = 10
-	def eat(self, N):
-		'''Make the monkey eat N bananas!'''
-		capacity = capacity - N*banana.size
+    # Bananas the monkey can eat.
+    capacity = 10
+    def eat(self, n):
+        """Make the monkey eat n bananas!"""
+        self.capacity -= n * banana.size
 
-	def feeding_frenzy(self):
-		eat(9.25)
-		return "Yum yum"
+    def feeding_frenzy(self):
+        self.eat(9.25)
+        return "Yum yum"

+ 10 - 9
website/index/samples/sample.python.txt

@@ -1,12 +1,13 @@
-from banana import *
+import banana
+
 
 class Monkey:
-	# Bananas the monkey can eat.
-	capacity = 10
-	def eat(self, N):
-		'''Make the monkey eat N bananas!'''
-		capacity = capacity - N*banana.size
+    # Bananas the monkey can eat.
+    capacity = 10
+    def eat(self, n):
+        """Make the monkey eat n bananas!"""
+        self.capacity -= n * banana.size
 
-	def feeding_frenzy(self):
-		eat(9.25)
-		return "Yum yum"
+    def feeding_frenzy(self):
+        self.eat(9.25)
+        return "Yum yum"