In: Computer Science
Using python as the coding language please write the code for the following problem.
Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness.
First Argument Value |
Second Argument Value |
Return Value |
"coarse" |
"rounded" |
"intermediate" |
"coarse" |
"angular" |
"nearby" |
"medium" |
"rounded" |
"intermediate" |
"medium" |
"angular" |
"intermediate" |
"fine" |
"rounded" |
"intermediate" |
"fine" |
"angular" |
"far" |
Please find the Python code for the following:
Code:
#Defined a function called provenance that takes two string
arguments
#and returns another string depending on the values
def provenance(argument1,argument2):
#Using an if-else ladder, we are checking both the string
arguments
#Then returning the string based on the table return values
if argument1=="coarse" and argument2=="rounded":
return "intermediate"
elif argument1=="coarse" and argument2=="angular":
return "nearby"
elif argument1=="medium" and argument2=="rounded":
return "intermediate"
elif argument1=="medium" and argument2=="angular":
return "intermediate"
elif argument1=="fine" and argument2=="rounded":
return "intermediate"
elif argument1=="fine" and argument2=="angular":
return "far"
Please check the
compiled program and its output for your reference:
Output:
(Feel free to drop me a comment, If you need any help)
Hope this Helps!!!
Please upvote as well, If you got the answer?
If not please comment, I will Help you with that...