Python Scripting for ArcGIS Pro

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the following script: import arcpy fc = "C:/Data/zipcodes.shp" fieldname = "CITY" delimfield = arcpy.AddFieldDelimiters(fc, fieldname) sqlwhere = delimfield + " = 'LONGWOOD'" with arcpy.da.SearchCursor(fc, ["NAME", "CLASSCODE"], sqlwhere) as cursor: for row in cursor: print(row[0]) What is the SQL Where clause?

"CITY" = 'LONGWOOD' 'LONGWOOD'. In this statement, "CITY" is the name of the field in double quotes, and 'LONGWOOD' is the value of interest. Because the value is a string, it must be in single quotes as part of SQL syntax. Then to use the clause as the where_clause parameter, the entire expression must be a string. This requirement presents an issue because both types of quotation marks would result in a syntax issue. Neither ""CITY" = 'LONGWOOD'" or '"CITY" = 'LONGWOOD'' results in the correct string because of inconsistent use of quotation marks.

What is the output of this code? text = "Geography" text[2:5]

"ogr"

What is the basic syntax for in-line variable substitution in geoprocessing tools and ModelBuilder?

%name%

What are the two ways to start working with a project using the ArcPy mapping module?

(1) reference an existing .aprx file stored on disk, or (2) use the project from the current ArcGIS Pro session.

What are Debugging procedures?

- Carefully reviewing the content of error messages - Adding print messages to your script - Selectively commenting out code - Using a Python debugger

What are some of the typical examples for the ArcPy mapping module?

- Finding a layer with a specific data source and replacing it with another data source - Modifying the display properties of a specific layer in multiple maps - Generating reports that describe the contents of projects, including maps, layers, tables, and layouts - Searching for and replacing a text

What are some common geoprocessing-related errors

- Forgetting to determine whether data exists. A small typo in the name of the workspace or feature class will cause a script to fail. - Forgetting to check for overwriting output. The default setting is not to overwrite outputs, so unless overwriting is specifically allowed, a script that attempts to overwrite existing files will not run - Data is being used by another application - Not checking the properties of parameters and objects returned by tools

What are some benefits of error catching?

- Program design thought process - Organized code - Preventing unanticipated errors from crashing the program

What are some common Python code errors

- Simple spelling mistakes - Forgetting to import modules, such as arcpy and os - Case sensitivity - Paths - Forgetting colons after statements - Incorrect or inconsistent indentation - Conditional (==) versus assignment (=) statements

What are some benefits of creating a script tool

- The script becomes part of the geoprocessing framework. - A user interface is added to run the script. - Built-in validation prevents errors. - The script tool is easier to share.

How many lines will this code print? while False: print("Looping...")

0

How many items are in this list? [2,]

1

The basic geoprocessing framework comprises

1. A collection of tools, organized in toolboxes and toolsets 2. Methods to find and execute tools 3. Environment settings and other geoprocessing options that control how tools are run 4. Tool dialog boxes for specifying tool parameters and controlling the execution of tools, 5. ModelBuilder, a visual programming language for creating models that allow for the sequencing of tools 6. Python window for executing tools using Python 7. Geoprocessing history that logs the tools being executed and 8. Methods for creating Python scripts and using them as tools

What is the typical debugging procedure?

1. Check for any syntax errors, and save the script 2. Set breakpoints, allowing you to pause running the script at specific lines 3. Run the script using a debugger 4. Step through the script, keeping an eye on the values of pertinent variables

Python has several features that make it the programming language of choice such as:

1. Simple and easy to learn 2. Free and open source 3. Cross-platform 4. It is interpreted 5. It is object-oriented

In addition to its structure and its integration with ArcGIS Pro, ArcGIS Notebooks also provides other benefits over other scripting environments. Such as:

1. You can develop more complex Python scripts because code is not written and run in an interactive manner. 2. You can generate dynamic output, such as graphics, to assist with verifying and analyzing output. 3. You can write cleaner code with the assistance of syntax formatting and code completion. 4. You can save Python code to the project as a notebook or export it as a .py or .html file.

Each object has the following:

1. value 2. an identity (unique identifier) 3. a type (which is the kind of value an object can hold)

What is the output of this code? x = 4 x *= 3 print(x)

12

How many different values can a Boolean represent?

2

What is the output of this code? x = 3 num = 17 print(num % x)

2

What is the result of this code? if not True: print("1") elif not (1 + 1 == 3): print("2") else: print("3")

2

What is the result of this code? nums = [1, 2, 3, 4, 5] nums[3] = nums[1] print(nums[3])

2

How many arguments are in this function call? range(0, 100, 5)

3

How many numbers does this code print? i = 5 while True: print(i) i = i - 1 if i <= 2: break

3

What is the output of the following code? Look at the screenshot in definition import arcpy arcpy.env.workspace = "C:/Data" ws = arcpy.ListWorkspaces() print(len(ws))

3

What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num == 7: print("7")

3

What is the result of this code? nums = list(range(5, 8)) print(len(nums))

3

How many lines will the following code output? print("Hi") print("""This is great""")

4

How many numbers does this code print? i = 3 while i >=0: print(i) i = i - 1

4

What is the result of this code? letters = ["a", "b", "c"] letters.append("d") print(len(letters))

4

What is the result of this code? nums = [5, 4, 3, 2, 1] print(nums[1])

4

What is the result of this code? nums = list(range(5)) print(nums[4])

4

Consider the catalog screenshot in definitition import arcpy walk = arcpy.da.Walk("C:/Temp") for dirpath, dirnames, filenames in walk: for file in filenames: print(file)

5

What is the output of this code? list = [2, 3, 4, 5, 6, 7] for x in list: if(x%2==1 and x>4): print(x) break

5

What is the output of this code if the user enter '42' as input: age = int(input()) print(age+8)

50

What is the result of this code? nums = [9, 8, 7, 6, 5] nums.append(4) nums.insert(2, 11) print(len(nums))

7

nums = [10, 9, 8, 7, 6, 5] nums[0] = nums[1] - 5 if 4 in nums: print(nums[3]) else: print(nums[4])

7

What is the output of this code? spam = "7" spam = spam + "0" eggs = int(spam) + 3 print(float(eggs))

73.0

What is the output of this code? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])

8

What is the output of this code? x = 5 y = x + 3 y = int(str(y) + "2") print(y)

82

What is the result of this code? nums = list(range(3, 15, 3)) print(nums[2])

9

Which of the following is (are) correct to run the Clip tool using ArcPy? (check all that apply) A. import arcpy arcpy.env.workspace("c:/data") arcpy.Clip_analysis("roads.shp", "boundary.shp", "result.shp") B. import arcpy arcpy.env.workspace("c:/data") arcpy.analysis.Clip("roads.shp", "boundary.shp", "result.shp") C. import arcpy arcpy.env.workspace("c:/data") arcpy.analysis_Clip("roads.shp", "boundary.shp", "result.shp") D. import arcpy arcpy.env.workspace("c:/data") arcpy.Clip.analysis("roads.shp", "boundary.shp", "result.shp")

A & B import arcpy arcpy.env.workspace("c:/data") arcpy.Clip_analysis("roads.shp", "boundary.shp", "result.shp") import arcpy arcpy.env.workspace("c:/data") arcpy.analysis.Clip("roads.shp", "boundary.shp", "result.shp")

What is a .cal file

A .cal file is a text file with the contents of both the expression and the code block formatted for importing. Although a .cal file is not a Python script file, you can open it as a text file and work with the Python code.

What type of values does the arcpy.Exists() function return?

A Boolean value of True or False

What is the difference between Point and PointGeometry objects?

A Point object consists of little more than a pair of x,y coordinates, and has a limited number of properties and methods. For example, it does not have a spatial reference, regardless of the nature of the coordinates. A PointGeometry object is a geometry object and, as a result, has a much more extensive number of properties and methods, including a spatial reference.

Which two debugging approaches can be used if your script starts to run but then fails while executing? Choose two. A. Use the print function throughout your script to output status notifications. B. Add a hashtag symbol before specific lines of code to comment them out and stop them from executing. C. Add the findError function to the end of your script to mark which lines have errors. D. Read through the script and ensure that your Python code has no missing quotation marks, colons, or indentations

A and B A. Use the print function throughout your script to output status notifications. B. Add a hashtag symbol before specific lines of code to comment them out and stop them from executing.

Which two statements describe conceptual Python environments? Choose two. A. Workflows are written as Python code in scripting environments. B. Python scripts are executed in run environments. C. Python scripts are tested in testing environments. D. Data is interactively queried in query environments.

A and B A. Workflows are written as Python code in scripting environments. B. Python scripts are executed in run environments.

Which two statements describe an IDE? Choose two. A. It is a highly configurable scripting environment. B. It is integrated with ArcGIS Pro. C. It includes features like code completion and syntax formatting. D. It uses an interactive method for writing and running code. E. It displays dynamic output during script execution.

A and C A. It is a highly configurable scripting environment. C. It includes features like code completion and syntax formatting.

Which of the following statements regarding batch processing in ArcGIS is (are) true? A) All batch tools are created as models upon execution. B) All geoprocessing tools in ArcGIS can be run in batch mode. C) All batch tools employ dynamic naming to facilitate the naming of output files. D) For tools with multiple parameters, batch processing only allows you to select one parameter as the batch parameter.

A and D

What is the base case of a recursive function?

A case that doesn't involve any further calls to the function

What is a cursor?

A cursor is a database technology term for accessing a set of records in a table. Conceptually, it works the way list functions work where a cursor is used to manipulate a list of records.

What is a debugger

A debugger is a tool that allows the programmer to set breakpoints, step through the code line by line, and inspect or modify the value of variables. or A debugger is a tool that allows you to step through your code line by line, to place breakpoints in your code to examine the conditions at that point, and to follow how certain variables change throughout your code

What is the finally block?

A finally block consists of code that is used to execute important code such as closing a connection, etc. This block executes when the try block exits. It also makes sure that finally block executes even in case some unexpected exception is encountered. Contains code that should be executed after the code in the try block whether it succeeded or not.

A logic error means

A logic error means the script will run but produce undesired results

What is a map frame?

A map frame is an element in a layout to display the contents of a map

What does a map in ArcGIS Pro mean?

A map in ArcGIS Pro represents a collection of symbolized geographic data layers and tabular data. A project contains one or more maps, and each map typically contains one or more layers and/or tables

What is a namespace?

A namespace in Python is a system to make sure all the names are unique and can be used without any conflicts. In simple terms, a namespace is a collection of names used in a script.

What is the difference between a package (like ArcPy) and a module in Python?

A package can contain multiple modules, as well as classes and functions

The script does not run and produces an error. ArcGIS Notebooks returns the SyntaxError: EOL while scanning string literal message in the output area of the first Code cell. The error message informs you that there is a syntax error in line 1. Without this error message, how would you know that Python encountered a syntax error and not an exception?

A script does not execute when Python encounters a syntax error. Because the script did not run, Python must have encountered a syntax error.

A script tool is an integrated method of ____ and ___ a Python script in ArcGIS Pro

A script tool is an integrated method of storing and executing a Python script in ArcGIS Pro.

Python has encountered an exception. How do you know that Python encountered an exception and not a syntax error? sampleMeans = [samplesA, samplesB, samplesC] buffDists = [] for values in sampleMeans: meanValue = statistics.mean(values) buffDists.append(meanValue) print(buffDists) --------------------------------------------------------------------------- NameError Traceback (most recent call last) In [10]: Line 4: meanValue = statistics.mean(values) NameError: name 'statistics' is not defined ---------------------------------------------------------------------------

A script will execute until Python encounters an exception. Because this script started to run before failing, Python must have encountered an exception.

What is the search cursor?

A search cursor retrieves rows. This type of cursor finds specific records on the basis of attribute values, similar to performing a query, as well as reads the geometry and attribute values of all records

What is a shared lock?

A shared lock is applied when a table or dataset is accessed. For example, opening a feature class in ArcGIS Pro and performing a query results in a shared lock on the dataset. Multiple shared locks can exist, but no exclusive locks are permitted if there is already a shared lock

What are static and dynamic scripts?

A static script contains hard-coded values for paths and variables. The script is written to work only with these values and does not allow for any change to those values without editing the script. A dynamic script allows the user to provide values interactively. This ability makes the script more flexible by allowing the script to run with different data stored in different locations.

What is a vertex?

A vertex is a pair of x,y coordinates. These vertices can be accessed using geometry objects, such as points, polylines, and polygons

What is a wildcard?

A wildcard is a symbol that represent one or more characters. In the context of the ArcPy list functions, the wildcard is used to list only the elements that meet a specific criterion based on their name

What is a workspace?

A workspace provides a default location for the files you will be working with, such as inputs and outputs of geoprocessing tools

Which of the following statements regarding Python 2 and 3 is (are) true? Check all that apply. A) Some new functionality added in Python 3 has also been added to Python 2, a process known as backporting B) All code that works in Python 2 will also work in Python 3, and vice versa C) With some effort, code can be written that works in both Python 2 and 3. D) Both Python 2 and 3 will be maintained for many years to come E) ArcGIS Desktop 10.x works with Python 2 and ArcGIS Pro works with Python 3

A, C, E

Which of the following is (are) correct to run the Clip tool using ArcPy? (check all that apply) A. import arcpy arcpy.env.workspace("c:/data") arcpy.Clip_analysis("roads.shp", "boundary.shp", "result.shp") B. import arcpy arcpy.env.workspace("c:/data") arcpy.analysis.Clip("roads.shp", "boundary.shp", "result.shp") C. import arcpy arcpy.env.workspace("c:/data") arcpy.analysis_Clip("roads.shp", "boundary.shp", "result.shp") D. import arcpy arcpy.env.workspace("c:/data") arcpy.Clip.analysis("roads.shp", "boundary.shp", "result.shp")

A. import arcpy arcpy.env.workspace("c:/data") arcpy.Clip_analysis("roads.shp", "boundary.shp", "result.shp") B. import arcpy arcpy.env.workspace("c:/data") arcpy.analysis.Clip("roads.shp", "boundary.shp", "result.shp")

