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
square = [X**2 for x in range(10)] |
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
#!/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 |
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 | |
def start_again(): | |
print("Invalid Input") | |
lets_play() | |
def play_again(): |
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
#Libert R Schmidt | |
#[email protected] | |
#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) |
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
##Libert R Schmidt | |
##[email protected] | |
##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] |
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
##Libert R Schmidt | |
##[email protected] | |
##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 |
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
#Libert R Schmidt | |
#[email protected] | |
#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): |
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
#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 |
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 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=[] |
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
#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) |
OlderNewer