Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 Write a Python recursive function that accepts two integer numbers as parameters representing the width and height of a rectangle and returns the

image text in transcribed
Exercise 1 Write a Python recursive function that accepts two integer numbers as parameters representing the width and height of a rectangle and returns the area of the rectangle. Hint: find the relationship between the area of a rectangle having a width of W and the area of a rectangle having a width of W-1 Exercise 2 Write a Python recursive function that accepts one integer number as a parameter representing the side f a square and Hint: find the relationship between the area of a square having a side of S and the area of a square having a side of S-1 returns the area of the square. Exercise 3: Write a recursive Python function that accepts as a parameter an integer number N and returns the sum of all its digits. Hint: make use of integer division and modulus. Exercise 4: Write a Python recursive function that accepts a string as a parameter and returns the reverse of that string. Hint: remove the first character of the string and add it the reverse of the rest of the string. Exercise 5: Implement the reverse function in exercise 3 using an iteration Exercise 6: (submit your solution on Moodle before 3/11/2018@23:55) Write a Python recursive function that accepts as parameters to strings strl& str2 and returns true if strl is a substring of str2, and false otherwise. Hint: check recursively if str2 starts with strl Exercise 7: Using recursion calculate the sum of all values in a list. Exercise (Challenging Exercise): Write a Python recursive function that accepts as a parameter a string str and returns all the substrings of str Hint: first generate all substrings that start with the first character, then generate recursively the substrings of the string obtained by removing the first character

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions