With String Indexing/Slicing, remember, I think it would be important to show that negatives can be used too as indexes. That can be useful sometimes... I have no idea why the switch statement suggestion was rejected in the past for Python though. That was a dumb decision... Otherwise you could have added that in too.
Why did you choose a C++ comparison to Python though? I didn't get that part. Even if it was C to python, you could have shown more similarity:
-
printf() is much more similar to
print(), than
cout << is.
Unless you were showing differences, but there's lots of differences for C++ compared to Python...
Another thing I might consider adding if I were you is the use of
in. Lots of people forget this. And as a result, start writing code like this:
Code:
list1=[1, 2, 3, 4, 5, 6, 7, 8, 9]
findNum=10
numExists=False
for i in list1:
if i==findNum:
numExists=True
print(numExists)
Instead of:
Code:
list1=[1, 2, 3, 4, 5, 6, 7, 8, 9]
findNum=10
numExists=findNum in list1
print(numExists)
And lastly, where is type casting?? This is a basic enough concept...
JUST advice though. Great guide for beginners! Well done, and I can see the effort put forth into this. Lets expand on it a bit
I was reading the rejection of the switch statement a while back though (not sure if it now exists in 3, I use 2.7...). Something like this would have been nice though...
Code:
switch True:
case x:
break
case y:
break
...
Whoever rejected this idea was a moron. There are many things that can be made efficient from a switch statement when it's used in the right places, and not to mention, readability is much better too. The way this works in many languages is the evaluation becomes effectively based off of a lookup table, depending on if you have 5 or more conditions, otherwise the overhead isn't worth it. But with lots of conditions, the benefits can rape that of an if statement...
edit: Here is actually a really ****ing interesting link for those of you interested:
http://stackoverflow.com/questions/60208...-in-python