Skip to content

Instantly share code, notes, and snippets.

View libert-xyz's full-sized avatar
🗽
/dev/urandom

Libert Schmidt libert-xyz

🗽
/dev/urandom
View GitHub Profile
square = [X**2 for x in range(10)]
@libert-xyz
libert-xyz / Guest the Number
Created December 30, 2015 05:52
A simple Guest the Number Game
#!/usr/bin/env python
from random import randint
opt = 3
rn = (randint(100,199))
while opt >= 0:
if opt == 0:
print "You Lost, the number was: ", rn
import random
def start_again():
print("Invalid Input")
lets_play()
def play_again():
#Libert R Schmidt
#rschmidt@libert.xyz
#Practice Python http://www.practicepython.org/exercise/2014/04/02/09-guessing-game-one.html
import random
def start_game():
num = int(input("Guess the number between 1 and 9 --> "))
game(num)
##Libert R Schmidt
##rschmidt@libert.xyz
##List Overlap Comprehensions http://www.practicepython.org/exercise/2014/04/10/10-list-overlap-comprehensions.html
import random
a = random.sample(range(1,50),10)
b = random.sample(range(1,50),10)
common = [i for i in a if i in b]
##Libert R Schmidt
##rschmidt@libert.xyz
##http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html
def divisors(num):
c = 0
for i in range(1,num+1):
if num % i == 0:
c = c + 1
return c
#Libert R Schmidt
#rschmidt@libert.xyz
#http://www.practicepython.org/exercise/2014/04/25/12-list-ends.html
def listEnds():
n = 0
a = [5, 10, 15, 20, 25]
newList = []
for i in range(0,2):
#Libert R Schmidt
#http://www.practicepython.org/exercise/2014/04/30/13-fibonacci.html
def fibo(num):
s1 = 0
s2 = 1
l = []
for i in range(num+1):
s2 = s2 + s1
def duplSets(l):
l = set(l)
print (l)
#Libert R Schmidt
# http://www.practicepython.org/exercise/2014/05/15/14-list-remove-duplicates.html
def duplLoop(l):
newL=[]
#Libert R Schmidt
#http://www.practicepython.org/exercise/2014/05/21/15-reverse-word-order.html
def reverse(w):
l = w.split()
l.reverse()
res = ' '.join(l)
print (res)