Day: February 14, 2021

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

Hits: 15 (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 …

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

Hits: 10 (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 …

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

Hits: 9 (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 …

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

Hits: 3 (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 …