r/learnpython • • Mar 22 '21

My mom offered to pay for a python/programming course - should i take it or try to learn myself?

480 Upvotes

This morning my mom called me and told me that her friend's son took part in (not a cheap one) a python course and now he has a well-paid job. I wanted to learn python myself but i kind of don't have time right now( bachelor thesis).

So I wanted to ask, is this a waste of money? Or more like - should I accept my mom's offer or it's not worth it and try to learn python myself?

I study finance so I have probability and statistics and I'm gonna have c++ and python in the next semester if that matters

EDIT: Okay that was my bad i shouldn't have said that i have bachelor thesis: the offer still stands after i finish writing it.


r/learnpython • • Aug 10 '20

I'm learning Python without any education in Computer Science — what books should I read to gain a greater understanding of CS?

480 Upvotes

I'm a few weeks into my journey learning Python. It's my first programming language, and I'm excited. Well... excited and terrified.

Excited by the adventure. But terrified by the amount of work that awaits.

It feels like I'm setting out to climb Mount Everest. And with every day of climbing, I get slightly further on the journey. But I also get a clearer view of the mountain ahead, and a better awareness of just how much I don't know.

Anyway, I suspect that since I don't have a background in CS, it may help to step back from "the mountain climb" of Python for a bit. To learn some fundamentals of Computer Science or "computational thinking".

I recently read and enjoyed "Understanding the Digital World" by Brian W. Kernighan. It's an overview of computers and the internet for someone without a background in CS.

Can anyone recommend other books like this, which may be of assistance on my climb? Thanks!


r/learnpython • • Nov 05 '20

How does one learn to make well-structured programs? Mine are dumpster-fires.

478 Upvotes

So I just (kind-of) finished reading Automate The Boring Stuff With Python, and for the past month I've felt like a big-brained super-hero automating myself out of a job (Data Analyst).

The problem is, I feel I missing something along the way. I don't understand the proper way to use functions, what a class is, why people have multiple files in a program, how/why people use GitHub...probably some other things I haven't discovered yet.

They all seem to be related to organization? Is there a "How To Structure Your Python Stuff With Python" book?


r/learnpython • • Oct 24 '17

6 Months of Python Grinding Pays Off (thanks to this sub)

478 Upvotes

I’m in a customer support leadership position and I’ve been at Python for roughly a half year after learning SQL the first half of the year. It wasn’t in my job description, but all the free time I had I spend working on relevant python scripts and I’d sometimes spend 15+ hours/week outside of the job getting scripts to work.

Our business intelligence officer let me know the plan is to pull me out of support and into an official data analyst role in Q1.

I feel incredibly proud and wanted to share and thank this subreddit for always giving thoughtful answers, and for people not being afraid to ask what they might think are stupid questions. So many good resources are references and a plethora of general programming tips are shared.

For anyone who’s just starting out, keep at it! If you have the opportunity work on scripts practical to your job you’ll eventually you’ll impress someone. I really can’t wait for the opportunity to focus on this stuff full time and really begin to grow.

Thanks!


r/learnpython • • Apr 29 '21

How to get better at programming - 'fast'!

477 Upvotes

I stumbled across this subreddit 1-2 months ago by chance. Since then I have been pretty active here, posting almost daily, trying (and mostly succeeding I hope) to help people solve their python related problems. Now, I'm by no means an expert, programming is only a hobby to me and I work in an unrelated field. I just want to share some of my experiences in the hope someone may find it useful.

Anyway, during this time I noticed a few reoccurring questions that get posted a few times a week:

  1. Is [xyz] book/course a good way to learn python?

  2. I know the basics, how do I get better?

  3. What projects can I do?

Personally I think, and from what I've seen many people agree, the probably 'most efficient / fastest' way of learning python (just my opinion) is to get the basics down and then find yourself a project. Problem based learning. I think, what specific course/book you use to learn the basic building blocks of python isn't even all that important (though there are certainly better and worse options to choose from).

While this method has a solid support base, the question of what project to work on seems to throw off many aspiring and even intermediate programmers. The best choice is obviously to find a project of personal relevance to apply one's skills; It's always more motivating to work on something that is useful to oneself. However, those projects are actually not always readily available or maybe too large/complex to be suitable as a first project for a complete novice. On the other hand, writing a program just for the heck of it without anyone ever using it, is far from motivating.

What I find curious though, is that these people looking for projects are actually sitting on a treasure trove of real world programming problems waiting to be solved and they don't seem to even notice. Namely this sub.

Since I found this sub I've been doing nothing else but opening posts and trying to solve the problems of other people. Oftentimes I only have a vague or no clear idea how to solve these problems. However, I think of different approaches and possible solutions, googling and researching and once I find a solution I post it. The idea is similar to rubber duck debugging. When you want to learn something, try to explain it to someone else, if you can't explain it you don't actually understand it fully yourself. This way in the past 1-2 months I've learned more (also more diverse things) than in the whole last year combined.

It's a win-win situation, the person asking the question gets help and I get free real world exercises and more programming experience. As a plus, there are many people on this sub who, different from me, actually are experts, so you get various creative approaches you can refer and compare your approaches to. And, what's equally important: you get feedback on your solutions. If you are lucky in the form of comments telling you what is good/bad about your approach. Sadly though down votes without an actual explanation are more prevalent (still better than nothing.) If you lack confidence in your skills, solve the problem for yourself first and then wait for other people to reply. Compare the approaches and see if you can improve your answer.

On a side note, I really wish people would give more feedback on posted solutions. Like any field, programming is not a skill you ever master completely, you get more proficient, but there is always more to learn. And in order to learn you need to know what and where to improve. Feedback is essential in learning anything. A down vote is fine, but please say what's wrong with the answer. Thanks!

Now, before I wrap this up (this is already longer than planned), I want to give a short example of my learning curve that might encourage / motivate some people.

I recently posted a solution to a pandas related problem which garnered a bit of attention. Mostly, because I got lucky and implemented a useful method which many people up until then apparently didn't know about. People called me smart or an expert, which I found rather funny and actually embarrassing because it's so far from the truth. After all, one month ago my knowledge of pandas was limited to reading in a csv file. It's just that after trying to solve other people's pandas problems on a regular basis for a month, I rather naturally learned my way around the library. And this super useful method I used? Well, I found it an hour prior in the pandas docs while I was looking to solve this very problem. By putting in the effort to learn, I didn't just help myself but apparently also many others.

My point is, solving all these problems made me learn way faster (and more relevant things) than any tutorial, book or course ever could. While calling me a pandas expert is certainly very much over-exaggerated, my proficiency still rose exponentially. I made similar progress in many different areas over the last 1-2 months (eg. I took a deep dive into python's standard library - a real treasure trove), just by helping other people. Thus, I can only encourage everyone to take part, work on problems even though you may not know the answer initially. Take it as an opportunity to become a better programmer while getting karma as a bonus.

I hope someone found my ramblings useful.

Have a nice day everyone and kudos to this awesome community!


Since I highly doubt that people will actually read this wall of text:

TL;DR - Fastest way to learn programming is doing projects. If you don't have a project try solving the problems on this subreddit as exercises: Free real world problems, feedback, and the possibility to compare your approaches to those of people who know their stuff. Also, you're a good person by helping people, plus you get karma. To sum it up: Help yourself by helping others - everybody wins!


r/learnpython • • Sep 02 '20

To all passionate programmers out there: What is the best process in getting systematically better in learning Python?(up to Level Mastery?) My target is to be a Python Developer in a Startup here in Berlin.

476 Upvotes

I currently work on Automate the Boring Stuff (Fantastic Book). It has plenty of Practical Projects. Well I solve one by one. Simultaneously I build up a GitHub Pages Website where I document my projects.

Is this the best process of getting a job? Solving more and more projects? Making them more and more complex? Does this process lead to Real-World Results?

Thanks guys. Have an incredible day. All the best from Berlin


r/learnpython • • Nov 30 '21

Entry level Python developer interview

475 Upvotes

Hi All! Just had an exhausting 90 min technical interview for the position of Python developer - fresher at a startup. To give a bit of a background, I am an engineer and have been learning python for 1 year. I practice mostly on hackerearth. I have done no python projects whatsoever and although I have mentioned my github profile in my resume, it's just empty. There were 3 sections in the interview-1) Python theory 2) Coding round 3) Logical Reasoning

In the theory round, I was asked about OOPS, unit testing, difference between arrays and lists, static keyword, difference between lists and tuples, list slicing, the concept of 'self' parameter, .py vs .pyc file, public and private keywords, pointers (from c++), and a lot of other stuff that I don't remember. Overall, I started feeling dejected towards the end of this round.

I was most petrified of the coding round as I felt that my coding skills were nowhere close to being a python developer. The first program that I was asked to write was a simple one - find mean and median of an integer list. The catch however is that I wasn't allowed to use the built-in functions to sort the list, so I had to write a separate function using nested 'for loops' to sort the list. Second program was to find the vowels from a given string. It was a bit easy for me as I have been practicing regex for a while now. I finished it in no time. Third program was to reverse a string using tail recursive function. This is where I botched it. I had the idea of what I was supposed to do, but I couldn't get it to work. They appreciated my approach and asked me to mail the solution to them after the interview. At this point I had lost all the hopes of getting through as this was supposed to be a fairly simple program. I would have been able to write it easily any other day, but just when it mattered, I couldn't.

The third round had logical reasoning problems. They asked three problems, first one was the shortest path problem for an ant on a unit cube from one point to the diagonally opposite point. The second problem was three bucket problem, in which we have 2 buckets of capacity 3L and 5L full of water, and a third bucket of 8L capacity empty. The task is to fill 4L water in 8L bucket without any measurement tools by just using the 3 buckets. The third problem, and the toughest one IMHO, was a geometry problem. They drew a rectangle with unknown sides and area, and then marked a point (say 'O') inside it arbitrarily. Then they connected the four vertices of the rectangle with the point ('O') marked inside the rectangle. They specified that the lengths of three of the drawn lines are 4, 5, and 6. I was supposed to find the length of the last remaining line. I guessed the answer to be 3 but apparently it's sqrt(5).

Pretty tired overall, I am not expecting any offer but I learnt a lot of things from this interview. I would like to thank this sub for all the support; the critical stuff that I learned from here was super helpful. To anyone appearing for any Python interviews, Good Luck!

Edit:

I am attaching some of my solutions here.

For regex problem - print(''.join(re.findall(r'[aeiou]',string)))

For the string reversal problem - https://imgur.com/a/l0j9QRQ

For the geometry logic problem - https://imgur.com/a/MMweGoi

For the ant problem- There are 4 equally short routes


r/learnpython • • Dec 21 '19

Is it too late for a 40 years old uncle to learn Python from no basics?

475 Upvotes

I just took my venture in Python learning.

Maybe I am too old. Maybe I have nothing in Mathematics or computer knowledge.

I just wanna try, and see how far and how long I can last.

Hello my new friends here! Hope us growing better!


r/learnpython • • Oct 17 '15

My cousin asked me where I would go if I wanted to learn programming all over again. This was my response.

475 Upvotes
  1. Learn python:

  2. https://www.codecademy.com/en/tracks/python

  3. https://www.coursera.org/learn/python

  4. https://www.coursera.org/learn/python-data

  5. Solve challenges with Python

  6. https://www.hackerrank.com/domains

  7. Note: You should be able to the "Algorithms" and "Python" domains. "AI" is fun too.

  8. Learn skills with Python

  9. https://www.coursera.org/learn/python-databases

  10. https://www.coursera.org/learn/python-network-data

  11. Get ready to build something

  12. Get a Github account -

  13. If you have an edu email: https://education.github.com/pack

  14. Star interesting projects! Search, discover, read!

  15. www.reddit.com/r/Python

  16. StackOverflow.com

  17. Build something!!! Ideas:

  18. I know you're in the financial world. Why not Computational Investing?

    1. https://www.coursera.org/learn/computational-investing

  19. Python webapps are popular. Learn DJANGO (a python framework).

    1. http://gettingstartedwithdjango.com/

  20. Raspberry Pi's are hackable little computers that can be scripted with python. Buy a Pi 2 and hack away! Build a robot

  21. Visit Hackathons!

    1. https://mlh.io/seasons/s2015/events

  22. Do TOPCODER challenges. These are some of the questions that come up in technical interviews

  23. https://www.topcoder.com/challenges/?pageIndex=1

  24. Something else! The possibilities are endless. Find something you want to do and do it!

  25. Next steps

  26. Data Science is huuuuge and it's only getting bigger. Seek out online courses for DS and do the TopCoder DS challenges.

  27. Practice more on Django or Python on Pylons. Search for webdev openings.


r/learnpython • • Sep 19 '20

When you automate something in python, you'd obviously have to run the script forever. Where can we run the script?

473 Upvotes

I want to automate something, and whenever that event occurs, I get an email But I was thinking I can't use my laptop for this as it's not on forever and when I run another script, the previous one stops and I don't get emails How do you approach your automations? Like, do you put it on some server that can run 24 7 or something?


r/learnpython • • 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.

471 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

EDIT: 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.

EDIT: If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.

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/learnpython • • Dec 24 '20

Just turned 5 lines of simple code into 1 unnecessarily convoluted one. FANG, please IM me your offers.

469 Upvotes

Been at this coding thing since April. Felt things really click more since tackling algo/data structures the past 2 months.

But today I became a man. For the first time in my life, I turned 5 lines of clean, readable code into a single spaghetti expression that I'll have to stare at one day to ever understand where I was going with it.

I think I've earned a Bud Lite shandy.

5 lines

minVal = m.inf
for k, v in self.weight.items():
    if k in self.unvisited and v < minVal:
        minVal = v
        u = k

Never slipped a dict comprehension in my lambda before -- but I liked it

u = min({k: self.weight[k] for k in self.unvisited}.items(), key = lambda item: item[1])[0]

r/learnpython • • Jul 11 '21

If you are employed as a python programmer, tell me the stuff you do on a day in the office

468 Upvotes

I want to be employed not python in particular but its my favorite language so I wanted to know what level of knowledge a job requires like what the people in offices actually do? I've seen videos but its just them typing on a computer


r/learnpython • • Feb 22 '19

Got a job offer today after doing the coding challenge and their technical interview with pythob

467 Upvotes

I got offered a new job today and took it. I did the coding challenge in flask and the simple interview question in python. I’m just really happy and just wanted to share somewhere. Thanks for all the help guys.

Edit: just realized my title misspelled python. I’m a disgrace.

Edit2: a lot of people have asked about the challenge and the interview question. I can’t really give out details about the challenge due to signing an nda, but i hopes of keeping it somewhat obscure it was to code a website/api that allowed users to register, login, and then save and manipulate some data.

The interview question was checking two strings to see if they were anagrams.

Update: I was originally going to do some stuff in salesforce but my first few tasks are automating browser testing. I’m using python with splinter. I’m soooooooo happy.


r/learnpython • • Aug 02 '21

[Giveaway] Announcing Practice Python Projects ebook, free for a week

465 Upvotes

Hello!

I'm excited to announce my latest book titled Practice Python Projects. This book presents five beginner to intermediate level projects inspired by real world use cases:

  • Enhance your CLI experience with a custom Python calculator

  • Analyzing poll data from a Reddit comment thread

  • Finding typos in plain text and Markdown files

  • Creating a GUI for evaluating multiple choice questions

  • Square Tic Tac Toe — creating a GUI game with AI

To test your understanding and to make it more interesting, you'll also be presented with exercises at the end of each project. Resources for further exploration are also mentioned throughout the book. Visit https://github.com/learnbyexample/practice_python_projects for programs and related example files presented in this book.

To celebrate the release, all my Python books are free for a week. To get the projects book alone:

The bundle also includes 100 Page Python Intro and Python re(gex)?:

If you prefer web version, visit https://learnbyexample.github.io/practice_python_projects/

Hope you find these books helpful in your Python programming journey. I'd highly appreciate your feedback.

Happy learning :)


