Skip to content

Instantly share code, notes, and snippets.

@Hwatwasthat
Hwatwasthat / main.py
Last active February 21, 2018 10:56
List manipulation created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-manipulation
# 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:
@Hwatwasthat
Hwatwasthat / main.py
Created February 21, 2018 10:55
Divisors created by Hwatwasthat - https://repl.it/@Hwatwasthat/Divisors
#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)
@Hwatwasthat
Hwatwasthat / main.py
Created February 21, 2018 10:54
List comparison created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-comparison
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)