6 Matching Annotations
  1. May 2019
  2. Mar 2019
    1. print(self.num,"/",self.den)

      i particularly like an alternate construction better, because it allows you better control of the output string(this example will not insert spaces before and after the slash, unless you deliberately put them there)

      print('{}/{}'.format(self.num,self.den))
      

      It uses the .format module, that lets you replace {} structures with the print verions of variables, you can set names for them like

      print('{numerator}/{denominator}'.format(denominator = self.den, numerator = self.num))
      

      and a lot of other stuff, you can learn more reading the python documentation of the string class

  3. Feb 2019
    1. list comprehension

      Black magic of making math inside of a list variable creation

    2. Modify the code from Activecode 8 so that the final list only contains a single copy of each letter

      the in can be used to check if somethings is in another set

    3. each value will be assigned to the variable item

      how the variable of the for statement works