Adding as many examples as I've converted so far.
This commit is contained in:
1 parent
0aa0875c42
commit
543bc78e51
21 files changed
+161
-3
No files matched your search
@@ -0,0 +1 @@
|
||||
Write a program that requests an integer from the user, and prints that many random numbers AND prints hte sum and average of those numbers.
|
||||
@@ -0,0 +1,15 @@
|
||||
import random
|
||||
|
||||
numberToRandomize = int(input("Number of random values to create: "))
|
||||
|
||||
sum = 0.0
|
||||
|
||||
for i in range(numberToRandomize):
|
||||
randomNumber = random.random() * 100 + 1
|
||||
|
||||
print("Random Number " + (i + 1) + ": " + str(randomNumber))
|
||||
|
||||
sum += randomNumber
|
||||
|
||||
print("Sum = " + str(sum))
|
||||
print("Average = " + str(sum / numberToRandomize))
|
||||
Reference in new issue
Block a user