Justin Bieber's Purpose Generator

From Hackers & Designers
Revision as of 15:17, 27 December 2017 by Hd-onions (talk | contribs)
MainNavigation No

Justin.png

The Bieber algorythm

      import sys
      
      import random
      from subprocess import call

set the variable

      var1 = raw_input("Enter your name: ")
      var2 = raw_input("A verb that defines you: ")
      var3 = raw_input("One word that inspires you: ")
      txt = 
      lines = []

lyrics file

      f = open("justinbieber.txt", "r")

image turned into text

      f2 = open("justin.txt", "r")
      justin = f2.read()
      txt += justin
      txt += "\n"
      txt += "JUSTIN BIEBER'S PURPOSE GENERATOR\n"
      txt += "\n"
      txt += "\n"
      for line in f.readlines():
              lines.append(line.strip())

selection of a random number of lines between 25 and 42

      for i in range(random.randint(25,42)):
              l = random.choice(lines)

replace function

              l = l.replace("your",var1+"'s")
              l = l.replace("you",var1)
              l = l.replace("make",var2)
              l = l.replace("I ",var3+" ")
              l = l.replace("I'",var3+"'")
              txt += l +  "\n"

print

      output = open("output.txt", "w")
      output.write(txt)
      output.close()

basic layout for the page

      call(["lp", "-d", "HP_LaserJet_8150_Series__0030C1CCDDF2_", "-o", "page-left=72", "-o", "cpi=15","-o", "lpi=9", "-o", "page-bottom=36", "-o", "page-top=28", "-o", "page-right=42", "output.txt"])

save the file in a folder

      output = open("biebs/" + str(int(round(time.time()))) + ".txt", "w")
      output.write(txt)
      output.close()