Which of the following are typical properties of geoprocessing tool parameters? (Check all that apply) A. Direction (input or output) B. Environment settings (e.g. coordinate system, workspace) C. Data type (e.g. feature class, raster, string) D. Unit (e.g. m, km, degrees) E. Name F. Required or optional

A. Direction (input or output) C. Data type (e.g. feature class, raster, string) E. Name F. Required or optional

Which two attributes are benefits of using Python? Choose two. A. High scalability B. Multiple scripting environments C. Complex syntax D. Low subscription cost

A. High scalability and B. Multiple scripting environments

Which two statements describe the Python programming language? Choose two. A. Its syntax is easy to learn and understand. B. It is free and open-sourced. C. It supports only built-in libraries to ensure stability. D. Debugging requires specialized software.

A. Its syntax is easy to learn and understand and B. It is free and open-sourced.

Which of the following is (are) a list function of ArcPy? (check all that apply) A. ListTables B. ListFields C. ListGeodatabases D. ListFeatureClasses E. ListFiles F. ListProperties G. ListFeatureDatasets

A. ListTables B. ListFields D. ListFeatureClasses E. ListFiles

Which two statements are true regarding using cursors to read and write geometry? (Choose two.) A. Use an update cursor to replace existing geometry with updated coordinates. B. Use an insert cursor to read a feature's coordinate values. C. Use an insert cursor to add new features. D. Use a search cursor to add new features

A. Use an update cursor to replace existing geometry with updated coordinates. C. Use an insert cursor to add new features.

Which of the following correctly describes the general syntax for a function in ArcPy? A. arcpy.<functionname>(<arguments>) B. arcpy_<functionname>(<arguments>) C. arcpy.<functionname>.<arguments> D. arcpy.<functionname>_<arguments> E. arcpy_<functionname>_<arguments>

A. arcpy.<functionname>(<arguments>)

The ListWorkspaces() function recognizes five different types of workspaces. What are they?

ACCESS (personal geodatabase) - legacy workspace (no long supported) COVERAGE (coverages) - legacy workspace (no long supported) FILEGDB (file geodatabases) FOLDER (shapefiles) SDE (enterprise geodatabase)

What is the effect of the following code snippet? arcpy.env.workspace = "C:\Data\SanJuan.gdb" fcList = arcpy.ListFeatureClasses()

All feature classes in the C:\Data\SanJuan.gdb workspace will be included in the fcList variable

If you do not provide any parameters, what will be returned by the ListFeatureClasses function?

All the feature classes in the current workspace environment will be returned as a Python list.

What is an alternative for determining whether a table name exists?

An alternative for determining whether a table name exists is to use the arcpy .CreateUniqueName() function. This function creates a unique name in the specified workspace by appending a number to the input name. This number is increased until the name is unique.

What is an assertion?

An assertion is a sanity-check that you can turn on or turn off when you have finished testing the program. An expression is tested, and if the result comes up false, an exception is raised. Assertions are carried out through use of the assert statement.

What is meant by uncaught error?

An error that is not handled by error handling code, and thus usually forces the program to crash

What is an exclusive lock?

An exclusive lock is applied when changes are being made to a table or dataset. Examples include editing and saving a feature class in ArcGIS Pro, changing the schema of a table or feature class in ArcGIS Pro, and using an insert or update cursor on a feature class in Python

What is an inset cursor?

An insert cursor inserts rows. This type of cursor adds new rows to a table, which can then be populated with new attribute values and new geometry

Examine the following script: import arcpy arcpy.env.workspace = "C:\EsriTraining\SanJuan.gdb" rows = arcpy.InsertCursor("Plants") row = rows.newRow() row.PLANT_NAME = "Canada Thistle" rows.insertRow(row) What does the variable "rows" represent?

An insert cursor on the Plants table

What is an update cursor?

An update cursor updates and deletes rows. This type of cursor modifies existing attribute values or deletes rows from a table

What is the general syntax of the importDocument() method?

ArcGISProject.importDocument(document_path, {include_layout}, {reuse_existing_maps}) The document_path variable consists of a string that represents the full path and name of the document. You can import only one document at a time, so to import multiple documents, you must repeat the method. A map document always includes a layout, whereas globe documents and scene documents do not. The optional include_layout parameter is a Boolean to indicate whether you want to import the layout. The default is True. If this parameter is set to False, only the data frames of the map document are imported as maps, not the layout. The optional reuse_existing_maps parameter is a Boolean to avoid duplicating maps when importing a layout file (.pagx).

Automation in Python enables you to

Automation in Python enables you to perform actions multiple times without the need to write repetitive code. Instead of writing multiple lines of code to perform an action multiple times, you only need to write a small amount of Python code to cover all of the repetitive actions

Which Python site package enables access to core ArcGIS functionality, including the use of geoprocessing tools? A. ArcGIS API for Python B. ArcPy C. Package Manager D. SciPy

B. ArcPy

A GIS administrator has developed a stand-alone Python script that updates the names of feature classes within a geodatabase. The administrator wants to give the script to an intern who needs to run the script on GIS data that the company regularly receives from a local agency. However, the intern has limited programming experience, and the task requires that some inputs must be changed each time the script is executed. Which approach should the GIS administrator take to accomplish this goal? A. Share the stand-alone script, and then instruct the intern about the use of IDEs and how to modify lines of code for the input parameters. B. Create and share a script tool, and then show the intern how to open the tool, select parameters, and run the tool. C. Share the stand-alone script, and then teach the intern how to import and run code in the Python window and how to modify lines of code for the input parameters. D. Create and share a notebook that has instructions about how to modify lines of code for the input parameters, and then show the intern how to open and run the notebook.

B. Create and share a script tool, and then show the intern how to open the tool, select parameters, and run the tool.

select the most appropriate scripting environment for each scenario. You want to test some ideas for a Python script, but you are working on a locked-down machine that cannot access additional software. A. IDE B. IDLE C. Python window in ArcGIS Pro D. ArcGIS Notebooks

B. IDLE

Which three statements describe benefits of creating a script tool? (Choose three.) A. Script tools can be added to the system toolboxes that are installed with ArcGIS. B. If the value is typed into a field, the tool will validate the input. C. The tool interface allows for browsing to data. D. You can run your script tool from a model, the Python window, or another script. E. Changes to the properties of your script tool are made with Python.

B. If the value is typed into a field, the tool will validate the input. C. The tool interface allows for browsing to data. D. You can run your script tool from a model, the Python window, or another script.

For the sample Python code below, identify its type and cause of error. list = ["A", "B", "C"] for item in list: if item = "C": list.remove(item) else: pass A. It would cause a NameError exception because the list variable is not defined. B. It would cause an evaluation syntax error because the evaluation statement has only one equal sign. C. It would cause a TypeError exception because the list contains string values. D. It would cause an indentation syntax error because the if-else statements are not indented properly.

B. It would cause an evaluation syntax error because the evaluation statement has only one equal sign.

Following the DRY principle makes the code: A. bad and repetitive B. easier to maintain C. loop forever

B. easier to maintain

Which of the following is used to retrieve all error messages from executing a geoprocessing tool? A. print(arcpy.GetMessage()) B. print(arcpy.GetMessages(2)) C. print(arcpy.GetMessages()) D. print(arcpy.GetMessage(2)) E. print(arcpy.GetMessages(1)) F. print(arcpy.GetMessages(1))

B. print(arcpy.GetMessages(2))

You have created an update cursor to change attribute values in your table. Which snippet would set a value of Primary to the ROAD_TYPE attribute? A. row.ROAD_TYPE = Primary B. row.ROAD_TYPE = "Primary" C. row = "Primary" D. row.Setvalue = "Primary"

B. row.ROAD_TYPE = "Primary"

Both Describe() and da.Describe() are dynamic. In the case of Describe() the properties of the object are dynamic and in da.Describe(), the keys of the dictionary are dynamic. What does dynamic mean?

Being dynamic means that the properties or keys available depend on the data type being described

What is binary mode?

Binary mode allows you to change the way a file is handled.

A ___ of code is one or more consecutive lines idented by the same amount

Block

______ is used to make more complicated conditions for if statements that rely on more than one condition

Boolean logic

What are some common characteristics of lists and dictionaries

Both are mutable and both can be nested

Using a conditional statement to allow for choosing between two or more execution paths is called ____.

Branching

What is branching?

Branching is one way to control the workflow in your script. It basically means deciding to take one path or another. Branching typically uses the if structure and its variants

Which two options are features of ArcGIS Notebooks? Choose two. A. Python code is written and run interactively. B. Python scripts are stored as .py files. C. ArcGIS Notebooks generates dynamic output, such as graphics. D. Python scripts are written and run as a series of compartmentalized cells.

C and D C. ArcGIS Notebooks generates dynamic output, such as graphics. D. Python scripts are written and run as a series of compartmentalized cells.

Which statement best describes how a Python library can enable expanded capabilities? A. A Python library contains books that can teach you new ways of coding. B. A Python library is a collection of published works that outline best practices to increase code efficiency and increase available computing resources. C. A Python library can be imported to expand the packages and modules that are available for use. D. A Python library module provides an efficient method of indexing, which reduces the run time of scripts.

C. A Python library can be imported to expand the packages and modules that are available for use.

Scenario 2: Develop a GIS workflow to share with others As a GIS manager in a large organization, you developed a workflow to accomplish a variety of tasks necessary for regular office operations. This workflow requires you to run a series of geoprocessing tools in a specific order, produce dynamic output to quickly review intermediary results, and output resulting layers to a map for final verification. You would like to create a Python script to facilitate this complex workflow, as well as share the script with other GIS users in the organization so that they can complete the required tasks. Which scripting environment would be best for this scenario? A. Python window in ArcGIS Pro B. IDE C. ArcGIS Notebooks D. IDLE

C. ArcGIS Notebooks The Python window can display results in a map, but it is not able to display dynamic output and it is not the best choice for writing, running, and sharing complex workflows An IDE can write, run, and share complex workflows, but it is unable to display dynamic output or display results in a map IDLE is not the best choice for writing, running, and sharing complex workflows, and it is unable to display dynamic output or display results in a map

Which two options describe the roles of statements in Python? Choose two. A. Process data and generate a value as output B. Display printouts of processes with the print statement while your script is executing C. Automate processes through the use of for-in and other looping statements D. Create logical flows through the use of if-else statements

C. Automate processes through the use of for-in and other looping statements D. Create logical flows through the use of if-else statements

As a GIS administrator, you developed a stand-alone Python script into a script tool. Which unique feature of script tools can help facilitate the use of the script in ArcGIS Pro? A. Including Markdown cells to describe the workflow of the script B. Exporting the script tool as a notebook C. Configuring the script to use an interface for selecting parameters D. Storing the script tool as a .py file, which can be executed by ArcGIS Pro or IDEs

C. Configuring the script to use an interface for selecting parameters

Which Python language component both performs an action and returns a value? A. Instructions B. Statement C. Function D. Data type

C. Function

If you think of a Python script as a recipe, which element would be considered the ingredients? A. Syntax B. Functions C. Data types D. Statements

C. If you think of a Python script as a recipe, the data types are the recipe's ingredients, and the statements and functions are the recipe's instructions. You need ingredients and instructions for a recipe, just as you need data types, statements, and functions for a script.

select the most appropriate scripting environment for each scenario. You are working on a complex automated workflow in ArcGIS Pro, and you want to test the configuration of a geoprocessing tool in Python before you incorporate it into your Python script. A. IDE B. IDLE C. Python window in ArcGIS Pro D. ArcGIS Notebooks

C. Python window in ArcGIS Pro

You are a GIS technician using a print function in ArcGIS Notebooks to view the results of a block of Python code. Which statement explains what happens after you run the print function? A. Results are written to a text file. B. Code output is exported as a printable PDF. C. Results are printed in an Out cell type. D. Code output is printed in the transcript section.

C. Results are printed in an Out cell type.

You are a GIS analyst working on a Python script in ArcGIS Notebooks. Which action should you take to run all the lines of code in the notebook? A. Execute the notebook geoprocessing tool. B. Run the final notebook cell. C. Run all the notebook cells. D. Run the .py file in File Explorer.

C. Run all the notebook cells.

Which error type is related to the structure of a Python script? A. Composition B. Structure error C. Syntax error D. Exception

C. Syntax error

You are a GIS analyst using Python code to generate full addresses for a feature class with an address number (integer) and a street name (string). What code would you use to create a full address for the information below, which should read as "100 Main St"? addNum(integer) streetName(string) 100 Main A. fullAddress = addNum + streetName + St B. fullAddress = addNum + str(streetName) + "St" C. fullAddress = str(addNum) + " " + streetName + " St" D. fullAddress = str(addNum) + streetName + "St"

C. fullAddress = str(addNum) + " " + streetName + " St"

In the following example of the catalog path, what is the workspace, and what is the base name: C:\Data\study.gdb\final\streets

C:\Data\study.gdb\final is the workspace, and streets is the basename

What is the syntax do for the Calculate Field tool?

CalculateField(in_table, field, expression, {expression_type}, {code_block})

ArcPy functions are divided into tool functions and nontool functions. What are some distinctions between the two?

Calling tools requires the use of the toolbox alias or the module name, whereas nontool functions do not Tools produce geoprocessing messages, which can be accessed through a variety of functions. Nontool functions do not produce these messages Tools are licensed by license level (Basic, Standard, Advance) and by extension. The Tool Reference indicates the license level that is required for each tool. Nontool functions, on the other hand, are not licensed separately. All ArcPy nontool functions are available to use with ArcPy, independent of the license level The documentation is in different sections of ArcGIS Pro help. Tools are documented under Tool Reference. The documentation also can be obtained from the tool dialog box when running a tool in ArcGIS Pro. Nontool functions are documented only in the ArcPy documentation under the Python tab of the ArcGIS Pro help pages

What are type errors?

Code that doesn't make sense

What are syntax errrors?

Code that doesn't work with current programming language

What are name errors?

Code that tries to use something that doesn't exist

What are the two types of errors (in high-level results of running code)

Compilation errors and runtime errors

What are compilation errors?

Compilation errors are those that occur when compiling our code in the first place

What is the catch block?

Contains the code the computer should run if an expected error was encountered. Declares the type of error that should be expected

What is the general syntax for the Copy Features tool?

CopyFeatures(in_features, out_feature_class, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})

Which of the following is not a typical feature of an IDE? A) debugging tools, B) syntax highlighting, C) code autocompletion prompts, D) spell check, or E) syntax checking

D) Spell check

Which of the following is not part of the Geoprocessing Environment settings? A) processing extent, B) coordinate system for output, C) workspace for saving results, or D) automatically adding output dataset on open map

D) automatically adding output dataset on an open map

select the most appropriate scripting environment for each scenario. You would like to create and share a Python script for use in ArcGIS Pro, and the script needs to generate dynamic output and include comments that can be used as a guided narrative. A. IDE B. IDLE C. Python window in ArcGIS Pro D. ArcGIS Notebooks

D. ArcGIS Notebooks

Which of the following is (are) considered a catalog path that is (are) not recognized by Windows and Python, but only by ArcGIS (and ArcPy)? (check all that apply) A. D:\MyFiles\Projects\Network.shp B. C:\MyData\Mapping.gdb C. C:\Projects\Roads.dbf D. C:\Projects\Transportation.gdb\Roads E. C:\Catalog\Parcels.shp F. E:\Data\Catalog\Project.gdb\Parcels\Lotlines

D. C:\Projects\Transportation.gdb\Roads F. E:\Data\Catalog\Project.gdb\Parcels\Lotlines

Which of the following is not a correct approach to skip optional parameters when running a geoprocessing tool using ArcPy? A. Setting optional parameters to an empty string (""). B. Bypassing optional parameters by specifying the other parameters of interest by name. C. Setting optional parameters to the number sign (#). D. Creating a list of parameters and resorting the list so that skipped parameters are at the end.

D. Creating a list of parameters and resorting the list so that skipped parameters are at the end.

Scenario 1: Test attributes of a geoprocessing tool You are a GIS technician at a local nonprofit organization, and you have been asked to write a simple Python script to collect coordinate system information from layers in a map and display it on the screen. As a novice Python user, you would like to test a few approaches before committing to writing a Python script. Which scripting environment would be best for this scenario? A. IDE B. IDLE C. ArcGIS Notebooks D. Python window in ArcGIS Pro

D. Python window in ArcGIS Pro IDLEs can quickly test Python code, but it is not easy for working with map layers and GIS functionality as ArcGIS Pro integrated scripting environments ArcGIS Notebooks make is easy to work with map layers and GIS functionality, but it is not the best choice for quickly testing Python code. An IDE is not the best choice for quickly testing Python code, and it is not as easy for working with map layers and GIS functionality as ArcGIS Pro integrated scripting environments

Consider the following example code: import arcpy myshape = "C:/Data/Parcels.shp" Which of the following correctly creates a list of field objects of type integer? A. mylist = arcpy.ListFields("Integer") B. mylist = arcpy.listFields(myshape, "", "Integer") C. mylist = arcpy.ListFields(myshape, "Integer") D. mylist = arcpy.ListFields(myshape, "", "Integer") E. mylist = arcpy.listFields(myshape, "Integer") F. mylist = arcpy.listFields("Integer")

D. mylist = arcpy.ListFields(myshape, "", "Integer")

Consider a script that determines the spatial reference of a feature class: import arcpy fc = "C:/Data/City.gdb/parks" <missing lines of code> Which of the following correctly prints the name of the spatial reference? (check all that apply) A. sr = arcpy.SpatialReference(fc) print(sr.name) B. sr = arcpy.Describe(fc)["spatialReference"] print(sr.name) C. sr = arcpy.da.Describe(fc).spatialReference print(sr.name) D. sr = arcpy.da.Describe(fc)["spatialReference"] print(sr.name) E. sr = arcpy.Describe(fc).spatialReference print(sr.name) F. sr = arcpy.SpatialReference("C:/Data/City.gdb/parks.prj") print(sr.name)

D. sr = arcpy.da.Describe(fc)["spatialReference"] print(sr.name) E. sr = arcpy.Describe(fc).spatialReference print(sr.name)

What is debugging?

Debugging is a methodological process for funding errors in your script

What is debugging?

Debugging is the process of locating and reducing the number of defects or errors within our code. Trying to find out why your code isn't behaving the way you want it to

What is scope debugging?

Debugging small sections of a program to make sure things have run correctly so far

What does Exists() function determine (arcpy.Exists())?

Determines the existence of feature classes, tables, datasets, workspaces, layers, and other files

What are some common runtime errors?

Divide by Zero Errors (code that divides a value by zero) Null Errors (code containing a variable that has no value) Memory Errors (Code that surpasses your computer's memory)

How is each type of cursor created?

Each type of cursor is created by the corresponding class of the arcpy.da module: arcpy.da.SearchCursor, arcpy.da.InsertCursor, and arcpy.da.UpdateCursor.

which type of error occurs (syntax error or exception) with each of the Python code samples below. number = '5' string = ' shapes' print (number + text)

Exception

which type of error occurs (syntax error or exception) with each of the Python code samples below. import arpy

Excpetion

When you run a script and a geoprocessing tool fails to run for some reason (e.g. missing data, invalid parameters, not able to write the results, etc.), ArcPy throws a(n) ___exception.

ExecuteError

Consider the following code: import arcpy myprj = "c:/data/example.prj" spatialref = arcpy.SpatialReference(myprj) In the last line of code, myprj is a ___ of the SpatialReference ___. A. function, class B. function, module C. property, module D. property, class E. parameter, function F. parameter, class

F. parameter, class

False and False

False

True or False: All functions in ArcPy are geoprocessing tools in ArcGIS Pro.

False

True or False: Only point features may be created using cursors with Python.

False

True or False: Strings, numbers, and tuples are mutable

False

True or False: There is a function called ListGeodatases() to list all the geodatabases in a workspace

False

True or False: When using the Python window in ArcGIS, you should include the import arcpy statement before executing ArcPy functions.

False

What is the output of this code? print(7 > 7.0)

False

What is the result of this code? Not True and False

False

What is the result of this code? True and False

False

What is the result of this code? not True or False

False

What is the output of this code? print(not 1 == 1) print(not 1 > 7)

False, True

True or False: all the items in a single list are the same data type

False, although the items in a single list are typically the same data type, it is not required

True or False: Most of the time, debugging does tell you why a script did not run properly

False. Most of the time, debugging does not tell you why a script did not run properly, but it will tell you where- that is, on which line of code it failed

True or False: A stand-alone Python script does not have a current working directory

False: A stand-alone Python script has a working directory, which by default is the location of the script. Note that the path is a string variable.

What is functional programming?

Functional programming is a style of programming that (as the name suggests) is based around functions. A key part of functional programming is higher-order functions

What are decorators?

Functions that modify other functions

What is the output of this code? mytext = "GIS is cool" print(mytext.upper))

GIS IS COOL

What is geoprocessing?

Geoprocessing in ArcGIS Pro allows you to perform spatial analysis and modeling as well as automate GIS tasks

What is the output of this code? mytext = "GIS is cool" print(mytext.title))

Gis Is Cool

Python was created by

Guido van Rossum at the Centum voor Wiskunde en Informatica (CWI) in the Netherlands and was first released in 1991.

What error is caused by importing an unknown module?

ImportError

Different exceptions are raised for different reasons.Common exceptions:

ImportError: an import fails; IndexError: a list is indexed with an out-of-range number; NameError: an unknown variable is used; SyntaxError: the code can't be parsed properly; TypeError: a function is called on a value of an inappropriate type; ValueError: a function is called on a value of the correct type, but with an inappropriate value.

Consider the following example: point1 = arcpy.Point(0, 0) point2 = arcpy.Point(100, 100) array = arcpy.Array([point1, point2]) polyline = arcpy.Polyline(array) print(polyline.length) The result prints 141.4213562373095. Explain the Array object

In this example, the Array object is created using a list of two Point objects. Conceptually, an Array object is like a list, but it is used specifically to store Point objects instead of other types of elements. The Array object creates a single Polyline object. Because it is a geometry object, you can work with its properties, such as length. Because no spatial reference is set, the units of the length property are not defined.

Field crews have collected new sites and also collected new attributes for existing sites. Which type of cursor would be best to add the new sites and update the old attributes?

In this scenario, two cursors would need to be used: an Insert cursor for the new sites and an Update cursor for the existing sites that need to be updated.

Which type of error is the most likely to occur as a result of copying/pasting code from other file types, like Word, PDF or HTML?

Indentation

What are some common syntax errors and how would you fix them?

Indentation: Confirm that any code within a looping or conditional statement is indented and that the indents line up. Capitalization: Confirm that functions and statements, such as print and import, are using correct capitalization. Closures: Confirm that lists, strings, and other data types are enclosed by the appropriate characters (for example, brackets for lists and quotation marks for strings). Evaluations: Confirm that conditional statements (for example, if statements) use two equal signs to evaluate a value.

What are some common syntax errors?

Indentation: Python code uses indentations to group processes together and create structured hierarchies, such as a for loop statement and an if-else statement. Indentation errors occur when Python code is not properly indented. Capitalization: Python is a case-sensitive language. A capitalization error can occur when statements and functions are not lowercased. Closures: Data types like strings and lists must be enclosed in quotation marks and brackets. A closure error occurs when quotation marks are missing. Evaluations: Python uses the equal sign in different ways. A single equal sign (=) means that a variable is being assigned to a value. Two equal signs (==) signify that the values on both sides of the equal signs are being evaluated to see whether they are equal in value. An evaluation error occurs when an equal sign is missing from an evaluation statement.

What does the insertRow(row) method do in the cursor class da.InsertCursor?

Inserts a row object into the table

What does IDE stand for in the context of computer programming?

Integrated Development Environment

What is print debugging (tracing)?

Is where you instruct your program to print out its status throughout the run process

What is rubber duck debugging?

It was introduced by a book from 1999 entitled The Pragmatic Programmer, and it refers to a programmer who carried around a rubber duck to which to explain problems

ArcPy list functions include: ListFields() ListIndexes() ListDataset() and what other functions

ListFields() ListIndexes() ListDataset() ListFeatureClasses() ListFiles() ListRasters() ListTables() ListWorkspaces() ListVersions()

A programming technique used to execute a block of code multiple times is called ____.

Looping

Which construct can be used to iterate through a list? if statements Variable assignment Loops

Loops

How are maps accessed and that is the syntax?

Maps are accessed using the listMaps() method of the ArcGISProject class. This method returns a list of Map objects in a project. The syntax is ArcGISProject.listMaps({wild_card})

What is the try block of the error handling control structure?

Marks off the code in which an error is anticipated to arise. Its a block of code that is marked off to run if some other code didn't take place. It will always try to run and stop if an error is encountered.

What are some common exceptions?

NameError: NameErrors are caused by issues related to variable names. They are usually a result of a Python script attempting to use a variable name that has not been defined or that has been misspelled. TypeError: TypeErrors are a result of trying to use an inappropriate data type for a process that has rules regarding acceptable data types. Some examples include trying to concatenate a string and a number with the plus (+) operator, or performing mathematical operations like division with a string and a number. ImportError: ImportErrors arise from issues related to importing a library or module. Common issues include misspelling library or module names, or not including an import statement.

What is the result of this code? if 1 + 1 * 3 == 6: print("Yes") else: print("No")

No

What is the result of this code? x = 4 y = 2 if not 1 + 1 == y or x == 4 and 7 == 8: print("Yes") elif x > y: print("No")

No

Once a script creates an exclusive lock, the lock persists until the script releases the lock. What re the ways to release the lock?

Option 1: Using the cursor inside a with statement, which guarantees closure and release of database locks. This is the recommended approach. Option 2: Deleting the cursor explicitly by using a del statement. Option 3: Calling the reset() method on the cursor, which is available for the SearchCursor

What does this code do? for i in range(10): if not i % 2 == 0: print(i+1)

Print all the even numbers between 2 and 10

What are the three general types of debugging?

Print debugging, scope debugging, and rubber duck debugging

What does the SearchCursor do?

Provides read-only access to the input data. This cursor allows you to search a table and return values. It can be iterated by using a for loop statement or a with statement which resets iteration and removes data locks. arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause}, {datum_transformation})

What does the UpdateCursor do?

Provides read-write access to feature classes or tables. This cursor allows you to update or delete values. It can be iterated by using a for loop statement or a with statement which resets iteration and removes data locks. arcpy.da.UpdateCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause}, {datum_transformation})

What does the InsertCursor provide?

Provides write-access to a feature class or table. This cursor allows you to insert new rows or add new features. It can use geometry tokens to create new point, line, or polygon features in a feature class or adds new rows of data to a table arcpy.da.InsertCursor(in_table, field_names, datum_transformation)

What does PyPI stand for

Python Package Index

Many third-party Python modules are stored on the ______. And the best way to install these is using a program called

Python Package Index (PyPI), pip

A ____ includes a specific version of Python and any packages that are installed

Python environment

What does the deleteRow() method do in the cursor class da.UpdateCursor?

Remove the row from the table

list.remove(item):

Removes an object from a list

What does the reset() method do in the cursor class da.SearchCursor?

Resets the cursor back to the first row

What does the reset() method do in the cursor class da.UpdateCursor?

Resets the cursor back to the first row

Consider the following code: import arcpyarcpy.env.workspace = "C:/Data"mycount = arcpy.GetCount_management("streams.shp") What data type is mycount?

Result

Consider the following code: import arcpy arcpy.env.workspace = "C:/Data"mycount = arcpy.GetCount_management("streams.shp") What data type is mycount?

Result

list.count(item):

Returns a count of how many times an item occurs in a list

min(list):

Returns the list item with minimum value

max(list):

Returns the list item with the maximum value

list.reverse():

Reverses items in a list.

What are the debugging approaches for Exceptions?

Review the error message Resolve exceptions using: Pseudocode Commented code Print function

What are the debugging approaches for syntax errors?

Review the message Fix and find structural issues in your Python code

You want to include the Roads feature class as the second input parameter in a script tool. What code snippet would change the Roads feature class from a hard-coded value to a value that could be input dynamically?

Roads = arcpy.GetParameterAsText(1)

What are runtime errors?

Runtime errors occur when actually running the code

The basic structure of a SQL statement used in ArcGIS Pro is

SELECT * FROM <table> WHERE <condition> This basic structure selects records from a database table. The wildcard * means all fields are included by default, and the condition is the WHERE clause.

