Day: February 14, 2021

Python Example – Write a Python program to display a floating number in specified numbers

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to display a floating number in specified numbers.   Sample Solution Python Code: order_amt = 212.374 print(‘\nThe total order amount comes to %f’ % order_amt) print(‘The total order amount comes to %.2f’ % order_amt) print() Sample Output: The total order amount …

Python Example – Write a Python program to compute the product of a list of integers (without using for loop)

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to compute the product of a list of integers (without using for loop).   Sample Solution Python Code: from functools import reduce nums = [10, 20, 30,] nums_product = reduce( (lambda x, y: x * y), nums) print(“Product of the numbers …

Python Example – Write a Python program to filter the positive numbers from a list

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to filter the positive numbers from a list.   Sample Solution Python Code: nums = [34, 1, 0, -23] print(“Original numbers in the list: “,nums) new_nums = list(filter(lambda x: x >0, nums)) print(“Positive numbers in the list: “,new_nums) Sample Output: Original …

Python Example – Write a Python program to filter the positive numbers from a list

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to filter the positive numbers from a list.   Sample Solution Python Code: nums = [34, 1, 0, -23] print(“Original numbers in the list: “,nums) new_nums = list(filter(lambda x: x >0, nums)) print(“Positive numbers in the list: “,new_nums) Sample Output: Original …