Question: # 1 ) Write a function that checks whether a given word or number is palindrome or not # and returns True if it is

# 1) Write a function that checks whether a given word or number is palindrome or not
# and returns True if it is palindrome and False if it is not palindrome.
def is_palindrome(word):
pass # remove this line and comment and replace it with the code needed for the main function.
# write a function that computes the length of a DNA sequence and the proportion of individual bases in the sequences
# Note that: the function must return the four values inorder of , DNA_sequence_length, base_A_proportion,
# base_T_proportion, base_C_proportion and base_G_proportion.
def dna_nucleotide(text):
pass # remove this line and comment and replace it with the code needed for the main function.
def main():
word = input(" Please enter a word : ")
# uncomment the following lines to test your is_palindrome() function
# if is_palindrome(word):
# print(f"{word} is palindrome!")
# else:
# print(f"{word} is not palindrome!")
print()
txt = input(" Please enter a DNA sequence: ")
# uncomment the following lines to test your dna_nucleotide() function
# dna_length, base_A_prop, base_T_prop, base_C_prop, base_G_prop = dna_nucleotide(txt)
# print(f" DNA sequence length ={dna_length}")
# print(f" Base A proportion ={base_A_prop:.2f}%")
# print(f" Base T proportion ={base_T_prop:.2f}%")
# print(f" Base C proportion ={base_C_prop:.2f}%")
# print(f" Base G proportion ={base_G_prop:.2f}%")
if __name__=='__main__':
main() using Assignment Requirements
For this assignment, you need to commplete the following two problems as described below and based on the starter code
Problem 1: A palindrome is a word or number that reads the same backward or forward.
Example:
palindrome number: 121,252,16461,...
palindrome word: racecar, civic, madam, ...
Write a python function to check if a given string is palindrome or not. Your function is name is_palindrome (word). The function returns true if the given word is palindrome , false otherwise.
Problem 2 : Given a DNA nucleotide seqences, for instance:
DNA="ATGCGCGGATCGTACCTAATCGATGGCATTAGCCGAGCCCGATTACGC"
Write a python program that computes the length of the sequence and the proportion of individual bases in the sequence. That is percentage of A(A%), percentage of T (T%,), percentage of C (C%) and percentage of G( G%).
The function name is dna_nucleotide (text) and it returns five values such as dna_length, base_A_proportion, base_T_proportion, base_C_proportion and base_G_proportion respectively. The text can be given in lower case or uppercase. Your code must work in both cases. Thus, consider converting the given text to upper case. There are only four bases (A,T,C and G) in DNA sequence.
Note that:
base_A_proportion(percentage of A )=(number of letter A in the text)/(total length of the text)
Similarly, you can compute for percentage of T , percentage of C and percentage of G."""
this was my written code and there are still test fails can you please fix it
# 1) Write a function that checks whether a given word or number is palindrome or not
# and returns True if it is palindrome and False if it is not palindrome.
def is_palindrome(word):
word = word.lower()
return word == word[::-1]
# write a function that computes the length of a DNA sequence and the proportion of individual bases in the sequences
# Note that: the function must return the four values inorder of , DNA_sequence_length, base_A_proportion,
# base_T_proportion, base_C_proportion and base_G_proportion.
def dna_nucleotide(text):
text = text.upper()
dna_length = leng(text)
count_A = text.count('A')
count_T = text.count('T')
count_C = text.count('C')
count_G = text.count('G')
if dna_length ==0:
return dna_length, 0,0,0,0
prop_A =(count_A / dna_length)*100
prop_T =(count_T / dna_length)*100
prop_C =(count_C / dna_length)*100
prop_G =(count_G / dna_length)*100
return dna_length, prop_A, prop_T, prop_C, prop_G
def main():
word = input(" Please enter a word : ")
if is_palindrome(word):
print(f"
{word} is palindrome!")
else:
print(f"
{word} is not palindrome!")
txt = input("
Please enter a DNA sequence: ")
dna_length, base_A_prop, base_T_prop, base_C_prop
print(f"
DNA sequence length ={dna_length}")
print(f"Base A proportion ={base_A_prop:.2f}%")
print(f"Base T proportion ={base_T_prop:.2f}%")
print(f"Base C proportion ={base_C_prop:.2f}%")
print(f"Base G proportion ={base_G_prop:.2f}%")
if __name__=='__main__':
main()
# 1 ) Write a function that checks whether a

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 Programming Questions!