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
677e655456d9930f10af53915d188447859b4bfa
Lugulabre/projet_structure
/acces_code/point.py
1,144
3.53125
4
from vector import Vector3 import traceback class Point(): """Description""" nb_points = 0 def __init__(self, X, Y, Z): self.position = Vector3(X=X, Y=Y, Z=Z) Point.nb_points += 1 self.num_point = Point.nb_points self.voisins = [] self.occuped = False pass ...
f698b2e835bfbcb468e997b389b0d4b17d5a8f78
joelb-2011/Tarea1_Semana1_Estructura
/Ejemplo12.py
526
3.90625
4
class Ejemplo12: def __init__(self): pass def Whilenum(self): suma, prod, num = 0, 0, 0 suma = 0 prod = 1 num = int(input("Ingrese un numero: ")) while (num > 0): suma = suma + num prod = prod * num num = int(in...
9cd010892e3c50589e2e0fde9ec9f074367792e3
iconoeugen/swe
/structs/binary_tree.py
3,239
3.953125
4
class Node(): def __init__(self, data = None): self.data = data self.left = None self.right = None # Get tree height def get_tree_height_helper(root, max_height_diff = -1): height = 0 if root == None: return -1 height_left = height if root.left != None: h...
510f7d29e2e27add2866264dfd2541dba7c25c33
iconoeugen/swe
/sorting/quick.py
1,117
4.09375
4
#!/bin/python # Quick sort - unstable sorting algorithm (might change the occurrence of two similar elements in the list while sorting) # # Time complexity: # Big-O: O(n^2) # Big-omega: O(n * log n) # Big-theta: O(n * log n) # # Space complexity: # O(n * log n) def partition(list, start, end): # index ...
2cdf3ee23e4db1ec39810a47d712c50e4cf479ba
iconoeugen/swe
/sorting/select.py
810
4.3125
4
#!/usr/bin/python """Selection sort Time complexity: Big-Oh: O(n^2) Big-Omega: O(n^2) Big-Theta: O(n^2) Space complexity: O(1) """ def sort(list): l = len(list) steps = 0 for i in range(0, l-1): min_idx = i for j in range(i+1, l): if list[min_idx] > list[j]...
12cb04c632d16225961d5c466e49d7ec10c0c1a6
mtbottle/mts_project_euler_exercises
/ex9.py
563
4.34375
4
# -*- coding: utf-8 -*- from math import * #A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, #a^(2) + b^(2) = c^(2) #For example, 3^(2) + 4^(2) = 9 + 16 = 25 = 5^(2). #There exists exactly one Pythagorean triplet for which a + b + c = 1000. #Find the product abc. if __name__ == "__mai...
fb5cff97de32c0ffaa40c0e23da8ebd23e48a783
mtbottle/mts_project_euler_exercises
/ex2.py
450
3.5
4
# -*- coding: utf-8 -*- #Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #Find the sum of all the even-valued terms in the sequence which do not exceed four million. sum = 2 frst = 1 ...
948bb0d93256879d168e232c6473a8c773ec7417
mzietara/CPU-Games
/minimax.py
5,881
3.859375
4
# tools for minimax def _switch_rate(r): '''Return opposing players rating corresponding to r.''' return r * -1 # one's loss is the other's gain def include_better_move(L, ply): '''L is a list of tuples that have the first element being the move, and the second element is the predicted score of that ...
f18c87a0d2873ab60f5e9f4d6c32839494f7112c
mzietara/CPU-Games
/game_tree.py
4,278
3.84375
4
# some utilities to explore game trees import minimax import copy class GameStateNode(object): """Represent a GameState with possible links to successors. """ def __init__(self, game_state): """Create a node to represent game_state. Arguments: game_state: A GameState i...
3802533230f204bc89dfd0c6f0884c8c9e7d4351
ciaocamilo/ejemplos-python
/list_com3.py
612
3.828125
4
# mi_lista = [] # for x in range(4, 31, 2): # if x%3 == 0: # mi_lista.append(x**2) # print(mi_lista) # mi_diccionario = dict() # for y in range(3, 11): # mi_diccionario[(y, y**3)] = [] # for x in range(4, 31, 2): # if x%y == 0: # mi_diccionario[(y, y**3)].append(x**2) # mi_d...
1d63d6434cdcacf5cbde78f8be2dbfc2799362d9
ciaocamilo/ejemplos-python
/condicionales1.py
1,426
4.4375
4
numero = 57 # if numero > 0: # print("El número es positivo") # else: # if numero < 0: # print("El número es negativo") # else: # if numero == 0: # print("El numero es cero") # if numero > 0: # print("El número es positivo") # elif numero < 0: # print("El número es nega...
f3714c6174738ba9976489c5ad6676dcb000bc69
ciaocamilo/ejemplos-python
/parad_func3.py
2,953
3.96875
4
def suma (val1 = 0, val2 = 0): return val1 + val2 # def resta (val1 = 0, val2 = 0): # return val1 - val2 # def multiplicacion (val1 = 0, val2 = 0): # return val1 * val2 # def operacion (funcion, val1 = 0, val2 = 0): # return funcion(val1, val2) # # funcion_suma = suma # # funcion_resta = resta # re...
b6ce3ac2e828d8858a6e16c8ecce0dcce2a02d10
ciaocamilo/ejemplos-python
/variables2.py
1,038
3.921875
4
# var1 = 1.94587 # print(var1) # var1 = int(var1) # print(var1) # print(round(var1, 2)) # var1 = 120 # var2 = var1 # print(var2) # var1 = 120 # var2 = 200 # print(var1) # print(var2) # var1 = var2 = var3 = 200 # print(var1) # print(var2) # print(var3) # int - entero # float - decimal # str - cadena de caracteres...
5cd74be86f21b356fe5b5fb24308e8904dbfc30d
ShashankGinjpalli/Docket
/Docket.py
4,968
4.3125
4
#Shashank Ginjpalli # Creating a List for the Agenda and the Calendar todo = [] calendar = [] # function used to def mainMenu(): print("\n") print("1: Todolist Menu") print("2: Calendar Menu") print("3: Exit the Program") userInput = int(input("Please enter which Menu you would like to access: "...
43c22ee37b9abe433fbac8b3f0680db77d993593
fordzii/60021346
/inclassroom/Ex.py
3,480
3.515625
4
#1. ให้เขียนโปรแกรมเพื่อรับค่าตัวเลข 3 จำนวนจากนั้นให้หาค่าที่มีค่าน้อยที่สุดในสามจำนวนนั้น ''' a = int(input()) b = int(input()) c = int(input()) abc = [a,b,c] print(min(abc))''' #2. ให้เขียนโปรแกรมเพื่อรับค่าตัวเลขจำนวนเต็ม ไปเรื่อยๆ จนกว่าผู้ใช้จะผู้ใช้จะพิมพ์ค่า 0 จากนั้นให้แสดงผลรวมของเลขจำนวนที่ผู้ใช้พิมพ์ ''' a ...
8b4ff80835a585d6d6073ea3abe4ae85c7baeed5
cs-fullstack-2019-spring/python-loops-cw-LilPrice-Code
/Classwork.py
1,214
3.875
4
def main(): # exer1() # exer2() # exer3() # exer4() Fuzz() def exer1(): i = -20 while i <= 50: print(i) i+=1 def exer2(): n = 0 while n <=20: print(n) n += 2 def exer3(): num1 = int(input("Enter 1st number ")) num2 = int(input("Enter 2nd...
7911d9f26d2bef644b68dd80f1ed78471b2f5314
ljhopkins/INF108
/Assignment 6 Finished.py
3,576
4.03125
4
#1. #An IDE usually has the ability to write code, compile, and debug (more specialized) while a notebook is more broad and usually just involves writing the code. #Colab is a notebook and Spyder is an IDE. I prefer Colab because I find it more easy to navigate since it's cleaner/less cluttered than Spyder. #2. ...
c069754f58e576e01efcc7e620a154bfc79fd358
ramon-ortega/codigo-python
/CodigoDePractica/CodigoPython/strings.py
283
3.984375
4
name='Ramon' age = 25 age=str(age) print('Hello, my name is ' + name + ' and I am ' + age) #Otra manera de hacerlo, argumentos por posicion #print('My name is {name} and I am {age}'.format(name=name, age=age)) #basicamente coloca los titulares. s='hola' print(s.capitalize())
9f574d8b2d828a1a8fb24e8c1b67e58216280c0a
ramon-ortega/codigo-python
/CodigoDePractica/CodigoPython/condicionales.py
1,157
4.1875
4
##x = input('escoge x: ') ##y = input('escoge y: ') ##if x > y: #print x, "es mas grande que", y ## print('{x} es mas grande que {y}'.format(x=x, y=y)) #otra forma de hacerlo es por posicion, example: print('{0} es mas grande que {1}'.format(x,y)) ##else: ## print y, "es mas grande que ", x ##print('-------...
fd71abb1efd4f3e8331d1907c6a865c1136e4b33
lunafi-dorian/blockchain-example
/user.py
2,616
3.953125
4
#!/usr/bin/python # -*- coding: utf-8 -*- import math class User(object): """ A user class that can send and receive money on a ledger """ def __init__(self, name, ledger): self._name = name self._credit = 0 # used to populate the first user self._ledger = ledger def send(self...
e0c552546a75f7badedb0dfb01dc15aeae9e24fc
Omega97/Learning-Python
/_B_Simple/Copy.py
1,275
4.25
4
""" The difference between assignation, shallow copy and deep copy """ from utils import title @title def no_copy(): """ no copy """ a = [['a', 'a'], ['a', 'a']] print('old a =', a) b = a b[0] = ['b'] b[1][0] = 'b' b[1][1] = 'b' print('new a =', a) print(' b =', ...
bc6f3bce8b7624732f64e415ac743ffa1ec7919d
Omega97/Learning-Python
/_C_Intermediate/partial.py
537
3.6875
4
"""Return a new partial object which when called will behave like func called with the positional arguments args and keyword arguments keywords""" from utils import title from functools import partial @title def example_1(): """demo""" def f(*args): print(args) partial(f, 1)(2, 3, 4) ...
b72bc03f797eec772ad9bbba5d6ef7d2e85e5f85
aabadg1/Nombre-y-telefono
/ejercicio_entregar_7.py
499
3.71875
4
datos= [] while True: nombre= input('Nombre:') if nombre == 'fin': break apellido1 = input('Primer apellido:') apellido2= input('Segundo apellido:') telefono= input('Telefono movil:') #CREAMOS UN DICCIONARIO linea= {} linea['Nombre'] = nombre linea['1er apellido'] = apellido1...
b915175d590183ec16154e7973ad7d51ee8d64dc
Briggzly/datatbases-assesment
/process.py
551
3.640625
4
# opens the file in python log_file = open("um-server-01.txt") # defining a function def sales_reports(log_file): # looping through each line of the file for line in log_file: # setting line = to the method that removes white spaces at the end of the string line = line.rstrip() # sett...
ff266ff66d3aa030d699c7266cab8ae2100e2b96
clara51/DataStructure
/3_存在重复元素.py
197
3.75
4
nums = [1,2,3,4,5,6,7,3,3,43,5,6,6] nums = [1,2,3,2] # 数组存在相同的 # print(len(set(nums))== len(nums)) res = 0 # 数组中唯一出现的数 for i in nums: res = res ^ i print(res)
0379685ffb9fa8d5b6ab5fa37f2c0ae1678de2ad
XVs32/LeetCode
/30_days_challenge/day_06/30_6_ver_sort.py
920
3.71875
4
class Solution: def groupAnagrams(self, strs): sort_map = {} ans_length = 0 ans = [] for string in strs: sorted_string = "" sorted_string = sorted_string.join(sorted(string)) if sorted_string not in ...
a03e2545843edc3663c26d0788c2968fbcde5fd6
XVs32/LeetCode
/30_days_challenge/day_08/30_8.py
698
3.8125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def middleNode(self, head): slow = ListNode(0,head) fast = ListNode(0,head) while True: slow = slow.next ...
e6ff04ddbbb8ac1c8d312cd5245776551afb042b
XVs32/LeetCode
/30_days_challenge/day_16/30_16.py
1,121
3.546875
4
class Solution: def checkValidString(self, s): left = 0 right = 0 uni = 0 for i in s: if i == "(": left += 1 elif i == ")": right += 1 if left + uni < right: return...
01fab564b20e0cf090e270496bf41c4763b475c4
JJDProjects/wiki_search_bot
/reddit/wikipedia.py
445
4.0625
4
''' wikipedia.py All functions related to wikipedia: Looking through comments and getting wikipedia URLs, using the URL to access wikipedia and get the summary of the article (first paragraph of the introduction) ''' def get_urls(comment: str) -> [str]: '''Looks through a reddit comment and returns a list of wiki...
073359ea63a444fa5b4cbb5e97744cc956df4ad3
zozulia-developer/battle-simulator-light-it-academy
/models/squad.py
2,442
3.734375
4
# -*- coding: utf-8 -*- """ Module for squad model This module demonstrates model of squad. """ from functools import reduce class Squad: """ Squads are consisted out of a number of units (soldiers or vehicles), that behave as a coherent group Args: type_unit (str): type of unit: vehicles or soldie...
b441cc2598b6467868cdf2d3c531eb93212cf4da
thomas-liao/python_prac
/LintC/BinarySearch and LogN algorithm/two_sum_series.py
1,518
3.734375
4
# 56, most basic two sum question O(n) speed and O(n) time # or if need to be sorted, can have O(n) space and O(logn) time # 注意,返回index跟返回value的做法是不一样的,返回index你没法sort然后用double pointer的方法来搞。 class Solution: """ @param numbers: An array of Integer @param target: target = numbers[index1] + numbers[index2] ...
100ab0cc74e0724fb12ee66d19b316cab821ffd0
thomas-liao/python_prac
/MultiProcessing_MultiThreading/multiprocessing_pool_prac.py
423
3.5
4
import multiprocessing as mp import time # if you use pool, your job function can have return.. def job(x): return x*x def multicore(): pool = mp.Pool(processes=2) res = pool.map(job, range(10)) res = pool.apply_async(job, (2,)) print(res.get()) multi_res = [pool.apply_async(job, (i,)) for i ...
a7c4c0d97e4f774985c38a44ae53d2bf09248364
DragosTeodoru/SD
/ps5 (1) (1).py
2,464
4
4
#Task 1 a=13 b=14 if (a+1)<=b: print("(a+1)<=b is true") elif a+1>=b: print("a+1>=b is true") elif a+1!=b: print ("a+1!=b is true") #Task 2 myage=str(input("How old are you? ")) print("Hi there, you are " + myage +" old.") #Task 3 number1 =int(input("Enter first number ")) number2 = int(in...
ff53db48710d1f32bd277e5be21342455081d63c
harshil2711/Healthy_Programmer
/Healthy_Programmer.py
2,870
4.09375
4
# Healthy Programmer # Pygame module to play audio # Time module to display time # Date time module to display date with time import time from pygame import mixer import datetime # These are initial time variable for water , eyes exercise and physical exercise. init_water = time.time() init_eyes = time.time() init_phy...
76f064d23a400bddad8fe8b11e2ccc6010c5c5a8
zaqwes8811/cpp-tricks
/edu/courses/my-cs/java_details/java_sort_selection_details/partioners/__init__.py
874
3.6875
4
# coding: utf-8 class Partitioner(object): @staticmethod def partition(array): """ Берем певый в качастве Pivot """ IDX_PIVOT = 0 # Возможно лучше выбрать последний # тогда будет проще работать с индексами pivot_value = array[IDX_PIVOT] i = 1 ...
f8985d70b1b0bce83298170600507af9c3fba06d
yumerov/codewars
/done/kyu-5/simple-pig-latin.py
430
3.96875
4
# https://www.codewars.com/kata/simple-pig-latin/train/python from unittest import TestCase def transform_word(word): return word[1:] + word[0] + "ay" if word.isalpha() else word def pig_it(text): return " ".join(list(map(transform_word, text.split(" ")))) test = TestCase() test.assertEqual(pig_it('Pig latin is c...
48232867740ed33e9c1a0d01f4dc13e29d7853cb
yumerov/codewars
/done/kyu-6/palindromization.py
1,768
3.953125
4
# https://www.codewars.com/kata/palindromization/train/python from unittest import TestCase def left(e, n): l = len(e) ll = n // 2 # left length h = e * (ll // l) # head t = e[:ll % l] return h + t def mid(e, n): l = len(e) ll = n // 2 i = (ll) % l return e[i] * (n % 2) def pa...
57c2da3eac36a8ca64e12e87ecb17f982c817c1a
yumerov/codewars
/todo/kyu-4/last-digits-of-n-power-n-equal-to-n.py
895
3.625
4
# https://www.codewars.com/kata/last-digits-of-n-2-equals-equals-n/train/python from unittest import TestCase def is_green(n): return str(n ** 2).endswith(str(n)) def green(n): i = 1 j = 1 while i <= n: while True: print(j) if is_green(j): break ...
17b501b77ece1e1d6c819a218a5f922bcf152fd5
yumerov/codewars
/done/kyu-4/next-bigger-number-with-the-same-digits.py
837
3.65625
4
# https://www.codewars.com/kata/next-bigger-number-with-the-same-digits/train/python def with_same_digits(n1, n2): return sorted(str(n1)) == sorted(str(n2)) def next_bigger(n): b = int("".join(sorted(str(n), reverse=True))) for i in xrange(n + 1, b + 1): if with_same_digits(i, b): ret...
8e90c76058295031e9c2931a7752e608fffbe9e3
yumerov/codewars
/todo/kyu-6/string-character-frequency.py
925
3.546875
4
# https://www.codewars.com/kata/string-character-frequency/train/python def solve(s): print(s) m = {x: s.count(x) for x in set(s)} l = len(m.keys()) if l == 1 or sum(m.values()) == l: return True vs = sorted(m.values()) if min(vs) == 1 and vs.count(1) == 1: return True ret...
0caa6ab876958efdb53faf6b7947fb4f517e483a
yumerov/codewars
/done/kyu-7/competitive-eating-scoreboard.py
2,038
3.765625
4
# https://www.codewars.com/kata/competitive-eating-scoreboard/train/python from unittest import TestCase def transform(who): score = who.get("chickenwings", 0) * 5 score += who.get("hamburgers", 0) * 3 score += who.get("hotdogs", 0) * 2 return { "name": who["name"], "score": score ...
017289a37448673a8d027e8654f6109403318a60
yumerov/codewars
/done/kyu-7/next-prime.py
637
3.71875
4
# https://www.codewars.com/kata/next-prime/train/python from unittest import TestCase def is_prime(n): if n == 1: return False upper_limit = int(n ** 0.5) + 1 for i in range(2, upper_limit): if n % i == 0: return False return True def nextPrime(n): while True: ...
9f2998567abe1559e35e46a9d377a7b1b982e62a
yumerov/codewars
/todo/kyu-5/master-your-primes-sieve-with-memoization.py
978
3.765625
4
# https://www.codewars.com/kata/master-your-primes-sieve-with-memoization/train/python primes = [2, 3, 5, 7] def is_prime(n): if n in primes: return n if n < 2: return False for prime in range(2, n): if prime in primes: continue for i in range(4, int(n ** 0.5) ...
05c86db503ab1dcfc1619d73a45c16f9bbf1b078
Birohn/WebCrawling
/os_file.py
1,446
3.5625
4
#@author: Byron Mouen #Main purpose of this file is to hold #all methods pertaining to editing/configuring #files an directories. import os #generate directory if it does not exist. def generate_project_dir(directory): if not os.path.exists(directory): print('Creating project' + directory) os.makedirs(dir...
1d0ad8465b05342d172f14cd438a353321bcf272
cpcarey/nyu-cusp-us-pedestrians
/displacement.py
748
4
4
import util class Displacement: """An encapsulation of the displacement between two points used for comparison.""" def __init__(self, p0, p1, id0, id1): self.p0 = p0 self.p1 = p1 self.vector = (p1[0] - p0[0], p1[1] - p0[1]) self.id0 = id0 self.id1 = id1 self...
e68a23472e159c441441ea14858974259091d9ab
Harshsa28/CLRS_exercises_codes
/22_1_3.py
280
4.1875
4
x = {} x[1] = [2] x[2] = [4] x[3] = [1,2] x[4] = [3] print(x) def transpose(adj_list): y = {} for i in adj_list: for j in adj_list[i]: if j in y: y[j].append(i) else: y[j] = [i] print(y) transpose(x)
0a2477f955e46dfee6dba618f545d4f342a4ea78
dj-amadeous/NearestNieghbor_graph
/main.py
1,374
4.03125
4
#imports from sklearn.datasets import load_iris import numpy as py import matplotlib.pyplot as py from sklearn.neighbors import KNeighborsClassifier from sklearn.cross_validation import train_test_split from sklearn import metrics import matplotlib.pyplot as plt #set iris to iris data set in sk learn iris = load_iris()...
8c4f2f6c8d3a80879b1813ee31d943e8e2c96f60
athena15/hackerrank
/write_a_function.py
309
3.75
4
# HackerRank "Write a function" Leap Year challenge # https://www.hackerrank.com/challenges/write-a-function/problem def is_leap(year): leap = False if year % 4 == 0: if year % 400 == 0: return True elif year % 100 == 0: return False else: return True else: return False is_leap(1990)
fceab387e04ec8a69287356f892172f0107ea807
aalvarezb9/ProyectoBasesFinal
/Código/Core/userControl.py
3,158
3.875
4
# importamos libreria tkinter from tkinter import Tk, Label, Button from createUser import createUser from removeUser import RemoveUser class userControl: def __init__(self): # creamos nueva instancia de la clase Tk self.controlUser = Tk() # definimos tamaño de la ventana ...
ebb90a55cf240a006539db879e4444eb9cce3feb
MinorJinx/Telegram
/seleniumTranslate.py
3,246
3.875
4
''' Created for UALR COSMOS Team Given a .csv with text, this script will return a .csv with translated text. It requires the input language to be defined as a country code: ('uk' is Ukranian) Once run, the messages are sent to a .html file and loaded into Chrome using Selenium. It waits for a user to click ...
a35acf3040475607b5f580326284b72c6caa4148
MockingBill/aluthorth
/公开课/问题二(百元买糖)_练习.py
744
3.59375
4
# 巧克力购买的数量范围 chocolate = [?, ?] # 水果糖购买的数量范围 fruitCandy = [?, ?] # 口香糖购买的数量范围 chewingGum = [?, ?] # 所需要的糖果数量 required_num = ? # 所需要话费的钱 required_money = ? for i in range(chocolate[0], chocolate[1] + 1): for j in range(fruitCandy[0], fruitCandy[1] + 1): for n in range(chewingGum[0], chewingGum[1] + 1): ...
47a223704f9bbf4366cb4219cea8f21ad777f73f
Dwaretha/Data-Structures-Python
/Stack Queue/Queue.py
734
4.09375
4
class queue: def __init__(self): self.items=[] def isempty(self): return self.items==[] def push(self,data): self.items.append(data) def pop(self): return self.items.pop(0) def display(self): print( self.items) s=queue() print("1.enqueue\n2.dequeue\n3.display\...
233868d2e122a041a24a3dc9a4d1a181ba2764f2
pwlolk/Wprawki
/003_tabliczka_mnozenia.py
1,409
4.0625
4
#Rysowanie listy print("Tabliczka mnożenia".upper()) def mult_table (size_x, size_y): cell_size = len(str(size_x) + "x" + str(size_y) + "=" + str(size_x*size_y)) cell_size += 2 if (size_x == 2 and size_y == 2): print("+" + size_x*(cell_size*"-" + "+")) for x in range(1, size_x+1): ...
88dce2e689bc3f2366ed5d611846c876d482ceef
yjhao/PyNumberLeetcode
/pyNumber.py
3,931
3.5625
4
from random import randint import sys class problemSet(object): def __init__ (self): self.list = set() self.lower = 0 self.higher = 330 self.readFromFile() def readFromFile(self): f = open('number.txt', 'r') lines = f.read().split(',') f.close() ...
74ef18b0f61c29d81d9238c167fdd4ea81e5799a
RyanFrantz/Concierge
/test/parseYaml.py
8,707
3.625
4
#!/usr/bin/python # parse init.yaml and build the appropriate SQL statements to be executed so that we can seed our database with defined services, apps, and their dependencices # # TODO # 1. build some static tables so that we can insert user-specified data into them # 2. build query statements that will be required ...
72c8413d3fbb7892500d0f9cd057c326cf0f527a
aj-1000/project-euler
/first-50/problem_5.py
694
3.9375
4
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. # What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def greatest_common_denominator(a,b): """ An implementation of the Euclidean algorithm """ whi...
46d9865e5dc4cc3b5c7861334c0e3d63dc592fe6
alexcuate/metodos_numericos
/Primer Parcial/NewtonRaphson.py
346
3.625
4
#Newton def f(c): return c**4-8.6*(c**3)-35.51*(c**2)+464*c-998.46 def fprima(c): return 4*(c**3)-25.8*(c**2)-71.02*c+464 x0=2 itera=0 for i in range(100): itera+=1 xr=x0-(f(x0)/fprima(x0)) fxr=f(xr) if abs(fxr)<0.01: break x0=xr print("El valor de la raiz es %0.5f"%x0) print("Numero...
59258d33f5dc162615c716e13df6489318c6b0a3
alexcuate/metodos_numericos
/Katas/kata2_2.py
352
3.875
4
''' Create a function that takes a list of non-negative numbers / strings and returns a new list without the strings. Example: [1, 2, "a", "b"] ➞ [1, 2] [1, "a", "b", 0, 15] ➞ [1, 0, 15] [1, 2, "aasf", "1", "123", 123] ➞ [1, 2, 123] ''' def filter_list(lst): nlst = list() for i in lst: if isinstance(i,int): nl...
f60806e2ba2a3f97ecccf83f8a3daefaf059e51c
reign912/MazeGenerator-Solver
/maze/maze.py
9,182
3.640625
4
import numpy as np import collections import random import maze.utils as utils import maze.base as base class Maze(base.MazeBase): """This class contains the relevant algorithms for creating and solving.""" def __init__(self): """Constructor.""" super(Maze, self).__init__() self._dir...
bc55d671a14c69da1a4282b57ebe577b39ee0438
k1412/python0
/i02003.py
718
3.59375
4
def getpass(prompt='Password: ', stream=None): import msvcrt for c in prompt: msvcrt.putch(c) pw = "" while 1: c = msvcrt.getch() if c == '\r' or c == '\n': break if c == '\003': raise KeyboardInterrupt if c == '\b': pw = pw[:-1...
46997a013417acf5963c9b39ce9d6efe81e381d1
k1412/python0
/i01001.py
297
3.5
4
from fractions import Fraction from decimal import Decimal import cmath a = 2**2048 print a print "这是中文" b = Fraction('19/155') d = Decimal('1.5') a = 2.0 c = a*b dd = float(d) f = a * dd print c print dd f = cmath.sqrt(-2) print f x = 7358.04/3600.0 print x print 'You Rolled \u2680'
57955205409d3180cf4cc841b6b7609172966dcb
jenny5546/2020-Spring-Algorithm
/sorting/insertion_sort.py
410
3.640625
4
""" 문병로 교수님 알고리즘 4강. 정렬 삽입정렬을 파이썬으로 짜서 연습해보자! """ array = [1000,1111111110,5,31,3,4,100,102,103,2,1] def sort(arr, n): for i in range(1,n): # 1부터 n-1까지 while i!=0 and arr[i]<arr[i-1] : arr[i],arr[i-1]=arr[i-1],arr[i] i=i-1 print(arr) sort(array,len(array)) ...
a57dc3ebd47f2a49e0aa8fb0674cd98da1a0a96d
LS-NotInUse/helloGit
/main.py
798
3.75
4
# import self as self # # # class TreeNode: # node_id: int # node_parent: "TreeNode" # node_children: ["TreeNode"] # # def __init__(self, node_id: int, parent: "TreeNode" = None): # self.node_id = node_id # self.parent = parent # self.children = [] # # # class BinaryTree: # # ...
8de0182e5b6bf2b956759e79b11e4d9c5910546f
shubham166/Competitive_Programming
/arrays/max_product_increasing_subsequence.py
1,296
3.625
4
import sys class Solution(object): def get_max_product_increasing_subseq_triplet(self, numbers): if numbers == None: return None size = len(numbers) if size < 3: return None lnr = Solution.largest_number_right(numbers) lnl = Solution.largest_number_...
d4604f0b95fbedcb2fcec35b8f60974177a84235
Eraydis/Test-tasks
/test_task1.py
812
4.25
4
# '''Имеется функция StringChallenge(strArr), использующая параметр StrArr, который содержит только один элемент, #Возвращая строку true, если это валидное число, которое содержит только цифры с правильно расставленными разделителями и запятыми, а обратном случае возвращает строку false''' import re def Strin...
6160c979af5edc9f30ef2e2652fe4b7a7060bdbe
Tephen/forLeetCode
/37.py
1,276
3.8125
4
class Solution: def solveSudoku(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ def backTrack(board) ->bool: def notValid(row,col,num): for i in range(0,9): if board[row][i]==num: ...
79334f13eb6489cef0f8ff686172937c0fe1bba8
Hriman-Mahanta/PythonPrograms
/AddBinary.py
161
4.0625
4
# 42. Program to add two binary numbers. a=input("Enter first binary number: ") b=input("Enter second binary number: ") sum = bin(int(a,2) + int(b,2)) print(sum)
cb912a26ff99d9a4eaea2d0c1694adceded44c35
Hriman-Mahanta/PythonPrograms
/TupleToDictionary.py
173
3.65625
4
# 24. Program to convert a tuple to dictionary. tup=[("akash", 10), ("gaurav", 12), ("anand", 14), ("suraj", 20), ("akhil", 25), ("ashish", 30)] dic=dict(tup) print(dic)
5d6b10060b7566c9996beca969bf4eea6ca5a97f
Hriman-Mahanta/PythonPrograms
/CombinationsDigits.py
274
4.0625
4
# 45. Program to print all combinations from 3 digits. n=int(input("Enter a 3 digit number: ")) list=[] while(n!=0): list.append(n%10) n//=10 for i in list: for j in list: for k in list: if i!=j and j!=k and i!=k: print(i,j,k)
8e7b16355aaa20085a40ddd5caa3a04e983032fb
Hriman-Mahanta/PythonPrograms
/ArraySum.py
117
3.921875
4
# 8.Program to find the sum of array elements. A=[1,2,3,4,5] sum=0 for i in range(0,len(A)): sum+=A[i] print(sum)
88b322080a0fe4e01a258897026bbdff36457022
Hriman-Mahanta/PythonPrograms
/ReplaceCharacter.py
96
4.25
4
# 56. Program to replace 'a' with '$'. s=input("Enter a string: ") s=s.replace('a','$') print(s)
d8ca1fe8f291903794c1a7d2715032cc2571c96d
Hriman-Mahanta/PythonPrograms
/DictionarySum.py
141
3.984375
4
# 20. Program to find the sum of the values in dictionary. dict={'a':100,'b':200,'c':300} sum=0 for i in dict.values(): sum+=i print(sum)
d8e3637a4416f286c9f846fa9e47666454a5d660
Hriman-Mahanta/PythonPrograms
/Join.py
200
4.15625
4
# 19. Program to join a list into string. list=[] n=int(input("Enter the number of words: ")) print("Enter the words: ") for i in range(0,n): i=input() list.append(i) s=" ".join(list) print(s)
61faf22cf930f9699df583b4ab4d4ee76bf0d6b3
mike171001/ALLESVANPYCHARM
/Al het huiswerk/5. Dict & Functions.py
637
3.546875
4
def namen(): namen = {} while True: naam_in = input('Volgende naam: ') if len(naam_in) == 0: for naam, voorkomst in namen.items(): if voorkomst == 1: print('Er is {} student met de naam {}'.format(voorkomst, naam)) elif voor...
0b916f5dbff817f414d6143e65b3b4129098f91c
mike171001/ALLESVANPYCHARM
/Al het huiswerk/1. While-loop & numbers.py
212
3.671875
4
nums = [] while True: Getallen = float(input("Geef een getal: ")) if Getallen == 0: break nums.append(Getallen) print("Er zijn", len(nums), "getallen ingevoerd, de som is:", sum(nums))
0eae3ada3ce0f73680773abeaa7fc863055e7b3c
mike171001/ALLESVANPYCHARM
/Al het huiswerk/2. Lists & strings.py
337
3.515625
4
num_strings = 0 string = [] new_strings = [] while num_strings != 10: string.append((input("Vul hier een woord in"))) num_strings += 1 for i in range(len(string)): if len(string[i]) == 4: new_strings.append(string[i]) print("De nieuw-gemaakte lijst met alle vier-letter strings is: ") p...
8ca3d93a7c524b78d0ea72334e4a217fece92a4b
butiran/butiran.github.io
/src/py/fi3201/root/root-newton-raphson.py
1,574
3.59375
4
# # root-newton-raphson.py # Finding root using Newton-Raphson method # # Sparisoma Viridi | https://butiran.github.io/ # # Execute: py root-newton-raphson.js # # 20210131 # 1850 Start this program from root-bisection.py. # 1954 Continue make test_function and its derivative. # 2006 Test it and ok, also for SHOW_PR...
b8ff6da26da588544f2baededd624ba30df11254
butiran/butiran.github.io
/src/py/fun/vect3dot.py
476
4.0625
4
# # vect3dot.py # Dot product of two 3-d vectors in Python 3.7 # # Sparisoma Viridi | https://github.com/dudung # # 20210110 # 1953 Start creating this example. # 1956 Test it and ok. # 2000 Add \xb7 for middle dot. # # Define two vector using array r1 = [1, 2, 3] r2 = [2, 2, 9] # Calculate dot product of two vecto...
8ae5046420eadf1895780a4c66b7f1d13672a993
yanhuilee/l_python3
/fromzero/dict_.py
751
3.71875
4
# append()/insert()/ pop(index=-1) / remove(obj) # 将元组转换为列表 list(seq) # list.append(obj) / list.extend(seq) / clear() # list.sort(cmp=None, key=None, reverse=False) # copy() # 日期和时间 # 文件操作 # 比起os模块的path方法,python3标准库的pathlib模块的Path处理起路径更加的容易 import os print(os.path.dirname(__file__)) #/ print(os.getcwd()) #\ import p...
a2f8ebcbeccc4bb0ee997336818f7c2e6c470c93
yanhuilee/l_python3
/fromzero/fir.py
390
3.96875
4
# -*- coding: utf-8 -*- class Fruit: color = "" def __init__(self, color="green"): Fruit.color = color def harvest(self): print("水果是" + Fruit.color + "的") class Apple(Fruit): def __init__(self): print("我是苹果") super().__init__() #不放在第一行? if __name__ == '__main__': ...
cddae5eca60a23f3baa2c79156b806808d3d52e6
AKuederle/funcmap
/examples/example_class.py
1,880
4
4
# -*- coding: utf-8 -*- """When using funcmapper with instance methods, you can ot use the decorator syntax. Instead you need to perform the mapping after the instance is created. The best place to do this is the init method of your class. This ensures, that each instance has its own funcmap and the self context is ava...
c133053e8445f9b1d0354f7c063fc2cda9c695e1
floyebolu/Udemy
/src/helloworld/simplemain.py
129
3.828125
4
print("Hello World!") b = 3**3 c = ("You are " + str(b) + " now.") print(c.__len__()) print(c) print(len(c))
e38e8bb62a4dd1bc9d3d2c8683a980f9ebaad69f
NojNo/Project3
/database_setup.py
2,543
3.671875
4
# important everything you need from SQLAlchemy from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, backref from sqlalchemy import create_engine Base = declarative_base() '''create a table with 4 columns:...
9dbbfe855f6e682baddd7ebed899b29581d992e9
terrymyy-zz/Python
/addressbook.py
316
3.921875
4
class Address_Book(object): def __init__(self, owner, contacts): ''' owner is a string and contacts is a list of contact objects''' self.owner = owner self.contacts = contacts class Contact(object): """docstring for Contact""" def __init__(self, name, phone): self.name = name self.phone = phone
5f73b7e468ab8b5e88d3d161a65c39ac04de9a94
terrymyy-zz/Python
/numb.py
3,206
4.0625
4
import math import sys def is_prime(x): '''function that returns whether or not the given number x is prime. returns boolean.''' counter = 0 for i in range(1,x+1): if x % i == 0: counter += 1 if counter == 2 : return True else: return False def is_composite(...
6d782370219bc41f3845be4e8c5790e839fef327
sridhar1029/Basic_NN
/Basic_NN.py
6,072
3.5
4
import numpy as np import matplotlib.pyplot as plt #utils def sigmoid(Z): A = 1/(1+np.exp(-Z)) return (A, Z) def relu(Z): A = np.copy(Z) A[A<0] = 0 return (A, Z) def sigmoid_backward(dA, Z): sig, cache = sigmoid(Z) grad_sig = sig*(1-sig) dZ = dA*grad_sig return dZ def relu_backwa...
b87c89d52bd13bbcabdd8023a98d50e759fc0fbf
lawrencemh/cs50
/pset6/mario.py
525
4.0625
4
def main(): # get height of pyramid from user height = 0 while not (height > 0 and height <= 23): height = int(input("Enter a height: ")) # init spaces and # variables spaces = height hash = 1 # loop through each pyramid row for i in range(height): print(" " * s...
340f9f1ac3ae45d7302582f6c97d26790a49d209
ibrahim-elgazwy/SA
/remove repeated words from text file.py
409
3.671875
4
# -*- coding: utf-8 -*- lst = [] #this list store unique words lst2 = [] #this list store all words with open ("neg_words_all.txt") as f: for line in f: for word in line.split(): lst2.append(word) for x in lst2: if x not in lst: lst.a...
44fb0816bba467b6bd8013122700816828e24997
rizwandel/nltk-spacy
/nltk-tokenization.py
908
3.515625
4
import nltk str = "Pythons live near the equator, in Asia and Africa, where it is hot and wet and their huge bodies can stay warm. They make their homes in caves or in trees and have become used to living in cities and towns since people have been moving in on their territory." nltk.word_tokenize(str) # Out[2]: =>...
9b8b4fe8412f1a5d9ad48417f5296e318f6f9ea8
avinash3699/Simple-Calculator-using-tkinter
/Simple Calculator using tkinter.py
4,320
4.375
4
# Python program to create a Simple Calculator GUI using tkinter #importing everything from tkinter module from tkinter import * # creating a GUI window window = Tk() # restricting the user to change the dimensions of the window using 'resizable' method window.resizable(width=FALSE, height=FALSE) # setti...
86d80f6fffea0dcb88347cc973b5d9e99f8a133e
maksdk/python-basic
/47.py
150
3.625
4
def is_mister(string): return string == "Mister" def is_castle(value): return value == "Castle" print(is_castle(2)) print(is_castle("Castle"))
a929d875abb67896afbf998e29ede0538bfd0846
maksdk/python-basic
/46.py
353
3.828125
4
#Список операций сравнения: # # < — меньше # <= — меньше или равно # "> — больше # ">= — больше или равно # == — равно # "!= — не равно def is_infant(age): return age < 1 print(is_infant(2)) def is_pensioner(age): return age >= 60 print(is_pensioner(65))
bef27e023f043d25eae925aac9000cbd3b135517
jaredparmer/ThinkComplexity
/ch3.py
9,846
4.0625
4
""" for chapter 3 of Allen Downey, Think Complexity """ import matplotlib.pyplot as plt import networkx as nx import numpy as np from collections import deque from ch2 import flip, all_pairs import random import math def adjacent_edges(nodes, halfk): n = len(nodes) for i, u in enumerate(nodes): for j...
d0d49d90457938bbb80be7ff3a09fe64ebe3d9b8
SACHSTech/ics2o1-livehack2-practice-toast23
/problem2.py
637
3.921875
4
""" ------------------------------------------------------------------------------- Name: problem2.py Purpose: determine if a vacation is rewarded Author: Yao.T Created: 13/02/2021 ------------------------------------------------------------------------------ """ #get mark and earnings information mark = rou...
08466b4a18e936763819f9827f8054e2ff2e480c
SitiNurcholis/Fitur1-Tugas-DDP
/Tugas1_SI02_0110120009.py
2,600
3.75
4
print('Fitur Pengisian Rencana Studi') # cek kondisi tahun masuk dan max pengambilan sks nim = input('Masukkan NIM : ') # input nim user panjang_nim = 10 # nim harus berisi 10 angka max_sks = 0 # nilai default sks if nim[5:7] == '20' and len(nim) == panjang_nim: # jika diantara index 5-7 nim berisi...
377537832a4081226196270a1fa9c6fae2e9490b
ahmadalsajid/TutorialNLTKPractice
/Vid2.py
442
3.984375
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_text = "This is an example showing off stop word filtration." stop_words = set(stopwords.words("english")) words = word_tokenize(example_text) ''' # long version filtered_sentence = [] for w in words: if w not in stop_words: ...
6470c1ac40bdb0694f525f3796da2cd29e6f0950
yunusarli/Quiz
/questions.py
1,717
4.21875
4
#import sqlite3 module to keep questions in a database. import sqlite3 # Questions class class Questions(object): def __init__(self,question,answer,options=tuple()): self.question = question self.answer = answer self.options = options def save_question_and_answer(self):...
c7b050e273ef666ea9595d8fd2be573e63b362d0
LimSeongHwan/algorithms
/2102/BJ_1010.py
378
3.515625
4
def solution(case): def factorial(number): if number == 0: return 1 elif number == 1: return number return number * factorial(number - 1) n, m = map(int, input().split()) res = factorial(m) / (factorial(n) * factorial(m - n)) return int(res) case = int...
d968eef26e8076719d20381bfdcce1d596019f0c
lcygithub/Pylearn
/enumerate/enumberate.py
886
3.984375
4
#!/usr/bin/python #-*- coding:utf8-*- strings = ["xxxx",'adf','asdfasdf'] for string in strings: if "xxxx" in string: index = strings.index(string) strings[index] = '[censored]' print strings print index testlist = [1,12,23,32,3,4] index = testlist.index(12) print index strings = ["xxxx",'adf','asdfasdf'] for inde...
545873b1ceb5c6cc63ed3c3ab1969dc1acc1e950
KenDooley/evaluate-math
/test_postfix.py
371
3.75
4
from postfix import parse_expression_into_parts, evaluate_postfix EXPR = "9 - ( 1 + 3 ) * 2" INFIX_PARTS = [9, '-', '(', 1, '+', 3, ')', '*', 2] POSTFIX_PARTS = [9, 1, 3, '+', 2, '*', '-'] def test_parse_expression_into_parts(): assert parse_expression_into_parts(EXPR) == INFIX_PARTS def test_evaluate_postfix(...