blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
dd9db3117e5591581050b0a0b2951a87831533a0
HollisHolmes/MIT_6.006
/PS2/minheap.py
4,074
4.03125
4
class MinHeap: """ array based min heap implementation of a priority queue Things to note: 1) left child, right child, and parent indexing with 2*i, 2*i+1, i//2 does not work if the array starts at index 0. ex: index 1 and 2 should have parent 0, but 2//1 = 1 which is wrong we need a...
e71cb442dc1388eb31774665a3db80578dcded3f
Kvn12/MC102
/Lab09.py
1,267
4.03125
4
def intersecao(m, n): '''Recebe duas matrizes cujas linhas sao conjuntos e compara cada linha em busca de intersecoes, as quais se existirem\ sao colocadas como linhas de uma nova matriz, a qual e retornada. Parametros: m --- matriz a ser comparada n --- matriz a ser comparada ''' matriz_...
c260c9db895e6c7dcaaf475a655d3722b4d99663
deepeshkumarsoni/Python-Basic
/numconverfunct.py
376
3.71875
4
#1.Conversion into Binary Form print('Conversion into Binary Form') print(bin(15345)) print(bin(0o7625)) print(bin(0xface34)) print('\nConversion into Octal Form') #2.Conversion into Octal form print(oct(34765)) print(oct(0b1101110001)) print(oct(0xafc4f)) print('\nConversion into Hexadecimal Form') print(he...
078120fd81a0a8068d2ac958c340b3562bb10da1
Brian-Mascitello/Advent-of-Code
/Advent of Code 2015/Day 3 2015/Day3Q2.py
3,927
3.953125
4
# -*- coding: utf-8 -*- """ Author: Brian Mascitello Date: 12/20/2015 School: Arizona State University Websites: http://adventofcode.com/day/3 http://adventofcode.com/day/3/input Info: --- Part Two --- The next year, to speed up the process, Santa creates a robot version of ...
e6d1f6d318b52a21f1807b615c897c35101b670c
felipeserna/holbertonschool-machine_learning
/unsupervised_learning/0x01-clustering/11-gmm.py
602
3.578125
4
#!/usr/bin/env python3 """ Calculates a GMM from a dataset """ import sklearn.mixture def gmm(X, k): """ Returns: pi, m, S, clss, bic """ GMM = sklearn.mixture.GaussianMixture(n_components=k) # Estimate model parameters with the EM algorithm. GMM.fit(X) pi = GMM.weights_ m = GMM.mean...
ad0d8272be495b8b651186d9330cef3c89a1958c
zhouyang209117/leetcode
/py/l010_regular_expression.py
427
3.84375
4
# coding: utf-8 import re class Solution: def isMatch(self, s: str, p: str) -> bool: r = re.match(p, s) if r is None: return False return r.group() == s if __name__ == '__main__': s = Solution() print(s.isMatch("aa", "a")) print(s.isMatch("aa", "a*")) print(s....
0db338de2b757b7f45eb5c4761a184da0677ae1a
ShineySun/Vanishing-Point-Detection
/v_code/kruskal.py
3,786
4.1875
4
import numpy as np from operator import itemgetter # function [w_st, ST, X_st] = kruskal(X, w) # # This function finds the minimum spanning tree of the graph where each # edge has a specified weight using the Kruskal's algorithm. # # Assumptions # ----------- # N: 1x1 scalar - Number of nodes (vertices) of...
436da6d84c19a4038e7f87c8e7ad9516f9accc68
tbrodbeck/InspiredByNature
/GA/Makespan_GA_Inga.py
8,282
3.625
4
import numpy as np from abc import ABC, abstractmethod ''' The problems ''' def get_problem_1(): process_200 = np.random.randint(10, 1001, 200) process_100 = np.random.randint(100, 301, 100) processing = np.zeros(300) processing[:200] = process_200 processing[200:] = process_100 return proces...
705fc3b78cbad6655922216d87d8687a5766e489
spnear/Python-Advanced-Concepts
/decorador_execution_time.py
841
3.765625
4
#Validar eficiencia del programa calculando tiempos de ejecucion from datetime import datetime #*args, **kwargs para enviar n cantidad de parametros def execution_time(func): def wrapper(*args, **kwargs): initial_time = datetime.now() func(*args, **kwargs) final_time = datetime.now() ...
ede3c3cac9ddd9701cd07f2b28202e320aed608a
keenhenry/euler
/euler21_30.py
4,967
3.84375
4
#!/usr/bin/python """ Project Euler Solutions: Problem 21 - 30 """ import sys import time import euler11_20 import euler1_10 import string #import math # function to generate fibonacci numbers: a generator def fib(): a, b, i = 0, 1, 1 while True: yield b, i a, b, i = b, a+b, i+1 def ydigits(num=0): '...
dcd252960a1b08665c15f551c29bd9f9aacd0218
johannabi/MA-ConceptMining
/MA-ConceptMining/inout/inputoutput.py
3,476
3.6875
4
import sqlite3 as sql import re import csv def read_file_by_line(file): """ reads a text file line by line :param file: path to file :return: list of all lines """ word_list = list() with open(file, mode='r', encoding='utf-8') as f: for line in f: line = line.strip() ...
fff85242b8b8741f6738b916760a53767cb28f91
BogdanFi/cmiN
/FII/L3/RN/1/sem/ex.py
2,833
3.5
4
#! /usr/bin/env python import datetime import json import math import re import urllib2 import sys import numpy def ex1(): name = raw_input("Nume Prenume: ") age = raw_input("Varsta: ") chunks = name.split(" ") if len(chunks) != 2: print("[x] Doar nume prenume.") exit() last, fir...
72a5e589104c67da59eea40c758dd9dc0bcd591c
ulyssesorz/data-structures
/oj/是否是二叉搜索树.py
2,059
3.84375
4
""" 按照层次遍历给出一颗二叉搜索树,例如:3 1 4 # # 2 #,以空格分开,其中#号代表对应的节点处为空 """ class Node: def __init__(self,val): self.left=None self.right=None self.val=val def level_insert(root,val): #按照题目所给还原该树 if root is None: #空树,生成根节点 root=Node(val) else: ...
11377403f75dcfce2ef674afe462854b158b8c30
globalghost1/Secure_ERP_Python_project
/view/terminal.py
4,966
3.765625
4
import os import datetime from copy import deepcopy def clean(): os.system("cls || clear") show_now = datetime.datetime.now().strftime("%A, %d-%m-%Y\nTime: %H:%M:%S ") print('Today is:', show_now) print("\n") def print_menu(title, list_options): """Prints options in standard menu format like thi...
943aae59bfd26bfb27efddb3971066109da2a003
taras16/Python_learn
/ATV/Numbers.py
147
4
4
num1 = 30 num2 = 45 num3 = num1 + 10 print(num3) print(num1 + num2 ) print(num1 * num2 +10) print(num2/3) # float x1 = 6 x2 = 4 print(x1/x2)
18137f736b9bc8cc477d8742d7e9c1d48b8bbb0f
BALURAAM/sc
/6.py
123
3.671875
4
def bala(a,b): if(b==0): return a else: return bala(b,a%b) a = int(input()) b= int(input()) print (bala(a,b))
cf80cb9a836d8dc7b75ab622b02a92367e4eab4f
jingong171/jingong-homework
/刘恺诚/2017310423第四次作业金工17-1刘恺诚/骰子.py
309
3.640625
4
class Die(): """A small Die""" def __init__(self,sides=6): self.sides=sides def roll_die(self): print(int(randint(1,self.sides))) from random import randint sides=int(input("请输入骰子的面数")) myDie=Die(sides) for i in range(1,11): myDie.roll_die()
d7a89f675a7df26559f92547984848f7dd11d50f
i3ef0xh4ck/mylearn
/Python基础/day015/08 random模块.py
1,664
3.640625
4
# random随机数 import random # print(random.random()) #0~1之间的小数 # print(int(random.random() * 10)) # print(random.randint(1,5)) #随机范围整数,包含边界 # print(random.randrange(0,10,2)) #随机偶数 # print(random.randrange(1,11,2)) #随机奇数 # print(random.choice([1,2,"ww",22,33])) #从可迭代对象随机一个元素 # print(random.choice("12345")) #从可迭代对象随...
3b492dd41354983b222c219debde58ce0f0e5168
Gayatri424/Assignment-supportgenie
/Supportgenie/Selected_Agents.py
1,530
3.84375
4
import random from Agent_data import Agent n=int(input("Enter Number Of Agents :")) #Enter No of Agents selection_mode=int(input("Enter Number Of Selection mode :")) #Selectionmode 1.All available 2.Leastbusy 3.Random j=0 agents=[] #Enter Agent Data here while j<n: agent=Agent(eval(input()),input(),[item for it...
22df2a801d292cf1efa815cc1786ae25ee45c9d7
shalinichaturvedi20/moreExercise
/question5.py
434
4.21875
4
# fact=int(input("enter the number")) # i=0 # while i<fact: # if fact < 0: # print("it is factorial number") # elif fact == 0: # print("The factorial of 0 is 1") # else: # for i in range(1,fact + 1): # fact = fact*i # print("The fact of",fact,"is",fact) num = int(input("ente...
fc37caa5d7f3f89f3dbff1c7d9ba9a5131c4593c
redixhumayun/ctci
/RADP/Robot.py
1,290
4.03125
4
#! /usr/bin/env python3 import pdb class Point(): def __init__(self, x, y): self.x = x self.y = y def findPath(grid, row, column, pathArray, failedPoints): ''' findPath is a function to help a robot move through a grid Return type: grid of path ''' # pdb.set_trace() try: ...
7021403de9813d4c888e02045dec85a3f8556f7b
Yobretaw/AlgorithmProblems
/EPI/Python/Recursion/16_1_tower_of_hanoi_problem.py
1,148
4.03125
4
import sys import os import math """ You are given n rings. The i-th ring has diamter i. The rings are initially in sorted order on a peg(P1), with the largest ring at the bottom. You are to transfer these rings to another peg(P2), which is initially empty. You have a third peg(P3), which is initially...
357636e66c64e3d53f47291fb9bf593d735ec2c1
rrssantos/Python
/Python39/teste ro.py
309
4.125
4
print("Exercicio 13") h13 = float(input("Digite sua altura: ")) s13 = input("Você é homem ou mulher? (m/h") if s13 == "m" or s13 == "M" : print(f"Se voce for homem seu peso ídeal é de: {(72.7*h13)-58:6.2f}") else : print(f"Se voce for mulher seu peso ídeal é de: {(62.7*h13)-44.7:6.2f}")
6f81993c484b04f440943cdd0acdf3a988de6fde
ZeroxZhang/pylearning
/inheritance&override.py
583
3.90625
4
class Father: def eat(self): surname = "zhang" print("Father can eat") class Mother: def cook(self): print("mom can cook food") #son继承father的属性,在类括号中写入要继承属性的类名 class Son(Father,Mother):#继承的时候用逗号隔开多个类 def eat(self): print("这句话重载了father eat的方法") def cook(self): pri...
83421b5edaa402adc3a5eaaba85edf6d8cbb8406
abhishek-jana/Leetcode-Solutions
/dynamic_programming/300-Longest-Increasing-Subsequence.py
3,136
3.875
4
''' Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may be more than one LIS combination, it is only necessary for you to re...
44db98b01565aaa9ce17491282490483d9968528
Jackelyneg/Python-challenge
/budget.py
1,853
3.921875
4
# read csv import os import csv budget_csv = os.path.join("..", "Resources", "budget_data.csv") total_months = [] total_profit = [] Average_change = [] Monthly_profit = [] with open(budget_csv) as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") #skips column name skip_header = next(cs...
c916098a8b0247d4966841b39855da45d6448319
Prasan92/mywork
/python_AtoZ/decorator.py
579
3.765625
4
def deco(f): #check no. of arguments def inner(*args): try: if len(args) != 2: raise Exception ("cannot pass more then two arguments") a,b=args if not (type(a) in [int,float] and type(b) in [int,float]): raise Exception ("pass either i...
5647eed9b4a815e17b5b7fc7ed9c57d794ceee3f
OvchinnikovaNadya/coursePython1
/Example_5_2_compare.py
251
3.515625
4
def compare(S1, S2): ngrams = [ S1[i:i + 3] for i in range(len(S1)) ] count = 0 for ngram in ngrams: count += S2.count(ngram) return count / max(len(S1), len(S2)) a = compare('стол', 'стул') print(str(a))
32fb7abd131562a992181b0fb4984e32e3b56fbe
crisdata/Proyecto-Agenda
/contacts.py
6,704
3.6875
4
# -*- coding: utf-8 -*- import os import csv # Clases class Contacto: def __init__(self, nombre, telefono, email): # variables inicializadas en publicas self.nombre = nombre self.telefono = telefono self.email = email class Agenda: def __init__(self): # Guarda una v...
ef0a97be6c731097640016f271ec139fdb565087
chenxy3791/leetcode
/No0543-diameter-of-binary-tree.py
3,584
4.28125
4
""" Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Example: Given a binary tree 1 / \ 2 3 / \ ...
441b927481354faf54b2a7b163e49c9ccd7e756b
pnkumar9/linkedinQuestions
/smallestMissingInt.py
358
3.671875
4
#!/usr/local/bin/python3 #Given an array of ints, #return the smallest positive integer that doesn't appear in the list #A = [ 1, 13, 3, 4, 7 ] A = [ 1, 2, 3 ] #A = [ -1, -3 ] #A = [ 1, 3, 6, 4, 1, 2 ] A.sort() i=1 false=0 true=1 while (i <= len(A)+1): found=false for val in A: if(i==val): found=true if (fo...
6ba69e65d6a2f5fdb6f081b0f0f26957e786289d
plzprayme/study-python-algorithm-interview
/ch7_sequential/q1.py
501
3.671875
4
test_cases = [ dict(nums=[2,7,11,15], target=9), ] def main(test_case): nums = test_case["nums"] target = test_case["target"] for idx, num in enumerate(nums): for idx2, num2 in enumerate(nums[idx+1:]): if num + num2 == target: return idx, idx + idx2 + 1 return...
d2b0faddef8801724de6bc9aace4bdea074ce16b
rakaar/algo-ds-notes
/insertion_sort.py
1,092
4.03125
4
arr = [5,2,4,6,1,3] # insert sort for i in range(1, len(arr)): key = arr[i] j = i - 1 # the idea is to keep pushing the key inside the sorted array till it finds it proper place while j >=0 and arr[j] > key: arr[j], arr[j+1] = key, arr[j] j -= 1 print(arr) # optimised insertio...
7580f441c2898f9de3b492b8a3ef0e2900eca26c
ivenpoker/Python-Projects
/Projects/Project 0/Strings/string-validators.py
1,442
4.34375
4
#!/usr/bin/env python3 """ Program purpose: Validates characters in the string. Program Author : Happi Yvan Author email : ivensteinpoker@gmail.com """ def process(_str): print("\n\tIs there any alphanumeric character: ", end="") if any(c.isalnum() for c in _str): print("Tr...
6e4fd97f950e1e19d04cdbbfc11a04adc119a098
DHRUVSAHARAN/python-
/ch 5/practice_6.py
327
3.5
4
favlang = {} a = input("enter your favorite lang srishti :\n") b = input("enter your favorite lang shivan :\n") c = input("enter your favorite lang aarav :\n") d = input("enter your favorite lang dawik :\n") favlang [ "srishti"] = a favlang [ "shivan"] =b favlang [ "aarav"]=c favlang [ "dawik "]=d print (fav...
a30685ea83282f07eb0047349e1fad35d3253298
salaschen/ACM
/Leetcode/2144_MinCostBuyCandies/sol.py
582
3.921875
4
''' Prob: 2144 - Easy Author: Ruowei Chen Date: 26/Feb/2022 ''' class Solution: def minimumCost(self, cost: [int]) -> int: cost = sorted(cost, reverse=True) result = 0 clen = len(cost) i = 0 # at least three candies left in the loop while i < (clen-2): re...
9bf429830641604a4fc1706980b3fe92f9a8dc24
alexandraback/datacollection
/solutions_2645486_0/Python/rishig/b.py
825
3.59375
4
from library import * from itertools import * # given pairs return the key corresponding to the greatest value def argmax(pairs): return max(pairs, key= lambda x: x[1])[0] # given values return the index of the greatest value def argmax_index(values): return argmax(enumerate(values)) def recstep(start, end, E...
446db15c854e44602a5aa9f0964f99be20fe5d25
IvanWoo/coding-interview-questions
/puzzles/number_of_boomerangs.py
1,450
3.890625
4
# https://leetcode.com/problems/number-of-boomerangs/ """ You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Return the number of b...
27fa308137938aeea83c4d6a35579083a37e07d9
kanglicheng/CodeBreakersCode
/mixed bag/day3/81. Search in Rotated Sorted Array II (can't move left or right when a[l] == a[mid] or a[r] == a[mid]).py
2,060
3.53125
4
# can't make decision when a[l] == a[mid] or a[r] == a[mid] class Solution: def search(self, a: List[int], tgt: int) -> bool: def bSearch(a, tgt, l, r): if l == r: return a[l] == tgt if l == r - 1: retu...
2d82271d0d48bc98dd6e0478c7c128c107dd44eb
tgandor/meats
/toys/math/geometry.py
1,971
3.625
4
from math import * # conventions: # 2D point: (x, y) tuple # 2D line: (A, B, C) tuple, Ax + By + C == 0 # 2D circle: (x0, y0, R), hypot(x-x0, y-y0) == R def bisector(a, b): """2D line equidistant to points 'a' and 'b'.""" return (2*(b[0]-a[0]), 2*(b[1]-a[1]), a[0]*a[0] + a[1]*a[1] - b[0]*b[0] - b[1]*b[1]) d...
982d4ee3e3ff25862deee3a0ec7b7da4e7d6e9b1
Aasthaengg/IBMdataset
/Python_codes/p00005/s277840971.py
225
3.65625
4
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) while True: try: a, b = map(int, input().split()) print(int(gcd(a, b)), int(lcm(a, b))) except EOFError: break
37c071adff0c60b9dfe3e7d35012a1fb1d628214
sxlongwork/pythonPro
/if-for-while/for.py
676
4.28125
4
# for 使用 # for循环遍历一个对象(比如数据序列,字符串,列表,元组等),根据遍历的个数来确定循环次数。 for i in range(5): print(i, end=" ") print() for i in range(3, 10): print(i,end=" ") print() for i in range(1, 20, 2): print(i, end=" ") print() for i in range(20, 0, -2): print(i, end=" ") print() name = input("pls type your name:") for i ...
2192fead97f4c769321bf8efe2c5cdba09ece4c4
hellux/tddd86-kattis
/bachetsgame/bach_test.py
361
3.5
4
def show_wins(stones, M): wins = [False for _ in range(stones)] for i in range(1, stones): for m in M: index = i - m if index >= 0 and not wins[index]: wins[i] = True break for i in range(1, stones): print("+" if wins[i] else "_", end...
df929df7785e84a2c93cce38c0c250b005d6bfdd
Dorkond/stepik-python-course
/Module 1/1.12.2.py
524
4.125
4
''' Задача 2 Напишите программу, принимающую на вход целое число, которая выводит True, если переданное значение попадает в интервал (−15,12]∪(14,17)∪[19,+∞) и False в противном случае (регистр символов имеет значение). ''' num = int(input()) if -15 < num <= 12 or 14 < num < 17: print('True') elif num >= 1...
a17852f89fa1db2689547ec90e67428118a63289
rasel06/python
/sorting.py
222
4.1875
4
#Input like # mango,banana,lichi,malta,grape,orrange,coconut input_string = input("Enter enter fruits list (, seperated value)= ") words = input_string.split(",") words.sort() for item in reversed(words): print(item)
62643bdba2ca151c771ba3f790909c54ca6babff
tomjingang/data-science
/Chapter 2 custom visualization hard.py
4,914
3.84375
4
# A challenge that users face is that, for a given y-axis value (e.g. 42,000), # it is difficult to know which x-axis values are most likely to be representative, # because the confidence levels overlap and their distributions are different # (the lengths of the confidence interval bars are unequal). One of the s...
0530cad68dc4e62256619ff831f59237787ff524
chengming-1/python-Basic
/proj01.py
897
4.15625
4
########################################################### # Computer Project #1 # # Algorithm # input te rod # convert rod from string to float # convert the rod to other measurement by divied coefficient # output the measurement by different cofficient #######...
4fccc07533869dc9b90fd1036197c4ebd205987e
demo112/1807
/python/Myself_Note/note/sleep.py
242
3.78125
4
from time import sleep # # def myfn(n): # while n > 0: # print("hello world") # sleep(1) # n -= 1 # # myfn(6) def myfn(n): if n > 0: print("hello world") sleep(1) myfn(n - 1) myfn(3)
2a2f38ec62547698a28cff549e06a123dc2590f2
haha479/Interview_questions
/02-使用nonlocal修改变量.py
147
3.5625
4
def func(*args): ax = 0 def func_in(): nonlocal ax for n in args: ax = ax + n return ax return func_in a = func(1,2,3,4) print(a())
2830233a21c51cbc30dbf8cf35fead7c27ecd69f
Nkaka23dev/data-structure-python
/maricar2.py
1,233
3.75
4
# # returning a friend when characters are equals to 4 # def friend(arr): # return [char for char in arr if len(list(char))==4] # arr=["Ryan", "Kieran", "Jason", "Yous"] # print(friend(arr)) # # python programm to make a phone number from a list of numbers # arr=[1,2,3,4,5,6,7,8,9,0] # str_=[str(n) for n in ...
97dd767cabef8028704b339edc9454821a912561
fucci/HelloWorld3
/fred.py
164
3.84375
4
a = 20 b= 10 for i in range(1, 10,1): b=b+i a=a*i print ('a='+str(a)) print ('b='+str(b)) b=b+i print ('i='+str(i)) print "this is the end"
dba1a9f2aa0f9796e685b5576805d57ddfadfa98
Hari2019041/Fun-Scripts
/Maths/impossible_squares.py
499
3.828125
4
N = 10**3 SQUARES = {int(i * i) for i in range(N + 1)} def find_possible(n): if n in SQUARES: return f'{n}' for square in SQUARES: if n - square in SQUARES: return f'{square} + {n-square}' return '' impossible_squares = [] possible_squares = {} for i in range(1, N + 1): ...
0caeca0265e90d0b8742de253da3006e68546f1e
jrbublitz/Aulas-python
/exercicios/4 - ExercicioLoops.py
1,387
3.859375
4
# # primeiraFase = [5, 9, 3, 5, 2, 1, 6, 3] # segundaFase = [] # final = [] # # def CalcularFase(Fase, proximaFase): # if (len(Fase) != 2): # for i in range(0, len(Fase), 2): # if Fase[i] != Fase[i + 1]: # maior = max(Fase[i], Fase[i + 1]) # proximaFase.append(mai...
4efa06d667375ff7918dcf9cbbdc4220db5acd2a
jaisinghchouhan/Forsks
/Day2/bricks.py
401
4.1875
4
def bricks(small,big,total): if small+big*5>=total: if total%5<=small: return True else: return False else: return False small=int(input("enter total number of one intch of brick")) large=int(input("enter the number of 5 intch of brick")) total=int(input...
7023c32df9c562c373ae29dbd799ba736d0ab67f
Elita1114/POS-Tagging-with-Gibbs-Sampling
/non_negative_counter.py
536
3.53125
4
import numpy as _np from collections import Counter as _Counter class NonNegativeCounter(_Counter): """This class is a Counter sub-class that only accepts non-negative integers as values.""" def __setitem__(self, key, value): if type(value) not in {int, _np.int}: raise TypeError("T...
03cb02f8a9737407d7889e1ddadbb34d222b80d0
rockboynton/blind75
/maxprofit.py
565
3.578125
4
def maxProfit(self, prices: List[int]) -> int: # min_price = float('inf') # max_profit = 0 # for price in prices: # min_price = min(min_price, price) # profit = price - min_price # max_profit = max(max_profit, profit) # return max_profit min_price = flo...
c72b9bc9e59a50537a3da949e91dacb396ebb91d
hoomanvhd/inf8007
/test_text.py
2,672
3.828125
4
from unittest import TestCase, main from td1 import Text class TestText(TestCase): sentences = ( 'The cat sat on the mat.', 'This sentence, taken as a reading passage unto itself, is being used to prove a point.', 'The Australian platypus is seemingly a hybrid of a mammal and reptilian cre...
a6f40c5d750cefae142fdeae01efc674a5c36d77
freddywilliam/Python_Intermedio
/list_and_dict.py
528
3.609375
4
def run(): my_list = [1, 'HELLO', True, 4.5] my_dict = {'firstname' : 'William', 'lastname' : 'Martinez'} super_list = [ {'firstname' : 'William', 'lastname' : 'Martinez'}, {'firstname' : 'Freddy', 'lastname' : 'Martinez'}, ] super_dict = { 'natural_nums': [1,2,3,4,5,7]...
947b94f4a72c11a408e3c76ed88028a6a39672de
v-crn/nlp-100-fungoes
/01_Warming-up/03_count_length_of_each_word.py
528
4.4375
4
import re def count_length_of_each_word(sentence): regex = re.compile(r'[a-zA-z]+') return [len(s) for s in regex.findall(sentence)] def main(): print('Test 1:') sentence = 'Now I need a drink, alcoholic of course, \ after the heavy lectures involving quantum mechanics.' print(count_leng...
bd5acde3ef6424e022cedcae262a1ea2c3ae7138
qlhai/Algorithms
/程序员面试金典/01.01.py
705
3.828125
4
"""" 面试题 01.01. 判定字符是否唯一 实现一个算法,确定一个字符串 s 的所有字符是否全都不同。 示例 1: 输入: s = "leetcode" 输出: false 示例 2: 输入: s = "abc" 输出: true 限制: 0 <= len(s) <= 100 如果你不使用额外的数据结构,会很加分。 """ class Solution: def isUnique(self, astr: str) -> bool: mask = 0 for char in astr: move_bit = ord(char) - ord('a') ...
4e2a6bc69cd14dba5becbc658b07f951096ad80b
pangruitao/nt_py
/day08/exercise.py
707
3.671875
4
# 购物车功能要求: # 要求用户输入总资产,例如: 2000 # 显示商品列表,让用户根据序号选择商品,加入购物车 # 购买,如果商品总额大于总资产,提示账户余额不足,否则,购买成功。 # goods = [ # {"name":"电脑","price":1999}, # {"name":"鼠标","price":10}, # {"name":"游艇","price":20}, # {"name":"美女","price":98}, a = int(input('请输入总资产:')) D={} m=0 c=0 goods=[] while True: n=str(input('商品:')) p=str(input...
42ae0635cdce32c324564a31c8abdb9734546af3
shireen-nazneen/loops
/prime_num_loop.py
204
4.09375
4
num=int(input("enter your number_--")) counter=0 i=1 while i<=num: if num%i==0: counter+=1 i=i+1 if counter==2: print(num,"is prime number") else: print(num, 'is not prime number')
cfe3c685c0f032ca26135917ce57e054ce73c77f
Ritvik19/CodeBook
/data/Algorithms/Insertion Sort.py
353
4.1875
4
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 if __name__ == "__main__": arr = [64, 34, 25, 12, 22, 11, 90] insertionSort(arr) print("So...
15971f6473413a2ead2eab772fc9b8e1b13ab100
shenqiti/leetcode
/1.Two_sum.py
877
3.921875
4
''' 1.Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. ________________________________________ Example: Given nums = [2, 7, 11, 15], target = 9, Because ...
b601dc5a216aeb15da23c0c876ec23a9f7b5a4f9
sebnorth/flask-python-coursera
/app/static/module4_project.py
5,456
3.984375
4
def make_dict(keys, default_value): """ Creates a new dictionary with the specified keys and default value. Arguments: keys -- A list of keys to be included in the returned dictionary. default_value -- The initial mapping value for each key. Returns: A dictionary where every key i...
0aac3665460994edded34f9e42c4f2329f91ec82
sametatabasch/Python_Ders
/ders15.py
352
3.765625
4
def selamla(): """Merhaba mesajını yazdırır""" print("Merhaba") #selamla() def selamla1(isim): print("Merhaba", isim) #selamla1("sdfgh") def selamla2(isim): return "Merhaba " + isim def topla(s1,s2): return s1+s2 print(selamla2("Ahmet"),topla(5,6)) sonuc= 5*2+topla(7,9) print(sonuc) print...
167c6c98c8f7673fe3b1d42918433a35e1c17054
anishst/Learn
/Programming/Python/functions_practice/lambda_functions.py
840
4.5
4
# lambdas are functions without name # alwasy used to return values; not for actions # example 1 def add(x,y): return x+y print(add(5,3)) # giving name to lambda result = lambda x, y: x+y print(result(5,3)) # example 2 def double(x): return x *2 # using list comprehension sequence = [1,5, 3,2] doubled = [doub...
77cff494f4f46458f5972d21cc2beb9c979d1468
landeholt/tilda
/skeleton-code/binary_search_tree.py
2,378
3.984375
4
# Author: John Landeholt [TA] class Node: def __init__(self, data): self.right = None self.left = None self.data = data # "greather than" magic_method def __gt__(self, other): """Dictates whether self or other is greather""" # YOUR CODE HERE return None ...
1828a7b827b39231d837ee270353af3d3e347377
Broadan26/Project-Euler
/Euler3/euler3.py
2,678
3.953125
4
import math def Euler3BruteForce1(size): #Horribly inefficient brute force largest_factor = -1 i = 2 while (i < size): #Check all values below the number if (size % i) == 0: #Found a divisor is_prime = True j = 2 while (j < i): if...
12f63a3776cc94f8199d79d28dad90468e89d430
sreejitaghosh/Travel-Book--Python
/Fetch_Distance.py
501
3.5
4
from math import radians ,sin, cos, sqrt, atan2 def Fetch_Distance(Lat1,Lon1,Lat2,Lon2): Radius_Of_Earth = 6373 Diff_Lat = radians(Lat2 - Lat1) Diff_Lon = radians(Lon2 - Lon1) SubCalculation = (sin(Diff_Lat/2)*sin(Diff_Lat/2)) + cos(radians(Lat1)) * cos(radians(Lat2)) * (sin(Diff_Lon/2)*sin(Diff_Lon/2)...
7734bdc1b5ec4f5a5146e80db2970507df245bca
nekoTheShadow/atcoder-answers
/panasonic2020/c.py
184
3.65625
4
import decimal a, b, c = map(int, input().split()) if decimal.Decimal(a).sqrt() + decimal.Decimal(b).sqrt() < decimal.Decimal(c).sqrt(): print('Yes') else: print('No')
d74be0cbf4e6db7507b28042678dc0c3ff0e3283
mohitsharma2/Python
/icccricket_sqlite.py
2,059
3.90625
4
""" Code Challenge Name: Webscrapping ICC Cricket Page Filename: icccricket.py Problem Statement: Write a Python code to Scrap data from ICC Ranking's page and get the ranking table for ODI's (Men). Create a DataFrame using pandas to store the information. Hint: https://www.icc-cric...
c0046dd18609db4215dabfae58829937ce33b296
arxrean/ML-Algorithm-Implementation
/knn.py
1,764
3.53125
4
# https://towardsdatascience.com/machine-learning-basics-with-the-k-nearest-neighbors-algorithm-6a6e71d01761 from collections import Counter import math reg_data = [ [65.75, 112.99], [71.52, 136.49], [69.40, 153.03], [68.22, 142.34], [67.79, 144.30], [68.70, 123.30], [69.80, 141.49], [7...
b8c0683e5f1c67ef31794e6db3bd3cb20a7e207a
Vicklan/Classes
/animals.py
487
3.90625
4
class Animals: def __init__(self, name, weight, height, food): self.name = name self.weight = weight self.height = height self.food = food def getFood (self): return self.__food def setFood(self,food): self.__food = food class Birds(Animals):...
7b4735b11c676f6bdca78d41f809c51200b7a7c5
FabianoJanisch/CursoEmVideo-Python
/Exercício 096.py
240
3.765625
4
def área(l, c): a = l*c print (f'A área do seu terreno {l}x{c} = {a}m²') print (30*'-') print ('Calculador da área'.center(30)) print (30*'-') l = float(input('Largura (m): ')) c = float(input('Comprimento (m): ')) área(l, c)
3b5455234bcb3a3f38785d65b5d00c0f073d0d58
RaymondZano/Initial-programs
/Mastermind version 2.py
3,612
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 23 23:38:43 2019 Version 2 of the Mastermind game This is a transition program to the final version. I used loop thru the dataframe to check the number of correct guess. Determining the currect color but incorrect place is challenging. Increased co...
97e57f74a57c5d2f610120ae0a593eacb081478e
JontySinai/hackerrank
/10_Days_Stats/day4_geom_dist_1.py
356
4.0625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import sys # inp = raw_input() inp = '1 3\n 5' inp = inp.split(' ') inp[1] = inp[1].replace('\n' ,'') num = float(inp[0]) den = float(inp[1]) p_def = num/den inspection = int(inp[2]) def geom_dist(n,p): return ((p-1)**(n-1))*p print ro...
56436e45be8c7486f58a5640f7ae2acb4c1ce5d1
devansh20la/Algorithms
/topinterview/flatten-nested-list-iterator.py
1,635
4.09375
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger: # def isInteger(self) -> bool: # """ # @return True if this NestedInteger holds a single integer, rather than a nested list. # """...
05de53faace4960e88f76fbe9c3d7020a1a1f737
yarduoc/L-Systems
/Environment-sensitive/Growth_Modifier.py
4,337
3.578125
4
## Growth_Modifier_Volume Objects """ Defines volumes in a 3D space, associated with a function on Euclidian_Space_Vectors. """ import os os.chdir("C:\\GitHub\\L-Systems\\Environment-sensitive") from Euclidian_Space_Vector import * ## Abstract Volume class Growth_Modifier_Volume : """ Growth_Modifier...
fbb6bb45204d87e29b99e91aa82128a49b000444
RoanPaulS/Whileloop_Python
/num_divby_3.py
262
4.09375
4
first = 1; last = 100; while(first <= last): if(first%3==0): print(first); first = first+1; """ without using if condition first = 3; last = 100; while(first <= last): print(first); first = first +3; """
0b5d47eec4174325920c9454a19996b7e18537dd
AshDagot/python_lessons
/lesson1.py
4,368
3.953125
4
# 1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько # чисел и строк и сохраните в переменные, выведите на экран. # 2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате # чч:мм:сс. Используйте форматирование строк. ...
e560e1a1f6f4797e6cffa979cc66b6879c740bf0
shubhangsrikoti/lab1-python
/main.py
582
4.28125
4
## Author Shubhang Srikoti svs6959@psu.edu ## Collaborator Zihan Xia zfx5078@psu.edu ## Collaborator Xinyi Yang xvy5166@psu.edu ## Collaborator Lynn Francis jtf5383@psu.edu temp = float(input("Enter temperature: ")) unit = input("Enter unit in F/f or C/c: ") if unit == "F" or unit == "f": newCelsius = ((temp - 32) ...
eef0aeff189ebfda11809665b38a64f59e084612
0neir0s/ctci
/1-arrays-strings/1.3.py
181
3.875
4
def permutation(s1,s2): """Given two strings, decide if one is a permutation of the other""" if len(s1) != len(s2): return False return sorted(s1) == sorted(s2)
062663954a0689537bfd4b0671ddd17d260375c8
Lazy-coder-Hemlock/Leet_Code-Solutions
/988. Smallest String Starting From Leaf.py
723
3.765625
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 Solution: def smallestFromLeaf(self, root: TreeNode) -> str: if root is None: return "" de...
50b346c924470dda87b5ae62c36488361b4d2a61
Manis99803/advance_calendar
/calendar/month_calendar.py
1,964
4.1875
4
""" file which deals with generating month calendar """ import calendar class MonthCalendar: """ displays the full calendar """ def __init__(self, today_date): """ constructor for initializng the necessary items for full calendar class """ self.today_date = t...
61e65e37b64a6ab8f3de8202d7ca61a7d857e812
agyen/glcd
/advanced_python/fold.py
150
3.890625
4
def join_string(): words = ["hey", "how", "are", "you", "doing"] return ("" + words) words_joined = join_string() print( " " + words_joined)
238f75b271d0b78f7e3a989ca33a7f0b4ea0eb6a
coreyarch1234/leetcode-problems
/leetcode/random_pick_index.py
443
4.0625
4
import random def pick(target, nums): """ :type target: int :rtype: int """ len_nums = len(nums) found = False while found == False: random_indices = [] for num in nums: random_indices.append(random.randint(0, len_nums - 1)) for index in random_indices: ...
f65971306c8f0fe9407ea30d50065bf23fdcca36
mne-tools/mne-tools.github.io
/0.21/_downloads/b8b52271197f52c0aa9d972bdb70f36c/plot_3d_to_2d.py
4,910
3.65625
4
""" .. _ex-electrode-pos-2d: ==================================================== How to convert 3D electrode positions to a 2D image. ==================================================== Sometimes we want to convert a 3D representation of electrodes into a 2D image. For example, if we are using electrocorticography ...
d74f515852e4146e324f4d719476f8c2e6a2af3e
Azerlund6214/Python-Semantic-Analysis-for-NNetwork
/FUNC/TEXT/_3_get_list_words_no_small.py
421
4.15625
4
# 01.dec.17 20.29 def GET_LIST_WORDS_NO_SMALL( list_of_words , MAX_LEN_OF_SMALL_WORD ): # MAX_LEN_OF_SMALL_WORD = 3 final_list_lists = [] for one_word in list_of_words: if len(one_word) <= MAX_LEN_OF_SMALL_WORD: continue ...
b74ee0c8f0c7ab909600d8f15cb104351a9a0aaf
Monzillaa/practices-python
/lists.py
1,280
4.21875
4
demo_list = [1, 'hello', 1.34, True, [1,2,3]] colors = ['red', 'red', 'red', 'green', 'blue'] ##Definimos las listas a travez de un constroctor o funcion llamado list numbers_list = list((1,2,3,4)) print(numbers_list) #print(type(numbers_list)) #r = list(range(1, 10)) #print(r) #print(dir(colors)) #print(len(demo_lis...
47f0e2d3a7ccbdf4ee7d765c3761e0d29912bf74
sirvolt/Avaliacao1
/questao14.py
315
3.578125
4
def contaEV(): frase=str(input('Frase: ')) i=0 x=0 while i<len(frase): if frase[i]==' ': x=x+1 i=i+1 print('Espacos: %d'%(x)) i=0 x=0 while i<len(frase): if frase[i]=='a' or frase[i]=='e' or frase[i]=='i' or frase[i]=='o' or frase[i]=='u': x=x+1 i=i+1 print('Vogais: %d'%(x))
edff72b178255bcd926cab683a257610bd70ca56
eugenepark1/py2
/interview/basic/palin.py
1,435
4
4
''' Created on Aug 31, 2017 @author: eugene when there is an inner and outer loop, ask if you need to shoten the inner loop (i.e. possible palins) ''' # 1st inner-outer loop # 2nd is have all the palins in dictionary and search against it o(1) # cigar tragic # palin means reveserd is the same def is_pa...
dbeed1ea7490ee00fa842ca55d7caa757f61bf69
zchaoking/gsplinets
/gsplinets_tf/group/SE2.py
7,335
3.65625
4
# Class implementation of the Lie group SE(2) import tensorflow as tf import numpy as np # Rules for setting up a group class: # A group element is always stored as a 1D vector, even if the elements consist # only of a scalar (in which case the element is a list of length 1). Here we # also assume that you can parame...
820e8fbea5b01f6fa436d83cbe969973bfbd5751
hefengxian/python-playground
/learn/slice/advanced_slice.py
3,628
4
4
""" 深入理解 slice 切片操作 """ lst = list(range(10)) # X >= len(list) 时如下的切片都表示完整的 list(没有截取) X = len(lst) print(lst == lst[0:X]) # True print(lst == lst[0:]) # True print(lst == lst[:X]) # True print(lst == lst[:]) # True print(lst == lst[::]) # True print(lst == lst[-X:X]) # True print(lst == lst[-X:]) # True prin...
7c9dcb84f33118685cab06a8878af486422bbc78
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4008/codes/1745_3088.py
174
3.9375
4
num = (int(input("digite um nume: "))) par = 0 impar = 0 cont = 0 while(num!=0): if(num%2): par = par + 1 cont = num + 1 else:(num%1): impar = impar + 1 cont = num
7311ac2d265d2256cafb99b7bc96cb3ec0001e36
thierrydecker/ipi-pyt010
/files-manipulation.py
2,333
3.875
4
#!/usr/bin/python # -*- coding= utf-8 -*- # Imports de la biblithèque standard # # # Imports des bibliothèques tierces # # # Internal functions # # # main() function # # # Open a file # def file_open(file_name, rights): # Rights : 'r' -> read # 'w' -> write # 'a' -> append file_...
126a550d60ea0e596d741ffbf5be43e1928dba71
guipw2/python_exercicios
/ex050.py
282
3.640625
4
soma = 0 cont = 0 conta = 0 for c in range(1, 7): num = int(input('Digite um valor:')) conta += 1 if num % 2 == 0: soma += num cont += 1 print('Você me informou {} números dos quais {} era(m) par(es) e a soma dele(s) foi {}'.format(conta, cont, soma))
ab5da6baa1da81b80bd60684eb1bf0d978f40285
nadeendames96/Web-Application-By-Python
/partical_assignments/PA1_NadeenDames/prob3.py
628
3.84375
4
# # Prob 3 # # Mars Rover x=0 y=0 # Define Tuple and add x,y to position variable position=() print("Enter dicoration and value of dicoration : ") dic=" " dic_value=" " for i in range(1,7): dic,dic_value=input().split() #dic_value=int(input()) if(dic=="U"): y+=int(dic_value) position=(...
fb911ac3d63e60b1dc186b01bd32542366040642
WasimAlgahlani/Instagram-Followers-Game
/main.py
1,003
4
4
"""Guess the number program""" import random from game_data import data def check(guess_f, account_a_f, account_b_f): if account_a_f['follower_count'] > account_b_f['follower_count']: return "a" else: return "b" con = True score = 0 account_a = random.choice(data) while con: ...
439ab46484d99efb052575eb9be269d32a5eabf7
janak11111/Data-Structure-With-Python
/Searching/BinarySearch.py
473
3.640625
4
pos = -1 def Search(list,n): l = 0 u = len(list)-1 while l <= u: mid = (l+u)//2 if list[mid] == n: globals()['pos'] = mid return True else: if list[mid] < n: l = mid+1 else: u = mid-1 ...