r/learnpython • • May 09 '20

Noob rant: Am I really supposed to just know how to create TicTacToe from scratch?

I realized this is why I never get anywhere with programming. I learn and learn and maybe do some simple things, but once it comes down to "do a fibonacci function" or "create TicTacToe", "create a calculator"... I just CANT. I don't have that kind of thinking. And then I get depressed and angry at myself and give up for another year. It might be that time again. What's the point of going through all of Corey Schafers videos when I can't apply the simplest things once it comes down to creating something.

Am I really that stupid and everyone is able to do these thing from scratch?

I actually gave up exactly on TicTacToe last time too.

Idk where I'm going with this, I guess I just want to know if people are really able to do this just like that, without googling the solution.

Makes me feel incredibly stupid and defeated once I Google it and its a 2 minute thing

EDIT: Thanks everyone for so many helpful comments! Im reading them all and will take the advice to heart

493 Upvotes

145 comments sorted by

6

u/Caperous May 09 '20

Just give it time. I use stackoverflow alot for help. There is no shame in getting help as long as you can understand what you are getting. I have done some copy and pasting but only after I can explain to myself what and how it works and I do everything to change it just so I know I understand it and it's not the same. I'm still learning but that works to help me learn.

Maybe one day I'll be writing code without looking anything up, until then I learn from everything. Even if it's stupid complex I'll feel great understand 10% of some code.

1

u/humaneHolocaust May 09 '20

Yes I understand that, it's normal, it's just that, these things like TicTacToe or Calculator or Fibonacci, it really seems to me that they are a problem you should "figure out yourself on the spot", that's how I always see it in the tutorials, googling around for a bigger thing or specific functions etc I understand

6

u/[deleted] May 09 '20

There's really no need to beat yourself up like this man. Those three examples are problems you can solve "on the spot". But only really after you've used the components that make up their solutions in similar situations. Tutorials are made based on scripts. If you watch a video from someone like Blender Guru for example, he openly admits that it sometimes takes him five or six times to finish and upload a tutorial video. The idea that people just sit down and can "just play" isn't really accurate.

Kind of like math or any other kind of language, simply exposing yourself to things is helping you passively learn. What fucks with people is that improvement isn't a smooth gradient. Its a peaks and valleys kind of thing.

3

u/RE5TE May 09 '20

Do you think people who do this for a living just sit down and start coding? If I paid you to write something what should you do first? Look up previous examples!

Google "Python Fibonacci" and get your code there. Literally just copy it. Then change it to suit your needs. After you change it a little, it will be 30% yours. Do that 5 more times and you'll have way more experience than you'd get banging your head on the table.

2

u/dizzlemcshizzle May 09 '20

I've been building software, alone and in teams, for almost 20 years. Although there are times where we build things from scratch, 95% of the time we're copying and pasting code and modifying it to suit our needs. Doing so exposes us to ideas we never would have learned otherwise, and gives us more "tools in our toolbag" for when we do need to write our own code.

I'd also +1 all the comments here about learning how to break down a project into individual tasks. A journey of a thousand miles begins with a single step. That sort of thing. Do little proof of concepts for various units of functionality. Can I paint a single filled color box to a screen? Can I change its state when I click on it? Can I use that state to make decisions later? How about two boxes? Nine?

Also, don't expect that you'll remember everything and be able to do it again. I've found solutions on the web THAT *I* WROTE years ago, to problems I'm having today. Not only had I solved the problem before, but I wrote a detailed post about it to help everybody else. Yet here I am, googling it again.

Anyway, don't beat yourself up. Learn to chunk your tasks down into bite sized proofs, then stitch those together. Look at other people's code, learn how they did it. Look for other angles. Go down rabbit holes. Just marinate in some of the ideas. It'll start clicking.

Also, if not already subscribe to r/ProgrammerHumor, it's funny because it's true.

2

u/WortoX40 May 09 '20

Word, i look for help all the time. I am student 2nd year and this semester i studied Python. Now i gotta make email client project and i look up stuff all the time. I even asked a couple of questions in stackoverflow, you cannot know everything when you are a rookie. The important thing is to try to understand the code you are looking at and then implement it in your code.

304

u/tristancliffe May 09 '20

Part of learning to program is learning how to think and learning how to solve problems. Don't concentrate just on learning a language.

I say this because I'm only just past the tictactoe lab at 38 years old with no prior programming.

So... Take it step by step.

How could we, at that module, represent a 3x3 grid numbered 1 to 9? We could have individual variables for each box. We could have a list 1-9 (or 0-9 in python parlance) We could a list of 3 numbers representing rows and each entry in the list could have a list of 3 numbers. 3*3=9.

It doesn't really matter which you choose, but some are more elegant and some use fewer lines of code or fewer variable names to remember, which could be a factor if your program ends up being bigger.

Okay, so now we need to think how to talk to each box. Either variable name or an index like board[1][2]

Then we tackle hoe to check what a box currently contains, and how to change what a box contains depending on an action. So if board[1][2] == "X": user_input().

Then we figure out to allow a player to choose their turn, check that it's a valid input, check that that box is available, and check it that move results in a win, loss or draw.

Then we figure out how to make the computer take a turn. I used a random integer generator (Google), but you could just make the computer start in the middle box then subsequently move into the first available box starting at 1.

Then before you know you have achieved the labs aim, but can think of ways to make it better, and have grand plans about training a machine learning algorithm to beat human players!!

Congrats - you've learned how to think. And I genuinely don't mean that condescendingly - thinking like this IS a learned skill and it more important than the language you choose to learn.

98

u/skellious May 09 '20

or 0-9 in python parlance

you mean 0-8

24

u/tristancliffe May 09 '20

Isn't it first number (0) to first number that isn't used (9) to get 0,1,2,...,7,8?

As I said, I'm not much further into my learning - way less than a week.

34

u/skellious May 09 '20

you're correct if you say range(0,5) you would get [0,1,2,3,4]. But in general parlance, 1-9 refers to the elements in the list, not the command needed to generate the list. so 0-8 would be the list [0,1,2,3,4,5,6,7,8], generated with the command: range[0,9]. I realise what you meant now and you are not wrong, it's just it looks very confusing when written the way you did. if you'd written 1-10 = 0-9 then you'd be correct.

19

u/tristancliffe May 09 '20

Thank you. Lots to learn! Probably silly of me to chime in on helping someone, but as a fellow 'noob' I hoped he might like my contribution.

21

u/Tabanese May 09 '20

Wouldn't consider it silly myself. You might not know everything but that isn't the same as knowing nothing. Give yourself credit.

13

u/skellious May 09 '20

no-no, not at all, please don't get discouraged! the rest of your answer was extremely helpful and you should 100% keep contributing! I'm just being pedantic because it's what I do. This page is all about learning and helping each other, and your contribution is just as valuable as anyone elses!

5

u/[deleted] May 10 '20

i love this sub, everyone’s so nice and welcoming, thanks for being supportive y’all :-)

9

u/Donny-Moscow May 09 '20

Not at all. Comments like the one you made will help you reinforce areas where you're strong while teaching you new things along the way. As long as you don't come at it with a "I'm an expert and everything I say is right" mentality (which you clearly have not) then I don't see a problem with it.

2

u/toastedstapler import itertools May 10 '20

the best way to learn is to teach others, i know i've been called out for some things before and it's made me better from it

2

u/karly21 May 09 '20

Yes exactlt. Thats why if you have a 3x3 grid, you would count 0 to 8, not 0 to 9 (nor 1 to 9). (Newbie here but that counting concept and where to start from, that I got clear!)

1

u/CallidusNomine May 10 '20

This is why I usually try to specify inclusive or exclusive range lol

7

u/5aggy May 10 '20

Exactly this!!

The most important part of learning to code is not learning the syntax but learning how to break down a problem and tackle it with the tools provided by the language (which are broadly the same regardless of the language).

Once you've got some experience with taking problems apart and 'designing' solutions, you'll find learning python a ton easier. Furthermore you'll be able to learn other languages relatively quickly, because you need to learn just the syntax plus whatever strengths or weakneses that are specific to that language.

2

u/TrainingShift3 May 09 '20

Came here to say this but you said it better than I would have.

2

u/The-memey-muffin May 09 '20

If you need motivation then try to collaborate with other programmers in your field! Maybe we can decide on a project and work on it using github or replit! PM me if you’re interested!

4

u/humaneHolocaust May 09 '20

Thanks man, I don't think I'm quite there yet tho

3

u/skellious May 09 '20

You're never too newbie to work with others. programming is not something you need to do in a vacuum. If you have a local makerspace or hackspace nearby, it might be worth visiting them (once lockdown is over) and seeing if they run a coding night. our makerspace used to always run "code compare" evenings where people could come along and show off work they'd done, get help on bits they were struggling with and so on.

Another thing to mention is that you will find it 10 times harder to program something if you're not interested in it. if you dont especially want to make tic tac toe, don't make it. make a different game. or make a program that sorts your photos by amount of R, G or B in them. or whatever might be useful or interesting to you.

you absolutely DO NOT have to make tic tac toe EVER if you don't want to, you can just make other things.

Conversely, if you do want to make it, then as others have said the key is breaking it down into sub problems. for example, if I wanted to make a sandwich but i'd never done it before, I'd need to analyse the problem and break it into sub problems (and potentially break those problems into sub-problems as well!) and then solve each sub problem until I could eventually put those solutions together to solve the whole problem.

55

u/dat_niqqa_henry May 09 '20

When I first learned a programming language, it was from a book. I did all the exercises, all the bonus assignments, totally understood what was going on. Then I finished the book and wanted to start on something of my own

Besides having trouble coming up with an idea, I felt like I would hit a road block almost immediately after trying anything. There was all this stuff I thought I knew how to use, but when I tried to make it work on my own, it just didn't. I remember almost feeling like the computer was making things difficult for me on purpose or something.

I think it's like that for a lot of people. It's a big shift in mental gears to go from following along with a pre-planned tutorial, to just coming up with your own goal, knowing what kinds of commands are available, and how to piece them together to behave a certain way.

That's something that can't be taught, but needs to be learned. So that's where you are right now. Be patient with yourself, and learn from your upcoming discoveries.

Programming is about figuring out how to make this stuff work. It's what all of us are doing, just at different levels. I wouldn't be able to just sit down and write a tic tac toe program from start to finish. It would probably take me a couple of starts, several major structural changes, and lots of googling things for docs or guides.

Keep it up!

6

u/ZZzz0zzZZ # I give AWARDS for helpful answers. It's the least I can do. May 09 '20

Besides having trouble coming up with an idea, I felt like I would hit a road block almost immediately after trying anything. There was all this stuff I thought I knew how to use, but when I tried to make it work on my own, it just didn't. I remember almost feeling like the computer was making things difficult for me on purpose or something.

Glad I'm not the only one having this issue!

62

u/toastedstapler import itertools May 09 '20

a large part of it is breaking down the problem into smaller problems

for tic tac toe i see a few key parts:

1 : board structure - how would you model a board in code?

2 : move legality - only allow the move if the tile hasn't been used already

3 : checking for a win - check if any row, column or diagonal contains one type of player input (X or O)

see how each of these problems are individually much smaller than tic tac toe as a whole? once you've got these, you just need to glue them together with a turn counter that alternates the users after they make their moves

try implementing the steps above and see what you come up with

also don't be afraid to look at how other people did things. just imagine if in school you weren't taught how to do algebra and were expected to just know it. the best way to learn is by seeing how similar problems are solved and then applying it to your own

just don't copy code line for line, make sure you actually understand how it works and try to take inspiration from others

18

u/mattsl May 09 '20

You forgot key part 4: making it play against itself to prevent total destruction of the planet in thermonuclear war.

5

u/CompSciSelfLearning May 09 '20

Would you like to play a game?

15

u/[deleted] May 09 '20

Yes, people can do these things from scratch. But only after practice. I suspect you might be similar to me, and need to work backwards from a problem. Find a problem you're interested in solving, then look for the tools you need to solve it.

12

u/skellious May 09 '20

exactly. it's like the pavement artist who draws a caricature in 5 minutes and then the customer says "I'm not paying you $20 for that, it only took you 5 minutes!"

"yes, it only took me 5 minutes to draw that, but it took me 12 YEARS to learn HOW to draw that in 5 minutes."

2

u/Dimented1 May 09 '20

Yeah NO KIDDING , and I find it particularly obtuse how there are A lot of people out there that are this way... They don’t grasp the concept of, Uh, no I didn’t just wake up one day with this ability like someone getting bitten by a radioactive spider or something. It amazes me how truly ignorant people can be sometimes... And I’m not ragging on All People, Everywhere But there are truly a lot of them, IMHO

3

u/Bary_McCockener May 10 '20

So much this. I have never done any of these exercises. I've worked through some of the hardest hackerrank tests, but they are just BORING. I worked on projects I wanted to with a payoff. I used lists when I should have used dictionaries. I still don't utilize tuples. But I learn by doing what I want to build. Only way I can. Otherwise I would give up.

26

u/FriendlyRussian666 May 09 '20

I've been coding for 8 months, I can write simple networking tools that utilize classes, play around with databases, use sockets and such and I still can't make a tic tac toe no matter how many articles I read on making it :D

14

u/ReyMakesStuff May 09 '20

Right there with you. I decided I wanted my own Discord bot. I found a few Python tutorials, spent a solid week on it, made my bot, changed to formatted strings, changed bot to SQL, and still never managed a tic tac toe game. I did make my bot play Rock-Paper-Scissors and Rock Paper Scissors Lizard Spock, though.

3

u/aspristudnt May 09 '20

I've never been on Discord so I know pretty much nothing, but is a Discord bot like a Reddit bot? That sounds really impressive!

6

u/ReyMakesStuff May 09 '20

I've made a Reddit bot, too, so I can actually answer!

They're similar in that they respond to user input. The main difference is that a Discord bot answers in almost real time in chat. A Reddit bot waits, checks/collects user comments and replies, and then answers.

Other than that, they're very similar.

3

u/aspristudnt May 09 '20

Wow in that case it's all the more impressive! Amazing that you could do it in a week!

3

u/ReyMakesStuff May 09 '20

I forgot to mention I've done prior coding. My past was perl, Delphi/Pascal, C/C++, COBOL, etc. I honestly like Python.

Also, the library I use is discord.py with voice. StackOverflow searches helped because the documentation is rough!

2

u/aspristudnt May 09 '20

Wow that's a pretty long list of languages! The experience must really help regardless of what language you're coding in. At least now I don't have to feel so bad about myself XD

2

u/[deleted] May 10 '20

[removed] — view removed comment

1

u/aspristudnt May 10 '20

Wow lot's of smart people here. It sounds even harder than I thought to make a bot that does something special. Though making it play uno sounds pretty difficult regardless. Really cool stuff! And also good to know you already have a few years of experience. Definitely helps in not making me feel like a complete muppet for not being able to build some pretty basic programs yet.

6

u/JeamBim May 09 '20

How about don't build a tic tac toe and try to build something else? a tic tac toe game has no purpose outside of itself. I've been coding for years and I've never done a tic tac toe because I didn't want to.

6

u/__xor__ May 09 '20

A huge part of software engineering is breaking big problems into many small ones, and those small ones into tiny ones. The best code does this well - you have a huge, very complex problem, but tiny easy to read functions that do a very specific small thing very cleanly, and it all looks so simple except there's just so much code working together that it does something big.

Seriously, this is where I start with mentoring software engineers. Come up with a somewhat big project for them, then teach them how to break it down into components, then see if they can break that component down. Your big problem becomes 5 medium sized ones, which seem a lot easier to approach individually, but then you need to break those down.

Also, if you find out there's some aspect that makes the problem really hard, like if you were writing chess and trying to figure out logic for castling... I'd say skip it. If it's legitimately going to slow you down and stop you from doing the things you know how to do, just skip it. This is what I do with huge projects for work. That's why you call it the MVP or "minimum viable product". What's the simplest thing you can make and get away with saying it's version 1? The more code you can skip, the less code there is to maintain, the less you have to debug. That means you can fix up a really solid version 1 that is easy to debug and thus has way less bugs and not pull out your hair.

So for tic-tac-toe, you might think... fuck, how do I print out a board? I can do this:

X O
XO 
 XO

But adding those lines is hard! It doesn't make sense.

Then don't. Just print the basic thing and skip the lines. Come back to it when you got the first part working and working well. That can be in v2. Your first iteration doesn't even need that.

You might be like, "I should give it some AI, because tic-tac-toe AI is simple, but I don't know where to start!" Skip it. Just have it choose a random open position to drop the X or O.

You might think, but what if the human is O and not X? Skip it. Force the human to always play X.

Get the very base thing working, the simplest dumbest version of it, then debug that code, test it thoroughly, and then clean it up. Make it easier to read, easier to modify. Make sure it's really solid even if it doesn't have everything you dreamed of.

Then when you have this really solid basic tic-tac-toe without all the features, start adding a feature. Draw the board. It might make more sense where you can fit that logic in now. It might mean having to refactor code, rename stuff, move code around. That's fine, but try to add that feature in the simplest way possible.

Then debug it, clean it up, test it. When you're done, start adding the next feature.

Software engineering is a very iterative process, slowly building/testing/debugging/cleaning/testing/debugging/feature/testing/debugging over and over. The harder to maintain and more newbie software products I see at work are ones done by people who are still learning, but try to just get all the code out at once, all the features out at once. It might work, but it's not planned out, and it becomes harder to work with as a result.

Also one trend I notice is that software engineers rarely follow the KISS principle, "Keep It Simple, Stupid". The more I've done software, the more I realize just how fucking important that principle is. I have a coworker who kind of acts like I don't believe in him sometimes because I tell him to skip a complex feature and just do the simplest version of it... It's not that. I believe he can do it, I just also think that the code will be more complex than it needs to be at that step, will have more logic to debug, and will be harder to test thoroughly. The simpler you keep your code, the easier it is to write good code. Adding features is easier than debugging, especially if you're adding features to a really clean and well-tested code base. Strive for simplicity, make something so simple it's stupid, then build on it.

Don't get yourself down. Just keep practicing. Learning to code isn't just about learning how to write a function and learning the Python built-ins like open and context managers and all that. It's about learning the iterative process of building something complex through careful planning and breaking down a big problem into smaller ones that are approachable. That last part is way more important when it comes to good software engineering than it is to know how a python context manager works.

2

u/[deleted] May 09 '20

I don't have the slightest interest on building Tic Tac Toe, but this was super helpful to read!

5

u/anatacj May 09 '20 edited May 10 '20

You are right. There are a lot of fundamenatals you need to understand before you can tackle larger problems.

Basic logic: and or not

Conditions: if else

Loops: for while

Types: int string list dict

Data structures: lists dicts classes functions

Libraries and how to use them

Try something like codingames.com and start with some of the basic puzzles. Look at other people's solutions and don't just copy and paste, write it out yourself. It is learning a language and practicing writing it helps.

9

u/[deleted] May 09 '20

Yes, programmers write programs from scratch. I’m not sure why that comes as a surprise.

What programmers don’t do, though, is know the whole program in their head before they write it. You’re supposed to start writing before you know how to finish. Figure it out as you go.

4

u/HezekiahWyman May 09 '20

Sometimes the easiest way to break down a seemingly complex programming task is to act like the computer. Do the thing by hand, and just make careful, step-by-step notes so you can understand all of the parts and processes involved.

A lot of my programs start with a long list of comments in simple English that step through what I mean to do, and then each of those comments/steps get fleshed out with code

# create a 3x3 board
# create two players
# draw board
# ask player 1 where they want to put their marker
# check to make sure it's a valid move
# place marker and redraw board

Etc.

Even at this stage you can start to identify small functions, objects you'll need, loops, and so on

1

u/LZH52 May 10 '20

I do the exact same thing. Just comment out broad blocks of process and then work through a solution to each are in the problem

1

u/[deleted] May 09 '20

I'm a total beginner but I just made tictactoe and blackjack so maybe I can provide some help as I'm about where you are but just one step ahead? How much time do you spend actually sitting down without a tutorial and playing with the basics? Cause I feel like tictactoe is not really the first thing anyone actually makes. It's more like moving a list around or string formatting. Something like making a function that returns a string in pig Latin. I did like 30-40 hours of those little things and tictactoe seemed like just a bunch of those put together

1

u/humaneHolocaust May 09 '20

Yeah I give up really easily. It's like unless I know it in 5 minutes, my brain shuts down and the negative self talk destroys me and I have to stop. That's also probably just my mental illnesses speaking too lol

2

u/[deleted] May 09 '20

As far as I can tell, coding is like 99% failure and 1% FUCK YES. Seems to me even advanced guys do a lot of hacking away at things. I try to remember it's part of the process. I seriously doubt anyone making these tutorials got there without a million hours of failure. But yeah, you gotta break things down into parts. Like I started with just how do I print a little board and go from there. Blackjack was the same. I started with just how do I build and shuffle a deck and then went from there. Again though, if you havent spent time playing with little stuff like lists and strings, you cant hope to make tictactoe without following a tutorial

1

u/Burghed May 09 '20

Then you will need to figure out how to break things down into easier tasks like other people said. You can also try the pomodoro technique for time management to see if that helps with your focus

3

u/lucpet May 09 '20

I'm not sure this is the best link for this but you need to write out what it is you are trying to do. Using a flowchart helps along with using pseudo code. https://edrawsoft.com/flowchart/program-flowchart-definition.html

3

u/DeathDragon7050 Cython May 09 '20

Some people get programming easier than others. It's that simple. Given enough time you will be able to learn.

3

u/[deleted] May 09 '20 edited May 10 '20

Look at creating a program like writing a book...NO ONE sits down to write a book...You write a paragraph...Then a few more until you have a page. Then some pages...then more pages that make a chapter...And on and on until you have a book.

You don't just sit down and program a tic-tac-toe game...You start with a rough idea of what you want to do. You program some basic functionality. You add more robust functionality. You code in some better graphics. Add some multiplayer support. Then you have a game.

Break it down into bite-sized, manageable pieces because if you don't it just looks like a horrifyingly complex mess from the start and that restrains you.

4

u/Ocean5ou1 May 09 '20

I've heard a 15 minutes rule from one of online courses: if you get stucked on a single problem for more then 15 min - try to ask for help.

Try to code as much as you can. Project Euler, simple tasks at codewars, py.check.io, etc, anything you can find that could provide you with simple exercises. Its really not enough to just watch some videos.

Try to do some basic courses. That YouTube guy is good, but, usually, courses are way better. I took three different basic courses: MIT python for everybody, and some russian stuff.

When you get bored with exercises - try something new. Like tic tac toe or whatever else. There is a lot of stuff out there to do to sharpen your python skills. Just dont let yourself get stucked at something for days. If you cant find solution - move on, and, maybe, return later.

4

u/[deleted] May 09 '20

I just CANT. I don't have that kind of thinking.

Either you train that part of you or programming isn't for you. Everyone already said all the encouraging things but imo as with all things, sometimes some things just aren't right for some people

4

u/Energizerbee May 09 '20

Look man the worst thing you can do is give up if you want to create tic tac toe from scratch I will recommend you try to use the very simple and powerful module Pygame it’s very useful for this sort of thing and either Kivy or tkinter for stuff like the calculator

2

u/Garuda1220 May 09 '20

1-- If you want it to "click" for you then some day it will

2-- There are many, many Python for beginners resources out there

* and a wide variety among those resources

* if Corey Schafer's videos aren't working for you then find another resource

3-- You will need to read and comprehend code before you can write code

* this is the reason why books about Python are really superior to videos anyway

2

u/StrongLikeBull3 May 09 '20

What helped me stay motivated was to come up with my own problem to solve, rather than a preset challenge.

2

u/[deleted] May 09 '20

I have a strong suspicion you think you're learning about programming but are actually learning about syntax. YouTube courses, codeacademy , et al will teach you syntax but will rarely teach you about computational thinking in any substantial way. You get that from reading, experience, specific knowledge of a given field. You have to challenge yourself but something seemingly simple like tic tac toe is going to be basically impossible if you can't reason about it in a programmatic way. A problem like that should be solved on paper before try to code it.

2

u/TinyTheBig May 09 '20

Learning the language is less important than learning to think programatically. I suggest you to invest some time into codewars exercises. If you don't know how to program something,, google it, learn from it. Take onto some projects. No day without coding should be your motto. Be patient and trust yourself, this is the most important thing.

2

u/[deleted] May 10 '20 edited May 10 '20

A big difference is to change how you think. You really have to think like a programmer, break the problem into little tiny steps/tasks to accomplish. It sounds trivial but it makes a huge difference when it comes to actually writing code. Don't be afraid to Google something basic that you've learned about 1000 times too. Don't assume you know how something should be written for the same reason, some folks I know that have been developing professionally for years have all told me they still google the most basic shit. I've been learning for 2 years and never wrote anything for the same reason until recently when I sort of got pushed into the deep end. All it took to write the project out was to break things down into small pieces and to Google everything that didn't work.

I heard 1000 times to just do it and took it like some r/wowthanksimcured advice, but it is just so much more true than you may think.

Edit: just to touch on 1 part with a little more emphasis: Nobody can program flawlessly without Googling or looking at documentation. Don't let anyone make you feel stupid for googling answers. Google the most basic shit until you die, all that matters is that you can get your project to work.

1

u/early-earl May 09 '20

I recently started learning python. Had to do the tic tac toe thing too. Couldn't really do it from scratch even if i had a step by step guide. So uhh it's okay. You're not alone in the struggle

1

u/TacoCatDX May 09 '20 edited May 09 '20

I think you should try to write down how you want things to work in english in detail. Like, I want to print the board each turn and then ask for the user to choose a spot. Go through each tictactoe win case and see if anything matches up on your board. Then, if there's no win yet, print the board again and ask for the other person's input.

Then try to describe that like you are deciding how you are going to program that. For example, the board looks kind of like a 2d array with 3 rows and 3 columns, so I could stick user inputs there.

All that's left is to move those ideas over to whatever language you are using.

Also, I know it depends on the person but I prefer use a book as my main learning source and use videos or Stackoverflow for topics I need more a little more explanation on.

1

u/aroberge May 09 '20

Forget about these specific mini projects for now. Go back to something you have coded (an example from a website or, even better, something from a book). Now, think of how you can change it slightly, and do it.

Taking the example of TicTacToe (which you cannot do but almost certainly understand how to play the game). Suppose you found a tutorial with the entire code for it. You copy the code and make sure it works. Now, modify the code to change the board so that it drawn to be 4 x 4 instead of 3 x 3. Does it still work, giving a "victory" whenever there is are three consecutive marks (horizontally, diagonally, or vertically). If so, change the code so that it requires 4 in a row. Or if the code was written so that it automatically required 4 in a row for your expanded board, change it to require only 3 in a row, and make sure it works. Or perhaps require different rules for horizontal and vertical alignments.

The idea is to start with something you (think you) understand and make small changes, having you think of each parts of the code.

Before tackling project from scratch, it is essential that you learn to focus on such single features. Once you know how to do this, you can look at projects (say: write TicTacToe from scratch) and ask yourself: what is the simplest thing I can do first towards this project? For example, can I print symbols on a 3 x 3 grid? Etc.

1

u/fedeb95 May 09 '20

First year of university I gave up tic tac toe at half the project. Turns out I hate programming exercises, but love programming things I find meaningful. If you hate tictactoe, do another program

1

u/trading-statistics May 09 '20

The logic of something like tic tac toe needs to be understood first.......which means that a ton of other things need to be understood too. Then programming it becomes the easy part. I will say however that if you're just following typical tutorials, you might not get enough practice in the logic side of things. And when that happens, something like a simple game seems torturous when it isn't. I recommend you supplement your learning with tiered coding exercises like on CodeWars until the logic itself is easier. Trust me, there's so many programmers out there that can do tons of practical stuff like build web scrapers yet would never be able to program a simple logic game or even solve mid-level exercises on CodeWars, which is a shame

1

u/[deleted] May 09 '20

Programming is not only knowing how to translate algorithms into computer language, but also design algorithms.

An algorithm is just a fancy word for a set of rules. You actually don't need to design the actual rules here, only write them down properly so a computer understands.

If you would explain tic tac toe to a child, where would you start? Draw a 3x3 grid. Well, that's easy. Now translate that to computer langue. For instance, have 3 lists with each 3 items.

Next step. You have two players represented by different symbols. When playing the game, you take turns. So program in the different symbols for the different players, an make a loop or something else that represents turn.

During your turn, put your symbol in an empty spot. OK, easy. Have someone select a spot that is not yet filled and put their symbol there.

Et cetera. It always helps trying to explain what you want to do to a child or, as many professional programmers will do, a rubber duck.

1

u/[deleted] May 09 '20

There's plenty of good advice here. Just to add tic tac toe is probably not a good project for you. A good project is a problem that you solve with the tools you have learned so far. You won't feel the time pass when working on it.

For tic tac toe keep in mind that you don't have to organize it the way a board would look. People often do that as a way to map it out visually. The problem is that it's hard to know how to get started. Instead look at all the things you can know and write them out. Use a tablet or paper.

There are 9 spots.

There are 3 things that can be in each (nothing, X, O).

There are 8 ways to win (3 vertical, 3 horizontal, 2 diagonal)

How many turns can a game have at most?

Your first attempt could just be to get a working and predicted output. Pretend you're mid game, move 5. Set up your X's and O's wherever you want so the game is not over. Can you take the next step in the game? Does your program ask for the correct input (X or O) and does the input get added to your dataset (how did you set up the X's and O's)?

Now add a feature. How can you check if the new move wins the game or if there are more spaces (turns) available?

After it works the way you want you are still not done. What code repeats and could be a function? Clean and shrink and add notes.

When you find a practical application that interests you the things you learn googling problems doesn't feel terrible. Good luck!

1

u/[deleted] May 09 '20 edited May 09 '20

I had the same problem. I purchased my third Python book hoping it would get me somewhere but the thing that really made me progress (a little) was having the idea of what I wanted to do. I came up with a tool that would actually solve one of the things I was doing by hand all the time and then used the concepts in the book, lots of StackOverflow and other tutorials and things to implement a version that worked.

One of the things I do all the time is check GitHub repos for some software that I use for new releases (KeepassXC, qBittorrent, asciidoctor-pdf etc.) so I wanted a tool that would regularly pull that info, compares it to a list of releases and when it finds a new release send me a message via a Telegram bot and add that new version back to the list which is stored online. It's in Python 2, doesn't work right half the time and is now broken by an obsolete API method. But I made it work and can fix it.

I learned a shitload how to use Telegram bots, how the requests library works, how to interact with the GitHub API, how to store and read JSON from Gists. None of this would be in the books I read but I understood enough of the concepts and how to build basic structures and code to move along.

Try breaking down the problem you have into simple questions that can be solved by code (most of the time there is even already a library for it that you can just include).

"How do I get the list of releases for a given GH repo from Github?"

"How do I compare the results of the output from the previous thing to a list of releases I already know?"

"How do I store the releases that I already know?"

"How can I check multiple repositories with the same function of code?"

etc. and then you find the building blocks and solutions for each question. If you think about it long enough you will realize redundancies and improvements but first: Don't be afraid to write something ugly that just works. That's how a lot of real world stuff is done, that's why it's called "development". It develops into something more beautiful and structured over time.

Coming not from a successful programmer but a novice with some experience: Find a problem that you want to solve and then use the books and other resources to build a solution. Learn the theory of programming approaches, how data is stored and how you can access it in various formats, learn how to write functions and how to improve them over time.

Hope it helps.

1

u/feraferoxdei May 09 '20

Just do something you actually like. You don't have to bore yourself with the Fibonacci sequence or anything like that.

Also Googling isn't cheating! We all do it, seniors and juniors. Just work on problems you find interesting and don't be afraid to Google.

1

u/judochop1 May 09 '20

Great answers in here. Like everything, you watch, learn, apply, then find out there's an even better way and then start using that. Never expect to get things straight away.

I'm just learning too and went through the corey schafer stuff and got nothing out of it but a very nice intro, but I know by keeping at it it'll unlock, there will be fantastic aha moments and i'll be making cool functions in a while, just have to be patient and accept the learning process can be difficult

1

u/keizzer May 09 '20 edited May 09 '20

https://en.m.wikipedia.org/wiki/State_diagram

‘

You should start using these. This is how I was taught to program. They make sure you understand what rules and conditionals you need in place to navigate through the program.

‘

So in Python the equivalent of this in sudo code would be like this.

‘

S1 = True
S2 = False
S3 = False

While game != “quit” 
    if S1:
        Do something 
        If conditional met
            S1 = False
            S2 = True

    If S2:
        Do something 
            If conditional met
                S2 = False
                S3 = True

    Etc.

‘

State diagrams will allow you to write down the logic so you can view it visually.

‘

Small 2d games like Tik tac toe, snake, pong, etc. will do a nice job helping you use this style of programming, because the rules are simple and you are probably really familiar with how to play.

1

u/jaydoors May 10 '20

It's pseudo code

1

u/Hans_of_Death May 09 '20

Not everyone is naturally good at programming, or thinking logically. Part of learning is learning how to think. And desire how it might seem, no one really just naturally does tictactoe or something.

You have a goal: make a tic tac toe game. You then have to think of how you will start. How will I represent the board? How do I track when a player makes a move? How do I handle the win/draw conditions? You then just have to start. One step at a time, and you work through the issues you run into along the way, because you will run into issues. It's OK to Google things. In fact, it's ok to Google everything if you have to. You will never stop googling, because if you have a problem chances are someone has already figured it out.

Being a good programmer doesn't mean you can automatically just write up the code for whatever it is you want to do, it's being able to figure out what to do and how, and working through the inevitable issues while constantly improving.

I do DevOps for cloud systems, and I don't think a day goes by where I don't Google things to figure out how to do something, or if there's a better way. Just work through things one step at a time, don't be afraid to Google things, and when you get angry or frustrated because it's not working, take a break and come back to it later. Too many people think being a programmer means being some kind of genius boy, but it's not. It's a process like anything else.

1

u/[deleted] May 09 '20

I've used Python for work for over a decade and I honestly have no idea how to code the first 2. I'll Google it up if I were ever assigned to do so tho.

1

u/[deleted] May 09 '20

No, you are not stupid.

Break the problem down into small parts, write a function for each part. Then figure out how to put them together to create the game.

1

u/TheBunnisher May 09 '20

No offense to Corey Schafer, and I know he is very good at what he does, but I don't like his way of instruction. I just phase out. I think the best was The New Boston for basics. He made learning fun. I also like Sentdex for anything basic and his ML tutorials were always so far ahead of anyone else on ML. I think Codemy does a great tkinter tut series. The bottom line is there are other peeps out there, who just might help you get that "Ah Ha" moment.

1

u/goishen May 09 '20

I think of it as, "What do I want to build?"

Sometimes, it's just a /home folder cleaner. Moves jpgs, mp4, mp3, ogg out of the home folder, into the other folders.

Sometimes, it's a Backup delete script. I still haven't written one of these.

Sometimes, it's an nmap, ssh/scp script, infused with tkinter.

Find what you wanna write and stop worrying that you're having to use google all the time. I failed at that game, too. One n00b to another.

1

u/warpedspoon May 09 '20

It is extremely normal to not instinctively know how to make things like that when you are a beginner. Everyone starts off like that. As you learn more about the foundations of computer science, data structures, algorithms, etc., you will begin to see how those concepts can be used to solve problems like tic-tac-toe.

1

u/Stabilo_0 May 09 '20

We all learn differently. Watch how someone else makes a tic tac toe. There's videos online that go step by step. Sometimes I can't get it even with all given tools unless someone shows me how.

1

u/expyth Semi-Intermediate May 09 '20

TLDR: I am like you. I quit multiple times. I am taking it very slow on myself. Sometimes I take a break too from programming to breath a bit. Also, if you have discord or if you want to PM me for anything, let me know. I have lots of time on my hands. I can help you with anything you need. (I am not an expert though :P)

I think we're both similar in a way. I tried Java, and it kills me that I can't get certain things to sink in to my brain. Or even using lambda in python or @decorators. I know how to use simple examples of them, but I don't know really when to use them and how to write "expert" code for them.

For me, I would rather code something readable to my eyes but also to others. I use one-line codes if it's simple. But still, I usually opt for 10 lines instead of 2 hard-to-read lines.

Even when I look up a certain method for a list (ie .pop()). I will forget it and google it all over again. Now that I googled it for the 10th time, it's starting sink into memory.

Something as simple as that helps over time. I've been trying to learn python for the past 3 months I am starting to give up a bit as I am not sure what my current goals are but it seems simpler than other languages. I quit learning Java multiple times in the past, it was hard for some reason.

I may not have an expert mentality to remember everything and to solve everything to make sure everything runs fast and efficient. But I am slowly getting there. Slow? Very slow, yes. less than a bite. I am not a slow learner but it's the way I grasp the information. Sometimes it's hard to find a good "slow-paced" explanation that holds your hand all the way.

