Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 2.09 KB

File metadata and controls

19 lines (17 loc) · 2.09 KB

High Level functions

Write a python program for below tasks using combinations of High level functions (Map, Filter, Reduce, Zip, Reduce). Use Built-in functions.

  • Given a list of strings representing numbers, filter out the odd numbers and then square each of the remaining even numbers.
  • To compute the factorial of a given number.
  • Given two lists of equal length, one containing student names and the other containing their respective grades, create a dictionary where the keys are student names and the values are their corresponding grades.
  • Given two lists of numbers of equal length, filter out the elements from the first list that are greater than the corresponding elements in the second list.
  • Given a list of integers, map each integer to its square, filter out the negative squares, and then find the sum of the remaining squares.
  • Given three lists representing the lengths of the sides of triangles, to filter out the triangles that are not valid (i.e., the sum of any two sides is less than or equal to the third side).
  • Given a list of strings, filter out the strings that contain only vowels and then concatenate the remaining strings into a single string.

Iterators and Generators

Write python program independently using generator and iterator for the below tasks.

  • Write a program that reads a large file line by line and yields each line as it's read. This allows you to process large files without loading the entire contents into memory.
  • Write program to implement lazy evaluation for complex computations.E.g. Fibonacci, prime numbers, or sequences, finding even numbers/ squares, etc.. Instead of eagerly computing all results upfront, generate values on-the-fly.
  • Write program to filter and transform data streams on-the-fly. For example, you can filter out invalid or irrelevant data points, or transform raw data into a more usable format as it's being read.

Add-ons (Only if possible - NOT Mandatory)

  • Write custom functions for all high level functions (lambda, zip, map, filter, reduce) with/without using iterators.
  • Writing random module functionalities on your own.