-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhauschildt-exercise6.py
26 lines (21 loc) · 1.54 KB
/
hauschildt-exercise6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from helpers import getNum
from random import randint
# STEP 3: Define a randomNumbers function that takes a number as a parameter.
# STEP 4a: Create an empty array called result
# STEP 5: Create a loop that runs n times
# STEP 6: Generate a random number between 0 and 100. Add the number to the result array.
# STEP 4b: Return the result array variable
# STEP 9: Define a largerThan function that takes an array of numbers and a single number as parameters.
# STEP 10: Create an empty array called result
# STEP 11: Create a loop that runs once for each item in the list/array parameter
# STEP 12: Write an if statement to test if the current value in the list is greater than the number parameter
# STEP 13: If true, write another if statement to test if the current value in the list is not already in the result array
# STEP 14: If true, add the current value in the list to the result array
# STEP 15: Print the list array variable. Label it "List of numbers".
# STEP 16: Sort the result array variable and print it. Label it "Numbers that are greater than [n]"
def main():
# STEP 1: Prompt the user for a number between 10 and 20. Assign the user's response to a variable called howMany.
# STEP 2: Call a randomNumbers function, passing the howMany variable as an argument. Assign the result to a variable called list.
# STEP 7: Prompt the user for a number between 0 and 100. Assign the user's response to a variable called n.
# STEP 8: Call a largerThan function, passing the list and n variables as arguments.
main()