A
asdf
B
asdf
C
sdf
D
sdaf
E
1
Bash
$num1 = 20;
$num2 = 10;
if [ "$num1" -eq "$num2" ]; then
echo "Numbers are equal"
elif [ "$num1" -gt "$num2" ]; then
echo "First number is greater"
else
echo "Second number is greater"
fi
# Checking the password entered by user
echo "Enter password: "
read input
if [ $input = "Pass!@#" ]; then
echo "Correct password entered"
fi
$ for i in $(seq 1 2 5); do
echo "Number: $i";
done
Number: 1
Number: 3
Number: 5
$ i=1
$ while [ $i -le 3 ]; do
echo "I is $i";
i=$(($i+1));
done
I is 1
I is 2
I is 3
$ while true; do
echo "To stop execution of a loop, use CTRL+C"
done
Go
var s int
var i int
for ; i < 50; i++ { // step 3, 4, 8; you can have a sparse loop declaration
if s > 100 {
break
}
if i % 2 == 0 {
continue
}
s += i
}
Kotlin
class Author(id: Int, login: String, email: String, val books: String): User(id, login, email) {
override fun toString(): String {
return "Author{id=$id, login=$login, email=$email}, books: $books"
}
}
val user = User(1, "marys01", "mary0101@gmail.com")
val author = Author(2, "ohwilde", "wilde1854@mail.ie", "Someone’s portrait")
println(user) // User{id=1, login=marys01, email=mary0101@gmail.com}
println(author) // Author{id=2, login=ohwilde, email=wilde1854@mail.ie, books: Someone’s portrait
Python
pets = ['dog', 'cat', 'parrot']
for pet in pets:
if pet == 'dog':
continue
print(pet)
pancakes = 2
while pancakes > 0:
print("I'm the happiest human being in the world!")
pancakes -= 1
if pancakes == 0:
print("Now I have no pancakes!")
break
else:
print("No pancakes...")
Java
class Human {
String name;
int age;
public static void averageWorking() {
System.out.println("An average human works 40 hours per week.");
}
public void work() {
System.out.println(this.name + " loves working!");
}
public static void main(String[] args) {
Human.averageWorking(); // "An average human works 40 hours per week."
Human alice = new Human();
alice.name = "Alice";
alice.work(); // "Alice loves working!"
}
}
JS
// literal notation
let arr = [element_1, element_2, element_3, element_n];
let arr1 = ['JetBrains', 'Hyperskill'];
let arr2 = [45, 34, 23];
let arr3 = ['JavaScript', 12];
// Multiple arguments
let platforms = new Array('JetBrains', 'Hyperskill', 'WebStorm', 'PyCharm');
console.log(platforms.length); // 4
console.log(platforms[0]); // JetBrains