Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # -"- coding: utf-8  -"-
  2. print("--- DZ 29.03 --------зад.1-сумма цифр числа  -----------")
  3. N = int(input('N шестизначное число '))
  4. s  = 0
  5. for i in range(6) :
  6.     s = s + N%10
  7.     N = N//10
  8. print(s)    
  9. print("-------------------- зад.2-квадрат числа ------------- ")
  10. N = int(input('N '))
  11. s = 0
  12. for i in range( N, 0 ,-1) :
  13.     s = s + 2*i - 1
  14. print(s)  
  15. print("--------------------- зад.3-количество перемен знака чисел --------")
  16. #a = [1,-3,-6,8,10,2,-1,0,0,11]
  17. i = 0
  18. a = []
  19. for i in range(10) :
  20.     a.append(int(input("введите 10 +-целых чисел ")))
  21. for i in range(10) :
  22.     if i == 0 :
  23.         s = 0
  24.     elif i > 0 and a[i] > 0 and a[i-1] < 0 :
  25.         s += 1
  26.     elif i > 0 and a[i] < 0 and a[i-1] > 0 :
  27.         s += 1    
  28.     elif i > 0 and a[i] > 0 and a[i-1] == 0 and a[i-2] < 0 :
  29.         s += 1
  30.     elif i > 0 and a[i] < 0 and a[i-1] == 0 and a[i-2] > 0 :
  31.         s += 1
  32.     elif i > 0 and a[i] > 0 and a[i-1] == 0 and a[i-2] == 0 and a[i-3] < 0 :
  33.         s += 1
  34.     elif i > 0 and a[i] < 0 and a[i-1] == 0 and a[i-2] == 0 and a[i-3] > 0 :
  35.         s += 1
  36. print(a)
  37. print('изменений знака чисел :'+ str(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement