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
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
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}]
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)]
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
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
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]
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]
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
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
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)