Question

x-12 def f1(a, b-x): print (a, b) x-15 f1(4) a) Error b) 12 4 c) 4 12 d) 4 15 Part 2: Show how this function is called b. Wri

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

r5 p1 xd 12345678

In [37]: runfile( C:/Users/ Administrator/Desktop/untitledl.py, wdir-C:/Users/Administrator/Desktop) 4 12 In [38]:|

Output is: 4 12

As the first argument is passed and which is 4, and the second argument is not passed but it is assigned to x in the function itself, so it takes the value of x and prints it.

Hence we get the following output.

Option C is correct.

2.

PART A:

#function to find the complement of the DNA sequence
def dna_complement(seq):
    output = ''
    
    #loop will go through each alphabet in sequence and convert them accordingly and add to the output string
    for letter in seq:
        letter = letter.upper()

        if letter == 'A':
            output += 'T'
            
        elif letter == 'T':
            output += 'A'
            
        elif letter == 'G':
            output += 'C'
            
        elif letter == 'C':
            output += 'G'
        
        else:
            output += ''
    
    #returning the complemented sequence
    return output

#taking user input for DNA sequence
dna_seq = input('Enter a DNA sequence: ')

#calling the funcion and storing the result 
complement = dna_complement(dna_seq)

#displaying the result
print('\nComplemented sequence is: ',complement)

1#function to find the complement of the DNA sequence 2 def dna_complement(seq) 3 output - 5 6 #loop will go through each alpIn [15]: runfile( C:/Users/Administrator/Desktop/untitledl.py, wdir C:/Users/ Administrator/Desktop) Enter a DNA sequence: a

PART B:

#function to find the complement of the DNA sequence
def dna_complement(seq):
    output = ''
    
    #loop will go through each alphabet in sequence and convert them accordingly and add to the output string
    for letter in seq:
        letter = letter.upper()

        if letter == 'A':
            output += 'T'
            
        elif letter == 'T':
            output += 'A'
            
        elif letter == 'G':
            output += 'C'
            
        elif letter == 'C':
            output += 'G'
        
        else:
            output += ''
    
    #returning the complemented sequence
    return output

#opening the file to read from
f = open("DNAseq.txt", "r")

#opening the file to write in
f_1 = open("DNAcomp.txt", "w")

#reading the lines from the file of DNAseq and the calling the function to find the complement and then writing to the file DNAcomp
for x in f:
    comp_seq = dna_complement(str(x))
    f_1.write(comp_seq)
    f_1.write('\n')

#closing both files
f.close()
f_1.close()

2 def dna_complement(seq) output- 4 5 6 #loop will go through each alphabet in sequence and convert them accordingly and a fo

For help please comment.

Thank You.

Add a comment
Know the answer?
Add Answer to:
X-12 def f1(a, b-x): print (a, b) x-15 f1(4) a) Error b) 12 4 c) 4 12 d) 4 15 Part 2: Show how th...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word)...

    Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word) To run the function modify() defined above, we make the following call: result = modify('course', 's') Find and fix the errors in the function definition, lines (1) to (4), such that after the call is executed: • Variable result has the value 'courses' • 'new word is courses' is printed out. For each error found and fixed, you must indicate the following: • line...

  • In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a seri...

    In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a series of characters separated by a single space - The second line contains the number of states as an integer k 2 1; states will be numbered 0,1,..., k -1. The start state is always state O The third line contains a series...

  • In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a seri...

    In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a series of characters separated by a single space - The second line contains the number of states as an integer k 2 1; states will be numbered 0,1,..., k -1. The start state is always state O The third line contains a series...

  • I'm a bit confused on how to get this program to run right. Here are the...

    I'm a bit confused on how to get this program to run right. Here are the directions: Part 1: Write a Python function called reduceWhitespace that is given a string line and returns the line with all extra whitespace characters between the words removed. For example, ‘This line has extra space characters ‘  ‘This line has extra space characters’ Function name: reduceWhitespace Number of parameters: one string line Return value: one string line The main file should handle the...

  • Consider the following Python program: def fun(x, y): return x + y # [2] # [1]...

    Consider the following Python program: def fun(x, y): return x + y # [2] # [1] a = fun(2, 3) b = fun("2", 3) print a, b What does it evaluate to? Replace the last statement print a, b with print a + b and explain the traceback. What's wrong? Now eliminate the line marked [1] and change line [2] to read return x + y. Run the program and explain the traceback. Consider the following definition: def fun(n, m):...

  • Write a class called TemperatureFile. • The class has one data attribute: __filename • Write get...

    Write a class called TemperatureFile. • The class has one data attribute: __filename • Write getter and setter for the data attribute. • Write a “calculateAverage” function (signature below) to calculate and return average temperature of all temperatures in the file. def calculateAverage(self): • Handle possible exceptions Write a main function: • Create a file ('Temperatures.txt’) and then use “write” method to write temperature values on each line. • Create an object of the TemperaureFile with the filename (‘Temperatures.txt’) just...

  • Program In Assembly For this part, your MAL program must be in a file named p5b.mal....

    Program In Assembly For this part, your MAL program must be in a file named p5b.mal. It must have at least one function in addition to the main program. For the purposes of Part (b), you may assume the following 1. Any line of text typed by a user has at most 80 characters including the newline character. 2. A whitespace character refers to a space, a tab or the new line character. 3. A word is any sequence of...

  • Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string...

    Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...

  • Program is in C++.   Write a function named wordStatsPlus that accepts as its parameter a string...

    Program is in C++.   Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...

  • 1) Write a complete C or C++ program to print Hello World Greetings. 2) Using the...

    1) Write a complete C or C++ program to print Hello World Greetings. 2) Using the command line, compile and generate the executable for the above program. Let’s call helloWorld the target executable. 3) Write a C program that does the following: a) forks a child to execute helloWorld b) waits for the child execution to end 4) Reuse the above program to try a different variant of exec family of system calls. OPTIONAL: 1) write a program main that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT