Question: is_dna_palindrome: (str, str) -> bool Both parameters are non-empty strings representing DNA strands. The two strands form DNA: are_complementary would return True if called on

is_dna_palindrome: (str, str) -> bool

Both parameters are non-empty strings representing DNA strands. The two strands form DNA: are_complementary would return True if called on the two inputs. Return True if and only if the DNA strands represented by the two parameters form a DNA palindrome.

According to the Oxford Dictionary, a palindrome is "a word, phrase, or sequence that reads the same backward as forward." For example, the phrases "Madam, I'm Adam." and "nurses run" are palindromes. (Notice from these examples that blanks and punctuation are ignored when conisdering whether or not a phrase is a palindrome.) The word "radar" is an odd-length palindrome, and "toot" is an even-length palindrome. A DNA sequence is an inverted repeat palidrome if it is a sequence that reads the same forward as backward, but where the string that is read forward and the string that is read backward are taken from the two strands in the DNA sequence. We will call DNA sequences that satisfy the inverted repeat palindrome property a DNA palindrome. Here are two examples: GGATCC GGCC CCTAGG CCGG Notice that the top strand of the first of these DNA sequences (GGATCC) is the reverse of the corresponding bottom strand (CCTAGG). If you concatenate the top strand and the bottom strand, the result is a string that is a palindrome.

use any of these functions to help:

def is_palindrome_word(word: str) -> bool

reverse = word[::-1] return reverse == word

def is_palindrome_phrase(phrase: str) -> bool

word = "" reverse = "" for i in range(len(string)): if phrase[i].isalpha(): word += phrase[i].lower() if phrase[len(phrase) - i - 1].isalpha(): reverse += phrase[len(phrase) - i - 1].lower()

return word == reverse

def get_odd_palindrome_at(s: str, index: int)-> str

result = '' if 0 <= index < len(s): result += s[index] i = 1 while 0 <= index-i < len(s) and 0 <= index+i < len(s) and s[index-i] == s[index+i]: result = s[index-i] + result + s[index+i] i += 1

return result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!