Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I ' m trying to write a python code that returns a copy of the tuple with only fixed points as defined below. I '
Im trying to write a python code that returns a copy of the tuple with only "fixed points" as defined below. Im very limited in what functions I use to help me I cannot use enumerate. I have to use an introcs module instead of build in python and I only have access to a find function, an index one, a count one, or a replace tool for tuples. I don't think this answer is supposed to use any of those because the example we were told to use if we were struggling has none of those. I'll attatch an image of the problem, my incorrect answer on the bottom left it'll show how it's incorrect and a screenshot of the example p def fixedpointstup:
Returns a copy of tup, including only the "fixed points".
A fixed point of a tuple is an element that is equal to its position in the tuple.
For example and are fixed points of The fixed points are returned in
the order that they appear in the tuple.
Examples:
fixedpoints returns
fixedpoints returns
fixedpoints returns
Parameter tup: the tuple to copy
Precondition: tup is a tuple of intsImplement fixedpoints
Read the specification of the function
fixedpoints in the module funcs. Implement
this function according to its specification. This is a
function where it is particularly helpful to look at
the examples and test cases.
When you have implemented the function, test
your answer with the test script. You should now
pass all tests.
Check the Function
You may run this test multiple times.
LAST RUN on :: PM
The call fixedpoints returns
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started