Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a script called add_names that will get a name as argument and add this na

ID: 3529959 • Letter: W

Question

Write a script called add_names that will get a name as argument and add this name in file callesd names_list.txt This file should contain names; one name per line. The script should check that the name does not exist in the file before adding it. If the name exists, the script should print a relevant message and quit. It should also check that only one argument is provided and in any other case print a message and quit. Example Assuming that we have a file that contains: Tom Mary Bob Alice Then after running: $ add_names John $ our file should now contain: Tom Mary Bob Alice John While: $ add_names Bob Name already exists $ And: $ add_names Nick Angelo I can only add one name at a time $

Explanation / Answer

def getParameterInfo(self): #Define parameter definitions # First parameter param0 = arcpy.Parameter( displayName="Input Features", name="in_features", datatype="GPFeatureLayer", parameterType="Required", direction="Input") # Second parameter param1 = arcpy.Parameter( displayName="Sinuosity Field", name="sinuosity_field", datatype="Field", parameterType="Optional", direction="Input") param1.value = "sinuosity" # Third parameter param2 = arcpy.Parameter( displayName="Output Features", name="out_features", datatype="GPFeatureLayer", parameterType="Derived", direction="Output") param2.parameterDependencies = [param0.name] param2.schema.clone = True params = [param0, param1, param2] return params

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote