Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

1a)JAVA

i)A variable name can consist of capital letters from A-Z, lowercase letters a-z, digits and special
characters such as underscore and sign.
ii)The first character cannot be a digit.
iii)Blank spaces cannot be used in variable names.
iv)Java keywords cannot be used as variable names.
v)Variable names are case sensitive.
Vi)There is no limit on length of variable but by conversion, it should be between 5-15
characters.
vii)Variable names should always exist at the left hand side of the assignment operator.

b) JAVASCRIPT
i)The first letter of a variable must be a letter or underscore.
ii)The wrest of the variable names can include any letter, number or underscore. You cannot use
any other characters such as spaces, symbols and punctuation marks.
iii)Variable names are case sensitive.
iv)There is no limit to variable length.
v)Reserved words cannot be used as variable names.

c)PYTHON

i)Variable names cam only contain letters, numbers and underscores.


ii)Variable names cannot start with a number.
iii)Variables are case sensitive.
iv)Variables names should be short but descriptive.
v)Variable names should be in lowercase, if it contains multiple words, you separate them with
an underscore.

d)PHP
i)A variable name cannot start with a number.
ii)Variable names are case sensitive.
iii)Do not use pre- defined constant names, such as PHP_VERSION, PHP_OS etc.
iv)Do not use reserved keywords as variables.
v)All variables begin with a dollar sign.

e)C#
i)A variable name can consist of capital letters, lower case letters, digits and special characters
such as underscore and dollar sign.
ii)The first character cannot be a digit.
iii)Variable names are case sensitive.
iv)Keywords cannot be used as variable names.

2a) Strongly typed


i)Java
ii)Python
iii)c#

b)Loosely Typed
i)PHP
II)JavaScript

3a)Java
i)WHILE LOOP
example:
while (i >= 10) {
System.out.println(i);
}

ii)DO WHILE LOOP


example:
int I = 5;
do{
System.out.println(i);
I++;
}
While(i<=10);

iii)FOR LOOP
example:
for(int I =1; I < = 10, i++) {
System.out.println(i);
}

b)JAVASCRIPT

i)FOR LOOP
example:
for(let I =0; I <= 10, i++) {
Console.log(i);
}

ii)WHILE LOOP
example:
let count = o;
while(count < 5) {
count ++;
Console,log(count);
}

iii)DO WHILE LOOP


example:
let win = true;
do {
let giftt = 5;
Console.log(gift ++);
}
While (win = true);

c)PHP
l)WHILE LOOP
example:
$i = 1;
While($i <= 5){
Echo($i);
$i++
}

ii)FOR LOOP
for($i = 0; $i < 10, $i++) {
echo($i);
}

iii)DO WHILE LOOP


example:
$y = 1;
Do{
Echo(“the value of y is 1”);
$y++;
}
While($y < 5);

d)PYTHON
i)FOR LOOP
example:
numbers = [1,2,3,4]
for x in numbers:
if(x % 2 == 0):
print(x*x)
ii)WHILE LOOP
example:
n=5
while n > o:
n=n–1
if n =2:
break
print(n)

4a) JAVA
I)IF STATEMENT
Example:
Int user = 17;
If(user < = 18) {
System.out.println(“the user is 18 years old or younger”)
}

ii)IF ELSE STATEMENT


example:
int user = 17;
if(user <= 18) {
System.out.println(“The user is 18 years old or younger”);
}
Else if(user > 18) {
System.out.println(“the user is greater than 18”)
}

iii)SWITCH STATEMENT
example:
switch(weekday) {
case1:
System.out.println(“Sunday”)
Break;
Case2:
System.out.println(“Monday”)
Break;
Case 3:
System.out.println(“Tuesday”)
Break;
Default:
System.out.println(“Wednesday”)
}
b)PYTHON
i)IF STATEMENT
example:
I = 23
if I %2 == 0:
print(“this is the if block”)

ii)IF ELSE STATEMENT


example:
I = 23
If I %2 == 0:
Print(“this is the if block”)
else:
print(“this is the else block”)

c)JAVASCRIPT
I)IF STATEMENT
Example:
If (day === 3) {
Console.log(“the day is Wednesday”);
}

ii)IF ELSE STATEMENT


example:
if(day === 3) {
Console.log(“it is Wednesday”);
}
Else if(day === 4) {
Console.log(“it is Thursday”);
}

iii)SWITCH STATEMENT
example:
switch(animal) {
case “kangaroo”:
Console.log(“usuall found in Australia”);
Break;
Case “Lions”:
Console.log(“More in Africa”);
Break;
Default:
Console.log(“the wrest are found everywhere”)
}

d)C#
i) IF STATEMENT
example:
if(I > 2) {
Console.writeline(“Change please”);
}
Else if(I < 2) {
Console.Writeline(“You can chose to change or not”);
)
Else (
Console.Writeline(“Change please”)
}

ii)SWITCH STATEMENT
example:
switch(animal) {
case “kangaroo”:
Console.writeline(“Usually found in Australia”);
break;
Case “Lion”:
Console.writeline(“Found mostly in Africa”);
Break;
Default:
Console.writeline(“the wrest can be found mostly anywhere around the world”);
}

e) PHP
i) IF STATEMENTS
example:
$name = “Eric”
If ($name == ” Mike”) {
echo “name is mike”;
}
Else if($name ==”Eric”) {
Echo “name is Eric”
}
Else {
Echo “ name is $name”;
}
ii)SWITCH STATEMENT
example:
switch ($country) {
case “USA”:
echo “you are in usa”;
break;
case “Japan”:
echo “you are in Japan”;
break;
default:
echo “I do not know your location”
}

You might also like