Programming Languages war
Python, PHP, Javascrip (Nodejs)
Valentine's day

Programming Languages war Python, PHP, Javascrip (Nodejs) Valentine's day

Carlos Rivas's photo
Carlos Rivas

Published on Feb 15, 2021

4 min read

Hey my friends, a new post about this war. I don't know which is better, but I'll try to figure it out. I hope y'all enjoy this series. Here we go!

Yesterday was Valentine's day, This time is about love, if you want to say what you think about this person special, I hope to be able to help you!

I had to look for a good word for each letter. πŸ˜…

Python

First, I save a dictionary the words, I save my wife's name in a variable, I convert the letters to lowercase with the method "lower" and next I use a "for" to read letter by letter, and print the result.

dictionary = {
  "a": "Awesome", 
  "b": "Beutiful", 
  "c": "Creative", 
  "d": "Daring", 
  "e": "Exceptional",
   "f": "Fantastic",
   "g": "Gorgeous",
   "h": "Hope",
   "i": "Inspiration",
   "j": "joyful",
   "k": "Kind",
   "l": "Lovely",
   "m": "Magic",
   "n": "Noble",
   "o": "Open-hearted",
   "p": "Perfect",
   "q": "Quintessential",
   "r": "Responsible",
   "s": "Smart",
   "t": "Tenacious",
   "u": "Unique",
   "v": "Virtuous",
   "w": "World-class",
   "x": "xper",
   "y": "Yearning",
   "z": "Zazzy"
   }

name = "Grehtlingmar"

name = name.lower()

print("If my words can't say that I thing about you, my code does it! πŸ’–")

for letter in name:
  print(dictionary[letter])

PHP

First, I save an array the words, I save my wife's name in a variable, I convert the letters to lowercase with the method "strtolower" and next I use a "for" to read letter by letter, and print the result.

<?php
$array = [
    "a"=>"Awesome",
    "b"=>"Beutiful",
    "c"=>"Creative",
    "d"=>"Daring",
    "e"=>"Exceptional",
    "f"=>"Fantastic",
    "g"=>"Gorgeous",
    "h"=>"Hope",
    "i"=>"Inspiration",
    "j"=>"joyful",
    "k"=>"Kind",
    "l"=>"Lovely",
    "m"=>"Magic",
    "n"=>"Noble",
    "o"=>"Open-hearted",
    "p"=>"Perfect",
    "q"=>"Quintessential",
    "r"=>"Responsible",
    "s"=>"Smart",
    "t"=>"Tenacious",
    "u"=>"Unique",
    "v"=>"Virtuous",
    "w"=>"World-class",
    "x"=>"xper",
    "y"=>"Yearning",
    "z"=>"Zazzy"];

$name = "Grehtlingmar";

$name = strtolower($name);

echo "If my words can't say that I thing about you, my code does it! πŸ’– \n";

for($count = 0 ; $count < strlen($name) ; $count ++)
{
    echo $array[$name[$count]] . "\n";
}
?>

Javascript

First, I save an object the words, I save my wife's name in a variable, I convert the letters to lowercase with the method "toLowerCase" and next I use a "for" to read letter by letter, and print the result.

const object = {
  a: 'Awesome',
  b: 'Beutiful',
  c: 'Creative',
  d: 'Daring',
  e: 'Exceptional',
  f: 'Fantastic',
  g: 'Gorgeous',
  h: 'Hope',
  i: 'Inspiration',
  j: 'joyful',
  k: 'Kind',
  l: 'Lovely',
  m: 'Magic',
  n: 'Noble',
  o: 'Open-hearted',
  p: 'Perfect',
  q: 'Quintessential',
  r: 'Responsible',
  s: 'Smart',
  t: 'Tenacious',
  u: 'Unique',
  v: 'Virtuous',
  w: 'World-class',
  x: 'xper',
  y: 'Yearning',
  z: 'Zazzy'
};

let name = 'Grehtlingmar';

name = name.toLowerCase();

console.log(
  "If my words can't say that I thing about you, my code does it! πŸ’–"
);

for (let count = 0; count < name.length; count++) {
  console.log(object[name[count]]);
}

Conclusion

  • Structure: In the love, the three cases are very similar.
  • Lines: Python: 37, PHP: 40, Javascript: 40

Would you like to say something to your love?

This post is inspired by my wife. Thanks a lot for your time and dedication. You are the best! I love you!

I hope you enjoy my post and remember that I am just a Dev like you!

Β 
Share this