Scripting Languages Comparison Flashcards

1
Q

How do you assign variables in PowerShell?

Only language where its different

A

$varName=value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you display a variable to terminal in Bash?

A

echo $varName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you display a variable to terminal in PowerShell?

A

Write-Host $varName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you display a variable to terminal in Ruby?

A

puts varName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the comparison operators in Bash?

A

-eq (==), -ne (!=), -lt (), -ge (>=)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the comparison operators in PowerShell?

A

-eq, -ne, -gt, -ge, -lt, -le

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the comparison operators in Ruby?

A

==, !=, >, >=,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the comparison operators in Python?

A

==, != (<>), >, >=,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the different kinds of loops in Bash?

A

For

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the different kinds of loops in PowerShell?

A

For, While, Do-While, Do-Until

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the different kinds of loops in Ruby?

A

while, until, for

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the different kinds of loops in Python?

A

for, while

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Flow Control in Bash

A
if condition
then
    commands
elif
    commands
else
    commands
fi
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Flow Control in PowerShell

A
if (condition) {
    statements
} elseif (condition) {
    statements
} else {
    statements
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Flow Control in Ruby

A
if condition then
    statements
elsif
    statements
else
    statements end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Flow Control in Python

A
if condition:
    statements
elif condition:
    statements
else:
    statement
17
Q

How to input from the terminal in Bash?

A

Read –p “Prompt:” var

18
Q

How to input from the terminal in PowerShell?

A

$firstName = Read-Host –Prompt ‘Enter first name’

19
Q

How to input from the terminal in Ruby?

A

name = gets

20
Q

How to input from the terminal in Python?

A

Name = raw_input(‘Please enter your name’)

21
Q

Error handling in Bash

A

If [“$?’ = “o”] then

22
Q

Error handling in PowerShell

A
try {
Command
}
catch {
    errHandling
commands
}
23
Q

Error handling in Ruby

A
begin
    statements
rescue
    statements if error occurred
else 
    statement if no error 
end
24
Q

Error handling in Python

A
try:
    statements raise 
except:
    statements
    customErrorObject
finally:
    statements to clean up
25
Q

Arrays in Bash

A
bashArray = (val1, val2, val3)
For I in 1 2 3
Do
    echo
${bashArray[$i]}
26
Q

Arrays in PowerShell

A
$PSarray=@(1.3.5.7.9); 
for($i = o; $1 –lt $PSarray.Length; $i++)
{
$PSarray[$1]
}
Foreach ($element in $PSarray) {
    $element
}
27
Q

Arrays in Ruby

A

rubyArray = [“val1”, “val2”, “val3”]
print rubyArray[1]
print

28
Q

Arrays in Python

A

pythonArray = [10,20,30,40,50]
print(pythonArray[1])
len(pythonArray)