This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Initiating variables, list is fixed, value is an input from the console | |
| # and result is an empty list to be filled with results | |
| list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| value = int(input("what would you like to count to?")) | |
| result = [] | |
| # For loop that compares values in list to value from beginning to end of the list. | |
| # if the value in list is smaller than value then it is appended to the empty list result | |
| for i in range(len(list)): | |
| if list[i] <= value: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Enter number for divisors here | |
| Num = int(input("What number do you want Divisors for?")) | |
| #Ensure number is positive | |
| if Num <= 0: | |
| print("Number must be positive") | |
| quit() | |
| #create range to work in | |
| range_nums = range(1, Num) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| # Generate Lists | |
| list1 = random.sample(range(50), 20) | |
| list2 = random.sample(range(50), 20) | |
| lists_compared = [] | |
| # Compare list a and b, put into a list from a set (compares as a set) |
NewerOlder