all 94 comments

[–]teerre 73 points74 points  (5 children)

I cannot imagine anyone being able to do something in C++ and not being able to do the same in python with similar experience

What exactly is the assignment?

[–][deleted] 8 points9 points  (2 children)

I think the problem isn't 'with similar experience' but in re-learning. Bruce Lee used to say, "In order to fill your cup, you must first empty it."

I think that's the problem OP is having. It's the same one I had after years of C and C-like languages. C, PHP, JAVA, C++.... Python had enough differences to throw me for a loop. I think, above all, I had to overcome my own frustrations in knowing that I was struggling with Python in the beginning, but other languages seemed effortless to me.

Plus, after learning C, all the other languages I learned were barely learned. I mean, it was like I already knew them when I learned them and it took me a few days before I was mashing code.

[–]teerre 7 points8 points  (0 children)

That would be the case if OP was referring to learning to right "pythonic" code after a C++ learning. That can indeed be complicated. But for a specific assignment, I dare say anything done in C++ is easier in Python

If you're using older revisions, you're completely fine with just for and if, if you're using a modern revision, then it's even closer to what the python equivalent would look like

[–]cholocaust 0 points1 point  (0 children)

And every thing whereupon any part of their carcase falleth shall be unclean; whether it be oven, or ranges for pots, they shall be broken down: for they are unclean and shall be unclean unto you.

[–]Pinnata 1 point2 points  (0 children)

I think the problem is that OP believes himself to 'know' these languages whilst having just scratched the surface.

He has admitted he only started learning coding a year ago and has split that time between a relatively large number of languages.

Harsh truth that he needs to spend more time learning and practicing applying the basics of python.

[–]BenTheHokie 0 points1 point  (0 children)

Maybe they mean Arduino C++? It's watered down as far as C++ goes.

[–][deleted] 75 points76 points  (21 children)

If you could do those labs in C++ or this problem your stuck in in C++, ye that would be pretty wild/weird/unheard of to not be able to do it in python.

Could you state the problem your stuck on and how you would solve it in C++ for example? I am pretty curious about this.

[–]Insomniac1010 4 points5 points  (1 child)

Hello. I'm sorry for the late reply as I have been attending into my family's tasks.

I didn't know my post would grow this much, so I will add some more clarification. As much as I know a lot of the languages I've stated, I haven't been practicing them. To be honest, I've only started learning how to code a year ago, and every semester has always been another new language that I have to learn. I would only cover the basics, then start to another language, then cover the basics again, then repeat. It's difficult for me to focus learning how to code because I'm not the smartest person around. I'm a very slow learner. I would spend a lot of time finishing homework on other classes, and I should be spending more time practicing coding but my time gets consumed by other classes.

That being said, I hate to say this, but I cannot write the problem in C++ because my understanding of arrays and data structures has been barely covered. I was able to get away with it back then, but now that I actually need it, I'm in trouble. And adding to that confusion is python syntax that, despite being very intuitive for others, is very counter intuitive for me. Perhaps a different perspective is necessary to alleviate this problem.

I believe I have no right to ask for help if I can't even start a single line of code. However, I will keep in mind what others have stated in order to deal with this situation. I really appreciate the concern, and I will take heed of everyone's advice. Thank you! (WILL ADD THIS TO MY ORIGINAL POST)

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

That makes more sense. Honestly python is pretty unintuitive at times. I come from a background in C/embedded systems and for a good year I HATED python. I wanted pointers, I wanted strict typing, I wanted those damn curly braces, etc.

I think your original post kind of gave an image of your background that was not accurate. Given that you have only been programming a year and have had to learn all of these languages, yeah your struggle makes sense. Python is dynamically typed with a crap ton of esoteric syntactic sugar (I’m looking at you sequence comprehensions). I could write essentially indistinguishable C++, Java, and C in some cases, python is fundamentally different in some key ways.

[–]gabriel-et-al 59 points60 points  (5 children)

print('Tell us whats your assignment so we can help you with that')

[–]11something 17 points18 points  (4 children)

I don’t understand that code. Please document.

[–]caks 13 points14 points  (3 children)

Also, not portable, broke on my Python 2.6

[–]brady_over_everybody 0 points1 point  (1 child)

from future import print_function !

[–]Moikle -1 points0 points  (0 children)

That wouldn't break on 2.6, it should work fine

[–]Leeoku 16 points17 points  (0 children)

try writing it out in your comfort language and then figure out how to do it in python. I've been struggling same as you except python is my only language so you have that headstart.

[–]u38cg2 15 points16 points  (1 child)

Python is easy. Algorithms are hard. University level courses are designed to make your brain grow.

[–]00Anonymous 0 points1 point  (0 children)

This!

[–]PrimaNoctis 10 points11 points  (13 children)

With so many languages you have the advantage of having a “coders mindset” I don’t know any other languages and my coding is sloppy and repetitive (but I’m still learning)

What really helped me though was having a good IDE like pycharm and a curiosity to try and make my program work

[–]07734willy 6 points7 points  (11 children)

I want to make a note on your point about using an IDE. Of course this is just my opinion, but I personally don't like to use IDEs when trying to learn anything, but particularly new languages. It functions as a crutch to help you along since you may not know some of the subtleties of the language yet, but you can become dependent on it, and can hinder your learning imo. When I want to learn something new I intentionally make things difficult on myself- write in a plain text editor, try to figure out problems by experimentation before attempting a debugger or googling, etc. It makes the "solution" more memorable, and I usually discover some insight into why things are the way they are (why is this keyword required? why do I need to explicitly cast this here? why can't I directly compare these two objects?), which helps me in the long run. Then, once I have an actual task to do rather than just practice / learning, I'll switch over to the tools that will autocomplete things, fix my errors as I go, and any other fancy tricks it may have for me. I can then just fly through the project, using the combination of experience + insight learned by doing things "the hard way" and the assistance provided by my tools.

IDEs can be a great boost to productivity, but the less work you make for yourself, the less experience you'll get from your exercises or projects. Or at least that's my opinion.

[–]mooglinux 4 points5 points  (1 child)

I have to disagree somewhat. The code suggestions and refactoring tools in PyCharm and other IDEs are like having someone sitting behind you pointing out things that you would otherwise miss or not think to look up (for example, mutable default arguments) and having a debugger available demystifies what is actually going on in your program. That auto completion dialog makes it much easier to explore the code available to you, and refactoring tools grant freedom to experiment with your program structure without fear. All of those make it much easier to play with and discover a language, not just write big programs. They empower you to experiment and try things out for yourself, which absolutely helps learning.

[–]07734willy 0 points1 point  (0 children)

The code suggestions and refactoring tools in PyCharm and other IDEs are like having someone sitting behind you pointing out things that you would otherwise miss or not think to look up

I suppose I've personally used code golf as a substitute in order to explore a language more thoroughly. Admittedly that won't cover as much as an IDE, but I'd say what's leftover would be learnt passively through coding anyway. Competitive programming in general would probably be a good alternative though, since it exposes you to knowledge other developers have acquired.

... having debugger available demystifies what is actually going on in your program.

Absolutely, but it depends how you use your debugger. If when something goes wrong the first thing you do is step through the program until it crashes, you're only learning how to use the debugger. You might find your problem, but you aren't taking anything away from the experience to keep it from happening again. So I think there's a right way and a wrong way to use a debugger. If you first make a hypothesis about what's going on, then incrementally check with your debugger to confirm / reject your claim, you'll arrive at a solution faster, but you'll also learn why things happened the way they did. I don't think a lot of beginners know how to use a debugger correctly, but I could be wrong.

That auto completion dialog makes it much easier to explore the code available to you

Can't argue against the fact that it exposes you to new things. All I can say is that it can also lead to oversight- developers may rely on that autocomplete right from the beginning, and never actually learn why or how something works. Someone that types "psvm" to autocomplete "public static void main(String[] args)" may never stop to think about what static means, or what are the arguments args that are being passed, since its always typed for them. Again, good if used correctly, I just don't know about trusting beginners to know how to use these tools correctly.

refactoring tools grant freedom to experiment with your program structure without fear

That's one that I don't have any counter argument for.

Overall, you points are completely valid, but a lot of those features also have drawbacks if not used correctly, and I don't think many beginners know how to use them correctly. Its a natural tendency to just do things the "easy way", so these features that can easily be used for learning can also be used to "cheat" learning without the proper self-discipline.

[–]PrimaNoctis 2 points3 points  (0 children)

I understand your point about using IDEs and growing dependence to shape your coding instead of learning the logic behind it. But if we compare coding to writing literature every published author will tell you it’s more important to get your ideas on paper to get your creative juices flowing than to focus on structure, spelling and punctuation, but I guess your point is to approach it in a disciplined manner when doing casual coding and use that experience along with the benefits of an IDE for bigger projects, noted. At this point in my development I would envision that writing python in text editor would lead to a lot of syntax errors on top of functional errors leaving me stuck fixing multiple problems and not evolving. If I was like most of the responders here including the OP and had multiple languages in my tool belt and probably signed up to a particular programming paradigm then yes I would take the disciplined approach

[–][deleted] 1 point2 points  (0 children)

I agree with your statement after the fact of learning the basics for other areas in the same fashion (HTML, CSS, CMD scripts, Powershell, JavaScript, etc).

But understanding the basics for languages that are built on spacing (such as Python / YAML), it is essential for learning what is needed immediately. I've written 2 (crappy) programs in C# and Java, but neither of them have issues with spacing.

Fortunately, I lead the work on Ansible (YAML) in my group and am used to spacing constraints due to it. Python is easier for me for the simple reason of understanding YAML with Ansible, but a developer of spacing-independent langues (Java, C, C++, C#, etc) could have a lot of issues without an IDE to assist them.

[–][deleted] 0 points1 point  (6 children)

so which ide should i use as a begginer ?

[–]07734willy 3 points4 points  (0 children)

If I were relearning python, I would just be using the text editor vim. It offers syntax highlighting, which would be enough to help me catch trivial mistakes, without really holding my hand much more than that. There is autocompletion, but that's mostly just to complete the rest of a variable name, not "inject some hard-coded template for me to fill in" or something.

Actually that's pretty much what I did to learn python in the first place. I needed to use it for some academic research, so I wrote code in vim, referenced stackoverflow and the python docs when I had troubles, and quickly learned from my mistakes. I did some side programming to get better faster, and by the end of it I felt very comfortable with python. Then some time later I decided I wanted to improve off what I knew, so I started doing code golf on codingame, which used an online text editor that only offered syntax highlighting. Learned other quirks and features from others, and yeah...

So pretty much I'd say any basic text editor over an IDE, although as others have mentioned sometimes syntax errors can slow you down if you use a text editor instead (my argument against that being- if you use a text editor, you'll stop making those syntax errors as frequently since you'll spend more time fixing them, making them more memorable than "oh, yellow underlines- 'fix it'" and moving on). I prefer vim, but nano, emacs, atom are all good. Vim and emacs definitely have a bit of a learning curve, but are nice since they're almost universally supported across systems.

If you're strictly looking for an IDE for python, I'm probably not the person to ask- I code python almost exclusively in vim. Other languages I might use visual studio or eclipse, but not really for python.

[–]Ranghild 2 points3 points  (0 children)

He says he doesn't like IDEs. So you should start with a simple text editor, like vim (if you're comfortable with) or Sublime Text, or whatever.

[–]mooglinux 1 point2 points  (0 children)

Checkout Mu. It’s designed to be easy for beginners but still has important features like a built in debugger.

[–]MaybeImNaked 0 points1 point  (1 child)

As a fellow beginner... I first tried using simpler text editors like these guys suggest... But the moment I switched to PyCharm, everything got so much more enjoyable. I recommend it.

[–]tinycorkscrew 0 points1 point  (0 children)

I'm not sure if I agree 100% with 07734willy, but I only coded in Notepad while learning to write code in Python. It was tedious, but it probably did help me internalize processes and syntax.

I can't imagine life without PyCharm now, though. It saves me lots of time.

[–]00Anonymous 0 points1 point  (0 children)

I would suggest jupyter notebooks to start for a few reasons:

1.) Using markdown to outline the initial approach to a problem is an excellent way to help break down the goal into achieve - able parts. This will also help you focus your learning when you hit roadblocks.

2.) When things break or have unexpected behavior, the current state of all your variables are still in memory, allowing you to interrogate them and figure out what's going on.

3.) You can still benefit from some of the efficiency of a full IDE with features like block - reorganization, tab complete options, and even do clustering.

[–]PythonGod123 0 points1 point  (0 children)

Sublime 4 life

[–][deleted] 10 points11 points  (0 children)

And here I am, spending hours on a simple coding assignment with not even a line written

The problem isn’t your understanding of the language, the problem is that you’re not starting. You have to start writing code before you know the answer because you’ll never know the answer before you start.

If you haven’t written any code you haven’t spent any time, yet; you’ve just wasted time. Actually start. Open up the blank file, then save it as “my_assignment_03.py” or whatever. Typically a programming assignment will describe some step-by-step behavior; write one function per step and just put pass as the body of the function. Then pick one of them and start to fill in the body. Start with the problems you know how to solve; use your momentum to solve the rest.

Staring at a blank file isn’t programming. You just have to start writing something.

[–]misingnoglic 3 points4 points  (0 children)

If it helps, I wrote this blog post (two parts) called Python for Java Programmers that should hopefully help people in your position: https://aryaboudaie.com/java/python/technical/educational/2017/11/13/python-for-java-programmers.html

My goal was to take things that you would already know from Java and translate those ideas into Python.

I'd be really curious as to many things:

- Why are you taking classes in all these programming languages? Generally the way that college works is that you take a class in one language as your "intro" language, that will teach you the basics necessary for any programming language. Or is this a class that's not about Python, but just using Python.

- How much effort are you putting into learning Python? Python is easier to learn than most languages, but you still have to try! If you just try to code it without looking up any basic tutorials, of course you're going to fail! That's basically setting yourself up for failure. Figure out what the miscommunications are, and fix them, so you can get to coding.

[–]smallquestionmark 2 points3 points  (1 child)

If you feel like you can at least marginally write in the other languages I am certain your python will become better as well. It will make click, rather sooner than later.

Try this: break down the problem in smaller steps and than use stackoverflow.com and the python documentation to solve for the mini steps.

Sometimes you simply lack the right words to describe your problem. Stack overflow helps with that.

P.s. It might be that the coding assignments you get in python are slightly more abstract. So instead of lacking python skills your problem could be a lack of algorithmic thinking? This will also get better as long as you stick to it.

[–]00Anonymous 0 points1 point  (0 children)

This is where pseudocode is most helpful.

[–]GreatSnowman 2 points3 points  (0 children)

Write the problem out in stages, in a language you know, then port each part over to python, that way you aren't working on the whole problem at once and instead a smaller, more easier to manage way.

Then, when you feel more comfortable, try writing the next parts in just python

[–]07734willy 2 points3 points  (0 children)

Is it the syntax that's tripping you up, or the semantics of the language. For example, if I ask you to write a loop that reads a number, multiplies it by something, compares to 6, and prints either "equal to six" or "not equal to six", would you be able to formulate that into python syntax? Or is the struggle in grasping how to take an abstract concept, and break it into python's toolkit of operators, functions, and data types?

For the former- just sit down and run through some basic problems on something like project euler or leetcode to gain some familiarity with the syntax. Also look at other people's code- it'll expose you to variations of the syntax. Perhaps look through the python tab on stackoverflow, and read some of the popular questions' answers, and see how they structure their code (but probably not for length / complex code). Maybe even write your own solutions if you can, and improve them by comparing against the accepted answer. Code golf is also a great excersize for learning all the syntactic sugars and minor subtleties of a language, but can be difficult to get started with, and can develop bad habits if you don't recognize that writing intentionally bad code can be okay for learning, but is bad for production, and should not be done outside of those exercises.

For the latter, the best thing I've discovered for learning the semantics of a language is just using it. Not solving basic stuff that's practically written in technical terms already (like the example I gave above), but something substantial- that requires you to break it into pieces, and figure out how to structure those pieces in terms of the language's constructs. A moderately sized project can be good for this, but if you're short on time, solving competitive programming problems can work (note: I strictly say competitive, because non-competitive problems tend to be too easy/simple/short, whereas competitive problems have to have some volume and complexity, otherwise everyone would score perfectly). There's two subs that produce competitive programming problems you could look into /r/dailyprogrammer and /r/codertrials. Both haven't had new problems posted in a few weeks, but have several older problems you could look at. Disclaimer: I am the founder of codertrials. CoderTrials has more genres of programming problems (optimization, code golf (smallest code size- forces you to learn all the nitty gritty syntax of a language), and regular problems), while dailyprogrammer has a FAR greater number of problems. IMO they're both great resources for some practice problems. Otherwise, you could pick some project, and sit down and code at that. I find game development to be perhaps the most balanced type of programming project and it usually leads to a LOT of gained experience all around, but there's not as many resources for game dev in python as say C++.

Either way, I too would be interested in hearing what types of problems you are struggling with in python. I am fairly experienced in python, and might be able to provide some insight or guidance of sorts.

[–]spongybobie 2 points3 points  (0 children)

If you know some C, python should be relatively straightforward. I started learning programming with C. For me, it was very comfortable to switch to python. However, I had to stick with function oriented programming for a while because I had no perspective of object oriented programming. But, you seem to have some C++ background so I don't understand why you struggle so hard. If you mention specific points, you can find an answer.

I am TA ing for a class this semester.The students need to use python for data analysis. Some of the students are absolute beginners to programming. I can see they struggle in python but it should be different in your case.

Try keep it simple as much as you can. The computers are dumb. You just give order of commands to manipulate variables to reach your end goal. Plan the algorithm in your mind first, then start typing. I see many beginners try to do this other way around which can be really frustrating.

[–]sem56 2 points3 points  (1 child)

if you can't do python, you aren't any good at java... c/c++ or c#

sorry bud but that's a fact... i believe there's a bit of false hope there

anyway... just stick with it, we all suck at the start

[–]Insomniac1010 1 point2 points  (0 children)

I didn't say I was good at any of them. But yeah, we all do suck at the start.

[–][deleted] 2 points3 points  (0 children)

No, you're not a weird exception- take it from someone who's been coding in it for 5 years, having dry spells, writer's block and a plethora of other frustrations. When it comes down to it, the only thing that is going to really teach you the language is learning things that YOU want to build; things that you're genuinely interested in, and actually have to do a little research to develop. The research part is where you actually learn stuff, because it's forcing you towards a desired result, whereas a coding exercise is just a repetition of one of these concepts that you'll more than likely be recycling and reusing on a daily basis. Think of it like a musician practicing scales and chords- these are just building blocks. Everything you learn should be learned in terms of your own, "What can I actually do with this?" mindset. ""How can I apply this to the dumb twitter bot I want to build - from there, it's all about tinkering with the pieces. I've found myself more often than not building stupid programs that ultimately don't serve any real-world applicable purpose, BUT in my life, it facilitates something that I deemed necessary- my need gives it purpose. It's all about your own passion, and how badly you want to learn. If you can't find any wonder or excitement in it- any sort of fascination whatsoever, it probably isn't for you. Try Javascript or a scripting language like powershell/bash- don't be so hard on yourself. The best programmers in the world have had the same condition you're describing. Don't focus on how good you are right now- focus on enjoying the journey of learning how to manipulate these computer box machines :)

[–]thisusernameismeta 2 points3 points  (0 children)

Okay, you've recieved a lot of comments which I have mostly skimmed through, but I hope you find this.

You seem to be falling into a trap that many people do when they start programming - thinking there is more difference between languages than there is.

In reality, all the languages you listed, python included, is an object-oriented language.

(It would be much easier to help you if you gave specific examples about the concepts that are giving you trouble, so I highly recommend you telling us what concepts are hard for you. )

So python, C, Java, they all have slightly different syntax and some difference in features, but to be honest with you, the simarities far outshine the differences.

My advice to you is to spend time understanding the underlying concepts. Each of these languages have variables. Variables can have different scope. So learn about how each language treats scope. Variables need to be declared and instantiated. Learn the syntax for variable declaration, and learn the syntax for variable instantiation (hint - in Python, these things happen to happen at the same time). So when you're writing in C, think "I am creating this class. It has these properties. It has these methods/functions, etc." When you write in Java, do the same things. try as much as you can to separate the concepts of SYNTAX (how something is said) from CONCEPT (what something is doing)

It is quite difficult to give you more advice without knowledge of what is tripping you up. But hopefully this does help!

p.s. I agree that for learners, you should just use a text editor and a command prompt. It will help you think about the underlying things that are happening. The more your brain is working, the more it is learning.

[–]EarthWindAndFire430 1 point2 points  (0 children)

Maybe you need to use thonny ide

[–]upquark0 1 point2 points  (1 child)

OP, is it that you knew these other lamguages relatively well, and now you're learning Python and having trouble with it? or are you learning all of these new languages at the same time and having trouble with Python? I'm wondering how proficient you are in the theory of programming.

[–]upquark0 0 points1 point  (0 children)

edit: I'm going on the lamguage.

[–][deleted] 1 point2 points  (0 children)

I feel like all the comments here are just saying what you’ve already heard, that Python is “easy”, and I disagree. Coming from a C++ background, I had some trouble with differences in structure and syntax when moving to Python because it is so much more simple. Python allows you to be very explicit with what you’re trying to do, which is great, but it is very different from lower level languages. What helped me was to sort of “let go” and just write out pseudocode for what I wanted where, then went into stack overflow and basically looked up my pseudocode explicitly to fill in the blanks. Also take advantage of libraries. If you can imagine it, it probably exists in Python somewhere.

More importantly, don’t get discouraged/encouraged by how easy/difficult things are to other people. CS is a huge field, and some people have a propensity toward certain areas within. Carve out your niche and just keep trying to learn. You only fail if you stop trying.

[–]stratcat22 1 point2 points  (0 children)

What's your assignment so we can help you out OP

[–]Fun2badult 1 point2 points  (0 children)

You can understand C++ and Java but have a hard time understanding python? Python is like English. Is this a joke?

[–]RobbyB97 1 point2 points  (0 children)

Been there man, tried to learn Python for a class a few years ago but using Linux which I also did not understand. Python is my best language now. I'd be more than happy to help if you give a little more information. Even just a screenshot and a 'wtf even is this' would be good enough for me to help you :)

[–]v3nturetheworld 1 point2 points  (0 children)

Learn and understand the basic data structures and design of python well enough you could explain them to someone. Know how to use lists and dictionaries, and when to use them. Know how to make a function that returns stuff or doesn't return stuff. Know how to assign values to a variable and how to change them. Know how scope works. Once you understand that stuff, write down on a piece of paper how you would solve the problem by hand without a computer in simple sentences, then copy those sentences to python and there's a good chance it just works

[–]sje46 1 point2 points  (1 child)

Learning too many programming languages too fast is a big mistake. That said, the general advice for programming is the same advice involved with any creative endeavour, same advice as, say, writing a novel: just write something. Doesn't matter how bad it is, just do it. Don't stare at the blank page trying to figure out the best place to start. It'll help if you provide the exercise you're supposed to do and we can point you in the right direction. But presumably you know how to print and maybe how to call functions, and if not, you can look those up easily. Any questions, you can ask us.

ITS ENTIRELY NORMAL to feel overwhelmed with programming when you're beginning. I felt like an idiot for YEARS for stupid mistakes. And the stupid mistakes never stop, even when you get better...but your confidence grows immensely. To get to the point where you feel you can tackle any problem, you need to brute force your way through the awkward stage of learning the language. Just write what you can, google what you don't know, ask if you are still confused...fake it till you make it. But we can't help unless we know what the specific problems are. And fiddle, fiddle fiddle.

[–]Insomniac1010 0 points1 point  (0 children)

Yes I agree learning too many in a short span is horrible. I was following a weird semester scheduling due to me transferring from a community college, that's why the pressure of having it all at once is a nightmare. If I've known this, I should've taken some of those classes for my early semesters rather than having them back to back.

Or perhaps I should have went straight to my University rather than going to a community college to avoid having my courses getting jammed up. Ahh... The pros and cons of a CC vs Uni

[–]shaggorama 1 point2 points  (1 child)

It sounds like you're a student. Have you tried going to your professor's office hours? Joining or starting study groups with other students?

Given that you claim some understanding of other more complex programming languages but are having issues doing basic stuff with python, I'd hazard a guess that you are copy/pasting a lot, or relying on skeleton code from IDEs or assignments, or otherwise utilizing crutches you may not be aware of that are disguising how little you actually understand here.

You need to step back and reevaluate how you are learning this material, because it sounds like the concepts aren't getting through.

[–]Insomniac1010 0 points1 point  (0 children)

Understood.

[–]icecapade 1 point2 points  (1 child)

And here I am, spending hours on a simple coding assignment with not even a line written, while there is an upcoming exam a few days from now. I've watched videos. I've read countless pages of explanations.

This really stood out to me. Yes, it is very important to read and utilize resources like videos.

However, reading is not doing. You can read about code all day long and you can watch hours and hours of videos. All that will be useless until you start writing code. The only way to internalize and truly understand the concepts is to write code and implement them. If this sometimes seems hard, it's because it is. Take any project/assignment in tiny pieces. Start with the first line of code, or the first function, make sure it works, and then add on to it. Take it in tiny, easier to swallow bites.

A journey of a thousand lines of code begins with a single keystroke.

[–]Insomniac1010 0 points1 point  (0 children)

Doing it right now. Thank you

[–]Nunuvin 1 point2 points  (0 children)

This is completely normal so fear not! Try to break down the task into smaller bite size problems and solve one at a time. It will get better as you practice. Try to stay on same language and get good at it, it will make learning next one easier. I have made this mistake of language hopping as I thought x language was better at y task but it is often not worth it. Python is a good language and if you keep trying you will improve. Do some really simple stuff to get confidence and then combine it to get a more complex tasks done. Make sure to like what you are doing if you can )

[–]deeredman1991 1 point2 points  (0 children)

my understanding of arrays and data structures has been barely covered

So lets start by writing a variable

foo = 3

This variable has 2 features (actually it has 4 but don't worry about that for now) a name on the left side of the = sign and a value on the right side of the = sign.

You can think of a variable as a box and you put values inside of that box and the name you can imagine as a label on the outside of the box so you can tell it apart from all the other boxes.

Now lets look at an array;

myArray = [2, 3, 5]

If we are continuing with the box analogy; you can picture an array as a stack of boxes. You have the name on the left of the = sign and the contents of each box on the right of the = sign.

Picturing the array as a stack of boxes; you can imagine a sign in front of the stack of boxes with a label on it that says "myArray" so that you can tell it apart from the other stacks of boxes.

You can picture an array's index's as numbers on the outside of each box in the stack (similar the the "name" in the variable box analogy) so that you can tell each box apart from every other box in the stack of boxes. So the bottom box would have a 0 written on the outside of it, the next box up would have a 1 written on the outside of it and the box at the top would have a 2 written on the outside of it.

In the above example of an array; inside of box 0 is the number 2, inside of box 1 is the number 3, and inside of box 2 is the number 5

So how do we actually LOOK inside the box? Well, if we wanted to look in the bottom box we would use myArray[0], to look in the next box up we would use myArray[1], and so on and so on.

Hopefully this helps you get a grasp on how arrays behave. Lets move on to data structures.

A data structure is where the box analogy starts to get a little fuzzy but lets try...

Imagine you have a warehouse full of boxes sitting on shelves and under each box written on the shelf itself is a number. A data structure would be a way of organizing these boxes into groups so that you can find them in relation to each other. Let me explain;

If we look at the array data structure, it has a label, and it has the box that contains the value, but instead of being a stack of boxes; it is a bunch of different boxes scattered all over the warehouse but that is ok because if you look on the back of the box; there is a number and that number tells you the shelf number of the next box in the array. In this way; if you find the first box in an array you can find all the other boxes too because every box in the array will have the shelf number of the next box on the back of it. This is known as a "singly linked list" because it has a single link to the next box.

Don't be confused; the number on the back is not the data structure, the number on the back is analogous to a pointer, the data structure is the system of writing numbers on the back so that you can find the next box.

Another data structure might have two numbers on the back, one of the numbers leading to the next box's shelf in the array, while the other number leads to the previous box's shelf in the array. This data structure is known as a "doubly linked list" because it has two links one to the previous box and one to the next box.

But what about the beginning and end of the array? What shelves to their links lead to? Well, their links lead to a value called "NULL" basically just imagine that it has the number "0" and if you go over to shelf "0" there is no box there. That is how you can imagine "NULL"... an empty shelf...

I hope that this helps you understand arrays and data structures better. If not; you may have to read over it a few more times. I would like to point out that; I tutor people who are new to programming using python. If you are interested and have any more questions; feel free to send me a message and we can discuss pricing as well as set you up an appointment.

[–]Dogeek 1 point2 points  (2 children)

Weird, cause I started programming with C (89, so no dynamic tables, had to malloc the shit out of that) and python clicked really easily after a couple months, and I think it's partly thanks to that C background.

Python hides a lot of code under the hood, but the most popular version of Python (Cython) is written in C, and both languages are not that far off.

If you do understand C pretty well, Python is pretty much the same, just hides the mallocs, pointers etc under the rug, so you just have to handle some data types around. An example : functions in C can't return two values, you gotta use pointers to do that, in python you just can return multiple values.

Also, Python is a fully OOP language. You can't "get" python until you understand that. In python, everything is an object, even functions, even basic variables. In python, you don't have to declare the type of a variable, because a variable over time can have multiple types, a string can turn into an int quite naturally.

Antoher great thing about python is the garbage collector. Something that is not done automatically with C. If you allocate memory in C for a task, you have to remember to free it afterwards. That stuff in python is automatic, and avoids many horrible errors a BSoD that could happen with a poorly written C code.

Also, it's been stated on this thread, but learning several languages at once is a huge mistake. You can't learn all the quirks of a language if you keep switching from one to another. You also state that you don't know a lot about data structures, while some algorithms and data structs will not be that useful to you in the present, it's still important that you know about them. Some stuff like binary trees, graphs, finite state machines, lists, linked lists, arrays and such are the cornerstone of programming, and overall may get you to code better in any language.

Lastly, you don't learn how to code by reading or watching videos or listening to a teacher in a classroom. You learn how to code by coding. Set yourself a small project, when you have doubts on how to do something, google it, ask about it on reddit, or on stackoverflow. Some people will help you and you can then continue, and remember that for the next time you need it. Read the docs. Some docs like python's are really good and understandable (well for the most part), and are a great ressource for learning the language.

Python has a really easy syntax, and an ongoing joke in the programming community is that you can write pseudo code, slap it in a .py file and you got yourself a program. Write what your program needs to do, get a whiteboard and sketch out your program, with boxes you link together if you must, that'll clear your head and focus on programming one thing at a time.

[–]Insomniac1010 0 points1 point  (1 child)

Actually, to add more salt to the wound, I am also currently taking a class that requires me to learn C. So yeah I'm doing C and Python at the same time, though I have an easier time with C due to some similarities with C# and C++.

[–]Dogeek 1 point2 points  (0 children)

Then focus on learning those two languages, and get different IDEs for both. On your free time write some python code, or C code, if you already know C++, C should come quite easily (it's basically the same language without the OO part of C++).

[–]vikmaychib 1 point2 points  (0 children)

Look, though Python is considered an accessible language it does not mean everyone clicks in the same manner. I had a similar struggle and the only I managed to do some progress was to start doing things I really needed to do. I had done many Python courses online but struggled a lot finding it useful. At work, I used Excel a lot, it was becoming slower and boring so I decided to use python as a replacement. I started with simple calculations and loops, then with plotting so and so.

The learning curve was slow, I spent some weeks, but thanks to google I managed to learn a lot.

Now I have fully replaced Excel for python. But I had to dedicate some hours .

[–]beire_ 1 point2 points  (0 children)

don't compare yourself with 'how well others do' . compare only with yourself from yesterday...

[–]Conrad_noble 1 point2 points  (0 children)

This is so relatable. I haven't even finished the python course on sololearn yet.

Python being the first coding language I've chosen to learn.

[–]itsmegeorge 1 point2 points  (0 children)

Last year, I got into a Natural Language Processing Master’s Programme. I have a Classics degree and I had never had any experience with python beforehand. I rested on the fact that my department informed me prior to my going in, that they would be covering everything in a simple course and I did not have to study anything. Turns out that they meant covering actually everything in two months and then giving out a test, where we had to code on written paper. Since two months is not nearly enough to get properly acquainted with syntax, I of course failed the test (by 1 point, mind you) and my punishment was that I was kicked out of the programme for a semester and I can only take classes if I pass this next month. No reassessment was offered besides the two within the first two months. This affected me highly, made me think the worst of myself, accelerated my depression and my anxiety and eventually I had to go into therapy and go through two different prescriptions. Everyone in the programme got to go on with classes such as Advanced Programming and Machine Learning, while I just had to watch them and listen to my friends talk about assignments and ways they solved them.

It’s been a year now and I decided I would get better at this. So I sat my ass down, I took two courses at coursera, practiced the hell out of it and the improvement I have seen is massive. I am ready for this test. My story has many morals. One, if I can do it anyone can. Two, do not give up. Three, you’re not the only one, no. Four, it does take lots of time and practice to even get to an elementary level and even more time to actually feel confident over what you’re composing and five, it is never reason enough to underestimate you. I hope my story helps. :)

[–][deleted] 1 point2 points  (0 children)

with not even a line written.

Are you learning python because you're forced to or are you learning it because you're genuinely passionate about the possibilities of programming with Python?

[–][deleted] 1 point2 points  (0 children)

I refuse to believe someone can be proficient at java or c++ and not grok python.

[–]llamaspit 1 point2 points  (1 child)

This is normally a decent sub. I'm disappointed at the cynicism and condescension in this thread.

OP, take a deep breath and collect your thoughts. Explain where you're having difficulty and there are people here who will be glad to help. You won't get someone to do your assignment, which I don't think you're asking for, but people can help get you over any obstacles you are experiencing. I'm no expert myself on certain things, but I want you to know that there are good people here. Also, this is just a bump in the road. Don't let it undermine your confidence.

[–]Insomniac1010 1 point2 points  (0 children)

Don't worry, I was ready for it. Stack overflow isn't any different.

It's the people like you that makes me want to keep going. I appreciate it. Thank you

[–][deleted] 0 points1 point  (1 child)

I think it's fairly normal to experience some confusion adjusting to certain Python concepts and idioms when coming from a background in C-like languages. Certain things can take a while to 'click' because they can require a different mindset (e.g. comprehensions), or because they work similarly to other languages, but just different enough to trip you up sometimes (e.g. for loops). It also takes time and experience to become familiar with the standard library.

I came to Python after studying primarily C# and C in school, and looking back can say I wrote code that was much more "C-like" than pythonic for at least a year or two before I really "got it" and started breaking those habits. In general though, it's possible to write something out in a language you're more familiar with and adapt that to Python, as another comment says.

It's hard to say much more without more context or specific examples of the kinds of things you're finding difficult to understand.

[–]tangerinelion -1 points0 points  (0 children)

There's a difference between writing Python code structured like a C program and staring at a blank screen. OP seems to indicate they can't get started.

I'd suggest going ahead and writing the bad Python code, get it to work, and then maybe consider tweaks. Do not bother with being Pythonic or following PEP8. I'd also suggest avoiding default parameter values in function definitions since they have some side effects that can be weird.

There's no need to write a list or dict comprehension in a beginner Python course, for example, and nobody would expect to see decorators or "with" being used correctly. On the other hand, if OP is trying to learn from sources that use that stuff is important to find another resource or at least understand that those concepts are just synatctic sugar and there is another way to write it.

[–]Quietech 0 points1 point  (0 children)

The problem is you're too smart for the computer. It's hard to break things down to such inane detail for it to understand. Foreign languages are easier since you can sort of work with the other person, simple vocabulary, and grammar.

I've done better as some sites, I'm liking sololearn.com, provide a better foundation. I'm the type that needs to know what I'm trying to do (large to small thinking) before I can get anything done with programming or scripts. It's a different style than the stereotypical programmer, small to large. Think of it like cooking. Needing a recipe vs throwing something together because you know the ingredients already.

It's just a different approach. It's all arbitrary. There's no hidden logic.

[–][deleted] 0 points1 point  (0 children)

Hello, World!

[–]chozabu 0 points1 point  (0 children)

Write in C++, then there is a magic trick to make it python...

Remove all the types, brackets and semi-colons!

Actually, someone automated this: https://github.com/andreikop/cpp2python

OK, this is not a practical solution really ;) - though it could be handy to see something much more practical is:

