Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to sum only the odd values in python

>>> lst = [0, 1, 2, 3, 4, 5]>>> sum(n for n in lst if n % 2 != 0)9
Comment

Odd number sum in python

for tc in range(int(input())):
    a,b = map(int,input().split())
    x =  b//2 + (b%2)
    y =  a//2
    print("Case %d: %d"%(tc+1,x*x-y*y))
    
"""
Input:
2
1 10
2 10
Output:
Case 1: 25
Case 2: 24
"""
Comment

PREVIOUS NEXT
Code Example
Python :: calculate sum in 2d list python 
Python :: how to create a save command in python 
Python :: grab the first letter of each string in an array python 
Python :: mro in python 
Python :: what is manage.py 
Python :: python3 password generator script 
Python :: add Elements to Python list Using insert() method 
Python :: fluffy ancake recipe 
Python :: tkinter triangle 
Python :: Python NumPy asfarray Function Example List to float type array 
Python :: geometric progression in python 
Python :: python if else interview questions 
Python :: python how do index all odd numbers in a list 
Python :: import messages 
Python :: qtablewidget add row python 
Python :: flask set mime type 
Python :: opencv write video 
Python :: python for loop inside list 
Python :: python3 vowels and consonants filter 
Python :: utils/decorators.py", line 11, in __get__ raise AttributeError("This method is available only on the class, not on instances.") AttributeError: This method is available only on the class, not on instances. 
Python :: endgame 
Python :: Convert the below Series to pandas datetime : DoB = pd.Series(["07Sep59","01Jan55","15Dec47","11Jul42"]) 
Python :: Installez django-cruds-adminlte 
Python :: feed-forward network medium 
Shell :: bitnami restart apache 
Shell :: postgres stop linux 
Shell :: Remove composer for ubuntu 
Shell :: git clean cache 
Shell :: ubuntu apt-get update without input 
Shell :: how to flush dns on mac 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =