SHARE
TWEET

Untitled

a guest Jun 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##define function
  2. def pizzabot(inputx, inputy):
  3.    
  4.  x = 0
  5.  y = 0
  6.  
  7.  
  8. #while x isn't equal to it's destanation
  9. #loop through from x to the x coordinate
  10.  
  11. # indentation in python is weird if u dont know...
  12. # you indent to define functions, loops, etc, instead of squiggly brackets
  13.  
  14.  while(x != inputx):
  15.      if(x < inputx): ## if x is less than destanation
  16.          x = x+1     ## we move east by 1
  17.          print("E")
  18.      elif(x > inputx):
  19.          x = x-1    ## if x is more we move west
  20.          print("W")
  21.  while(y != inputy):
  22.       if(y < inputy): ## same concept for y
  23.             y = y+1
  24.             print("N")
  25.       elif(y > inputy):
  26.             y = y-1
  27.             print("S")
  28.  print("D")        
  29.  
  30. # next line is unindented, signalling we go out of the function
  31.  
  32.  
  33. # we could call this function over and over and get the correct route from 0,0 everytime
  34. # but i think u need to go from the last destination.. idk what way to feed in the entire list of coords
  35.  
  36. # could maybe have a public variable for x and y which store the destination each time u go into the pizzabot function, but seems not so good
  37.  
  38.        
  39. pizzabot(1, 3)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top