r/learnpython • • Feb 09 '21

How long did it take for you to really enjoy programming?

403 Upvotes

I say this as someone who's fairly new to the game.. A few years back I tried to get into front end development. Using codecademy, starting with HTML, CSS then Javascript. This is where things went off the rails for me. The first two were easy, but dull. Javascript hit me like a freight train though, id hit road block after road block and just lost all ambition.

Years go by, I mostly moved on but the failure stuck with me. So I dove back in, only this time trying Python via Udemy's "Automate the boring stuff". Im not far into it section 3 I think. Im not far enough to be at stage where I have code memorized but not really lost either. Just bored.. What im learning is very run of the mill and I guess I just cant seem to grasp the whole picture. Just following along without knowing what the end goal is here...

Am I alone here? Did you feel this way? should I stick it out and better times will come?... Help

Thank you all for the support! It seems as though most of you know exactly where I'm at.. I've now got two goals. 1. Get the basics down 2. Start a project


r/learnpython • • Jul 29 '20

Basic Scraper Template, for anyone wanting to start learning Web scraping

403 Upvotes

It's very basic and will only work on non js based sites

This is a great introduction, and should be enough to play around and make work for you.

Dependecies:

pip install requests bs4

Template

# dependencies
import requests
from bs4 import BeautifulSoup

# main url to scrape
MAIN_URL = ""

# get the html and convert to soup.
request = requests.get(MAIN_URL)
soup = BeautifulSoup(request.content, 'html.parser')

# find the main element for each item
all_items = soup.find_all("li", {"class": "item-list-class"})

# empty dictionary to store data, could be a list of anything. i just like dicts
all_data = {}

# initialize key for dict
count = 0

# loop through all_items
for item in all_items:
    # get specific fields
    item_name = item.find("h2", {"class": "item-name-class"})
    item_url = item.find("a", {"class": "item-link-class"})

    # save to dict
    all_data[count] = {
        # get the text
        "item_name": item_name.get_text(),
        # get a specific attribute
        "item_url": item_url.attrs["href"]
    }

    # increment dict key
    count += 1

# do whats needed with data
print(all_data)

I will try my best to answer any questions or problems you may come across, good luck and have fun. Web scraping can be so fun :)


r/learnpython • • Jun 29 '20

Just earned the Gold Badge for 30 Days of Code on HackerRank!

403 Upvotes

I finished solving the 30 coding challenges in python and it was a great journey looking forward to solving more challenges. This helped me gain a bit more confidence and i would definitely recommend it. The best part about hackerrank is that they give you stars and the gold badge when you have completed all of it . There is the python gold badge that I am going to start working towards now!

The gold badge:

https://www.hackerrank.com/aiden506sams?badge=30-days-of-code&stars=5&level=3&hr_r=1&utm_campaign=social-buttons&utm_medium=twitter&utm_source=badge_share&social=linkedin


r/learnpython • • Sep 17 '24

Is it worth learning Python at age 35, keeping in mind that AI era is here.

402 Upvotes

I have been using Cody with VS code since last 3 to 4 months and it seems like it gets the job done. Would it be worth it to learn Python at this age for a career switch?

What if I am learning something which would be overtaken by AI in the next few years.


r/learnpython • • Dec 24 '21

I'm 54, learning Python, been out of IT for 10 years, any advice?

402 Upvotes

Want to get back into working for IT. Over the last 10 years have mainly been doing Video Production but have done a little IT support for small companies (Windows Desktop/Linux Server) including setting up a few Linux boxes. I worked mainly in Oracle Development, Business intelligence Design.

Ime currently on day 65 of Dr Angela 100 Days of code Python basecamp.

Previously I learned some basic Ruby and ROR and it was a while back but I think I prefer Python. The idea that there should be one obvious way to do stuff really appeals. The fact that Python seems to aim for this is great and it feels this may be truer than in Ruby. Don't get me wrong, I did enjoy Ruby/ROR.

Any advice, am I screwed :).

PS I should of explicitly stated ime trying to get back to working in IT.


r/learnpython • • Jul 22 '21

/r/python is hosting an AMA with Al Sweigart on 28th July at Noon PT (7pm UTC)

401 Upvotes

Next week we'll be hosting an AMA with Al Sweigart (u/AlSweigart), author of "Automate the Boring Stuff". His most recent book is, "The Big Book of Small Python Projects", a collection of small projects and programs that help teach programming concepts in a learn by doing approach. You can pick it up here or read it for free online.

The AMA starts at 2 pm Central, 7 pm UTC and will run for an hour. Earlier that morning there will be a post made by Al Sweigart where you can begin asking him your questions in the comment section. We'll sticky the thread and mark it as an announcement so it's easy to find. I'll also update this post with a link pointing to the AMA.

link here: https://www.reddit.com/r/Python/comments/opnsf4/join_us_for_an_ama_with_al_sweigart_on_july_28th/


r/learnpython • • Feb 07 '21

My first proper project on Github, Yay!!

401 Upvotes

After about 2-3 years of being on and off into coding, I managed to actually finish a project end to end. It isn't very fancy but it gives me immense pleasure to finally achieve this milestone in this line of my life. I really appreciate everyone here for being so helpful and also many thanks for all the support.

The project utilizes the cool Python module Streamlit to create a visual interface to build/analyze a Portfolio management strategy using the RandomForest Regressor to predict the prices for n days ahead. It uses the random grid search for inside cross-validation to optimize the hyper parameters(different for every equity) for a chosen number of equities(stocks) by fetching the data from the nsepy module with the ability to select the timeline along with a backtester to test the strategy created.

Anyone could, infact, add a function to this script in the main long-short-equity class appropriately to use different models for prediction I believe, it's of course not investment advice but a simple representative strategy+backtester for budding systematic trading enthusiasts.

PS: Please give me suggestions on how I could make this code better and/or the pros and cons of my code.

Github: Long Short Equities

Preview

Edit: Thanks for the awards strangers :)


r/learnpython • • Jul 18 '20

after 2 ish weeks of learning python I've made an Alarm clock

401 Upvotes

ive made a very basic alarm clock could you guys asses it?

import time, winsound




def main():
    global maininp
    maininp = input("Hours mins or sec").lower()
    timelist = ("hours","mins" ,"sec")
    if maininp in timelist:
        times(maininp)
    else:
        print("try again")
        main()


def times(userinp):
    if userinp == "hours":
        timewanted = int(input("how many hour: "))
        waitingtime= (timewanted*60)*60
        alarm(waitingtime)

    elif userinp == "mins":
        timewanted = int(input("how many mins: "))
        waitingtime= timewanted*60
        alarm(waitingtime)

    elif userinp == "sec":
        timewanted = int(input("how many sec: "))
        waitingtime= timewanted
        alarm(timewanted)


def alarm(thetime):
    if maininp == "hours":
        s = str((thetime/60)/60)
        items = s.split(".")
        if thetime ==1:
            print(f"Your alarm is set for {int((thetime/60)/60)} Hour")
            time.sleep(thetime)
            sound()
        elif thetime != 1:
            print(f"Your alarm is set for {int((thetime/60)/60)} Hours")
            time.sleep(thetime)
            sound()

    elif maininp == "mins":
        test = float((thetime / 60))
        twodp = float("{:.2f}".format(test))
        s = str(twodp)
        items = s.split(".")
        if test >60:
            print(f"Your alarm is set for {items[0]} Hours and {items[1]} mins")
            time.sleep(thetime)
            sound()

        else:
            print(f"Your alarm is set for {int(thetime/60)} mins")
            time.sleep(thetime)
            sound()


    elif maininp == "sec":
        print(f"Your alarm is set for {thetime} seconds")
        time.sleep(thetime)
        sound()



def sound():
    for i in range(2):
        for j in range (3):
            winsound.MessageBeep(-1)
            time.sleep(0.3)
        time.sleep(1)


main()

r/learnpython • • Jun 09 '20

Github as a beginner

401 Upvotes

As a beginner learning python, is it too early to create and start coding simple projects on Github. and how do I transfer these codes (simple calculators) to a website I build subsequently?


r/learnpython • • Aug 29 '20

What would be great ways to pratice python ?

400 Upvotes

I learned python from Udemy : From Zero to Hero by Jose . But I feel that there's little too less to practice in there. Before learning python I had learned light C++ which was part of my high school . My sir would give us many kinds of exercises. Right Now Since I'm learning it on my own I am finding it hard to find practice exercises. (on lists, tuples , OOP, loops, I think the whole bunch).
Thanks :)


r/learnpython • • Jul 08 '20

How to share python exe with people to use the program without having to install python?

399 Upvotes

Hi All, I have written a my first very basic program for webscraping where it summaries the top 5 most read article and sends a email.

The user needs to enter their email ID and password to login using smtplib and that's all the input that is required.

I wanted to share this with my friends so they can use it at their end without having to install python.

Is it possible to do that? Basically i wanted to know once we write a program how do we create a user friendly front end app?

Many thanks in advance! Any inputs are highly appreciated!


r/learnpython • • Jun 09 '21

My Python programming journey

398 Upvotes

Hey Guys,

I'm 26 years old and from Germany. Today I want to start my programming journey in Python, I want to learn the basics and then realize a project I already have on my mind. I created this account with the goal to learn the language and land a job with this skill one day. I'll probably need to learn some more things then just Python, but I want to start with it.

For everyone who wants to start as well, do it like me and just start. I set myself the minimum requirement of coding at least 10 minutes per day (that's a trap for my brain, when I already started it is more like for me to code way more then 10 minutes).

I already downloaded Atom, Python and I selected the book "automate the boring stuff with python" as my main literature. Now I have to read the manual of Atom and get familiar with it, the only thing I've done so far. I'll try to keep you updated everyday, I is not important if anyone follows this. I will use my daily posts to monitor my progress.

Enjoy!

Edit: Wow this blew up! Thank you so much for your support, you're such a cool community! I will try to journal everyday on my account and after some greater success I'll make another post. Thank you ! Danke


r/learnpython • • Nov 30 '19

Learn computer programming by implementing games in Python

398 Upvotes

I ran across this jewel - it looks like a great way to learn programming.

The author transcribed the code from a series of books designed to teach programming in the days of the Commodore 64.


r/learnpython • • Jan 14 '22

Am I just tech illiterate, or is automate the boring stuff with python too hard for a beginner like me?

397 Upvotes

Hello! I'm hoping to pick up some coding during my down time and I have been eying ATBS with python for quite a while.

However, when trying to follow the tutorial on the internet, I feel like I'm thrown into a loop and am very confused throughout the beginning of the course.

For example, in chapter 2 when it introduces the range function, the tutorial showed me the function:

for i in range(5):

I get really confused to what is the tutorial trying to tell me. Where doe "i' come from? What does the number in brackets mean? (it says there should be 3 integers but why are there only 1?)

Another example is later when it gives me a line of sample code:

print('%s Wins, %s Losses, %s Ties' % (wins, losses, ties))

And again, the % is supposed to do something, but what does it do? How does it work?

I feel like I'm hitting a brick wall every time something new and unexplained come up, and I cannot seem to move forward with the learning progress. Is it just me, or I'm better suited for another language/learning source?

Edit: Thank you for all your kind words. I'll need to take a break but I'll be back tomorrow!


r/learnpython • • May 18 '17

Python for Beginners - Complete Series

397 Upvotes

A nine-part series I put together on Python Programming for Beginners. We go over the setup, data types, conditionals, loops, functions, how to import modules and explore the standard library. I hope you find them useful:

  1. Installation and Setup

  2. Strings

  3. Integers and Floats

  4. Lists, Tuples, and Sets

  5. Dictionaries

  6. Conditionals and Booleans

  7. Loops and Iterations

  8. Functions

  9. Importing Modules and the Standard Library

Entire Playlist - Here


r/learnpython • • Apr 08 '20

LPT: If you’re using the free code academy pro right now, read the FAQS in each lesson

393 Upvotes

I can’t stress this enough, the top answers from moderators in the FAQs answer questions about further applications of what you’re learning, beyond what’s in the actual lesson. They also delve into WHY certain things work the way they do, rather than skimming over it and just explaining how to use them.

Definitely an underrated part of the site


r/learnpython • • Feb 29 '20

Actually used python today

393 Upvotes

I've been learning python for about a month now. I started with automate the boring stuff like so many others have. Since then I have made some small games to practice. I am currently working on a hangman game and needed a list of words to use. I found a list of words and copied the whole thing to a .text file but it came with extra stuff I didn't need. So instead of manually deleting everything I didn't need I made a python script to do it for me. GREATEST FEELING EVER.


r/learnpython • • Feb 14 '23

Best online course to actually learn to use Python

392 Upvotes

I see a lot of different courses like • Angela yu, • Automate the boring stuff • The Helsinki class • Harvard cs50p.

And 100’s of other courses.

I have read that the course by angela and automating the boring stuff is god in the beginning but is heavily outdated later on.

I am trapped and can’t seam to find out where to begin. I have read true a lot of post and know this question gets repeated like every other day. But what are your recommendations and thoughts.

And I am a beginner but I had a course last semester at my university called programming whit mathematics, it was basically a python introduction class whit a lot of math. So I know a little but don’t know where to begin now.

Edit: I am now in may finished with my bachelor I economy and administration but I have for a while been contemplating trying to become a software developer and I really enjoyed the programming whit mathematics application. But I don’t think I will start a new bachelor at first to learn to program.


r/learnpython • • Jul 09 '20

I made a calculator in Python!

392 Upvotes

Hello everyone!

I just wanted to share this project i made, its not my first programming project or python project whatsoever, but it is indeed the first one i didnt depended much on google or a video tutorial so that for me its a great advance.

The project is also my first on a github repository!

https://github.com/mexicanlefty/Python-Calculator

Please take a look and test it, in case you can provide any feedback it would be even better, it doesnt matter if you guys want to be very critical, i dont mind i want to keep practicing and i already have my next project in mind.


r/learnpython • • Feb 26 '21

Automate the boring stuff vs python crash course

391 Upvotes

Hey guys, I’m not sure which of these 2 books I should start of with. I have no prior programming experience, and these both seem like solid options. Is it viable to go through both, or should I stick to one?


r/learnpython • • Apr 07 '15

Here's What I Recommend To ABSOLUTE Beginners

391 Upvotes

Rule No. 1: You are going to be extremely confused in the beginning. You are going to go through phases of excitement, and you will get ahead of yourself. At some point after learning the syntax you will be lost, and not know what the heck to do. LUCKILY I've been there, and I know the way out of that mess and Here it is. DO NOT GIVE UP, I promise you that it sinks in.

Rule No. 2: Focus. Do not begin learning Python, and then get excited and begin learning other languages. This is a mistake, I promise you. Take the time to focus on one language, and get good enough at it to build your own programs before moving on. If you do not do this, you are going to get confused and there is a chance you will just give up.

Rule No. 3: There is an efficient order to learning Python that I have found to be best. FIRST! Learn the Syntax. I recommend Codeacademy, for Python. There is a great community there as well if you get stuck. SECOND! Start attempting the small projects listed here. THIRD! Once you feel as if those projects are pointless, and you have lost interest in them, start exploring Python's libraries and modules, and begin to find an area you are interested in! FINALLY! Learn a new language that is closely related to your interests.

Rule No. 4: Always try to abide by this ratio. 70% of your time should be dedicated to coding. 30% dedicated to learning via tutorials, or what-have-you.

Good Luck!

[Edit 02/17/2016] The original playlist I provided as the first link in this post was removed, but I managed to find the exact same playlist by another user on YouTube and updated the link.

[Edit 06/2/2016] The playlist was taken down once more, however I have located another one and have updated the link above. I'll continue to update the post whenever someone messages me about it being broken if I can locate a new playlist.

[Edit 04/28/2017] The new playlist has been taken down again. To clarify, the playlist was a video tutorial series provided by Lynda.com. The author was Simon Allardice, and it was titled Objected Oriented Design. Here is the introduction video to it. I implore you to seek it out, it helped me and many others a lot.

[Edit 02/03/2018] I still get a lot of messages about the playlist being taken down. Please read the edits above. Thank you.


r/learnpython • • Jan 02 '21

How to learn Algorithms and Data Structures

389 Upvotes

Hello everyone,

i am an engineer and basically tought myself how to code, because i would like to go for machine learning. I am not an expert yet.

I often read or heard that algorithms and data structurs and all that are super important for coding and even if i think i make quite a good progress in learning, i often feel like i am missing the basics.

It's so much out there. Like tons of youtubers and online courses and some fancy bootcamp thing (Until recently i didn't even know something like that exists). Like Udemy, coursera, edx, youtube, tons of books, kaggle, leetcode, algoexpert, the list is endless. Everything is full of advertisement and i have no idea what i should go for...

What source can you recommend me to learn this stuff theoretically and practically preferable in python? I would prefer videos over a book and a big course that covers everything rather than a bit of this topic here and a bit of that topic there and stuff. I don't mind if it is some sort of academic and mathematically, but it should cover some practice aswell.

I was thinking about just going for this:

https://www.edx.org/xseries/mitx-computational-thinking-using-python

But not sure if it's deep enough. I don't even know how deep i have to understand all that. I am not planning to go for some PhD. I Just want to go for a Job at the interface of machine learning/coding and engineering, but i also realy want to understand this whole topic as deep as possible. So I don't want to spend hours and hours on following some course just to begin another course right after. If that's the only way, fine. But maybe someone has a good recommendation?


r/learnpython • • Oct 16 '19

My Aunt gets really upset if I don't answer her daily good morning texts. WhatsApp API?

387 Upvotes

Could I just make a script to open up a chome tab with whatsapp web, find my aunt in my messages, and reply to it something preselected?


r/learnpython • • Jan 06 '22

What part-time job can I get that I can automate with python? (Serious)

386 Upvotes

I was thinking bookkeeping? Or scheduling?