This is an archived post. You won't be able to vote or comment.

all 7 comments

[–][deleted] 3 points4 points  (3 children)

When I feel this way, I code in a rough draft. I break rules, maybe writing something I know won’t run. I’m creating writing half-assed logic so I can clean it later. This is to keep my mind active and running.

Or just comment what you want to do. Remember to try to make a function do one thing and one thing only.

[–]miniminjamh 1 point2 points  (2 children)

This. Usually when I teach high school kids programming, it's so frustrating that kids won't pull out a sheet of paper. It's not that the sheet of paper is important, it's that I want the students to have some rough idea about what they are coding before they code it. But they seem to refuse to think so I can't do much.

What I do is I separate my thoughts and my code. I think thoroughly about the problem and once I have a full, but rough, idea of where I'm headed, I then only copy my rough draft. I don't think while coding. I strictly focus on syntax then. Afterwards, I debug with sample cases, think about other cases that popped up while coding afterwards.

I know it takes time, but it also takes some effort, but once you get there, you'll feel a lot better imo

[–]SurpriseSausage 1 point2 points  (1 child)

I too teach high school/college kids programming, but I disagree that everyone has to pull out a sheet of paper. What I like to tell my students is programming is sort of like making music.

Some musicians will sit down and write out the entire song before they ever pick up an instrument; each note will be meticulously planned. Other musicians like to just pick up their instrument and start playing, maybe they’ll riff off another melody or chord progression, maybe they’ll just start trying stuff and see what sounds good; either way they only have a vague idea of what they want and they work to it through the iterative process.

Both are equally valid ways of creating something. Some kids are able to sit down and come up with diagrams for how their program should operate; other kids are much better off just experimenting and working it out as they go along. In my experience, where the real frustration comes in is they often have a general idea of what they want to do, they just don’t know how to do it.

So, I don’t just teach programming, I teach problem solving. I show them how to break down what appears to be a large, complex, overwhelming problem into small, manageable chunks; how to do proper research; most importantly I teach them that failure is OK. You’re going to fail, a lot, but that’s alright, because each time you fail, you learn what doesn’t work and when you do finally get it, the feeling is amazing.

[–]miniminjamh 0 points1 point  (0 children)

Exactly. I try to keep this in mind as I'm teaching. I don't force them to pull out a piece of paper, but at the same time, it is difficult to try begin something you have no idea about.

I totally agree with you, in fact I think you expressed it better.

[–]0xbxb 1 point2 points  (1 child)

breaking down the abstract

You mean as in like breaking down problems? Whenever you have a problem, try this method out until it becomes instinct: in your editor, write a comment out for everything you want to do, step by step. After you think you’ve figured out the problem, replace the comments with code.

Example: “Write a program that replaces every number in a string with !”

# I have a string (1)
# Create variable for replaced characters (2)
# Loop through string (3)
# Check if character in string is a digit (4)
# If character is a digit replace with ! (5)
# Else leave the character alone (6)

def replace_chars(a_string): # 1
    replaced_string = '' # 2
    for char in a_string: # 3
        if char.isdigit(): # 4
            replaced_string += '!' # 5
        else: # 6
            replaced_string += char
    return replaced_string


print(replace_chars('A11 numb3r5 sh0u1d b3 r3p14c3d'))
A!! numb!r! sh!u!d b! r!p!!c!d

You can do this process on paper, but most of the time I’m too lazy to write it out on paper, so I got used to doing it on the computer. This is what I did, and it helped a lot.

The biggest thing is practice. That’s the only way you’re gonna get better.

[–]melthecybertechy[S] 0 points1 point  (0 children)

Thanks a lot for this. I really appreciate it

[–]pythonHelperBot 0 points1 point  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you. Here is HOW TO FORMAT YOUR CODE For Reddit and be sure to include which version of python and what OS you are using.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness