Skip to content

Instantly share code, notes, and snippets.

# juggling_balls_game.py
import turtle
import time
import random
from juggling_balls import Ball
# Game parameters
WIDTH = 600
import random
class Wizard:
def __init__(self, name, patronus, birth_year):
self.name = name
self.patronus = patronus
self.birth_year = birth_year
self.house = None
self.wand = None
self.skill = 0.2 # 0.0 (bad) to 1.0 (good)
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
       
my_article = SubstackArticle(1000)
print(my_article * 3)
# TypeError: unsupported operand type(s) for *: 'SubstackArticle' and 'int'
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
   def __mul__(self, other):
       if isinstance(other, int):
           return SubstackArticle(self.number_of_words * other)
   def __repr__(self):
       return f"SubstackArticle({self.number_of_words})"
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
   def __mul__(self, other):
       if isinstance(other, int):
           return SubstackArticle(self.number_of_words * other)
   def __rmul__(self, other):
       return self.__mul__(other)
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
   def __mul__(self, other):
       if isinstance(other, int):
           return SubstackArticle(self.number_of_words * other)
   def __rmul__(self, other):
       print("__rmul__ called")
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
   def __mul__(self, other):
       if isinstance(other, int):
           return SubstackArticle(self.number_of_words * other)
   def __rmul__(self, other):
       return self.__mul__(other)
class SubstackArticle:
   def __init__(self, number_of_words):
       self.number_of_words = number_of_words
   def __mul__(self, other):
       if isinstance(other, int):
           return SubstackArticle(self.number_of_words * other)
       return NotImplemented
   def __rmul__(self, other):
class Wizard:
def __init__(self):
self.name = None
self.patronus = None
self.birth_year = None
self.house = None
self.wand = None
class Wizard:
def __init__(self):
self.name = None
self.patronus = None
self.birth_year = None
self.house = None
self.wand = None
# Create two wizard instances
harry = Wizard()