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
/*! | |
* gulp | |
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev | |
*/ | |
// Load plugins | |
var gulp = require('gulp'), | |
sass = require('gulp-ruby-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
cssnano = require('gulp-cssnano'), |
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 firstDuplicate(a): | |
""" This function return a first doublicate element if it exit and return -1 if it does not .""" | |
new_set = set() | |
for i in a: | |
if i in new_set: | |
return i | |
else: | |
new_set.add(i) | |
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
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
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 nearest_square(limit): | |
""" Find the largest square number smaller than limit. """ | |
answer = 0 | |
while (answer+1)**2 < limit: | |
answer += 1 | |
return answer**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
def word_count(document, search_term): | |
""" Count how many times search_term appears in document. """ | |
words = document.split() | |
answer = 0 | |
for word in words: | |
if word == search_term: | |
answer += 1 | |
return answer |
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 remove_dublicates(source): | |
""" | |
-This program remove dublicate elements in string or list. | |
""" | |
target = [] | |
for element in source: | |
if element not in target: | |
target.append(element) |
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 median(numbers): | |
numbers.sort() | |
if len(numbers) % 2: | |
# if the list has an odd number of elements, | |
# the median is the middle element | |
middle_index = int(len(numbers)/2) | |
return numbers[middle_index] | |
else: | |
# if the list has an even number of elements, | |
# the median is the average of the middle two elements |
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 which_prize(points): | |
""" | |
Returns the prize-winning message, given a number of points | |
""" | |
points = int(points) | |
prize = None | |
if points <= 50: | |
prize = "a wooden rabbit" | |
elif 151 <= points <= 180: |
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 bus_fares(age): | |
""" | |
The bus fares program will print appropriate price for a particular age group. | |
User should enter a age and the program will suggest the price. | |
Parameters: | |
age: enter age as number: | |
""" |
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 garden_calendar(season): | |
if season == "spring": | |
print("time to plant the garden!") | |
elif season == "summer": | |
print("time to water the garden!") | |
elif season == "autumn" or season == "fall": | |
print("time to harvest the garden!") | |
elif season == "winter": | |
print("time to stay indoors and drink tea!") | |
else: |
NewerOlder