blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
deb3507dcd968f9138bce57ff717d8e50ef4518a
bnpy/bnpy
/tests/zzz_deprecated_unmaintained/parallel/kmeans/TestKMeans_Shared.py
10,249
3.515625
4
""" Shared memory parallel implementation of k-means local step. Classes -------- SharedMemWorker : subclass of Process Defines work to be done by a single "worker" process which is created with references to shared read-only data We assign this process "jobs" via a queue, and read its results from a ...
d6cac76041500ae1ff5d6eeb88d3ade42946aa58
Oldbreaker/Rocket_Api
/request.py
1,948
3.625
4
import requests """ Del api de pokemon cuya documentación se encuentra en la pagina https://pokeapi.co/, realiza las siguientes instrucciones: Crea una función en python que consuma el siguiente servicio: API GET https://pokeapi.co/api/v2/type/{name}/ donde "name" es un parámetro de la función que va ser el tipo ...
e2ad5022f9820b69b1f85f863bf6326155d7f876
Jonly-123/homework1_3
/获取文件大小.py
795
3.828125
4
import os # def getFileSize(filePath,size = 0): 定义获取文件大小的函数,初始文件大小是0 # for root, dirs, files in os.walk(filePath): # for f in files: # size += os.path.getsize(os.path.join(root, f)) # print(f) # return size # print(getFileSize('./yuanleetest')) all_size = 0 def dir_s...
d59b7f218b386a2e3aa6988917532c1fcf08be58
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter11/statSet.py
1,260
4.09375
4
# statSet.py from math import sqrt class StatSet: """ A Stat Set object is used to do simple statistical calculations""" def __init__(self): self.listX = [] def addNumber(self, x): # Add x to Object self.listX.append(x) def mean(self): # Return the mean of Object ...
f22353c54f8f914f108530601da9ea7ecb0fc612
NicholasBoss/CSE111
/Week9/reciept.py
3,725
3.875
4
import csv from datetime import datetime #indexes for products PRODUCT_NUMBER_INDEX = 0 PRODUCT_NAME_INDEX = 1 PRODUCT_PRICE_INDEX = 2 def main(): while True: try: products = getfilename("Please enter the name of the file: ") products = read_dict("products.csv", PRODUCT_NUMBER_INDE...
0f396e01858b3b96528378a35bc2fb1ef10159a2
Mugen-03/madlib
/python libs/crazy.py
253
3.953125
4
noun = input("enter a noun: ") verb = input("enter a verb: ") noun1 = input("enter a noun: ") noun2 = input("enter a noun: ") noun3 = input("enter a noun: ") print(noun + " had been running up a hill and did a " + verb + " over a " + noun1 + "!")
ee1df73006188c7413d5bef9242f41fe1199c157
wangtianqi1993/OfferAlgorithm
/offer_algorithm/sort/count_sort.py
521
3.765625
4
# !/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'wtq' def count_sort(data): """ 非比较排序时间复杂度为O(n) :param data: :return: """ min_data = min(data) max_data = max(data) len_data = max_data - min_data + 1 store = [0]*len_data for i in data: store[i-min_data] += 1 ...
e5a34f84d8b6b6d99245ab2dac7f14e8a2b0b80b
joaomcouto/UFMG-20202
/PraticaDevSoft-CodeReviewExercise/NormalizaListaSegmentos1-Rejeitado.py
1,714
4.0625
4
# Este programa python recebe uma lista de pares ordenados definindo trechos de um pequeno video, por exemplo # [ ( 49 , 80 ) , ( 600 , 1013 ) , ( 42 , 78 ) , ( 449 , 557 ) , ( 852 , 961 ) , ( 111 , 119 ) , ( 77 , 139 ) ]. # Cada par é da forma (frame inicial, frame final). Observe que os ...
7842b94f22cce2c86602972fb4a974549282f213
campbelldgunn/cracking-the-coding-interview
/ctci-08-01-triple-step.py
889
4.46875
4
#!/usr/bin/env python3 """ Triple step, for n steps, if you can walk 1, 2 or 3 at a time, how many ways are there to climb the steps? Completion time: 20 minutes. Examples: (1, 1), (2, 2), (3, 4), (4, ?) Notes - Right intution, f(n-1) + f(n-2) + f(n-3). - Did not need as many base cases. - Incorrectly simplified to...
04d8cd9db2f4ef635cd8f092f353a950554a13e4
mistrydarshan99/Leetcode-3
/graph/implement_graph_representation_sonya.py
2,431
4.375
4
""" purpose: implement an adjacent matrix to represent graph. Need to include below functions: - add an edge """ class Node: def __init__(self, vertex): self.v = vertex self.next = None class Graph: def __init__(self, num_of_vertex): self.num_of_vertex = num_of_vertex self.graph = [None] * s...
2e2c96f31e901076750cd65177d848266bb89160
afrancais/euler
/src/problems_30_40/euler_36.py
190
3.515625
4
def palindrome(i): return str(i) == str(i)[::-1] s = 0 for i in range(0, 1000001): b = bin(i)[2:] if palindrome(i) and palindrome(b): print i s += i print s
cb9bfed9e66d34720f7d82aa394db1ee585badbd
jasbury1/TutoringWorkshops
/202 Recursion/Problem 1/solution.py
407
4.09375
4
def factorial(num): # Base Cases if num == 0: return 1 if num < 0: return 1 # Reduction reduced_factorial = factorial(num - 1) # combining reduced result and num combined_value = reduced_factorial * num # Return combined results return combined_value if __name__ =...
19082eba9f9885e936f05eac1954d9eab27a36c7
derdelush/project1
/Python3/squares.py
124
3.515625
4
for i in range(1, 100): square = i**2 if square > 2000: continue print(i, " * ", i, " = ", square)
191c4030f5bcc4682d4436091d959810dbd2d840
JWill831/Algorithms
/1550. Three Consecutive Odds.py
761
3.8125
4
# 1550. Three Consecutive Odds # Easy # 102 # 14 # Add to List # Share # Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. # Example 1: # Input: arr = [2,6,4,1] # Output: false # Explanation: There are no three consecutive odds. # Example 2...
3ae2ad4e5ddaef5ba4098b24b9b16a51ae5b4508
Srividya-Ghanta/263680
/ListOperations.py
580
3.703125
4
N = int(input()) task = [] for i in range(N): inpt = [x for x in input().split()] task.append(inpt) arr = [] for i in range(N): if task[i][0] == "insert": arr.insert(int(task[i][1]),int(task[i][2])) elif task[i][0] == "print": print(arr) elif task[i][0] == "remove": arr.remov...
5507f37687ab2d5ba92c403abcdda4b0e41c53da
zhushh/PythonCode
/basicStudy/func_doc.py
359
4.03125
4
#!/usr/bin/env python # Filename: func_doc.py def printMax(x, y): '''Prints the maximum of two numbers. The two values must be integers.''' x = int(x) # converts to integer, if posiible y = int(y) if x >= y: print x, 'is maximum' else: print y, 'is maximum' printMax(3, 6) pr...
02f0513f324ac08949959293f0eb2e12d280f3b0
Bhuvaneswaribai/guvi
/code kata/greatest.py
158
3.875
4
n1,n2,c3= input(),input(),input() if (n1 >n2) and (n1 >c3): largest = n1 elif (n2 >n1) and (n2 >c3): largest = n2 else: largest = c3 print(largest)
4b9e1e08db87fb347917b508aadaf1a90aa8345a
SSaratKS/Python-Projects
/Day Planner/day_planner.py
1,590
4.21875
4
------------------------------ ### PROJECT: DAILY PLANNER ### ------------------------------ ''' Creating a day planner for a student - we need a username and password from a user, grant or deny access - once access is granted, the system requests to get the time of the day from a user - the system t...
d1791a32253182e12ab07aa9441188b7dbf7f810
Killsan/python
/numpy/2_change_info.py
314
3.84375
4
import numpy as np a = np.array([[1,2,3,4,5,6,7], [8,9,10,11,12,13,14]]) a[1,5] = 20 print(a) print('') a[:, 2] = [1, 2] print(a) print('------------------------3d shit-----------------------') b = np.array([[[1,2],[3,4]],[[5,6],[7,8]]]) print(b) # Get specific element (work outside in) print(b[0,1,0])
5e5c6ce5cfe839f4bda6eb3cef5465a952b3a0d6
mschae94/Python
/Day18/GUIEX03.py
315
3.984375
4
#추석 숙제!!!! 버튼들을이용해서 사칙연산 계산기 from tkinter import * win = Tk() b1 = Button(win , text= "One") b2 = Button(win , text= "Two") b3 = Button(win , text = "Three") b1.grid(row = 0 , column = 0) b2.grid(row = 0 , column = 1) b3.grid(row = 1 , column = 0) win.mainloop()
865f95e4fd27cf1cc90058bb5995b48cafa0406f
acadien/projecteuler
/p57.py
498
3.515625
4
#!/usr/bin/python from math import * #The idea: #calculate all numerators of root 2 expansions #calculate all denominators of root 2 expansions #Count all len(numer)>len(denom) numers=[1,3] denoms=[1,2] for i in range(2,1001): numers.append(numers[i-1]*2+numers[i-2]) denoms.append(denoms[i-1]*2+denoms[i-2]) n...
4cd45470f3acf367639af202a6771d39837a55dc
nathanbaja/Python-Exercises-CursoEmVideo
/ex078.py
201
3.984375
4
n = list() for x in range(0,5): n.append(int(input('Digite um valor: '))) n.sort() print(f'O maior valor digitado foi {n[0]}') n.sort(reverse=True) print(f'O menor valor digitado foi {n[0]}')
88e9f094dccf0ba5563f2f42e06503c40db0e832
RafaelDiasCampos/DatabaseImporter
/parsers/phoneParser.py
2,455
3.578125
4
import re if __name__ == '__main__': from baseParser import Parser else: from .baseParser import Parser # This class parses lines as an phone number and password. # Example of accepted lines are: # 5531123456789:pass # 5531123456789;pass class PhoneParser(Parser): def __init__(self): super().__in...
b8f862ea74e70d5d53186bcd33422b5648dc43b4
krafczyk/AOC_2020
/src/day_2.py
1,296
3.953125
4
import argparse import os import sys import re # Define Argument Parser parser = argparse.ArgumentParser('Solves Advent of Code Day 2') parser.add_argument('--input', help="Path to the input file", type=str, required=True) # Parse Arguments args = parser.parse_args() # Get input filepath input_filepath = args.input ...
7d8a3f993c4a6fce4156450cb8a9cc017d725392
awzsse/Keep_Learning_ML
/python就业班/python-07/11-通过send来启动生成器.py
771
3.703125
4
def create_num(all_num): a, b = 0, 1 current_num = 0 while current_num < all_num: r = yield a print(">>>r>>>", r) a, b = b, a+b current_num += 1 obj = create_num(10) ret = next(obj) print(ret) # 调用next以后会卡在yield # 换成send,这种方式有什么好处呢 # 这种方式相比于next,可以传参数进去 # 之前yield卡住,在调用send以后,继续进行 # 先进行赋值语句,赋值给ret,然后如果由于...
884e28a40ed4a818f3e4548c76d24602ad9d8327
VadimSquorpikkor/Python_Stepik
/2/2_4_strings/2_slice.py
893
4.09375
4
# Есть строка s = "abcdefghijk". # В поле ответа через пробел запишите строки (без кавычек), полученные в результате следующих операций: # # # s = 'abcdefghijk' # s[3:6] # s[:6] # s[3:] # s[::-1] # s[-3:] # s[:-6] # s[-1:-10:-2] # # Попробуйте найти ответ к этой задаче, не используя интерпретатор Python. Если без интер...
462fc9358d17b11b35991a3b5c0aa0cfd814ffc3
GokhanIrmak/PythonBasics-Demos
/Miscellaneous_2/Inputs.py
105
3.703125
4
age = input("Please enter first age") age2 = input("Please enter second age") print(int(age)+int(age2))
a48df62ba02659cc7351658b29da355f6d9d39ae
mikecwilk/Main-Repo
/python/login.py
487
4.03125
4
loop = 'true' while (loop == 'true'): username = input("Username Please : ") password = input("Password Please : ") if(username == "mike" and password == "wilk"): print ('Logged in Successfully as ' + username) loop = 'false' loop1 = 'true' while(loop1 == 'true'): command = input(username + "{} > > ") ...
31ac904844fc066be2655df9b4d30f78d1e6447f
deepaksharma9dev/DSA
/Step8/stack_operations.py
360
3.875
4
# stack = [] # def isEmpty(stack): # if len(stack) !=0 : # return "stack is not empty" # else: # return "stack is empty" # def insert_stack(stack,element): # stack.append(element) # def remove_stack(stack): # stack.pop() # def print_stack(stack): # return stack # def top_most(s...
e1abdba27b6da043d5635b91728f9211ad2444b2
ashritdeebadi/ds_leetcode
/optimized_water_distribution.py
1,732
3.890625
4
class Solution: def minCostToSupplyWater(self, n, wells, pipes): """ we solve this using krushal's algorithm IF we make the wells as Nodes and the pipes as edges then this problem would be reduced as a MST problem We use disjoin sets to solve this 1) We create a map to ke...
817826e9582d2d5b1d623ba9d1792294482f0b89
Cukerman/repos
/1/32.py
139
3.59375
4
n = int(input("Введите число ")) x=1 p=1 c=0 for i in range (1,n): x = 0 x = p + c c = p p = x print (x)
2c77bd200e6a8e00bd50e3d8f02adf859e629000
abhinandhani/bita
/strmanu.py
525
3.84375
4
#string manuplation word=input("enter the word:").lower() for i in word: if i=="e" or i=="o" or i=="u" or i=="i" or i=="a": i=ord(i)+1 neword=chr(i) print(neword,end='') else: print(i,end="") #other method '''word=input("enter the word:").upper() case=ord("word") ...
eef5c63757e3ac29f101abfeccbea9c46c4c22cd
qiujiandeng/-
/python1基础/day07/练习5_3.py
2,454
3.8125
4
# 3.<<学生信息管理项目>> # 输入任意个学生的姓名,年龄,成绩,每个学生的信息存入字典,然后放入列表中, # 每个学生的信息需要手动输入,当输入姓名为空时,结束输入 # 如: # 请输入姓名:tarena # 请输入年龄:20 # 请输入成绩:99 # 请输入姓名:name2 # 请输入年龄:18 # 请输入成绩:88 # 请输入姓名:<回车> 结束输入 # 内部存储格式如下: # [{'name':'tarena','age':...
1270ff637240fa4a784fd4123b53bf631dac1f3e
CaiZhongheng1987/algorithm_questions_and_codes
/leetcode054/test_Spiral_Matrix.py
1,897
3.5
4
# 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 # # 示例 1: # # 输入: # [ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] # ] # 输出: [1,2,3,6,9,8,7,4,5] # 示例 2: # # 输入: # [ # [1, 2, 3, 4], # [5, 6, 7, 8], # [9,10,11,12] # ] # 输出: [1,2,3,4,8,12,11,10,9,5,6,7] class Solution: def spiralOrder(self, matrix): ...
194619db9921dc366dbea8429ce636e9d8c5608a
songfish/leecode_solution
/array/53_Maximum Subarray.py
403
3.5625
4
class Solution: def maxSubArray(self, nums): ans = nums[0] sum = 0 for num in nums: if sum < 0: sum = num else: sum += num ans = max(sum, ans) return ans S = Solution() print(S.maxSubArray([-2,1,-3,4,-1,2,1,-5,4]))...
5f2c10773b9a4dafe68b39e8a99838243e5a4128
resb53/advent
/2020/src/day-15.py
1,887
3.75
4
#!/usr/bin/python3 import argparse import sys # Check correct usage parser = argparse.ArgumentParser(description="Check your Memory.") parser.add_argument('input', metavar='input', type=str, help='Numbers game input.') args = parser.parse_args() turns = [] # Reverse turn order so to use list.ind...
d8016475ff2dc039f1abf782caf06970129cd5c2
mooksys/Python_Algorithms
/Chapter39/file_39_2.py
203
3.90625
4
def add(number1, number2): result = number1 + number2 return result def display_sum(num1, num2): print(add(num1, num2)) # 메인 코드 a = int(input()) b = int(input()) display_sum(a, b)
2c4875172af880cbddc22171b36973eaa66a9825
fengxiayiji/xiaozhu
/python/pyfour.py
840
3.578125
4
#lass Employee : # empCount=0; # def __init__(self,age,salary): # self.age=age; # self.salary=salary; # Employee.empCount+=1; # # def displayCount(self): # print Employee.empCount; # # def dispalyEmp(self): # print self.age,self.salary; #mp1=Employee(20,4000); #mp2=Employee(30,19000); #etattr(emp1, 'name', 'xia...
1026b427db879aa72559c3ab91279d9a9343aeb3
bharath02/pythonDataStructure_1_week
/List/14.0_circularlyIdentical.py
322
3.9375
4
# Write a python program to check whether two lists are circularly identical. class circularlyIdentical: def checkTwoList(self,List1,List2): print(' '.join(map(str, List2)) in ' '.join(map(str, List1 * 2))) List1=[10,10,0,0,10,] List2=[10,0,0,10,10] circl=circularlyIdentical() circl.checkTwoList(List1,List...
3c6ba203eab850e75f13d4e1b7399b645327d1ca
rcullen011/Test_Repo
/sentence_checker_tests.py
4,869
3.5
4
import unittest import sentence_checker class TestSentenceCheckerMethods(unittest.TestCase): # Valid Sentence Tests def test_sentence_is_valid(self): sentence_checker_result = sentence_checker.is_valid_sentence('The quick brown fox said hello Mr lazy dog.') self.assertTrue(sentence_c...
72685774e5a9ab4f3152d5fec1e6fa06be05f6f0
genera11ee/code
/py/subject8-9/16.py
89
3.515625
4
my_number = 0 while my_number <= 10: print(my_number) my_number = my_number + 1
b04a848cec8a6dc29a6c6723787865842804c108
freshkimdh/Machine_Learning
/Level_1_python/python_basic_1/List_comprehension.py
333
3.84375
4
#기존 areas1 = [] for i in range(1,11) : if i%2 == 0: #길이가 짝수인 사각형 넓이 areas1 = areas1 + [i*i] print("areas1: ", areas1) #List comprehension areas2 = [i*i for i in range(1,11) if i%2==0] print("areas2: ", areas2) #8의 배수 list1 = [i for i in range(1,100) if i%8==0] print("list1 : ", list1)
0c9d4e996f297b5db40e4b66a413d20509dc7afc
retzstyleee/Chapter-05-Protek
/latih2.py
445
3.734375
4
print("Cek Status Kelulusan Mahasiswa") print("Range 0-100") Indonesia = int(input("Masukkan Nilai Bahasa Indonesia:")) Ipa = int(input("Masukkan Nilai IPA:")) Mat = int(input("Masukkan Nilai Matematika:")) if(Indonesia < 0) or (Ipa < 0) or (Mat <0): print("Maaf Input Anda Tidak Valid") elif(Indonesia > ...
fda77c738e936d0adca042ca9bdd2f15aa96d74a
MartinaLima/Python
/exercicios_python_brasil/estrutura_repeticao/08_soma_media.py
258
3.828125
4
print('\033[1m>>> SOMA E MÉDIA <<<\033[m') soma = 0 c = 0 for c in range(5): c += 1 num = int(input(f'- {c}º VALOR: ')) soma += num media = soma/c print(f'A SOMA DOS VALORES É: {soma}') print(f'A MÉDIA DOS VALORES É: {media:.2f}')
1bc36e8478e05c1e320f60e0a18c4bef0790a537
rodrigobeavis/curso-python
/teste-python/desafio52.py
478
4.0625
4
num = int(input('Digite um número: ')) divisores = [] string_Divisor = '' for count in range(1, num+1): if num % count == 0: divisores.append(count) string_Divisor += '{}, '.format(count) print(string_Divisor) if (1 in divisores) and (num in divisores) and (len(divisores) == 2): print('O numer...
4cff2887504720cc5b4604562b806cfe010717e3
SadeghShabestani/45_Store_db
/main.py
2,145
3.953125
4
from sqlite3 import connect class Database: connect = connect("store.db") cursor = connect.cursor() @staticmethod def show_all(): Database.cursor.execute("SELECT * FROM Products") result = Database.cursor.fetchall() print(result) # Database.connect.close() ...
2436a2f30d7b2f99cd7fc8697e837cdc6e158d57
wiknwo/Project-Euler
/Python/problem1.py
429
4.28125
4
# William Ikenna-Nwosu (wiknwo) # # Problem 1: Multiples of 3 and 5 # # If we list all the natural numbers below 10 that are # multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of # these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below 1000. def main(): sum = 0 for i in range(0, 1000...
fa85b32b1657ef18261f2768aa66470b672ce65a
nikita-r-patel/OthelloPythonProject
/gamelogic.py
6,735
3.53125
4
BLACK = "B" WHITE = "W" NONE = "." DIRECTIONS_LIST = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[1,-1],[-1,-1],[-1,1]] class InvalidMoveError(Exception): '''Raised whenever an invalid move is made''' pass class OthelloGameState: def __init__(self, rows: int, cols: int, first_turn: str, left_pi...
67e1310cf4395c1c72169f2a0e5496a55e67648d
pranithajemmalla/Cracking_The_Coding_Interview
/Data Structures/ArraysAndStrings/1.9 String Rotation.py
977
4.28125
4
# String Rotation # Given two strings s1 and s2, write code to check if s2 is a rotation of s1. eg: "waterbottle" is a rotation of # "erbottlewat" class StringRotation: def __init__(self): self.str_1 = None self.str_2 = None def isSubstring(self, string): return string.find(self.str_1)...
b07800509ec200ea2d7823f0c6cf61929a9736f2
eric774/100-days_projects
/day 21/main.py
1,278
3.515625
4
from turtle import Screen from caterpillar import Caterpillar from food import Food from scoreboard import Scoreboard import time screen = Screen() screen.setup(width=600, height=600) screen.bgcolor("black") screen.title("My caterpillar Game") screen.tracer(0) caterpillar = Caterpillar() food = Food() scoreboard = Sc...
07ce3b755c7e597511e213d09e4d45723d4aec55
biancapitic/University
/Fundamentals of Programming/Hangman/UI/Console.py
1,946
3.703125
4
from Exceptions.Errors import HangmanException class UI: def __init__(self, sentences_repository, game_service): self._sentences_repository = sentences_repository self._game_service = game_service def __read_sentence(self): sentence = input("Enter sentence: ") senten...
0a615e97c87a48fa51662b854313fea2e81472d0
Tansiya/tansiya-training-prgm
/sample_question/permutation.py
186
4.15625
4
""" write a program which prints all permutations of [1,2,3]""" #import for math operator import itertools #print permutation of list print (list(itertools.permutations([1,2,3])))
48f4e4dfad4bf044aeb103114182c3620ece6725
aksharpatel17/first-python-file
/first.py
1,297
3.90625
4
import time; print("hello there") a = b = c = 1, 2, "JD" print(a, b, c) list = ['abcd', 786, 2.23, 'john', 70.2] tinylist = [123, 'john'] print(list) print(list[0]) print(list[1:4]) print(list[2:]) print(list[:2]) print(list[:-1]) print(tinylist * 2) print(list + tinylist) tuple = ("abcd", 1, 2) prin...
1dd3bcdf02b54a4794bbe9dda6ecd8966636cf15
TiagoCaldaSilva/FEUP-FPRO
/RE12/Card_game(RE12).py
2,618
3.890625
4
import random from typing import List, Tuple # card suits SUITS = "♠ ♡ ♢ ♣".split() # spade, heart, diamond, club # card ranks RANKS = "2 3 4 5 6 7 8 9 10 J Q K A".split() # 2-10, Jack, Queen, King, Ace Card = Tuple[str, str] Deck = List[Card] haands = [] def create_deck(shuffle: bool = False) -> Deck: """Cre...
29724c035ec6b7c008a180c1ddf7940f09228d87
MalikaJain09/DataStructurePracticePython
/venv/MaxOfNumber.py
1,446
4.03125
4
# number =[10, 11, 32 , 34 , 5 , 98 , 12] # # def maximum(number , begin , end ): # # max = number[begin] # if begin == end: # return (number[begin]) # if end == begin+1: # if number[end] > number[begin]: # return (number[end]) # else: # return(number[...
f4ce4bf8064ee93fa5087cfcf9be00ee08b4756e
ChinaChenp/Knowledge
/learncode/python/data_structure/set.py
226
3.875
4
a = set('abracadabra') b = set("alacazam") print('a=', a) print('b=', b) print('a-b=', a-b) print('a|b=', a|b) print('a&b=', a&b) print('a^b=', a^b) if 'a' in a: print("a in a") if 'x' not in a: print("x not in a")
da087a386b22622f71621248f55040d7131895af
linkjavier/holbertonschool-interview
/0x00-lockboxes/0-lockboxes.py
469
3.765625
4
#!/usr/bin/python3 """ Lockboxes """ from itertools import dropwhile def canUnlockAll(boxes): """ Method that determines if all the boxes can be opened """ BoxesNumber = len(boxes) keys = [0] for key in keys: UnitBox = boxes[key] for NewKey in UnitBox: if NewKey not in key...
40e7829f9ab29837aace0ad6572238c6d7be0de7
rafaelsouzak2b/CursoPython
/Mundo02/Exerc/Ex053.py
483
4.03125
4
''' --------------------Exerc 051------------------- Crie um programa que leia um frase qualquer e diga se ela e um palindromo, desconsiderando espacos ------------------------------------------------ ''' frase = input('Digite a sua Frase: \n'); frase = frase.replace(' ', ''); fraseInvertida = frase [::-1]; print(fra...
a891db11d49687a4a044091d9b3a3a5bbf616c40
yhaidai/epam-python-winter-2021-final-project
/department_app/models/department.py
1,809
3.640625
4
""" Department model used to represent departments, this module defines the following classes: - `Department`, department model """ # pylint: disable=cyclic-import import uuid from department_app import db class Department(db.Model): """ Model representing department :param str name: name of the depar...
e6200109f488cb66776b582f37e26a3eabbcdfaa
dinomitedude/utilities
/math/units.py
1,633
3.828125
4
#!/anaconda2/bin/python class Units( object): def __init__( self, unitstring, inverse=False, chars=3): self.top = unitstring[:chars] self.bot = unitstring[chars:] self.inv = inverse if self.inv: self.inverse() def inverse( self): bot, top = self.top, self.b...
09d55cb7c888d42ce54fc27ca0353f0348301032
vinodbellamkonda06/myPython
/functions/ss.py
491
3.515625
4
def CountSquares(a, b): cnt = 0 # initialize result # Traverse through all numbers for i in range(a, b + 1): j = 1 d = 0 while j * j <= i: d += 1 if j * j == i: cnt = cnt + 1 j = j + 1 i = i + 1 return cnt print(Count...
83290cf4ec9bfb06a423ffcfa6e0de2b5cf8b7c8
AdamZhouSE/pythonHomework
/Code/CodeRecords/2201/60638/250170.py
341
3.53125
4
def isPara(num): if num==1: return False for i in range(2,num): if num%i==0: return False return True n=int(input()) for x in range(0,n): list1=list(map(int, input().split(" "))) num=list1[0]+list1[1] number=num+1 while not isPara(number): number=number+1 ...
944a1decce4223a8d7923c06ec204e9e43333ca4
gsudarshan1990/PythonClassesExample
/Encapsulation_example1.py
353
3.671875
4
class Base: def __init__(self, name, protected_name): self.name = name self._protected_name = protected_name def _protected_print(self): print("This is protected print") b1=Base('sonu','shashank') print(b1.name) print(b1._protected_name) b1._protected_name = 'good name' b1._protected_pr...
7a292b5a02f844649369413de53cd9170aac622d
jameswmccarty/AdventOfCode2015
/day4.py
1,512
4.0625
4
#!/usr/bin/python import hashlib """ --- Day 4: The Ideal Stocking Stuffer --- Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys. To do this, he needs to find MD5 hashes which, in hexadecimal, start with at le...
f4131a488c76f6bc1938b6a214b91125cf3ff0bd
seohae2/python_algorithm_day
/코딩인터뷰/chapter08_연결리스트 [다시하기]/01_두_정렬_리스트의_병합/seohae.py
1,198
3.671875
4
# 정렬되어있는 두 연결 리스트를 합쳐라 # 입력 1->2->4, 1->3->4 # 출력 1->1->2->3->4->4 class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # 리스트 변환 def mergeTwoLists(l1: ListNode, l2: ListNode) -> ListNode: while l1 is not None: prev = l1.val while l2 is not No...
3d583ecd9661619b08c63a86f474210cecb0d1f3
yyyuaaaan/pythonfirst
/crk/4.3.py
2,512
4.125
4
"""__author__ = 'anyu' 4.3 Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height. One way to implement this is to use a simple root.insertNode(int v) method This will indeed construct a tree with minimal height but it will not do so...
16d7bb6e7251252184512b39a26845a9d4a37a70
yehuohan/ln-misc
/gists/python/underline.py
954
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ _var : 命名约定,表示非开放接口,同时'from <mod> import *'不会导入_var var_ : 无特殊用意,可以避免与python关键字冲突 __var : python进行名称修饰,会添加'_<ClassName>'作为前缀 __var__ : 一般用于特殊用途,如'__init__'用于构造函数,'__call__'用于括号调用 _ : 表示临时或无意义变量 REF: https://zhuanlan.zhihu.com/p/36173202 """ class Var: ...
6aa2354749f1dc2d3fd6f579c2dafd88e34b17b2
RedWhistleProductions/Arduino_Light_Switch
/Light_Strip.py
2,549
3.578125
4
''' Light Switch written by Billy Snyder for Public Domain This is a simple app for testing serial communication with an Arduino Uno The final app will be to control a RGB light strip connected to an Arduino Uno ''' import serial import serial.tools.list_ports as Port_List from tkinter import * def Connect(): #...
1029e5606f44087fa3e00c3e2aa6fdfb481080b5
gutierrez310/proyectos-py
/biseccion.py
2,106
3.8125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 29 10:05:39 2020 @author: carlo """ """ Please think of a number between 0 and 100! Is your secret number 50? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l Is your secret num...
3b23735a32c891aabd678589189c704363543344
mhcrnl/D-Pad
/message.py
342
3.71875
4
from tkinter import messagebox def alert(alert_text): """ Displays an Alert box. """ messagebox.showerror(title="Oops", message=alert_text) def info(info_text): """ Displays an Information box """ messagebox.showinfo(title="Information", message=info_text) if __name__ == '__main__': alert('Te...
7d6b40b5b5ca21025cbaf0be17a3c8dc402f92d3
xMrShadyx/SoftUni
/Python Fundamentals - September 2020/10_List_Advanced_Exercise/01_Which_Are_in.py
178
3.875
4
list_1 = input().split(", ") list_2 = input().split(", ") result = [subst for subst in list_1 for word in list_2 if subst in word] print(sorted(set(result), key=result.index))
82ebc1a686d89ec78eba15d94865cbf96469c414
takuya0412/AOJ
/Volume0/84.py
739
3.75
4
def search(): return import re data2=[] data=input() print("文字列長さ",len(data)) for i in range(len(data)-3): print("i",i,"data[i+4]",data[i:i+4]) if data[i:i+4].isalpha() and data[i+4].isalpha()==False and data[i-1].isalpha()==False: print("if",data[i:i+4]) data2.append(data[:i+4]) print...
3d28d6b5dc180bb582378ada9f9326691a049b4a
lambdaschool-pm/graphs-review
/src/graph.py
4,947
3.640625
4
import random class Vertex: def __init__(self, label, color="gray", **pos): self.label = label self.color = color self.pos = pos self.edges = set() ''' def __repr__(self): return str(self.label) ''' # Use the str method instead def __str__(self): ...
bb59cde1a24ac4f4a79acf92d69908f096b10b6b
AlwaysOnline233/cookbook
/cookbooks/chapter_3/3_1.py
882
3.953125
4
# 数字的四舍五入 print('——————————————————————') # 简单的舍入运算使用内置的 round(value, ndigits) print(round(1.23, 1)) print(round(1.27, 1)) print(round(-1.27, 1)) print(round(1.25361,3)) print('——————————————————————') # 当一个值刚好在两个边界的中间的时候, round 函数返回离它最近的偶数 # 传给 round() 函数的 ndigits 参数可以是负数,这种情况下, 舍入运算会作用在十位、百位、千位等上面 a = 1627731 print...
6e5170c60f759e34fd532a0b643d257e997691c8
lemon-l/Python-beginner
/100例/用字典存储.py
481
3.9375
4
dict = {} for i in range(2): stu = input('请输入学生姓名:') socre_1 = int(input('请输入语文成绩:')) socre_2 = int(input('请输入数学成绩:')) socre_3 = int(input('请输入英语成绩:')) print('-------------') list_i = [socre_1, socre_2, socre_3] dict[stu] = list_i for i in dict: print('%s 的语文成绩为: %d ;数学成绩为 %d ;英语成绩为: %d'...
8e7a50ddae33025fcabe29cb371100fc88e158e3
yokomotoh/python_excercises
/np_array_math_operators.py
1,374
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 8 14:59:43 2019 numpy array math operators @author: yoko """ import numpy def arrays(arr,n,m): tmp=numpy.array(arr,int) return numpy.reshape(tmp,(n,m)) N, M = input().split(' ') arr=[] for i in range(int(N)): arr.append(input().strip(...
9c8ac92cbb20c843f68d8dcec6fc78893633b3ad
surjitr/PythonUnitTestDrivenDevelopment
/TestDrivenDevelopment/src/tstadder.py
666
3.8125
4
"""Demonstrates the value of test driven programming""" from adder import adder import unittest class TestAddr(unittest.TestCase): def test_num(self): self.assertEqual(adder(3,4), 7, "3 + 4 should 7") def test_string(self): self.assertEqual(adder('x','y'), 'xy', "x + y should be xy") def...
f3b64ffe5deae9ec28af4b5c370bc07551e86e96
jeremiahxy/DataViz
/Bootcamp Class Activities/Python/1116/Refresher_class 2.py
219
4.125
4
print("Hello User!") name = input("What is your name?") print("Hello "+ name +".") age = int(input("What is your age?")) if age <30: print("Aww... you're just a baby!") else: print("Ah... A well-traveled soul are ye.")
d2005e89818a7fb3f60a710f987ccf3c481a753d
RafaelDSS/uri-online-judge
/iniciante/python/uri-1021.py
801
3.796875
4
# -*- coding: utf-8 -*- N = input().split('.') valor = int(N[0]) cedulas = (100, 50, 20, 10, 5, 2) print('NOTAS:') for cedula in cedulas: quant_cedulas = 0 while valor >= cedula: quant_cedulas = valor // cedula valor %= cedula print('%d nota(s) de R$ %d.00' %(quant_cedulas, cedula)) ...
ee7e1a84c600c000b28e0260718d0a233a3c92f1
Saatvik17/pythonws
/strings/practice/001date/001.py
337
4.3125
4
from datetime import datetime , timedelta today = datetime.now() oneday = timedelta(days=1) yesterday = today - oneday print("today is :" + str (today)) print("yesterday was : " + str(yesterday)) birthday = input ("enter you birthday ") birthdaydate = datetime.strptime(birthday , "%d/%m/%Y") print("birthday :" + s...
cc2e61383fe8ade14f8792a96570cc6eef969c6c
beckum8282/MyPythonPractice
/영단어.py
1,339
3.53125
4
import random class Word: def __init__(self, Eng ,Kor): self.Kor=Kor self.Eng=Eng; Words=[]; file=open("C:\work\words1200_o.txt","r"); #경로 u=1; English=" "; Korean=" "; def init(): global Words; lines=file.readlines() for line in lines: English=line[7:23]; ...
bc611293daa7470667039dd4dca53b0b47382036
Tanuki157/Chapter-2
/test.py
4,564
4.375
4
def comment_example(): #comment example receives no arguments #it explains how to creat a function header #and outputs or returns "Hello World!" print('hello world!') def program2_1(): #apostrophe output print('Kate Austen') print('123 Full Cirlce Drive') print('Asheville, NC 28899') ...
8b0151528cfeea7d5a94a6f7235fb24b31a10cba
aa-ag/nano
/algorithms/basic_algorithms/guess_the_number.py
1,842
4.125
4
###--- IMPORTS ---### import random ###--- GLOBAL VARIABLES ---### total_tries = 7 start_range = 1 end_range = 100 ###--- CODE ---### def guess_the_number(total_tries, start_range, end_range): ''' guess a random number between 1 and 100, you will have 7 tries ''' if start_range > end_range: ...
c4eb497c79e2952e6cdd7d604f0d6102302baebb
yuhanlyu/coding-challenge
/lintcode/binary_tree_level_order_traversalII.py
740
3.828125
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: buttom-up level order in a list of lists of integers """ def levelOrderBottom(self, root...
397b005700b8af84424d89dc773c9c32e045fb75
fintse/susu-101-prepare-to-exam-exercises
/ex43.py
1,184
4.09375
4
# имя проекта: python exercises # номер версии: 1.0 # имя файла: ex43.py # автор и его учебная группа: Э.Финце, ЭУ-120 # дата создания: 29.11.2019 # дата последней модификации: 24.12.2019 # связанные файлы: # описание: Дан одномерный массив числовых значений, насчитывающий N элементов. # Из элементов исходного массива ...
1bba89807c45f9739b271c00aa2268c263f7b6eb
Nihat17/LinearRegression-and-Regularization
/Regressin Model on Boston data set.py
639
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 18 00:27:45 2018 @author: Nihat Allahverdiyev """ from sklearn.model_selection import train_test_split import mglearn.datasets as md from sklearn.linear_model import LinearRegression # load the data X, y = md.load_extended_boston() X_train, X_test...
76d893517a5164c433768f4d22248b5258177001
wlsherica/FunTime
/others/funQ/randomNum_generator.py
850
3.5625
4
#!/usr/bin/env python #2015-05-11 #Create a random number generator Xn+1 = (A*Xn+B)%M, A, B, M, Xn will be given #Output: print random number from K to K+4 #Usage: python yourcode.py "9 7 6 1 3" import sys def RandomGen5(line): A, B, Xi, K, M = map(int, line) return (A*Xi+B)%M if __name__ == "__main__": ...
5410f5591a990bbc9a33df50a80adfb0bcf3a4bd
fatimatswanya/fatimaCSC102
/Class Work oop part 2.py
473
3.96875
4
class oranges: price=50 stockquantity=100 def __init__ (self, amount): self.amount = amount def CustomerOrder(self): if self.amount > oranges.stockquantity: print('Unfortunately We do not have enough oranges. Reduce your order please.') else: print(f'...
9227d2e46b55e80e446076a7d7b03e339bb3d6e3
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/string/IsomorphicStrings.py
1,627
4.15625
4
""" @author Anirudh Sharma Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to th...
ca9648f938636697372b9d2be5a57acda8a37aa6
YanceWang20000806/K-Means-Cluster-Weightlifting-Data
/EXAMPLE.py
12,251
3.90625
4
""" Author: Jaeger Jochimsen An interactive example of the code and its use, designed to be run in jupyter notebook or another web-based interpreter. The allows individuals without Python installed locally to test the functionality of the program without needing to download anything. """ import math import random impo...
65c8ac96d09ea1a533db502ba11aa9e726faf99a
Jack0rantan/Competitive-programming
/122---HackerRank/InterviewPreparation/RepeatedString/test.py
327
3.90625
4
#!/bin/python3 import sys # Complete the repeatedString function below. def repeatedString(s, n): count = 0 ll[] return count if __name__ == '__main__': # input file f = open('input.txt', 'r') sys.stdin = f s = input() n = int(input()) result = repeatedString(s, n) print(r...
5e6f3f2e6745ac7d987cb0c2166b41563b2cb269
akhilfrancis93/LuminarDjango
/Languagefundamentals/flowcontrols/looping/reversinganumber.py
124
4.125
4
num=int(input("enter number ")) result="" while(num!=0): digit=num%10 result+=str(digit) num//=10 print(result)
76099e9199161bf3e5d944e4201fac40f700024b
innTall/tasks
/task2/num1_10.py
2,800
3.9375
4
from random import randint, uniform import math # print(f'd = {d}') a = randint(0, 100) b = randint(0, 100) c = randint(0, 100) d = randint(0, 100) print(a, b, c, d) # 2.1. Составить программу: # а) вычисления значения функции y = 17x2 – 6x + 13 при любом значении x; # б) вычисления значения функции y = 3a2 + 5a – 21 ...
0a7209371664b19819d7877b7738c538d234f370
vmichal/ALP-FEE-CTU
/HW/rectangle.py
1,783
3.65625
4
import sys from itertools import product def read_matrix(): with open(sys.argv[1]) as file: return [list(map(lambda x: 1 if x[0] == '-' else 0, line.split())) for line in file] def calculate_histogram_heights(matrix): height, width = len(matrix), len(matrix[0]) for y in range(1,height): for x in range(width):...
87793bedda176610e0539b11e789aeab2651734f
ShwinyG/Priority-Queue
/tasks.py
643
3.5625
4
""" Name: Ashwin Gowda asg7954@rit.edu File: tasks.py Purpose: Used as a task file to """ from priority_queue import * from dataclasses import dataclass @dataclass class Task: name: str priority: int def make_task(name, priority): """ Makes an empty task :param name: What the name of the task i...
3a68ec24818c26c9a224d62988974be39581cafc
sreerajch657/internship
/practise questions/average of list.py
292
4.25
4
#Python Program to Calculate the Average of Numbers in a Given List lst=[] n=int(input(" enter the limit of the list : ")) for i in range(0,n): x=int(input("enter the element into the list : ")) lst.append(x) avg=int(sum(lst)/n ) print(" the average of the list is : %d " %avg)
3ff68098da6b248c0c0e326917e84799e70d5d7b
JoeyParshley/met_cs_521
/jparshle@bu.edu_hw_5/jparshle@bu.edu_hw_5_6_1.py
1,215
4.28125
4
""" Joey Parshley MET CS 521 O2 10 APR 2018 hw_5_6_1 Description: Description: Write a function with the following header that returns a pentagonal number. def getPentagonalNumber(n): Write a test program that uses this function to display the first 100 pentagonal numbers with 10 numb...
bbf7fc3fd0275cce76526ad9a00ef3397e43a0ab
turbobin/algorithm_learning
/21_graph.py
1,544
3.84375
4
# -*- coding: utf-8 -*- class UndiGraph: """无向图,使用邻接矩阵存储""" def __init__(self, v): self.v = v self.adj = [] for __ in range(self.v+1): self.adj.append([]) def add_edge(self, s, t): """存储边""" if s > self.v or t > self.v: return "图存储溢出了" ...
ae36042a8378ab98e2d52546e5c51a84da59bbac
ujjwal002/100daysofDSA
/day_2 sorting/selection_sort.py
527
3.828125
4
def selectionSort( itemsList ): n = len( itemsList ) #lenght of array for i in range( n - 1 ): # minimum position where we start loop minValueIndex = i for j in range( i + 1, n ): if itemsList[j] < itemsList[minValueIndex] : minValueIndex = j if minValueInd...
e83777ee0618c0f424123cb557de32a32191b822
ag300g/leecode
/mergsort.py
1,428
4.34375
4
# mergesort # the two sorted sublists to be merged are: # lt[left:mid] and lt[mid, right] def merge(lt, left, mid, right): i, j = left, mid lt3 = [0] * len(lt) #temporarily store sorted sublist for k in range(left, right): # lt3[left:right] will store sorted results # if scanning lt[left:mid]...