Multiply All Numbers In A List | Python Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

these short exercises really important to lpython learners

freguenshoodjean
Автор

Hello, could you please explain what the i here means?

import array as arr
My_Array = arr.array('i', [1, 2, 3, 4])
print(My_Array)

liri
Автор

please kindly help me with this code its not calculating properly
# write a program that asks the user to enter 5 positive integers,
# the program disregards negative values and zeros and makes the user re enter an input if so.
# The program is capable of calculating both sum and product of all the numbers entered .
# after taking the inputs
# it asks the user whether they want to print the sum of the numbers
# or products and then shows the result accordingly

count = 0
sum = 0
product = 1
while count <= 4 :
numbers = int(input("Please enter 5 different inputs: "))
print()
count += 1
if numbers == 0 or numbers < 0 :
print("Please re-enter input")
else:
print("Would you like to multiply of add the total numbers")
choose = input("Choose to multiply or add now: ")
if choose == "add":
for x in range(numbers):
sum = sum + numbers
print(sum)
if choose == "multiply":
for x in range(numbers) :
product = product * numbers
print(product)

JokeJoshua