Which cursors have optional arguments?

Search and update cursors

You have added a fire hydrants feature class into ArcGIS Pro and want to read the Water_Pressure attribute from each hydrant. Which type of cursor would be best for reading the attributes?

Search cursor

The Data Access module provides three types of cursors. What are they?

SearchCursor, UpdateCursor, InsertCursor

What re some of the commonly used list functions in ArcPy.

See image. In addition, the result of each of these functions is a Python list, which is an ordered, changeable list of values enclosed by square brackets. After you have created a list, you can create a for loop to access each individual value

What is the generic syntax of the Select tool?

Select(in_features, out_feature_class, {where_clause})

What is selectively commenting out

Selectively commenting out code involves removing certain lines to see if this eliminates the error

which type of error occurs (syntax error or exception) with each of the Python code samples below. list = ["apple", "banana", "strawberry"] for item in list: if item = "apple": list.remove(item) else: pass

Syntax error

which type of error occurs (syntax error or exception) with each of the Python code samples below. numbers = [1, 3, 5, 7, 9] numSquared = [] for number in numbers: if number > 3: numSquared.append(pow(number, 2)) else: pass

Syntax error

which type of error occurs (syntax error or exception) with each of the Python code samples below. text = "This is a string

Syntax error

This sample Python script contains two syntax errors and two exceptions. What would fix the errors for the script in the left-hand column. #Assign variables numbers = [-2, -1, '0', 1, 2 posNumbers = [] #Add positive numbers to a new list for number in numbers: if number > 0: negNumbers.append(number) else: pass

Syntax error: numbers = [-2, -1, '0', 1, 2 Solution: Add a bracket to the end of the line Syntax error: negNumbers.append(number) Solution: Add indentation before the line of code TypeError exception: numbers = [-2, -1, '0', 1, 2 Solution: Remove the quotation marks from the 0 value NameError exception: negNumbers.append(number) Solution: Change the variable name from negNumbers to posNumbers

What are three types of compilation errors?

Syntax errors, name errors, type errors

Displaying code using different colors to indicate the different types of elements in code is an example of ____.

Syntax highlighting

What is the difference between system paths and catalog paths?

System paths are the paths recognized by the Windows operating system and catalog paths are the paths that only ArcGIS Pro recognizes

The Python window is split into two sections. What are they?

The Python window is split into two sections: the transcript and the Python prompt

Consider the following code for the SearchCursor: import arcpy fc = "C:/Data/study.gdb/roads" cursor = arcpy.da.SearchCursor(fc, "STREET_NAME") for row in cursor: print("Street name = {0}".format(row[0])) Why would you use row[0] instead of row?

The SearchCursor object returns a tuple of values. Therefore, you must use index zero[0] to obtain the first (an only) element of the tuple

What name is given to Python's preinstalled modules?

The Standard Library

What does the arcpy.ValidateFieldName() function do?

The ValidateFieldName() function takes a field name and a workspace and returns a valid field name for the workspace. Invalid characters are replaced by an underscore

What happens if you open a file in write mode and then immediately close it?

The file contents are deleted

What is the GetParameterAsText index number of the first parameter in your script?

The first parameter is index(0), which is the Lakes feature class.

What is geoprocessing framework?

The geoprocessing framework in ArcGIS Pro consists of a set of windows and dialog boxes to organize and execute tools. This framework makes it easy to create, execute, manage, document, and share geoprocessing workflows.

What is the goal of debugging?

The goal of debugging is to get the information necessary to locate and fix the error

What does it mean when a tool (or other element) does not have a fill color in ModelBuilder but is shown in grey?

The model is not ready to run

The script tool has a front-end interface that resembles system _______ ; that enables the tool to be run like other _________, but it also requires you to configure inputs, outputs, and other parameters. After you have configured your Python script tool, you can open it from the Catalog pane, use it in ______ or the ModelBuilder or the Python window, or call it like other _________ in ArcGIS Notebooks or external scripting environments, such as IDEs

The script tool has a front-end interface that resembles system geoprocessing tools; that enables the tool to be run like other geoprocessing tools, but it also requires you to configure inputs, outputs, and other parameters. After you have configured your Python script tool, you can open it from the Catalog pane, use it in ModelBuilder or the Python window, or call it like other geoprocessing tools in ArcGIS Notebooks or external scripting environments, such as IDEs.

What part of an if statement should be indented?

The statements within it

Snippet

The term snippet is used in programming to indicate a small portion of code, typically a few lines long

There are three common structures for error handling. What are they?

The try, the catch, and the finally

What are the two approaches to obtain Map objects?

The two approaches to obtain Map objects are the ArcGISProject.listMaps() method and the MapFrame.map property. The former returns a list of maps, whereas the latter returns a single map

What is dot.notation?

The use of a period is called dot notation. It indicates that what comes after the dot belongs to what comes before the dot.

What are exceptions in programming?

There might be errors, or there may simply be events you did not anticipate. These events are called exceptions. Exceptions refer to errors that are detected while the script is running. When an exception is detected, the script stops running unless the exception is handles properly

When working with cursors, which statement best describes how you should treat the cursor variables in your script?

These variables should be deleted; otherwise, applications could be prevented from accessing the data.

What is the arcpy.da.Walk() function?

This is a function of the data access module, and it is specifically designed to "walk" up and down the folder and database structure

Since a Point object is not a geometry object and can be used to construct geometry. How is this task accomplished?

This task can be accomplished using the PointGeometry class. The general syntax of this class is arcpy.PointGeometry(inputs, {spatial_reference}, {has_z}, {has_m}) Note that this syntax is identical to the syntax of the Geometry class except for the geometry parameter, which is implicit in the type of geometry object for this class—i.e., a point feature. The PointGeometry class has a spatial reference parameter.

True or False: To ensure some code runs no matter what errors occur, you can use a finally statement.

Tru

List comprehension. True or False: the following are the same: for <item> in <list>: <expression> [expression. for <item> in <list>]

True

Records in a table are referred to as rows

True

The only methods that work on tuples are count() and index() because these methods do not modify the sequence of elements

True

True of False: The following is the syntax for setting the property of a class in ArcPy: arcpy.<classname>.<property> = <value>

True

True or False every installation of Python includes IDLE as a default IDE to write and run Python code.

True

True or False, the history pane allows you to review the messages that resulted from previously executed tools.

True

True or False, when creating the dictionary the keys must be unique

True

True or False: z = "Alphabet Soup" print(z[0:8]) returns the characters with the index numbers from 0 up to, but not including, 8, and therefore the result is Alphabet

True

True or False: A Point object is not a geometry object, but it can be used to construct geometry

True

True or False: A common error is to include the del statement inside an earlier iteration, which deletes the variable before the iteration over all the rows is completed.

True

True or False: A cursor can be used to iterate over the records in a table or to insert new records into a table

True

True or False: A cursor object allows you to access rows in a table. Cursors can be used both to read and write attribute and geometry values.

True

True or False: A dict is unordered

True

True or False: A list comprehension can also contain an if statement to enforce a condition on values in the list.

True

True or False: A list comprehension in Python is a concise way to create a list by iterating over an iterable object. It provides compact syntax that is just like a for loop

True

True or False: A list consist of zero or other elements in a fixed order.

True

True or False: A script tool is built using Python code, and it can be stored within a standard toolbox or a Python toolbox.

True

True or False: A single # is typically used for permanent comment by the author of the script to explain something about the code, whereas a double # symbol is used for temporarily commenting out lines of code during the testing process

True

True or False: A stand-alone Python script is stored as a file with a .py file extension.

True

True or False: A string is created by entering text between two single or double quotation marks

True

True or False: A try statement can have multiple different except blocks to handle different exceptions.

True

True or False: A useful dictionary method is get. It does the same thing as indexing, but if the key is not found in the dictionary it returns another specified value instead ('None', by default).

True

True or False: A workspace is required because you cannot pass a path to the list functions in ArcPy

True

True or False: Adding "b" to a mode opens it in binary mode, which is used for non-text files (such as image and sound files).

True

True or False: Additional keywords can be added to the SQL statement - for example, ORDER BY such as SELECT * FROM <table> WHERE <condition> ORDER BY <field>

True

True or False: All messages have a severity property. This property is an integer with a value 0 (information), 1 (warning), or 2 (error)

True

True or False: Although the generic Geometry class can create any type of geometry, ArcPy has four other geometry classes: MultiPoint, PointGeometry, Polygon, and Polyline. In addition, ArcPy uses two other classes to assist with constructing geometry: Array and Point.

True

True or False: An alternative approach to closing a file is to use a with statement, which takes the following form: with open(<file>) as <variable>: <code to process file> The with statement automatically closes the file once the with block of code is completed, even in the case of errors. There is no need to use the close() method in this case. As a result, the use of with statements is highly recommended when opening files. It results in cleaner code and facilitates handling errors.

True

True or False: An alternative way to access maps is to use a MapFrame object.

True

True or False: An empty dictionary is defined as {}.

True

True or False: An enterprise geodatabase is referred to as ".sde"

True

True or False: An except statement without any exception specified will catch all errors.

True

True or False: Any statement that consists of a word followed by information in parentheses is a function call.

True

True or False: ArcGIS Notebooks are docked to the view pane of the ArcGIS Pro interface.

True

True or False: ArcGISProject.listMaps() always returns a list of Map objects, even if the list contains only a single map

True

True or False: ArcPy includes several classes to work with geometry objects. The most basic is the Point class, which is the equivalent of a single vertex and is used to create all other geometry objects. Polyline and polygon features consist of multiple vertices and are constructed using two or more Point objects.

True

True or False: ArcPy provides several functions that are not tools. Functions can list datasets, retrieve properties of a dataset, check for the existence of data, validate names of datasets, and perform many other useful tasks. These functions are designed for Python workflows, and therefore are available only in ArcPy and not as tools in ArcGIS Pro. These functions are sometimes referred to as nontool functions

True

True or False: ArcyPy returns the output of a tool as a Result object. When the output of a tool is a new or updated feature class, the Result object includes the path to the dataset. For other tools, however, the Result object can consists of a string, a number, or a Boolean value

True

True or False: AssertionError exceptions can be caught and handled like any other exception using the try-except statement, but if not handled, this type of exception will terminate the program.

True

True or False: Bad, repetitive code is said to abide by the WET principle, which stands for Write Everything Twice, or We Enjoy Typing.

True

True or False: Basic error-handling procedures include checking whether data exists, determining whether data inputs are the right type, checking for licenses and extensions, and validating table and field names. Typically, an if statement is used for this type of error handling.

True

True or False: Basic uses of sets include membership testing and the elimination of duplicate entries.

True

True or False: Both warning and error messages are accompanied by a six-digit ID code. The ID codes are documented, and the description of each ID code may be helpful in identifying the causes of potential problems and how they can be dealt with

True

True or False: By default, Python assumes you are dealing with text files, which contain characters. If you are working with some other kind of file such as an image, you can add b to the mode—for example, "rb".

True

True or False: By default, the new rows are inserted at the bottom of the table. And fields in the table that are not included in the cursor are assigned the field's default value.

True

True or False: By identing a line, the code becomes a block

True

True or False: CSV files can be used in Python scripts by using the built-in csv module

True

True or False: CSV files represent a widely used alternative to text files when working with tabular data. Python's built-in csv module can be used to read the contents of CSV files.

True

True or False: Certain functions, such as int or str, return a value that can be used later. To do this for your defined functions, you can use the return statement.

True

True or False: Classes in ArcPy are used to create objects. Commonly used classes the env class and the SpatialReference class

True

True or False: Code in a finally statement even runs if an uncaught exception occurs in one of the preceding blocks.

True

True or False: Comments are annotations to code used to make it easier to understand. They don't affect how code is run.

True

True or False: Compound statements in Python contain a group of statements or a block, and these blocks are created using indentation

True

True or False: Creating a custom class is at the top of the script because any classes must be defined before they can be used

True

True or False: Cursors are used to iterate over rows in a table

True

True or False: Cursors can be used to iterate over a set of rows in a table and search, insert, or update the data in the rows. A common use is to read existing geometries and write new geometries in feature data. The cursors can be used to correct data in existing datasets or to update the data with new information.

True

True or False: Cursors can iterate over rows in a table. Iteration is typically accomplished using a for loop or a with statement.

True

True or False: Cursors can iterate over the records in a table using a for loop or a while loop

True

True or False: Cursors honor layer definition queries and selections.

True

True or False: Custom classes can be used to create many different objects, not just exceptions

True

True or False: Decorators provide a way to modify functions using other functions.This is ideal when you need to extend the functionality of functions that you don't want to modify.

True

True or False: Describe() function returns a Describe object that contains the properties of the dataset. These properties can be accessed using the <object>.<property> notation

True

True or False: Dictionaries are data structures used to map arbitrary keys to values.Lists can be thought of as dictionaries with integer keys within a certain range.Dictionaries can be indexed in the same way as lists, using square brackets containing keys.

True

True or False: Dictionaries are not sequences, and the elements are not ordered

True

True or False: Docstrings (documentation strings) serve a similar purpose to comments, as they are designed to explain code. However, they are more specific and have a different syntax. They are created by putting a multiline string containing an explanation of the function below the function's first line

True

True or False: Due to the fact that they yield one item at a time, generators don't have the memory restrictions of lists.In fact, they can be infinite!

True

True or False: Each feature in a feature class consists of vertices

True

True or False: Each row retrieved from a table by using a cursor is returned as a list (or tuple) of field values, in the same order as specified by the field_names argument

True

True or False: Error messages for exceptions may display more information overall about the issue, but they do not always relay information, such as with syntax error messages, that can help pinpoint the issue. To narrow down potential root causes of exceptions, you can employ three methods: review pseudocode, comment out code, and use print functions.

True

True or False: Errors encountered during the execution of your script are called exceptions.

True

True or False: Even is a custom toolbox has been added to a project in ArcGIS Pro, Python is not aware of this toolbox until it is imported

True

True or False: Exceptions are raised automatically when something goes wrong while running a script. You can also raise exceptions yourself by using the raise statement

True

True or False: Exceptions are said to be "thrown," as in "the script throws an exception."

True

True or False: Exceptions in a script can be handled - that is, caught or trapped - using a try-except statement

True

True or False: Fields cannot be added unless their name is valid, so unless field names are validated first, a script may fail during execution

True

True or False: Finite generators can be converted into lists by passing them as arguments to the list function.

True

True or False: Function arguments can be used as variables inside the function definition. However, they cannot be referenced outside of the function's definition. This also applies to other variables created inside a function.

True

True or False: Function parameters are also called arguments

True

True or False: Function syntax begins with the name of the function and is followed by its parameters, which are enclosed in parentheses.

True

True or False: Functional programming seeks to use pure functions. Pure functions have no side effects, and return a value that depends only on their arguments.

True

True or False: Functions can also be used as arguments of other functions.

True

True or False: Generators are a type of iterable, like lists or tuples.Unlike lists, they don't allow indexing with arbitrary indices, but they can still be iterated through with for loops.They can be created using functions and the yield statement.

True

True or False: Geometry objects (and their vertices) of an existing feature class can be accessed using a search cursor.

True

True or False: Geometry objects are often used to carry out tasks in memory instead of creating a new temporary feature class or modifying existing feature classes

True

True or False: Geometry objects often are used to carry out tasks in memory instead of creating a new temporary feature class or modifying existing feature classes.

True

True or False: GetParameterAsText is zero-based, meaning that the first parameter is specified as GetParameterAsText(0). The second parameter is GetParameterAsText(1), and so on.

True

True or False: If a negative value is used for the step, the slice is done backwards.Using [::-1] as a slice is a common and idiomatic way to reverse a list.

True

True or False: If no mode argument is provided, the read mode is used by default

True

True or False: If the first number in a slice is omitted, it is taken to be the start of the list.If the second number is omitted, it is taken to be the end.

True

True or False: If you are not using a with statement, forgetting to use the del statement at the end of a script can lead to errors, so be sure to include it after using insert and update cursors. Using the del statement is not required after using search cursors because they do not result in an exclusive lock.

True

True or False: If you have a need to start a new project from scratch in your scripts, a workaround is to author a basic template project in ArcGIS Pro. This project would contain only the minimal elements—i.e., at least one map and one layout, and you can then manipulate the contents using arcpy.mp.

True

True or False: Importing is accomplished using the arcpy.ImportToolbox() function

True

True or False: In ArcGIS Pro, it is possible to have multiple maps that use the same name. Identical names become confusing when trying to reference maps in Python, and therefore it is important to uniquely name each map so they can be referenced using the name property.

True

True or False: In ArcGIS Pro, remember to use a toolbox alias to call geoprocessing tools. Calling a tool by name only will produce an error

True

True or False: In ArcGIS Pro, the Exists() function returns a Boolean value

True

True or False: In ArcGIS Pro, the SpatialReference object is used in the Define Projection tool to specify the coordinate system

True

True or False: In ArcGIS Pro, the Usage() function is a useful shortcut for getting the syntax of ArcPy functions without relying on the pop-ups in the Python windows.

True

True or False: In Python, a comment is created by inserting an octothorpe (otherwise known as a number sign or hash symbol: #). All text after it on that line is ignored.

True

True or False: In Python, an iterable object (or simply an iterable) is a collection of elements that you can loop (or iterate) through one element at a time

True

True or False: In Python, strings, are, by default, Unicode strings

True

True or False: In a scripting environment, the ArcGISProject object uses the save() and saveACopy() methods. The saveACopy() method accomplishes the same thing as the Save As option in the ArcGIS Pro application

True

True or False: In addition to using pre-defined functions, you can create your own functions by using the def statement.

True

True or False: In the Calculate Field tool, the Python 3 expression type does not refer to Python version 3 but is simply a reference to the fact that this is the third version of Python expression types in ArcGIS Pro

True

True or False: Indexing returns the value of the element, and slicing returns a new list

True

True or False: Insert and update cursors apply an exclusive lock to a table or feature class, preventing other process from making changes

True

True or False: Insert and update cursors support editing operations, and as a result, a lock is set on the table when the cursor object is created

True

True or False: Integers have no length

True

True or False: It is common to use the for loop when the number of iterations is fixed. For example, iterating over a fixed list of items in a shopping list.

True

True or False: Just like lists, dictionary keys can be assigned to different values.However, unlike lists, a new dictionary key can also be assigned a value, not just ones that already exist.

True

True or False: Lambda functions can be assigned to variables, and used like normal functions.

True

True or False: Like lists and dictionaries, tuples can be nested within each other.

True

True or False: Like the ValidateTableName() function, the ValidateFieldName() function does not determine whether the field name exists, so a script could still fail, or an existing field could still be overwritten. To determine whether a field name exists, the ListFields() function creates a list of the fields in a table or feature class, and the new field name can be compared against this list.

True

True or False: Like the arguments to range, the first index provided in a slice is included in the result, but the second isn't.

True

True or False: List comprehensions provide a concise alternative to regular for loops when working with lists

True

True or False: List functions exist for different types of elements, including workspaces, files, datasets, feature classes, fields, rasters, tables, and others

True

True or False: List functions facilitate batch processing

True

True or False: List slices can also have a third number, representing the step, to include only alternate values in the slice.

True

True or False: List slices provide a more advanced way of retrieving values from a list. Basic list slicing involves indexing a list with two colon-separated integers. This returns a new list containing all the values in the old list between the indices.

True

True or False: Listing all the data elements is complicated by different data formats and subfolder structures. To facilitate working with more complex situations, you can use the da.Walk() function to "walk" up and down the folder and database structure to obtain all the elements inside a folder

True

True or False: Lists are mutable - unlike strings, lists can be modified in place by assignment to offsets as well as a variety of list method calls

True

True or False: Lists are positionally ordered collections of arbitrarily typed objects, and they have no fixed size

True

True or False: Lists, tuples, dictionaries, and sets are all iterable objects

True

True or False: Looping statements allow you to automate the same task for several items at the same time

True

True or False: Loops are often controlled by sentry variables. Another name for a sentry variable is a loop variable. A sentry or loop variable is a variable used in the condition and it is compared to some other value or values.

True

True or False: Messages that result from running a tool can be retrieved using message functions, including GetMessages(), GetMessage(), and GetMaxSeverity().

True

True or False: Modules are pieces of code that other people have written to fulfill common tasks, such as generating random numbers, performing mathematical operations, etc.

True

True or False: Most updates or insertions to a table are done in ArcGIS outside of an edit session. Changes made outside of an edit session are permanent and cannot be undone. Simultaneous editing and updates to versioned data are tasks that require an edit session.

True

True or False: Multiple exceptions can also be put into a single except block using parentheses, to have the except block handle all of them.

True

True or False: Nearly all geoprocessing tools in ArcGIS Pro are functions in ArcPy, but not all ArcPy functions are geoprocessing tools in ArcGIS Pro

True

True or False: Negative values can be used in list slicing (and normal list indexing). When negative values are used for the first and second values in a slice (or a normal index), they count from the end of the list.

True

True or False: New features are created using the InsertCursor class of the arcpy.da module. This process requires creating a geometry object, and then saving the result as a feature using the insertRow() method.

True

True or False: New features can be created using an insert cursor on a feature class or by using a geoprocessing tool to copy geometry objects to a new feature class. Features are constructed from vertices, which are created using Point objects. Coordinates can be entered directly into a script or read from a file to create Point objects. To create polyline and polygon features, multiple Point objects are combined into an Array object.

True

True or False: None is a Python keyword and is used to define a null value or no value at all. It is not the same thing as an empty string, but it has the same effect in the context of setting parameters for a tool

True

True or False: Not all valid workspaces in ArcGIS Pro are recognized by the Windows operating system, and as a result, the workspace in a geoprocessing script should be set using: arcpy.env.workspace

True

True or False: Often used in conditional statements, all and any take a list as an argument, and return True if all or any (respectively) of their arguments evaluate to True (and False otherwise).The function enumerate can be used to iterate through the values and indices of a list simultaneously.

True

True or False: Once a file has been opened and used, you should close it.This is done with the close method of the file object.

True

True or False: Once you return a value from a function, it immediately stops being executed. Any code after the return statement will never happen.

True

True or False: One of the advantages of Result objects is that you can keep track of information about the running of tools . This includes not only the output, but also messages and parameters

True

True or False: Only immutable objects can be used as keys to dictionaries. Immutable objects are those that can't be changed.

True

True or False: Points, polylines, and polygons are examples of geometry objects. You can work with geometry objects and their properties by setting a cursor on the Shape field of a feature class. You can work with the full geometry object (i.e., SHAPE@), including all its properties such as length and area, but you also can use geometry tokens (e.g., SHAPE@) as shortcuts to specific properties.

True

True or False: Polyline and polygon features consist of multiple vertices and are constructed using two or more Point objects. To facilitate working with multiple Point objects, ArcPy uses the Array class. This class is created specifically to construct polyline and polygon geometry objects.

True

True or False: Python doesn't have general purpose multiline comments, as do programming languages such as C.

True

True or False: Python is a zero-based language

True

True or False: Python is also used to write expressions in the Calculate Field tool. This includes basic expressions to calculate field values on the basis of another existing field, as well as more complex calculations using custom functions in a code block.

True

True or False: Python provides support to wrap a function in a decorator by pre-pending the function definition with a decorator name and the @ symbol.

True

True or False: Python syntax is case sensitive, for the most part

True

True or False: Python's strings come with Unicode support required for processing text in internationalized character sets

True

True or False: Reading geometries can be accomplished using a search cursor. Specific approaches are necessary to read the properties of multipart features and polygons with holes.

True

True or False: Recursion can also be indirect. One function can call a second, which calls the first, which calls the second, and so on. This can occur with any number of functions.

True

True or False: Recursion is a very important concept in functional programming.The fundamental part of recursion is self-reference - functions calling themselves. It is used to solve problems that can be broken up into easier sub-problems of the same type.

True

True or False: Returning to Python and ArcPy, the cursor classes support only a limited number of SQL keywords. DISTINCT and TOP are prefix clauses, and ORDER BY and GROUP BY are postfix clauses.

True

True or False: SQL expressions are not limited to search cursors and are used in tools such as Select

True

True or False: SQL expressions in Python can query data using search cursors. Queries carried out using SQL in Python use a WHERE clause. Proper syntax of queries is facilitated using the AddFieldDelimiters() function. Other supported SQL clauses include DISTINCT, GROUP BY, ORDER, and TOP.

True

True or False: SQL queries can be carried out in Python using the SearchCursor class

True

True or False: Sequences are an example of iterables, which includes strings, lists, and typles

True

True or False: Sets are data structures, similar to lists or dictionaries. They are created using curly braces, or the set function. They share some functionality with lists, such as the use of in to check whether they contain a particular item.

True

True or False: Sets can be combined using mathematical operations. The union operator | combines two sets to form a new one containing items in either. The intersection operator & gets items only in both. The difference operator - gets items in the first set but not in the second. The symmetric difference operator ^ gets items in either set, but not both.

True

True or False: Sets differ from lists in several ways, but share several list operations such as len.They are unordered, which means that they can't be indexed. They cannot contain duplicate elements. Due to the way they're stored, it's faster to check whether an item is part of a set, rather than part of a list. Instead of using append to add to a set, use add. The method remove removes a specific element from a set; pop removes an arbitrary element.

True

True or False: Setting a cursor on geometry is accomplished by using a geometry token instead of a field name

True

True or False: Setting the workspace has no effect and produces an error unless the script resides in the same folder as the .aprx file. In other words, a reference such as arcpy.mp.ArcGISProject("Study .aprx") works only if the script and the .aprx file are in the same folder. Otherwise, you must provide the full path.

True

True or False: Several functions are available to check available licenses for products and extensions, to check out licenses, and to check licenses back in

True

True or False: Similar to while loops, the break and continue statements can be used in for loops, to stop the loop or jump to the next iteration.

True

True or False: Slicing can also be done on tuples.

True

True or False: Splitting the fully qualified name for a dataset into its components is commonly referred to as parsing

True

True or False: Stand-alone scripts can incorporate GIS functionality outside of ArcGIS Pro, but they need to import ArcPy or ArcGIS API for Python to access this functionality.

True

True or False: Strings can be sliced into smaller things

True

True or False: Syntax errors and exceptions require different debugging approaches. Syntax errors are caused by structural issues, and they are encountered before a script can run. If your script fails to execute, begin by reviewing your Python code for syntax errors. If you have resolved, or did not encounter, any syntax errors, and your script fails while executing, you need to look for exceptions.

True

True or False: Syntax errors prevent code from running in the first place

True

True or False: Table and field names can be parsed into separate elements using the ArcPy parsing functions ParseTableName() and ParseFieldName().

True

True or False: Table and field names can be validated using the ValidateTableName() and ValidateFieldName() functions, respectively. These functions convert all invalid characters into an underscore (_). The CreateUniqueName() function can create a unique name by adding a number to an existing name

True

True or False: Technically, parameters are the variables in a function definition, and arguments are the values put into parameters when functions are called.

True

True or False: The ArcGIS Pro geoprocessing environment always uses the fully qualified names for feature classes and tables. For example, to process a feature class called roads, a geoprocessing tool must know not only the name, but also the path, the name of the database, and the owner of the data. This information is essential when working with geodatabases.

True

True or False: The ArcGISProject() function an ArcGISProject object. In other words, ArcGISProject is both a function and a class of the arcpy.mp module

True

True or False: The ArcPy data access module, arcpy.da, provides support for editing and working with cursors to manipulate data.

True

True or False: The ArcPy mapping module allows you to reference and manipulate .aprx files, in addition to layer files (.lyrx), which contain properties for individual layers.

True

True or False: The ArcPy mapping modules is referred to as arcpy.mp

True

True or False: The ArcPy parsing functions are specifically designed to work with geodatabases and are therefore more robust.

True

True or False: The DISTINCT keyword selects only distinct (i.e., unique) values and removes any duplicates. DISTINCT is a prefix clause that can be used in combination with a postfix clause: such as sql = ("DISTINCT", "ORDER BY STREET_NAME")

True

True or False: The Describe function returns a Describe object that contains properties, such as data type, fields, indexes, and many others. Its properties are dynamic, meaning that, depending on what data type is described, different properties will be available for use. For example, describing a raster dataset will return raster-specific properties, such as the number of bands and the raster format.

True

True or False: The Describe() function returns a Describe() object, and you can use the object to check its properties, such as the data type

True

True or False: The ListFields() function returns a list of Field objects. A field object represents a column in a table

True

True or False: The None object is returned by any function that doesn't explicitly return anything else.

True

True or False: The None object is used to represent the absence of a value.It is similar to null in other programming languages.Like other "empty" values, such as 0, [] and the empty string, it is False when converted to a Boolean variable.When entered at the Python console, it is displayed as the empty string.

True

True or False: The ORDER BY keyword comes after the WHERE clause and is referred to as a postfix clause.

True

True or False: The SHAPE@ token gives access to the full geometry object and all its properties

True

True or False: The arcpy .ValidateTableName() function obtains a valid table name for a specific workspace.

True

True or False: The arcpy.GetParameterAsText function allows your script to accept dynamic input and assign these input values to the variables in your script

True

True or False: The argument of the open function is the path to the file. If the file is in the current working directory of the program, you can specify only its name.

True

True or False: The assert can take a second argument that is passed to the AssertionError raised if the assertion fails.

True

True or False: The base case acts as the exit condition of the recursion.

True

True or False: The buffering parameter controls the buffering of the files. When buffering is used, Python may use memory instead of disk space to improve performance

True

True or False: The built-in functions map and filter are very useful higher-order functions that operate on lists (or similar objects called iterables).The function map takes a function and an iterable as arguments, and returns a new iterable with the function applied to each argument.

True

True or False: The contents of a file that has been opened in text mode can be read using the read method.

True

True or False: The contents of text files can be manipulated in Python. The open() function creates a file object, and several methods can be used to read and write text, including read(), readline(), readlines(), write(), and writelines(). One of the more common operations on files is to iterate over their lines to perform the same manipulation repeatedly, such as replacing strings to make the text files more usable.

True

True or False: The design principle of the arcpy.mp module is that projects and their contents are authored using the ArcGIS Pro application and that arcpy.mp is then used to automate repetitive tasks, such as modifying map properties, adding layers, applying symbology, and exporting layouts.

True

True or False: The elements of a list can be anything, such as a number (int), strings (str), and even other lists

True

True or False: The finally statement is placed at the bottom of a try/except statement. Code within a finally statement always runs after execution of the code in the try, and possibly in the except, blocks.

True

True or False: The for loop always ends with a colon, which indicates that you want to perform an action for each item in the list. The indented line of code indicates that this action will loop through the list and execute for each individual item. Lines of code that are not indented will not be included in the loop.

True

True or False: The for loop can be used to iterate over strings.

True

True or False: The for loop is commonly used to repeat some code a certain number of times. This is done by combining for loops with range objects.

True

True or False: The function enumerate can be used to iterate through the values and indices of a list simultaneously.

True

True or False: The function filter filters an iterable by removing items that don't match a predicate (a function that returns a Boolean).

True

True or False: The if-else statement allows you to perform tasks based on a specific logic condition

True

True or False: The importDocument() method makes it possible to import map documents (.mxd files), globe documents (.3dd files), and scene documents (.sxd) into a project.

True

True or False: The main disadvantage of using only pure functions is that they majorly complicate the otherwise simple task of I/O, since this appears to inherently require side effects

True

True or False: The module itertools is a standard library that contains several functions that are useful in functional programming.One type of function it produces is infinite iterators.The function count counts up infinitely from a value.The function cycle infinitely iterates through an iterable (for instance a list or string).The function repeat repeats an object, either infinitely or a specific number of times.

True

True or False: The order of the list of maps is the same as the order used in ArcGIS Pro, which is alphabetical

True

True or False: The primary purpose of the arcpy.mp module is to manipulate the contents of existing projects (.aprx) and layer files (.lyrx). This includes working with maps, layers, and tables; applying symbology; and managing layouts

True

True or False: The properties of an ArcGISProject object include basic descriptive properties such as activeMap (the map associated with the focused view), dateSaved (the last date the project was saved), documentVersion (the version of the document when it was last saved), and filePath (the full project path and file name). These properties are all read-only. Several other properties are read and write, including defaultGeodatabase (the project's default geodatabase location), defaultToolbox (the project's default toolbox), and homeFolder (the project's home folder location).

True

True or False: The properties of the Describe() object are dynamic

True

True or False: The reset() method is available only for the search and update cursors of arcpy.da. It resets the cursor back to the first row. This reset makes it possible to perform a second iteration using the same cursor. This task is not common because most tasks require only a single iteration.

True

True or False: The result class has several advantages over calling message functions, most notably the fact that messages can be maintained after running multiple tools. The result class also has several additional properties and methods, including options to count the number of outputs and the ability to work with specific outputs form a geoprocessing tool

True

True or False: The return statement cannot be used outside of a function definition.

True

True or False: The spatial reference can be set on cursors to work with geometries in a coordinate system that is different from that of the feature class.

True

True or False: The spatial reference is not part of the Point class

True

True or False: The syntax for running a tool is arcpy.<toolname_toolboxalias>(<parameters>)

True

True or False: The syntax for setting the property of a class is <arcpy.<classname>.<proeprty> = <value>

True

True or False: The try block contains code that might throw an exception. If that exception occurs, the code in the try block stops being executed, and the code in the except block is run. If no error occurs, the code in the except block doesn't run.

True

True or False: The try-except statement also can include an else statement, which is like a conditional statement

True

True or False: The underlying logic is that a cursor is set to iterate over all the records in a table but using only a few specific fields that are needed for a given task. This feature limits the amount of processing needed when using cursors

True

True or False: The update cursor updates or deletes the row at the current position of the cursor

True

True or False: The updateRow() method updates the row. After a row object is retrieved from the cursor, the row is modified as needed, and the modified row is passed to the table by calling the updateRow() method

True

True or False: The use of the sql_clause parameter does not exclude the use of the where_clause parameters at the same time. You can combine the SQL WHERE clause with any combination of the SQL prefix and postfix clauses in the same cursor.

True

True or False: The where_clause parameter of the search cursor must be a string

True

True or False: The words in front of the parentheses are function names, and the comma-separated values inside the parentheses are function arguments.

True

True or False: The workspace for an element inside a geodatabase is the geodatabase itself, whereas for stand-along datasets, the workspace is simply the root folder

True

True or False: The write method returns the number of bytes written to a file, if successful.

True

True or False: The yield statement is used to define a generator, replacing the return of a function to provide a result to its caller without destroying local variables.

True

True or False: There are also several combinatoric functions in itertool, such as product and permutation. These are used when you want to accomplish a task with all possible combinations of some items.

True

True or False: There are limitations on the use of these keywords. First, not all data formats support them. DISTINCT and ORDER BY are supported only in geodatabases, not in formats such as shapefiles and DBF tables. TOP is supported only by SQL Server databases. Second, you can use only one prefix and one postfix clause at a time because the parameter must consist of a pair of values in a list or tuple.

True

True or False: There are many functions in itertools that operate on iterables, in a similar way to map and filter. Some examples:takewhile - takes items from an iterable while a predicate function remains true;chain - combines several iterables into one long one;accumulate - returns a running total of values in an iterable.

True

True or False: There are various types of exceptions, but errors in the logic or decision-making steps of your script are typical causes

True

True or False: To determine whether a key is in a dictionary, you can use in and not in, just as you can for a list.

True

True or False: To handle exceptions, and to call code when an exception occurs, you can use a try/except statement.

True

True or False: To read only a certain amount of a file, you can provide a number as an argument to the read function. This determines the number of bytes that should be read.

True

True or False: To retrieve each line in a file, you can use the readlines method to return a list in which each element is a line in the file.

True

True or False: To split the fully qualified name of a field in a table into its components use the arcpy.ParseFieldName() function. This function returns a single string with the database name, owner name, table name, and field name, each separated by a comma.

True

True or False: To use the CURRENT keyword, it (aprx = arcpy.mp.ArcGISProject("CURRENT")) ArcGIS Pro must be running, and this method can be used only from within the ArcGIS Pro application. This includes running code in the Python window in ArcGIS Pro or running script tools. The CURRENT keyword does not work for stand-alone scripts because the ArcGIS Pro application is not recognized at runtime

True

True or False: To write to files you use the write method, which writes a string to the file.

True

True or False: Trying to index a key that isn't part of the dictionary returns a KeyError.

True

True or False: Trying to reassign a value in a tuple causes a TypeError.

True

True or False: Trying to use a mutable object as a dictionary key causes a TypeError.

True

True or False: Tuples are faster than lists, but they cannot be changed.

True

True or False: Tuples are very similar to lists, except that they are immutable (they cannot be changed).Also, they are created using parentheses, rather than square brackets.

True

True or False: Tuples can be created without the parentheses, by just separating the values with commas.

True

True or False: Two scripts cannot simultaneously create an insert or update cursor on the same dataset

True

True or False: Typically, you should close your files by calling the close() method. When you open a file in read mode, calling this method is not critical because the file object is closed automatically when you quit the program using the file.

True

True or False: Unlike conventional comments, docstrings are retained throughout the runtime of the program. This allows the programmer to inspect these comments at run time.

True

True or False: Using arcpy.Clip_analysis is the same as using arcpy.analysis.Clip

True

True or False: Using generators results in improved performance, which is the result of the lazy (on demand) generation of values, which translates to lower memory usage. Furthermore, we do not need to wait until all the elements have been generated before we start to use them.

True

True or False: Using only a file name as a parameter returns a file object you can read from. If you want to do something else, such as write to the file, it must be stated explicitly by specifying a mode

True

True or False: Using pure functions has both advantages and disadvantages.Pure functions are:- easier to reason about and test.- more efficient. Once the function has been evaluated for an input, the result can be stored and referred to the next time the function of that input is needed, reducing the number of times the function is called. This is called memoization.- easier to run in parallel.

True

True or False: Using the break statement outside of a loop causes an error.

True

True or False: Using the continue statement outside of a loop causes an error.

True

True or False: Using the generic Exception is referred to as an unnamed exception

True

True or False: We can also create list of decreasing numbers, using a negative number as the third argument, for example list(range(20, 5, -2)).

True

True or False: When ArcPy is imported into Python, all the system toolboxes are available. When custom tools are created and stored in a custom toolbox, these tools can be accessed in Python only by importing the custom toolbox

True

True or False: When Python encounters an error, it raises, or throws, an exception , which typically means the script stops running. If such an exception object is not handled, also referred to as caught or trapped, the script terminates with a runtime error, sometimes referred to as a traceback.

True

True or False: When a script is finished running, Python automatically removes references to objects, so the del statement is not required but still reduces the likelihood of unwanted locks

True

True or False: When an ArcGISProject object is referenced in a script, the .aprx file is locked. This lock prevents other applications from making changes to the file. It is therefore good practice to remove the reference to a project when it is no longer needed in a script by using the Python del statement. This statement does not delete the actual .aprx file, only the reference to the object in memory.

True

True or False: When an exception occurs, a script will stop running mid process

True

True or False: When building a script tool, the parameter order displayed on the tool's dialog box must match the parameter order in your script.

True

True or False: When exploring data, it is critical to be aware of the workspace being used as well as the use of catalog and system paths

True

True or False: When using cursors to update or add rows to a table, all changes made are permanent and cannot be undone.

True

True or False: When working with cursors, you should delete the variables that reference the table you are accessing when you are finished with your script. If these variables are not deleted, other applications or scripts could be prevented from accessing the data.

True

True or False: With Python, you can create scripts that allow you to automate geoprocessing workflows in ArcGIS. You can access environment settings in Python that will make writing your scripts easier and more efficient. Using the arcpy.Describe function, you can load the properties of your GIS data into a variable and access them within your script. Several ArcPy list functions allow you to create Python lists of GIS data. After you have created your list, you can iterate through the list with a for loop. Accessing attribute values within a table can be done with a cursor. There are three types of cursors that allow you to read and write values. Cursors can also be used to read and write geometry. After you have created your script, you may want to share it as a script tool.

True

True or False: With a try-except statement, any code that follows it will still be executed, regardless of the error, whereas an error that is not trapped will result in the script being terminated before that portion of the code runs. Therefore, trapping errors resulting in more robust and user-friendly scripts

True

True or False: Without the del statement, a lock could needlessly block other applications or scripts from accessing the dataset. The del statement is not needed when the cursor is used inside a with statement.

True

True or False: Working with a list in Python typically requires a for loop

True

True or False: Write mode allows you to write to the file. Read/write mode can be added to any of the other modes to indicate both reading and writing is allowed. Binary mode allows you to change the way a file is handled.

True

True or False: You can access the values in the tuple with their index, just as you did with lists

True

True or False: You can also define functions with more than one argument; separate them with commas.

True

True or False: You can make more calls to read on the same file object to read more of the file byte by byte. With no argument, read returns the rest of the file.

True

True or False: You can never overwrite the values of immutable objects

True

True or False: You can open text files using the open() function, which has the following syntax: open(name, {mode}, {buffering}) The only required argument is a file name, and the function returns a file object.

True

True or False: You can raise exceptions by using the raise statement.

True

True or False: You can specify the mode used to open a file by applying a second argument to the open function. Sending "r" means open in read mode, which is the default. Sending "w" means write mode, for rewriting the contents of a file. Sending "a" means append mode, for adding new content to the end of the file.

True

True or False: You can use stand-alone scripts directly in ArcGIS Pro by either loading the code into the Python window or creating a script tool with the Python code.

True

True or False: You can use the .get() method to find keys in a dictionary, and use a second parameter to return a default value, in case the key is not found.

True

True or False: You can use the raise statement outside the except block?

True

True or False: You can work with geometry object and their properties by setting a cursor on geometry field, typically named Shape, of a feature class

True

True or False: You don't need to call list on the range object when it is used in a for loop, because it isn't being indexed, so a list isn't required.

True

True or False: You must define functions before they are called, in the same way that you must assign variables before using them.

True

True or False: You need to specify the type of the exception raised.

True

True or False: a While statement requires an exit condition

True

True or False: a dict is an unordered mutable collection of key-value pairs

True

True or False: a file geodatabase is referred to as a "gbd"

True

True or False: a list is an unordered mutable collection of elements

True

True or False: a method is a function that is closely ties to an object

True

True or False: a module is like an extension that can be imported into Python to extend its capabilities

True

True or False: a set is an unordered mutable collection of unique elements

True

True or False: a tuple is an ordered immutable collection of elements

True

True or False: a with statement is recommended when working with cursors

True

True or False: an expression is a value

True

True or False: an insert and update cursor cannot be applied if an exclusive lock already exists

True

True or False: an interpreter is a kind of program that executes other programs

True

True or False: da.Describe() is a function of the arcpy.da module or data access module

True

True or False: dat.Describe() function returns the same information as the Describe() function but in the form of a dictionary

True

True or False: every try block in python has a corresponding except (or catch) block?

True

True or False: example, SHAPE@XY returns a tuple of x,y coordinates representing the feature's centroid, and SHAPE@LENGTH returns the feature's length.

True

True or False: example, if the name "Clip" already exists, the CreateUniqueName() function changes it to "Clip0"; if this name also exists, the function changes the name to "Clip1," and so on. This function can only create unique table names within a workspace. It does not work for field names.

True

True or False: feature datasets can be used a s a workspace, but they are not a type of workspace that is returned by the ListWorkspaces() function

True

True or False: field delimiters vary depending on the data, and to avoid confusion, use the arcpy .AddFieldDelimiters() function.

True

True or False: generators allow you to declare a function that behaves like an iterator, i.e. it can be used in a for loop.

True

True or False: if you are specially looking for a feature datasets, use the arcpy.ListDatasets() function when the workspace is set to the gdb

True

True or False: in the arcpy.ValidateFieldName() function each invalid character is replaced by an underscore

True

True or False: list elements are accessed by their position in the list, whereas dictionary elements are access by their key

True

True or False: lists and dictionaries are mutable

True

True or False: most functions take arguments.

True

True or False: number are not iterable

True

True or False: operation such as deleting, appending, removing, and others are not supported by tuples

True

True or False: overwriteOutput is a Boolean data type

True

True or False: range can have a third argument, which determines the interval of the sequence produced, also called the step.

True

True or False: saying the value of 12 is assigned to the variable x is the same as saying that the variable x is bound to the value of 12

True

True or False: simple expressions are built from literal values by using operators and functions

True

True or False: that both the GraphicElement and TextElement objects have a clone() method to create a copy of these elements on a layout.

True

True or False: the ArcPy data access module arcpy.da allows control of an edit session, editing operations, cursor support, functions for converting tables and feature classes to and from NumPy arrays for additional processing, and support for versioning and replica workflows

True

True or False: the Dataset property group includes properties such as the type of dataset and the spatial reference.

True

True or False: the FOLDER workspace type is an regular system folder that could potentially contain shapefiles or other dataset, even id the folder does not contain any files. The function does not determine whether any shapefiles or other spatial datasets are present or not

True

True or False: the FeatureClass properties provide access to the FeatureClass data type, which can be a geodatabase, shapefile, or other type of feature class

True

True or False: the ListDatasets() (arcpy.ListDataset())can also return several other geodatabase elements, including geometric networks, networks, raster catalog, topology, and several others

True

True or False: the deleteRow() methods deletes the row at the current position of the UpdateCursor. After the cursor retrieves the row object, calling the deleteRow() method deletes the row

True

True or False: the importDocument() method gives you the option to exclude the layout (which is not possible using Import and Open in ArcGIS Pro), whereas using Import and Open in ArcGIS Pro opens one of the maps or the layout in a view (which importDocument() does not do).

True

True or False: the keys() method returns a view object that displays a list of all the keys in the dictionary

True

True or False: the order in which the items are created in the dictionary does not matter

True

True or False: the str() function can be used to convert a number to a string

True

True or False: the variable used in the exit condition is called a sentry variable or loop variable

True

True or False: the while loop is used in cases when the number of iterations is not known and depends on some calculations and conditions in the code block of the loop.

True

True or False: to facilitate working with more complex folder and file structure, you can use the arcpy.da.Walk() function.

True

True or False: to obtain maps, layers, or layouts, you must first reference an ArcGISProject object. As a result, the ArcGISProject object typically is the first object reference created in a mapping script

True

True or False: to obtain more than one element, you can use multiple index numbers known as slicing

True

True or False: to use an else with error handling, it is added after the except block.

True

True or False: to use the current project in ArcGIS Pro, the keyword CURRENT (in all uppercase) is used for example: aprx = arcpy.mp.ArcGISProject("CURRENT")

True

True or False:In addition to a SQL WHERE clause, you can also use a limited number of other SQL clauses. Both the SearchCursor and UpdateCursor classes have the optional sql_clause parameter. Supported clauses include DISTINCT, GROUP BY, ORDER, and TOP.

True

True or False; In except blocks, the raise statement can be used without arguments to re-raise whatever exception occurred.

True

True or False; Python has a built-in debugger package called pdb

True

True or False; loops allow you to repeat a certain part of your code until a specified condition is reached or until all possible inputs are used

True

True ro False: The sql_clause parameter consists of a pair of SQL prefix and postfix clauses organized in a list or tuple. If you want to use only one clause, the other one would be specified as None.

True

What is the output of this code? print( 7 != 8)

True

What is the output of this code? print(8.7 <= 8.70)

True

What is the result of this code? True and True

True

What is the result of this code? not True or True

True

True or False: in order for an error to be a compilations error it need to be an error inherent within the code

True It has to be an error we can identify by looking at the code

True or False: Messages from the last tool run are maintained by ArcPy and can be retrieved using the GetMessages() function. In addition indivudal messages can be retrieved using the GetMessage() function

True The GetMessages() function returns a single string containing all the messages from the tool that was last run The GetMessage() function only has one parameter, which is the index number of the message

True or False: Another example of a SQL keyword is TOP, which allows you to select a specific number of records such as the following: SELECT TOP 5 * FROM <table> WHERE <condition>

True This statement selects only the first five records that meet the condition. The TOP keyword comes before the WHERE clause and is referred to as a prefix clause.

True or False: List comprehension also supports the use of element filtering with conditions. Bonus: what is the syntax

True [<expression> for <item> in <list> if <condition>]

What are the two Boolean values in Python

True and False

What is the result of the following code: nums = [1, 2, 3] print(not 4 in nums) print(4 not in nums) print(not 3 in nums) print(3 not in nums)

True, True, False, False

What is the output of the following code: print(False == False or True) print(False == (False or True)) print((False == False) or True)

True, False, True

True or False: The if structure and its variants are referred to as control structures

True, because the structure directs the order of execution for the statements in a series

True or False: None is its own data type in Python

True, i.e NoneType

True or False: Lambda functions aren't as powerful as named functions. They can only do things that require a single expression - usually equivalent to a single line of code

True.

True or False: Cursors also support with statements.

True. A with statement has the advantage of guaranteeing closure, releasing data locks ,and resetting iteration, regardless of whether the cursor finished running successfully or not

True or False: In addition to the cursor classes that are part of the data access module, ArcPy also contains cursor functions arcpy.SearchCursor(), arcpy.UpdateCursor(), and arcpy.InsertCursor()

True. However, these legacy cursor functions are discouraged

True or False: Cursors navigate only in a forward direction

True. If a script must make multiple passes over the data through iteration, the cursor must be reset

True or False: Functions that are associated with a specific data type or object are referred to as methods.

True. Like other functions, methods perform an action, but the action depends on the data type that it is associated with. For example, a string method like capitalize will capitalize the string value that it is associated with (attached to)

What is the output of this code? print("Annie" > "Andy")

True. The first characters from "Annie" and "Andy" (A and A) are compared. As they are equal, the second two characters are compared. Because they are also equal, the third two characters (n and d) are compared. And because n has greater alphabetical order value than d, "Annie" is greater than "Andy".

True or False: system paths also contain a base name

True. The last part of the path that does not contain a slash

True or False: Syntax refers to the rules that dictate how Python code needs to be structured

True. Therefore, a syntax error is an error related to the structure of your Python code

True or False: a tuple is immutable

True. Which means that a tuple cannot be changed after it has been defined. In other words, there are no functions such as tuple.append(), tuple.pop() etc

True or False: It is not possible to use two different workspaces at the same tume

True. You cannot use two different workspaces at the same tie

True or False: The second argument is not included in the range.

True. range(3, 8) will not include the number 8.

Which exception is raised by this code? print("7" + 4)

TypeError

Some of the route numbers in your roads geodatabase have changed. Which type of cursor would be best to change the old route numbers to their current numbers?

Update cursor

You need to create a Python script to delete rows that are no longer needed from a table. Which type of cursor would be best suited for this situation?

Update cursor

Your geodatabase has a table of addresses. Some of the address records are duplicated, and you want to remove the duplicates. Which cursor would be best for deleting the duplicate records?

Update cursor

What does the updateRow(row) method do in the cursor class da.UpdateCursror

Updates the current row with a modified row object

You want to access the properties of a raster dataset and use these properties in a Python script. How can you access these properties in Python?

Use the ArcPy Describe function.

What is meant by catching errors?

Using error handling to prevent a program from crashing when an error is encountered

In addition to a try-except statement for trapping errors in scripts, several other error-handling methods can be used such as

Validating table and field names using the arcpy.ValidateTableName() and arcpy.ValidateFieldName() Checking for licenses for products using the arcpy.CheckProduct() function and for extensions using the arcpy.CheckExtension() function Checking for data locks - many geoprocessing tools will not run properly if data locks exist on the input

What is a Walrus operator?

Walrus operator := allows you to assign values to variables within an expression, including variables that do not exist yet.

In general what are the steps you will need to complete to turn your script into a tool?

Write and test script It is often easiest to write and test your script with hard-coded values. After you have your script debugged, you can allow your variables to accept user input. Allow dynamic input Determine the order in which you want to have the tool input presented in the tool's interface. Modify the variables in your script to accept dynamic input by removing the hard-coded values and replacing them with arcpy.GetParameterAsText. Create new toolbox Your script tool will be stored in a toolbox. You need to have write access to the toolbox in which you will store your script tool. The toolboxes that are installed with ArcGIS are read-only. Toolboxes can be created in a folder or a geodatabase. Create new script tool Adding a script tool to a toolbox or toolset will allow you to browse to the location of your script. You can set the tool name and label, and even set an option to embed the script within the tool. Tool parameters are also set up in the new script dialog. Add validation (optional) To provide additional validation of user input, you can add custom Python code to your script tool.

Can a docstring contain multiple lines of text?

Yes

Can you slice a tuple?

Yes

What is the object in which you can list all the map frames in a layo8ut, and then access the map associated with a map frame?

You can list all the map frames in a layout, and then access the map associated with a map frame through the properties of the MapFrame object

Which errors occur during the execution of this code? try: print(1 / 0) except ZeroDivisionError: raise ValueError

ZeroDivisionError and ValueError

What is a data structure

a collection of elements that are structured in some meaningful way

An object-oriented program involves

a collection of interacting objects, as opposed to the conventional list of tasks

What does \n represent

a new line

A literal is

a number or text(string) value

A set of characters surrounded by quotation marks is called

a string literal or simply a string

A variable is

a values used to represent a number or text(string) value

Which of the following is (are) a keyword in Python? (Check all that apply) a. break b. Python e. import d. for e. string f. print

a, c, d a. break e. import d. for

Which one of the following is a valid Python if statement? a. if a >= 17: b. if (a>= 17) c. if (a = 17): d. if a >< 17: e. if a => 17: f. if a > 17

a. if a >= 17:

What is the result of this code? x = "a" x *= 3 print(x)

aaa

Fill in the blanks to print "Welcome" age = 15 money = 500 if age > 18 __ money > 100: ____("Welcome")

age = 15 money = 500 if age > 18 or money > 100: print("Welcome")

A list is

an indexed and editable collection of values

The ___ operator takes two arguments, and evaluates as True if, and only if, both of its arguments are True. Otherwise, it evaluates to False

and

Python's Boolean operators are

and, or & not

The ______ method adds an item to the end of an existing list.

append

What is the syntax for the arcpy.AddFieldDelimiters() function

arcpy.AddFieldDelimiters(datasource, field)

What are the two functions in ArcPy to describe datasets

arcpy.Describe() and arcpy.da.Describe()

What is the syntax to describe a dataset using the Describe() function

arcpy.Describe(<input dataset>, {datatype})

What is the syntax of the Exists() function (arcpy.Exists())

arcpy.Exists(<dataset>)

What is the general syntax of the Geometry class?

arcpy.Geometry(geometry, inputs, {spatial_reference}, {has_z}, {has_m}) The geometry parameter specifies the type of geometry as a string—i.e., point, polyline, polygon, or multipoint. The inputs parameter represents the coordinates (i.e., vertices) used to create the object. These vertices can be in the form of either Point or Array objects,

What is the syntax for arcpy.ListDatasets()

arcpy.ListDatasets ({wild_card}, {feature_type})

What is the syntax for arcpy.ListFeatureClasses()

arcpy.ListFeatureClasses ({wild_card}, {feature_type}, {feature_dataset})

Which ArcPy function could be used to create a list of attribute fields?

arcpy.ListFields

What function can be used to perform parsing task?

arcpy.ParseTableName()

What is the syntax for arcpy.ParseTableName() and what does it do?

arcpy.ParseTableName(name, {workspace}) The ParseTableName function returns a single string with the database name, owner name, and table name, each separated by a comma.

What is the general syntax for the Point class?

arcpy.Point({X}, {Y}, {Z}, {M}, {ID}) None of the parameters are required, which allows you to create an empty Point object and populate its properties later. Logically, however, it would not make sense to use a Point object unless you have at least an x,y coordinate pair.

You want to reset all geoprocessing environments to their default values in your script using PyCharm. What Python code statement will reset ArcGIS geoprocessing environments?

arcpy.ResetEnvironments()

What is the syntax for the arcpy.ValidateFieldName() function

arcpy.ValidateFieldName(name, {workspace})

What is the syntax for the arcpy.ValidateTableName() function and what does it do?

arcpy.ValidateTableName(name, {workspace}) This function takes a table name and a workspace and returns a valid table name for the workspace. If the table name is already valid, the function returns a strings that is the same as the input. If the input name contains invalid characters, they are replaced by an underscore(_)

What is the syntax for the da.Describe() function

arcpy.da.Describe(<input dataset>, {datatype})

What is the general syntax for insert cursor?

arcpy.da.InsertCursor(in_table, field_names)

What is the general syntax for the search cursor?

arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explore_to_points} {sql_clause})

What is the general syntax for the update cursor?

arcpy.da.UpdateCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explore_to_points} {sql_clause})

What is the syntax for arcpy.da.Walk()?

arcpy.da.Walk (top, {topdown}, {onerror}, {followlinks}, {datatype}, {type})

What is the general syntax for the arcpy.mp.ArcGISProject() function?

arcpy.mp.ArcGISProject(aprx_path) where the aprx_path parameter is a string representing the full path to an .aprx file on disk

Modules

are Python's highest level of organizing code

What does a scripting language refer to

automating certain functionality within another program

Which of the following is (are) true regarding indentation in Python? (Check all that apply) a. in Python indentation, one tab is equal to four spaces b. Python editors have built-in tools to assist with writing correct indentation c. indentation in Python can use tabs or spaces d. the key to using an indentation style in Python is consistency e. you can mix tabs and spaces for indentation as long as the lines of code visually align f. instead of using indentation, you can also use curly braces { } to indicate a group of statements

b, c, and d b. Python editors have built-in tools to assist with writing correct indentation c. indentation in Python can use tabs or spaces d. the key to using an indentation style in Python is consistency

Which of the following is (are) examples of the start of compound statements in Python? (Check all that apply) a. not b. while c. break d. if e. in f. for

b, d, and f b. while d. if f. for

Python scripts use variables to store information. A variable is

basically a name that represents or refers to a value

To end a while loop prematurely, the ___ statement can be used.

break

Which of the following is (are) correct to write a single line of code on multiple lines? (Check all that apply) a. mytext = (This text is broken up into multiple lines.) b. mytext = ("This text is broken up into multiple lines.") c. mytext = "This text is broken up \ into multiple lines." d. mytext = ("This text is broken up " "into multiple lines.")

c and d c. mytext = "This text is broken up \ into multiple lines." d. mytext = ("This text is broken up " "into multiple lines.")

Which of the following can be used to comment out a line of code? a. // b. * c. # d. (comment) e. [ ]

c. #

Using a function is referred to as ____ the function

calling

Which of the following variable names can produce an error? (check all that apply) case% record count featureData list 17 my_var var_0lol1 DATABASE

case% record count list 17

Converting the value of the variable from one type to another is known as

casting

Unlike break, ____ jumps back to the top of the loop, rather than stopping it. Basically, the _____ statement stops the current iteration and continues with the next one.

continue, continue

How do you create a variable called count that is equal to 17?

count = 17

A collection of data elements that are organized in some meaningful way is called a(n) ____.

data structure

Data types that contain more that a single value are referred to as

data structure

Fill in the blanks to define a function that compares the lengths of its arguments and returns the shortest one. def shortest_string(x, y): if len(x) <= _____(y): _______ x else: ______ y

def shortest_string(x, y): if len(x) <= len(y): return x else: return y

What is the output of this code? zoning = {'IND' : 'Industry', 'RES' : 'Residential', 'WAT' : 'Water'} zoning.keys()

dict_keys(['IND', 'RES', 'WAT'})

What is the data type: nums = {'1': 1, '2':2}

dictionary

Consider the following example code: codes = {'IND': 'Industry', 'RES': 'Residential'} In this example, codes is a _____, 'IND' is a _____ and 'Residential' is a _____.

dictionary, key, value

A shorter option for an "else if" statement is:

elif

Multiple if/else statements make the code long and not very readable. The ____ (short for _______) statement is a shortcut to use when chaining if and else statements, make the code shorter.

elif (short for else if)

The ___ statement can be used to run some statements when the condition of the if statement is False

else

What is the result of this code? if 1 + 1 == 2: if 2 * 2 ==8: print("if") else: print("else")

else

In this example: arcpy.env.workspace What is env and what is workspace

env is a class and workspace is a property of that class

Consider the following outline for a script. try: <block of code> except ZeroDivisionError: <block of code> except TypeError: <block of code> except: <block of code> finally: <block of code> Which of these blocks may not run at all when the script is executed? (check all that apply)

except ZeroDivisionError except except TypeError

In the following snippet: arcpy.Buffer_analysis(fc, fc + "Buffer", "1000 meters") what will be the output name of each feature class after it is buffered?

fc + Buffer (ex: LakesBuffer)

What is the output of this code? spam = 7 if spam > 5: print("five") if spam > 8: print("eight")

five

The ____ loop is used to iterate over a given sequence, such as lists or strings.

for

Which type of Python loop would be best suited to iterate through a list of feature classes?

for loop

Fill in the blanks to iterate over the list using a for loop and print its values. list = [1, 2, 3] ___ var list: print(____)

for var in list: print(var)

A ____ is like a little program that is used to carry out an action

function

Consider the following code: mytext = "The Meaning of Life" print(mytext.lower()) In this example, print() is a ____ and lower() is a ____.

function, method

A ___ takes input data (a feature class, raster, or table), performs a geoprocessing task, and producers output data as a result

geoprocessing tools

What is the output of this code? mytext = "GIS is cool" print(mytext.lower))

gis is cool

The ___ statement allows you to check a condition and run some statements, if the condition is True

if

Strings, numbers, and tuples are _____ and lists and dictionaries are _____.

immutable, mutable

To check if an item is in a list, the __ operator can be used. It returns True if the item occurs one or more times in the list, and False if it doesn't. The __ operator is also used to determine whether or not a string is a substring of another string.

in, in

_____ is used to define the level of nesting

indentation

Python uses _______ to delimit blocks of code.

indentation (white space at the beginning of a line)

The ____ method finds the first occurrence of a list item and returns its index.If the item isn't in the list, it raises a ValueError.

index

Strings (and other Python sequences such as lists) have an __________ which uses a range of values enclosed in brackets

index positioning system

Obtaining an individual character from a string(or. more generally, a single element from a sequence) is simply called

indexing

All three cursors have two required arguments. What are they?

input table and a list(or tuple) of field names

The _____ method is similar to append, except that it allows you to insert a new item at any position in the list, as opposed to just at the end.

insert

The two types of numeric data types

integers and floats

What is a programming language

involves the development of more sophisticated multifunctional applications

What is a package in Python?

is a collection of modules and other elements that adds functionality to Python

What is a tuple?

is a sequence of elements, just like a list, but a tuple is immutable, meaning that it cannot be changed

What is a statement?

is an instruction that tells the computer to do something. This can consists of changing the value of variables through assignment, printing values to the screen, importing modules, and many other operations

The code in the body of a while loop is executed repeatedly. This is called ____.

iteration

What are anonymous functions called

lambdas

To get the number of items in a list, you can use the _____ function.

len

String values consist of character, which can include

letters, numbers, and other types of characters

A ____ consists of a sequence of items surrounded by brackets ([]), sometimes referred to as "square brackets," and the items are separated by commas

list

What is the data type: nums = [1, 2, 3, 4, 5]

list

Which of the following data types in Python are sequences? (check all that apply) float list string tuple Boolean integer

list, string, tuple

A list has several common functions for adding or removing elements such as:

list.append(element) adds an element to the end list.insert(index, element) inserts an element at position index pop() which removed an element from a list at a specified location and returns the value of the element

The ArcGIS Project class includes two methods to handle broken data sources. What are they

listBrokenDataSources() and updateConnectionProperties()

What are some other methods of the ArcGISProject class?

listColorRamps()—returns a list of ColorRamp objects listLayouts()—returns a list of Layout objects listMaps()—returns a list of Map objects listReports()—returns a list of Report objects These methods return a list of objects, and therefore work like a list function in ArcPy. They are not functions of arcpy.mp, however, but methods of the ArcGISProject object

What is mutable?

mean the data elements can be modified

What is an iterable object

means you should be able to iterate over its contents

A ____ is a function that is coupled to an object - for example, a number, a string, or a list

method

Python scripts, by definition, are called

modules

The ___ operator only takes one argument, and inverts it. The result of not True is False, and not False goes to True

not

To check if an item is not in a list, you can use the ___ operator

not

Consider the following code. import arcpy myfile = arcpy.Describe("C:/Data/Roads.shp") type = myfile.shapeType basename = myfile.baseName In this script myfile is a(n) ___ and shapeType and baseName are ____.

object, properties

A dict consists

of zero or more key-value pairs. That is each element of a dict is a combination of a value that services as a key and that is associated with another value

Every if condition block can have ____ else statement

only one

Batch geoprocessing makes it easier to automate certain tasks, but there are limitations. Such as

only one tool parameter can be used as the batch parameter. Second, the values for the batch parameter must be entered one by one.

Which function is used to access files?

open

The __ operator also takes two arguments. It evaluates to True if either (or both) of its arguments are True, and False if both arguments are False

or

A Dictionary consists of

pairs of keys and their corresponding values. Pairs are also referred to as the items of the dictionary

Consider the following code: import arcpymyprj = "c:/data/example.prj"spatialref = arcpy.SpatialReference(myprj) In the last line of code, myprj is a ___ of the SpatialReference ___.

parameter, class

What are the high-level results of running code?

perform correctly perform incorrectly generate an error

Which line of code will cause an error? num = [5, 4, 3, [2], 1] print(num[0]) print(num[3][0]) print(num[5])

print(num[5])

________ allows you to build components from scratch, as well as the applications that incorporate these components

programming

Consider the following code import arcpyarcpy.env.workspace = "C:/Data" In the second line of code, workspace is a ___ of the env ___.

property, class

import arcpy arcpy.env.workspace = "C:/Data" In the second line of code, workspace is a ___ of the env ___.

property, class

What are the most common values for modes in open() funciton

r: read mode w: write mode +: read/write mode (added to another mode) b: binary mode (added to another mode—e.g., rb, wb, and others) a: append mode

The ____ function returns a sequence of numbers. By default, it starts from 0, increments by 1 and stops before the specified number.

range()

_______ is a programming task that allows you to connect diverse existing components to accomplish a new, related task

scripting

What are the three types of cursors:

search, insert, and update

Consider the following code: i = 0 while i <= 10: print(i) i += 1 In this example, the variable i is the _____ variable and i <= 10 is the ____ condition.

sentry, exit

What is the syntax of a tuple

separate a sequence of values with commas

The most basic data structure in Python is the _____ , in which each element is assigned a number, or _____

sequence, index

A ____ is an unordered collection of elements without duplicates

set

What is the data type: nums = {1, 2, 3, 4, 5}

set

What is this? names = {0, 1, 2, 3, 5}

set

What are the severity level of messages?

severity = 0 (information message) - this type of message provides information about the execution. This includes general info such as the tool's progress, the start and completion time of the tool, and information about the tool results. The messages are never used to indicate problems severity = 1 (warning message) - this type of message indicates a possible problem. This could be a situation that may cause a problem during the tool's execution or a situation where the result may not be what you might expect. Warning messages will not prevent a tool from being executed, but they do warrant inspection severity = 2 (error message) - this type of message indicates a situation that prevents the tool from execution. Typically, this means that one or more parameter settings are invalid

What the the two types of locks?

shared and exclusive

There are three main types of modules in Python, those you write yourself, those you install from external sources, and those that are preinstalled with Python. The last type is called the ________and contains many useful modules

standard library

The variable element is an integer. How would you cast this variable into text?

str(element)

Tasks that can be done by the standard library include

string parsing, data serialization, testing, debugging and manipulating dates, emails, command line arguments, and much more!

Some of the standard library's useful modules include

string, re, datetime, math, random, os, multiprocessing, subprocess, socket, email, json, doctest, unittest, pdb, argparse and sys.

Examples of sequences

strings, lists, and tuples

A set of rules that dictate how words and symbols can be put together to form valid program statements is called ____.

syntax

What are the three main types of errors in Python:

syntax errors, exceptions, and logic errors

Languages that work with these lower-level primitives and the raw sources of the computers are referred to as

system language

What is one of the limitations of the arcpy.mp module?

that it cannot be used to author a new project from scratch, and you can work only with existing projects. Similarly, you cannot create many other typical elements of a project, including maps, layouts, and layout elements

To perform more complex checks, if statements can be nested, one inside the other. This means

that the inner if statement is the statement part of the outer one. This is one way to see whether multiple conditions are satisfied.

In the try-except statement, what is the finally statement

the finally block of code will always be executed. This block typically consists of cleanup tasks and can include checking in licenses or detecting reference to files

If you want to work with one of the map, you use

the index number: m = aprx.listMaps()[2]

In the syntax for the SearchCursor class: arcpy.da.SearchCursor(in_table, field_names {where_clause}, {spatial_reference}, {fields}, {explode_to_points}, {sql_clause}) what is the parameter that consists of a SQL expression

the optional where_clause parameter

Catalog paths consist of two parts. What are they?

the workspace and the base name

What is the data type: nums = (1, 2, 3, 4, 5)

tuple

What is the data type: nums = 1, 2, 3, 4, 5

tuple

What is the data type? name = 1, 2, 3, 4, 5

tuple (1, 2, 3, 4, 5)

A memory location that can store a value is called a ____.

variable

A ____ loop is used to repeat a block of code multiple times.

while

____ is a short and easy way to make an infinite loop.

while True

What is the result of this code? words = ["hello"] words.append("world") print(words[1])

world

Fill in the blanks to compare the variables and output the corresponding text: x = 10 y = 20 __ x > y_ print("if statement") _____ print("else statement")

x = 10 y = 20 if x > y: print("if statement") else: print("else statement")

What does this code output? letters = ['x', 'y', 'z'] letters.insert(1, 'w') print(letters[2])

y

What statement is used in functions to turn them into generators?

yield

What is immutable?

you can't modify them but only replace them with new values

What is the output of this code? number = {1, 1, 1, 1} number

{1}


संबंधित स्टडी सेट्स

Ecology, Photosynthesis, and Cellular Respiration

View Set

COMP 2210 Module 14 - Search Trees

View Set

Cisco Chapter 9: Transport Layer

View Set

Chapter 7: The News and Social Media

View Set