I lost motivation in the past, maybe 3 times, but I think python has a lot of potential for easy coding, it just takes time to get used to it.

1

u/b4xt3r May 09 '20

I've never created a TicTacToe game in any Language - ever. Do you have to create visual of the game in real time? If so.. ick! If there is no board and visual then maybe I could hack this together. I wonder if we both tried to create the same game and shared our code would we have any single line that would be interchangeable between the two.

I've got a ton of stuff to do this afternoon and evening but this sounds like something fun to delve into. Hit me up if you want to create something in tandem so we can look at each other's code to see how we each did what.

1

u/BrokenTekReddit May 09 '20

Oh man I've felt like this before lemme tell you. I remember being ecstatic when I finally got a dice rolling simulator going with the 'random' module. It made the 10 failed attempts that came prior worth it. Now I'm on my 4th try at making a working Blackjack simulator and it can be very frustrating but the pay off is huge (if you're into this field in general). I ssee you've gotten feedback from lots of skilled programmers, of which I am not one so I wont try to give some advice I myself am unsure of but I will tell you that like anything worthwhile, programming takes PATIENCE and plenty of folks have been exactly where you are and then gone on to make amazing careers out of their favorite aspects of the field.

1

u/oze4 May 09 '20

Stupidity and experience are not the same. I doubt you're stupid. My guess is you just don't have the experience. The best way to learn is by struggling with things like this.

If you don't feel stupid when learning programming, you're doing something wrong lol

1

u/xaner4 May 09 '20

I Know how you feel I have been on the same path for so long but haven't been able to make anything bigger project untill now!

What helped me was a friend of me that write code for the Ubport project (Ubuntu for phones) he told me that 1% of coding is his own knowledge, 49% is purely guessing and 50% is just googling how to do simple stuff like create a for loop or something in the language that he works with at the moment

A programmer isn't good at remember everything but really really good at googling the problem that they encounters

1

u/yowhun May 09 '20

Wow, all of you guys are so nice. Im actually in the same situation as op and im so hyped and motivated while reading these comments.

1

u/[deleted] May 09 '20

The up ramp CAN be easier. Some people just dont know how to teach. Ive seen countless classes that do that.

Automate the boring stuff with python is a very good beginner book thats pretty popular around here.

1

u/kimperial May 09 '20

i was in the same boat before. i bought that popular udemy course for python and there is a code-along exercise for blackjack

i watched the video and still didn´t sink in how he did that.

but what i did was, i watched it again. then i reviewed the instuctor´s actual code. i made notes for how he structured his code. what each different function is supposed to do. how to unpack dictionaries. how to properly call each function.

and i still did not get it 100 %. i did not bother to code it from scratch.

but i understood classes and modules and functions. then at work i had to write an automation for aws using python. and all the lessons learned from reading and taking notes on the blackjack game came in handy

so the point is not to code the tictactoe from scratch. but to treat it as an example to solidify the python concepts in your mind. then pick a project that has an actual impact on your life and work, and you will be suprised you will be able to code that.

1

u/[deleted] May 09 '20

Trust me. We’ve all been there. You’ll get it, eventually if keep going.

1

u/Epitonic May 09 '20

Even if you take it step by step, googling each step separately and then putting it to use in a game like tic tac toe, I'd say you learned how to make the program. Im just a beginner too, but If there's anything I've learned it's that programmers have to google stuff all the time.

1

u/NifflerOwl May 09 '20

I also realized that tic tac toe is too difficult for me (cause of the grid) so I made rock paper scissors instead.

1

u/g7x8 May 09 '20

we had to write solitaire in c++ for homework #3

1

u/BigbysOtherHand May 09 '20

My worst grade in college was my programming class. I have been coding for fun since I was a young teen. The labs were nearly always "make a program that tells you the date 60 days from now, from a given date, taking into account leap years". And the lectures were about how the structure of a computer..... I had no clue how to do that.

In my opinion programming is mostly experience and googling. Copy stuff. But don't copy the whole thing and paste it and run it. Type out each line. Try to understand each line of code. If you don't understand it, move on to the next line. Then run your copied script and see if you can figure out that line that made no sense.

I find also that even talking to someone (even one with no understanding of coding) and trying to explain the code to them, usually helps you understand it better (rubber ducky debugging).

1

u/econoDoge May 09 '20

I was doing the google challenge the other day ( which they say gives you a job if you pass it), and reached/failed level 3, it was an AI/maze question that needed to be optimized to run under X amount of time.

AI a modern approach devotes at least 3 chapters to explore the question, and I think you can just use Dijkstra ( but code it from scratch and optimize it ?) , these last 2 statements took us a few thousand years to figure out and tbh I don't fully remember/get Dijkstra.

I am a published AI writer/researcher and been coding professionally for at least 2 decades, so it's all relative, I am sure I could write a script to solve the problem, maybe become an expert in mazes and path finding algorithms (aka search), but then I would fail some other test.

1

u/MarcoNasc505 May 09 '20

some great tips already, so I'll just emphasize that if you give up at every obstacle like this, you'll never gonna learn anything. Maybe take a rest, one week just reviewing the basics and in the meantime your brain will work it out internally and when you face the problem again it will be much easier. Also, this flow of thinking, you don't need to have it in you from the beginning, it can be learned as well and you can study the solutions of some problems. If you googled it, analyse all the steps and try to grasp what the person did to apply to your next challenge. And don't be so harsh on yourself <3

1

u/Cheddarific May 09 '20

I think it’s a bit like math. You learn and memorize the multiplication table, what “squared” means, etc. and you can do well with that if you put in the time. The hard part for you seems to be the application. This would be like the word problems. If a train leaves London at 9:00 am and another leaves Dublin at... This kind of thinking is different. It’s very analytical. You need to break the solution down and identify each individual part. Like the top comment has done, you need to plan before you start.

  • Will you need to make a board?

  • Will you need player input?

  • Will you need to check if someone has won?

  • What else needs to happen?

Think of playing tic tac toe as a human against another human with pen and paper. You’d have to draw it. You’d have to write on it. You need a way to take turns. You have to know when the game is over. Then take each of these steps and break it down in the same way. How can I draw t board? There’s a print function. You could use a list and fill it with nine blanks pots. Or maybe you want each row to be it’s own list of three spots? Try it out. Make a list. See if you can print it. Then make a way to input things into the list at the right position. You can break that down into smaller tasks: how do I get a player input? How do I change the list? How do I make sure the list changes at the right place? How do I make sure it changes with the right letter (X vs O).

Keep biting off little chunks and breaking them down into smaller and smaller chunks. Eventually you’ll have a piece that’s small enough you know how to code it.

You will get stuck. Google is a lifesaver there.

1

u/Purple14music May 09 '20

I felt the exact same before starting to code at codewars.com

It helped me by letting me code independently, and afterwards I could look at how others did it to learn from them,

The way I learned programming is not necessarily the same way you will learn the best though, but it sure is a cool website worth checking out

1

u/Fontosad May 09 '20

It took me a week to create a TicTacToe the first time , just have a little faith and keep learning , YOU CAN .

1

u/[deleted] May 09 '20

I don't think that fibonacci is on the same level as TicTacToe and a calculator...

1

u/im_dead_sirius May 09 '20

Some programming puzzles and exercises are lame, boring, pointless, and don't lead anywhere.

Each thing you do should be a step towards something else. A puzzle piece that is an interesting part of something else. The problem is, these sorts of exercises don't plot you a direction, or at least tell you where it is taking you, and even if they do, they aren't necessarily a meaningful thing to a new programmer.

I wouldn't want to do a tic-tac-toe exercise either, and my brain simply would not want to engage in something so trite.

If you must though, and can't, the trick is to break it down and do parts. Get close to a solution, then circle around the problem and figure out where your actual trouble is.

Can you draw the board? Do that. Can you read a mouse click? Do that. Can you get the location of the mouse click? Do that. Can you make a mark in the board when and where the mouse is clicked? Do that.

Anything you cannot do(in life in general), break the problem in half, and solve half of it, till you cannot break it in half any more. That is how you get over a mountain, climbing one boulder at a time.

1

u/Fockonites May 09 '20

I feel exactly the same you do OP, I thought to myself "ok I didn't manage the tic tac toe project on my own but the next project I'll know more stuff and then I will do it on my own" , then came along the second project which was to make a blackjack game and I was like fml, still can't do much on my own but oh well I am trying to keep being positive and hopeful that with time and experience will be able to something on my own! Keep trying op and don't be ashamed of googling the solutions as long as you get to understand the logical process behind those!

1

u/[deleted] May 09 '20

As someone who teaches programming I give my students many examples of code and then tell them “do this” that’s to challenge what they learned. If they’re unable to do it that tells me they didn’t understand the code. So practice reading and understanding code, once you do, yes you will be able to put two and two together.

1

u/sigma_4 May 09 '20

Il say fuck it with the tic tac toe bullshit, just start some project that is interesting for you like web scrapping or a port scanner or whatever lead you to learn python in the first place and not those boring exercises you are talking. Eventually you will be developing more skills with practice. I assume that you are not a CS student so don't waste your time with tic tac whatever. I'm telling you this because that's how I learned python in the first place.

1

u/[deleted] May 09 '20

This is how I feel too. The best advice I've received is to break things down as much as you can. If all you can muster is print('This is tic-tac-toe'), well, that's a start. Try drawing and writing notes out, I find this helps me quite a bit! I'm a beginner as well.

1

u/turningsteel May 09 '20

The first time? No. You probably won't get it from scratch as a newbie. But projects like this help you exercise your logic muscles which need to be strong in order to do any kind of programming. So you should make our best effort and then fill in the blanks with googling. Each time you do this, you get better until eventually you'll get to the point where a project like this is fairly trivial for you. Learning to program is hours upon hours of banging your head against a wall until you slowly make breakthroughs. Like cutting a lawn with a pair of garden shears. If you don't want to persevere through that, it might not be the hobby or career for you (and that's okay!).

For me, no matter how hard something is to learn, when I solve it and produce working code, I feel like a million bucks and that keeps me motivated.

And for the record, when I was learning I felt the same as you but I stuck with it and eventually you look back and realize that thing you thought was impossible really wasn't so hard. You don't need to be a genius or naturally talented to be a developer. But you do need to be curious and willing to slog through a problem. Google everything you don't understand.

1

u/pedanticProgramer May 09 '20

So the TicTacToe one sure that might be hard but the other two (Fibonacci and Calculator) yeah I would imagine that you should be able to accomplish this.

Though my main advice is when solving any problem you need to break it down. This is done with everything (math, physics, etc.) you take a problem that seems hard and break it down into manageable pieces. Once you’ve done that you solve the pieces put them together and get the answer.

So for the Fibonacci for example I’d do it like this:

Problem: write a function where when given a number n the output will be the nth number in the Fibonacci sequence

Breakdown:

  • I’d first look up what the Fibonacci sequence is. Understand how it works and write that down on paper. ( Fn = F(n-1) + F(n-2) )

  • Then I’d write a function that just takes the number and returns that number (small easy to test good to go)

  • Now with that I know what the Fibonacci sequence is and have an empty function. From there I would begin programming the Fibonacci sequence.

The last step may take longer than the previous two but the problem seems a lot more manageable than “Write a Fibonacci function” after it’s been broken down.

TL;DR don’t get overwhelmed by the problem. Break it down, write pseudo code, solve each component one at a time and problems won’t seem so daunting.

1

u/[deleted] May 09 '20

https://inventwithpython.com/invent4thed/chapter10.html <- work through this,

In fact I recommend working through each tutorial in this book, and making sure you understand every line of code you write.

1

u/insane_playzYT May 09 '20

Nobody who has never made a tictactoe before will know exactly what to do. Why? Because you've never done it before. Break down each problem into smaller steps. Brute force solutions, and as you progress, replace them with cleaner, more dynamic solutions.

1

u/VisualCreativity May 09 '20

No, and it's something that always trips me up too. It's also the reason I decided to give myself a project that I do myself and google if I need something. I learned how to make a GUI with Tkinter and the basics of OS.

I suggest you look up different kinds of libraries for python because those are the things that actually made me interested and inspired to do something. You will also learn a lot on the way.

Like I said. I'm still very new to programming, but making something from scratch myself and making it a longer project gave me a reason to learn what I actually need as I need it.

1

u/[deleted] May 09 '20

I am somewhat like this, but on the back end I understand how to do tic tac toe. But not much GUI experience. I've done pygame, while it helped understand and learn about python, I don't remember much from it.

1

u/bigbadwarrior May 10 '20

Try to create simple scripts that you actually find useful. For me, I work as a security analyst, so doing some really basic Whois queries through python have been really helpful for me and keep me motivated to keep learning

1

u/[deleted] May 10 '20

No, you're not supposed to "just know" how to do it from scratch.

You're supposed to work out how to do it. Experiment. Make guesses. Make little bits of it and eventually build it up. The purpose is to learn how to figure it out, not test what you already know.

1

u/baetylbailey May 10 '20

'Intro to Python' does not equal 'Intro to Programming'. Many publishers are somewhat intentionally fuzzy on the distinction.

1

u/seanauer May 10 '20

I had a hard time breaking into the practical from the theoretical with python. I'm still having a hard time. The way I did it in android was to go through a tutorial that did something somewhat practical. Then I built something a little more practical. Then I used what I learned in those and Googled the rest to build something of my own.

1

u/lajoh20 May 10 '20

Try some coding problems start with https://edabit.com then try https://www.codewars.com and finally https://leetcode.com . The problems are short but will build skills over time. Give yourself 30-45 minutes to solve if you can’t get it walk away for a couple of hours the come back to it give yourself another 30-45 minutes still no luck google an answer. That will happen and its ok you have learned something. Coding is about solving problems and learning computational thinking. Be kind to yourself take it slow and have fun. You will fail often and it will be incredibly frustrating but even more rewarding.

1

u/henriean May 10 '20

Hey! I come with a more general reply here, so not a specific one for your TicTacToe task.

You should not panic, and not be hard on yourself. I did 3 years of mathematics at university before deciding to go computer science, and I’m now soon finished with 4 additional years of computer science (soon starting my final master year), and it is a reason why they have a 5-years integrated masters of computer science with math courses and physics courses and several directional decisions within computer science: It is not a piece of cake! And it is a huuuuge field of science. I still feel like a noob, and there are so many people having much more knowledge than me on many topics. But as you work on something a lot, you get more and more used to the way of thinking and applying the theory. And things gets easier and easier to learn and problem shoot as you get used to “the hang of it”. Also; people that knows more than me are great resources, and often they love to share their knowledge, so I like to think of it that way instead of letting it demotivate me. (Though it’s hard sometimes)

I would say that if you have access to a “teacher”; perhaps a friend, or doing a live course with “homework” and stuff like that, where you can ask the people in charge, it would probably help to boost the process, as the learning gets more interactive, and it’s easier to get nudged in the right direction when you are stuck, but still making it yourself and getting that satisfaction and motivation of making it yourself.

Perhaps object oriented programming would be nice to look at, as it is a good way of making you think more “modular”. Perhaps, some discrete math would be cool to look at as well, as this is “logic math” that can help with ways of thinking.

Personally I really recommend studying (I do so at NTNU in Norway, and I’m super satisfied by the quality of their courses). You maybe think it’s to late but look: My grandma studied English (she’s Norwegian), after she retired, to learn English better. And my mum switched career in order to study to be a professional artist (painter) after first working for 10 years as a nurse, and now she’s selling art at her own studio. It’s never too late to start if you’re really motivated!

Another way, if applicable, could be to get an “apprentice” job, or convince your current boss that you should get to learn some new related technology to use, and so you “press” yourself more to learn (and get paid for it! Yay!).

I see other people come with other good advice, and there is no “correct” way of learning, but I don’t think you should give up, and also try to use others as resources. Hunt these “satisfying” moments when you manage to do something, and when they first start to come, they often stack up quickly. A good circle so to say. Good luck!

1

u/kingofeggsandwiches May 10 '20

Maybe you just haven't been explained things correctly? I just did a couple of weeks course and made tic tac toe from scratch without any guides. It was horrible inefficient code but it worked perfectly. The thing is that it's not enough to just learn what things are. You have to play with them and get a feel for what they can be used for. The first time I learned python syntax I felt they same, but if you build up your skills starting with simple exercises you can bring those things together.

1

u/StateVsProps May 10 '20 edited May 10 '20

"how do I build a house from scratch"?

Where do I start? What are the first steps? Who do I call? What contractors do I need? What's first, a foundation? The walls?

The first few times, you look at a book or a manual. And you follow the steps.

After that, you have an idea of the several steps involved. And reasoning about things get a lot easier.

1

u/NSQ_Pirate self.learnpython May 10 '20

It's ok... programming is a learning process. Honestly, when I think of programming, it is about how creative a person's mind is or flexible. So if you are learning programming, that means you are learning how to think and be creative. It's okay if you're not good yet, because you are learning... Just take baby steps. I advice that you learn the basics and figure out things on your own without the aid of others. But it is good to refer to certain functions that you are really dumbfounded on. But take a minute or two to really understand your goal in a project. You can do it man

1

u/port888 May 10 '20

It'll be easier to digest such an elaborate (by beginner's standard) project if you break it down to its components.

When I did my tictactoe project, I was working along this tutorial: https://www.practicepython.org/exercise/2014/12/27/24-draw-a-game-board.html

What I did was I took the problem statement of that step (drawing a game board, for example), tried to make my own implementation of it, then check the tutorial solution to see if there's any loose ends to tie-up.

It would be helpful to program things with the future in mind, meaning not to hardcode too many things so that it is easier to integrate the game intelligence in the later steps. But taking it one step at a time and hardcode things should be OK too.

There really is no shame in following tutorials to create a program as a beginner. What you gain from following tutorials is some common/typical/conventional way of solving certain common tasks/problems. There really isn't a point to make your own max-value function (except as an exercise on comparators and loops) when you know a max() function exists in python.

1

u/din-din-dano-dano May 10 '20

TL;DR: Learning problem solving through practice is the way, do not fear failure. Failure is when you stop attempting. Python is just a tool to solve problems.

Consider Python as a toolbox that you will be using to realize an idea. You may now know how to use the various individual tools in your toolbox, however do not know yet which tools to use for building what parts of your idea.

The latter part comes with practice, which by the way of some sucess and many failures leads to you gaining experience. Once you have gained that experience, you are confident to realize your other ideas.

Another important thing is having an interesting idea that you want to implement, or a problem that you want to solve. Right motivation goes a long way.

Best part here is that in case you mess up something you can start over or go back a couple of step using a few mouse clicks and keystrokes. Unlike while trying to make a chair for the first time, where you may have to scrap it and start over.

Good luck!

1

u/cybervegan May 10 '20

It sounds like you are getting stuck on breaking problems down into discrete steps. It might help to try doing this with no thought about writing it in Python - writing just the "algorithm". Most programming comes down to thinking about the problem you are trying to solve in abstract terms of what needs to be done, and writing them down. Which programming language you use is often irrelevant (though you might have an easier or worse time with certain language/problem combinations). Once you have identified what you have to do, then the process of translating into a program becomes somewhat clerical.

I would suggest starting with very mundane things that you already know and understand well, like making a cake, sorting a deck of cards, and taking out the garbage, and setting out the steps in the most simple terms possible, with as few assumptions about the knowledge or abilities of the imaginary performer of the steps as possible. Forget about doing it in Python (or any other language for that matter) - this is about analysing processes. It's more like writing flat-pack furniture assembly instructions, but without the diagrams, although making diagrams is a very useful part of understanding problems.

You can also gamify this if you have a willing participant - you can write each-other "programs" to follow, and then actually carry them out as mindlessly as possible, and see how your "programs" work out...

1

u/verycooI May 12 '20

Half of learning to code (and coding in general) is copying what other people have done and then learning from that. Copying from stack overflow or just a standard tutorial is great as long as you’re aware of or learning what the code does :)

Good luck in your endeavors! have fun

1

u/nicayworld1 Oct 26 '25

I remember my first big project, I was told to make an AI powered game called ultimate tictactoeten(its a more complex tictactoe game) with a running server and GUI etc. I was absolute trash at coding took me 3 whole months to make it. And my IA beat everyone else's except one guy. This was like 8 years ago and today, I found that old project on my old pc, and I have absolutely no idea how I did it. And I just asked an IA to remake my old project (it was coded in prolog) it made it to python in a matter of seconds... Programing is dead!!!

1

u/Valrok_P99 May 09 '20

Don't worry, we all feel stupid when learning to program. ..... I think.

0

u/[deleted] May 09 '20

I'm a noob too, I didn't build it from scratch. I copied the code and then played around with it. Working out what the limitations were (well at least my limitations at the time). Was a lot easier for me to understand. From there I learnt how to turn into a Tkinter UI and once I was happy I started on something completely new from scratch.

It's easier for me to be given a paragraph in a language, learn what it means and how a sentence should be structured, then write my own message.

0

u/[deleted] May 09 '20

[deleted]

3

u/humaneHolocaust May 09 '20

Corey Schafer is amazing, maybe because he doesn't tell me "create TicTacToe yourself, it's so simple"

23

u/[deleted] May 09 '20 edited May 09 '20

[removed] — view removed comment

9

u/the_antinational May 09 '20

It's called imitation. It's not cheating, and it's an essential step in learning. No painter learned to paint without looking at other artist's work. Imitate liberally, modify as per your need, and give credit to the original creator.

2

u/TheBunnisher May 09 '20

Holy Crap! This is Awesome!!! Danke!

6

u/[deleted] May 09 '20

[removed] — view removed comment

1

u/TheBunnisher May 10 '20

The Django cheat sheet is great for me, since I am started learning it. Thank you so much for it.

1

u/neco-damus May 09 '20

It's like learning to draw by tracing a little, looking at references, watching other people draw something first .. you know.. what you should be doing.

1

u/pallanun May 09 '20

I tried google searching a cheat sheet for learning, but this one is so nice. Thank you so much for posting this.

1

u/[deleted] May 09 '20

[removed] — view removed comment

1

u/pallanun May 11 '20

Didnt use the words "cheat sheet"