• Welcome to Autism Forums, a friendly forum to discuss Aspergers Syndrome, Autism, High Functioning Autism and related conditions.

    Your voice is missing! You will need to register to get access to the following site features:
    • Reply to discussions and create your own threads.
    • Our modern chat room. No add-ons or extensions required, just login and start chatting!
    • Private Member only forums for more serious discussions that you may wish to not have guests or search engines access to.
    • Your very own blog. Write about anything you like on your own individual blog.

    We hope to see you as a part of our community soon! Please also check us out @ https://www.twitter.com/aspiescentral

Help with Python

On of the things I loved so much about coding, was being able to play with an example, to find out just what was inside that black box. Make lots of mistakes! It's just a little bit of code, unlikely to cause damage (beyond some very specific stuff), safe to try anything out, however stupid seeming, you'll often learn at least something, even if it's not to do that particular thing again! ;)
Mistakes teach you ten times more than getting it right first time. They force you to start going through the code bit by bit, to work out where the fault is. You start to realise where you haven't yet fully understood how it's working.
 
Mistakes teach you ten times more than getting it right first time. They force you to start going through the code bit by bit, to work out where the fault is. You start to realise where you haven't yet fully understood how it's working.
I completely agree

I do not know if the app has mistakes or does things to teach you but some of the examples it gives are not written correctly (they have errors). A fun thing I've done using the app is figuring out where the error is and running the code until it's correct, scrutinizing everything and not turning to bing right away.

As you say, that's how you truly learn, by trying a million times and researching and not asking for help until all your resources have been spent.
 
Recently I've had to pick up Powershell for work. It's not really much of an application language, but it's fantastic for admin of hundreds of account and suchlike, and for a Microsoft product, a huge step forward from cmd.exe
But one of the things I liked about it so much, is it holds many of the tools you need to examine what's going on in there, built into it. It's object based, so you can run a command and load the returned data into a variable, then you can interrogate it as to it's type/class, it's contents, the data, and their types, what properties and methods it has, and so on. As you pick up more of it, it gives you more and more power to work out what's happening and how to best exploit it.
Finally a shell and scripting tool that has something of the power of Unix/Linux distros. Only took them a few decades or so! :laughing:
Pythons a fine language to learn, lots of uses, very popular so lots of support, lots of packages, good object oriented methodologies. It's popularity in science and other serious subjects bodes well for it too. Personally I've barely used it, and that was so long ago, I can't remember it - the vocabulary, syntax, etc, but mostly I've had to focus on tools appropriate for whatever job I've been doing at the time, often fixed by whatever has been used so far in a system.
 
Pythons a fine language to learn, lots of uses, very popular so lots of support, lots of packages, good object oriented methodologies
This is true, it's also very beginner friendly.

I decided to start with python because of this, actually, but am planning into moving to other languages as time goes by. I don't want to just stop at python! Want to learn as much as I can for as long as I live. Who knows? Maybe I''ll become a master l33t h4xx0r :tearsofjoy:
 
Being a good coder, can actually be a pretty minor part of being a hacker. The one's who actually make the tools, and come up with the more sophisticated malware, are very good low level coders, but I believe t's not a major part of the game.
Personally I got more from making some obscure or tricky bit of code work, sometimes just for my own satisfaction, than I really was attracted to damaging other peoples stuff. The idea can be exciting, especially the better stories, but in the end, unless you turn to white hatting (a very worthy pursuit), hacking often ends up to do with doing someone a disservice (I don't mean to say you would do that!).

The language I loved most of all, and the one I really started on (not counting basic on Sinclair zx81! :D) is C.
Which is synonymous with Unix. Such a beautifully terse language. And so low level, hitting memory directly, running bios and dos functions embedded in the motherboard, compiling the most compact and fast code you could get, unless resorting to assembly language. Problem with it was when windows became popular, it took a huge amount of coding just to get a blank window on the screen, development was so slow, so Visual Basic started taking over (in my area anyway). And C++ took over from it in many places.

But oh! The lovely things I'd do in C. If you wanted strings, you had to reserve some memory for it, store the address, create a pointer variable to hold that, etc etc. No declaring a string and just using it! Call a function and pass a complex data structure? - you had to find it's location in memory, pass that as a parameter, so the function could locate it, and diddle about with the contents. Such fine and precise control over everything.
Linked lists, binary trees, recursive functions, having to learn different sorting algorithms (because they don't come built in). You could even find the memory address where a function you've written is located, and store it in an array, with a bunch of other function addresses, and then come up with a clever algorithm to select which one to use for a specific situation - a dynamic 'flow chart' that can alter itself! And you also had to worry about every little byte you used. If you reserved some memory, you had to make sure you freed it up at the right point, or it got lost from the program, which could just start eating all the memory up by not releasing back to be reused, until the pc crashed - out of memory!

Er, is anyone still there? Hellooo! Where you all gone? :oops:
 
But oh! The lovely things I'd do in C. If you wanted strings....
I worked with an old coder on an open source game for a while and you sound just like him, bemoaning the fact that it was written in C++ instead of just C. :)

He knew what he was on about though.
 
I worked with an old coder on an open source game for a while and you sound just like him, bemoaning the fact that it was written in C++ instead of just C. :)

He knew what he was on about though.
C++ retained the C part, pretty much fully backward compatible, although it used a different method of calling DLL functions, which broke the compatibility a bit, but I know C++ has now pretty much taken over. I suspect C is more popular now for things like embedded controllers, where you want very compact and fast compiled executables.
I don't know how familiar this stuff is these days, but C is a fully compiled language, so you'd compile your source code, along with any header files for the standard C libraries which contained all the common functions that were standardised in the language, and came with all compilers - like the classic printf function, for general formatted text output, like Print in basic (but more sophisticated), to create an object file (.obj), which was your code converted to pure native machine code. Then you had to run a linker, which would stitch together the object code, with the library object code (precompiled for compilation speed) and it would then calculate all the memory addresses for loops, jumps, function calls etc. and create an executable file (.exe file in dos/windows) that could be run as a proper native program. Because C++ was far more extensive in it's language (more keyword, functions, symbols, etc etc) plus the hugely complex object orientation, the inheritance, and virtual functions, and overridden class members, etc etc. it required a lot more overhead in the standard libraries and related object code, so even the simplest Hello World example, was many times the size of an equivalent C program.
Hmmm, I look above, and the word nerd comes to mind, for some strange and unknown reason! :laughing:
 
@Boogs

Your posts are interesting, but I don't think OP is able to contextualize most of that information yet.

OP is one or two steps past "Hello World".
He'll be able to interpret what you're sharing in a few weeks or months if he's working steadily. But IMO not yet.

For OO coding, IMO the "basic insight threshold" is somewhere around the point that the newbie can make a good attempt at answering the question "what is an object?", and perhaps explain the basics of memory management (from the perspective of the coding language, not the language runtime or the operating system).
 
Ok I have another question this time regarding modulus operations

I have this example from the app

even=[ ]
#telling python this is a list using the [ ]

for x in range (1,11)
#telling python the range of numbers it's gonna use, from number 1 to number 11

if x%2 == 0:
even.append(x)
#this is where I'm confused

print(even)
#telling python to print the even list

OK now, my confussion

I understand that the modulus opeator calculates the residual part of the division, the numbers that are left over

But how is this giving me even numbers if even 5/2 has a residual of 0?
 
If "%" is modulus and "/" is integer divide:

5%2 should be 1: 5 divided by 2 = "2 with a remainder of 1"

5/2 is (probably) different. Here we get a difference between computer logic and numbers in general.

At first glance, Modulus is a "naturally" integer operation. 5%2 = 1 is intuitively sensible
Intuitively, 5/2 is 5 1/2 or 5.5. But neither 5 1/2 or 5.5 is an integer.

