Begin a new Kumite
Search
About
  • Filter by Language:
    Ad
  • Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.

    You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.

    A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.

Create a Geodatabase in the new output folder.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    # Create a user named Geodatabase in the new output folder
    GeodatabaseLocation = out_workspace
    GeodatabaseName = "Assignment2_AniMorrow.gdb"
    arcpy.CreateFileGDB_management(GeodatabaseLocation, GeodatabaseName)
    arcpy.AddMessage("Created a Geodatabase")

Create 3 feature datasets: Point, Polyline and Polygon. Use the Spatial Reference object from
Describe to set the coordinate system of each.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    # Create 3 feature datasets: Point, Polyline and Polygon. Use the Spatial Reference object from Describe to set the coordinate system of each
    New_out_workspace = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb
    output_location = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb"
    
    PointDataset_Location = output_location
    PointDataset = "Point"
    Point_spatial_reference = Spatial_Reference
    arcpy.CreateFeatureDataset_management(PointDataset_Location, PointDataset, Point_spatial_reference)
    arcpy.AddMessage("PointDataset made")

    PolygonDataset_Location = output_location
    PolygonDataset = "Polygon"
    Polygon_spatial_reference = Spatial_Reference
    arcpy.CreateFeatureDataset_management(PolygonDataset_Location, PolygonDataset, Polygon_spatial_reference)
    arcpy.AddMessage("PolygonDataset made")

    PolylineDataset_Location = output_location
    PolylineDataset = "Polyline"
    Polyline_spatial_reference = Spatial_Reference
    arcpy.CreateFeatureDataset_management(PolylineDataset_Location, PolylineDataset, Polyline_spatial_reference)
    arcpy.AddMessage("PolylineDataset made")

Create a list of each shapefile by type (point, polyline and polygon) and print to screen one at a
time.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    ###### Using Lists ---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("USING LISTS")
    
    # Create a list of each shapefile by type (point, polyline and polygon) and print to screen one at a time
    shapefile_location = r"D:\Python\Data"
    arcpy.AddMessage ("Here's the lists of shapefiles")

    point_output_location = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Point"
    Pointlist = arcpy.ListFeatureClasses("", "Point")
    arcpy.AddMessage(Pointlist)
    for fc in Pointlist:
        if 'WA' in fc:
            arcpy.AddMessage(fc)
            fc1 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc1[1] + "_" + fc1[0] + "_" + fc1[2] + "_" + fc1[3].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, point_output_location + os.sep + outfc)  # copy the points
            arcpy.AddMessage(point_output_location + os.sep + outfc + " has been copied into the point dataset")
        else:
            arcpy.AddMessage(fc)
            fc2 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc2[1] + "_" + fc2[0] + "_" + fc2[2].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, point_output_location + os.sep + outfc)  # copy the points
            arcpy.AddMessage(point_output_location + os.sep + outfc + " has been copied into the point dataset")

    polyline_output_location = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\polyline"
    polylinelist = arcpy.ListFeatureClasses("", "polyline")
    arcpy.AddMessage(polylinelist)
    for fc in polylinelist:
        if 'WA' in fc:
            arcpy.AddMessage(fc)
            fc1 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc1[1] + "_" + fc1[0] + "_" + fc1[2] + "_" + fc1[3].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, polyline_output_location + os.sep + outfc)  # copy the polylines
            arcpy.AddMessage(polyline_output_location + os.sep + outfc + " has been copied into the polyline dataset")
        else:
            arcpy.AddMessage(fc)
            fc2 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc2[1] + "_" + fc2[0] + "_" + fc2[2].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, polyline_output_location + os.sep + outfc)  # copy the polylines
            arcpy.AddMessage(polyline_output_location + os.sep + outfc + " has been copied into the polyline dataset")

    polygon_output_location = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\polygon"
    polygonlist = arcpy.ListFeatureClasses("", "Polygon")
    removeAOI = polygonlist.remove("Amherst_Clip2022.shp")
    arcpy.AddMessage("REMOVED Amherst_Clip2022.shp")
    arcpy.AddMessage(polygonlist)
    for fc in polygonlist:
        if 'WA' in fc:
            arcpy.AddMessage(fc)
            fc1 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc1[1] + "_" + fc1[0] + "_" + fc1[2] + "_" + fc1[3].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, polygon_output_location + os.sep + outfc)  # copy the polygons
            arcpy.AddMessage  (polygon_output_location + os.sep + outfc + " has been copied into the polygon dataset")
        else:
            arcpy.AddMessage(fc)
            fc2 = fc.split("_") # .split to removes the numeric prefix because its not allowed in a GDB
            outfc = fc2[1] + "_" + fc2[0] + "_" + fc2[2].rstrip(".shp")
            arcpy.CopyFeatures_management(fc, polygon_output_location + os.sep + outfc)  # copy the polygons
            arcpy.AddMessage  (polygon_output_location + os.sep + outfc + " has been copied into the polygon dataset")
    
    arcpy.AddMessage("LISTS made, REMOVED Amherstt_Clip2022.shp and LOOPED through each list copied each to respective dataset")

Describe each feature class by type (point, polyline and polygon) and print to screen one at a
time.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    ###### Using Describe ---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("USING DESCRIBE")

    # Describe each feature class by type (point, polyline and polygon) and arcpy.AddMessage to screen one at a time
    feature_class_location = r"D:\Python\Data"

    fcList = arcpy.ListFeatureClasses(feature_dataset = "*")
    for fc in fcList:
        desc = arcpy.Describe(fc)
        arcpy.AddMessage("Here's the Feature claas and it type " + str(desc.shapeType))

Create a new feature dataset called Basemap, again same spatial reference as above.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

        
    #   Create a new feature dataset called Basemap, again same spatial reference as above
    Basemap_location = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb"
    
    BasemapDataset_Location = Basemap_location
    BasemapDataset = "Basemap"
    arcpy.CreateFeatureDataset_management(BasemapDataset_Location, BasemapDataset)
    arcpy.AddMessage("BasemapDataset made")

Merge the Points, Polylines and Polygon feature classes and store outputs in Basemap
feature dataset.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    # Merge the Points, Polylines and Polygon feature classes and store outputs in Basemap feature dataset
    feature_class_to_merge_location = r"D:\Python\Data"

    points_to_merge = arcpy.ListFeatureClasses("", "Point")
    Merged_points = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points"
    arcpy.Merge_management(points_to_merge, Merged_points)
    arcpy.AddMessage("Merged points")

    Polylines_to_merge = arcpy.ListFeatureClasses("", "Polyline")
    Merged_Polylines = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines"
    arcpy.Merge_management(Polylines_to_merge, Merged_Polylines)
    arcpy.AddMessage("Merged Polylines")

    Polygons_to_merge = arcpy.ListFeatureClasses("", "Polygon")
    Merged_Polygons = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons"
    arcpy.Merge_management(Polygons_to_merge, Merged_Polygons)
    arcpy.AddMessage("Merged Polygons")

Make a copy the AOI shapefile and place in the Basemap feature dataset.

and

Clip the Points, Polylines and Polygon feature classes to the AOI and store in the Basemap
feature dataset add _Clip to the end of each name.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    # Make a copy the AOI shapefile and place in the Basemap feature dataset
    AOI = r"D:\Python\Data\Amherst_Clip2022.shp" 
    out_AOI = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\AOI"
    arcpy.CopyFeatures_management(AOI, out_AOI)
    arcpy.AddMessage("AOI copied")

    # Clip the Points, Polylines and Polygon feature classes to the AOI and store in the Basemap feature dataset add _Clip to the end of each name
    pointFC = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points"
    clip_feature = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\AOI"
    clipped_points = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points_Clip"
    arcpy.Clip_analysis(pointFC, clip_feature, clipped_points)
    arcpy.AddMessage("Clipped points")

    PolylineFC = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines"
    clip_feature = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\AOI"
    clipped_Polylines = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines_Clip"
    arcpy.Clip_analysis(PolylineFC, clip_feature, clipped_Polylines)
    arcpy.AddMessage("Clipped Polylines")

    PolygonFC = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons"
    clip_feature = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\AOI"
    clipped_Polygons = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons_Clip"
    arcpy.Clip_analysis(PolygonFC, clip_feature, clipped_Polygons)
    arcpy.AddMessage("Clipped Polygons")

Permanently Join NSTDB_FCODES.csv in the Assignment 1 data folder for each of the clipped
dataset

and

Print the total number of Points, Polyline and Polygon features to screen for each feature
class

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    ###### Joins ---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("JOINS")
    # The feature_codes table is already a dbf. Go into the Python\Data folder and find the feature codes table and you'll see its a .dbf
    # No need to convert from .csv to a .dbf
    
    # Permanently Join NSTDB_FCODES.csv in the Assignment 1 data folder for each of the clipped datasets
    points = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points_Clip"
    pointsField = "FEAT_CODE"
    JoinTable = r"D:\Python\Data\feature_codes.dbf"
    feature_codes_Field = "FEAT_CODE"
    arcpy.JoinField_management(points, pointsField, JoinTable, feature_codes_Field)
    arcpy.AddMessage("Joined points")

    Polylines = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines_Clip"
    PolylinesField = "FEAT_CODE"
    JoinTable = r"D:\Python\Data\feature_codes.dbf"
    feature_codes_Field = "FEAT_CODE"
    arcpy.JoinField_management(Polylines, PolylinesField, JoinTable, feature_codes_Field)
    arcpy.AddMessage("Joined Polylines")

    Polygons = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons_Clip"
    PolygonsField = "FEAT_CODE"
    JoinTable = r"D:\Python\Data\feature_codes.dbf"
    feature_codes_Field = "FEAT_CODE"
    arcpy.JoinField_management(Polygons, PolygonsField, JoinTable, feature_codes_Field)
    arcpy.AddMessage("Joined Polygons")

    ###### Printing\AddMessage results---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("PRINTING\ADDMESSAGE RESULTS")

    Merged_points_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points_Clip"
    pointsCount = arcpy.GetCount_management(Merged_points_Clip)
    arcpy.AddMessage("This is how many Points there is: " + str(pointsCount))

    Merged_Polylines_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines_Clip"
    PolylineCount = arcpy.GetCount_management(Merged_Polylines_Clip)
    arcpy.AddMessage("This is how many Polylines there is: " + str(PolylineCount))

    Merged_Polygons_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons_Clip"
    PolygonCount = arcpy.GetCount_management(Merged_Polygons_Clip)
    arcpy.AddMessage("This is how many Polygons there is: " + str(PolygonCount))

Create a user named summary table of each feature class using the Legend field to get the
Sum or Count of the total for each. (Use mysum as the default and add _line, _poly and
_point at the end of each and store in the Geodatabase).

and

Using a Cursor, loop through each record of the three summary table results and
print\AddMessage the summary result fields to screen one at a time.

### Technique 1: Running the tool with a AddMessage statement before stating it is started and after stating it finished
### Technique 2: Adding a print statement stating which tool is running
### Technique 3: Try-Except
#-------------------------------------------------------------------------------------------------------------------------

import os,sys,arcpy
from arcpy import env as e
arcpy.AddMessage("Imported arcpy, os, sys, and env as e")

# Try-Except statement
try:
    ###### Data prep and management ---------------------------------------------------------------------------------------------------
    arcpy.AddMessage("DATA PREP AND MANAGEMENT")
    
    # Allow user to specify a workspace and a new output folder. (Use "D:\Python\Data" as the default and folder named "Results")
    e.workspace = r"D:\Python\Data"  
    workspace = e.workspace                            
    arcpy.AddMessage("Specified a workspace")
    
    out_workspace = r"D:\Python\Data\Results"         
    e.overwriteOutput = True        
    arcpy.AddMessage("Specified an out workspace")

    ###### Create summary tables---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("CREATE SUMMARY TABLES")

    Merged_points_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_points_Clip"
    mysum_point = arcpy.GetParameter(3)
    StatisticsField = [["DESCRIPT", "COUNT"]]
    CaseField = "DESCRIPT"
    arcpy.Statistics_analysis(Merged_points_Clip, mysum_point, StatisticsField,)
    arcpy.AddMessage("Finished Summarizing points")

    Merged_Polylines_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polylines_Clip"
    mysum_line = arcpy.GetParameter(4)
    StatisticsField = [["DESCRIPT", "COUNT"]]
    CaseField = "DESCRIPT"
    arcpy.Statistics_analysis(Merged_Polylines_Clip, mysum_line, StatisticsField,)
    arcpy.AddMessage("Finished Summarizing Polylines")

    Merged_Polygons_Clip = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\Basemap\Merged_Polygons_Clip"
    mysum_poly = arcpy.GetParameter(5)
    StatisticsField = [["DESCRIPT", "COUNT"]]
    CaseField = "DESCRIPT"
    arcpy.Statistics_analysis(Merged_Polygons_Clip, mysum_poly, StatisticsField,)
    arcpy.AddMessage("Finished Summarizing Polylines")

    ###### Using Cursors---------------------------------------------------------------------------------------------------------------------------------
    arcpy.AddMessage("USING CURSORS")

    mysum_point = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\mysum_point"

    point_cursor = arcpy.da.SearchCursor(mysum_point, ["*"])
    for row in point_cursor:
        arcpy.AddMessage("OBJECTIDE: {0}, FREQUENCY: {1}, COUNT_DESCRIPT: {2}".format(row[0], row[1], row[2]))
    arcpy.AddMessage("Finished points cursor")
    del point_cursor
    
    mysum_line = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\mysum_line"

    polyline_cursor = arcpy.da.SearchCursor(mysum_line, ["*"])
    for row in polyline_cursor:
        arcpy.AddMessage("OBJECTIDE: {0}, FREQUENCY: {1}, COUNT_DESCRIPT: {2}".format(row[0], row[1], row[2]))
    arcpy.AddMessage("Finished lines cursor")
    del polyline_cursor

    mysum_poly = r"D:\Python\Data\Results\Assignment2_AniMorrow.gdb\mysum_poly"

    polygon_cursor = arcpy.da.SearchCursor(mysum_poly, ["*"])
    for row in polygon_cursor:
        arcpy.AddMessage("OBJECTIDE: {0}, FREQUENCY: {1}, COUNT_DESCRIPT: {2}".format(row[0], row[1], row[2]))
    arcpy.AddMessage("Finished poly cursor")
    del line_cursor
    ######---------------------------------------------------------------------------------------------------------------------------------

except:
    import traceback
    e = sys.exc_info()[1]
    arcpy.AddMessage(e.args[0])
    arcpy.AddMessage("ERROR!")
    print (e.args[0])
    print ("ERROR!")

# Script Finished
arcpy.AddMessage("Script finished")

# Cleans out the memory for the script
del arcpy

Give the game more features

import random
def roll():
    return random.randint(1,6)
roll()