r/learnpython • • Feb 08 '23

Why didn't I learn this sooner?!

336 Upvotes

I started learning Python a few months ago and I feel like I'm still very much a beginner. However, I want to learn about front-end stuff so I'm gonna be starting the Odin Project this week.

To keep my Python sharp as I switch gears, I've decided to try and speed run the official Python tutorial. I figured I'd get through a lot of the beginning sections quickly, but, holy crap, I'm already learning such neat and easy features of the language!

So this made me think: what topics do you feel you learned way too late? I'll give my two examples to start:

  • The enumerate method: Seems super useful for looping over iterables which may contain duplicates values.

  • Else clauses on loops: Too many times I used and abused Booleans to decide if a loop had terminated or not, but no more!

Put your examples, whether they're beginner level like mine or more advanced, below!


r/learnpython • • Jun 28 '20

Can anyone explain why we use Python

336 Upvotes

I keep reading people say things like ‘because Python is built on C’ and ‘Python is much slower than C++ or Go’, ‘Thats why those languages are used to make most popular games’. I also see people refer to Python as a ‘machine’ language, etc etc. So... why use python then if you can do things faster with another language? And why is Python so popular if this is the case? Seems like python is easier to understand for me at least and much easier to read, but is there some other benefit I’m not understanding? Sorry if this had been asked before, I can’t find any direct comparison information between Python and other languages.

EDIT: Thanks everyone! I feel a much better understanding of why python is fast in a different way from other languages, saving programming time rather than computing time. Definitely got the answers I was looking for.

Another edit: Great insights all around. Thanks to everyone taking the time to answer! Looks like I need to do some more research on Cython as I see a few people mentioning it for when speed is required.


r/learnpython • • Jun 22 '20

How to approach Automate the Boring Stuff?

336 Upvotes

Hi all,

I have been using all the extra time we have at the moment to start studying Python (no previous coding experience). I tried Codecademy for awhile, alongside a few Youtube tutorials - but after seeing it recommended so much on this sub started working my way through the ATBS book. I'm really enjoying it so far; it feels like it's sticking a lot more than the other avenues I had tried before!

I was just wondering if it is the sort of text I should work through from start to finish, or if after covering some of the introductory chapters I should jump into the later sections and begin working on some usable projects? For those that aren't familiar with the text, you can find it here.

I'm not sure it's worth mentioning, but I am currently making my way through chapter 3. Fortunately, I am still able to do my job from home, so have been squeezing in time for learning early in the mornings or on my lunch breaks.


r/learnpython • • Dec 02 '19

Advent of Code (AoC) 2019 starts today!

336 Upvotes

https://adventofcode.com/

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

These puzzles are a great way to practice your Python and problem solving skills.

Edit: added description from AoC site.


r/learnpython • • Dec 04 '20

Just wrote my first real Regex's for Advent of Code Day 4

335 Upvotes

I can identify whether a string is 9 numbers in a row. I am a god and can bend computers to my will.
For real though, it feels amazing to have written something that looks like gibberish but actually works, even if it's actually pretty simple. Now I don't have to mess around with 30 nestled if statements and .split() statements. Regex's are pure magic.


r/learnpython • • Sep 03 '20

Windows defender thinks that code I wrote using python 3.8.5 and converted to .exe file using pyinstaller is a virus.

335 Upvotes

I wrote a small program that I plan to use on school computers that gives me information about elements and common polyatomic ions using python 3.8.5. I converted the .py file into a single .exe file for windows 10 using the command pyinstaller --onefile "``MyCode.py``". However, when I go to the folder where pyinstaller placed the .exe file, windows defender looks at my .exe file, thinks it is a Trojan and immediately quarantines it placing it into a folder to which I do not have any access to without my approval. The .py file does not contain any viruses. How can I convert the python script into a .exe file so that windows defender does not think that the .exe file is a virus without doing anything to windows defender (as I plan to use it on school computers)? pyinstaller --onedir "MyCode.py" works, but it is not what I want because the .exe file requires python to run.

OS: windows 10 (home and school)

