Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.44 KB

File metadata and controls

33 lines (20 loc) · 1.44 KB

LAB_RECURSION_LAMBDA

1) Using recursion, if given a word/phrase return how many vowels(a,e,i,o,u) are in that phrase or word:

Note: the function should be able to count how many vowels no matter if it is lowercase or uppercase .

Example: given the phrase I love python , it should return : 4

2) Given a list of numbers : [40,35, 10, 15, 20]

create a new list containing each number from the previous list mutliplied by itself.

print the new list.

Note: use map() with a lambda funciton

Bonus (solve in a new file)

Exercise: FizzBuzz

FizzBuzz is a common coding problem that asks you to print the numbers from 1 to 100. However, there are a couple of exceptions:

  1. For multiples of three, print "Fizz" instead of the number.
  2. For multiples of five, print "Buzz" instead of the number.
  3. For numbers which are multiples of both three and five, print "FizzBuzz".

Try to write a Python program that accomplishes this task using a function with a "for" loop. After you've completed that, try to write the same program but using a "while" loop instead.

Remember to test your code to ensure it's working as expected!

Hints:

  • You can use the modulus operator % to check if a number is a multiple of another number. For example, n % 3 == 0 checks if n is a multiple of 3.
  • For the "for" loop, consider using the range function.
  • For the "while" loop, you'll need to manually increment your counter.