If all values are limited to integers, 5/2 = 2. And of course 4/2 = 2 as well.

Test this by:
* Run a loop that prints the result of the modulus operator on a range of numbers (1 to 11 is fine).
* Run the same loop but with integer divide (1/2, 2/2, ...)

If you look around in the docs or however you're learning from, you'll find a way to specify an non-integer number.
I'd expect 5.0/2 (or maybe 5.0/2.0) to return 5.5, but it varies quite a lot between programming languages.

Note that this isn't crazy.
There are many situations where strictly integer operations are very useful. But it introduces "interesting" behaviors, like "5/2=2". On the other hand, for loop control a strict integer is very convenient. Even if you could have "decimal" numbers as loop controls, it would be confusing.

BTW - Coding doesn't use "=" the same way math does, but all coders are numerate, so we mix it up often - an experienced coder recognizes what's being said from the context.

In coding: "==" is normally used for testing, and "=" is used for assignment of a value to a variable.



BTW: Remember I said that programming course and docs are usually terrible for beginners.
That wasn't misplaced humor, it was a genuine warning.

The vast majority of people using docs to learn a programming language are already skilled coders.
They're writing for me and for Boogs (i.e people who already know all this basic stuff) rather than for you.
And even worse, coders are rightly notorious for generally being terrible at writing docs for beginners.
So even if they're trying hard, they are very likely to mess it up /lol.

Just take it slow but steady at first. After a while you'll get over the initial threshold, and there's a period where you can write certain kinds of logic quite easily.
There are many more thresholds in front of you of course, but the first is the most annoying.
 
Last edited:
I forgot the List part.

Coding has a concept with a lot of different names, but I use "Container" or "Data Structure" depending on the context.
"List" is one of these. There are a lot of different names and specific contexts though.

Think "one variable name" and a "digital cardboard box" that can hold multiple "things".
So "even=[ ]" creates an empty container named "even".

We know, from the other logic in your post, it will contain integers in this case, but don't assume than an "[]" object is limited to integers. There are probably plenty of other "things" you can put into that kind of container.

So what might "[] + 5" mean? Probably nothing.
You can't "+" (arithmetic add) a number to a container than can e.g. hold hundreds of different unrelated numbers.

i = 0
i = i+2
works in an intuitive way.
"i" holds exactly one integer, and is initially set to 0.
We "+" it with 2, so now i's value is 2.

But with containers we can't use +, -, /, etc. We need a different kind of operator.

This line:
even.append(x)
says "put another distinct "thing" (the current value of variable "x") into container "even".

So your code, run for all values from 1 to 11 inclusive will find 2, 4, 6, 8, and 10 all return "0" from the "%2" operation.

and "even" will look something like this when you run "print(even)" after the loop:
[2, 4, 6, 8, 10]

This should also make it clear that it makes no sense to use "arithmetic +" on a container.

Note that "print()" runs a lot of code to do its job.
It's like the loop statement above that includes checking for the end of the loop, but "print()" has a lot more logic than "while".

Last point. There's a common thing usually called "operator overloading" that you need to watch for.
Standard example:
"+" in coding isn't always the same as "arithmetic +".

In many languages you can build text strings using "+" as "string concatenate" ...
so if we set string variables like this:
a = "XYZ"
b = "ABC"
then we "+" them into "c"
c = a + b:

Print(c) would print
"XYZABC"
 
I have a couple of minutes spare (waiting for a call), so I'll add something to the "even.append(x)" part of the text.

NB: Skilled coders try languages and libraries out by writing small programs to see how the work. So:
my "Test this by:" suggestion above was made with that in mind. But even that kind of thing is difficult right at the beginning.

So here's a text version that's similar to the "find even numbers" logic we're discussing.

