Facebook
From shine, 1 Year ago, written in Python.
Embed
Download Paste or View Raw
Hits: 109
  1. #python program to print the even numbers from a list
  2. x = [1,2,3,4,5,5,6,8,9,10]
  3. for i in x:
  4.     if i % 2 == 0:
  5.          print(i)
  6.  
  7.  
  8. #python program to sum all numbers in a list
  9. x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
  10. k =0
  11. for i in x:
  12.     k=i+k
  13. print('your total value is ',k)
  14.  
  15.  
  16. #python program to multiply all numbers in a list
  17. x =[1,2,3,4,5,6,7,8,9]
  18. a = 0
  19. for i in x:
  20.     a=i*a
  21. print('your final value after multiplication is ', a)
  22.  
  23.  
  24. #python program to find the maximum value of three numbers
  25. a =19
  26. b=2
  27. c=15
  28. if a>b:
  29.     max_num = a
  30. elif b>a:
  31.     max_num = b
  32. if max_num>c:
  33.     new_max_num = max_num
  34. else:
  35.     new_max_num = c
  36. print('now the maximum value here is ', new_max_num)