r/learnpython • • Mar 20 '20

Possibly the proudest day of my life

465 Upvotes

I have finished my first Python Windows Desktop application in a little under a month. Even tho people told me to change language and I found quite a few pitfalls with some libraries . It is a Connectwise Manage employee time manager, with an Active Directory Logon and uses the time entries done by employee and push data to extra data fields. It even print reports in excel and PDF. It's moving to production next week! Thank you to those that told me to stick with it!


r/learnpython • • Nov 22 '22

I built an app that scans every social media network for your username, and this is how

464 Upvotes

I found myself scrolling through Github’s “trending” repos, looking for some coding inspiration. Within the next hour, I stumbled across something called The Sherlock Project. Interesting, It had over 35k stars, must be pretty popular.

I quickly cloned the repo and started toying around with it. It didn’t take me long to realize the power of this tool. All I had to do was insert a username, and Wa Lah! I was looking at every social media website that was associated with the username. Not only that but direct links to the accounts.

I immediately wanted to turn this into a web app so that everyone could use it. My first challenge was that this was a CLI tool, so I got to work. The Sherlock project makes about 400 requests to various site s to check if your username exists. This was going to be tough... I noticed they were using requests.FutureSession to multithread the result.

My first thought was maybe I could collect all the requests into a list and then dump it back to the frontend with a get request, but the issue here was that the results could take a couple minutes to gather, and no-one is gonna sit and wait that long.

Ok, so how do I continuously report out data to the frontend as the requests get full-filled? The answer? Web-sockets. Not just any web-socket though, a multithreaded web-socket. After ALOT of trial and error I finally got something working. The Issue now though was that it wouldn't run in production due to a multiprocessing error: Daemonic processes are not allowed to have children.

The hell did that mean? back to the drawing board. Eventually I learned that you cant use the standard multiprocessing library for this kind of thing, you had to use billiard. Bam! It worked. I quickly hacked together a simple frontend, configured the web socket, and results were pouring in.

Time to post on reddit. I quickly sent out a post or two and eagerly awaited peoples responses. There was an issue though. The more people flooded the site, the slower it got until it was completely unusable. Dang. How do I fix this? I removed the post quickly and got back to work.

Turns out, the web-socket is considered a "long running request" as it makes 400 external requests. Maybe I could use celery to offload this process to a worker and queue it up. I started working on it and realized this was a little out of my skill range.

I then decided to take a look at the logs where I hosted the code and what do i find? CPU, Memory, and bandwidth all reaching a staggering 100% usage. Welp, I found my issue. I did some rework of my codebase and it started running a little faster.

I then realized the true issue. I was using the free tier of Render that only allowed for one instance of my app...duh.

Needless to say, I learned to take it slow, build tests for my code, and be patient with results.

Here is the final result: https://www.handlefinder.com/

What do you guys think? Any hard lessons learned in coding? What were your takeaways?

Here is also a link to the repo: https://github.com/bnkc/handlefinder


r/learnpython • • Feb 03 '21

My eyes have been opened!

464 Upvotes

Only 2 weeks into learning Python and I’m already dreaming of what I can be automating. Loads of help and ideas in here, so thanks to everyone that contributes!

I’m enjoying the challenge of working things out, but my 1st plan is to read a pdf, extract certain bits of data and transpose into a predefined template.

Already cracked pdf reading (thanks to the course by Al Sweigart!), so onto the next step.

Any thoughts or tips on how or where to store data once I’ve extracted text from a pdf would be appreciated!

Edit: thanks all for the comments support and ideas. Really appreciated!

A few people have asked what resources I’m learning from - I’m using the youtube beginners guide by Mosh and and Automate the Boring Stuff by Al Sweigart on Udemy. They cover similar topics but in different ways, so I’ve learnt from both. Not to mention this group, I’ve been a lurker for a while and this is my 1st post.

I do have the benefit of working in a data driven industry, so I have something practical and tangible to work towards. People have different learning styles, but I think I struggle to learn without having a project that “means something” to me.

So I guess that would be my takeaway - don’t just expect to learn python by taking a few courses. Learn the basics, but try to apply some practical examples as soon as you get your head around the logic!


r/learnpython • • Jul 15 '24

my hello world program is a little slow for some reason

463 Upvotes
import random as rand

letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 
    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ',', ';',
    ':', '!', '?', '-', '_', '(', ')', '[', ']', '{', '}', '"', "'",
    ' ']

a1 = ''
a2 = ''
a3 = ''
a4 = ''
a5 = ''
a6 = ''
a7 = ''
a8 = ''
a9 = ''
a10 = ''
a11 = ''
a12 = ''

while a1 != 'H':
    n = rand.randint(0, 78)
    a1 = letters[n]
    print(a1)
while a2 != 'e':
    n = rand.randint(0, 78)
    a2 = letters[n]
    print(a1 + a2)
while a3 != 'l':
    n = rand.randint(0, 78)
    a3 = letters[n]
    print(a1 + a2 + a3)
while a4 != 'l':
    n = rand.randint(0, 78)
    a4 = letters[n]
    print(a1 + a2 + a3 + a4)
while a5 != 'o':
    n = rand.randint(0, 78)
    a5 = letters[n]
    print(a1 + a2 + a3 + a4 + a5)
while a6 != ' ':
    n = rand.randint(0, 78)
    a6 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6)
while a7 != 'W':
    n = rand.randint(0, 78)
    a7 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7)
while a8 != 'o':
    n = rand.randint(0, 78)
    a8 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8)
while a9 != 'r':
    n = rand.randint(0, 78)
    a9 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9)
while a10 != 'l':
    n = rand.randint(0, 78)
    a10 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9+ a10)
while a11 != 'd':
    n = rand.randint(0, 78)
    a11 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9+ a10 + a11)
