Ниже функции, которые это выполняют + одна вс (нужная для третьей)
Объяснение:
def testNumbers1():
print("The first program")
a = int(input('input a: '))
b = int(input('input b: '))
if a == b:
print ('a = b =', a)
elif a > b:
print ('a - b =', a - b)
else:
print ('b - a =', b - a)
def testNumbers2():
print("The second program")
num = int(input('input quantity of numbers: '))
sum = 0
for i in range(num):
number = int(input('number: '))
if (number > 9 and number < 100):
sum =sum + 1
print ('Number of two-digit numbers =', sum)
def sumExclude(numbers, ex):
## Определяет сумму всех чисел, за исключением ex-го
sum = 0;
sizeNumbers = numbers.shape[0]
for i in range(sizeNumbers):
if i != ex:
sum = sum + numbers[i]
return sum
def testNumbers3():
## Выводит число, если оно превосходит сумму всех остальных
print("The third program")
num = 3
numbers = np.zeros(num)
k = 0
numbers[i] = int(input('number: '))
sum = sumExclude(numbers, i)
if numbers[i] > sum:
k = k + 1
print ('Number =', numbers[i], 'The sum of all numbers, excluding this number = ', sum)
if k == 0:
print ('The quantity of numbers that exceeded the sum of the remaining numbers = ', k)
# Вызов функций
testNumbers1()
testNumbers2()
testNumbers3()
Ниже функции, которые это выполняют + одна вс (нужная для третьей)
Объяснение:
def testNumbers1():
print("The first program")
a = int(input('input a: '))
b = int(input('input b: '))
if a == b:
print ('a = b =', a)
elif a > b:
print ('a - b =', a - b)
else:
print ('b - a =', b - a)
def testNumbers2():
print("The second program")
num = int(input('input quantity of numbers: '))
sum = 0
for i in range(num):
number = int(input('number: '))
if (number > 9 and number < 100):
sum =sum + 1
print ('Number of two-digit numbers =', sum)
def sumExclude(numbers, ex):
## Определяет сумму всех чисел, за исключением ex-го
sum = 0;
sizeNumbers = numbers.shape[0]
for i in range(sizeNumbers):
if i != ex:
sum = sum + numbers[i]
return sum
def testNumbers3():
## Выводит число, если оно превосходит сумму всех остальных
print("The third program")
num = 3
numbers = np.zeros(num)
k = 0
for i in range(num):
numbers[i] = int(input('number: '))
for i in range(num):
sum = sumExclude(numbers, i)
if numbers[i] > sum:
k = k + 1
print ('Number =', numbers[i], 'The sum of all numbers, excluding this number = ', sum)
if k == 0:
print ('The quantity of numbers that exceeded the sum of the remaining numbers = ', k)
# Вызов функций
testNumbers1()
testNumbers2()
testNumbers3()