1. Create a lambda function

Anonymous functions in Python are called Lambda functions. Typical functions are in Python are defined using the def keyword. Anonymous functions are defined using the lambda keyword.

1) Create a lambda function

--

--

List comprehensions are an alternative to using for loops and lambda functions (next section). They are an elegant and concise way to define and create lists based on existing list or string. The syntax of a list comprehension Is as follows:

--

--

Loops allow you to execute a block of code multiple times. There are 2 types of loops in Python:

  • For Loops
  • While Loops

Writing a For Loop based on a range: The range function generates a sequence of numbers starting with 0.

Writing a For Loop based on a subset of a range: Use the range function to generate a loop starting at position 5 and ending at position 9

Writing a For Loop using step counts: Use the range function to generate a loop with 10 positions and output only every 2 positions.

--

--

Python gives us many useful methods for dealing with Strings.

1) Make all the characters in a string upper case

2) Make all the characters in a string lower case

3) Make the first letter of a string capital

4) Make a string title case

Title case means that the first letter of every word is capitalized

5) Check if a string is a number

6) Check the length of a string

7) Pad a string with zeros

--

--