First you'll set up a loop that steps from 1 to 11 (inclusive)like the "while" example earlier. I'll leave that part out.
Second, you select even numbers from the set of numbers numbers (1, 2, 3, ... 10,11) using "number % 2".
If the result of that is zero, it's an even number. Otherwise it's odd.
If it's even, add it to the container "even". Your test calls [] a "list", which is a common name for containers in different languages - but it doesn't mean the same thing in all languages /sigh.

assume our loop variable is "i"

So first pass:

the container named "even" is empty
i is 1
i%2 is 1 which means it's an odd number, so the container remains empty

second pass:
"even" is empty
i is 2
i%2 is 0, which means an even number, so the value of i is put into the container at the end
"even" is now [2]

third pass:
"even" is [2]
i is 3
i%2 is 1, which means an odd number so "even" isn't changed, and it's still [2]

fourth pass:
"even" is [2]
i is 4
i%2 is 0, so the value of i is appended at the end of the container
"even" is now [2, 4]

this continues the same way, so I'll step to 10 and 11.

tenth pass:
"even" is [2, 4, 6, 8]
i is 10
i%2 is 0, which is even, so the value of i is appended at the end of the container
"even" is now [2, 4, 6, 8, 10]

eleventh pass:
"even" is [2, 4, 6, 8, 10]
i is 11
i%2 is 1, so no change to container "even"
"even" is still [2, 4, 6, 8, 10]

The loop ends here, so we run print(even) to see all the even numbers between 1 and 11:
It probably prints this, or something similar:
[2, 4, 6, 8, 10]

If you printed the contents of the container each time through the loop, the first 11 lines of output would be something like:
[]
[2]
[2]
[2, 4]
[2, 4]
[2, 4, 6]
[2, 4, 6]
[2, 4, 6, 8]
[2, 4, 6, 8]
[2, 4, 6, 8, 10]
[2, 4, 6, 8, 10]

That's not so interesting if the is the 500thtime you've written a loop, but it's useful for you to do it now. I still do that kind of thing for debugging.
 
This is true, it's also very beginner friendly.

I decided to start with python because of this, actually, but am planning into moving to other languages as time goes by. I don't want to just stop at python! Want to learn as much as I can for as long as I live. Who knows? Maybe I''ll become a master l33t h4xx0r :tearsofjoy:

Oddly enough, even if you just stayed with Python (nobody ever really does, for various reasons) there'd still be plenty to learn in a life-long fashion regardless -- new libraries, modules, and tools are always being made / updated to enhance workflow / productivity, so there's really never a dull moment. Just focus on those fundamentals :)

Still coding, BTW? I hope so!
 
This is true for so many of us, but it's also what people mean when you hear them talk about "non linear learning". Many of us seem to need all that extra peripheral information because it affects the way we understand what we're trying to focus on.
If I understand what you mean, yeah, absolutely! I find I need to find out enough to understand how something works at a fundamental level. But once that's achieved, I can usually make the thing dance to my tune (within my own limits of course).

But finding all that info needed, is not a simple linear matter oftentimes. I think a lot of NT (er, Neural-Typical, not Windows NT (bad joke for the older ones here! ;))) coders are happy to learn by rote, and use the item as taught. But it's so limiting to me, and infuriating not to know what's going on under the bonnet, because once you do click, so many other uses can appear! And there can be so many directions you need to look, because it's not just the language, but what you're doing with it, and the other things it interacts with, even if indirectly.

I've also found it invaluable for diagnosing faults in live systems (not debugging, but finding failures in apps and servers etc). For example, I wanted to find out how sockets worked ages ago when www was starting to grow, so wrote a simple server running on a winsock, and learnt how most internet protocols work at the networking level, which was really helpful in finding out why other systems may not be working correctly. Doing things like testing a server with a telnet client, seeing if you can connect, seeing if you get the daemon/service to respond - talk back, even pull a web page down, or send an smtp email, etc. Quite fascinating really, to see what's actually going on, instead of just learning some commands by rote.
 
This is true, it's also very beginner friendly.

I decided to start with python because of this, actually, but am planning into moving to other languages as time goes by. I don't want to just stop at python! Want to learn as much as I can for as long as I live. Who knows? Maybe I''ll become a master l33t h4xx0r :tearsofjoy:
If you intend continuing with object-based and object-oriented languages, Python will teach many essential concepts, that other languages will also use, just maybe with different syntax, or slightly different inheritance models, etc. But as I recall (not used it for 20-odd years I think) it has a pretty clean model, and shows many of the important object oriented concepts. If you choose to go feet first into something like C++, there's a lot of difference, but your knowledge of objects and classes will bear you in good stead! Or, you may try Java, which I believe also has a similar object-oriented model to Python.
Personally my favourite ever is C, so basic yet hugely powerful, compact and as fast as it gets unless you hanker for something a little more masochistic like assembly language of (no! pleeese!) machine code, which counts as self abuse these days! :laughing:


C is so 'pure' and compact and elegant, I always found it hugely satisfying, plus being able to do all the really tricky stuff that many other languages couldn't do could be very gratifying. But it's hard work. There isn't even a string data type! You have to maintain contiguous arrays in memory, with a zero to mark the end of string (though the standard library includes functions to do the common string handling). And if you want any kind of sophisticated data structures, and especially collections, it's do it yourself, no just instantiating a collection,. then using an add method. But when you write your own sorting algorithm's and suchlike, it has a deeply satisfying feeling when you finally get it to work without crashing the whole PC (C's good for doing that too!).
The .net languages are worth looking at too, especially C# if you like C/C++ type syntax, but not need all the manual memory management etc. And lots of easy user interface stuff (drag and drop forms creation) - coding interfaces at 3GL languages can be sooo tedious!
 
and as fast as it gets unless you hanker for something a little more masochistic like assembly language of (no! pleeese!) machine code, which counts as self abuse these days!
You just perfectly described my teen years. :)
 
I don't really like Python that much. It's slow. Even a simple app runs slowly. But it's an interpreted language, so no wonder.

which I believe also has a similar object-oriented model to Python.
Objects in Python are an impovisation... I can't recall now, the way they're implemented has terrible loopholes. A prankster could easily exploit it, for example, you can manually change fields of any object you have access to and Python won't disallow it. The way Python works is also very incoherent sometimes... I used it for a long time. It's good for quick scripting, but it has many drawbacks. I would also advise against learning it as the first programming language, as it has dynamic typing and you completely skip memory management, which doesn't teach crucial programming skills. Java or C# would be better in my opinion. C and C++ can be a tad difficult, but they're a must-know.

compact and as fast as it gets unless you hanker for something a little more masochistic like assembly language of (no! pleeese!) machine code, which counts as self abuse these days! :laughing:
Assembler was fun. There are a lot of things that are easy that most people consider self-abuse... "Easy" and "hard" are subjective concepts. But I'm the guy who codes in gedit and compiles in terminal, lol, so everything depends on the viewpoint.
 
Assembler was fun. There are a lot of things that are easy that most people consider self-abuse... "Easy" and "hard" are subjective concepts. But I'm the guy who codes in gedit and compiles in terminal, lol, so everything depends on the viewpoint.
I found it great for learning about how a cpu basically works, but for anything serious in size, I'd get bored long before I could produce something that worked. And since in most cases, the difference between that and C was so minimal it wasn't worth it. maybe a small object file with something truly time critical, or to manipulate some hidden recess of the machine that other languages couldn't reach too well, linked to some C, but beyond that, no thanks! :)
The self-abuse comment was just a joke (yeah, i know, tell me about it! ;)), and honestly, having to count the bytes to work out jmp instruction, was too much for me. That's something I'm happy for the machine to do, it's just boring.
 
Last edited:

New Threads

Top Bottom