Python Exercise Lists

Python Lambda Exercises

1. Write a python program to generate a function to double a specified number.

The output is:

Specified number: 27.2

Expected Answer:
The double number of 27.2 = 54.4

Click for the answer



2. Write a python program to generate a function to get the power of a specified number.

The output is:

Power of: 5, 6, 7
Specified number: 3

Expected Answer:
The power of five for number 3 = 15
The power of six for number 3 = 18
The power of seven for number 3 = 21

Click for the answer



3. Write a python program to sort the order of programming based on its alphabet sequence with list of dictionaries, programmer is provided. The expected answer is in the following output for better understanding.

The output is:

programmer =
[{'Name':'Mark', 'Programming':'Python', 'Year of Experience': 3},
{'Name':'Nicole', 'Programming':'C', 'Year of Experience': 1},
{'Name':'Jason', 'Programming':'R', 'Year of Experience': 10}]

Expected Answer:
The initil list of dictionaries :
[{'Name': 'Mark', 'Programming': 'Python', 'Year of Experience': 3},
{'Name': 'Nicole', 'Programming': 'C', 'Year of Experience': 1},
{'Name': 'Jason', 'Programming': 'R', 'Year of Experience': 10}]

After sorting the list of dictionaries :
[{'Name': 'Nicole', 'Programming': 'C', 'Year of Experience': 1},
{'Name': 'Mark', 'Programming': 'Python', 'Year of Experience': 3},
{'Name': 'Jason', 'Programming': 'R', 'Year of Experience': 10}]

Click for the answer



4. Write a python program to sort the programmer user as provided in the output below in increasing order.

The output is:

n_programmer = [('Python', 198), ('C', 112), ('R', 67)]

Expected Answer:
The initial list of tuples:
[('Python', 198), ('C', 112), ('R', 67)]

After sorting the list of tuples:
[('R', 67), ('C', 112), ('Python', 198)]

Click for the answer



5. Write a python program to generate a lambda function that able to add a number of 20.

The output is:

Input number: 10

Expected Answer:
After adding 10: 30

Click for the answer



6. Write a python program to generate a lambda function that able to multiply two input number.

The output is:

Two numbers: 3.2, 7.6

Expected Answer:
Multiplication of both input number: 24.32

Click for the answer



7. Write a python program to generate a lambda function to separate the odd and even number from a list of numbers, list_a as provided in the following output.

The output is:

list_a = [22, 56, 77, 99, 45, 36, 87, 93, 5, 78, 2, 66]

Expected Answer:
The initial list of integers: [22, 56, 77, 99, 45, 36, 87, 93, 5, 78, 2, 66]
Even numbers from the said list: [22, 56, 36, 78, 2, 66]
Odd numbers from the said list: [77, 99, 45, 87, 93, 5]

Click for the answer



8. Write a python program to generate a lambda function to get the power of two on a list of numbers, list_a as provided in the following output.

The output is:

list_a = [22, 56, 77, 99, 45, 36, 87, 93, 5, 78, 2, 66]

Expected Answer:
The initial list of numbers: [3, 22, 36, 45, 56, 77, 87, 93]
The power of two for all elements in list: [9, 484, 1296, 2025, 3136, 5929, 7569, 8649]

Click for the answer



9. Write a python program to generate a lambda function to check whether the specified first letter "C" match with the input values randomly key in by user. (True or False)

The output is:

First letter: C

Expected Answer:
Python starts with C letter: False
C Programming starts with C letter: True

Click for the answer



10. Write a python program to generate a lambda function to check whether a given string is a number or not. (True or False)

The output is:

Example of Expected Answer:
Is the given 3687 a number: True
Is the given Python a number: False

Click for the answer



                               


More Exercises:

Python String Exercises
Python List Exercises
Python Library Exercises
Python Sets Exercises
Python Array Exercises
Python Condition Statement Exercises
Python Lambda Exercises
Python Function Exercises
Python File Input Output Exercises
Python Tkinter Exercises


More Numpy Exercises:

Numpy String Exercises
Numpy Integer Exercises
Numpy Array Exercises
Numpy Data Analysis Exercises
Numpy Data Sorting Exercises


More Pandas Exercises:

Pandas Series Exercises


More Tutorials:

Python Installation - Linux (Ubuntu)
Python Installation - Mac OS
Integrated Development Environment - IDE
Python - Basic Variables
Python - Sequence Introduction
Python - Output Formatting
Python - Escape Character
Python - Type Conversion
Python - Numbers
Python – Arithmetic Operators
Python – Assignment Operators
Python – Comparison Operators
Python – Logical Operators
Python – Precedence and Associativity Operators
Python – Bytes Type and Usage
Python – Long & Raw Strings
Python – Concatenate Function
Python – Slice Function
Python – Length and Split Function
Python – Join and Count Function
Python – Find Function
Python – Index Function
Python – Alignment Function
Python – Startswith and Endswith Function
Python – String Case Conversion
Python – Remove Specified Character
Python – Encode and Decode Function
Python – dir and help Function
Python – Input Output Introduction
Python – Basic Operation
Python – Open Function
Python – Read Function
Python – Readline Function
Python – Write Function
Python – Close Function
Python – Seek and Tell Function
Python – Pickle Module
Python - File Input Module and Linecache Module
Python - Pathlib Module
Python - Pathlib Module
Python - os.path Module
Python - fnmatch Module
Python - Tuple Introduction
Python - List Introduction
Python - List Add Element
Python - List Delete Element
Python - List Modification Element
Python - List Find Element
Python - Dictionary Introduction
Python - Dictionary Basic Operation
Python - Dictionary Method Guide
Python - Set Collection
Python - Set Basic Operation
Python - Set Basic Method
Python - Frozenset Method
Python - If Condition I
Python - If Condition II
Python - While loop
Python - For loop
Python - Pass Statement
Python - Break Statement
Python - Zip Reverse Function
Python - Function Introduction
Python - Positional Parameters
Python - Key Arguments
Python - None and Return
Python - Variable Scope
Python - Local Function
Python - Closure Method
Python - Lamdba Expression