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
##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] |
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 | |
##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 |
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 | |
#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): |
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
#rschmidt@libert.xyz | |
#http://www.practicepython.org/exercise/2014/07/05/18-cows-and-bulls.html | |
import random | |
def start(): | |
num = input('Enter a 3 digit number: ') | |
return 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
#Finding the percentage | |
#6/27/16 | |
#https://www.hackerrank.com/challenges/finding-the-percentage | |
avg = {} | |
number = input(('Number of students: ')) | |
for i in range(number): | |
name_marks = raw_input(str('Name and Marks: ')) |
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
#6/28/16 | |
#python 3 | |
#https://www.hackerrank.com/challenges/python-lists | |
for i in range(n): | |
command, *args = input().split() | |
if 'print' in command: | |
print (N) |
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
#https://www.hackerrank.com/challenges/python-tuples | |
#06/29/16 | |
#map(function, iterable, ...) | |
#Return an iterator that applies function to every item of iterable, yielding the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see itertools.starmap(). | |
input() | |
print (hash(tuple(map(int, input().split(" "))))) |
OlderNewer