Programming for Beginners: 6 Books in 1- Python Programming( 3 Book series) & SQL Programming(3 Book series) by Daniel Jones

Programming for Beginners: 6 Books in 1- Python Programming( 3 Book series) & SQL Programming(3 Book series) by Daniel Jones

Author:Daniel Jones
Language: eng
Format: azw3, epub, pdf, mobi
Published: 2017-08-29T07:00:00+00:00


Python

a = 3

b = 4

c = a + b

print c

However, that doesn’t mean that they’re not beholden to a lot of the same principles. Indeed, a lot of the things which showed up in C show up in Python as well, despite Python’s huge amount of abstraction. This is what I mean by the C string example.

C didn’t originally have strings. It had a bunch of different data types which would represent numeric values, either on the surface or below the hood, but a way to store plain text messages just simply didn’t exist natively. Indeed, this is due to the limitation of computers to represent text and the fact that computers are, at their root, computing machines, geared ultimately towards numbers and representation thereof.

What C did have, however, were arrays. Arrays are a bit of an ancient analogue to Python lists. They’re still commonly used in C++ and Java and other languages as such, but scripting languages have for the most part eschewed them in favor of lists. C++ and Java, themselves, have implemented things like Python lists like vectors, sets and, well, lists.

So what’s the difference between C arrays and Python lists? Well, not too much. They function pretty similarly. You’ll see where I’m going with this in a second, I promise. Anyway, C arrays and Python lists represent the same basic idea: the storage of related data. However, they go about it different. Python lists expand to be the size that is needed; they have the freedom to do so, because Python is built for modern computers with memory to spare. When C was developed, computers didn’t have that luxury, so it’s built to actually set aside the amount of memory needed for a certain variable. So for example, let’s say we had a C array called “grades” which could hold up to 4 values, but we only guaranteed one:

int grades[4];

grades[0] = 75;

The spots at grades[1], grades[2], and grades[3] would be guaranteed open to the program to use. They’re reserved:

Memory slots

12345 6

takengrades[0]grades[1]grades[2] grades[3] open

Memory spot closed/open?



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.