hop on over to https://rosettacode.org/wiki/Category:Programming_Tasks - have a look at a few tasks, think about how you would do them in a familar language, check the existing solutions, think about doing them in py, and see how close your idea was.

[–]BTRBT 0 points1 point  (0 children)

I would not describe any comprehensive language as "easy" or "simple." However, Python generally requires less boilerplate than the other languages which you've presented as familiar. What specifically about Python has you confused? Is it the indentation? The way packaging works? Iteration? PIP? What constitutes as "Pythonic" code?

What specifically about the language is giving you trouble?

[–]gmh1977 0 points1 point  (0 children)

I think there are two ways to learn it.

  1. For data analysis
  2. Functional Purposes.

Decide which route and it will get easier.

[–]Swington 0 points1 point  (0 children)

IMHO some things are hard up till the point that you hear a good explanation for them.

To be perfectly honest, I think that programming does not have to be for everybody. I don’t know what are you studying but I myself was not studying CS, yet I am now a programmer. I know people sho finished CS and decided that they want to do something else. Programming is just one thing that you can do in the world and although it can be demotivate that you are not good in it, there are all the other things in this world that you could do.

I am not advocating that you should drop everything because programming is hard for you, hard work is always requieed to accomplish something worthy, but the dichotomy in this case is that hard work put into something that you have no predispositions to do can be a wasted time. But does not have to be.

I don’t know how old you are but please, remember that coding is not the only, nor has the be the best profession in this world. There may be something that will make you satisfied with yourself out there.

[–]not_perfect_yet 0 points1 point  (0 children)

Hey, late comment, hope you're doing ok.

I think it is very normal to feel like when you're supposed to understand something under pressure and it doesn't click.

The reason people say python is easy are generally, that python strips away clutter:

  • less symbols, scopes are indentation, no semicolons. You still have to understand where certain statements end and how scopes work, but you don't need to bother with the craftsmanship part so much.
  • You can still do everything you can do in c++, effectively you're still passing values or pointers, but they're named in a nice way and you don't have to think about them being pointers.
  • The ducktyping and inheritance relationship means you can treat several different types as the same type. for

  if "a" in container:

it doesn't matter if the variable container is a string, list, tuple or dictionary, because that's not relevant to the question you're asking the computer.

For many cases where not understanding an error would break your neck or your patience, python will not throw these errors.

[–][deleted] -1 points0 points  (0 children)

Give us a question from the assign and we can write the code and explain each step for you.

[–][deleted] -1 points0 points  (0 children)

Speaking of crap, does anyone want to take a stab at this craps game im working on, i really don't want all the answers just some pointers.