This file contains 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
#Number Guesser 2 | |
print("Think of a number between 1 and 100.") | |
def checker(guess): | |
nums = [1,2,3] | |
print("Number is "+ str(guess) + ". Is my answer:") | |
print("[1] correct") | |
print("[2] Too high") | |
print("[3] Too low") | |
while True: |
This file contains 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 | |
#Linear search | |
def linseach(ordered_list, element_to_find): | |
for i in ordered_list: | |
if i == element_to_find: | |
return True | |
return False | |
#Binary search |
This file contains 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
def fibonacci(): | |
count = int(input("How many fibs?")) | |
n1 = 1 | |
n2 = 0 | |
sequence = [0] | |
for i in range(count): | |
sequence.append(n1) | |
n1 = n1 + sequence[n2] | |
n2 += 1 | |
del sequence[0] |
This file contains 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
def rps(): | |
one = input("Player one Choose rock, paper or scissors").lower() | |
two = input("Player two Choose rock, paper or scissors").lower() | |
list = ["rock", "scissors", "paper", "rock"] | |
if (one or two) not in list: | |
print("fail") | |
else: | |
if one == two: | |
print("draw") | |
elif (list.index(one) + 1) == (len(list) - 1 - list[::-1].index(two)): |