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
| a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | |
| print (set(a).intersection(set(b))) |
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 | |
| #import time | |
| def passwordgen(): | |
| # ts = time.time() | |
| # st = time.time()- ts | |
| timeroptions = [1,2,3,5,4,8,9,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,5,1,2,3,1,1,1,2,5,5,5,5,5,5,] | |
| timerseed =[1,2,3] | |
| seedlength = len(timerseed) | |
| n=0 |
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 | |
| def passwordgen(): | |
| pass_options = "1234567890!@#$%^&*QWERTTYUIOPSADFGHJKLXZCVBNMqwertyuiopasdfghjklzxcvbnm" | |
| passw = [] | |
| for element in pass_options: | |
| passw.append(element) | |
| password = random.sample(passw,7) | |
| password = ' '.join(map(str, password)) | |
| print("Here is your password = ",password) |
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
| def namelist(): | |
| namelist = input("enter sentence") | |
| newlist = namelist.split(' ') | |
| newlist.reverse() | |
| print(newlist) | |
| namelist() |
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
| def setsfunction(): | |
| list1 = [0,1,1,1,2,4,3,2,5,5,5,4,2,3,4,4,4] | |
| newlist = set(list1) | |
| print(list1) | |
| print (newlist) | |
| (setsfunction()) |
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 math | |
| from math import sqrt | |
| def fibonacci2(): | |
| num = int(input("Enter your chosen number to see the Fibonacci numbers before it")) | |
| a=[] | |
| for i in range(0, (num + 1)): | |
| a.append(int(float(math.pow(1.618033989,i)-math.pow(-0.618033989,i))/sqrt(5))) | |
| if i == (num): | |
| print(a) |
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
| def fibonacci(): | |
| num = int(input("How many fibonacci numbers up to your chosen number")) | |
| fib = [] | |
| i=1 | |
| if num == 0: | |
| fib = [] | |
| elif num == 1: | |
| fib = [1,1] | |
| elif num == 2: | |
| fib = [1,1] |
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 | |
| rand = random.randint(2, 3) | |
| user1 = 0 | |
| count = 0 | |
| while user1 != rand: | |
| print("tries", count) | |
| user1 = int(input("pick number")) | |
| count+=1 | |
| print("user", user1) | |
| print(rand) |
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 | |
| score = 0 | |
| choice = ["rock","scissors","paper"] | |
| x = random.choice(choice) | |
| def rockpaperscissors(): | |
| print(score) | |
| user1 = input("Choose rock, scissors or paper") | |
| if (x == "rock" and user1 == "rock") or (x == "paper" and user1 == "paper") or (x == "scissors" and user1 == "scissors"): | |
| print ("tie") |
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
| word = input("Enter your word in lowercase") | |
| wordlist = list(word) | |
| x = [] | |
| for i in wordlist: | |
| x.append(i) | |
| wordlist.reverse() | |
| if wordlist == x: | |
| print(word, "is a palindrome") | |
| else: | |
| print ("The word is not a palindrome") |
NewerOlder