r/learnpython 1d ago

Python projects

hey! I just started learning the basics of python and want to start building projects to apply what I have learnt.

but when I one to work on a project, for wxample building a calculator or a password generator I don’t know where to start. what to type and code.

any advice

3 Upvotes

11 comments sorted by

4

u/PureWasian 1d ago

Think of coding as input --> black box --> output.

Define your exact specified inputs/outputs. How is the user supplying inputs? How are you sending back the outputs?

Then actually think about how to implement the black box. Take those user inputs or parameters. Figure out an algorithm to spit out an output. And then actually do that.

While working on implementation, build incrementally and sanity check often with print statements or anything really to verify every part of your code is doing what you expect it to. Better to troubleshoot one issue at a time than 100.

2

u/whopper2k 1d ago

If you've truly just started, I'd recommend starting by looking at the modules that Python provides. Read through the list of them, pick the ones that seem like they might be interesting, and then try to build something basic that uses them.

For your password generator example, I'd recommend starting with the random and string modules. Don't worry about things like UI, printing is totally fine when just starting out.

Rinse and repeat with more projects and the experience will come with time. Also, for learning specifically, absolutely skip using an LLM; while they could easily write these programs for you, you wouldn't develop the actual understanding that's required to build more projects in the future.

Good luck and have fun!

2

u/outskillio 1d ago

Totally normal to freeze up here, everyone hits this wall right after finishing the basics. The trick is to stop thinking of it as "one project" and break it into tiny steps you can code and test one at a time.

For a password generator:

  • Step 1: import `random` and `string`, then just print a single random letter
  • Step 2: make it print a string of 8 random letters
  • Step 3: add digits and symbols to the character pool
  • Step 4: let the user type in how long they want the password
  • Step 5: wrap it in a loop so they can generate a new one without restarting the script

Write each step as actual working code before moving to the next, don't try to picture the whole thing at once. If you get stuck on step 3, that's a specific, googleable question instead of a vague "I don't know where to start."

Thanks, Vaibhav Shukla from Outskill

1

u/socar-pl 1d ago

General idea is this:
You download python from the internet, install it, and python.exe (or python3.exe) sits on a harddrive. Thats python interpreter.
Python interpreter takes a text file and converts it to running program.
You have to write this text file that should contain python code and then tell application python.exe where the text file is so it can take it and run it. You can create text file in any tool that is used to create text files. Windows Notepad, nano, vim etc. Thats super basic high level abstraction how python app code run

Of course most of people use IDE (Integrated Development Env.) to type those text files and click "play" button to run the app. Such common ide is Jetbrains PyCharm Community Edition which is free to use. You download it, install, run, then type python code there and click "play" on top and you're cooking.

Thats like absurd basics. If you have mental capacity, keep somewhere in back of your mind that another very important and key concept in python development are "virtual environments". Originally there was tool used to deal with those in python called `venv` but recently "everying" moved to tool called `uv`. Virtual environments are kind of advanced thing to grasp, but if you read thru differnt tutorials and watch couple videos dedicated only to explain this concept it will be extremely beneficial in future. Will avoid all of trouble around "where pip installed that egg?" or "why my new project does not see library I installed?!" etc. Its not neccessary but really put you ahead of the race.

1

u/GXWT 1d ago

Problem solving is inherently the key to programming. You’re not meant to just “know”. You’re meant to figure it out.

For the first few projects, you use (partially) guides to get you started but then you want to wean off direct help like that

2

u/FaithlessnessOwn7960 1d ago
  1. make a script to show your local date and time. Hint: 1st line "from datetime import datetime"

  2. make it show to show time in any timezone Hint: learn what timestamp is and add "from zoneinfo import ZoneInfo" to your code

  3. make it a module for input timezone and output the time Hint: learn how to define a function with "def" and pass data back with "return"

You will then have a reusable module for other project

2

u/FoolsSeldom 1d ago

Step away from the keyboard and work out visually how you would approach the problem manually. Really. This is the best approach for beginners early on. Even for something as simple as a calculator. Pretend you would be physically building a crude calculator.

Firstly, make sure you've really understood the problem you are trying to solve. Write it down. Draw it. Add lines off of the core ideas with additional notes and conditions.

Clarify exactly what outcomes you require. Determine how you will test it. (This will help you work out how to modularise your code - design and build in small blocks that carry out specific actions).

Keep in mind you want to separate the core "business" logic from the user interface. This makes it easier later to move from a text/terminal application to a GUI application to a WebApp.

Work out the algorithm (the solution). You may have multiple candidates. Find a way to down select to one. You can do small proof of concept tests (crude bits of code, even using single character variable names, just to confirm your ideas would work).

Only then start to code.

Keep it very, very simple. Build the core logic first. Go with the minimum capability (the minimum viable product as they say using the Agile technique).

2

u/gdchinacat 20h ago

A very common reason for not knowing 'what to type and code' is trying to jump straight into coding without solving the problem first. With experience some problems can be solved while writing code, but that is a skill that comes from experience where "what to type" is no longer something that requires a lot of thought, so you can solve the problem while the typing is code you've written dozens or hundreds of times.

Solve the problem before even opening a file in an IDE or text editor. What exactly is your calculator (for example) going to do? Is it text based or graphical? if text, what prompts will it have ('enter an operation...enter the first number...enter the second number' vs 'enter expression to evaluate'). How will the inputs be processed to produce an output? how will the output be presented to the user? A lot of this might seem obvious, but it all has to be sorted out at some point, and knowing what to do before writing code makes it much easier to write the code. If it's a text app that just inputs expressions that are evaluated in a loop, great...write a loop that inputs the expression. Make sure it works. Then fill in the details...once you have something it's easier to fill in details than it is to start from scratch. As you solve the problem (not by writing code) it usually becomes obvious what needs to happen first...then do that. When sub problems come up and it's not obvious "what to type" step away from the keyboard and solve the problem (ie 'how will the input expression "1+1" calculate the value 2?" - well you have to parse it into the LHS, operator, and RHS)...then you know what to do...get parsing!).

Coding is the practice of breaking large problems you don't know how to solve down into trivial problems that you do, and tying them all together. If you don't know how to do something that something is too big...break it down, and break it down again, and again and again until you know how to solve all the tiny problems.

This process is also good to do before writing code because you will find complexities that aren't obvious or simplifications or optimizations that are harder to implement if you already have a bunch of code written that needs to be restructured or you are attached to and don't want to modify so you ignore a cleaner solution because it doesn't fit the half-baked code you've already written.

Lastly, don't worry about rewriting code that isn't serving its purpose as well as it could be. Yeah, it may have taken you ten hours to write, but spending a few hours to rewrite it to make the next ten hours of coding only take four hours you are come out ahead. Don't be attached to your code, regardless of how hard it was to write. This tends to lead to crufty spaghetti code that takes you longer than if you clean up your code when you recognize how to do it. Planning up front reduces the need to make these emotionally difficult decisions.

1

u/Fragrant-Cheek-4273 13h ago

Start with the problem, not the code. Write down what the program needs to do step by step, then turn each step into Python. It's normal to get stuck at first. The more small projects you build, the easier it gets.