I’m a beginner in programming, and I found out I cannot even reproduce a simple number guessing program I have earlier copied from a book.

Is it a beginner issue, or there is more than just continuing to learn to be able to code without hints?

  • hendrik@palaver.p3x.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    2 months ago

    You’ll get there. If you’re struggling to remember what to do and in what order… I’d say keep things simple. Re-visit the needed concepts. In case of a number guessing game, that’ll probably be conditions, loops, input and output, storing numbers. Make sure you understand each if those individually.

    You could write a program which just echoes the input. You could write a separate program which just has two fixed numbers and compares them. You can then extend it to also read one of the numbers from user input. And you’re half-way there.

    I’d tackle the loops seperately (if that’s contained in this example). Get comfortable with them. Start with a program that just counts from 0 to 99 and outputs all the numbers. You can then combine that with other concepts, like output “tomato” if a number is divisible by 6.
    And if you don’t get the loops… Just tell the user they have 10 tries and copy-paste your code ten times. That’ll do it as well. And you can work your way up from there.

    I think once you have a grasp of what all these things do, and you did a few super simple things with them on your own, it’ll be more clear what to do with more complex things. In this case probably: loop. And inside of that loop, ask for a number, compare it to the secret number, and decide what to output on a condition. That’s roughly an average number guessing game. I think you just need to tinker a bit more with each of the 5 concepts that get combined here.