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
c5765011e3f9b07eae3a52995d20b45d0f462229
adykumar/Leeter
/python/429_n-ary-tree-level-order-traversal.py
1,083
4.1875
4
""" Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: 1 / | \ 3 2 4 / \ 5 6 We should return its level order traversal: [ [1], [3,2,4], [5,6] ] Note: The depth of th...
abccc32f0d420aa7189c76bbdf0a67c63435a58a
adykumar/Leeter
/python/564_LC_find-the-closest-palindrome_bruteforce.py
1,260
4.03125
4
""" Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'closest' is defined as absolute difference minimized between two integers. Example 1: Input: "123" Output: "121" Note: The input n is a positive integer represented by string, whose length will not exceed 18....
165690d692300da3fc40600251f7812b70db5c15
adykumar/Leeter
/python/136_single-number.py
743
4
4
""" Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,1] Output: 1 Example 2: Input: [4,1,2,1,2] Output: 4 """ class Solution(obje...
d4836b75dadfb3625e1dd8f47297f4ef06997442
DingJunyao/my-first-algorithm-book-py
/0/full_sort.py
990
3.5625
4
""" 全排列算法(0-1,P4) 随机生成不重复的数列,当数列内数字排序正确再输出。 一个非常低效的算法。 """ from random import randint from time import time def gen_arr(n): arr = [] for _ in range(n): while True: random_int = randint(1, 1000000) if random_int not in arr: break arr.append(random_int) ...
f278ab03d685a821f876189a3034524ce4685d99
Leszeg/MES
/MES/Node.py
806
3.875
4
class Node: """ Class represents the node in the global coordinate system: Attributes: ---------- x : float x coordinate. y : float y coordinate t0 : float Node temperature bc : float Flag needed to check if there is a boundary condition """ def...
b0d28d98ea61e10c4ec318aa8184d0dab66c5978
StevenAston/project-euler-python
/euler-006.py
451
3.71875
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 9 03:41:36 2017 @author: Steven """ import timeit start = timeit.default_timer() def sum_of_squares(n): sum = 0 for i in range(1, n+1): sum += i**2 return sum def square_of_sum(n): sum = 0 for i in range(1, n+1): sum += i return sum**2 def difference(n): r...
3b790c60659d28ef6b1c29d24400266ff2266a49
Chimer2017/nba_stats_scraper_db_storage
/nba_ss_db/db/store.py
6,153
3.5
4
""" Handles the creation of tables and storage into tables. """ from typing import List from .. import db, CONFIG from ..scrape.utils import is_proper_date_format, format_date PROTECTED_COL_NAMES = {'TO'} DATE_QUERY_PARAMS = {'GAME_DATE', 'DATE_TO'} def store_nba_response(data_name: str, nba_response, primary_keys=...
ce4dbe12399397596aa9eebfaf09b62bc11b29f5
mosabry/Python-Stepik-Challenge
/1.04 Combining strings.py
142
4.3125
4
# use the variable names to print out the string *with a space between the words* word1 = "hello" word2 = "world" print(word1 + " " + word2)
2b65c4cf9a9372262d2cc927904e36f69cec9cd4
mosabry/Python-Stepik-Challenge
/1.06 Compute the area of a rectangle.py
323
4.15625
4
width_string = input("Please enter width: ") # you need to convert width_string to a NUMBER. If you don't know how to do that, look at step 1 again. width_number = int(width_string) height_string = input("Please enter height: ") height_number = int(height_string) print("The area is:") print(width_number * height_numb...
b7b296552886fe0ca8d13d543770e0575361837c
joanamdsantos/world_happiness
/functions.py
1,018
4.125
4
import numpy as np import pandas as pd import seaborn as sns import matplotlib as mpl import matplotlib.pyplot as plt def plot_countrybarplot(df, var, top_num): ''' INPUT: df - pandas dataframe with the data var- variable to plot, not categorical top_num - number of top countries to pl...
d9a77d8f9ee22aae949c604daa9b428f23aea5ac
reqhiem/EDA_Laboratorio
/Python/Insertionsort.py
635
3.5625
4
import random from timeit import default_timer def insertionSort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while j >= 0 and key < arr[j] : arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key def evaluateinsertion(ndatos): A = [] tiemp...
360ad5223ecaf2dd4d197282e964b1565d258a10
hefeholuwah/myfirstproject
/project.py
306
3.5
4
# we make a list of values c_t = [10,-20,-289,100,987] def temp(c): faren = c * 9 / 5 + 32 if c < -273: return("that temperature doesnt make sense") else: return(faren) with open("dat.txt","w") as file: for b in c_t: cont = file.write(str(temp(b))+"\n") print(cont)
1dd6bcec60728bf71fc84d3a759712d5032dfd59
shakib609/grokking-algorithm
/Chapter02/selection-sort.py
563
4.03125
4
import random def find_largest(arr): largest = arr[0] largest_index = 0 for i in range(1, len(arr)): if arr[i] > largest: largest = arr[i] largest_index = i return largest_index def selection_sort(arr): new_arr = [] for i in range(len(arr)): largest_in...
d4818ff0e9e58b79e1855bc4476fa881a47763da
andrzmil/Excercise_Numbers
/liczby.py
1,729
3.984375
4
import itertools from operator import itemgetter import operator import functools import math numbers = [] for i in range(5): print("Enter number no " + str(i+1)) given_number = int(input()) numbers.append(given_number) print("Chosen numbers:") print(numbers) index_list = list(itertools.combinations([0...
54f0e746f3067e9c8f182de031b0711fd4033569
shinozaki1595/hacktoberfest2021-3
/Python/Algorithms/Sorting/heap_sort.py
884
4.34375
4
# Converting array to heap def arr_heap(arr, s, i): # To find the largest element among a root and children largest = i l = 2 * i + 1 r = 2 * i + 2 if l < s and arr[i] < arr[l]: largest = l if r < s and arr[largest] < arr[r]: largest = r # Replace the root if it is not the...
8ffb50229c5c290cefa3a895c0853414f7da0b49
Byteme8bit/FileSearch
/program.py
1,758
3.859375
4
import os __author__ = "byteme8bit" # Program's main function def main(): print_header() # Prints app header folder = get_folder_from_user() # Grabs input from user if not folder: # Test for no input from user print("Try again") return text = get_search_text_from_user() # Grabs i...
13c8da2ded9c2e01f814ec2eb9a422d92a798ba9
rkalz/CS355
/hw9.py
662
3.53125
4
# Rofael Aleezada # CS355, Homework 9 # March 27 2018 # Implementation of the Rejection Algorithm from math import ceil import numpy as np import matplotlib.pyplot as plt def rejection_method(): a = 0 b = 3 c = ceil((b - 1) ** 2 / 3) x = np.random.uniform(a, b) y = np.random.uniform(0, c) f_...
0a5b3eadda2c696fa97a0169a8fa161fc6e51786
dunnbrit/Introduction-to-Computer-Networks
/chatserve.py
1,718
3.6875
4
# Name: Brittany Dunn # Program Name: chatserve.py # Program Description: A simple chat system for two users. This user is a chat server # Course: CS 372 - 400 # Last Modified: April 30, 2019 # Library to use sockets import socket # Library to get command line argument import sys # Referenced Lecture 15 and geeksfo...
34d8b5c3ddcac697d76c5d8f91309086475100dd
Priyankkoul/cd-1
/1-Token_and_Symbol_Table/inp.py
127
3.734375
4
#comment a=10 a++ b=20 if(a>b): b-- else: a++ x=30 while x>0: x-=1 # #a=0 #b=b+10 #while(a>=0): # a = a + 10 # #c = c +10
70d87e6fe32ad1b0d647e85cf8a64c8f59c9398a
marcin-skurczynski/IPB2017
/Daria-ATM.py
568
4.125
4
balance = 542.31 pin = "1423" inputPin = input("Please input your pin: ") while pin != inputPin: print ("Wrong password. Please try again.") inputPin = input("Please input your pin: ") withdrawSum = float(input("How much money do you need? ")) while withdrawSum > balance: print ("The sum you are trying to wi...
fa5a9cb791bfdacbbac3ac9ab057404daef6c8bf
marcin-skurczynski/IPB2017
/Michal Starzec ATM HM.py
2,404
3.90625
4
balance=2475.11 print(" > > > > eCard < < < < ") for i in range (1,4): PIN = int(input('Please Enter You 4 Digit Pin: ')) if PIN == (7546): print('Your PIN Is Correct\n') print(""" 1) Balance 2) Withdraw 3) Deposit 4) Return Card """) Option=int(input...
bb00780bcd9e892df3913c24da81fb1b15f09e41
Descalzo404/CS50-Problem-Sets
/Dna/dna.py
2,693
3.875
4
from sys import argv, exit import csv import re from cs50 import get_string def main(): # Open the data base csv csv_file = argv[1] with open(csv_file) as f: reader = csv.reader(f) # Getting the opitions of STR's from the header of the csv file str_options = next(reader)[1...
d4627d478b1aa4b5d9b061d66ce6cb32643b5bc7
HyeranShin/Deep-Learning-Lecture
/deep-learning-master/tensorflow_02.py
614
3.65625
4
x = 1 y = x + 9 print(y) # 10 import tensorflow as tf # python 소스 코드 내의 x와 뒤의 string x는 다르다. # 첫번째 x는 python 변수 # 두번째 x는 TensorFlow(그래프) 상의 이름 x = tf.constant(1, name = 'x') y = tf.Variable(x + 9, name = 'y') print(y) # <tf.Variable 'y:0' shape=() dtype=int32_ref> print(y.value()) # Tensor("y/read:0", shape=(), dtyp...
fd541455bd5ad5ca18866082a77842561ca1b2b7
cuotos/bash-python-caller
/test_python_helpers.py
2,384
3.671875
4
#!/usr/bin/env python import unittest import python_helpers as ph import re class TestPythonHelper(unittest.TestCase): def test_helper_should_reject_calls_if_wrong_number_of_arguments_used(self): # not expecting any arguments def f(): pass # pass in an argument that isnt expe...
db3e8d4e2f32b0327c4d4ebad59c6270ddfa92ba
syedshameersarwar/python
/quicksortAssignment.py
1,650
4
4
def readfile(): file = open("QuickSort.txt") numbers = [] for line in file: numbers.append(int(line.strip())) return numbers def quickSort(List,start,end,partition = None ): if start < end: comparisions = end - start pivot_index = partition(List,start,end) comparisi...
b2788add12ce65a30a8856de3575d0d7100d4591
syedshameersarwar/python
/secondMaximum.py
3,011
3.5625
4
'''You are given as input an unsorted array of n distinct numbers, where n is a power of 2.Give an algorithm that identifies the second-largest number in the array,and that uses at most n+log2n−2 comparisons.''' def findMaxTournament(List): if len(List)==1: return List[:] mid = len(List)//2 firstHa...
9c7d666c90a63956d4cb2a7c36a26cbe5f1fb46d
syedshameersarwar/python
/infixpostfixprefrix.py
2,726
3.84375
4
class Stack(object): def __init__(self): self.items = [] def is_empty(self): return self.items==[] def push(self,value): self.items.append(value) def pop(self): if self.size()==0: return None return self.items.pop() def peek(self): if self....
3b8b8cc921b2bd664584adca2b8add2773823e36
syedshameersarwar/python
/BresehhamCirle-algo.py
740
4.03125
4
from graphics import * import math import numpy as np def drawPixel(x,y): global screen screen.plotPixel(int(x),int(y),"red") def BresenhamCircle(Xc,Yc,r): x = 0 y = r d=3- (2*r) while y > x: drawSymmetricPoints(Xc,Yc,x,y) if d <0: d=d + 4*x +6 else: ...
296dd75cbc77a834515929bc0820794909fb9e54
sdaless/pyfiles
/CSI127/shift_left.py
414
4.3125
4
#Name: Sara D'Alessandro #Date: September 12, 2018 #This program prompts the user to enter a word and then prints the word with each letter shifted left by 1. word = input("Enter a lowercase word: ") codedWord = "" for ch in word: offset = ord(ch) - ord('a') - 1 wrap = offset % 26 newChar = chr(ord('a...
138fd202c91719c37dbd579d03246426fb42bd4b
sdaless/pyfiles
/Hw2pr1.py
1,070
3.875
4
# Name: # Hw2pr1.py # STRING slicing and indexing challenges h = "harvey" m = "mudd" c = "college" # Problem 1: hey answer1 = h[0] + h[4:6] print(answer1,"\n") # Problem 2: collude answer2 = c[0:4] + m[1:3] + c[-1] print(answer2,"\n") # Problem 3: arveyudd answer3 = h[1:] + m[1:] print(answer3,"\n") # Problem...
b3dbf8b4190548cd3787fbe0021ca46244b116af
sdaless/pyfiles
/CSI127/turtle_color.py
208
4.53125
5
#Sara D'Alessandro #A program that changes the color of turtle #September 26th, 2018 import turtle tut = turtle.Turtle() tut.shape("turtle") hex = input("Enter a hex string starting with '#' sign: ") tut.color(hex)
d6ff6244153119d0556db2ca0720e18b373af937
sdaless/pyfiles
/CSI127/octagon.py
164
3.9375
4
#Name: Sara D'Alessandro #Date: August 29, 2018 #This program draws an octagon. import turtle tia = turtle.Turtle() for i in range(8): tia.forward(50) tia.right(45)
3bcbd6b47d2963aa858db475bb55fd4137523a89
sdaless/pyfiles
/CSI127/dna_string.py
306
4.09375
4
#Name: Sara D'Alessandro #Date: September 23, 2018 #This program prompts the user for a DNA string, and then prints the length and GC-content. dna = input("Enter a DNA string: ") l = len(dna) print("The length is", l) numC = dna.count('C') numG = dna.count('G') gc = (numC + numG) / l print('GC-content is', gc)
9f53a5c4227a048e38bdf88430c1de6c69da6493
wenqiang0517/PythonWholeStack
/day15/第一次考试机试题讲解.py
5,051
3.578125
4
# 机试题 # 1.lis = [['哇',['how',{'good':['am',100,'99']},'太白金星'],'I']] (2分) lis = [['哇', ['how', {'good': ['am', 100, '99']}, '太白金星'], 'I']] # o列表lis中的'am'变成大写。(1分) # lis[0][1][1]['good'][0] = lis[0][1][1]['good'][0].upper() # print(lis) # o列表中的100通过数字相加在转换成字符串的方式变成'10010'。(1分) # lis[0][1][1]['good'][1] = str(lis[0][1][1]...
d2322f9a5514dbe9dd807dab9053d3b1ef7bc35f
wenqiang0517/PythonWholeStack
/day06/03 代码块.py
1,215
3.65625
4
# 代码块 # * 代码块:我们的所有代码都需要依赖代码块执行,Python程序是由代码块构造的。块是一个python程序的文本,他是作为一个单元执行的。 # * 一个模块,一个函数,一个类,一个文件等都是一个代码块 # * 交互式命令下一行就是一个代码块 # 两个机制同一个代码块下,有一个机制,不同的代码块下,遵循另一个机制 # 同一代码块下的缓存机制 # * 前提条件:同一代码块内 # * 机制内容:pass # * 适用的对象:int bool str # * 具体细则:所有的数字,bool,几乎所有的字符串 # * 优点:提升性能,节省内存 # 不同代码块下的缓存机制: 小数据池 # * 前提条件:不同...
a7512d155221f8cf092c99cb58320fdb2ae6c2db
wenqiang0517/PythonWholeStack
/day26/08-反射的例子.py
1,316
3.5625
4
class Payment: pass class Alipay(Payment): def __init__(self, name): self.name = name def pay(self, money): dic = {'uname': self.name, 'price': money} print('%s通过支付宝支付%s钱成功' % (self.name, money)) class WeChat(Payment): def __init__(self, name): self.name = name def ...
f8571a2378d85ae0d51811f2c9c5b44d3cd0b475
wenqiang0517/PythonWholeStack
/day23/02-命名空间问题.py
3,168
3.859375
4
# 类的成员和命名空间 # class A: # Country = '中国' # 静态变量/静态属性 存储在类的命名空间里的 # def __init__(self,name,age): # 绑定方法 存储在类的命名空间里的 # self.name = name # self.age = age # def func1(self): # print(self) # def func2(self):pass # def func3(self):pass # def func4(self):pass # def func5...
8b1a9df76b23b6f000a74cd458e84ac32b2fa2e4
wenqiang0517/PythonWholeStack
/day01/test01.py
534
3.78125
4
# 炸金花发牌游戏(奖品) # 生成一副扑克牌,去除大小王 # 5个玩家,每个人发三张牌 # 最后计算谁是赢家(进阶) a = 1 number = [] poker = [] letter = ['J', 'Q', 'K', 'A'] design_color = ['H', 'M', 'F', 'X'] while a < 10: a = a + 1 number.append(str(a)) num = number + letter for i in design_color: for y in num: poker.append(i + y) print(poker) # print...
18e3c19deb58a4a6933c5115994dea8e4e327e1d
wenqiang0517/PythonWholeStack
/day22/03 面向对象编程.py
3,361
4.125
4
# 先来定义模子,用来描述一类事物 # 具有相同的属性和动作 # class Person: # 类名 # def __init__(self,name,sex,job,hp,weapon,ad): # # 必须叫__init__这个名字,不能改变的,所有的在一个具体的人物出现之后拥有的属性 # self.name = name # self.sex = sex # self.job = job # self.level = 0 # self.hp = hp # self.weapon = weapon...
07f0648241f066c609a566dbd1ca4688530438f8
wenqiang0517/PythonWholeStack
/day25/04-父类对子类的约束.py
2,960
3.5625
4
# 普通的类 # 抽象类 是一个开发的规范 约束它的所有子类必须实现一些和它同名的方法 # 支付程序 # 微信支付 url连接,告诉你参数什么格式 # {'username':'用户名','money':200} # 支付宝支付 url连接,告诉你参数什么格式 # {'uname':'用户名','price':200} # 苹果支付 # class Payment: # 抽象类 # def pay(self,money): # '''只要你见到了项目中有这种类,你要知道你的子类中必须实现和pay同名的方法''' # raise N...
831e5bb5428964879e6cf64ca8291cd1771db5dc
wenqiang0517/PythonWholeStack
/day23/01-内容回顾.py
1,619
3.609375
4
# 面向对象 # 类 对象/实例 实例化 # 类是具有相同属性和相似功能的一类事物 # 一个模子\大的范围\抽象 # ***************** # 你可以清楚的知道这一类事物有什么属性,有什么动作 # 但是你不能知道这些属性具体的值 # 对象===实例 # 给类中所有的属性填上具体的值就是一个对象或者实例 # 只有一个类,但是可以有多个对象都是这个类的对象 # 实例化 # 实例 = 类名() # 首先开辟空间,调用init方法,把开辟的空间地址传递给self参数 ...
269201af84089e19d224373dbdaf11e941033cf8
wenqiang0517/PythonWholeStack
/day25/07-作业.py
5,634
3.96875
4
# 1,面向对象为什么要有继承 # 当两个类中有相同或相似的静态变量或绑定方法时,使用继承可以减少代码的重用,提高代码可读性,规范编程模式 # 2,python继承时,查找成员的顺序遵循什么规则 # 经典类 -- 深度优先 # 新式类 -- 广度优先 # 3,看代码,写结果 """ class Base1: def f1(self): print('base1.f1') def f2(self): print('base1.f2') def f3(self): print('base1.f3') self.f1() class Bas...
6f566cf1fba184c37d48176800c2a6073b4041fb
YoniSchirris/SimCLR-1
/modules/deepmil.py
6,942
3.625
4
import torch as torch import torch.nn as nn import torch.nn.functional as F class Attention(nn.Module): def __init__(self, hidden_dim=2048, intermediate_hidden_dim=128, num_classes=2, attention_bias=True): super(Attention, self).__init__() self.L = hidden_dim # self.D = int(hidden_dim / 2...
51a2d991ba8669d5fa8a30d849904c0bb3c13861
yangxin6/3DPointCloud
/lesson2/bst.py
5,093
3.546875
4
import numpy as np import math from lesson2.result_set import KNNResultSet, RadiusNNResultSet class Node: def __init__(self, key, value=-1): self.left = None self.right = None self.key = key self.value = value def __str__(self): return "key: %s, value: %s" % (str(self...
344be7d9070c5770d993d6376d6bca00c0d171d1
type9/CS-1.2-Intro-Data-Structures
/Code/dictionary_words.py
1,263
3.890625
4
import random import sys from fisheryates_shuffle import shuffle def random_sentence(num_words): dictionary = open('/usr/share/dict/words', 'r') dictionary_list = list() word_list = list() # final list of words num_lines = 0 # total word count for line in dictionary: # converts each line of the d...
15f73a195b2da78189198730bb2f6ffb12fc70dc
BhujayKumarBhatta/myflask
/experiments/ospath.py
1,426
3.5
4
import os print(" current working directory is % s" % os.getcwd()) print("dirname of current file is % s" % os.path.dirname(__file__)) print("realpath of current file is % s" % os.path.realpath(__file__)) print("abspath of current file is % s" % os.path.abspath(__file__)) print(" one level up previous dir of curren...
5f7c7a681de3287b0e2c05bb05d18df626eb3b54
sudev/dsa
/graph/UsingAdjacencyList.py
1,677
4.15625
4
# A graph implementation using adjacency list # Python 3 class Vertex(): def __init__(self, key): self.id = key # A dictionary to act as adjacency list. self.connectedTo = {} def addEdge(self, vert, w=0): self.connectedTo[vert] = w # Repr def __str__(self): return str(self.id) + ' connectedTo: ' +...
9fd9d17de19a87eadcace063eab22e9a8f91a3e5
gurupatoh/pypy
/employee.py
1,443
3.65625
4
class Employee: def __init__(self, first_name, last_name, employee_id): self.first_name = first_name self.last_name = last_name self.employee_id = employee_id self.base_salary = 0 def set_base_salary(self, salary): self.base_salary = salary class TeachingStaff (Employee): def __init__(self...
c461a5df6e2ef47e30b8a95d8da5f9373e31f182
TrevorHuval/SchemePrettyPrinter
/Parse/Scanner.py
7,594
3.71875
4
# Scanner -- The lexical analyzer for the Scheme printer and interpreter import sys import io from Tokens import * class Scanner: def __init__(self, i): self.In = i self.buf = [] self.ch_buf = None def read(self): if self.ch_buf == None: return self...
45c512a90c4429bb6cc8303d11845d3205583e70
TrevorHuval/SchemePrettyPrinter
/Special/Special.py
404
3.78125
4
# Special -- Parse tree node strategy for printing special forms from abc import ABC, abstractmethod # There are several different approaches for how to implement the Special # hierarchy. We'll discuss some of them in class. The easiest solution # is to not add any fields and to use empty constructors. cla...
31d68d11fdc06c09e0721e6541024eb33b585c91
selimozen/Hackerrank
/Python/ifelse.py
546
4.3125
4
#ENG: if n is odd, print Weird , if n is even and in the inclusive range of 2 to 5, print Not Weird, #if n is even and in the inclusive range of 6 to 20, print Weird, if is even and greater than 20, print Not Weird #TR: Eğer n sayısı tekil ise, 'Weird' yazdır, eğer n sayısı 2 veya 5'e eşit veya arasında ise Not Weird...
a961f3be1e5d83fbd174bc21851b0753bec84c04
andersonresende/learning_python
/chapter_19/recursion.py
1,077
4.21875
4
#nao mudar o tipo de uma variavel e uma boa pratica #nao usar globais dentro de funcoes, pois pode criar dependencias. #durante a recursao o escopo das funcoes e mantido, por isso funciona. #recursao exige que vc crie uma funcao, enquanto procedural nao. #vc nao pode alterar os valores de variaveis a partir de fora da ...
609add66f670ba8c7b3863bc12603b83e71c99af
andersonresende/learning_python
/chapter_18/min.py
723
4.125
4
def min1(*args): ''' Retorna o menor valor, passado em uma tupla. ''' res = args[0] for arg in args[1:]: if arg < res: res = arg return res print min1(10,2,3,4) def min2(first, *rest): ''' Retorna o menor valor, recebendo um argumento inicial e outros em uma tupla. ''' for arg in rest: if arg < first:...
796c1142383f647d8774b94317198df0904523bd
rwesterman/MachineMarchMadness
/setup/clean_tables.py
2,256
3.546875
4
import pandas as pd import re from pprint import pprint def get_xl_data(): """ Returns a dictionary of dataframes where each key is a sheet name and each value is a dataframe :return: """ # Setting sheet_name = None imports all sheets df_dict = pd.read_excel("Training_Data\\KenPom_Rankings.xlsx...
281fe91d03a3841187b5856bf42524a557c8b28b
dainbot/python-programming-practice
/Algorithm/gcd.py
376
3.921875
4
# Find the greatest common denominator of two numbers. """ 1 For two integers a and b, where a > b, divide a by b 2 If the remainder, r, is 0, then stop: GCD is b 3 Otherwise, set a to b, b to r, and repeat at step 1 until r is 0 """ def gcd(a, b): while (b != 0): t = a a = b b = t...
0406e3cc0d3d09c9bbaf400c2808ebf0737d31d4
bharathkkb/peer-tutor
/peer-tutor-api/timeBlock.py
1,230
4.25
4
import time import datetime class TimeBlock: """ Returns a ```Time Block``` object with the given startTime and endTime """ def __init__(self, start_time, end_time): self.start_time = start_time self.end_time = end_time print("A time block object is created.") def __str__(...
ff81de53a5684a0b156037e3e60b5ae9fa4127a7
MB-TAYLOR/ScrabbleAR-Grupo29
/ScrabbleAR_py/AiMaquina.py
3,281
3.578125
4
import itertools as it from pattern.es import spelling,lexicon,parse Tipo= {'adj':["AO", "JJ","AQ","DI","DT"], 'sus':["NC", "NCS","NCP", "NNS","NP", "NNP","W"],#Revisar volver a comprobar en facil , primero en spell y lexi luego en sus 'verb':[ "VAG", "VBG", "VAI","VAN", "MD", "VAS" , "VMG" , "VMI", "VB", "VMM" ,"VMN"...
06a1a7c44faa8688ce5d3229fc019aae1fe86fe5
chennavamshikrishna/ml_algorithms
/linear regression.py
595
3.65625
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np dataset=pd.read_csv('Salary_Data.csv') #print(dataset) X=dataset.iloc[:,:-1].values y=dataset.iloc[:,1].values from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(X,y,random_state=0,test_size=1/3) ##pr...
6edfeb4705a4f49b354ef9571029d19b9848f8e5
dani3l8200/100-days-of-python
/day1-printing-start/project1.py
454
4.28125
4
#1. Create a greeting for your program. print('Welcome to Project1 of 100 Days of Code Python') #2. Ask the user for the city that they grew up in. city_grew_user = input('Whats is your country that grew up in?\n') #3. Ask the user for the name of a pet. pet_of_user = input('Whats is the name of any pet that having?\n'...
653c613be1c54d924fe2bf398295601817ab30a5
dani3l8200/100-days-of-python
/day1-printing-start/exercise1.1.py
265
3.828125
4
print('Day 1 - Python Print Function') print() print('This function Print() is used for print strings, objects, numbers etc') print('''Is posibble obtains errors, it is possible if not use parenthesis close or triple single quote for indicate a print extend xd''')
399c6abffb5b4bc60849a84d0c0d112ab7cd2f96
dyshko/hackerrank
/World Codesprint 13/P4.py
911
3.515625
4
#!/bin/python3 import os import sys # Complete the fewestOperationsToBalance function below. def fewestOperationsToBalance(s): rs = [] for c in s: if c == '(': rs.append(c) if c == ')': if len(rs) > 0 and rs[-1] == '(': rs.pop() else: ...
593aa904c7c4b0dd294d25debb3eae2f67f1dc62
imsilence/refactoring
/chapter01/v03.py
1,823
3.5
4
#encoding: utf-8 import json import math ''' 以查询替代临时变量 内联局部变量 注意: 重构和性能之间首选选择重构,重构完成后进行性能调优 ''' def statement(invoice, plays): total = 0 credits = 0 print("Statement for: {0}".format(invoice['customer'])) def play_for(performance): return plays.get(performance.get('playId', 0), {}) de...
215ae22230731d3c486c7b652128fb1b212c78e0
islamrumon/PythonProblems
/Sets.py
2,058
4.40625
4
# Write a Python program to create a new empty set. x =set() print(x) n = set([0, 1, 2, 3, 4]) print(n) # Write a Python program to iteration over sets. num_set = set([0, 1, 2, 3, 4, 5]) for n in num_set: print(n) # Write a Python program to add member(s) in a set. color_set = set() color_set.add("Red") print...
a8d0633d0c553059cb45d78de73748d340fa50e7
yoku2010/just-code
/algorithms/number_combination.py
2,008
3.953125
4
#!/usr/bin/python class NumberCombination(object): def __init__(self, number_list, number): self.number_list = number_list self.number = number self.result = [] def process(self): ''' Algorithm process ''' # Make It Unique self.number_list = list...
3bedc90616961f248924953f468206cc06e27f92
yoku2010/just-code
/utility/spiral-pattern/code.py
1,339
4.03125
4
#!/usr/bin/python """ @author: Yogesh Kumar @summary: To draw a spiral pattern of numbers like that. Enter Number of Element: 21 17 16 15 14 13 18 5 4 3 12 19 6 1 2 11 20 7 8 9 10 21 """ def spiral_pattern(number): n = 2 ...
497ebf8e5b03ac3e9a424ef76838da53a46da8bb
shobasri/TrainingAssignments
/Naveena/patterns.py
1,155
3.6875
4
#!/usr/bin/python import sys r=int(sys.argv[1]) n = 0 print ("Pattern B") for x in range (0,(r+1)): n = n + 1 for a in range (0, n-1): print ('*', end = '') print () print ('') print ("Pattern A") for b in range (0,(r+1)): n = n - 1 for d in range (0, n+1): print ('*', end = '')...
42178b00cf2ba281a87c64c5ab945908fc1202a8
shobasri/TrainingAssignments
/Sony/Assignments/divisable7.py
140
4.34375
4
#given no divisible by 7 or not a=input("Enter a number ") if (a%7==0): print a,"is divsible by 7" else: print a,"is not divisible by 7"
81c99b4ece820adc4c322bbf5efaa475d5bd3a83
mijodong/euler
/python/problem-20.py
138
3.765625
4
factorial = 1 for _ in range(1, 101): factorial *= _ value_sum = 0 for _ in str(factorial): value_sum += int(_) print(value_sum)
489d48a54197ec60c9e916605caf8235b09dddc7
mijodong/euler
/python/problem-4.py
464
3.84375
4
from math import floor def is_palindrome(value): value_str = str(value) length = len(value_str) for i in range(floor(length / 2)): if value_str[i] != value_str[-i - 1]: return False return True palindrome = 0 for i1 in range(100, 999): for i2 in range(100, 999): pr...
e49a5633e9f24f787b78987b8954b5c4b40f3b82
roxdsouza/PythonLessons
/RegExp.py
4,328
4.3125
4
import re # re module is used for regular expression # Documentation - https://docs.python.org/2/library/re.html # Examples - https://www.guru99.com/python-regular-expressions-complete-tutorial.html # "\d" matches any digit; "\D" matches any non digit. # "\s" matches any whitespace character; '\S" matches any non-alp...
aae16277602c86460bafa3df51c1eb258c7d85db
roxdsouza/PythonLessons
/Dictionaries.py
2,088
4.65625
5
# Dictionary is written as a series of key:value pairs seperated by commas, enclosed in curly braces{}. # An empty dictionary is an empty {}. # Dictionaries can be nested by writing one value inside another dictionary, or within a list or tuple. print "--------------------------------" # Defining dictionary dic1 = {'...
4fa1560b335f86dae73766c7f6b316e339d54671
roxdsouza/PythonLessons
/Classes04.py
964
4.125
4
# Program to understand class and instance variables # class Edureka: # # # Defining a class variable # domain = 'Big data analytics' # # def SetCourse(self, name): # name is an instance variable # # Defining an instance variable # self.name = name # # # obj1 = Edureka() # Creating an inst...
7b73ee12749b361ea8b2581da5ff19ad01c584f6
mertzd1/MachineLearning-Python
/Regression/Section 5 - Multiple Linear Regression/multiple_linear_regression_1.py
2,315
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 10 13:51:42 2019 @author: donal """ #When creating dummy variables ***Always** omit one dummy variable in a multiple regression model #This is called Avoiding the Dummy Variable Trap #importing the Libraries import numpy as np import matplotlib.pyplot as plt import pand...
e8c8201207c84dade087650a761921226e2f0cf1
mbytes21/Python-Autoclicker
/autoclick.py
352
3.671875
4
import time import pynput from time import sleep from pynput import mouse from pynput.mouse import Button, Controller mouse = Controller() delay1 = input("How long until the clicking starts? ") clicknum = int(input("How many times do you want it to click? ")) x=int(delay1) for i in range(x): sleep(1) mo...
a8630178035f69f14bb41418b6b70a3fc120945e
olk911/ps-pb-hw3
/plural_form.py
725
3.90625
4
def plural_form(number, form1, form2, form3): f ='' # правильная форма для числа number date = str(number) # преобразование в строку и следовательно в список [] if int(date[-1]) == 1 and int(date[-2:]) != 11: f = form1 if int(date[-1]) > 1 and int(date[-1]) < 5: f = for...
1df9b8f1c11e8837892fb037232d3be40a124f80
GenghisKhanDoritos/Calculator-python-ver.-
/Calculator_Memory_Type.py
2,094
4.0625
4
#Calculator Memory Type.py print('='*50) print('Calculator Memory type') print('='*50) Working_Memory = 0 Secondary_Memory = 0 def operation(FN,OP,SN,Default): if OP=='1': Working_Memory = Default+FN+SN print(Working_Memory) elif OP=='2': Working_Memory = Default+FN-SN ...
8e56d445bc8dfff8db0f2658a92f19dcbb2f7922
ArrobaAnderson/Ejer_Class
/Sem2/condicion2.py
425
3.875
4
class Condicion: def __init__(self,num1=6,num2=8): self.numero1= num1 self.numero2= num2 numero= self.numero1+self.numero2 self.numero3= numero def usoIf(self): print(self.numero3) print("instancia de la clase") cond1= Condicion(70,94) ...
6e4eac8476b5580ec806298f05ebfd0386bd57f4
ArrobaAnderson/Ejer_Class
/Sem5&6/Ordenaciones.py
4,850
3.75
4
class Ordernar: def __init__(self,lista): self.lista=lista def recorrer(self): for ele in self.lista: print(ele) def recorrerPosicion(self): for pos,ele in enumerate(self.lista): print(pos,ele) def recorrerRange(self): for pos i...
81bb1e1f9c2972273b89457532534d9ba321654c
ArrobaAnderson/Ejer_Class
/Sem2/Diccionario.py
915
3.625
4
class Sintaxis: instancia=0 def __init__(self,dato="LLamando al constructor1"): self.frase=dato Sintaxis.instancia = Sintaxis.instancia+1 def usoVariables(self): edad, _peso = 21, 70.5 nombres = "Leonardo Arroba" dirDomiciliaria= "El Triunfo" ...
29aa99e1ece33882ff8e24ba1feb008b4eb9bd8f
LewisT543/Notes
/Learning_OOP/Classes and Instances/Python OOP 2 - Class Variables.py
868
4.03125
4
# SELF REFERS TO THE INSTANCE, in this case EMPLOYEE is what self is # referring to class Employee: num_of_emps = 0 raise_amount = 1.04 def __init__(self, fname, lname, pay): self.fname = fname self.lname = lname self.pay = pay self.email = fname + '.' + lname + '@compan...
e759d2b446b087c10defe5664b855e15f468c650
LewisT543/Notes
/Learning_OOP/Different Faces of Python Methods/11Part3.py
2,284
3.671875
4
from datetime import datetime class TimeList(list): @staticmethod def add_timestamp(txt): now = datetime.now().strftime("%Y-%m-%d (%H:%M:%S)") return f'{now} >>> {txt} ' def __setitem__(self, index, value): value = TimeList.add_timestamp(value) list.__setitem__(self, i...
78d56b418170f3c6a011439fc528ee4fec66e4ce
LewisT543/Notes
/Learning_Tkinter/17Main-window+user-convos.py.py
4,950
4.09375
4
#### SHAPING THE MAIN WINDOW AND CONVERSING WITH THE USER #### # CHANGING ASPECTS OF THE WINDOW # Changing the TITLE import tkinter as tk def click(*args): global counter if counter > 0: counter -= 1 window.title(str(counter)) counter = 10 window = tk.Tk() window....
dbb7e09bda996ede7be312e7a9b3fa5c6b0c0af8
LewisT543/Notes
/Learning_Tkinter/6Building-a-GUI-from-scratch.py
2,191
4.03125
4
import tkinter as tk from tkinter import messagebox def Click(): replay = messagebox.askquestion('Quit?', 'Are, you sure?') if replay == 'yes': window.destroy() window = tk.Tk() # Label label = tk.Label(window, text = "Little label:") label.pack() # Frame frame = tk.Frame(window, height=30, width=1...
4e7b02140879900cbbb4e3889789c8b3dcd15291
LewisT543/Notes
/Learning_Data_processing/3SQLite-update-delete.py
1,440
4.46875
4
#### SQLITE UPDATING AND DELETING #### # UPDATING DATA # # Each of the tasks created has its own priority, but what if we decide that one of them should be done earlier than the others. # How can we increase its priority? We have to use the SQL statement called UPDATE. # The UPDATE sta...
5ba9ce856ff7469ae0283044f155c2d7213da8fb
LewisT543/Notes
/Learning_OOP/Shallow and Deep Copy/4Example-copy-speed-comparison.py
2,783
4.0625
4
#### SPEED COMPARISON #### # We can see the differences in execution time very clearly. # Single ref: no time at all, # Shallow copy: almost no time at all, # Deep copy: exponentially longer. import copy import time a_list = [(1,2,3) for x in range(1_000_000)] print('Single refere...
77a3de5d9a5a2fea41962f745456533430eca80f
LewisT543/Notes
/Learning_Data_processing/11Labs-exams-report.py
2,704
3.78125
4
# Your task will be to prepare a report summarizing the results of exams in maths, physics and biology. # The report should include the name of the exam, the number of candidates, the number of passed exams, the number of failed exams, # and the best and the worst scores. All the data necessary to create the rep...
2c191da1dddc35a17485a3519f63c0a2dd879dd0
LewisT543/Notes
/Learning_OOP/Decorators/Timer.py
1,026
3.59375
4
from functools import wraps class Logging_decorator(object): def __init__(self, origional_function): self.origional_function = origional_function def __call__(self, *args, **kwargs): import logging logging.basicConfig(filename=f'{self.origional_function.__name__}.log', level=l...
95ce1eb58837658a9f65247e7c3c84548644ebe0
ahovhannes/Disco_API_Test
/Source/TestFunctions/FunctionRandom/Function_Random.py
613
3.671875
4
# # Collection of functions generating random numbers # import random class bddRandom: def generate_random_number(self, beginNumber, endNumber, seedValue=None): """ Generate random number between given numbers Args: beginNumber : Start number ...
2f69fc3c07f2bdd21293db493df9e25ef1f7978a
adambjorgvins/pricelist
/snake.py
2,389
3.890625
4
import random class Game: dimension = None board = None current_x = None current_y = None monster = None snake = None brick = None score = None def __init__(self, dimension): self.current_x = random.randint(0,9) self.current_y = random.randint(0,9) self.current_monster_x = random.randint...
b99087927611afb1de15d89e863cc7ad162abf7e
velios/6_password_strength
/password_strength.py
2,341
3.59375
4
import re from string import (ascii_lowercase, ascii_uppercase, punctuation, digits) from getpass import getpass from os import path def check_upper_and_lower_case_in_string(string): return any(char in string for char in ascii_uppercase) and \ ...
9c64a4aab34c6af4b71fc4162f6ea30d7b74bc2f
iceman67/algorithm
/02-analysis/search/linsear_search.py
923
3.75
4
def linearSearch(arr, key): n = len(arr) for i in range(0, n): if arr[i] == key: return i return -1 list = [1,2,3,4,5] key = 2 pos = linearSearch(list, key) print ("position = ", pos ) if pos == -1: print("not found" ) else: print (" ", list[pos]) key = -1 pos = linearSearch(list, key) p...
1827787e352eccbf15888adb66acdafee51cfdec
davidsamuelwhite/visualnba
/JSONGameData.py
3,431
3.859375
4
# this file contains functions that manipulate the data from the JSON file which # holds all the data that is plotted by the program. it creates objects called # dataframes from the pandas packages, which are essentially 2d lists that are # easier to data manipulation with. import json import pandas as pd # d...
8a57681c6bd62de888d89661572c134906752f24
mihai064/my-projects
/python/hello.py
1,134
3.96875
4
import time print("hello") var1 = input("what's your name? ") print("nice to meet you",var1) user_reply = input("do you wanna play something? ") if user_reply == "yes": ur2 = input("greatfull. so do you like programmig? ") if ur2 == "yes": print ("let's learn python") user_reply2 = input ("do you wan...
443ba59840b6aa72447c04f6e9d2dccdf9429df7
mihai064/my-projects
/python/buton.py
529
3.8125
4
import tkinter window = tkinter.Tk() button = tkinter.Button(window, text="Do not press this button.",width=40) button.pack (padx=10, pady=10) clickCount = 0 def onClick (event): global clickCount clickCount = clickCount + 1 if clickCount == 1: button.configure (text="Seriously? Do. Not. Pr...
509be7160806b00c6f34042fbe3e5f3e6308b082
prahaladh/webscrape
/webscrape.py
555
3.53125
4
import pandas as pd import requests from bs4 import BeautifulSoup def get_data(url): res = requests.get(url) soup = BeautifulSoup(res.content,'lxml') table = soup.find_all('table')[0] list_of_rows = [] for row in table.findAll('tr'): list_of_cells = [] for cell in row.findAll(["th"...
c7eb2f952f6ceadba48a40220ed18ec0b103b386
pcw109550/id0-rsa.pub
/32_Caesar/solve.py
404
3.515625
4
#!/usr/bin/env python3 import string chset = string.ascii_uppercase N = len(chset) f = open("ct", "r") ct = f.read().strip() f.close() for i in range(N): pt = "" for c in ct: x = chset.find(c) pt += chset[(x + i) % N] if "CAESAR" in pt: print("KEY: {:s}".format(chset[i])) ...
ee7040b673ccc088d8e708f017a5dd17e203e6c6
pcw109550/id0-rsa.pub
/38_Easy_Passwords/solve.py
1,512
3.5
4
#!/usr/bin/env python from passlib.hash import md5_crypt from itertools import product from string import ascii_lowercase def hash(salt, msg): h = md5_crypt.using(salt=salt, salt_size=8) return h.hash(msg) def step1(salt, res, datas): # https://www.scrapmaker.com/data/wordlists/dictionaries/rockyou.txt ...
d530548acdd3fb83f6302d73ae83597fc38fc4f8
Woltan/Chess
/board.py
4,472
3.5625
4
import random from pieces import Pawn, Rook, Knight, King, Bishop, Queen class Board(object): Pieces = property(lambda self: self._pieces) def __init__(self, pieces, turn): self._pieces = pieces self._turn = turn self._lastMove = None @classmethod def CreateNewBoard(cls, fen=None): if fen: raise Not...
7b8414a39ff9a45806152126d9bd2bc12d1cd54a
satlawa/ucy_dsa_projects
/Project_1/problem_6.py
4,138
4.1875
4
#------------------------------------------------------# # problem 6 - Union and Intersection #------------------------------------------------------# class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class Linked...
100a33b667fa60386fabf26718b7bdf71d25d26c
satlawa/ucy_dsa_projects
/Project_0/Task2.py
1,759
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...