Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python program to count positive and negative numbers in a list

# Python program to count positive and negative numbers in a List
  
# list of numbers
list1 = [-10, -21, -4, -45, -66, 93, 11]
  
pos_count, neg_count = 0, 0
num = 0
  
# using while loop     
while(num < len(list1)):
      
    # checking condition
    if list1[num] >= 0:
        pos_count += 1
    else:
        neg_count += 1
      
    # increment num 
    num += 1
      
print("Positive numbers in the list: ", pos_count)
print("Negative numbers in the list: ", neg_count)
Comment

Python program to print negative numbers in a list

# Python program to print negative Numbers in a List
  
# list of numbers
list1 = [-10, 21, -4, -45, -66, 93]
num = 0
  
# using while loop     
while(num < len(list1)):
      
    # checking condition
    if list1[num] < 0:
        print(list1[num], end = " ")
      
    # increment num 
    num += 1
Comment

Python program to print positive numbers in a list

# Python program to print positive Numbers in a List
  
# list of numbers
list1 = [-10, 21, -4, -45, -66, 93]
num = 0
  
# using while loop     
while(num < len(list1)):
      
    # checking condition
    if list1[num] >= 0:
        print(list1[num], end = " ")
      
    # increment num 
    num += 1
Comment

PREVIOUS NEXT
Code Example
Python :: Python - Change List Items 
Python :: generate random integers in a range python 
Python :: python code for string title 
Python :: install anaconda python 2.7 and 3.6 
Python :: Python Tkinter Message Widget 
Python :: hostname python 
Python :: How to check if a given string is a palindrome, in Python? 
Python :: pd dataframe single column rename 
Python :: import django concat 
Python :: python check samplerate of mp3 
Python :: python check if list contains value 
Python :: numpy random for string 
Python :: python script in excel 
Python :: ffmpeg python video from images 
Python :: python game example 
Python :: np.mean 
Python :: python beginner projects 
Python :: python3 lowercase 
Python :: how to use pip commands in pycharm 
Python :: tuple and list in python 
Python :: dfs python 
Python :: python dict comprehension 
Python :: python run powershell command and get output 
Python :: longest common subsequence python 
Python :: access env variable in flask 
Python :: bounding box python 
Python :: python reading csv files from web 
Python :: how to clear the list in python 
Python :: astype python 
Python :: fibonacci recursive python 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =