{"id":8677,"date":"2021-09-30T11:00:42","date_gmt":"2021-09-30T05:30:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=8677"},"modified":"2021-11-22T18:35:31","modified_gmt":"2021-11-22T13:05:31","slug":"python-program-to-print-sum-of-negative-numbers-positive-even-numbers-and-positive-odd-numbers-in-a-list","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-sum-of-negative-numbers-positive-even-numbers-and-positive-odd-numbers-in-a-list\/","title":{"rendered":"Python Program to Print Sum of Negative Numbers, Positive Even Numbers and Positive Odd numbers in a List"},"content":{"rendered":"

Beginners and experienced programmers can rely on these Best Java Programs Examples<\/a> and code various basic and complex logics in the Java programming language with ease.<\/p>\n

List in Python :<\/strong><\/p>\n

The list data type is one of the most often used data types in Python. The square brackets [ ] easily identify a Python List. Lists are used to store data items, with each item separated by a comma (,). A Python List can include data elements of any data type, including integers and Booleans.<\/p>\n

One of the primary reasons that lists are so popular is that they are mutable. Any data item in a List can be replaced by any other data item if it is mutable. This distinguishes Lists from Tuples, which are likewise used to store data elements but are immutable.<\/p>\n

Given a list the task is to print the sum of all positive even numbers ,odd numbers and negative numbers in the given list in python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list =[23, 128, -4, -19, 233, 726, 198, 199, 203, -13]<\/pre>\n

Output:<\/strong><\/p>\n

The sum of all positive even numbers in thee given list  [23, 128, -4, -19, 233, 726, 198, 199, 203, -13] = 1052\r\nThe sum of all positive odd numbers in thee given list  [23, 128, -4, -19, 233, 726, 198, 199, 203, -13] = 658\r\nThe sum of all positive negative numbers in thee given list  [23, 128, -4, -19, 233, 726, 198, 199, 203, -13] = -36<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list =[-4, 23, 12, -13, 234, 198, 55, -19, 87, 45]<\/pre>\n

Output:<\/strong><\/p>\n

The sum of all positive even numbers in thee given list [-4, 23, 12, -13, 234, 198, 55, -19, 87, 45]\u00a0 = 444 \r\nThe sum of all positive odd numbers in thee given list [-4, 23, 12, -13, 234, 198, 55, -19, 87, 45] =\u00a0 210 \r\nThe sum of all positive negative numbers in thee given list [-4, 23, 12, -13, 234, 198, 55, -19, 87, 45] =\u00a0 -36<\/pre>\n

Python Program to Print Sum of Negative Numbers, Positive Even Numbers and Positive Odd numbers in a List<\/h2>\n

Below are the ways to print the sum of all positive even numbers ,odd numbers and negative numbers in the given list in python.<\/p>\n