Number Conversions

07/20/2022

Content

  1. Background
  2. Function Table
  3. For Loops

Background

This is going to be an ongoing project where that reviews some functions/code snippets and the different syntax between common programming languages.

Function Table

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 Loops

PHP

for ($x = 0; $x <= 100; $x+=10) {
    echo "The number is: $x";
}

JavaScript

for (i = 0; i < len; i++) {
  text += cars[i];
}

Python

Looping through a list
fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x)
Looping through string index
for x in "banana":
  print(x)
Looping through a range
for x in range(6):
  print(x)

© 2024 by Ryan Rickgauer