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
db638cd7dc3135fef012f784d98c086fc5c3c934
aksharanigam1112/Titanic-Survivors
/MLProject_Titanic.py
13,488
3.84375
4
# Step1 importing libraries import numpy as np import pandas as pd pd.set_option('display.width', 1000) pd.set_option('display.max_column', 16) pd.set_option('precision', 2) import matplotlib.pyplot as plt import seaborn as sbn import warnings warnings.filterwarnings(action="ignore") # Step2 Reading data trai...
ba4cf7579b7aab015d0976d245a37b4e82c2b79b
OlafurAO/Megaman-Clone
/Megaman/Source/bullet.py
369
3.5
4
import pygame; pygame.init() class Bullet: def __init__(self, x, y, multiplier): self.x = x; self.y = y; self.multiplier = multiplier; def move(self): self.x += 10 * self.multiplier; def draw(self, display): pygame.draw.rect(display, (255, 255, 255), [...
907b54cc2a10a4a59828fe3d1a02bec494ef7442
jkgaoyuan/code
/all_note/day05/stack_test.py
4,344
3.65625
4
# stack = [] # def inputtext(): # data = input('data:').strip() # if data: # stack.append(data) # else: # print('null ') # # def output(): # if stack: # print('stack is %s' % stack) # else: # print('null') # def view(): # print(stack) # def menu(): # text = ''...
899b51f501461cff0e34ebb04d69fae0ae4fbbf1
pao10y/sales_inventory_system_group1
/sales_inventory_system.py
1,668
3.765625
4
def log_in(): user_name = input("Please enter your username: ") user_pw = input("Please enter your password: ") # two types of log in: # 1) admin/staff user (closed for new accounts) # 2) customers (open for new accounts) def register(): # sign up/new account for customers class Pr...
7f9f731e497f48a29fa8be39c812d905269f0ba2
ss433s/coding_test
/lc448 找到数组中消失的数字.py
1,313
3.5
4
# 参考资料 官方 # 给定一个范围在  1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数组,数组中的元素一些出现了两次,另一些只出现一次。 # 找到所有在 [1, n] 范围之间没有出现在数组中的数字。 # 输入: # [4,3,2,7,8,2,3,1] # 输出: # [5,6] # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array # 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 class Solution(object): d...
44f7fb4266ac41439ca0b4b91a71af90d5316750
ss433s/coding_test
/offer36二叉搜索树.py
1,784
3.59375
4
# from common_file import TreeNode from 二叉树遍历todo import OperationTree class Solution: def get_right(self, node): if node.right: return self.get_right(node.right) else: return node def get_left(self, node): if node.left: return self.get_left(node.l...
4e287a84b961fb314e5405559817cd73f16943e6
ss433s/coding_test
/lc713 Subarray Product Less Than K.py
1,138
3.53125
4
# 参考资料 https://blog.csdn.net/fuxuemingzhu/article/details/83047699 # https://www.cnblogs.com/grandyang/p/7753959.html from common_file import random_positive_int_list class Solution(object): # 暴力 def solve(self, int_list, k): count = 0 for i in range(len(int_list)): cur_product = ...
6af6951b07eeaca0ce4a145495454ea98a36572c
Shade96/hera19
/numtoword.py
98
3.71875
4
g = int(raw_input("Enter a number from 1 to 1000: ")) print ("\nYour number is " + str(g) + ".")
7570d25ca74d83380501a9209cebc3609738d19a
devng/code-puzzles
/src/devng/adventofcode/day13/day13_test.py
1,703
3.65625
4
#!/usr/bin/env python import day13 import unittest class Day13Test(unittest.TestCase): def test_parse_file(self): day13.parse_file("input_test.txt") expected_dict = { ('Bob', 'David'): -63, ('Carol', 'David'): 55, ('David', 'Alice'): 46, ('Bob', 'Ca...
88a1fcd1b614788412d8b5cbf709fdf1cabf6122
devng/code-puzzles
/src/devng/codejam2020/pascal_walk.py
3,620
3.875
4
#!/usr/bin/env python3 from copy import deepcopy DEBUG = False pascal_cache = {} # get value for position r, k in the pascal triangle def pascal(r, k): if r < 1 or k < 1 or k > r: return 0 if r == 1 or k == 1 or r == k: return 1 if (r, k) in pascal_cache: return pascal_cache[...
541ed6f6cc0ec6f7cb8d45d3786d1d665707fe5b
devng/code-puzzles
/src/devng/codejam2020/vestigium.py
1,791
3.8125
4
#!/usr/bin/env python3 # coding: utf-8 # gets the input matrix as a string list and returns the case matrix as array of arrays def parse_matrix_input(lines): case_matrix = [] for i in range(len(lines)): line = lines[i].strip() case_matrix.append(list(map(int, line.split()))) return case_m...
32f3c736b7c6cb8d59051b5a6184c39c1a090359
devng/code-puzzles
/src/devng/projecteuler/problem001/problem001.py
514
4.03125
4
#!/usr/bin/env python # coding: utf-8 def sum_n(n): """sum_n returns the sum of the first n numbers""" return (n * n + n) / 2 def sum_3_5(limit): """sum_3_5 finds the sum of all the multiples of 3 or 5 below the given limit.""" limit = limit - 1 sum3 = sum_n(limit // 3) * 3 sum5 = sum_n(limit ...
5ff32fa739c6ee2414bd43a9e239be5e91637a68
bhagu/mastering_python
/introduction_to_programming_mva/writing_to_files.py
539
3.8125
4
''' This script has been created as part of the introduction to python training by microsoft virtual academy This section covers how to write to files ''' fileName = 'demo.txt' # defining the accessmode variables WRITE = 'w' READ = 'r' APPEND = 'a' READWRITE = 'w+' myFile = open(fileName, WRITE) myFile.write(...
91480183154ae2e795a5739c2c9fd03f932f31e4
hcxgit/PycharmProjects
/Test_9/test_class_9.py
1,347
4
4
# -*- coding: utf-8 -*- class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine = cuisine_type self.number_served = 0 def describe_restaurant(self): long_name = self.restaurant_name + '做的是' + self.cuisine ...
b5a49aedfe398e813ee740583d7630021db4acd5
hcxgit/PycharmProjects
/untitled1/2.py
666
3.6875
4
#coding:utf-8 # * * * * * * * * * * * * 点球小游戏* * * * * * * * * * * * from random import choice score_you = 0 # 开始你得分0 score_com = 0 # 开始电脑得分0 direction = ['left','center','right'] # 射击方向 for i in range(0,5): print '* * * * * * Round%d!* * * * * * * *'%(i+1) print '选择一个方向射击:' print 'left,center,right' you...
0c6f697432c64e2ff1dfd39192c3e2d5d7938ba9
H0bbyist/hero-rpg
/hero_rpg.py
2,112
4.1875
4
from math import * #!/usr/bin/env python # In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee class Character: def alive(self): if self.health > 0: return True def attack...
e1936381661855f0909d9e4354d7b46300828a47
PyThingy/bearded-octo-ironman
/Spotkanie3/marcin_flatten_pickle.py
626
3.5625
4
import pickle def flatten(elem_nested): all_flatten = tuple() if isinstance(elem_nested, list): for item in elem_nested: all_flatten += flatten(item) elif isinstance(elem_nested, tuple): for item in elem_nested: all_flatten += flatten(item) elif isinstance(elem_n...
c80315695beb1d132f9fbc16fb44fd8c4cf0442b
PyThingy/bearded-octo-ironman
/Spotkanie1/marcin_list_jump.py
779
3.59375
4
def fun(L): index = 0 set_ind = set() len_L = len(L) while unify_ind(index, len_L) not in set_ind: if -len(L) <= index < len(L): set_ind.add(index) index = index + L[index] else: return len(set_ind) return -1 def unify_ind(ind, tab_len): retu...
534935476c7d3d8ee60d1930b83de7720dc04d29
FrankyJ578/Boggle
/util.py
737
3.6875
4
ROOT = './' INPUT_FOLDER = ROOT + 'input_files/' DICTIONARY_PATH = ROOT + 'dictionary.txt' END_WORD = '*' def construct_trie(dictionary_path): """Reads a dictionary text file line by line and constructs a trie to represent the dictionary. """ trie = dict() with open(dictionary_path) as file: ...
08ce8f288ed82ded9254db05d4345c17cc5b0dd0
aaycee/aaycee.github.io
/project-euler/py/e19.py
1,169
4.0625
4
# Akachukwu Obi # Project Euler #19 # created July 23, 2018 def first_day_sundays(start_year, end_year): """ finds how many sundays on the first day of the month within a given range """ days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def check_leap_year(year): """check for leap years and modify...
e4abf7d6f92d675e8a0673ac148963eea4cb49fd
aaycee/aaycee.github.io
/project-euler/py/e1.py
461
3.640625
4
# Akachukwu Obi # Project Euler #1 # created July 10, 2018 def Multi35(count): # no need to initialize variables count = count - 1 m3 = 3 * 0.5 * (count // 3) * ((count // 3) + 1) # // works as math.floor in both python2.7 and python3 m5 = 5 * 0.5 * (count // 5) * ((count // 5) + 1) m15 = 15 * 0.5 * (count // 15...
c300ca13a1fa644334279b82c83762c6f6155cb4
mt4g16/AdventOfCode2020
/Day_2/AoC_2.2.py
663
3.71875
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 27 21:09:30 2020 @author: Matteo """ my_file = open("input.txt", "r") content = my_file.read() passwords = content.split("\n") my_file.close() passed_pwds = [] for index, raw_entry in enumerate(passwords): #print(raw_entry) anchor = raw_entry.fi...
4f681914df4d4b9ebf3bdc0a9ec1f187492527d4
huang339/learngit
/me.py
614
3.640625
4
''' Created on Apr 23, 2015 @author: ff ''' class TestCase2(object): def __init__(self): print 'ok' def bubble_sort(self,sort_list): iter_len = len(sort_list) if iter_len < 2: return sort_list for i in range(iter_len-1): for j in range(iter_len-i-1): ...
3d9f51c6bf3df30e6ff6e11a732ca64e2a645d30
bloody-peanuts/aoc-2018
/day2.py
1,050
3.5625
4
import time start_time = time.time() def problem1(): twos = 0 threes = 0 for s in input1: if containsExact(s, 2): twos += 1 if containsExact(s, 3): threes += 1 return twos * threes def problem2(): while len(input1) > 2: s = input1.pop() for ...
87e95560d0f70ae5bb29d12c0215f8ea6d1bf9fb
aryan1025/Snake-ladder-gun
/game.py
895
3.75
4
import random l=["Snake","Water","Gun"] s="Snake" w="Water" g="Gun" n=input("Enter your name - ") i=1 j=k=0 while (i<=10): a=random.choice(l) b=input("Enter your choice Snake/Water/Gun : ") if (a==s and b==s) or (a==w and b==w) or (a==g and b==g): print("Computer - ",a) print(n," - ",b) ...
991f49d6c2cc344450a3834cca8501b5f33a7ab3
joyrexus/go-sandbox
/fib.py
145
3.671875
4
def fib(n): if n < 2: return 1 return fib(n-1) + fib(n-2) if __name__ == '__main__': for i in range(10): print i, fib(i)
c894c730831d6887cd673c0c76b8d7acc4b35857
kni16f053/solver_23
/solver23.py
3,532
3.53125
4
import math def solve2(a, b, c): D = b * b - 4 * a * c if a != 0 and D == 0: x1 = (-b + math.sqrt(D)) / (2 * a) return (1, x1) elif a != 0 and D > 0: x1 = (-b - math.sqrt(D)) / (2 * a) x2 = (-b + math.sqrt(D)) / (2 * a) return (2, x1, x2) elif a == 0 and b == 0 ...
bde693f1a34422b82033f467a077dc32fdcf276d
smartinternz02/SI-GuidedProject-4529-1626948622
/weather.py
3,418
3.96875
4
# Python program to find current # weather details of any city # using openweathermap api # import required modules import requests, json import wiotp.sdk.device import time import random ''' # Enter your API key here api_key = "560c4b69bb0a2c87ee3b704e9efed8e8" # base_url variable to store url base_url = "http://a...
a10387f96ccb53574446db45fef7b5527fb4945f
Percapio/Algorithms-and-Data-Structures
/lib/testers/_data_structures.py
4,225
4.03125
4
from utils import * def _linked( _class, _class_name ): print 'Performing ' + _class_name + ' basic operations:\n' linked = _class() print 'Add at beginning of list.' for i in range( 4, -1, -1 ): print_row( 'Adding...', str( i ) ) linked.add( i ) print 'Attempted to added 4, 3, 2, 1, 0 to linked ...
e2af114dca2a51f5802980c84b596e2e794ae15e
Percapio/Algorithms-and-Data-Structures
/lib/algorithms/quick_sort.py
1,957
4.15625
4
# Quick Sort: # Sort an unsorted array/list by first indexing an element as the pivot point, # check if this index is our target. If not, then check if target is more than # the indexed point. If it is then we check the right half of the list, otherwise # we check the left half. ####################################...
5d035b5556248cb3b3a2fe8c5e7c517dbda4a2f7
elenuco/PythonClass
/Python_Básico/Pasword.py
339
3.796875
4
#solicitamos la clave default = "1234" while 1: contra = input("Ingrese la contraseña: ") if contra != default: print("Contraseña incorrecta ¿desea intentarlo nuevamente? ") print("1. Si") print("2. No") selec = input() if selec != "2": print("Ok") else: break else: print("Bienvenido al sistema...
9f4c32c79da1d205bba40d33762899a756cfc3e8
elenuco/PythonClass
/Python_Básico/DescuentosDeLey.py
968
3.84375
4
#Nombre del empleado y horas laborales nombre=input("Nombre del empleado") DUI=input("Ingrese Su DUI:") NIT=input("Ingrese su su NIT:") salario=float(input("Digite su salario:")) confirmacion_bono=input("¿ Tienes un bono?\n 1.Si \n 2.No") if confirmacion_bono=="1": float("Ingrese la cantidad de bono: ") if confirm...
be0f4fe006401571cc8aacc80df12eeca72338c3
LailaShaikh/experiments
/python/print_tree_traversal.py
1,352
4
4
import Queue """ Interview question was asked in Invaria Tech. Printing the all nodes of given tree from root to child from left to right traversal way """ class Node(object): def __init__(self, name, left=None, right=None): self.name = name self.left = left self.right = right ...
dc9dbbc6fe6b00064e15cd4c6c3d4f25833c4948
LailaShaikh/experiments
/python/linked_queue.py
1,717
3.9375
4
class Node(object): def __init__(self, _ele, _next): self.val = _ele self.next = _next class LinkedQueue(object): def __init__(self): self.qhead = None self.qtail = None self.size = 0 def enqueue(self, val): curr_node = Node(val, None) if not se...
bfd8019d90f2d9cdf1a79b4d54a72d03e103d15e
LailaShaikh/experiments
/python/graph/graph1.py
2,298
3.8125
4
from collections import deque class Vertex(object): def __init__(self, name): self.name = name # Name of the vertex self.connections = {} def add_neighbor(self, neighbor_vertex, cost): self.connections[neighbor_vertex] = cost def __str__(self): return "%s connected To: ...
5b3f7dd24f559e7f3b141d637ca8ac57f31a29a5
laurmertea/simple-banking-system-python-developer
/classes/database.py
8,785
4
4
# Description # It's very upsetting when the data about registered users disappears after the program is completed. # To avoid this problem, you need to create a database # where you will store all the necessary information about the created credit cards. # We will use SQLite to create the database. # SQLite is...
8102eba968786e055b08aceeb54db1c35da15b3e
previsualconsent/projecteuler
/p044.py
508
3.765625
4
from itertools import count def pentagon(n): return n*(3*n-1)/2 n = 3000 print "making lists" pentagons =[ pentagon(n) for n in range(1,n+1)] pns = set(pentagons) print "running over lists up to",pentagons[-1] end = False for i in count(1): if not i % 100: print i for j in xrange(0,n-i): if pentago...
a5e61f5fafe9960fbf5c3b27b3acb4f3147b723a
previsualconsent/projecteuler
/p059.py
822
3.71875
4
#!/usr/bin/python2 from itertools import product from string import lowercase from Words import words wordset = set(words) def decrypt(s,key): return "".join([chr(a^ord(key[i%len(key)])) for i,a in enumerate(s)]) encrypted = [int(i) for i in open("p059_cipher.txt").read().split(',')] n_spaces = [(decrypt(encrypt...
0e3c6f15b2802f117bf1777a35339f3fcf037d3c
previsualconsent/projecteuler
/p005.py
158
3.5
4
import math import Prime lcm = Prime.factor(2) for i in range(3,21): lcm = lcm.LCM(Prime.factor(i)) print reduce(lambda x, y: x*y, lcm.getlist())
a8a79c27f7fd8ee806caf00705373443cfb815c1
previsualconsent/projecteuler
/Fraction.py
1,947
3.6875
4
import Tools class Fraction: def __init__(self,n,d): test = n*d self.num= abs(int(n)) self.den= abs(int(d)) if test > 0: self.sign = 1 else: self.sign = -1 self.reduce() def __add__(self,other): try: num = self.sign * ...
4487fe9e81b6b822685b409f75804e57883a516a
grupo1-bastidas-velasquez/grupo1-jav-fel
/T5E10_a.py
66
3.8125
4
num =0 while num < 13: num += 2 print(num) print("Adios!")
7f06aab9dc56c8d8c2272b657ae71d139decb406
DavidYopp/ELToro
/GIL Limitations/GIL_Example.py
1,078
3.875
4
import time from threading import Thread from multiprocessing import JoinableQueue, Process num = 0 #our countdown method def countdown(num): while num < 100000000: num += 1 #a single process example (normal execution) start_time = time.time() countdown(num) end_time = time.time() delta = end_time - sta...
0f5d70479014b4c2871ceb032c1f75e04f02f85f
Luisbustos8/flask_ventas
/cargaproductos.py
1,069
3.765625
4
import csv, sqlite3 #IMPORTAR LAS LIBRERÍAS filename = "./sales10.csv" #Nombre del fichero en una variable. database = "./data/ventas.db" #Fichero de database tambien dentro de una variable. conn = sqlite3.connect(database) #Crear conexion de base de datos. cur = conn.cursor() #elemento de pyhton para base de datos....
b8591c8775413e7a26139e3f362bb8338c6c6a4a
bhandarisudip/learn_python_the_hard_way_book_exercises
/ex7-studydrills.py
1,640
4.46875
4
#exercise 7--study drills #prints a string: 'Mary had a little lamb.' print("Mary had a little lamb.") #prints a string: 'Its fleece was white as snow.' print("Its fleece was white as %s." %'snow') #prints a string: 'And everything that Mary went.' print("And everything that Mary went.") #prints "." ten times prin...
48ff5efd50d6150ab8bf1b0e5e30fb7f0bd6e585
bhandarisudip/learn_python_the_hard_way_book_exercises
/ex6-studydrills.py
1,535
4.6875
5
#ex06-study drills #assign a string to x that includes a formatting character, which is then replaced by 10 x = "There are %d types of people."%10 #create a variable, binary, and assign the string "binary" to it binary = 'binary' #assign a new variable a string "don't" to a variable 'do_not' do_not = "don't" #cre...
686be88dd39411256693f460587ffab855537dbc
silenceTiano/Python-learning-100-Days
/02day/func_test.py
757
3.75
4
# 计算 x+y+z = 8 一共有多少个正整数解。例如 1+2+5 # 下面的m标识和为多少,n表示几个数字相加 m = int(input('m = ')) n = int(input('n = ')) fm = 1 for num in range(1, m + 1): fm *= num fn = 1 for num in range(1, n + 1): fn *= num fm_n = 1 for num in range(1, m - n + 1): fm_n *= num print(fm // fn // fm_n) # 将上面的计算方式中重复的部分写成函数,供下面使用的时候直接调用。 ...
a404703a9fe992322803bfa639994df6d401e1f0
mdhasan8/LeetCode
/2011-final-value-of-variable-after-performing-operations/2011-final-value-of-variable-after-performing-operations.py
401
3.765625
4
class Solution: def finalValueAfterOperations(self, operations: List[str]) -> int: count = 0 for elem in operations: if elem == '--X': count -= 1 elif elem == 'X--': count -= 1 elif elem == '++X': count += 1 ...
6e68390e17d3d440ca783c7250531b98c12988f1
juliocesarfs/Linguagem-C
/C/testing.py
270
3.953125
4
Number = int(input("Digite um numero: ")) Contador = 2 Contador2 = 1 i = 1 for i in range(i, Number): print(f"{i} ", end="") Contador2 += 1 if (Contador2 == Contador): print(" ") Contador += 1 i = 1
a957213cad27ef8e8fcb5fcad84e18a9ff3ffa33
Arun-9399/Simple-Program
/binarySearch.py
550
4.15625
4
#Binary Search Algorithm def binarySearch(alist, item): first=0 last= len(alist)-1 found= False while first<= last and not found: midpoint= (first+last)//2 if alist[midpoint]== item: found= True else: if item<alist[midpoint]: last= mid...
ba7ca23ba0ba5335abf4cde97892214a1cd807b5
51rL1N5/ViegasApp
/thread_sequencial.py3.py
2,176
3.546875
4
# UNIVERSIDADE FEDERAL DO RIO GRANDE DO NORTE # DEPARTAMENTO DE ENGENHARIA DE COMPUTACAO E AUTOMACAO # DISCIPLINA REDES DE COMPUTADORES (DCA0113) # AUTOR: PROF. CARLOS M D VIEGAS (viegas 'at' dca.ufrn.br) # # SCRIPT: Thread com execucao sequencial # # importacao das bibliotecas import threading # threads import time #...
d3f55ac30322022cda6d0ffed9baad4523b4af65
soonguKwon/Leetcode
/BST/binary_search_tree_iterator.py
893
3.75
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class BSTIterator: def __init__(self, root: TreeNode): import collections self.dq = collections.deque() def ...
5fa0a342eee7151e3a87cc85c247d6ec14d0038a
weiwang-linda/design_pattern
/factory_chapter4/pizza_store_packagechanges.py
1,110
3.703125
4
###################################################### # pizza_store_packagechanges.py # # 将变化的部分和不变的部分分离出来,进行封装,从而实现对改变关闭。 # 变化的部分是创建对象,将其移到orderPizza函数之外,移到另一个对象中。由新对象专职创建对象。新对象就是工厂。 ###################################################### from pizza_basic import CheesePizza, GreekPizza, PepperoniPizza class SimpleP...
10bc98943df9c8610ee37e7e3c664759d3956744
weiwang-linda/design_pattern
/welcome_chapter1/joe_interface.py
1,984
4.0625
4
########## # ******** Simulate Ducks game ******** ########## # Using interface to make some ducks can fly or some ducks can quack. #Superclass class Duck(): def __init__(self, mode): self.mode = mode def swim(self): print(self.__class__.__name__ + ": Swim in a pool") def display(self): ...
9bb568fcb62481e55cd447717c256d93e771d9ea
trwhitcomb/euler
/sudoku.py
7,164
4.125
4
""" Implement a basic 3x3 box Sudoku solver. T. R. Whitcomb 21 April 2009 Seat 2A, Alaska Air Flight 667 """ import itertools import sys import numpy as np NOT_COMPLETED = 0 BOX_SIZE = 3 PUZZLE_SIZE = 9 class PuzzleSet(object): """ A collection of Sudoku puzzles. """ def __init__(self): ...
342ddc75e963daefe5348880baeaee70eb1d58f1
nikita-sh/CSC148
/Lab 3/queue_client.py
1,219
4.375
4
""" Queue lab function. """ from csc148_queue import Queue def list_queue(lst: list, q: Queue): """ Takes all elements of a given list and adds them to the queue. Then, checks the queue for items that are not lists and prints them. If the item being checked is a list, it is added to the queue. This p...
f69039dba0926d741481e7dfdbc53ab2d81db69a
qirun-chen/image-integration
/FileSearching.py
2,856
3.65625
4
# coding= utf-8 import os class FileSearching: """A class for searching files. However, you cannot understander this file! I am sure. You would be confused, if you keep going on.""" def __init__(self, targeted_file_path, suffix, image_type_list): ''' suffix - .jpg count_keyword - ...
1ec3e20f2743feadef75547e7c94d15bebe47939
RuanNunes/Logica-de-Programa-o-com-Python
/WebProject1/listaEtuple.py
962
4.25
4
class listaEtuple(object): #Tuple é um conjunto de dados na mes variavel definido com "()" e separado cada valor por virgula, as tuples não podem ser modificadas depois de instanciasdas meses = ('janeiro','fevereiro','março','abril') #listas também é um conjunto de dados porem separados por "[]", as listas pod...
41dbf660efd4c1c62bf3743dbdd27279940c9fa9
peterpisarcik/matrix
/matrix.py
6,523
3.796875
4
class Matrix: def __init__(self, array): # Get matrix access to object self.array = array # Check if rows have same width for i in range(0, len(array)): if len(array[0]) != len(array[i]): raise ValueError("Rows are not equal") @staticmethod def z...
5079390048b51efd198b9a0b34b49c63d46b25f7
yahiya12/Python-code
/primeornot.py
166
3.703125
4
in=int(input()) if in>1: for i in range(2,in): if in%i==0: print("no") break else: print("yes") else: print("no")
afb7ee106643aaa83f3d28b9cb5db64019748b38
mrcbq/python-Intermediate
/debugging.py
460
4
4
def divisors(num): divisors = [] for i in range(1, num + 1): if num % i == 0: divisors.append(i) return divisors def run(): try: num = int(input('Put a number: ')) if num < 0: raise ValueError('Sorry, no numbers below zero') print(divisors(num)) ...
5f002ef13e8a9f3d6834a9c5f935ced678bcfac8
newton666/Python-Learn-Python-the-Hardway-
/neu.py
135
3.796875
4
numbers = [23, 34, 12, 32, 40] sum = 0 i = len(numbers) while (i != 0): i -= 1 sum += numbers[i] print "The sum is: ", sum
d44cac80b2988daa9eb1047467a4d4a16d22a811
zhaominqiong/try
/B.py
188
3.609375
4
class Example(): def __init__(self,a,b,c): self.a = a self.b = b self.c = c def minus(self): print(self.a - self.b) ex = Example(1,2,3) ex.minus()
f86a9c4575fc01964b15d16df211d5881daf9a25
educa2ucv/Material-Apoyo-Python-Intermedio
/Codigo/1-ProfundizandoEnFunciones/Ejercicio-1.py
876
4.1875
4
""" Ejercicio #01: Desarrolle una función que reciba una lista de asignaturas (Matemáticas, Fisica, Quimica, Historia y Lenguaje) pregunta al usuario la nota que ha sacado en cada una y elimine de la lista las asignaturas aprobadas. Al final, el programa debe mostrar por pant...
841785237a5e1549808c4c572deb45f08f67ff94
educa2ucv/Material-Apoyo-Python-Intermedio
/Codigo/1-ProfundizandoEnFunciones/Ejercicio-4.py
413
3.78125
4
""" Ejercicio #04: Realice una función recursiva que calcule el número Fibonacci N-ésimo. La secuencia de Fibonacci viene definida de la siguiente manera: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,… """ def fibonacci(n): if n <= 1: return n else: return ( fibon...
11da5b61c140246d6c49c1ff35e0137954583016
educa2ucv/Material-Apoyo-Python-Intermedio
/Codigo/1-ProfundizandoEnFunciones/Repaso.py
216
3.75
4
""" def suma(a,b): return a+b """ test = [] a = 5 def foo(): test.append(1) test.append(2) test.append(3) test.append(4) test.append(5) #a += (10*5)/2.0 #print(a) foo() print(test)
9ec420e0a8b14f0773b5a5f33b06dafa198b337f
CarlosCMora/Practica-11-Estrategias-para-la-construccion-de-algoritmos
/ejercicio6.py
1,142
4.0625
4
#Esttayegia divide y venceras """ 21 10 0 34 15 p i d """ def quick_sort(lista): quicksort2(lista,0,len(lista)-1) def quicksort2(lista, inicio,fin): if inicio<fin: pivote = particion(lista,inicio,fin) quicksort2(lista,inicio,pivote-1) quicksort2(lista,pivote+1,...
3353f343425b957a21d1bd3e4bdfa3760c996a0e
darthg/DataAnalysis
/numpytest.py
789
3.78125
4
import numpy import pandas ''' x=numpy.array([1,2,4,5]) x.sort()#排序 x.max() #-----------------切片 #numpy的运行效率跟C语言一样快,比列表快很多 #数组as print(x[1:3]) ''' ##---------pandas a=pandas.Series([8,9,2,1]) #print(a)#序列,每个数据有一个索引,并且可以给索引命名,有点像字典 print(a.index) c=pandas.DataFrame([[1,2,3,4],[2,3,4,6]])#构建数据矩阵 c.values[0][1]#取得行数和列数...
c77da36c4a9098cbbfd71ae6ed0b47a426ab396a
sunheehnus/Think-Python
/flower.py
497
3.671875
4
#!/usr/bin/env python # encoding: utf-8 from turtle_api import * def flower(t, R, n): angle = 360.0 / n for i in range(n): arc(t, R, angle) lt(t, 180 - angle) arc(t, R, angle) lt(t, 180) def dul_flower(t, R, n): for i in range(2): flower(t, R, n) lt(t, 180....
abb0ea7504272cff4de3bc2b0251217266281601
sunheehnus/Think-Python
/most_frequent.py
338
3.890625
4
#!/usr/bin/env python # encoding: utf-8 def most_frequent(sentence): hist = {} for i in sentence: hist[i] = hist.get(i, 0) + 1 t = [(freq, x) for (x, freq) in hist.items()] t.sort(reverse=True) print [x for (freq, x) in t] if __name__ == '__main__': most_frequent("Hello World!\nGoodbye...
3a429d551de636ab0d72cb7a0c9db128c28a4a98
wammar/wammar-utils
/prefix_lines.py
1,030
3.5
4
import io import argparse import re argparser = argparse.ArgumentParser() argparser.add_argument("-i", "--input_filename", required=True) argparser.add_argument("-o", "--output_filename", required=True) argparser.add_argument("-p", "--prefix", type=str, required=True, help="the string to prefix...
e21ff8e9548e3f0627c2bb4f83f040f7f3adb282
mcdavis19/syllable_gen
/Nucleus.py
1,185
3.78125
4
# -*- coding: utf-8 -*- import random class Nucleus: def __init__(self): #list of possible English syllable nuclei self.vowels = [ #0 short vowels [u"æ", u"ɒ", u"ɛ", u"ə", u"ɪ", u"ʌ", u"ʊ"], #1 long vowels [u"ɑ:", u"i:", u"u:", u"aɪ", u"aʊ",...
84a6c9d99f4cb21f944ec8b65cb559063b6a12aa
shufang000/python_ofMine
/com/shufang/halo/data_structure.py
5,792
3.828125
4
# python中的数据结构,python中有4种数据结构: # list(列表)、类似于scala中的List[Any] # dict(字典)、类似于jsonMap {'key':'value'} # tuple(元祖)、类似于scala中的元祖 # set(集合)、类似于java中的set # list # list中的所有元素都是可变的 # list中可以容纳python中的任何对象 # list中的元素是有序的、也就是说每一个元素都有一个位置 WEEK_LIST = ['monday', 'tuesday', 'wdensday', 'thursday', 'friday', 'saturday', 'sunday'] ...
b4f9216dde63230dad5f5c85948151dbdd3119db
hicaro/practice-python
/sorting/mergesort.py
1,417
4.28125
4
class MergeSort(object): ''' __merge Sort sorting algorithm implementation - Best case: O(n log(n)) - Average case: O(n log(n)) - Worst case: O(n log(n)) ''' @staticmethod def __merge(array, aux, lo, mid, hi): for k in range(lo, hi + 1): aux[k] = array[k...
677822cf2d9796a31de51f13477c5f31d097da76
hicaro/practice-python
/sorting/insertionsort.py
502
4.125
4
class InsertionSort(object): ''' Insertion Sort sorting algorithm implementation - Best case: O(n) - Average case: O(n^2) - Worst case: O(n^2) ''' @staticmethod def sort(numbers=None): _len = len(numbers) for i in range(1, _len): to_insert = numbe...
f779c1ef52cb22533ae98439ef988ae717c43c6f
lkuffo/leonardo-youtube
/Arbol Fractal/video.py
1,614
3.765625
4
import turtle import random window = turtle.Screen() window.bgcolor("black") random_colors = ["#0ca90c", "#c20d0d", "#ffffff", "#ffd700", "#3225de", "#8314b9"] tortuga = turtle.Turtle() tortuga.speed(0) tortuga.left(90) def dibujarArbol(tamanoDeRama, tortuga): tortuga.pensize(tamanoDeRama/10) ...
3ddb4cdacec816e3cd417ef2a466f9567773b95c
JasonCozens/Games
/SlidePuzzle/puzzle.py
3,332
3.546875
4
from aenum import Enum import random __author__ = 'Jason Cozens' message = "WELCOME TO SLIDING PUZZLES!" class Direction(Enum): Up = 1 Right = 2 Down = 3 Left = 4 class SlidePuzzle: Width = 3 Height = 3 Directions = [ Direction.Up, Direction.Right, Direction.Do...
c41f6b0b76209c7a2bb3c885b148e33d23ffc387
antaresc/scraper
/Scraper.py
7,381
3.84375
4
from bs4 import BeautifulSoup import requests import json import os class Scraper: """Scraper object serves as a super class to all website scrapers. All Scrapers have the document limit set to 1000 by default. Scraping formats the data into json form and stores it into the data attribute. BeautifulSo...
6f218346b557ddc0f5a33b6c8e52cb9432552e4b
ruchitiwari20012/PythonTraining-
/Namespace1.py
227
3.734375
4
a=10 print(a) print(type(a)) print(id(a)) print(id(10)) #The address for the value not for the variable a if we #change the value the address also got changed) #The memory handling in python is called as Namespace
fd839565d9126df599df76c367f63c050f5b270a
ruchitiwari20012/PythonTraining-
/while else loop.py
134
3.953125
4
a=1 while a<=5: print(a) a+=1 else: print("While Condition False So Else Part Executed") print("Rest of the code")
7df9e746b8e11f1e8d3dee1f840275f5e9763d68
ruchitiwari20012/PythonTraining-
/operators.py
693
4.53125
5
# Arithmetic Operators print(" 5+ 6 is ", 5+6) print(" 5- 6 is ", 5-6) print(" 5* 6 is ", 5*6) print(" 5/6 is ", 5/6) print(" 5//6 is ", 5//6) # Assignment Operator x=5 print(x) x+=7 print(x) x-=7 print(x) x/=7 print(x) #Comparison Operator i=8 print(i==5) print(i!=5)# i not equal to 5 print(i>=5...
75cc79a4f14e86fc8332f56385d08f76288387c2
SethFS99/SNLP
/RestOfNLP/Flores_Seth_b1.py
5,947
3.8125
4
# Speech and Language Processing # Assignment B1: Introduction to Prediction ''' this code was edited entirely by Seth Flores for the course Speech and Language Proccessing Assignment B1 ''' from sklearn.linear_model import LinearRegression import numpy as np import sys, re def reset_dict(letterCount):#res...
08b1600ad0f97fadb1c613c72ee5d83771771758
SethFS99/SNLP
/Flores_Seth_b1.py
4,645
3.84375
4
# Speech and Language Processing # Assignment B1: Introduction to Prediction ''' this code was edited entirely by Seth Flores for the course Speech and Language Proccessing Assignment B1 ''' import sys, re def is_viet(word): if len(word) <=4: return True return False def is_scottish(word):#...
4ad9875422533a0089f9d3b723a3e0ef7096d55d
KyungHoon0126/Algorithm
/SNIPPET/애너그램.py
172
3.765625
4
def are_anagrams(a, b): return sorted(a) == sorted(b) print(are_anagrams('listen', 'silent')) print(are_anagrams('pop', 'odd')) print(are_anagrams('hello', 'hxxxx'))
d29781efd61e9c36503d16dcabd8037d3396e03d
KyungHoon0126/Algorithm
/BOJ/5585번 - 거스름돈.py
202
3.765625
4
n = int(input()) coin_types = [1, 3] if n in coin_types: result = -1 elif (n % 5) % 2 == 0: result = n // 5 + (n % 5) // 2 else: result = ((n // 5) - 1) + ((n % 5 + 5) // 2) print(result)
b2e904d30a8964aa8fcdb31623eb73191d600dbf
KyungHoon0126/Algorithm
/이것 취업을 위한 코딩 테스트다 with 파이썬/Implementation/왕실의나이트.py
1,130
3.5
4
''' ord ord(c)는 문자의 아스키 코드 값을 돌려주는 함수이다. ※ ord 함수는 chr 함수와 반대이다. >>> ord('a') 97 >>> ord('0') 48 ''' # 현재 나이트의 위치 입력받기 input_data = input() row = int(input_data[1]) column = int(ord(input_data[0])) - int(ord('a')) + 1 print(column) # 나이트가 이동할 수 있는 8가지 방향 정의 steps = [(-2, 1), (-1, -2), (1, -2), (2, -1), (2, 1), (1...
a88ff7c4c484407327398104f4fcf506c47ae180
EnriqueThomazz/DiscordBots
/perfil6.py
1,048
3.53125
4
import random import os types = ["animal", "lugar", "personagem", "coisa", "pessoa"] possibleChoices = {"animal" : [], "lugar" : [], "personagem" : [], "coisa" : [], "pessoa" : []} def pickCard(): global possibleChoices name = '' questions = [] ty = random.choice(types) f = open(os.getcwd()+"/...
b040c7820d8ec889d613fd0aae159b81bebcafc9
nulpunkt/euler
/42/wi.py
440
3.515625
4
import re class WordIterator: def __init__(self, file): self.words = self.getWords(file) self.i = -1 self.n = len(self.words) def getWords(self, file): f = open(file, 'r') words = f.read() return re.split('\W+', words) def __iter__(self): return self def next(self): self.i += 1 if self.i >= se...
4f7086876b2f80ec9fee1778731c774ef69c6c38
nulpunkt/euler
/38/pandigital.py
773
3.5
4
class Pandigital: def is_pandigital(self, test, n): first = self.first(test, n) remaining = self.remaining(test, n) i = 2 while self.len(remaining) > 0: if self.c(first, i, remaining): remaining = self.remaining(remaining, self.len(first*i)) i = i+1 else: return False return True def c(se...
4508cdc1a949d7357548092bad5cf037bd5c5946
pythonvirus/ML-Times
/ML-Learning/Supervised Learning/Regression/Linear Regression/linear_regression_stats_scipy.py
870
3.984375
4
import numpy as np from scipy import stats import matplotlib.pyplot as plt def predict(x, intercept, slope): return slope * x + intercept if __name__ == '__main__': num_house = 200 np.random.seed(50) house_size = np.random.randint(low=1000, high=3000, size=num_house) np.random.seed(...
187d5a8d6deb51e5ffbdfcb88d6bc4b65563461d
kooock/kooock.github.io
/script/python/random_walk_graph.py
784
3.84375
4
from matplotlib import pyplot as mplp import math import random def draw_graph(x, y,label): mplp.plot(x, y,label=label) def xrange(start, final, interval): numbers = [] while start < final: numbers.append(start) start += interval return numbers def make_graph_x_y(xmin,xmax): a =...
e0bc52615a2313bcd0da5a7a3c426cdf0b353704
nlinx/CS61A
/lab07.py
4,642
4.21875
4
## Linked List Class and Generic Functions ## ###################### # Linked Lists Class # ###################### class Link: """A linked list. >>> s = Link(1, Link(2, Link(3, Link(4)))) >>> len(s) 4 >>> s[2] 3 >>> s Link(1, Link(2, Link(3, Link(4)))) """ empty = () def ...
8d27568139cbbca5e17d359e87442892fbd59d73
ashleysa12/Actividad-1
/actividad_5_condicional05.py
224
3.828125
4
# Reto 3.5: Condicionales If, Elif, Else name = input("Introduzca su nombre: ") print() if (name == "Ashley"): print("Hola", name) elif (name == "Edwar"): print("Hola prof.", name) else: print("No te conozco.")
2bae8ddc7584878b3b4c6f34bf9c99f571bfec0d
ashleysa12/Actividad-1
/actividad_6_tuplas02.py
762
3.796875
4
# Reto 1, programa 2 various = ("Carro", 123, "Moto", "Algo") print("Tupla:", various) print() listvarious = list(various) print("Tupla convertida en lista:", listvarious) print() listvarious.append(1618) print("Lista con un elemento agregado:", listvarious) print() listvarious.remove("Algo") print("Lista con un ele...
30c23d6195ef939a9968101fd946d5f11b6222d2
ashleysa12/Actividad-1
/actividad_6_clases.py
1,559
4.0625
4
# Reto 3 class Person: def __init__(self, name, lastname): self.name = name self.lastname = lastname class Parents: def __init__(self, mother, father): self.mother = mother self.father = father class House: def __init__(self, model, state): self.model = model ...
d24829a66e53a6c90d7d2023e12578d4e4825d67
Szy11mon/eng
/rzut.py
6,978
3.59375
4
# -*- coding: utf-8 -*- from visual import * from variables import * import math class Throw: def __init__(self, window): self.win = window def description(self): if self.win.PL: return u"Symulacja rzutu ukośnego z uwzględnieniem oporu powietrza\nMożesz wybrać kąt pod którym rzuc...
ff7e3e7ba4d8714c907b82622b4a7c4122bf7091
aliasvishnu/leetcode
/Solutions/51-NQueens.py
1,154
3.625
4
class Solution(object): def printBoard(self, board): ans = [] for lst in board: ans.append("".join(lst)) return ans def function(self, answers, board, r, c, s2, s3, s4, n): # print r, c if(r == n-1): board[r][c] = 'Q' # print board ...
f2121f4abcd95f8f5a98aaee6103f703cd5aa357
danismgomes/Beginning_Algorithms
/isPalindromeInt.py
603
4.15625
4
# isPalindrome # It verifies if a integer number is Palindrome or not answer = int(input("Type a integer number: ")) answer_list = [] while answer != 0: # putting every digit of the number in a list answer_list.append(answer % 10) # get the first digit answer = answer // 10 # remove the first digit def ...
82852bb909dd8e075fae9975f984716d5e54d1fb
ryancollingwood/DGAClassifier
/src/preprocessing/column.py
3,180
3.796875
4
import pandas as pd import numpy as np from .text import normalise_text_to_only_regex_matches from .text import normalise_text_to_ascii from .text import get_regex_for_az_digits_underscores from .text import get_regex_for_non_whitespace def normalise_column_to_lowercase(series: pd.Series) -> pd.Series: """ Re...
cf206d8dc55f049bc40200c3ddcb9da9e6f122b0
pithecuse527/COMP-1003-MUN
/spaced.py
1,018
4.0625
4
#!/usr/bin/python ## Assignment-201948932 ## ## Created by Hong Geun Ji on 24/05/20 ## VIM - Vi IMproved 8.0 ## Copyright © 2020 Hong Geun Ji. All rights reserved. ## ## return string with space ## def spaced(s): ''' Returning the string contains space between each character Time complexi...
4eb355ad61bac5262f322cb0287212b9d5a31335
0x0400/LeetCode
/p206.py
583
3.96875
4
# https://leetcode.com/problems/reverse-linked-list/ from common.linked_list import ListNode # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: ...