Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All of your code for this problem should go in a file called Recursionwarmup.py. Write each of the following functions using recursion. (Do not use

image text in transcribed
image text in transcribed
All of your code for this problem should go in a file called Recursionwarmup.py. Write each of the following functions using recursion. (Do not use for loops or while loops for these problems.) 1. power(x, y) takes two non-negative integers x and y as input and returns the value x. Of course, we could do this simply using the notation x"y, but the point here is to do this using recursion and multiplication. Note that x is 1 by definition. >>> power(2, 3) >>power(10, 2) 100 2. dot(L, K) should output the dot product of the lists L and k. The dot product of two lists is the sum of the products of the elements in the same position in the two lists. You may assume that the two lists are of equal length. If these two lists are both empty, dot should output e.e. Assume that the input lists contain only numeric values. >>> dot ([s,3], [6,4]) Note that 5*63*4 42 42 3. Gccount (DNA) takes DNA string as input and returns the number of G's and C's that appear in that string >>> GCcount ( 'TGTCG) GCcount ('ATATAT') 4. countstarts (DNA) takes a DNA string as input and returns the number of times the string ATG' appears in that string. We did this problem in Chapter 3 using for loops. The objective here is to do it using recursion >>> countstarts( 'ATGCATGT 5. explode(S) takes a string s as input and should return a list of the characters (each of which is a string of length 1) in that string. For example: >explode('spam) >> explode () Il Note that Python is happy to use either single quotes or double quotes to delimit strings -they are interchangeable but if you use a single quote at the start of the string you must use one at the end of the string (and similarly for double quotes). For example: -spam" >>> .spam. True

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions