COURSE 5 – PENETRATION TESTING, INCIDENT RESPONSE AND FORENSICS

Module 4: Introduction to Scripting

IBM CYBERSECURITY ANALYST PROFESSIONAL CERTIFICATE

Complete Coursera Study Guide

INTRODUCTION – Introduction to Scripting

Throughout this module, you will discover the significance of scripting in cybersecurity, gain insight into various scripting languages, and acquire fundamental skills in Python scripting.

Learning Objectives

  • Explain what a Python library is and describe examples
  • Discuss what Python functions and methods are
  • Explain the basic syntax of conditions in Python branching
  • Describe Python data structures
  • Recall Python rules for syntax, data types, and strings
  • Summarize the benefits of using Python
  • Describe the purpose and features of the JavaScript, Bash, Perl, PowerShell, binary, and hexadecimal scripting languages
  • Explain basic scripting concepts including script, variable, argument, parameter, if statement, and loop
  • Summarize the history of scripting languages and their common uses today

SCRIPTING OVERVIEW KNOWLEDGE CHECK

1. Which organization is credited with creating the first scripting language?

  • Digital Computer Corporation
  • NIST
  • University of California at Berkley
  • IBM Corporation (CORRECT)

2. Which concept of a scripting language helps with repetitive tasks?

  • Variables
  • IF statements
  • Arguments
  • Loops (CORRECT)

3. Which three (3) of the following are scripting language? (Select 3)

  • PowerShell (CORRECT)
  • JCL (CORRECT)
  • FORTRAN
  • JavaScript (CORRECT)

4. True or False. JavaScript greatly improved the functionality of webpages.

  • True (CORRECT)
  • False

5. Which Scripting language uses 1s and 0s in a two symbol system?

  • TRAC
  • Logical
  • Binary (CORRECT)
  • base2

PYTHON SCRIPTING KNOWLEDGE CHECK

1. Python can be best described as what?

  • A high-level scripting language. (CORRECT)
  • A low-level compiled programming language.
  • The hottest new scripting language introduced in 2012.
  • A structured programming language.

2. True or False. Extensive free resources are available on the web to make it relatively easy to learn Python.

  • True (CORRECT)
  • False

3. Indentations are used in Python code for which reason?

  • To indicate a library function is being called.
  • To define a block of code and are required. (CORRECT)
  • For readability and are optional.
  • To define loop nesting and are required.

4. What file type is commonly used to store Python code?

  • .txt
  • .python
  • Any extension is allowed as long as the file only contains ASCII text characters.
  • .py (CORRECT)

5. In the Python statement 

pi=3 

What is the data type of the variable pi?

  • string
  • float
  • bool
  • int (CORRECT)

6. True or False. In the Python statements below Example1=’A’ 

Example2=”B” 

Example1 is a character variable type while Example2 is a string variable type.

 

  • True
  • False (CORRECT)

7. What will be printed by this Python code block? 

pi=3 

pi3=3*pi 

print(pi3)

  • pi3
  • 333
  • 9 (CORRECT)
  • 3

8. True or False. A tuple in Python is similar to a list but it is an immutable data type so its values cannot be changed after they are first set.

  • True (CORRECT)
  • False

9. How many times will a while loop execute in Python?

  • As long as the specified condition is true. (CORRECT)
  • Until the end while statement is encountered.
  • As many times as are specified in the loop counter.
  • Until the first exit statement is encountered.

10. True or False. Python functions must be purchased or downloaded in libraries from Python development companies. You must have Python SDK in order to develop your own functions.

  • True
  • False (CORRECT)

11. Which two (2) of these Python libraries provides useful scientific computing functions? (Select 2)

  • NumPy (CORRECT)
  • StatsModels
  • Matplotlib
  • Pandas (CORRECT)
  • Seaborn
  • Scikit-learn

Partially correct!

INTRODUCTION TO SCRIPTING ASSESSMENT

1. What was considered to be the first scripting language?

  • Perl
  • Bash
  • TRAC
  • JCL (CORRECT)

2. Which concept of a scripting language is a memory address paired with a symbolic name (or identifier) which contains a value?

  • Arguments
  • IF statements
  • Loops
  • Variables (CORRECT)

3. Which three (3) of the following are scripting languages? (Select 3)

  • Bash (CORRECT)
  • Perl (CORRECT)
  • C++
  • Hex (CORRECT)

Partially correct!

4. Which Scripting language is a task automation and configuration management framework from Microsoft?

  • JCL
  • JavaScript
  • Perl
  • PowerShell (CORRECT)

5. Which is an example of how scripts are commonly used today?

  • Autocorrection
  • Word processing
  • Task automation (CORRECT)
  • Transcription

6. What scripting concept is widely used across different languages to process a set of instructions over and over again until a specified condition is met?

  • Arguments
  • If-then
  • Loops (CORRECT)
  • Variables

7. Bash is a scripting language developed for use with which operating system?

  • Linux
  • UNIX (CORRECT)
  • Mac OS X
  • Windows

8. Which Python command would print out “Hello World”?

  • print(Hello World)
  • print(“Hello World”) (CORRECT)
  • type(“Hello World”)
  • output(0,”Hello World”)

9. Why does Python often takes fewer lines of code to accomplish a task than C or Java?

  • Python can utilize extensive function libraries. (CORRECT)
  • In Python you can embed multiple steps within a single command.
  • Python generally takes more lines of code than C or Java to accomplish the same task.
  • Python code is more efficient than C or Java code.

10. How many spaces must be used to indent a block of code in Python?

  • Any number 1 or more as long as the same indentation is used within a code block. (CORRECT)
  • Multiples of 3.
  • Any number 1 or more as long as the same indentation is used throughout the program.
  • Indentation is binary, i.e. a line is either indented or it is not, so there is no restriction to how many spaces are used on any line of indented code.

11. What will Python do when it encounters the hash character “#”?

  • Treat everything to the right of the hash on the current line as a comment. (CORRECT)
  • Treat everything between that hash and the next hash encountered in the program as a comment.
  • Hash is used as a wildcard character in Python.
  • Call in the referenced library function the follows the hash.

12. What will be printed by this Python code block? 

  • pi=3.14159
  • pi=int(pi)
  • print(pi)
  • 3 (CORRECT)
  • 3.14159
  • pi=3.14159
  • pi

13. True or False. In the Python statements below

Example1=”3″ 

Example1 is a string variable type.

  • True (CORRECT)
  • False

14. What will be printed by this Python code block?pi=”3″ 

pi3=3*pi 

print(pi3)

  • 333 (CORRECT)
  • 9
  • 3
  • pi3

15. How many times will the following Python for loop be executed assuming UNMembers is a list of the 193 members of the United Nations General Assembly?

for country in UNMembers:

print(country) 

  • 0
  • 1
  • 193 (CORRECT)
  • Until it reaches a specified country

16. What is one good reason to write your own function in Python?

  • There is no library function already written that will do what you need. (CORRECT)
  • Python only operates through the execution of functions.
  • Functions execute far faster than standard Python code.
  • There are extra Python operators that will only execute inside of a defined function.

17. Which two (2) of these Python libraries provide useful graphics and visualization functions? (Select 2)

  • Pandas
  • Seaborn (CORRECT)
  • Scikit-learn
  • StatsModels
  • NumPy
  • Matplotlib (CORRECT)

Partially correct!

CONCLUSION – Introduction to Scripting

In conclusion, this module has underscored the vital role of scripting in cybersecurity, provided an overview of scripting languages, and introduced the basics of Python scripting.

Armed with this knowledge, you are poised to leverage scripting effectively to enhance security measures and address cyber threats proficiently.