FINAL EXAM REVIEW - Scripting IT
What are the following parameters that can be used to customize your PowerShell scheduled job? Select the best response. "-StartIfOnBatteries" All of the responses are true. "-WakeToRun" "-RunElevated"
"-WakeToRun"
In Python what should you type if you want to include a comment in your script? !! !# # "@"
#
What command should you type to define a comment in your code when writing a BASH script? ! # % $
#
What is used to test an arithmetic expression in BASH? (( expression)) && expression && {{ expression}} [{ expression}]
(( expression))
What is file extension of a PowerShell script? .PS1 .PS .SH .VB
.PS1
Review the Python image. What is the value of y? You can't add a float to an integer. 15.0 y 15
15.0
In Python, a Boolean can have _____________ possible values. Select the best response. 3 2 1 infinite
2
What is the process iD of Firefox found in the lecture video? 22345 778915 16376 16377
778915
What is the example of a block comment found in PowerShell? Powershell does not support block comments. A block comment starts with "<@" and ends with "#>". A block comment starts with "!#" and ends with "#!". A block comment starts with "<#" and ends with "#>".
A block comment starts with "<#" and ends with "#>".
Review the Python image. There is an invalid syntax error when running this script. What should you do to correct your code? Remove the indentation from the second line of code Indent the last line of the code as this is part of the function. The code is missing a closing parenthesis in the first line of the script. Add a colon to the end of the first line.
Add a colon to the end of the first line.
Which are invalid names for a variable in BASH? ?!mkdir 9Purple Green--Light All of the answers are invalid names in BASH.
All of the answers are invalid names in BASH
In Python a class ____. Select the best response. All of the anwsers are correct. allows new instances of that type to be made. provides a means of bundling data and functionality together. is a user-defined blueprint or prototype from which objects are created.
All of the anwsers are correct.
How many variables can a scalor variable hold at one time? 7 An array of numbers 1 2
An array of numbers
In Python you need to type the following to create a class called Dogs. Select the best answer. CLASS Dogs() class Dogs: CLASS Dogs(): class Dogs
CLASS Dogs():
Review the Python image. What should you do to correct your code? Images must be in a Photoshop format for Python. Make sure your fish.gif is in the same folder as as your script. You forgot to add the " from turtle import * " to the beginnning of your script. Python doesn't know what the "addshape" method is without the turtle module. You can't work with images in Python.
CORRECT You forgot to add the " from turtle import * " to the beginnning of your script. Python doesn't know what the "addshape" method is without the turtle module.
What keys would you press to save a script using NANO? CTL+C CTL+S CTL+X CTL+O
CTL+O
What keys would you press to exit out of NANO? CTL+C CTL+S CTL+X CTL+O
CTL+X
What does the following command do in your BASH script? if test -d "$FILE"; Checks to see if a file with the variable name $FILE exists Checks to see if a file with the variable name $FILE does not exist Checks to see if a directory with the variable name $FILE does not exist Checks to see if a directory with the variable name $FILE does exist
Checks to see if a directory with the variable name $FILE does exist
When using BASH what does -u robert mean when used with ps? Displays the processes running the user robert Defines the universal processes running under terminal -u is not an option that can be run with ps Defines all uniform processes running under robert on the terminal
Displays the processes running the user robert
What is the difference between echo ${myArray[@]} and echo ${myArray[*]} in your BASH script? For Loop Example with '*', will echo individually each values For Loop Exampe with '@', will echo only once all the values For Loop Example with '@', will echo individually each values For Loop Example with '@' or '*' will echo individually each values
For Loop Example with '*', will echo individually each values
How do you run a PowerShell script called MonitorService.PS1 from the command -line? From the command line type "run MonitorService.PS1" From the command line type "C:\MonitorService.PS1" Right click on the script and select run as administrator. From the command line type "./MonitorService.PS1" Make sure the script is in the same path as your command prompt or include the full path.
From the command line type "./MonitorService.PS1" Make sure the script is in the same path as your command prompt or include the full path.
This assigns the date today to the variable $Today1 and converts the current year to a string type. All of the answers are examples of a verb found in the PowerShell cmdlet format. Get Start New
Get
What command should you use to view the execution policy in PowerShell? Get-Policy Get-RestrictedPolicy Show-ExecutionPolicy Get-ExecutionPolicy
Get-ExecutionPolicy
In PowerShell how do you list all processes and sort them by ID? get-process Sort Object -Property ID Get-Process -name | Sort-Object -Property ID Use Task Manager. Get-Process | Sort-Object -Property ID
Get-Process | Sort-Object -Property ID
What do you call a while loop in BASH that doesn't have a condition to stop it? true loop false loop This type loop does not exist in BASH Infinite Loop
Infinite Loop
What text editor should you use to write your BASH scripts in this class? NANO Microsoft Word Google Docs TextEdit on Linux
NANO
In PowerShell you type get-execution policy. Your see that Restricted is the policy that is currently applied. What does this mean? No scripts are allowed. This is the default setting, so you will see it the first time you run the command. With this setting in place, before executing, a script will ask you to confirm that you want to run it. You can only run your trusted PowerShell scripts You can only run your own PowerShell scripts
No scripts are allowed. This is the default setting, so you will see it the first time you run the command.
What does AllSigned mean when setting up a PowerShell execution policy? No scripts are allowed. This is the default setting. You can run your own scripts or scripts signed by a trusted developer. You can run scripts signed by a trusted developer. Before executing, a script will ask you to confirm that you want to run it. You can run any script you want.
No scripts are allowed. This is the default setting.
Review the Python image. What do you call (2 ,1 ,3) in the first line of code? A tuple A complex array simple arguments Positional Arguments
Positional Arguments
Review the image. What do 12 and 10 represent on the first line of the BASH script? Functions Positional Parameters Error Codes The correct response isn't listed.
Positional Parameters
What does the following command do in BASH? ps -u rtest | more Prints out the the results of the ps command for the user rtest one screen at a time Writes a file called rtestMore Prints out the the results of the ps command for the user rtest and includes all processes from all users Prints out more details for the user rtest from the ps command.
Prints out the the results of the ps command for the user rtest one screen at a time
Review the image. When ever you run the following BASH script, you receive an error? What is the most likely reason? Replace until with while. Replace the colon with a semicolon on line 4 next to do. Remve esac as this isn't a BASH command. Repace the [] square brackets with () parentheses.
Replace until with while.
In Python what is self? Self represents global attributes associated with a function in your class. A name, myself, a name I call myself. Self is a special constructor object class that contains methods with attributes. This only works with int and float objects. Self represents the instance of the class or points to the instance of the class in your code..
Self represents the instance of the class or points to the instance of the class in your code..
What do the single brackets [ ] mean in BASH when used with a conditional statement? Single square brackets are used to indicate the beginning and end of a for loop Single square brackets are used to to group arrays together Single square brackets are used as a command that is a shell bulit in and alias to the test command None of the answers listed are correct.
Single square brackets are used as a command that is a shell bulit in and alias to the test command
You have just created a PowerShell script to monitor the spooler service. You want to ensure that the script does not take up too many CPU resources. What command should you include in your script? Schedule-Job | Background -seconds 60 Get-Schedule | -60 seconds -Background While (Schedule-Job} Background -10 seconds Start-Sleep -seconds 10
Start-Sleep -seconds 10
Review the image. What is the syntax error? name = str(int("What is your name?) Add quotes around the variable name. The code should be written as name = int(str("What is your name")) The code should be written as name = int(str("What is your name")) The code should be written as name = str(input("What is your name"))
The code should be written as name = str(input("What is your name"))
Your Python script contains the following code: if choice == "seven": What do the double equal signs mean ? This is an assignment statement along with an if statement. This is an assignment statement along with an or statement. The double equal signs represent a comparison between each value. The double equal signs represent an assignment statement between each value.
The double equal signs represent a comparison between each value.
What does the following command do in BASH? file /home/`whoami`/Desktop/log.txt The command file converts a file to a directory This creates a file called log.txt This generates an error message. Command not found The file command in Linux displays the type of file
The file command in Linux displays the type of file
What does the following command do in BASH? head /home/`whoami`/Desktop/log.txt The head command displays the top 10 lines of the file log.txt The head command displays the last 10 lines of the file log.txt The head command displays the file's line number with the content of the file log.txt to the screen The head command expands the file log.txt and adds white spaces to the tabs. This makes it easier to export to a CSV file
The head command displays the top 10 lines of the file log.txt
Review the following image. Why did Python display an error after assigning x a value. There is a type mismatch. You can't add a string to an integer. x should be converted to the data type of a float. There is a space between the equal sign and x. Python only supports concatenating integers.
There is a type mismatch. You can't add a string to an integer.
Review the PowerShell script. What does this code do in the script? Today1 =(Get-Date) ToString( "yyyy") This assigns a string variable to the method yyyy. This assigns a string variable to the object (Get-Date). This assigns a string variable to the year (GetType). This assigns the date today to the variable $Today1 and converts the current year to a string type.
This assigns the date today to the variable $Today1 and converts the current year to a string type.
What does the following command do in BASH? wc /home/`whoami`/Desktop/myScript.txt This command backs up the file myScirpt.txt This command formats the text using word wrap This command displays the number of lines, words and characters in the file myScript.txt None of the answers listed are correct
This command displays the number of lines, words and characters in the file myScript.txt
Review the image. What does the following code do in Python? Food = ["cake", "cookie", "cherry"] This creates a list. This creates a tuple. This creates an array with a tuple. This create s an array
This creates a list.
Review the Python image. What does the code Radar = Dog() mean within the script? All of the anwsers are correct. This assigns a string variable to the object Radar and passes the Dog() method. This assigns a string variable to the empty list Dog(). This creates an instance of the Dog class and names the instance Radar.
This creates an instance of the Dog class and names the instance Radar.
Review the Python image. What is the code doing in your script? This is a function which creates a tuple with string variables warning1, warning2, warning3. This is a function which takes 3 positional arguments. This is a function which creates a list with string variables warning1, warning2, warning3. This code calls the function warning and passes it 3 arguments.
This is a function which takes 3 positional arguments.
In PowerShell the difference between Do While and While is that even if the condition is not true, the Do actions still run at least once. Whereas with the While loop the actions do not ever run if the condition is not true True False
True
You can create a PowerShell script using the ISE or notepad. True False
True
The same commands that you can run from the command-line in Windows will also work in PowerShell. Example: IPCONFIG True True
True?
You have an assignment from your supervisor that requires you to write a BASH script that offers the user a menu with 7 different options for printing. This will allow the user to select the correct printer based on the floor that they are assigned to. Which is most likely the best kind of logic to use with your BASH script? Use an else if statement for each printers. You should write at least 7 if statements. Use a case statement in your BASH script to build your menu. Create 7 different BASH scripts and direct the user to run the correct script. Add all seven printers to the user profile. If they print to the wrong printer, they can take the stairs. Exercise is a good thing.
Use an else if statement for each printers. You should write at least 7 if statements.
How do you get the length of a list in Python? Use the length function. Use a for loop to print out each item in the list. Use the syntax listName{} Use the len() function
Use the len() function
How to you return the data type of a variable in Python? print("variable type") Use the type("variable") function. varibleType("variable") You can't return the data type of a variable in Python.
Use the type("variable") function.
You use the -Whatif parameter in PowerShell. Which cmdlets should you apply this parameter? Use this perimeter on any of the get-service and get-process commands. Use this perimeter on any PowerShell cmdlets. Use this perimeter on any PowerShell show cmdlets. This only works for cmdlets that change system state. Therefore, there is no -WhatIf parameter for cmdlets like Get-Process that only display information.
Use this perimeter on any of the get-service and get-process commands.
Review the image. When ever you run the following BASH script, you receive an error. What is the most likely reason? lpoption is a command that only runs on a Windows OS. You have the wrong parameter with the lpstat command. You are missing opening and closing curly brackets around the commands in your function. You are missing a parenthesis.
You are missing opening and closing curly brackets around the commands in your function.
Review the image. You have made the script executable however, whenever you run the BASH script nothing happens? What is the most likely reason? You only have Brother printers installed on your Linux computer. lptstat Iis only valid on Windows lpstat is not a BASH command. This is used with Python. You didn't call the function.
You didn't call the function.
Review the image. When ever you run the following BASH script, it only prints out Hello. What is the most likely reason? You need to add a user to your function and then update it for each new user in your network. You need to remove the quotes from the $1 as this is an integer. You should replace the curly braces with square brackets. When you called your function you didn't pass it an argument.
You need to remove the quotes from the $1 as this is an integer.
If you want a script to run under all user IDs, what should you type in your BASH script? whoami "whoami" !whoami `whoami`
`whoami`
What command is used to view the contents of a file in BASH? cat ls tail head
cat
What command do you use to make your BASH script executable? chmod +y chown +x chmod +x chmod +exe
chmod +x
How do you retrive the Bash Array size? (Array length) echo "myArray contain ${#myArray[" "]} elements" echo "myArray contain ${#myArray[?]} elements" echo "myArray contain ${#myArray[*]} elements" echo "myArray contain ${#myArray(*)] elements"
echo "myArray contain ${#myArray[*]} elements"
Review the code in the BASH script. Select the best answer to call the value of X? X=Puppy echo $X echo x echo X echo $x
echo $X
Review the BASH code and selec t the best answer to call the value of hobby? hobby="swimming" echo $Hobby echo "hobby" echo $swimming echo $hobby
echo $hobby
What is the correct syntax to retrive the first key of an array called exploits in BASH? echo explots[1] echo ${explots[0]} echo explots(1) echo $(explots(1))
echo ${explots[0]}
Which BASH command will print out all entires to the screen within the array superUsers? echo ${superUsers[0-3]} echo ${superUsers[@]} echo ${superUsers["admin1", "admin2", "admin3"]} All of the answers are correct
echo ${superUsers[@]}
Using Python ou run the following command: myNum = 78.3 What is the data type of myNum? float boolean integer string
float
You want to find the process ID of notepad on your Windows 10 workstation. What command should you run in PowerShell? get-process notepad.exe get-application notepad.exe get-process -name notepad.exe get-process -name notepad
get-process -name notepad.exe
In PowerShell how do you send the output of the command get-service to a text file? Write-command Get-Service > myFile.txt get-service | out-file sevice.txt get-service write file service.txt get-service | write-file sevice.txt
get-service | out-file sevice.txt
Review the Python image. What should you do to correct your code? greeting ("a long life" "Captain Michael Burnham" ) greeting ("a long life" , "Captain Michael Burnham" ) greeting ("Captain Michael Burnham", "a long life") greeting ("Captain Michael Burnham" ("a long life"))
greeting ("Captain Michael Burnham", "a long life")
What command in BASH should you use to find additional information for the command ls? help ls man ls help man ls ls is not a valid command in BASH..
help ls
What command should you type to view the recent commands you typed in terminal on a Linux OS? last history man history All of the answers are correct
history
Using Python you run the following command: myNum = 7. What is the data type of myNum? float number integer string
integer
In Python the __init_method_______. Select the best response. is used to delegate the creation of new objects in the class. is used to do any initialization of attributes on the object. is used to create a subclass of instances of attributes. is used to remove an instance of a class.
is used to do any initialization of attributes on the object.
Review the Python image. What do you call, end='\n' in the first line of code? Positional Arguments A tuple keyword or named argument A complex array
keyword or named argument
What command should you type in your BASH shell script to list hidden files? ls -l ls -@ ls -d ls -a
ls -a
What command should you type to list the permissions of both directories and files on your desktop if you using a Linux OS? ls ls -a ls -x ls -l
ls -l
Given the file favoriteFoods.txt, which of the following is the correct way to open the file for reading as a text file in your Python script? open('favoriteFoods.txt', 'readOnly') open('favoriteFoods.txt', 'r') open('favoriteFoods.txt', 'writeOnly') open('favoriteFoods.txt', 'read and write')
open('favoriteFoods.txt', 'r')
How do you convert the following variable in Python so that it prints out A as 8.0? A = 8 print(float(A)) print(decimal(A)) print(8.0) print(float(a))
print(float(A))
What command should you type in your BASH script to search for the process ID of the application Firefox? ps -u `whoami` grep firefox ps `user` grep firefox ps -u `whoami` | grep firefox ps -u `whoami` | grep "firefox"
ps -u `whoami` | grep "firefox"
From Terminal in Linux, what command should you run to determine what your current path is? ls ps -aux pwd grep path
pwd
Which command will allow you to delete a directory and the subdirectories in a BASH script? mv ** dir rm -r dir rm dir All of the answers are invalid for this command in BASH
rm dir
Using Python you run the following command: myNum = "nine". What is the data type of myNum? float string integer boolean
string
Your Python script contains the following code: choice = "77" You type type(choice) What does this command return? float number integer string
string
What BASH command will generate an array called superUsers in BASH? superUser=("admin1", "admin2", "admin3") superUser=["admin1", "admin2", "admin3"] superUser=[("admin1", "admin2", "admin3")] None of the answers listed are correct
superUser=("admin1", "admin2", "admin3")
What should type in your BASH shell if you want to create multipe files with the names of "a to f"? touch [A - F] touch {a ..f} touch (a..f) touch {a-f}
touch (a..f)
How do you change the modified time of a file called logs.txt after using touch in your BASH shell script to create a file? touch -v logs.txt touch -u logs.txt touch -m logs.txt touch -n logs.txt
touch -m logs.txt
What should you use in your BASH shell script to hide a file? touch .myhidden file.txt touch $myhidden file.txt touch %myhidden file.txt touch h*myhidden file.txt
touch .myhidden file.txt
What command should you type in your BASH script to create a file called myFile.txt on your desktop? touch /home/`whoami`/Desktop/myFile.txt touch /home/`whoami`\Desktop/myFile.txt touch \home\`whoami`\Desktop\myFile.txt mkdir /home/`whoami`/Desktop/myFile.txt
touch /home/`whoami`/Desktop/myFile.txt
What command should you type to create 100 files with the extension .sh when writing a BASH script? touch {1..100} touch {0..100} touch {1..100}.sh touch {1sh..100.sh}
touch {0..100}
What command do you type in BASH on a Linux system to retrive all basic system information? uname -all uname systemInfo uname -a\
uname -a
What command do you need to type in BASH to remove the value of the variable $mypet. You just typed mypet=fish. unset $mypet unset $fish unset mypet unset fish
unset mypet