r/inventwithpython • • Oct 01 '21

Thank you for helping me reach one million sign ups: Use code OCT2021FREE to sign up for the "Automate the Boring Stuff with Python" online course.

36 Upvotes

Whoa.

I'd like to thank everyone on Reddit and all the folks who have taken my course or read my programming books. I'm completely floored by the response I've gotten to this course. It's incredible and I feel so fortunate for being able to have such a large impact. As I write this, there are 999,866 folks who have signed up for my beginner programming course, so it looks like today, October 1st, 2021, will the day when I reach 1,000,000 sign ups. The vast majority of these are free sign ups. According to my metrics, only about 8% or so of students finish the course (about average for online courses).

But knowing that I've been able to teach roughly tens of thousands of folks to program really... gives me a satisfied sense that I'm useful. As Muhammad Ali put it, "Service to others is the rent you pay for the room here on earth." It's something I worry about a lot, but the number of people telling me they find my stuff useful is a great reassurance.

Thank you.

Anywhere, here's the usual info:

https://inventwithpython.com/automateudemy (This link will automatically redirect you to the latest discount code.)

You can also click this link or manually enter the code: OCT2021FREE

https://www.udemy.com/course/automate/?couponCode=OCT2021FREE

Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default.

This promo code works for 3 days (I can't extend it past that). Sometimes it takes an hour or so for the code to become active just after I create it, so if it doesn't work, go ahead and try again a while later. I'll change it to OCT2021FREE2 in 3 days, and that code will work for another 3 days.

Some people in India and South Africa get a "The coupon has exceeded it's maximum possible redemptions" error message. Udemy advises that you contact their support if you have difficulty applying coupon codes, so click here to go to the contact form.

I'm also working on another Udemy course that follows my recent book "Beyond the Basic Stuff with Python". So far I have the first 15 of the planned 56 videos done. You can watch them for free on YouTube.

Udemy has changed their coupon policies, and I'm now only allowed to make 3 coupon codes each month with several restrictions. Hence why each code only lasts 3 days. I won't be able to make codes after this period, but I will be making free codes next month. Meanwhile, the first 15 of the course's 50 videos are free on YouTube.

Side note: My latest book, The Big Book of Small Python Projects, is out. It's a collection of short but complete games, animations, simulations, and other programming projects. They're more than code snippets, but also simple enough for beginners/intermediates to read the source code of to figure out how they work. The book is released under a Creative Commons license, so it's free to read online. (I'll be uploading it this week when I get the time.) The projects come from this git repo.

Frequently Asked Questions: (read this before posting questions)

  • This course is for beginners and assumes no previous programming experience, but the second half is useful for experienced programmers who want to learn about various third-party Python modules.

  • If you don't have time to take the course now, that's fine. Signing up gives you lifetime access so you can work on it at your own pace.

  • This Udemy course covers roughly the same content as the 1st edition book (the book has a little bit more, but all the basics are covered in the online course), which you can read for free online at https://inventwithpython.com

  • The 2nd edition of Automate the Boring Stuff with Python is free online: https://automatetheboringstuff.com/2e/

  • I do plan on updating the Udemy course for the second edition, but it'll take a while because I have other book projects I'm working on. If you sign up for this Udemy course, you'll get the updated content automatically once I finish it. It won't be a separate course.

  • It's totally fine to start on the first edition and then read the second edition later. I'll be writing a blog post to guide first edition readers to the parts of the second edition they should read.

  • I wrote a blog post to cover what's new in the second edition

  • You're not too old to learn to code. You don't need to be "good at math" to be good at coding.

  • Signing up is the first step. Actually finishing the course is the next. :) There are several ways to get/stay motivated. I suggest getting a "gym buddy" to learn with. Check out /r/ProgrammingBuddies


r/inventwithpython • • Oct 05 '21

Why only this comes out after running the program?

3 Upvotes

I am learning Python on my own. I'm on my fourth day of Python right now. I'm learning Python with the book Automate the boring stuff with Python, and I've just finished chapter 1. I started my first program on chapter 1 today, and this is the result:

After running the program only this comes out. What is the error? Can someone help me, please?


r/inventwithpython • • Nov 16 '21

Tic Tac Toe - Help with function I cannot understand.

5 Upvotes

Can someone kindly explain:

70. def chooseRandomMoveFromList(board, movesList):
71.     # Returns a valid move from the passed list on the passed board.
72.     # Returns None if there is no valid move.
73.     possibleMoves = []
74.     for i in movesList:
75.         if isSpaceFree(board, i):
76.             possibleMoves.append(i)

What is movesList and how does it work exactly? I' m stuck here, I cannot figure out how movesList works with isSpaceFree to return possible moves? Is that even what movesList does?


r/inventwithpython • • Nov 13 '21

Error Installing Python Packages · Issue #6 · asweigart/automateboringstuff

Thumbnail
github.com
7 Upvotes

r/inventwithpython • • Oct 14 '21

Excel sheet specific width for each column?

3 Upvotes

I'm doing a script to prepare a list lf coordinates with other parameters to import in a finnicky software that only accepts .prn files with a specific amount of spaces as separator for each column.
Righ now we use a xlt model, copy-paste everything where it needs to go wothout touching anything, and save as .prn.
I managed to open and edit (adding and deleting columns mostly) the original txt file and save it as xls using Pandas. The problem is that if I try to save it as .prn(cvs), it puts a comma as separator (sep= " " doesn't seem to work), and if I save it as xls the columns have all 64 pixels, wich when saved manually puts the wrong amount of spaces between columns. Each column needs a different amount of spaces as separator, in pixels something like 50, 25, 45, 70, 90, 70; so I need to set every column separately.
I tried googling it but can't find a solution that actually works...
Any suggestions of how to do it?


r/inventwithpython • • Aug 25 '21

Practice problems

5 Upvotes

I am teaching myself python on the side and started with Crash Course but to Automate the Boring Stuff when I thought it was more applicable to my day job.

I am really enjoying the book and learning a lot but I wish there were more practice problems for me gain a deeper understanding of each concept. For example, the Collatz Sequence at the end of chapter 3 really reinforced the topics covered in the preceding sections.

Any suggestions of where I could find some practice problems with solutions? I had considered the Big Book of Small Python Projects but would like something more focused on individual topics, i.e. here how dictionary’s works try these problems.


r/inventwithpython • • Sep 12 '21

IS EXTENDING HANGMAN SOURCE CODE INCORRECT?

1 Upvotes

Good day everyone,

I am currently on chapter 9 (Extending Hangman) of Invent Your Own Computer Games w/ Python.

This chapter is supposed to print "HANG MAN", asks player to choose a difficulty level, and choose a word from the dictionary.

When I run the code, I notice it does not ask me for the difficulty level, despite adding lines 106 to 116.

Is this accurate or is the code missing something?

  • while difficulty in 'EMH':

  • print('Enter difficulty: E - Easy, M - Medium, H - Hard')

  • difficulty = input().upper()

  • if difficulty == 'M':

  • del HANGMAN_PICS[8]

  • del HANGMAN_PICS[7]

  • if difficulty == 'H':

  • del HANGMAN_PICS[8]

  • del HANGMAN_PICS[7]

  • del HANGMAN_PICS[5]

  • del HANGMAN_PICS[3]


r/inventwithpython • • Sep 25 '24

Feedback on Automate the Boring Stuff Summary

5 Upvotes

Hello Community.

I am currently working on going over all the chapters in the book. Would anyone like me to share the notes for each chapter? it will also include code snippets and some additional information.


r/inventwithpython • • Jul 02 '17

Automate the Boring Stuff - Chapter 7 - Password Detection Problem help

2 Upvotes

Hi all; I'm attempting the problem I've listed in the title (link here: https://gyazo.com/984db9a628c9670a0181a0c22209fcfe).

Here is my script (https://gyazo.com/b38fe7a832c98aa198850fb590d7fec4) but when I run it I don't seem to get an output, getting this screen (https://gyazo.com/074dc02ec3924d3458da5e84dbbcaf90).

Any help would be brilliant, thanks in advance!


r/inventwithpython • • Jan 22 '16

Automate the Boring Stuff with Python - Chapter 10 - Logging won't print

1 Upvotes

I'm currently teaching myself Python in my spare time using Automate the Boring Stuff with Python. I've been working through chapter 10 which deals with debugging and I am having trouble with one of the examples. I'm unable to get Python to print the strings found in logging.debug(), so all I'm outputting is the final result which is 0 in this case. The code that I have been trying to replicate is:

import logging

logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
logging.debug('Start of program')

def factorial(n):
    logging.debug('Start of factorial(%s%%)' %(n))
    total = 1

    for i in range(n + 1):
        total *= i
        logging.debug('i is ' + str(i) + ', total is ' + str(total))

    logging.debug('End of factorial(%s%%)' % (n))

    return total

print(factorial(5))
logging.debug('End of Program')  

r/inventwithpython • • Sep 06 '14

chapter 10 tic-tac-toe not working

2 Upvotes

i made a small change on line 26, replacing the print and then letter = input() statement with a letter = raw_input(print 'do you want to be 'o' or 'x'')

that ran fine, but when the program advances my move never registers or appends to the board. i copied this from the source script. has anyone else has issues/insights?


r/inventwithpython • • Jul 28 '16

[Automate] Ch. 7 strip() project: more efficient way to write?

2 Upvotes

Hope this finds you all well. I've been working on the strip() project at the end of Ch 7, and I would love some ways to improve my code. As of now, I'm able to take off whatever I put it in as my second argument off from the left side, but can't completely do so on the right side. I'm using multiple regexes to address each extra character on the left side so I would appreciate some advice on how I can get this all down in a single Regex.

http://pastebin.com/M8igY6Tu

Regards,


r/inventwithpython • • Jan 31 '16

Practice Projects

6 Upvotes

Does anyone have all the practice projects solved ?


r/inventwithpython • • Aug 31 '14

Making Games with python, Squirrel example, questions.

2 Upvotes

Hey everyone, I'm new to python and pygame generally. I have been trying to study the several examples of the book and have learnt quite a lot already in short time. I have several questions though regarding some of the code:

  1. Line 108. # camerax and cameray are where the middle of the camera view is. The way it works in the code below however it seems that camerax, cameray are the top left coordinates of the view and not the middle.

  2. Line 172. if (camerax + HALF_WINWIDTH) - playerCenterx > CAMERASLACK:

The way I understand the code by typing/running is that this condition seems to check whether the player is more pixels to the left of the center while the line 174 checks whether it is to the right. However in the text the opposite is stated. Which one is the correct interpretation?

3. Line 275. if 'rect' in sqObj and playerObj['rect'].colliderect(sqObj['rect']):

why is 'rect' in sqObj required in the if statement? Isn't it enough to call if playerObj['rect'].colliderect(sqObj['rect'])? Can't we just omit the 'rect' in sqObj? I am running it without it and it seems to work fine I just don't understand whether by omitting it there is a subtle loss.

Thank you in advance for your help.


r/inventwithpython • • May 31 '15

Understanding Len function in Chapter 9 (Hangman)

2 Upvotes

So I actually bought the book "Invent your own computer games with Python", third ed.

I'm new to programming though i've tested it before in school, back then I had a hard time to keeping up and understanding everything. I don't know if that has anything to do with my not so high math skills, but anyway.

I'm reading chapter 9 at the moment and I'm kinda stuck in the follwing section:

61. def getRandomWord(wordList): 62. # This function returns a random string from the passed list of strings. 63. wordIndex = random.randint(0, len(wordList) - 1) 64. return wordList[wordIndex]

I think the author has forgotten to explain the len-function in the book. I googled it of course, and I know that len "counts" how many letters a word exists of for example. But if anyone could explain the line 3 (btw, its actually 63 if you read the book, but the post keep typin 1,2,3,4) to me, I would be grateful.

Link: https://inventwithpython.com/chapter9.html

I know that the function returns a single secret word from the wordLIst, but I dont know how. Why is there a len-function, why do we want to count how many letters there is in the word we want to randomly select?

As you can guess, I need a kick in the right direction. Please explain to me as if I'm 5 years old :).

Ms


r/inventwithpython • • Jul 30 '16

Question??? Invent with Python, Hangman Game

1 Upvotes

In the hangman game I do not exactly know what the **end = ' ' ** does. I really don't understand why it's in the print function either.


r/inventwithpython • • Sep 28 '13

Make python/pygame script into an .exe

4 Upvotes

I am wondering where a good place would be to learn to compile the games we create using pygame into an .exe maybe even a .dmg? I have been looking into cx_freeze, is this a good option? Have you made any tutorials on the subject?

Thank heaps!


r/inventwithpython • • Aug 09 '16

Tic Tac Toe function I don't understand

2 Upvotes

Hi.

There's a certain function whose inner workings I don't understand.

I refer to this one:

'def getPlayerMove(board): # Let the player type in their move. move = " " while move not in "1 2 3 4 5 6 7 8 9".split() or not isSpaceFree(board, int(move)): print("What is your next move? (1-9)") move = input() return int(move)'

I understand the 'while move not in "1 2 3 4 5 6 7 8 9".split()'. It won't leave the while loop until the user inputs something in the list of integers from 1 to 9, that's easy.

However, I don't understand how the 'or not isSpaceFree(board, int(move))' part works. I've deleted it in the hopes of figuring how it works, but it doesn't seem obvious to me. Upon these arguments deletion, I can choose the same spot on the board, even after choosing the same spot on a previous turn.

I assume it won't let the player choose a spot on the board which was already taken but I don't really get how it works. Shouldn't that 'or' be an 'and'? Because the player must choose an integer from 1 to 9 AND it must be on a spot that wasn't taken. That function works with another reasoning I'm having problems to fully grasp, so I humbly ask for guidance on this matter.


r/inventwithpython • • Nov 22 '17

Automating Gmail with Inconsistent results

4 Upvotes

Has anyone else experienced the problem of the script running only once then only going halfway the second time. I noticed the selectors keep changing whether I use css_selectors or xpath to locate the message body and 'send' button. TIA.


r/inventwithpython • • Jun 13 '15

image window disappears

3 Upvotes

The following code creates a window on my screen, which disappears after about 1 second:

---code--

import pygame, sys

from pygame.locals import *

'''set up pygame'''

pygame.init()

'''set up the window'''

windowSurface = pygame.display.set_mode((500, 400), 0, 32)

pygame.display.set_caption('Hello world!')

--end code--

I've tried it with two setups with the same result: python2.7 and python3.4.

Before I put 3.4 on my system, python2.7, it ran with what I expect is the correct behavior, i.e., the image persisted until I killed python. After installing 3.4 and pygame for 3.4, the current problem emerged.

My OS is Debian Wheezy.

ALSO, is it possible to post to this forum using email?

FINALLY, i looked at the formatting help page and i can't find a way to set code blocks in the messages.

thanks in advance ;o)


r/inventwithpython • • Jan 19 '16

Nested For Loop Confusion

1 Upvotes

For some reason, I can't figure out what's actually going on inside a nested for loop. For example, the practice question in Chapter 4 (also referenced here).

grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]

for j in range(len(grid[0])):
    for i in range(0, len(grid)):
        print(grid[i][j], end='')
    print()

If there's anything out there that can explain what is kind of going on in this code, it would be super helpful.


r/inventwithpython • • Jul 28 '16

Chapter 6 Project: Password Locker

1 Upvotes

I'm working through Automate the Boring Stuff, and it's been going pretty well until Ch. 6. No matter what I do I can't seem to get this script to run.

When I try to run it in IDLE I receive the following error message:

Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> email NameError: name 'email' is not defined

And, when I try to run it from the command line it correctly prints the line: "Usage: python pw.py [account] - copy account password" but then gives me "Press any key to continue..."

I'm certain I have the code typed out correctly (but I've pasted it below), and I'm using Windows 10 and Python 3.5.2. Any ideas? Thank you

! python3

pw.py - An insecure password locker program

PASSWORDS = {'email': 'easyPW', 'blog': 'hardPW', 'luggage': '12345'}

import sys, pyperclip if len(sys.argv) < 2: print('Usage: python pw.py [account] - copy account password') sys.exit()

account = sys.argv[1] # first command line arg is the account name

if account in PASSWORDS: pyperclip.copy(PASSWORDS[account]) print('Password for ' + account + ' copied to clipboard.') else: print('There is no account named ' + account)


r/inventwithpython • • Jan 27 '16

Trouble installing Pyautogui

1 Upvotes

Hey everyone,

I've been struggling to install pyautogui for quite some time. My environment is OSX 10.9.5 and my pip3 version is 7.1.2. Using python 3.5

Anyways I've tried

sudo pip3 install pyautogui, 
sudo pip3 install --upgrade pypautogui

It seems like I am missing Quartz, though when I try to install it i get: Could not find a version that satisfies the requirement Quartz (from versions: ) No matching distribution found for Quartz

When I try to installl pyautogui I get:

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-0skmo2kq/pyautogui

Any help is greatly appreciated!


r/inventwithpython • • Jun 08 '15

Application specific passwords with Gmail?

3 Upvotes

I am using Automate the Boring Stuff with Python. I am working on sending email from Chapter 16. It's asking for an application specific password when I try to login. The book says to check the resources at nostarch.com/automatestuff but I can't find any references that refer to that . How do I set up an application-specific passwords for my script so I can use gmail as my outgoing mail server.

Thanks for any help


r/inventwithpython • • Jun 16 '15

Chapter 3 Practice Problem - The Collatz Sequence (Help please)

5 Upvotes

*Edit: I forgot to mention that this is for "Automate the Boring Stuff with Python"

I've been attempting to figure this out for a few days now and I can't figure it out. I'm not looking for the answer, but if someone could point me in the right direction, I'd really appreciate it. The problem is the following:

Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that lets the user type in an integer and that keeps calling collatz() on that number until the function returns the value 1. (Amazingly enough, this sequence actually works for any integer—sooner or later, using this sequence, you’ll arrive at 1! Even mathematicians aren’t sure why. Your program is exploring what’s called the Collatz sequence, sometimes called “the simplest impossible math problem.”) Remember to convert the return value from input() to an integer with the int() function; otherwise, it will be a string value. Hint: An integer number is even if number % 2 == 0, and it’s odd if number % 2 == 1. The output of this program could look something like this: Enter number: 3 10 5 16 8 4 2 1"

My code is the following:

http://pastebin.com/6EYktZ22

Which gets me 3, 10, and then 5 repeating.

I've also tried: http://pastebin.com/gnsxyp8x

Which gets me 3, and then 10, 5 repeating.

Thanks to anyone who can help!