Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your team captain decided to keep all your decisions password protected. Write a function that takes three parameters: a string, a positive integer and a
Your team captain decided to keep all your decisions password protected. Write a function that takes three parameters: a string, a positive integer and a boolean. Rules: - If one or more inputs do not satisfy the specified type, return 'ERROR!'. - Reverse a given string. - If a number is even, make it odd by adding 1 - If a number is odd, make it even by subtracting 1 - Flip the value of the boolean parameter. Then put all these components together into a string and return it. def password(text, number, boolean): """ Creates a password based on the given parameters: text is reversed, numbers becomes either even or odd, boolean value is flipped Parameters: text: a string number: an integer boolean: a boolean value Returns a password by adding altered components to the string. > password ("trip", "is", True) 'ERROR!' \> password(17, "is", True) 'ERROR!' password ("trip", 18, 20) 'ERROR!' \> password("trip", 18, False) 'pirt19True' > password("car", 21, True) 'rac20False' """ Hint: - Look up: "How to check the type of a variable in Python" - Look up: "How to reverse a string in Python" - Look up: "How to convert an integer to a string in Python
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