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
class Employee(object): | |
"""Models real-life employees!""" | |
def __init__(self, employee_name): | |
self.employee_name = employee_name | |
def calculate_wage(self, hours): | |
self.hours = hours | |
return hours * 20.00 | |
# Add your code below! |
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
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] | |
def print_grades(grades): | |
for grade in grades: | |
print grade | |
def grades_sum(grades): | |
total = 0 | |
for grade in grades: | |
total += grade |
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 median(nums): | |
nums = sorted(nums) | |
if len(nums) % 2 == 0: | |
# if even, grab the two mid letters | |
return (nums[int(len(nums) / 2) - 1] + nums[int(len(nums) / 2)]) / 2.0 | |
else: | |
return nums[int(len(nums) / 2)] | |
print median([4, 5, 5, 4]) #returns 4.5 |
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 remove_duplicates(nums): | |
no_dup = [] | |
for num in nums: | |
if not(num in no_dup): | |
no_dup.append(num) | |
return no_dup | |
print remove_duplicates([1,1,2,2]) |
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
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, | |
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, | |
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, | |
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, | |
"x": 8, "z": 10} | |
def scrabble_score(word): | |
word = word.lower() | |
points = 0 | |
for i in word: |
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 re | |
def anti_vowel(txt): | |
return re.sub('a|e|i|o|u', '', txt, flags=re.IGNORECASE) | |
print anti_vowel("I am a chicken!") |
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 is_prime(x): | |
if x < 2: | |
return False | |
for i in range(2, x): | |
if x % i == 0: | |
return False | |
return True |
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 calculate_tax(names): | |
try: | |
new_dict = {} | |
for name in names: | |
a = [0, 1000, 10000, 20200, 30750, 50000] | |
b = [1000, 10000, 20200, 30750, 50000, 100000] | |
p = [0, .1, .15, .2, .25, .3] | |
amount = names[name] | |
tax = 0 | |
i = 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
let fs = require('fs'); | |
// string generated by canvas.toDataURL() | |
let img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0" | |
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" | |
+ "3gAAAABJRU5ErkJggg=="; | |
// Grab the extension of the file | |
let ext = img.split(';')[0].match(/jpeg|png|gif/)[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
function main() { | |
var x1_temp = readLine().split(' '); | |
var x1 = parseInt(x1_temp[0]); | |
var v1 = parseInt(x1_temp[1]); | |
var x2 = parseInt(x1_temp[2]); | |
var v2 = parseInt(x1_temp[3]); | |
// return NO, if the first or second kangaroo is far ahead of each other. | |
if ((x2 > x1 && v2 > v1) || (x1 > x2 && v1 > v2)) { | |
console.log("NO"); |