Using of Variable, Keys and Tuples

What is variable in programming languages?

  • In computer programming, a variable is a storage location (identified by a memory address) paired with an associated symbolic name.
  • It contains some known or unknown quantity of information referred to as a value.
  • Finally A variable is a container for a particular type of data (like integer, float, String etc).

example: Java:: int num, String name;

Php:: $num (there is not necessary for type)

Kotlin:: var num, val num2;

Variables in C++ - GeeksforGeeks

What is keys using in Php and how we use it?

Php is used by embedding with HTML, due to which some new features can also be added to it. The specialty of this language is that it is used to design “Dynamic website”. When a user sends a request to a php web page from his browser, in which this code resides.

<?php
  <h1>Welcome to {{$name}} </h1>     //$name is variable but it comes from name key.
  @include ('address',['pin'=>212303])    //here, pin is an key which is not use in this page.
?>

In the PHP code: $featured is the associative array being looped through, and as $key => $value means that each time the loop runs and selects a key-value pair from the array, it stores the key in the local $key variable to use inside the loop block and the value in the local $value variable.

**In foreach use $key => $value

foreach($featured as $key => $value)
{
  echo $value['name'];
}

What is use of tuple in Programming language?

Tuple is used to store multiple objects in a single variable. Tuple is similar to list because the value of the objects stored in the list can be changed, whereas tuple is immutable so the value of the objects stored in the tuple cannot be changed.

example:

[Geeks, 123, &#*@]
key value[A, B]