Pyinstaller version: latest stable as of Sept 2, 2020.

Python version: 3.8.5 64-bit


r/learnpython • • Apr 17 '21

Can you advise good online courses for getting better in code structure?

334 Upvotes

Good day. I’m a junior Python developer, and I try my best to get better. Python is quite simple to start (compared to C++ or so), and now I’m at the point where I’ve already got basic knowledge, and want to develop my code structure skills. I mean, I would want to comprehend how to split your code correctly, which patterns is better to use, so that it can be scalable and I wouldn’t be ashamed to show it to experienced programmers. So I hope you can advise me some online courses (or anything) associated with this, or just any advise for me at this point will be appreciated :)


r/learnpython • • Sep 01 '20

Do you know any GitHub Users who write really good Python Codes so I can read & learn from their code?

334 Upvotes

Hey I am a Beginner in Python and I would like to check out projects on Github so I can learn from their code. Specifically, I look for people who are advanced in Python so I can trust their competence. I hope you have some great recommendations.


r/learnpython • • Aug 25 '20

How to read/understand a git repository?

334 Upvotes

I'm trying to learn how to make a python programs by looking through existing programs in a similar premise as what I'd like to achieve (learning by looking at examples). But one thing I'm having difficulty with is finding out how these github repos are organized.

So far (in the repo I have I'm viewing) I know that bin usually means terminal/command-line commands, docs is typically documentation (as one might expect), test is self explanatory, but some things I don't know is rpm and stubs, amongst others.

Is there a resource to learn how python/git programs are organized? And what to expect when looking through repos?


r/learnpython • • Aug 23 '20

I can’t seem to “think like a programmer”

334 Upvotes

Been learning python for about two months. Read a few books. I can now do every single exercise in python crash course without referencing the book and have even tweaked many of the exercise programs. But I’m beginning to feel that “imposter syndrome” I keep hearing about.

The problem I’m having is when it comes to breaking down a problem into single step by step problems. Even making a tic tax toe game is a little difficult for me right now.

From my own learning and research I’ve come to realize I may need to learn more on algorithms.

From what I understand an algorithm is simply a step by step series of instructions to solve a problem. That’s at least the best way I can sum up the idea in my head. Is this correct? I’m sure there’s more to it than that. Forgive my ignorance. Trying to teach myself everything in quarantine with. I experience.

If I’m correct in my understanding of algorithms and pinpointing what area I need to hone next, can anyone recommend any good books or even videos that can help me overcome this problem and get better at being able to break a complex idea or problem down or have a better understanding of algorithms.

Please try to keep in mind I am a beginner when recommending books. I have a solid foundation of the basic fundamentals of python. Lists, dicta, loops, classes and the like but am trying to figure out how to use and apply that knowledge better.


r/learnpython • • Nov 27 '20

Milestone - 1,000 lines of code - TU r/learnpython!

333 Upvotes

Hi friends,

Just wanted to tell you all that I reached my first 1,000 lines of Python code (wanted to show a pic, but not allowed). I'm going through the book Python Crash Course, 2nd edition and doing all the exercises and some of the examples. Strongly recommend this resource, as so many others already have done. Also, I want to say a huge thank you to this community! I wouldn't have come this far without you <3


r/learnpython • • Apr 07 '20

What's the difference between != and is not?

332 Upvotes

If I say

if x != 5;
   print(x)

and

if x is not 5;
   print(x)

is there a difference?


r/learnpython • • Sep 24 '18

"Learn You Some Code" Humble Bundle is out! Get Python (and other) ebooks for $1 while helping charities.

332 Upvotes

https://www.humblebundle.com/books/learn-you-some-code-books

Books at each tier:

$1 or more:

  • Automate the Boring Stuff with Python

  • The Linux Command Line

  • The Book of F#

  • Learn Java the Easy Way

  • Perl One-Liners

  • No Starch Sampler

$8 or more

  • Ruby Under a Microscope

  • Learn You Some Erlang for Great Good!

  • Learn You A Haskell for Great Good!

  • Clojure for the Brave and True

  • Land of Lisp: Learn to Program in Lisp, One Game at a Time!

$15 or more:

  • Python Crash Course: A Hands-On, Project-Based Introduction to Programming

  • Python Playground: Geeky Projects for the Curious Programmer

  • Think Like a Programmer

  • The Book of R

  • Wicked Cool Shell Scripts

For $15 you get ALL of these books while helping code.org teach kids to program!


r/learnpython • • Mar 18 '21

NOT A QUESTION ... just a thank you!

331 Upvotes

I just want to take some time to give a thanks to all the people who take time out of their day to help others learn and better themselves. Huge thank you to the people who answer questions on here!

Felt like it had to be said.


r/learnpython • • Feb 01 '20

What are some of the projects I can start working on while learning the basics of Python?

331 Upvotes

I want to learn and practice at the same time and I couldn't find a good idea to start coding a program and adding advanced things as I learn more ... Do you have any idea what I can do?

It has to be a program that starts simple and becomes slowly more difficult


r/learnpython • • Nov 28 '20

Data analysis for beginners

330 Upvotes

Hi all,

What would you recommend as the best route to start learning towards data analysis with Python (I will add that I'm not planning on becoming data analyst/scientist within few months or so - I started learning Python 4 months ago, got the basics, not interested in building websites, creating games, but I would like to explore data; I also already started learning SQL 2 months ago. Really taking it easy and want to see where it all leads to, but extremely happy that I'm learning new skill).

Should I start with Matplotlib? Or Numpy? Or Pandas?

Any other tips or recommendations?

Thank you for your answers in advance!


r/learnpython • • Oct 30 '20

Made a script that tweets out COVID-19 cases in schools in Ontario, Canada with charts

330 Upvotes

Hey guys. I made a Python script that formats and tweets out data regarding how many cases of COVID-19 are being reported for the day in schools in Ontario, Canada according to the Ministry of Education here. I used the Ministry's data API to retrieve the data and then used the Tweepy library and Twitter API to format and publish the tweet. My goal is to automate the process so that it can be tweeted automatically at 10:30 AM every weekday but the ministry is sometimes inconsistent with their publishing of the data.

Here is an example of the tweet: https://twitter.com/ONTSchoolCovid/status/1322197560082182144?s=20

I also used the Plotly library to take the same data and create 2 line charts - one for new daily cases and one for total cases.

Here is an example of the tweet with charts: https://twitter.com/ONTSchoolCovid/status/1322223014394683392?s=20

The account is dedicated to tweeting out information and making comments regarding how the provincial government is acting regarding the issue of cases in schools. I don't believe the government is doing as good of a job as they could be and I'm glad that I can use the skills I've learned from this subreddit and the sources posted here to share data that many people may not see.

I wanted to do this after speaking to parents who were just unsure about what to do given the choice of keeping their kids home vs sending them to school. I want parents and school staff to be aware of how many cases are being reported in school so they can make their own decisions.

I had to make this new reddit account because I'm already getting hate in my replies and didn't want to attach this project to my actual reddit account lol.

Let me know what you guys think and if there's anything you think I can do to improve the data formatting and the entire process.

And if you live in Ontario, consider following me to stay up to date with the numbers!

Edit: Got some requests for the source code so here's the github link https://github.com/ontschoolscovid/SchoolsCovidData


r/learnpython • • Aug 07 '19

Today I started writing my first API call using Python and I've never felt more energized.

330 Upvotes

I've had Python on my radar for about a year and a half, but I've had so much other stuff to learn as well - database design, ETL fundamentals, statistics, etc. Because of that, I haven't given it much attention until I started my new job a few months ago. So far I've only been able to dedicate a few hours a week to learning and building out small scripts. I just finished going through Automate the Boring Stuff this week after getting through most of Jose Portilla's Python bootcamp.

My clients use a digital survey platform that's really tedious to get data out of. The platform has a public API and an FTP protocol, but I knew that automating API requests would be the better way to go. In the past, I've used APIs via different BI platform UIs that helped you generate scripts, but I've never written the script myself.

Today, I started my first big project. I'm generating the API call, parsing the JSON, and dumping the data into a csv (eventually I will send this directly to a MySQL database) all with Python. The best part is that I'm writing it all myself - much to my chagrin (or benefit?), I couldn't find any prewritten scripts.

I'm so grateful for this community that's constantly encouraging and supportive of itself. I'm still working through the script but I'd be happy to share it for a review once I get it on my (currently empty) Github assuming I'm allowed to put it up.


r/learnpython • • Dec 20 '20

Example of a simple and well made Python project on Github

329 Upvotes

Hi, I'm wanting to have a look at some examples of really well made but extremely simple python projects in an attempt to better understand basic structure and design. People suggest to me things like Requests or Flask... they may be beautiful but they are way too complex for what I'm after.

Any suggestions that come to mind?


r/learnpython • • Dec 18 '20

Just got promoted from sales assistant to programmer!

329 Upvotes

I started learning Python during quarantine (I learned C as a teenager 15 years ago, so I had a bit of a running start) since I had so much down time. Pretty quickly I spotted an opportunity for a new product that I took from conception to deployment in 4 months! The public launch went AWESOME and our clients love it so today, two weeks after launch they formally promoted me to programming full time and gave me a 20% raise. Woohoo! Thanks for all the help along the way.


r/learnpython • • Sep 04 '20

I finished 2 tutorials about python and now I'm getting nowhere wasting a lot of time

329 Upvotes

i finished 'automate the boring stuff' and learnt about pygame via yt. But I don't know how to proceed.I made a modified game using pygame and solved some beginner problems online for practice. That being said i am able to solve some questions and others no matter what ,i am never able to solve some and after reading the solution i think 'why couldn't i think that, it's so simple'.This has happened far too many times .code wars seems to be a time wasted as i am not able to solve many questions. Do i need to learn more, proceed to data structures and algorithm or practice from a different source ? I just don't know how to take the next step. I would really appreciate some advice. edit: thank you everyone for such an overwhelming response.


r/learnpython • • Jul 23 '20

Is going through an online course like “Codecademy” an appropriate way to step into the python language?

328 Upvotes

In other words, are there any more preferable methods that you guys would recommend? Cheers for the help.


r/learnpython • • Jun 10 '20

I made a silly game to practice using classes

327 Upvotes

I have been learning python for a few months, albeit slowly, because I can only do it in my free time and profession is something else. So one day I randomly decided to try making a small and silly text-based game which can be played inside Jupyter Notebook. My primary intention was to understand how to use classes. So I created a character class, a monster class, and a potion class. Then combined them into a game based on a lot of random numbers and some planned numbers.

In the game, you face a monster. You have three options, fight, run, and try befriending. If you fight, each one takes turn to strike until one is dead. The damage and health attributes are displayed on screen. Damage done is proportional to the remaining health. If you run, you lose endurance and must have higher endurance than the monster else they'll catch you. If you befriend, there's a 10% likelihood the monster will be friendly.

When you get a potion, you can take it or leave it. If you take it, there is a 50% chance it will turn out to be a trap. But damage of trap potions is lower than bonuses of actual potions.

All probabilities are based on how lucky you are. You start at 50/50 and get luckier through potions.

The game can be accessed here: https://colab.research.google.com/drive/1WcRTeaPwg3oRXzHH1m76r4SAaDJJkqSV

or here: https://github.com/gouravkr/notebooks

It's not something anyone would actually enjoy playing. But any feedback on the code will be highly appreciated.

Edit: after receiving some feedback, I changed the images to point to public URLs and reduced the number of cells to make it easier to run.


r/learnpython • • Jun 18 '15

r/learnpython is the Subreddit Of The Day!

327 Upvotes

/r/learnpython is the subreddit of the day!!!


Do check out the article at: http://www.reddit.com/r/subredditoftheday/comments/3aa7hu/june_18th_2015_rlearnpython_help_sub_for_python/


Thanks a lot and do remember to check out the other subs featured! :)

Rya

edit: oops :P