Advertisement
asweigart

Untitled

Oct 21st, 2019
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. CLASS NOTES FOR THE TWITCH PYTHON CLASS
  2.  
  3. Full details about the class here: https://inventwithpython.com/blog/2019/10/20/live-online-python-class-on-twitch-on-october-21-2019/
  4.  
  5. FREE ONLINE CLASS COUPON CODE (only good today and tomorrow): https://www.udemy.com/course/automate/?couponCode=OCT2019FREE
  6.  
  7. I'm assuming you have Python 3 (any 3.x version) installed an working.
  8.  
  9. I've create a repo of several small games for beginners to examine the source code of: https://github.com/asweigart/pythonstdiogames
  10.  
  11. Copy along with the code being streamed, but you can also look at it directly here:
  12.  
  13. https://raw.githubusercontent.com/asweigart/PythonStdioGames/master/src/zigzag.py
  14. https://raw.githubusercontent.com/asweigart/PythonStdioGames/master/src/rockpaperscissors.py
  15. https://raw.githubusercontent.com/asweigart/PythonStdioGames/master/src/rockpaperscissorsalwayswin.py
  16. https://raw.githubusercontent.com/asweigart/PythonStdioGames/master/src/game2048.py
  17. https://raw.githubusercontent.com/asweigart/PythonStdioGames/master/src/mancala.py
  18.  
  19. Feel free to ask questions, but try to answer them yourself first. Read this blog post on how to ask effect programming questions: https://inventwithpython.com/blog/2018/02/02/how-to-ask-for-programming-help/
  20.  
  21. ===================================================================
  22.  
  23. This file will be updated with notes during the course.
  24.  
  25. squishColumns() function:
  26.  
  27. http://pythontutor.com/visualize.html#code=BLANK%20%3D%20''%0A%0Adef%20squishColumn%28column%29%3A%0A%20%20%20%20%23%20%60column%60%20is%20a%20list%20of%204%20values%3A%20either%20an%20int%20of%20the%20tile%20like%202%20or%2064,%20or%20the%20BLANK%20string.%0A%20%20%20%20%23%20The%20%22bottom%22%20of%20the%20column%20is%20index%200%20of%20the%20list.%0A%20%20%20%20%23%20Tiles%20always%20fall%20towards%20the%20bottom%20of%20the%20column.%0A%0A%20%20%20%20%23%20column%20%3D%20%5B2,%20BLANK,%20BLANK,%202%5D%20%3D%3E%20%5B4,%20BLANK,%20BLANK,%20BLANK%5D%0A%20%20%20%20%23%20column%20%3D%20%5B2,%20BLANK,%20BLANK,%20BLANK%5D%20%3D%3E%20%5B2,%20BLANK,%20BLANK,%20BLANK%5D%0A%20%20%20%20%23%20column%20%3D%20%5BBLANK,%202,%20BLANK,%20BLANK%5D%20%3D%3E%20%5B2,%20BLANK,%20BLANK,%20BLANK%5D%0A%0A%20%20%20%20%23%20NOTE%3A%20Index%200%20is%20always%20the%20bottom%20of%20the%20column.%0A%0A%0A%20%20%20%20%23%20Drop%20all%20the%20numbers%20down%20into%20any%20blank%20spaces%3A%0A%20%20%20%20%23%20%5B2,%20BLANK,%20BLANK,%202%5D%20%3D%3E%20%5B2,%202,%20BLANK,%20BLANK%5D%20%3D%3E%20%5B4,%20BLANK,%20BLANK,%20BLANK%5D%0A%20%20%20%20columnNumbers%20%3D%20%5B%5D%0A%20%20%20%20for%20i%20in%20range%284%29%3A%0A%20%20%20%20%20%20%20%20if%20column%5Bi%5D%20!%3D%20BLANK%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20columnNumbers.append%28column%5Bi%5D%29%0A%20%20%20%20%20%20%20%20%20%20%20%20column%5Bi%5D%20%3D%20BLANK%20%23%20%3F%3F%3F%3F%20Why%20is%20this%20here%3F%0A%0A%20%20%20%20for%20i,%20number%20in%20enumerate%28columnNumbers%29%3A%0A%20%20%20%20%20%20%20%20column%5Bi%5D%20%3D%20number%20%23%20Copies%20columnNumbers%20to%20column%0A%0A%20%20%20%20%23%20Squish/combining%20step%3A%0A%20%20%20%20for%20startingIndex%20in%20range%283%29%3A%20%23%20Skip%20index%203,%20since%20nothing%20can%20be%20on%20top%20of%20it.%0A%20%20%20%20%20%20%20%20if%20column%5BstartingIndex%5D%20%3D%3D%20column%5BstartingIndex%20%2B%201%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20column%5BstartingIndex%5D%20*%3D%202%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20aboveIndex%20in%20range%28startingIndex%20%2B%201,%203%29%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20column%5BaboveIndex%5D%20%3D%20column%5BaboveIndex%20%2B%201%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20column%5B3%5D%20%3D%20BLANK%0A%0A%0AsquishColumn%28%5B2,%202,%20BLANK,%202%5D%29%20%23%20%5B4,%202,%20BLANK,%20BLANK%5D&cumulative=false&curInstr=0&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=3&rawInputLstJSON=%5B%5D&textReferences=false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement