functions
functions
Functions
Lesson Plan
Polymorphism and
Encapsulation
Java + DSA
Theory Questions:
3. What are the different ways to define and call a function in Python?
5. What are iterators in Python and how do they differ from iterables?
6. Explain the concept of generators in Python and how they are defined.
10. What is the difference between `map()`, `reduce()`, and `filter()` functions in Python?
11. Using pen & Paper write the internal mechanism for sum operation using reduce function on this given
list:[47,11,42,13];
1. Write a Python function that takes a list of numbers as input and returns the sum of all even numbers in
the list.
2. Create a Python function that accepts a string and returns the reverse of that string.
3. Implement a Python function that takes a list of integers and returns a new list containing the squares of
each number.
4. Write a Python function that checks if a given number is prime or not from 1 to 200.
5. Create an iterator class in Python that generates the Fibonacci sequence up to a specified number of
terms.
6. Write a generator function in Python that yields the powers of 2 up to a given exponent.
7. Implement a generator function that reads a file line by line and yields each line as a string.
8. Use a lambda function in Python to sort a list of tuples based on the second element of each tuple.
9. Write a Python program that uses `map()` to convert a list of temperatures from Celsius to Fahrenheit.
10. Create a Python program that uses `filter()` to remove all the vowels from a given string.
11) Imagine an accounting routine used in a book shop. It works on a list with sublists, which look like this:
Write a Python program, which returns a list with 2-tuples. Each tuple consists of the order number and the
product of the price per item and the quantity. The product should be increased by 10,- € if the value of the