while a12 != '!':
    n = rand.randint(0, 78)
    a12 = letters[n]
    print(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9+ a10 + a11 + a12)

r/learnpython • • May 06 '24

What is the most practical application you have used Python for?

463 Upvotes

I know literally nothing about Python besides "it is a coding language" and "it's easier for dopes like me to pick up than some other coding languages". So my real question is, "Why should I learn Python?" What could I do with it that would improve my life, workflow, or automate menial tasks?


r/learnpython • • Dec 28 '19

I've been using Python for 5 years professionally. TODAY I discovered concurrent futures

463 Upvotes

Granted, I don't do much in the way of concurrency. But still, I have several open projects and have always used threading. It took me until today to discover a feature implemented in Python 3.2...

But given that it's comically simple, given an example, I figured I'd share one.

import concurrent.futures
import random 
import datetime
import time
import uuid

def do_something(seconds, name):
	print(f"Sleeping {seconds}\t{name}\t{str(datetime.datetime.now())[:19][11:]}")
	time.sleep(seconds)

with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
	for i in range(50):
		executor.submit(do_something
			, seconds = random.randint(1,6)
			, name = str(uuid.uuid4())[:6].upper())

r/learnpython • • Feb 09 '23

Petition to the Mods to allow removal of chatgpt posts

462 Upvotes

Mods, can we please bar posts on the sub that present the output of chatgpt along with any kind of "it doesnt work, fix it for me" or "will this chatgpt script work" comment?

I believe that chatgpt as a technology is pretty amazing. As an individual who holds a PhD in the arts, whose dissertation was explicitly about AI and machine learning applications to artmaking, I'm deeply interested in these technologies. But any learning that can happen from chatgpt's ability to generate python is more on the side of understanding what is possible with such AI models. Thus far, it has not had a positive impact on this community. I believe that if one wants to learn from examples of code, they should be directed to documentation (python docs, library docs, project docs), and examples written by other reputable individuals. Heck, reading the problems encountered by folks who frequent this sub are more informative than reading chatgpt output... for one big reason, the authors can provide reasoning and justification.

I would like to propose that any posts that mention chatgpt should be allowed if they are concerned with how to issue HTTP requests to an api endpoint using python, as that is a relevant and valuable thing to learn with the language. Corrections or debugging chatgpt generated code should be banned from the sub. Discussions of chatgpts generative strengths and weaknesses should also be banned, this is not a machine learning sub.

Edit: spelling corrections


r/learnpython • • May 11 '23

Just discovered a huge hole in my learning. Thought I'd share.

460 Upvotes

A funny thing about being entirely self-taught is that a person can go pretty far in their Python journey without learning some core concepts. I discovered one today. Let's say I have a class called Pet:

class Pet:
    def __init__(self, type, name, number):
        self.type = type
        self.name = name
        self.number = number

And I create a couple pets:

rover = Pet('dog', 'Rover', 1)
scarlet = Pet('cat', Scarlet', 2)

And I put those pets in a list:

pets = [rover, scarlet]

And I do some Pythoning to return an item from that list:

foo = pets[0]

Here's what I learned today that has blown my mind:

rover, pets[0], and foo are the same object. Not just objects with identical characteristics. The same object.

If I make a change to one, say:

foo.number = 7

then rover.number == 7 and pets[0].number == 7.

For almost two years, I have been bending over backwards and twisting myself up to make sure that I am making changes to the right instance of an object. Turns out I don't have to. I thought I'd share my 'Aha' of the day.

I have an embarrassing amount of code to go optimize. Talk to you later!


r/learnpython • • Jun 04 '23

2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (June 2023)

459 Upvotes

EDIT: The codes are all used up this month, but you can still watch the first 15 videos for free on YouTube. I've enabled Preview on all the videos, so you can watch them from the course page.

If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):

https:// udemy.com/course/automate/?couponCode=JUN2023FREE

https:// udemy.com/course/automate/?couponCode=JUN2023FREE2

Udemy has changed their promo code and severely limited the number of sign ups I can provide each month, so only sign up if you are reasonably certain you can eventually finish the course. The first 15 of the course's 50 videos are free on YouTube if you want to preview them.

YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.

NOTE: 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. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.

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.

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. If you have a VPN service, try to sign up from a North American or European proxy.

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.

Side note: My latest book, Python Programming Exercises Gently Explained is a set of 42 programming exercises for beginners for free or as a 99 cent ebook.

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