Es106 CFP Activity 3 Finals Alu
Es106 CFP Activity 3 Finals Alu
YOUR QUEST:
For this activity, you will follow, implement and answers instructions and questions
that are listed before and after some activity provide a separate document file and
save it as a pdf file and your scripts upon submission, attached your lab manual with
your activity sheet or you can edit the manual and have your scripts paste it on every
number and submit it in our google classroom. By the end of this Laboratory work
you will be able to:
YOUR MISSION:
Write the final output that prints your desired outcome base on the mission.
Modify the Parameters given below and observe what happen upon your changing the
Values and Parameters. You can do this on Google colab/ Jupyter Notebook/Python3:
def updated_area(length) : #this method will allow you to run your function
length = length + 10 #your original value will be added by 10 and stored at your new Parameter length
#script below will give you an output of what value will result upon your function initiated
print (“This is inside my function, updated length: “, length)
#script below will call your defined function and will capture the value of l and used it.
update_area(l)
Write this recursive function factorial(n) in the same platform what you use in mission
2 and run it to compute the factorial of a number n.
def factorial(n) : #this method will allow you to run your function
if n == 0: #this function is example of a if statement that is previously discussed
return 1 #this will give you an output n = 1 when your first statement will be true
#this is an example of a recursive case
else: #this statement will be initiated if your previous function is false
return n * factorial(n-1) #this will give you rerunning the previous function if n < 1.
# script below will give you an output of what value your Parameter n holds.
print (“Factorial of 5 is: “, factorial(5))
Write the function below to the same platform you use previously and run the scripts
and observe how the output look like.
kwarta = 36 #this will be your declared value for your declared parameter
sulod_pitaka() #this method calling will allow you to run your function
# script below will give you an output of what value your Parameter kwarta holds
print (“Akong kwarta gawas pitaka:”, kwarta)
Now try modifying your function to make your parameter kwarta global:
kwarta = 36 #this will be your declared value for your declared parameter
sulod_pitaka() #this method calling will allow you to run your function
# script below will give you an output of what value your Parameter kwarta holds
print (“Akong kwarta gawas pitaka:”, kwarta)
By applying what we already learn, we will now compute the area of a rectangle. You
can define a function compute_area(length, width) that returns the area. Then write a
recursive function to simulate subdividing a rectangle into halves until the area is less
than a threshold.
def compute_area(length, width) : #this will be your function in computing the triangle area
return length * width
By observing the output and modifying it in your own to fully understand, How does
the recursive subdivision help in engineering analysis like material stress testing or
flood zoning or state any real world engineering practice in your course that recursive
help.
Ans:
With the activity that you have done, list at least three statement what did you learn
and realize:
Submitted by:
Course and Section:
Instructor:
Date Submitted: