Maggie Samson
Quiz by , created more than 1 year ago

Geography Quiz on GEOM 73 - Python Quiz 2, created by Maggie Samson on 13/04/2019.

72
2
0
Maggie Samson
Created by Maggie Samson over 5 years ago
Close

GEOM 73 - Python Quiz 2

Question 1 of 10

1

Which of the following are considered a catalog path that are not recognized by Windows and Python, but only by ArcGIS? (check all that apply)

Select one or more of the following:

  • C:\Projects\Transportation.gdb\Roads

  • C:\Catalog\Parcels.shp

  • E:\Data\Catalog\Project.mdb\Parcels\Lotlines

  • D:\MyFiles\Projects\Network.shp

  • C:\Projects\Roads.dbf

Explanation

Question 2 of 10

1

In the following example code, myfile is a(n) __ and shapeType and baseName are __.

import arcpy
myfile = arcpy.Describe("C:/Data/Roads.shp")
type = myfile.shapeType
basename = myfile.baseName

Select one of the following:

  • object, properties

  • object, functions

  • class, functions

  • module, properties

  • module, functions

Explanation

Question 3 of 10

1

Which of the following is (are) a list function of ArcPy? (check all that apply)

Select one or more of the following:

  • ListProperties

  • ListFields

  • ListFeatureClasses

  • ListDatabases

  • ListFiles

  • ListTables

Explanation

Question 4 of 10

1

Consider the following example code:

import arcpy
myshape = "C:/Data/Parcels"

Which of the following correctly creates a list of field objects of type integer?

Select one of the following:

  • mylist = arcpy.listFields (myshape, "", "Integer")

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

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

  • mylist = arcpy.ListFields ("Integer")

  • mylist = arcpy.listFields (myshape, "Integer")

  • mylaist = arcpy.listFields ("Integer")

Explanation

Question 5 of 10

1

Which of the following Python data types are immutable, i.e. you can't modify them but only replace them with new values? (select all that apply)

Select one or more of the following:

  • String

  • Distionaries

  • Numbers

  • List

  • Tuple

Explanation

Question 6 of 10

1

Which of the following is (are) a type of cursor of the ArcPy data access module? (select all that apply)

Select one or more of the following:

  • WriteCursor

  • UpdateCursor

  • InsertCursor

  • EditCursor

  • SearchCursor

Explanation

Question 7 of 10

1

Which of the following is (are) a method of the InsertCursor of the ArcPy data access module? (select all that apply)

Select one or more of the following:

  • insertRow

  • reset

  • next

  • deleteRow

Explanation

Question 8 of 10

1

Consider the following example code that delete rows from a shapefile based on the value RESIDENTIAL in the filed LANDUSE:

import arcpy
myshape = "C:/Data/Parcels.shp"
(missing line)
for row in cursor:
if row[0] = "RESIDENTIAL"
cursor.deleteRow ()

Select one of the following:

  • cursor = arcpy.DeletCursor (myshape, "LANDUSE")

  • cursor = arcpy.da.UpdateCursor (myshape, ["LANDUSE"])

  • cursor = arcpy.da_UpdateCursor (myshape, ["LANDUSE"])

  • cursor = arcpy.da.DeleteCursor (myshape, "LANDUSE")

  • cursor = arcpy.da.DeleteCursor (myshape, ["LANDUSE"])

  • cursor = arcpy.da.UpdateCursor (myshape, "LANDUSE")

Explanation

Question 9 of 10

1

Which of the following creates a new empty text file in Python (provided no file with that name already exists)?

Select one of the following:

  • mytext = write("C:/Data/example.txt", "w")

  • mytext = create("C:/Data/example.txt", "w")

  • mytext = write("C:/Data/example.txt", "a")

  • mytext = open("C:/Data/example.txt", "w")

  • mytext = open("C:/Data/example.txt")

  • mytext = write("C:/Data/example.txt")

Explanation

Question 10 of 10

1

Consider the scenario where you have a text file where each line contains a pair of coordinates and other attribute values. Which of the following is (are) a valid approach to reading the contents of the text file, line by line, for further processing? (select all that apply)

Select one or more of the following:

  • Open the text file in read mode, than iterate over the lines in a for loop

  • Open the text in read mode, than iterate over the lines in a for loop using the readlines method

  • Open the text file in read mode, than iterate over the lines in a while loop using the readlines method

  • Import the file using the import module, than iterate over the line in a while loop using the readlines method

  • Import the file using the fileinput module, then iterate over the lines in a for loop using the input function

Explanation