quiz Flashcards

(17 cards)

1
Q

The variable below stores a shapefile’s name. shp_name = “MO_DOT_2018_03_28.SHP”
Write a code line to extract the substring “2018_03_28” from shp_name using slicing.

A

v = shp_name[7:17]

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

The variable below stores a shapefile’s name.
shp_name = “MO_DOT_2018_03_28.SHP”
Write a code line to create a list of strings elements from shp_name with the _ character as the separator using the split function.

A

l = shp_name.split(‘_’)

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

what would be the fourth element in the list created by splitting “MO_DOT_2018_03_28.SHP” by _ character

A

03

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

what module in arcpy is used to work with cursors

A

Data Access

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

Which of the following is the default mode when opening a text file in Python?

Append. 

Read. 

Write. 

b and a.
A

Read

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

When using update and insert cursors, what do you have to do to avoid data lock situations?

A

Delete the cursor variable

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

You are copying shapefiles to a geodabase with the line below, where the a_fc variable represents a shapefile with the format “finaName.shp”, and the_gdb variable represents the full path and name of a geodatabase. A workspace has been defined and corresponds to the location of the a_fc shapefile. The line shown below needs a correction; write a second code line that shows the correction.

arcpy.CopyFeatures_management(a_fc, the_gdb + “\” + a_fc

A

arcpy.CopyFeatures_management(a_fc, the_gdb + “\” + a_fc.replace(“.shp”, “”)

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

Name the 3 types of cursors from the Data Access module in ArcPy.

A

Search, insert, update

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

You need to create a new feature class from an original feature class with 100,000 records; the new feature class should have only the records that satisfy an attribute criteria. What Python script option would you use from the list below as the most efficient?

Create a new feature class; use a search cursor to read all the fields with the criteria; and then use an insert cursor to add records to the new feature class. 

Do a select layer by attribute on the original feature class to select records by the criteria, followed by a copy features step to create the new feature class.
A

B

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

What is the main difference between an attribute table from a feature class and a standalone table when it comes to geometry?

A

Stand alone table doesn’t have geometry

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

s_cursor = arcpy.da.SearchCursor(fc, [“ID”, “SoilType”], q)
for s_row in s_cursor:
u_cursor = arcpy.da.UpdateCursor(table, [“soil_type”])
for u_row in u_cursor:

u_cursor.updateRow(u_row)
del u_row

For the above loop, what would you type if you wanted to set the value of the field soil_type equal to the value from the field SoilType?

A

u_row[0] = s_row[1]

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

s_cursor = arcpy.da.SearchCursor(fc, [“parcel_no”, “owner”, “type”], q)
for s_row in s_cursor:
u_cursor = arcpy.da.UpdateCursor(table, [“block”, “tract”, “par_no”])

for u_row in u_cursor:
u_cursor.updateRow(u_row)
del u_row
del u_cursor

In the update cursor for loop above, what would you type if you wanted to set the value of the field par_no equal to the value from the field parcel_no?

A

u_row[2] = s_row[0]

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

Choose the correct statement from the options below regarding a Join operation:

It is done in the hard drive, the field names change, and to keep the new field names and the join you must export the joined data to a new feature class. 

It is done in memory, the field names remain the same, and to keep the new field names and the join you must export the joined data to a new feature class. 

It is done in memory, the field names change, and the joined data in memory will be kept so there is no need to export the joined data to a new feature class to keep the new field names and the join. 

It is done in memory, the field names change, and to keep the new field names and the join you must export the joined data to a new feature class.
A

D

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

The Python code lines below will create the text file “file.csv”.

txt = open(r"d:\temp\file.csv", "w") 

txt.write("a, b, c\n") 

txt.write("d, e, f\n") 

txt.write("g, h, i\n") 

txt.close()

What variable represents the text file you are creating?

A

txt

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

The Python code lines below will create the text file “file.csv”.

txt = open(r"d:\temp\file.csv", "w") 

txt.write("a, b, c\n") 

txt.write("d, e, f\n") 

txt.write("g, h, i\n") 

txt.close()

What is the purpose of the \n characters

A

newline

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

The Python code lines below will create the text file “file.csv”.

txt = open(r"d:\temp\file.csv", "w") 

txt.write("a, b, c\n") 

txt.write("d, e, f\n") 

txt.write("g, h, i\n") 

txt.close()

after executing what is the third line in the file

17
Q

The Python code lines below will create the text file “file.csv”.

txt = open(r"d:\temp\file.csv", "w") 

txt.write("a, b, c\n") 

txt.write("d, e, f\n") 

txt.write("g, h, i\n") 

txt.close()

if there is a preexisting file in the same folder with the same name, what will happen to it?

A

it will be overwritten