try this: make a python script which traverse given directory recursively and produce a graph which you can see using a svg viewer.
try to make it and experiment with it
!it will contain a horrendous bug if you are not careful!<
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
try this: make a python script which traverse given directory recursively and produce a graph which you can see using a svg viewer.
try to make it and experiment with it
!it will contain a horrendous bug if you are not careful!<
I did some webdriver stuff for reasons I don't remember anymore.
I also made a simple Django app to track job applications.
Unsolicited advice:
I taught beginner Python by working through this book: Coding Games in Python. I thought it did a decent job of teaching the fundamentals through increasingly complex games. The trickiest part is usually setting up an IDE, libraries, etc.
Otherwise you gotta start looking around for ideas. Maybe outline some interests to keep an eye on...
made a tiny script that scrapes setlists from a site and builds a chord practice queue for me. basically: input artist → get top songs → look up chords → generate a practice list sorted by difficulty.
it is maybe 80 lines including the argparse stuff. never bothered to clean it up but it still runs fine a year later.
for breaking out of tutorial hell: pick something you actually want. if you're just solving a generic practice problem you won't finish it. a dumb personal itch is worth 10 todo app clones.
My smallest python program was for filtering wifi names according to patterns. I hab collected some wifi names atomatically via sone other programs, and had them sitting in a text file with one name per line (a very simple data format). I wanted to find interesting names out of it, but didn't want to spend much time scrolling through hundreds of names following the same pattern, like ISP-12C5, ISP-3F4B, ... So i invented my own pattern syntax for very simple patterns, (ISP-%4Ax for ISP- followed by 4 hexadecimal digits with only capital letters), and wrote up a python script that read patterns from a file, and then filtered the standard input against those patters. any line not matching any pattern was then printed.
In short it was a small project that i wanted to do, with simple data formats that i could easily parse and relatively simpel logic that i had ideas how to implement while designing the patterns. And i had some data to test it on.
So my advice is similar to the other people here: look for things you are interested in or you need that sound simple to program, and then go on and program one of them. No problem is too small to make a program for.
Python is excellent at repetitive, scripty task.
Open file, do something with input like extract, measures, rearrange and save work in other file.
Another stuff is display or analyse statistical data. Find "raw" data of any of your hobbie(cooking, video games,Sport) and transform them into nice looking charts.
For basic mechanics it's really good to start with a text based tic tac toe.
It forces you to use for loops, read from input, parse, arrays, small amount of state, rendering said state and conditionals.
To go the extra mile try to make it look tidy. This can be done by using a class to represent a state and having single purpose functions.
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
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!
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.
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
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.
yeah and after doing this you will thank library like pandas and numpy which really makes our life easier
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.
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.
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.path.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.
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.
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.
can also try cloudflare worker which are free and as easy as aws lambdas
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!
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 :
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.
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.
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.
A lot of the early project euler problems can be solved in just a handful of lines: https://projecteuler.net/
there is also cryptohack if you are into cryptography and stuff
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.
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).
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.
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.
Here's a pretty small project that's still practically useful, at least to me.
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 !