Ответ:
import random
n = 5 # Number of random numbers
# Initialize variables for sum and product
sum = 0
product = 1
# Generate random numbers and add them to the sum and product
for i in range(n):
x = random.randint(1, 10)
sum += x
product *= x
# Print the results
print("Sum of random numbers:", sum)
print("Product of random numbers:", product)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
import random
n = 5 # Number of random numbers
# Initialize variables for sum and product
sum = 0
product = 1
# Generate random numbers and add them to the sum and product
for i in range(n):
x = random.randint(1, 10)
sum += x
product *= x
# Print the results
print("Sum of random numbers:", sum)
print("Product of random numbers:", product)