This is going to be an ongoing project where that reviews some functions/code snippets and the different syntax between common programming languages.
Functions: | PHP | JavaScript | Python |
---|---|---|---|
String length | strlen($str) |
str.length |
len(str) |
Array size | count($array) |
array.length |
len(array) |
Creating a function | function print() |
function print() |
def function: |
for ($x = 0; $x <= 100; $x+=10) {
echo "The number is: $x";
}
for (i = 0; i < len; i++) {
text += cars[i];
}
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
for x in "banana":
print(x)
for x in range(6):
print(x)
© 2024 by Ryan Rickgauer