What was the smallest python hobby project you worked on?
from maya_the_good_apple@sh.itjust.works to programming@programming.dev on 18 Apr 15:00
https://sh.itjust.works/post/58734287

I have a feeling I’m stuck in tutorial hell, and I need to start actually building things. But I don’t know where to start :/

Also I’m really bad at syntax. I only know concepts like for loops, while loops, if-elif-elses, etc…

So maybe something that helps me learn more about coding syntax would be helpful.

Thanks!

#programming

threaded - newest

lime@feddit.nu on 18 Apr 15:05 next collapse

console blackjack is a good start. take bets, hit or stand, count cards correctly, pay out winnings. makes you think about data structures and sequences and so on.

alternatively, think of something you find annoying to do on the computer and try to automate it.

CombatWombat@feddit.online on 18 Apr 15:06 next collapse

A lot of the early project euler problems can be solved in just a handful of lines: https://projecteuler.net/

SinTan1729@programming.dev on 18 Apr 15:08 next collapse

Here’s a pretty small project that’s still practically useful, at least to me.

github.com/SinTan1729/recipe-box-for-wikijs

thingsiplay@lemmy.ml on 18 Apr 15:20 next collapse

I can’t answer your question in the title, but I can say what I do whenever I learn a new programming language (even if its temporary just to play around with new languages). My personal Hello-World like program I tackle in most cases is something that runs another program. Lot of my personal projects are actually like that. You can start simple, to learn how to do associated tasks with it. There is a lot you can learn by diving into this (first) simple exercise.

This will help you understanding how to read directories, handle file names and paths correctly, read text files in example, how to spawn a process, handle possible errors and react to error codes, possibly read and process stdout of the program. Also handle commandline options, output stdout so it can be used with other programs easily. Write configuration file and so on.

An alternative thing you can try is, doing a simple grep like program. Or maybe a simple game that asks you a few questions and gives points. Or a note taking app.

mbirth@lemmy.ml on 18 Apr 15:20 next collapse

What I did when starting out with Python: I’ve bought a book similar to the O’Reilly Pocket Reference and read it cover to cover to get an overview of the structure, syntax, and available objects and methods. Then started piecing my tools together by looking at other people’s code and copying the bits I could use. If you want some inspiration, have a look at my Python projects.

Cryxtalix@programming.dev on 18 Apr 15:24 next collapse

Do your todo apps, sudoku solver etc. Simple problems are fine. Don’t look down on them, don’t tell yourself that they’re too simple for you. There is always more complexity that you first expect once you start tackling it seriously.

Also, every self respecting tutorial ought to have exercises after every chapter. Don’t skip them either.

aReallyCrunchyLeaf@lemmy.ml on 18 Apr 15:29 next collapse

Check out pi pico and hardware/microprocessor programming. I found it easier to wrap my head around certain concepts when I had a practical application for them right in front of me.

crunchpaste@lemmy.dbzer0.com on 18 Apr 15:45 next collapse

One of the first small projects I worked on when i was starting with python was a telegram birthday reminder bot as i really didn’t want to rely on Facebook for that. At first I was just looping over all the entries in a list, then went to a database, at some point added fuzzy search, adding and removing entries. Still use it today.

Imo the best way to learn is to think of a project that you personally find useful and need solved for yourself, not some abstract exercise.

bobo@lemmy.ml on 18 Apr 16:14 next collapse

A bit offtopic, but it’s relevant.

My first attempt to learn to code was more than a decade ago with python. I went through the basics, and decided to start a small project to practice. At the time python didn’t really have too many applications apart from automating tasks (before Hugo, flask, etc), so what did I think up? To make an automated propositional logic theorem prover. You input a formula, it tells you whether it’s a tautology or not.

Great idea, there are some relatively simple algorithms we’ve learned for pen and paper, it doesn’t seem too hard, etc. After a month I learned that it’s an extremely complex problem with billions invested in solving it because it’s directly relevant to PCB manufacturing.

That attempt failed horribly, and it took me a few more years and attempts before I found a good method. Web dev was actually crucial because I had direct feedback on simple logic.

So if you’re anything like me, make a blog from scratch or something else that’s actually simple, but gives you immediate visual feedback. And just to be clear, I ended up absolutely hating frontend, but it was a great stepping stone.

jcr@jlai.lu on 18 Apr 16:31 next collapse

I first built a dice roller : the core is just a call to random.randint module, but you need to have the terminal interface to get the instruction ( like “4d6” means you need to have 4 times random generation between 1 and 6). You can do it only with regexp, and if you want to get fancy you can try and find solutions to have compounded formulas, try to have the results stored during a game session, etc.

Second project was a small game: the idea was to have a map of coordinates (xy), and each game has random spawning of 2 goblins and 3 gold within the map ; the goal is to move around (nswe) getting the 3 gold without hitting a goblin.

So also no graphic representation of the map, you just have the game running at each keystroke.

You just need to be able to define functions and do string manipulation ; for logic you can stay with if-then-else and while loop.

And good luck with the learning !

Maiq@piefed.social on 18 Apr 16:41 next collapse

Just a thought, install ipython. Then start exploring modules. ipython is very helpful with this.

Here is a small example. After ipython is installed in a terminal start ipython shell by typing ipython. In my example we will use psutil.

import psutil as ps

You can access different methods in that module with a dot and you can see all available methods by hitting tab after the dot. ps.<tab>, then you can use the arrow keys to select different methods that interest you.

Here i will use process_iter to get programs that are running. I’ll use firefox as an example.

for proc in ps.process_iter():
    print(proc)

You can start to figure out how to access properties. Some properties are methods and require the () and others are attributes and dont.

for proc in ps.process_iter():
    if proc.name() == "firefox":
        print(proc.status())
        # or even kill the process
        proc.kill()

This can be fun. It can help you explore and familiarize yourself with different modules as you read their documentation.

You could teach yoursel list comprehension.

[ x for x in ps.process_iter() if 'fire' in x.name() ]

This gives you a list of processes with ‘fire’ in the name. A powerful way to sift generators, lists and the like becomes available.

psutil is fun but you dont have to start there. The os module is very handy.

import os

down = os.path.join(os.path.expanduser('~'), 'Downloads')

for zip in os.listdir(down):
    if os.oath.splitext(zip)[1] == '.zip':
        # delete all zip files in Downloads
        os.remove(os.path.join(down, zip))

# or with list comprehension

zips = [ z for z in os.listdir(down) if os.path.splitext(z)[1] == '.zip' ]

for zip in zips:
    os.remove(os.path.join(down, zip))

Maybe try https://en.wikipedia.org/wiki/Fizz_buzz for fun.

gsv@programming.dev on 18 Apr 17:27 next collapse

The only thing that really got me going was small applications I had some interest in. Writing games I will not play never kept my interest up for long. So I’ve been building mini tools I used for teaching numerics classes in meteorology (Python, Julia, Fortran, C) or code I would be using for some tinkering with microcontrollers or similar (Python, C++) when using new languages. For me personally, some iconic projects were a CO2 sensor with an attached display, or very simple internal gravity wave ray tracers. But that’s likely not what you’d be interested in. So without trying to suggest specific applications for you (many good examples in the responses :-) I’d advise to do something you’ll have fun with. Get yourself a small project that generates added value for you specifically (and fun is great added value in my eyes).

NewDawnOwl@lemmy.world on 18 Apr 17:56 next collapse

Maybe try it from the other way around : look for tutorials that help you achieve your goals, and contextualise the tutorial to your project.

I am wrapping up the Django tutorial because I needed to make a database that held the information on where I put my taxes instead of just ramming them in the downloads folder. I just followed the django tutorial on the official website, but changed variable names etc to make it suit my needs.

I’m also working on improving my bash skills. I made a clock chime to learn cases :

lemmy.world/post/43115099

Slatlun@lemmy.ml on 18 Apr 18:02 next collapse

A small script to append some characters to a string based on whether the letters in the file name were capitalized. Super simple, but I had a data migration project to a system that doesn’t recognize case and people before me coded information into case. It is essentially tutorial level but real life application. Maybe you have something similar? Practical and working before anything complex.

Sickday@kbin.earth on 18 Apr 18:05 next collapse

AWS Lambdas at work. None of them are particularly complex and the logic is often very targeted.

Edit: Just realized you said "hobby project". For me, that would be a simple web scrapper.

AstroLightz@lemmy.world on 18 Apr 18:16 next collapse
def main():
    print("Hello world")

if __name__ == "__main__":
    main()

/s

I think a small one I worked on was extracting URLs from a CSV file in a certain column. Not too difficult, but a very specific use case.

wholookshere@piefed.blahaj.zone on 18 Apr 18:57 next collapse

I’ve been a professional developer for over a decade.

Find something simple to solve a problem you actually have.

Who cares if its been done better a thousand times. Thats not the point.

The point is that the only way you get better is by doing it shittly first, and then learn from mistakes. After a while you make less.

Black jack inna terminal is a good one, a to do app, or time tracker, or automated stop watch. Whatever.

Even better if you find one that’s been done before. Do it yourself, then compare with what someone else did. What you like and dislike about how they did it, and keep learning.

aivoton@sopuli.xyz on 18 Apr 20:36 next collapse

I started programming after I played some PlayStation 1 game when I was a kid. Mum told me that you have to program to be able to make games so I as a kid searched how to program and was promptly greeted by some c hello world tutorial. 9 year old kid seeing hello world in terminal did not a programmer make.

Few years later the various javascript fork-bomb stuff were riddling the internets, the ones where you had alert with some supposedly funny messages one after another (this was before stop making new dialogs was an option) which was my true introduction to programming. Doing actual real world stuff - making my friends and teachers suffer. Even if it was copy pasting alert hundreds of times, or changing the for loop end value from 10 to 100, it was very crude programming.

As long as you understand the core concepts, you can start learning more. Set a small goal and try to achieve it. Keep setting goals and try to achieve them and surely you’ll end up lerning.

yelling_at_cloud@programming.dev on 18 Apr 21:33 next collapse

The first thing I ever did in Python, after the obligatory “Hello World”, was to follow a tutorial to make a simple task tracker web app. Then I made a small routine to edit Excel files. A few months later I was getting paid to write Python code (and yes, I got lucky as shit, but my point is that it was easy to keep going as soon as I just got started). Just start making things, it doesn’t really matter what as long as you enjoy it. It will be useful. Follow tutorials, look stuff up online, you’ll absorb syntax without cramming it. You’ve got this!

fargeol@lemmy.world on 18 Apr 23:43 next collapse

It was a tiny TicTacToe server I made to learn machine learning. I basically played TTT against it and it would train on the former games to improve. It didn’t work since I’m not a data scientist, but at least I know how to create Web Sockets!

I can give you a few advice if you want

  • Single Responsibility Principle: don’t do everything in the same place, separate between functions, classes or files. In my server, one file contained anything related to the server, another anything related to game logic and another anything related to machine learning.
  • Don’t reinvent the wheel: unless you’re making it as an exercice, don’t create something that already exist as a library. Python is wonderful for its libraries
  • Don’t optimize stuff: if you feel that “it could be faster”, either benchmark it or give up. "Premature optimization is the root of all evil"
  • Learn how to make useful naming, tests and documentation: this is not something developers like to do but you’ll love yourself if you read your code after a few months
  • Don’t code with an AI: If you’re bad without an AI, you’ll be bad with it. If you’re good with an AI, you’ll be good without it. You can still ask one for snippets or use it as a tool to discover concepts you don’t know about but I strongly advice against autocomplete and coding agents (I talk from experience).

If you don’t know how to start, you can make a really simple Tic Tac Toe game with its rules and play it in a CLI. Then you can decide how to pimp it: a better interface, game saves, an opponent played by the computer, a game server for a multiplayer game… you decide!

chicken@lemmy.dbzer0.com on 19 Apr 00:05 collapse

I made one to track volume of keypresses per hour, and draw a graph comparing how much typing I’ve been doing on the current day vs an aggregated average