Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -"- coding: utf-8 -"-
- print("--- DZ 29.03 --------зад.1-сумма цифр числа -----------")
- N = int(input('N шестизначное число '))
- s = 0
- for i in range(6) :
- s = s + N%10
- N = N//10
- print(s)
- print("-------------------- зад.2-квадрат числа ------------- ")
- N = int(input('N '))
- s = 0
- for i in range( N, 0 ,-1) :
- s = s + 2*i - 1
- print(s)
- print("--------------------- зад.3-количество перемен знака чисел --------")
- #a = [1,-3,-6,8,10,2,-1,0,0,11]
- i = 0
- a = []
- for i in range(10) :
- a.append(int(input("введите 10 +-целых чисел ")))
- for i in range(10) :
- if i == 0 :
- s = 0
- elif i > 0 and a[i] > 0 and a[i-1] < 0 :
- s += 1
- elif i > 0 and a[i] < 0 and a[i-1] > 0 :
- s += 1
- elif i > 0 and a[i] > 0 and a[i-1] == 0 and a[i-2] < 0 :
- s += 1
- elif i > 0 and a[i] < 0 and a[i-1] == 0 and a[i-2] > 0 :
- s += 1
- elif i > 0 and a[i] > 0 and a[i-1] == 0 and a[i-2] == 0 and a[i-3] < 0 :
- s += 1
- elif i > 0 and a[i] < 0 and a[i-1] == 0 and a[i-2] == 0 and a[i-3] > 0 :
- s += 1
- print(a)
- print('изменений знака чисел :'+ str(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement