blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
2d24e37cf81a55cefd83df8bc8e2532ba93a83ad
MQFN/MQFN
/bbmq/server/bbmq.py
1,312
3.984375
4
""" custom queue module implementing a basic queue that will hold the payload """ import Queue class BBMQ(object): """ Custom Queue class """ def __init__(self): """ initialize a queue """ self.queue = Queue.Queue() def add_message(self, message): """ ...
4071598da7f76b0c61a03325b989b3a58f2e91fd
wwwser11/train_task_massive
/task5.py
921
4.1875
4
# 5. В массиве найти максимальный отрицательный элемент. # Вывести на экран его значение и позицию в массиве. # Примечание к задаче: пожалуйста не путайте «минимальный» и «максимальный отрицательный». # Это два абсолютно разных значения. import random print('vvedite diapazon massiiva') char1 = int(input('min massiva:...
f9ab4508ac21a81807a24620c8b3d570c98bafbd
OrestOhorodnyk/101_bd_course
/map_reduce/ip/reduce_ip.py
721
3.65625
4
#!/usr/bin/python3.6 import sys # maps ip's to their counts ip2count = {} ip2bytes = {} # input comes from STDIN for line in sys.stdin: # split to ip and butas line = line.strip(',') # parse the input we got from map_ip.py ip, b, count = line.split(',') # convert count (currently a string) to int...
58e9b549fb1e96269cfdd1f40aaebc0af8e27362
eunabae/Practice
/Programmers/level1/두개합.py
338
3.546875
4
num = [2,1,3,4,1] def solution(numbers): answer = [] # 계산 for i in range(0,len(numbers)-1): for j in range(i+1,len(numbers)): val = numbers[i]+numbers[j] if val not in answer: answer.append(val) # 정렬 answer.sort() return answer solu...
e6bbd698be98304a5f3fdaf1f312fd611a054575
preak95/WordSearch
/createIndexFile.py
5,436
4.21875
4
""" Documentation Hello there. For the purpose of eas in understanding this project at later times in life, and also for the purpose of the understanding of others, I intend to heavily and very extensively documents this python file and all the python files to come. Thank you. Enjoy coding. The purpose of this script...
69cef75addf22569088a959cc25e2833b283fad3
preak95/WordSearch
/Temporary Scripts/addingWordsInFileArrayToDB.py
1,168
3.65625
4
# This script is meant to be run only once. """ As of now, we do not have the list of words in a particular book seprately in our MongoDB. Which is why, in order to not run the whole thing again, we'll use this script to add only the wordlist to the Db """ import os from pymongo import MongoClient import re connection...
503748ff5f9608f1eeda6df9285e9719285e12de
phyng/c-lang
/chapter4/qsort.py
556
3.640625
4
# coding: utf-8 def swap(v, i, j): temp = v[i] v[i] = v[j] v[j] = temp def qsort(v, left, right): if left >= right: return swap(v, left, (left + right) / 2) last = left i = left + 1 while i <= right: try: if v[i] < v[left]: last += 1 ...
2d93fbbe91d1095619239760f66e2e947d9ab9e6
Joon/Advent_Of_Code_2020
/Day11.py
2,747
3.59375
4
rows = [] f = open("Inputs/Day11.txt", "r") for x in f: rows.append(list(x.rstrip())) print(rows) def find_next_seat(all_lines, x, delta_x, y, delta_y): max_x = len(all_lines[0]) - 1 max_y = len(all_lines) - 1 while x <= max_x and y <= max_y: x = x + delta_x y = y + delta_y ...
1cf205ecfa4afdbcf67a12bfd0d8311245443b00
lee-seul/development_practice
/python/step_by_step/01/05_triangle.py
117
3.515625
4
# coding: utf-8 def triangle(): a, b = map(int, input().split()) print("{:0.2f}".format(a*b/2)) triangle()
9c4154f45e741c0f987de2f6f3be3daf3226467a
lee-seul/development_practice
/python/n_bits.py
226
3.671875
4
# coding: utf-8 def binary(n): global A if n < 1: print(A) else: A[n-1] = 0 binary(n - 1) A[n-1] = 1 binary(n - 1) n = int(input()) A = [0 for _ in range(n)] binary(n)
cf6fec1f4abea466f727e12de66edbbf3b499644
lee-seul/development_practice
/python/step_by_step/01/21_maxandmin.py
126
3.5
4
# coding: utf-8 def maxandmin(a, b): return max(min(a, b), a) x, y = map(int, input().split()) print(maxandmin(x, y))
51e44dc21a4e8ce046dd4fab0dcac7072354b5f6
lee-seul/development_practice
/python/algorithms/search_insersion_sort.py
928
3.765625
4
# coding: utf-8 # down_isertion_sort.py # 삽입 정렬, 검색 import time # 입력 함수 t1 = time.time() def input_list(): num = input("수열의 길이 입력: ") num_list = [] for i in range(int(num)): temp = input("숫자 입력: ") num_list.append(int(temp)) return num_list # 정렬 함수 #def sort_list(num_list): # fo...
a4c0df2938d64add3e474cbc7f662651c8e08d21
lee-seul/development_practice
/python/algorithms/change124.py
642
3.671875
4
# coding: utf-8 # change124.py def count_digit(num): std = 3 mul = 2 while(True): if num>std: std += 3**mul mul += 1 else: return mul - 1 def change124(num): answer = "" count = count_digit(num) minus = sum([3**i for i in range(1, count)]) + ...
7c6766f32d66ea1969329e402f28d14a7104b82f
lee-seul/development_practice
/python/step_by_step/01/38_tiles.py
242
3.734375
4
# coding: utf-8 a, b = map(int, input().split()) whole = (a//8) * (b//8) result = 0 if a%8: result += b//8 if b%8: result += a//8 if a%8 and b%8: result += 1 print("The number of whole tiles is {} part tiles is {}".format(whole, result))
79fb7ce262d927e4a9a2054ccef1d1665341cfb4
lee-seul/development_practice
/python/pingpong.py
472
3.609375
4
# coding: utf-8 def in_seven(c): if not c: return False if not (c - 7) % 10: return True return in_seven(c//10) def is_seven(c, plus): if not c % 7 or in_seven(c): return plus * -1 return plus def get_pingpong(x, n, c, plus): if x == c: return n return g...
85894f55ad0b5f8d20631911b66454fb1aa09a2e
lee-seul/development_practice
/python/python_db/select3.py
445
3.9375
4
# coidng: utf-8 # select3.py import sqlite3 # where절 이용 조회용 함수 def select_all_books(): conn = sqlite3.connect('my_books.db') cur = conn.cursor() cur.execute('SELECT title, pages FROM my_books WHERE pages > 300') print('[3] WHERE절 이용 데이터 출력하기') books = cur.fetchall() for book in books: ...
e450b2158deebd2291ac8c05b19ac0237301e40f
lee-seul/development_practice
/python/inflearn/array_01.py
272
3.5
4
# coding: utf-8 import array from pprint import pprint string = "abcdefgh" arr = array.array("u", string) print(arr) print(array.typecodes) arr1 = array.array('i', range(5)) print(arr1) arr1.extend(range(5)) print(arr1) print(arr1[3:6]) print(list(enumerate(arr1)))
bc24c6e26bbb9ec09a01f85da7fce57419c654f2
lee-seul/development_practice
/python/step_by_step/01/11_three.py
159
3.796875
4
# coding: utf-8 def three(): a = int(input()) b = input() for i in range(2, -1, -1): print(a*int(b[i])) print(a*int(b)) three()
0607738866bd75844af281cc900cec5b538a1a45
itar3/usable-stuff
/TestStack.py
774
3.78125
4
class Stack: def __init__(self, size): self.array = [None]*size self.top = -1 self.size = size self.count = 0 def __len__(self): return self.count def is_empty(self): return self.count == 0 def is_full(self): self.count == self.size def pus...
5eaf22c5a065e86c1261be0e3836a27e1407e122
itar3/usable-stuff
/PreOrderBTI.py
2,682
3.6875
4
class TreeNode: def __init__(self, item=None, left=None, right=None): self.item = item self.left = left self.right = right class PreOrderBTIterator: def __init__(self, root): self.current = root self.stack = [] self.stack.append(root) def __iter__(self): ...
8e5c760b3fcee07de0d01208ffebba78810b4108
itar3/usable-stuff
/ListLinked.py
1,919
3.828125
4
class Node: def __init__(self, item, next): self.item =item self.next=next class MyList: def __init__(self, size): self.count = 0 # self.array = build_array(size) self.head = None def is_empty(self): return self.count == 0 def is_full(self): return False ...
b21cbe6200b0c4928c94262109765d832a054827
paruf/Competitive-programming-Library
/Library/divsor.py
401
3.671875
4
def create_divisors(n): """ Rn̑SĂ̖񐔂񋓂Xg쐬B Parameters ---------- n : int R Returns ------- divisorsFlist """ divisors=[] for i in range(1,int(n**0.5)+1): if n%i==0: divisors.append(i) if i!=n//i: divisors.append(n//i) divisors.sort() return...
a6b4a6ada3031b38dec64551705e258d0be5bac8
bipulhstu/Data-Structures-and-Algorithms-Through-Python-in-Depth
/4. Stack/stack_implementation.py
1,162
3.96875
4
class Stack: def __init__(self): self.items = [] def isEmpty(self): #if empty array it returns true. If not empty returns false. Boolean values return self.items == [] def push(self, data): self.items.append(data) #keep appending the given item, which is data in this case, to the stack. def pop(s...
fe5e4243e64ebedaa1b31718b2be256e24cd52a3
bipulhstu/Data-Structures-and-Algorithms-Through-Python-in-Depth
/1. Single Linked List/8. Linked List Calculating Length.py
1,401
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.ne...
95d73f911050ec35c3c72275031267ee9ddca1ae
Shivanandroy/run_models
/run_models/__init__.py
6,483
3.578125
4
def run_regressors(df, target_column): ''' df: Data (dataFrame) target_column: Target variable/column name (str) 1. All regression models are ranked by RMSE (Root Mean Squared Error) 2. Categorical variables are dummy encoded for regression models except for Catboost and LightGBM. ''' ...
755337a994c7b1c78cc9cd4f9e9d22fc7c2c6d97
KOOKDONGHUN/study
/homwork/DeeplearningTextbook/ch7-numpy/p221_final_quiz.py
591
3.703125
4
import numpy as np np.random.seed(0) def make_image(m,n): image = np.random.randint(0,6,(m,n)) return image def change_little(matrix): shape = matrix.shape for i in range(shape[0]): for k in range(shape[1]): if np.random.randint(0,2)==1: matrix[i][k] = np.random.r...
c0cb92f6b1a66e3faaae25bcb01cd8a21cf6e7a2
KOOKDONGHUN/study
/homwork/DeeplearningTextbook/ch14-Preprocessing_by_DataFrame/p423_DataFrame_review.py
1,270
3.609375
4
import pandas as pd from pandas import Series, DataFrame attri_data1 = { 'ID' : ["100", "101", "102", "103", "104", "106", "108" ], 'city' : ['서울', '부산', '대전', '광주', '서울', '서울', '서울'], 'birth_year' : [1990, 1989, 1992, 1997, 1982, 1991, 1988], 'name' : ['명이', '순돌', '짱구',...
69e3da742367dd0272aaefb21969be183f43200c
KOOKDONGHUN/study
/homwork/DeeplearningTextbook/ch7-numpy/p209_transpose_matrix.py
154
3.75
4
import numpy as np arr = np.arange(10).reshape(2,5) # print(f"arr : \n{arr}\nnew_arr : \n{arr.transpose()}") print(f"arr : \n{arr}\nnew_arr : \n{arr.T}")
15477c1628898ab9e0d27aa4fe5903a7f4ab10f7
KOOKDONGHUN/study
/homwork/DeeplearningTextbook/ch7-numpy/p196_bool_index_ref.py
356
3.625
4
import numpy as np t = True f = False arr = np.array([2, 4, 6, 7]) print(arr[np.array([t,t,t,f])]) # [2 4 6] '''이런식으로 인덱스 값에 불값을 넣어서 슬라이싱? 도 가능''' arr = np.array([2,4,6,7]) print(arr[arr % 3 == 1]) # 4 7 한글 = "a" print(한글) arr= np.array([2,3,4,5,6,7]) print(arr % 2 == 0) print(arr[arr % 2 == 0])
b57e9638e2742d813953d157d12fbfd9d224e745
KOOKDONGHUN/study
/keras/keras104_gradient2.py
1,339
3.90625
4
''' import numpy as np import matplotlib.pyplot as plt f = lambda x : 3*x**2 - 4*x + 6 x = np.linspace(-100, 100, 10000) y = f(x) print(y) # plot plt.plot(x, y) #, 'k-') # plt.plot(2, 2, 'sk') plt.grid() plt.xlabel('x') plt.ylabel('y') gradient = lambda x : 2*x - 4 x0 = 0.0 MaxIter = 30 learning_rate = 0.1 print...
05caa2fd68e08437ee71919e6bc044168d4b69fc
emsipop/PythonPractice
/pig_latin.py
680
4.28125
4
def pig_latin(): string = input("Please enter a string you would like translating: ").lower() #Changes case of all characters to lower words = string.split(" ") # Splitting the user's input into an array, each item corresponding to each word in the sentence translation = [] # An empty array which each tr...
4a1333b1c3da67ad28f85a9094066b52c6ad51b6
gaurav9112in/FST-M1
/Python/Activities/Activity8.py
238
4.125
4
numList = list(input("Enter the sequence of comma seperated values : ").split(",")) print("Given list is ", numList) # Check if first and last element are equal if (numList[0] == numList[-1]): print("True") else: print("False")
acdc7afad9f86caf1cac44c2950cbf80033161b5
M0W0G/visual_bubble_sort
/pyplotFInal.py
1,729
3.625
4
import random as ran from matplotlib import pyplot as plt #this is key to allowing plots to update easily from matplotlib import animation #easy swapper function def swap(A, x, y): save = A[x] A[x] = A[y] A[y] = save def bubble_sort(data): swapped = True for x in range(len(data) - ...
75d22dfd7cec3b758a7d67ad57ee7d938f571540
vatsal-shukla/pythonworkspace
/howold.py
459
3.6875
4
from datetime import date, time, datetime def howold(): todaydate=date.today() mydob = date(1991,9,1) momdob = date(1967,7,15) daddob = date(1962,2,5) meold=todaydate-mydob momold = todaydate-momdob dadold=todaydate-daddob # print(type(meold)) print("I am " +str(int(meold.days/365))+ " years ...
906b42aa521322d5afceb7e069396a2366768ef6
KzZe-Sama/Python_Assignment_II
/Qn18.py
370
3.71875
4
import json # Inspecting JSON library # print(dir((json))) # print(help(json)) data={"name":"Aayush","age":19} print("Data: ",data) # Serializing A Dictionary to a Json File json_string = json.dumps(data,indent=2) print("After Serializing") print(json_string) # Deserialize the json file print("After De-Serializing...
b201d75c2d2b2b493a3facfea451767ed384c58d
KzZe-Sama/Python_Assignment_II
/Qn19.py
392
4.09375
4
# Algorithm def valid_parenthese(str1): stock, characters = [], {"(": ")", "{": "}", "[": "]"} for parenthese in str1: if parenthese in characters: stock.append(parenthese) elif len(stock) == 0 or characters[stock.pop()] != parenthese: return False return True # I...
b8b191f0bc565637eed24ca0f0cb9f4707442967
nBidari/contestQuestions
/Python/CCCJ2012/CCCJ32012.py
263
3.546875
4
icon = [["*","x","*"], [" " ,"x","x"], ["*"," " ,"*"], ] k = int(input("")) iLen = len(icon) for i in range(iLen): for j in range(len(icon[i])): icon[i][j] = icon[i][j] * k #print(icon) for m in range(iLen): for n in range(0,k): print(icon[m])
8bc487a9a40fe4939b53b9e523355e062768cf4b
nBidari/contestQuestions
/Python/CCCJ2010/CCCJ32010PM.py
556
3.828125
4
result = [0,0] pointer = 0 sevenSaid = False while sevenSaid == False: instruction = input("") if instruction[0] == "7": sevenSaid = True else: if (instruction[2] == "A"): pointer = 0; else: pointer = 1; if instruction[0] == "1": result[pointer] = instruction[4] elif instruction[0] ==...
96a74486ee1e206f76fc974a860d795673605285
Donix1337/DingoLingo
/schema.py
439
3.546875
4
import sqlite3 from sqlite3.dbapi2 import connect connection = sqlite3.connect('QuestionsList.db', check_same_thread = False) cursor = connection.cursor() cursor.execute( """CREATE TABLE questions( pk INTEGER PRIMARY KEY AUTOINCREMENT, question VARCHAR(), answer VARCHAR(), ...
85073ef88cc0cd419daaf8c5a53afbbb520ba792
sureshsagi1234/inven_problem
/inventory.py
2,178
3.8125
4
''' Created on Jan 11, 2017 @author: sureshsagiraju ''' ''' Inventory allocator: There should be an inventory allocator which allocates inventory to the inbound data according to the following rules: 1) Inbound orders to the allocator should be individually identifyable (ie two streams may generate order...
846c8a9207de30d4eac4f05be8df53fdd29bd4f6
aniruddha2000/dsa
/sorting/selectionSort.py
369
4
4
def selectionSort(arr): n = len(arr) for i in range(n): min = i for j in range(i+1, n): if arr[j] < arr[min]: min = j arr[i], arr[min] = arr[min], arr[i] arr = [64, 34, 25, 12, 22, 11, 90] selectionSort(arr) print ("Sorted array is:") for i in range(len(...
85bead6af738e96f4805921f1e18d8adc80dac1b
aniruddha2000/dsa
/tree/Binary Search Tree/find_shortest.py
1,579
3.890625
4
# If both keys are greater than the current node, we move to the right child of the current node. # If both keys are smaller than current node, we move to left child of current node. # If one keys is smaller and other key is greater, current node is # Lowest Common Ancestor (LCA) of two nodes. # We find distances of cu...
d03cc0c77d0044b383878f62bb8d80ec9189a597
aniruddha2000/dsa
/searching/binary_search.py
428
3.859375
4
def binary_search(arr, l, r, x): while l <= r: mid = l + (r - l) // 2 if arr[mid] == x: return arr[mid] if x > arr[mid]: l = mid + 1 if x < arr[mid]: r = mid - 1 return False arr = [10, 19, 25, 36, 55, 69, 78] x = 55 a = binary_search(arr, 0...
1de9825866a894d05f15ae8464135a8cd0e6fd65
aniruddha2000/dsa
/sorting/shellSort.py
451
3.78125
4
def shellSort(arr): n = len(arr) gap = n // 2 while gap > 0: for i in range(gap, n): v = arr[i] j = i while arr[j-gap] > v and j >= gap: arr[j] = arr[j-gap] j -= gap arr[j] = v gap = gap // 2 arr = [64, 34, 2...
020e801e0be13679a66e113af0945c191d54e2e9
aniruddha2000/dsa
/Recursion/reverseStringRecursion.py
210
4.15625
4
def reverse(string): if len(string) == 0: return string else: return reverse(string[1:]) + string[0] if __name__ == "__main__": result = reverse("aniruddha basak") print(result)
1b5e34be4ad6dfccaacb1da9753ccffdec9877f0
aniruddha2000/dsa
/sorting/countSort.py
425
3.734375
4
def count_sort(arr): max_ele = int(max(arr)) count = [0 for i in range(max_ele+1)] for i in arr: count[i] += 1 i, j = 0, 0 while i < max_ele+1: if count[i] > 0: arr[j] = i j += 1 count[i] -= 1 i += 1 arr = [5, 6, 2, 9, 3, 7, 1] count_s...
e7e3df7be2d198ceed4d498ab6856ae495acd08e
aniruddha2000/dsa
/tree/Binary Search Tree/search.py
594
3.9375
4
class Node: def __init__(self, data): self.val = data self.left = None self.right = None def searching_node(root, data): if root == None: return "Empty tree" while root: if root.val == data: return root.val elif data < root.val: root ...
a6ad672efdd82add3163b5a4d82012ee46df6a4b
aniruddha2000/dsa
/string/pattern_match_B_F.py
293
3.734375
4
def search(pat, txt): n = len(txt) m = len(pat) for i in range(n - m): j = 0 while j < m and pat[j] == txt[i+j]: j += 1 if j == m: print("Pattern found at index " + str(i)) txt = "AABAACAADAABAAABAA" pat = "AABA" search(pat, txt)
a42f08e915c1ed49f37054c78ea1e9dff2fec497
michaelczhou/data_mining_class
/dygw/count_attrs.py
1,238
3.5625
4
import os """ # 按属性统计词频, 将结果存入counts目录 """ def count_attr(attr, filename, num=50): with open('attrs/%s.txt' % attr) as f: # 去掉结尾的换行符 data = [line.strip() for line in f.readlines()] novels = data[::2] attrs = data[1::2] novel_attrs = {k: v.split() for k, v in zip(novels, attrs)} w...
6f0788300e8d64e338fb5a0a83ad9502841d7cdc
fernando-b15/Cnyt-lab1
/Calculadora Complejos/Calculadora.py
19,651
3.578125
4
from sys import stdin import math import unittest def main(): inicio() def inicio(): global num1 global num2 ope=stdin.readline().strip() print(ope) if ope=='suma': num1=list(stdin.readline().split()) num2=list(stdin.readline().split()) z=sumar(num1,num2) if z[1...
0071df21d8caf1ecaaf36ee25857ec85b9aae83d
davidjoliver86/advent-of-code-2019
/aoc2019/day3.py
2,344
4.1875
4
""" Day 3: Crossed Wires """ import pathlib import functools from typing import List, Tuple, Set def _trace_path(path: str) -> List[Tuple]: steps = path.split(",") path = [] x = 0 y = 0 for step in steps: direction, distance = step[0], int(step[1:]) if direction == "U": ...
076f2488504981643e90107ef8ba94963f2d43ec
XECOH/TIL
/Self_study/SW_D4/Python/1251.py
1,154
3.703125
4
from collections import deque def find_set(x): if parent[x] != x: parent[x] = find_set(parent[x]) return parent[x] def make_set(x): parent[x] = x rank[x] = 0 def union(x, y): root1 = find_set(x) root2 = find_set(y) if root1 != root2: if rank[root1] > rank[root2]: ...
cbb9eeb81bffab370fd9a279489d1cb7e6f24477
SeanWuLearner/cracking_coding_interview_6th
/src/test_q03_04_queue_via_stacks.py
689
3.515625
4
from stack import Stack def move_stack_data(src, dst): while not src.is_empty(): dst.push(src.pop()) class Queue(): def __init__(self): self._buf = Stack() def add(self, data): self._buf.push(data) def remove(self): if self._buf.is_empty(): return None ...
5ed8c01f4e9aa96f046c555516471e2d9ec06ee0
SeanWuLearner/cracking_coding_interview_6th
/src/test_q01_09_string_rotation.py
307
3.875
4
def is_substring(s, pat): return True if s.find(pat) != -1 else False def is_string_rotation(a, b): a = a + a return is_substring(a, b) def test_func(): assert is_string_rotation("waterbottle", "erbottlewat") == True assert is_string_rotation("waterbottle", "erbottlewata") == False
b10fda40e0bbb9cacaa0e4681ecdcd9b312b70c5
Makellum/Python-skill-challenges
/Orientation Challange Amber Miller.py
418
3.84375
4
print("Today's date?:") date = input() print("What is your favorite number?") number = input() print("What is your favorite color?") color = input() print("How many countries have you visited?") countries = input() print("Pick a number between 1 and 100?:") first_number = int(input()) print("Pick a number between 1 and...
0e8240844666542eeb745b0e53c5471e9a7d55a9
sergiuvidican86/MyRepo
/exerc4 - conditions 2.py
327
4.1875
4
name = "John" age = 24 if name == "John" and age == 24: print("Your name is John, and you are also 23 years old.") if name == "test" pass if name == "John"or name == "Rick": print("Your name is either John or Rick.") if name in ["John", "Rick"]: print("Your name is either John or ...
8b6fede2dc5f08017370143daafb8d6fbddfcc65
oscarwu100/Basic-Python
/HW8/number_writer_wu1563.py
657
4.03125
4
################################################################################ # Author: BO-YANG WU # Date: 03/29/2020 # This program is to asks the user how many numbers it should generate and # then writes that many random numbers to a file named random_numbers.txt. ############################################...
23d44b42ca4e6a2c6ff984854600b2fae57a0990
oscarwu100/Basic-Python
/HW4/prime_list_wu1563.py
661
4.09375
4
################################################################################ # Author: BO-YANG WU # Date: 02/20/2020 # This program predicts the prime number list ################################################################################ def prime_numbers(num):#if is prime if num== 1: ret...
63c29133e42fb808aa8e42954534eef33508e22b
oscarwu100/Basic-Python
/HW4/test_avg_grade_wu1563.py
1,145
4.125
4
################################################################################ # Author: BO-YANG WU # Date: 02/20/2020 # This program predicts the approximate size of a population of organisms. ################################################################################ def get_valid_score():#re print the ...
d9134fcdc5012a0529bd7a77131fa7c80c4a9085
oscarwu100/Basic-Python
/HW2/roulette_wheel_wu1563.py
952
4.125
4
################################################################################ # Author: BO-YANG WU # Date: 02/05/2020 # This program calculate the pocket number color ################################################################################ num= int(input('Please enter a pocket number:')) if num< ...
6dd26ecb710eec1d072c7971044b29362b244b10
AMRobert/Simple-Calculator
/Simple_Calculator.py
1,846
4.15625
4
#SIMPLE CALCULATOR #Function for addition def addition(num1,num2): return num1 + num2 #Function for subtraction def subtraction(num1,num2): return num1 - num2 #Function for multiplication def multiplication(num1,num2): return num1 * num2 #Function for division def division(num1,num2): return num1 / ...
0b54887405c59318adfb679f62c42e1a0de84982
EarthenSky/Image-Filter
/ImGui.NET.SampleProgram.XNA/components/c_smoothing.py
3,262
3.578125
4
''' This component smooths the image by avaraging nearby pixels to adjacent pixels. Can be used as anti-aliasing.''' class Component(): def __init__(self): self._components = [] self.name = "smoothing" def components(self): # Components are tuples with the data (id, title, init, min,...
6da34dc5b159b832eb957b10590bc746cf15ba3b
hzoo/rps
/rockpaperscissors.py
4,143
3.59375
4
#rock paper scissors ''' STUDY p1/p2 #r-r=0, draw #r-p=-2 and p1==r, p2 wins r-s=-4, p1 wins #p-p=0, draw p-r=2 and p1==p, p1 wins #p-s=-2 and p1==p, p2 wins #s-s=0, draw s-r=4, p2 wins s-p=2, and p1==s, p1 wins ''' #version 1.0 May 4, 2020 ''' d={'r':0,'p':2,'s':4} def loop(): a=int(d[input('player 1: ')]) b=...
a2188d2f548c78742eed1d1a6800f0d2a7763bc5
gabemdo/spanish-processor
/spanish-processor/conjugate.py
2,894
3.515625
4
import syllables as s def conjugate_haber(tense,person,number): if tense == 1: if person == 1: return (number == 1 ? 'he' : 'hemos') elif person == 2 and number != 1: return 'habéis' else: return conjugate('har',tense,person,number) if tense == 2: ...
fee26e20a7e7b7a3cad42cfd6bbc7a47a852bd66
egonz042/phys177
/Week2/ex1.py
780
3.546875
4
""" Week 2 Example 1 """ import numpy as np import matplotlib.pyplot as plt def trapFunc(x,y): dx = (x[1] - x[0]) #also h, trap spacing k = 1 #sum index TI = dx * 0.5 * (y[0] + y[-1]) #start I with end values kmax = x.size-1 for k in range(1,kmax): TI += dx * y[k] k += 1 return TI def sampFunc(w,z)...
d9325f7021e1bc9eabe0e5e47b4ef7fb8a460219
Analysis02/gitintro
/atm_mock.py
4,656
3.59375
4
import random import time t = time.localtime() current_time = time.strftime('%H:%M:%S', t) database = {} def init(): print('************ Welcome to Bank Som ************') haveAccount = int(input("Do you have an account with us: 1 (Yes) 2 (No) \n")) if(haveAccount == 1): login() elif(h...
5274f1be337427fa2a2c77295a7dd879b3753d92
huhu42/SQL-Project
/2. Code/improve_data.py
5,385
3.5
4
""" Your task in this exercise has two steps: - audit the OSMFILE and change the variable 'mapping' to reflect the changes needed to fix the unexpected street types to the appropriate ones in the expected list. You have to add mappings only for the actual problems you find in this OSMFILE, not a generalize...
dc5a82908b75658ddcfc02b1ab4cc878ac87770a
lnogueir/interview-prep
/problems/checkPermutation.py
350
3.6875
4
''' Prompt: Given two strings, write a method to decide if one is a permutation of the other. ''' from collections import Counter # O(nlogn + mlogm) def checkPermutation(s1, s2): return sorted(s1) == sorted(s2) def checkPermutationV2(s1, s2): c1 = Counter(s1) c2 = Counter(s2) return c1 == c2 print(check...
b26ea2e34ffd73e41cfaf61ccb7c96d4b864ba53
lnogueir/interview-prep
/problems/oneAway.py
1,236
3.96875
4
''' Prompt: There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. Given two strings, write a function to check if they are one edit (or zero edits) away. ''' def isOneReplaceAway(src, dst): if len(src) != len(dst): return False hasR...
739d011c560247219e51377afa6fafc6a043702b
lnogueir/interview-prep
/problems/mergeIntervals.py
978
3.734375
4
''' Prompt: Given a collection of closed intervals, merge all overlapping intervals. Ex: mergeIntervals(([[1,4],[7,8], [2,5], ]) == [[1,5], [7,8]] ''' # Time: O(nlogn), Space: O(n), though one could argue O(1) space def mergeIntervals(intervals): mergedIntervals = [] intervals.sort(key=lambda item: item[0]) cu...
61bacbb1ea376ca937a28cd73921ff314a6ad154
lnogueir/interview-prep
/problems/assignMiceToHoles.py
550
3.515625
4
''' Prompt: There are N Mice and N holes are placed in a straight line. Each hole can accommodate only 1 mouse. A mouse can stay at his position, move one step right from x to x + 1, or move one step left from x to x -1. Any of these moves consumes 1 minute. Assign mice to holes so that the time when the last mous...
e8af57b1a0b5d1d6ec8e8c7fa2899c2ddc8f2135
lnogueir/interview-prep
/problems/stringRotation.py
1,174
4.40625
4
''' Prompt: Given two strings, s1 and s2, write code to check if s2 is a rotation of s1. (e.g., "waterbottle" is a rotation of "erbottlewat"). Follow up: What if you could use one call of a helper method isSubstring? ''' # Time: O(n), Space: O(n) def isStringRotation(s1, s2): if len(s1) != len(s2): return False...
ac031baae886da1fd8785a74709abe5646ed74ca
lnogueir/interview-prep
/problems/canSum.py
1,505
3.859375
4
''' Prompt: Write a function canSum(targetSum, numbers) that takes in a target Sum and an array of nubmers as arguments. The function should return a boolean indicating whether or not it is possible to generate the targetSum using numbers from the array. You may use an element of the array as may times as needed. Y...
0f5bc641c6f9b7667d210cfac086c5c070699a49
lnogueir/interview-prep
/problems/maxNonAdjSubsetSum.py
602
3.875
4
''' Write a function that takes in an array of positive integers and returns the maximum sum of non-adjacent elements in the array. Ex: Input: [75, 105, 120, 75, 90, 135] Output: 330 // 75 + 120 + 135 ''' def maxSubsetSumNoAdjacent(array, i=0, cache=None): if cache is None: cache = {} if i in cache: re...
52aed69adcf28088031872fdb5855c6af2dcbe52
lnogueir/interview-prep
/problems/partition.py
930
4.09375
4
''' Prompt: Write a function partition(array, left, right) that takes a non-empty array of numbers and boundaries and will modify the array in-place and ensure that all elements in the left of some pivot point are less than pivot point and all elements to the right are greater than the pivot point. Return the index of ...
dd34f7e457f7d55626c887931249290764d94eae
GuidoPaul/2048
/python_web/user39_dPZ0s4MsGk_6.py
4,515
3.515625
4
""" Clone of 2048 game. """ import poc_2048_gui import random # Directions, DO NOT MODIFY UP = 1 DOWN = 2 LEFT = 3 RIGHT = 4 # Offsets for computing tile indices in each direction. # DO NOT MODIFY this dictionary. OFFSETS = {UP: (1, 0), DOWN: (-1, 0), LEFT: (0, 1), ...
e931d6c45ba4181ee92a5df69d3de859f3e2926d
ShreyaKaran14/Python
/program7.py
632
4.15625
4
def birthday(x): if x == 'apurva': print(x,'Birthday is on',data['apurva']) if x== 'ankita': print(x,"Birthday is on",data['ankita']) if x=='madhu': print(x, "Birthday is on",data['madhu']) if x == 'kavita': print(x, "Birthday is on",data['kavita']) name = ['apurva','anki...
ce42401788a199cbf3ef622099e7fb345f404f03
harmydiano/yorubastopwords
/dianocount.py
4,786
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import division,absolute_import import re import string import math def countmain(learn,test,time): print learn,test frequency = {} freq={} new_freq={} new_entrop={} new_variance={} document_text = open('Output3.txt', 'r') ...
0fc0f6280381fb38c45ca3ee726abb926eb0ecff
Bruslan/Ebay
/APISERVICES/test.py
212
3.703125
4
text = "Hallo World Das ist ein Test Und so weiter Used" array = text.split(" ") text_s = "" value_s = array[len(array)-1] for i in (range(len(array)-1)): text_s += array[i] +" " print(text_s) print(value_s)
88d1aabee6fae57b64627fca9f17a623f1604651
negeend/Python-scripts
/dfs.py
964
3.671875
4
class Node: def __init__(self, id, anime): self.id = id self.anime = anime self.left = None self.right = None def DFS_recursive(node): print(node.anime) if node.left: DFS_recursive(node.left) if node.right: DFS_recursive(node.right) def DFS_iterative(n...
2763f4766344b2133e458e321aa5b9de1294ce84
DanJackson29/Project_Opal
/commands.py
764
3.625
4
import weather def runWeatherCommand(): print("Where would you like the weather from?\nYou can enter City, (City, State), or Zip Code.") loc = input(">") weather.getWeather(loc) # def runGetRecipe(): # voiceEngine.say("What recipe would you like to hear?") # voiceEngine.runAndWait() # recip...
dab41da3119e9ddf31da28f8f53e5bf15b0a1c08
sweta134/Hackerank_Practice_Mysolution
/Python_Practice/Loops.py
284
4
4
#Task #The provided code stub reads and integer, , from STDIN. For all non-negative integers , print . #solution - Python 3 if __name__ == '__main__': n = int(input()) for i in range(n): #Range(n) -> value of i=0 to n-1 print(i*i) #or print(i**2) -> i to the power 2
713020b5e737e835ddb818a5faaacd037a2e4d16
RaymondLloyd/Election_Analysis
/Python_practice.py
976
4.15625
4
counties = ["Arapahoe", "Denver","Jefferson"] if counties[1] == 'Denver': print(counties[1]) if "ElPaso" in counties: print("El Paso is in the list of counties.") else: print("El Paso is not in the list of counties.") if "Arapahoe" in counties and "El Paso" in counties: print("Arapahoe and El Paso are i...
889601027509d1470b659b5dc4fe25b9090493ba
KevinWhalen/WeatherAlerts
/alerts/findLocationCode.py
1,004
3.703125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # Takes a city, area, airport, or such and returns the lookup matches. # Using the Weather Underground AutoComplete does not require an API key. ### NOT FINISHED ### from sys import argv #import getopt #from getopt import getopt #import argparse import urllib2 import json ...
f8a3eeb474f824da991de205bcb7b2f15528b938
elli56/my-new-repository
/app.py
2,280
4.09375
4
''' queue ''' class Node: def __init__(self, data): self.data = data self.__next = None def set_next(self, node): if isinstance(node, Node) or node is None: self.__next = node else: raise TypeError("The node must be a Node child or None") de...
affd1501fe8ec9e237aa8215ecd82fff6cd77c11
Skyime/Scripting-Challenges
/tally program.py
1,846
3.921875
4
import re import operator from textwrap import dedent from sys import exit scorers = 'abcde' scores = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0} # function to convert upper and lower case forms of a letter into a positive or negative point, and give the sum def score_convert(letter, to_score): score = ...
9ae73d7203afecb5c21c3381cac5fc08d13d66ce
albinsam7/repeated-values-in-list-tuple
/repeated values in list & tuple.py
266
3.546875
4
def a(x): s=len(x) b=[] for i in range(s): k=i+1 for j in range(k,s): if x[i]==x[j] and x[i] not in b: b.append(x[i]) print(b) a([1,3,4,5,'a',6,7,3,'b',1,4,5,'a']) a((0,2,4,6,8,"r","g",6,2,"r"))
e51c9503a9e0e0dd919e9fd809d26b72228ec8b1
guscastles/ga-project
/helper_funcs.py
3,690
3.671875
4
from urllib.parse import urlparse from urllib.parse import parse_qs import socket # HTTP Status Code Functions def http_status_is_200_parser(http_status_code): """ Call this function parsing the HTTP status code as parameter. It will return True if the status is 200, otherwise False. """ if http_s...
281c586270c7ac4d7b52202667f50f602a30088d
ImDresden/Connect-4
/Matrix.py
6,885
3.859375
4
import turtle class Matrix: def __init__(self, numberColumns, numberRows): # Using this class to save the board data, and search for a victory. self.gameMatrix = [] self.numberColumns = numberColumns self.numberRows = numberRows for i in range(numberRows): ...
e2201c882d418a2fb475265ac4ca4785f38140c6
Salvehn/bushcrawler
/index.py
1,197
3.703125
4
from typing import Iterable class Bush: """bush with berries or maybe not :D""" def __init__(self,r): self.berries=int(r) def __repr__(self): return f'{self.__class__.__name__}({self.berries})' def getBerries(self): return self.berries def crawler(inputstr): if len(input...
4a84cfd7ffefefdf4f03e4ced93a634155340e6e
ProximaMonkey/puzzles
/quixey/binary_search.py
593
3.9375
4
""" Binary Search Input: A sorted (ascending) array of integers Output: Index of item if found, otherwise -1 """ a = [i for i in range(10)] b = [i for i in range(20) if i % 3 == 0] def binary_search(l, target): min = 0 max = len(l) - 1 mid = (min + max) / 2 if l[max] == target: return max while...
9cea75902afcea276fffe060399e690bb6a0391b
ignekt/advent-of-code-2020
/d02/d02_p2.py
500
3.8125
4
import re def check(pos1, pos2, c, password): if password[pos1-1] == c and not password[pos2-1] == c: return True elif password[pos2-1] == c and not password[pos1-1] == c: return True f = open('input.txt') p = re.compile(r'(?P<pos1>\d+)-(?P<pos2>\d+)\s(?P<char>[a-z]):\s(?P<password>[a-z0-9]+)'...
6da9dcbddb51ba57a10a4c4953b1eda523c40d64
waytai/open
/python/odd.py
377
4.03125
4
######################################################################### #-*- coding:utf-8 -*- # File Name: odd.py ######################################################################### #!/bin/python def is_odd(n): return n % 2 == 1 odd = lambda n : n %2 == 1 print list(filter(is_odd, [1,2,3,4,5,6,7,8,9])) p...
9ab42c845ab8f95d6a4633c7e9336f03a450d979
Mukesh170293/Python-practice
/Fizzbuzz.py
455
3.703125
4
class Solution: def fizzBuzz(self, n): result = [] for i in range(n): j = i+1 if(j%3 == 0 and j%5 == 0): result.append("FizzBuzz") elif(j%3 == 0): result.append("Fizz") elif(j%5 == 0): result.ap...
2b4c1bef893ddc4446733848ea49aacbca69a0c0
mett/adventofcode2017
/day5/part2/punchcard.py
869
3.84375
4
""" punchcard.py Implementation to solve day5 of advent of code. """ def run(instructions): """ run(instructions) Runs a series of instructions according to the ruleset given in day5. """ steps = 0 index = 0 while True: try: next_index = instructions[index] except ...
e209927baddff4c3d19ba627e1b5d477369c20c2
mett/adventofcode2017
/day2/test_checksum.py
2,285
3.609375
4
""" test_checksum.py Collection of tests to verify day 2 of adventofcode.com """ import checksum def test_row_even_division_1(): """ test_row_even_division_1() Input: [5, 9, 2, 8] Expected: 4 """ stimuli = [5, 9, 2, 8] expected = 4 result = checksum.calculate_row_even_div(stimuli) ass...
85dce31cbe308ff15fc4e71919e5f2e04fa5e660
HIMANSHUFAGERIA/python-assignment
/APP.py
1,734
3.671875
4
class ubber: def __init__(self, car): self.car = car def Innova(self): self.rate = 12 return self.rate def Jeep(self): self.rate = 12 return self.rate def Swift(self): self.rate = 10 return self.rate def Indica(self): ...
d5993de624e01f52acc14709ac3e6bef307594bf
statistics-exercises/central-limit-theorem-1
/main.py
1,349
3.796875
4
import matplotlib.pyplot as plt import numpy as np def sample_mean(n) : # Your code to generate a sample mean from a sample of n normal # random variables with expectation 0 and variance 1 goes here. n = 20 # This is the number of bins in your histogram counts = np.zeros(n) xmin, xmax = -4, 4 # This is t...
ecfc7e057d9d66f1ed664082e873ecb558f058b1
talesritz/Learning-Python---Udemy-Course
/Utils/https:/github.com/talesritz/Learning-Python---Udemy-Course/tree/master/UtilsTarefa.py
2,049
3.703125
4
from datetime import datetime from utils import validacao class Tarefa: def __init__(self, descricao, vencimento=False): self.descricao = descricao self.feito = False self.criacao = datetime.now() self.vencimento = vencimento def __str__(self): return f'1;32mDescrição: {self.de...
c3f00aade5ee677dbf5e4f04fb902db30d6e2ddb
Kyuwii/Arthur-internship-2020
/Python/floatToIEEE754.py
3,553
3.859375
4
# imports import math def defineInputs(): a = 10#input("Input float number a : ") b = 5.5#input("Input float number b : ") return a, b def findSign(number): if number >= 0: return 0 else: return 1 def convertDecimal(binary): results = 0 for i in range(0, len(binary)): ...