Adding as many examples as I've converted so far.
This commit is contained in:
1
5 - Random Numbers and For Loops/Challenge/README.md
Normal file
1
5 - Random Numbers and For Loops/Challenge/README.md
Normal file
@@ -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.
|
||||
15
5 - Random Numbers and For Loops/Challenge/main.py
Normal file
15
5 - Random Numbers and For Loops/Challenge/main.py
Normal file
@@ -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))
|
||||
0
5 - Random Numbers and For Loops/README.md
Normal file
0
5 - Random Numbers and For Loops/README.md
Normal file
10
5 - Random Numbers and For Loops/main.py
Normal file
10
5 - Random Numbers and For Loops/main.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import random
|
||||
|
||||
for i in range(10):
|
||||
print("Index Number: " + str(i))
|
||||
|
||||
for i in range(5):
|
||||
print("Int Value " + str(i + 1) + ": " + str(random.randint(1, 100)))
|
||||
print("Float Value " + str(i + 1) + ": " + str(random.random() * 100 + 1))
|
||||
print("Boolean Value " + str(i + 1) + ": " + str(True if random.random() > .5 else False))
|
||||
|
||||
Reference in New Issue
Block a user