blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e29b6a0ae33e402a3b71403629d7ab7e0b70e42d
ankitdhebarin/Python3
/Regex/Parse_Date.py
341
3.984375
4
import re def Parse_Date(input): date_regex = re.compile(r'(?P<month>\d{2})[./,](?P<date>\d{2})[./,](?P<year>\d{4})') matches = date_regex.search(input) date = {} date['d'] = matches.group("date") date['m'] = matches.group("month") date['y'] = matches.group("year") return date print(Parse_Date("Today's dat...
7d31a69429a2e71045e010e9e269b300a073985b
Brokkenpiloot/Heuristieken
/visualization.py
728
3.53125
4
import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) grid = [] for row in range (10): grid.append([]) for column in range(10): grid[row].append(0) pygame.init() size = [400, 400] screen = pygame.display.set_mode(size) tileWidth = 20 tile...
126b2d9aa9eda3f9c9d968742dba99fa2b730d22
dylanagreen/kpno-allsky
/threshold.py
18,404
3.953125
4
"""A module providing analysis methods for determining cloudiness thresholds. The predominant function of this module is to analyze saved cloudiness data to try and determine the cloudiness value that corresponds to whether or not the telescope dome is closed or open. The main method analyzes the cloudiness of each im...
40fe8fe99d90d34ea32881bbcf893004645924e2
arnabid/QA
/strings/reverseWordsInString.py
1,062
3.796875
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 28 10:44:39 2016 @author: arnab """ """ reverse the words in a string this is a string -> string a is this += concatenation for strings is not slow """ def reverseInPlace(s): arr = [ch for ch in s] n = len(s) i, j = 0, n-1 while i < j: arr[i]...
5607d0f1e528424789b8f56d24c32baee18df773
sheamus-hei/whiteboarding
/student-resources/binary-trees.py
1,821
4.375
4
# basic class class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None # 1 # / \ # 2 3 # / \ # 4 5 tree = TreeNode(1) tree.left = TreeNode(2) tree.right = TreeNode(3) tree.left.left = TreeNode(4) tree.left.right = TreeNode(5) # Depth ...
b11eaf1c7f56779898a135e63530d43b60761f47
suryak24/python-code
/73.py
161
3.921875
4
n=int(input("Enter N value:")) l=int(input("Enter L value:")) r=int(input("Enter R value:")) if n>=l: if n<=r: print("yes") else: print("no")
c629024d835030dbc113c629df62313841a483db
esrasking/python
/Chapter 4/summing_a_million.py
431
3.71875
4
#20191203 #Chapter 4.5: Summing a Million #Start Program print(f"\nSTART PROGRAM\n") #The code below shows the sum of values 1-5. print(f"Here is a quick test that the sum of the range values works:\n") values = list(range(1,6,1)) print(sum(values)) print('') #The code below executes the sum of values up to and in...
e3c67b7d0c7ffdde0e1631896ba434d0c613244b
sedasakarya/workshop
/PYTHON/4.Functions/functions.py
1,966
4.28125
4
""" BUILD-IN FUNTIONS ==================================================== """ # Native functions like print... #print("whatever") #print("whatever", "and", "ever") age = 12 #print("age is:", age) #print("list\n", [1,2,3]) #print("list", [1,2,3], sep=":", end=".") # Sep adds a seperation sign. End adds a sign at the e...
2155ec6f018836adb02ec244bacb900540833c5f
saidskander/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
85
3.5
4
#!/usr/bin/python3 def uniq_add(my_list=[]): return sum(x for x in set(my_list))
b527634a678f3e13431d429b11371a8d72ed4313
123akhil/datascience
/6.00.1x_Introduction_to_Computer_Science_and_Programming_Using_Python/Week_3/Problem_Set_3/PS3_2.py
779
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 20 01:36:47 2016 @author: Camilo Cruz """ def getGuessedWord(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters and underscor...
669c7e1d2a2c8988fb5830ee71859047c6f20d26
EnochEronmwonsuyiOPHS/Y11Python
/StringSliceChallanges03.py
200
3.96875
4
#StringSliceChallanges03.py #Enoch firstname = str(input("Enter your first name in lower case")) lastname = str(input("Enter your last name in lower case")) s = " " print(firstname + s + lastname)
3040ec36600f1fb098b794b5f027fcc2f9afa415
Maayaavi/OC_Project_3
/main.py
6,533
3.734375
4
#!/usr/bin/python3 # -*- coding: Utf-8 -* ######################################################################## # Filename : main.py # # Description : A maze game in the player have to move Macgyver to the # # exit by collecting some objects through the...
ed1ab4791da91b52ba33a1b6f283c09dd8735504
buisang123/buiducsang-fundamentals-c4e18
/session 3/Homework/ve_la_co.py
328
3.65625
4
from turtle import* color2 = ('red','blue','brown','yellow','grey') k = 0 for i in range(5): color(color2[k]) fillcolor(color2[k]) begin_fill() right(90) forward(100) right(90) forward(50) right(90) forward(100) right(90) forward(100) k += 1 end_fill() main...
11760ec363e825947a8f16751ccc491c1eaa2dea
arjunshah1993/Algorithms
/rev_array_recur.py
291
3.5625
4
arr = [3, 5, 2, 6, 2, 1] i = len(arr) - 1 def arr_rev_recur(array, i): if i <= len(array)/2 - 1: return array temp = array[i] array[i] = array[len(array) - i - 1] array[len(array) - i - 1] = temp return arr_rev_recur(array, i - 1) print(arr_rev_recur(arr, i))
eea63698fd5d4959af65d7c53e143752834124f2
Cscotttaakan/EulerSolutions
/Euler83/Euler83self.py
6,281
3.65625
4
class Node:#create class to contain values def __init__(self, val, tot): self.value = val self.total = tot def __hash__(self):#make node hashable in dictionary return hash(id(self)) def __eq__(self, other): return (id(self) == id(other)) def __ne__(self, other): ...
df8dfb4504cc63cc9c31ac808d3513bcd7243389
udoprog/tl
/tl/__init__.py
3,482
3.78125
4
#!/usr/bin/python import sys; import re; import tl.units; def prettyprint_time(seconds): if seconds < 1: print "less than a second" return; timeparts = list(); mill = 0; cent = 0; dec = 0; y = 0; d = 0; H = 0; m = 0; if seconds > 60: m = seconds / 60; seconds -= (m * 60) ...
ef096bb4550a1dcbb008e379fbb2171841676db4
scub72/Hydraulika
/HydraulicLibrary/functions/calculateVelocity.py
251
3.5
4
# Calculates the velocity with given: # - flow [l/min] # - diameter [mm] # # calculation result is velocity in [m/s] def calculateVelocity( flow, diameter): velocity = flow/1000.0/60.0/(3.14*pow(diameter/1000.0, 2)/4.0) return velocity
eee24bdb5d93cbde7a1f4f149118d15fcb373b34
itsdeepakverma/python
/Deepak_Verma3.py
179
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 13 13:02:47 2018 @author: Admin """ def Main(): str=input("Enter your test") str="*".join(str) print(str) Main()
8a7cfb1f0723b096840902a62ead78a99f1272a4
camilleanne/project-euler-solutions
/6.py
346
3.609375
4
# Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. # -- scope = 100 sum_of_squares = 0 square_of_sums = 0 for i in range(scope + 1): sum_of_squares += (i * i) square_of_sums += i square_of_sums = square_of_sums * square_of_sums print square...
cdefa6f65d75c76a213a108b0223122b72b30a2f
morrosquin/aleandelebake
/crypto/caesar.py
385
4.125
4
from helpers import alphabet_position, rotate_char def encrypt (text, rot): encrypted_text = "" for characters in text: encrypted_text += rotate_char(characters, rot) return encrypted_text def main(): text = input('Enter your message: ') rotation = int(input('Enter rotation: ')) prin...
f1eb7c1008919db13ea251f213cb41939bc6d768
kevinniel/P5_openfoodfacts
/App/main_menu.py
1,245
3.5625
4
""" This module will generate the main menu """ # !/usr/bin/python3 # -*- coding: Utf-8 -* # import sys = Problème perso d'import à dégager par la suite. import sys sys.path.append('C:/Users/guthj/OneDrive/Bureau/coding/P5_openfoodfacts') from Config.config import MAIN_MENU from App.select_products import SelectCate...
33a494821adfe9152461186f0afae033a0c8f873
linchenlinchen/Class_3_term_1
/智能系统原理开发/PROJECT/lab2/17302010021_林晨/RecommendSystem/draft.py
398
3.59375
4
# Message = [[2,'Mike'],[1,'Jone'],[2,'Marry']] # dict1 = {} # for number in Message: # value = number[0] # if value not in dict1.keys(): # dict1[value] = [number] #此句话玄机 # else: # dict1[value].append(number) # print(dict1) L = ['1','4'] L.append('3') print(L) L1 = ['Google', 'Runo...
4fdb14994dead769d220a252b7cee66da9c0ec36
jdvpl/Python
/7 funciones/ejemplo.py
310
3.78125
4
def Tabla(num): print(f"####Tabla del {num} ###".center(50)) for contador in range(11): operacion=num*contador print(f"{num} x {contador} = {operacion}") print("\n") numero=int(input("tabla del: ")) Tabla(numero) for numero_tabla in range(1,numero+1): Tabla(numero_tabla)
b792b0da6060bcb0f4868d3c52145ba3dc1b9944
joway/PyAlgorithm
/leetcode/array/easy/findDisappearedNumbers.py
1,256
3.671875
4
""" Summary """ class Solution(object): """ Problem: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ Example: Input: [4,3,2,7,8,2,3,1] Output: [5,6] """ def findDisappearedNumbers(self, nums): """ :type nums:...
8bb2643692a42352205f142f9e077c32d4deef63
HypeRush/Python-Os-Module-Examples
/filedel.py
1,375
3.640625
4
import os print (os.name) print("şuan bulunduğun dizin:",os.getcwd()) path = input("Taranacak yerin pathi:",) def main(path): if path == (""): path = os.getcwd() dir_list = os.listdir(path) print("Aranan yerdeki dosyalar ve klasörler'", path, "' :") print(dir_li...
2e7d2c889dc1a05302794b49f6f8f0fafd9deb52
ppeiris/codes
/mooc/mit-6.00/ps3d.py
1,270
3.53125
4
# Problem Set 2 # Name: Geeeqie # Time: 00:30 # # Problem 4 # from string import * def constrainedMatchPair(firstMatch, secondMatch, length): match = () m = length for n in firstMatch: for k in secondMatch: if n+m+1 == k: match += (n,) return match def subStringMatchOneSub(key,target): """search fo...
2361862094cbe8bc414cb97fb37adbe939bea567
tresa2002/Python-Projects
/swap.py
497
4.34375
4
num1 = int( input("Enter value for num1: ")) num2 = int( input("Enter value for num2: ")) #values before swapping print ("The Value of num1 before swapping: ", num1) print ("The Value of num2 before swapping: ", num2) # To swap the value of two variables # we will user third variable which is a temporary var...
f7f386498a7b440298ad5231446fff1422d9792f
recheej/Data-Structures-In-Python
/queue.py
1,448
3.90625
4
__author__ = 'recheejozil' from linked_list import LinkedList from linked_list import Node from stack import Stack class Queue(object): def __init__(self): self.linked_list = LinkedList() def enqueue(self, item): if self.linked_list.head is None: self.linked_list.insert(item)...
e580b4cad68c56f71b474822cf7b35fd3442850a
kvizconde/Pizza-Builder
/user_interface_pizza.py
8,681
3.90625
4
import random import time from python_pizza import BasePizza, Toppings """ This module contains one class: UserInterface The UserInterface class handles all the user interaction which allow the user to build amazing pizza. """ class UserInterface: """ This class contains all the required methods for user in...
4928ac3e9edb82f94b374637add08d0a7805a6f2
mikeirwin/python_practice
/Data_Structures/Hash_practice.py
4,106
4.09375
4
""" Hash map: A key-value store that uses an array and a hashing function to save and retrieve values. Key: The identifier given to a value for later retrieval. Hash function: A function that takes some input and returns a number. Compression function: A function that transforms its inputs into some smaller range o...
0d19117eb33eae5a9598e6ca14a942bde11d2706
qqss88/Leetcode-1
/240_Search_2D_Matrix.py
1,239
4.0625
4
#!/usr/bin/env python # encoding: utf-8 """ Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. For example, Conside...
68065a7afd36484a2b903990a99ffd187dacabc3
askatako/youtube
/extract_categories.py
892
3.5625
4
import json import pickle def load_json(path): """ Loads the json file in the given path. Precondition: path: is a string of a valid json path. """ with open (path) as file: return json.load(file) def save_pickle(path,data): """ Dumps the json file in the given path. Precondition: path:...
566e17eb4417a07ba655c2e2c5bfc079cd8590e5
szhongren/leetcode
/393/main.py
1,745
4.1875
4
""" A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: For 1-byte character, the first bit is a 0, followed by its unicode code. For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10. This is how the U...
1861eca1fbfb1b4c08df336c11e7278ae5f9d91e
jmarianer/adventofcode
/2019/22.py
2,539
4.09375
4
import sys, itertools class Stack: """ A stack is described as a multiplier and an adder. Each card c goes to position (c+a)*m, where addition and multiplication are both done mod the stack length, which is assumed to be prime. """ def __init__(self, stacklen): self.stacklen = stacklen ...
0eb24df65410302445428df05a29d4fc80e3bff0
manimaran-elumalai/Giraffe_Academy_Python
/listfunctions.py
895
4.21875
4
friends = ["Christy", "Rahul", "Mohan", "Jyothi", "Kavin"] lucky_numbers = ["2", "4", "6", "8"] friends1 = friends.copy() print(friends1) friends.extend(lucky_numbers) #extend(extend is a list function) the elements of the other lists to the friends list print(friends) friends.insert(4, "David") #add a new element to t...
21d612fe7a2ffbb5062b7b9af3768ca765d005e3
angjerden/oiler
/others/luke10.py
2,080
3.5
4
# # Velkommen til Knowit sitt julebord! # # På julebordet er vi 1500 mennesker som sitter rundt et stort bord. # Vi er nummerert fra 1 til 1500 langs bordet. # Vi har fått tak i en flaske med meget sterk (men god!) akevitt. # # Den første personen tar flasken og serverer person nummer to en dram. # Akevitten er så ster...
451ffd2bfd5abd39d26744db50c2b3552862ffb1
DariaLotareva/Dasha
/hypothenuse.py
239
3.96875
4
print('please write down 1st leg of the right-angled triangle') a=int(input()) print('please write down 2st leg of the right-angled triangle') b=int(input()) c=((a**2)+(b**2))**(1/2) print('the hypothenuse is equal to {}'.format(c))
26640f83780758dc630e0b7a3cc8190f83772cc8
YashMistry1406/data-structures-and-algo
/implementation _pyhton/tree/check_BST.py
710
3.984375
4
class Node: def __init__(self,data): self.data=data self.left=None self.right=None def Insert(root,data): if(root== None): root=Node(root) if(root.data <=data): root.left=Insert(root.left,data) elif(root.right >data): root.right=Insert(root.right,data) ...
0999151ac911ad779be04c224dd7fd0e11c3a42f
LarisaOvchinnikova/python_codewars
/Sum of Digits - Digital Root.py
182
3.515625
4
https://www.codewars.com/kata/541c8630095125aba6000c00 def digital_root(n): while n > 9: s = 0 for i in str(n): s += int(i) n = s return n
57bfeb07f8a35d64ef49a7e216280bc9979155ad
vicety/LeetCode
/python/75.py
680
3.8125
4
from collections import deque from typing import List class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ if not nums: return zero_r, one_r, two_l = 0, 0, len(nums) - 1 while one_r ...
8531673bd473a5d14589488b8454d75c55c183f2
suryak24/python-code
/41.py
79
3.75
4
str=input("Enter the string:") k=int(input("Enter the k values")) print(k*str)
ae19ad05b2db47b553eb51fed91985edffbd75f9
momentum-cohort-2018-10/w2d1-currency-converter-meagabeth
/currency_converter.py
747
3.8125
4
# list = [(value, form, to)] rates = [ ("USD", "EUR", 0.74), ("EUR", "JPY", 145.949) ] def convert(list, value, original, to): if original == to: return value for conversion in rates: if original == conversion[0] and to == conversion[1]: return value * conversion[2] ...
e80f43e1941e735c7473553da70fe9c50829aa72
kegans/IntroToProg-Python-Mod07
/Assignment07.py
4,104
4.0625
4
# ------------------------------------------------- # # Title: Assignment07 # Description: Demo of exception handling # using custom error classes and pickling # ChangeLog: (Who, When, What) # KSanchez,11.30.2020,Created Script # ------------------------------------------------- # # --------------Exception Han...
62c88bf5303008b0a3d1d8d57013c27bf258c9e0
alisonsu/example
/test/test_algs.py
1,593
3.765625
4
import numpy as np from example import algs def test_pointless_sort(): # generate random vector of length 10 x = np.random.rand(10) # check that pointless_sort always returns [1,2,3] assert np.array_equal(algs.pointless_sort(x), np.array([1,2,3])) # generate a new random vector of length 10 x...
94d44701bc9f30a7f0275bede2f7c631c3f38411
superSeanLin/Algorithms-and-Structures
/222_Count_Complete_Tree_Nodes/222_Count_Complete_Tree_Nodes.py
1,133
3.9375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def countNodes(self, root: TreeNode) -> int: ## level-order traverse, find less-child on the last second layer ## also us...
71318bd17165d3dd23a00f5724a2849dd1548243
Pallavi2000/heraizen_internship
/internship/M_1/series2.py
310
4.15625
4
"""program to accept a number “n” from the user; then display the sum of the following series: 1/2^3+1/4^3 + ……+1/n^3""" n=int(input("Enter the value of n: ")) sum=0 if n==0: print(f"Input nonzero value") else: for i in range(2,n+1): sum+=1/(i**3) print(f"Sum of series={sum}")
24b1a1a64652849f2182fd257632f2af6ecd03dd
dmort27/epitran
/epitran/puncnorm.py
1,211
3.578125
4
# -*- coding: utf-8 -*- import pkg_resources import unicodecsv as csv class PuncNorm(object): def __init__(self): """Constructs a punctuation normalization object""" self.puncnorm = self._load_punc_norm_map() def _load_punc_norm_map(self): """Load the map table for normalizing 'down'...
5d223e12fa7027e815492a83b5cf1d74cde31330
synapse99/20190420
/loop03.py
540
3.78125
4
print("1부터 9까지") for i in range(1, 10, 1): print(i) print() print("0부터 9까지") for i in range(10): print(i, end=" ") print() print("0부터 10까지") for i in range(11): print(i, end=" ") print() print("1부터 10까지") for i in range(1, 11): print(i, end=" ") print() prin...
da2e2d77e484af592ae7c265933219729e3bc4aa
pavankumarag/ds_algo_problem_solving_python
/practice/very_hard/_72_iterative_inorder_traversal.py
519
3.90625
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def inorder_iterative(root): current = root stack = [] while True: if current is not None: stack.append(current) current = current.left elif stack: current = stack.pop() print current.data, current =...
587b8ce84a9250b9b8474cc245f802d6e45722f0
marclave/Project-Euler
/Problem16.py
439
3.921875
4
""" Problem 16 https://projecteuler.net/problem=16 Power digit sum answer is 1366 """ def powerSum(power): sum = 0 result = str(2**power) for i in range(len(result)): sum += int(result[i]) print sum if __name__ == "__main__": print "=================================" print " Problem16 ...
55394ad092a9e53b794501c05b4f680b43a89fb4
noobzyl/task
/fib list/fib_rec.py
262
3.734375
4
# coding : utf-8 '''递归法求斐波那契数列''' def fib(n): if n == 1 or n == 2: return 1 else: return fib(n-1) + fib(n-2) counts = int(input("请输入需要的个数: ")) res = [fib(n) for n in range(1, counts+1)] print(res)
2210a36d38a7c7c52c014483217198e97da47ae4
fruchoc/launder
/program/output.py
3,768
3.609375
4
""" output.py The output interface for writing text files from the main program (c) William Menz (wjm34) 2012 """ import sys class Output: def getData(self): return self.m_data def __init__(self, fname): self.m_fname = fname self.m_data = "" self.m_write = T...
1b67032ddb07ed8244c8f1d5f21aaddfd7450d7e
Jeroen-dH/functions-tryout
/multiplier-x.py
164
3.578125
4
tafel = int(input("Welke tafel wilt u weten. (1/10)")) def de_tafels(tafel:int): for a in range(1,11): print(a,"x",tafel,"=",a*tafel) de_tafels(tafel)
fcab8cb9524a1142a0a8ff994214eba608c2fe3c
ee18b101/Text-Based-Search-Engine
/Project/sentenceSegmentation.py
1,450
3.515625
4
from util import * # Add your import statements here import nltk class SentenceSegmentation(): def naive(self, text): """ Sentence Segmentation using a Naive Approach Parameters ---------- arg1 : str A string (a bunch of sentences) Returns ------- list A list of strings where each string is ...
5f79beb2277c9471d818cb3664a801f956189703
geozevallos/Repositorio_BackEnd
/session1/script.py
172
3.796875
4
print("Ingrese edad") edad = input() if int(edad) > 18: print("es mayor de edad") elif int(edad) < 0: print("edad invalida") else: print("no es mayor de edad")
a5f0d1c7214dc75fe9d98f822771a6bbbcff8e07
angelahe/automate
/dragon.py
1,711
4.125
4
import random import time def displayIntro(): print('You are in a land full of dragons. In front of you') print('you see two caves. In one cave, the dragon is friendly') print('and will share his treasure with you. The other') print('is greedy and hungry, adn will each you on sight') print() de...
32ca4879ce2bc2854f4a5f2cefac3cae64a484ce
miko73/codity
/small_frog.py
339
3.828125
4
import sqlite3 def solution(x, y, d): if d <= 0: print("Takhel tam nedojdu") return 0 if x * y <= 0 or y < x: print("spatny vstup") return 0 steps = (y-x)//d #print(steps) if ((y-x)%d) > 0: steps += 1 return steps A = [1,2,3,4,5] X = 10 Y = 85 D = 30 pri...
696793a21273d57cc6432f9684bd86f9dbd4a170
Anup-Toggi/python
/hcf1.py
177
3.859375
4
#Using Euclid's algorithm print("Enter Two Numbers") a=int(input()) b=int(input()) while True: if a==b: print("HCF = ",a) break if a>b: a=a-b else: b=b-a
2a2528538dec601b31c52d027be81b5756d72b70
BranSmit/Project-Euler-Solutions
/P1-10/P5.py
592
3.703125
4
# Smallest multiple # 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? # Not gonna generalize this one because I dont really feel like it. sm = 2520 numSet =...
5ca7f10a12c1c7528fe61db76ed4971a1688c634
AdrianoCavalcante/exercicios-python
/Lista_exercicios/ex061.py
216
3.890625
4
termo = int(input('Digite O numero para ver suas 10 priemeiras progreções: ')) razao = int(input('Digite a razão da progreção: ')) pa = 10 while pa != 0: print(termo, end=' ') termo += razao pa -= 1
3de817b2949e8a3d001124b28b94fb766be759b6
idaandersson89/Python-ida
/Hurray.py
186
3.984375
4
#fruits=["hip"] #for x in fruits: # print(x) for i in range(3): print(i) for i in range(2): print("hip") print("hurray") #for hip in range(2): # print(hip)
6c393332ae73d276a4629aa1402b101a98773e73
Hunt-j/python
/PP09.py
596
3.8125
4
from random import seed from random import randint seed(randint) x = 1 n = int(0) while (x == 1): a = randint(1,9) b = int(input("Pick a number between 1 and 9")) if (b > a): print("Too high!") again = input("play again (Y or N)") n = (n + 1) if (b < a): print("Too...
b162da0b8c90dc2d92f61e9144717431ab9f746f
ZwyAnswer/Leetcode_solutions
/Linked List/61.Rotate List/Solution.py
542
3.5
4
class Solution: # @param head, a ListNode # @param k, an integer # @return a ListNode def rotateRight(self, head, k): if not head or not head.next: return head if k == 0: return head p1 = head while k > 0: p1 = p1.next if no...
f0e22c5e2142d53c5f7622117d80e578ef4a6703
isilanes/myeuler
/p027/p027.py
860
3.65625
4
def f1(): maxn = 0 abmax = [0, 0] for a in range(-1000, 1001): for b in range(1001): n = -1 while True: n += 1 m = n*n + a*n + b if m < 2 or not isprime(m): break # n here will be length of s...
2b21d7e496b90f55cca93f4c79cacbc172118c95
CodeyBank/Webscrapping-with-Python
/webscraping.py
798
3.578125
4
import requests from bs4 import BeautifulSoup # # r = requests.get("http://testing-ground.scraping.pro/table") # c = r.content # # soup = BeautifulSoup(c, "html.parser") # # all = soup.find_all("div", {"class": "cities"})[0] # # use the find_all method to return elements of html with a particular # # this meth...
726acce695d62e6d438f2abd93b1685daab8f95a
applicationsbypaul/Module7
/Module8/more_fun_with_collections/dict_membership.py
502
4.15625
4
""" Program: dict_membership.py Author: Paul Ford Last date modified: 06/22/2020 Purpose: using dictionaries for the first time """ def in_dict(dictionary, data): """ accept a set and return a boolean value stating if the element is in the dictionary :param dictionary: The given dictionary to search ...
6cb4f91de1e80193e3e038f7ddd264bac3bed1b1
CFHT/apero-trigger
/trigger/baseinterface/processor.py
1,480
3.515625
4
from __future__ import annotations from abc import ABC, abstractmethod from typing import Optional class RecipeFailure(Exception): """ Exception representing any failure for a DRS recipe. """ def __init__(self, reason: str, command_string: Optional[str] = None, traceback_string: Optional[str] = None...
4610a69f7338705e30afa1a4f7c488e103ed86cf
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4480/codes/1644_1054.py
126
4
4
x= int(input()) y= int(input()) r= 3-2*x if(y==r): print('ponto pertence a reta') else: print('ponto nao pertence a reta')
50ed8f8e5827c24a22eae34bb7c635950b9b9f3c
valeriiaminikaeva/homework_python
/091021/time.py
1,421
4.03125
4
import datetime while True: date_ = input('Input the date in standard format DD/MM/YY: ') if date_ == ('q'): print('goodbye!') quit() day , month, year = date_.split('/') d = int(day) m = int(month) y = int(year) def checkfake(d): if not(0 < d < 32): pr...
24e134709ed3db9766bd87b94196681162323986
anjaligopi/leetcode
/daily_coding_challenge/october_2020/min_cost_to_move_chips_to_the_same_position_1217.py
1,544
4.1875
4
""" Question: We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position of the ith chip from position[i] to: position[i] + 2 or position[i] - 2 with cost = 0. position[i] + 1 or position[i] - 1 with cost = 1. Return...
3ddc5edaf705e501829d773be9aeb0bcb63d7a9a
iOSDevD/EMR_System
/utilities/Questionnaire.py
7,027
4.21875
4
""" Nikunj Upadhyay Class: CS 521 - Fall 1 Date: 10/16/2021 Homework Problem # Project Description of Problem (1-2 sentence summary in your own words): This program handles the questionnaire part. It can print the questionnaire summary using get_questionnaire_to_print() or generate a formatted string to which can be s...
f4712e0b76ee8fb88d54d52447ff2aee1cae74cd
prathamshrestha/assignment_1
/func15.py
149
3.546875
4
def filter_list(input_list): filter_even = filter(lambda x:x%2==0,input_list) return list(filter_even) print(filter_list([1,2,3,4,5,6,7,8]))
e9068e67fc48fddb8b42a90bfe2fa8851150c00b
akstt/LeetCode
/LeetCode/1-50/46_全排列.py
795
3.65625
4
class Solution: # 传入数字,依次放在第一位,将剩下的数字放到下次递归当中 def permute(self, nums: [int]) -> [[int]]: result_1 = [] for num in nums: nums_temp = nums.copy() nums_temp.remove(num) if len(nums_temp) > 0: # 将剩余数字的全排列并在num后面,组成全排列 results_retur...
fdbf71daa06bb8efedd5d791010bb3670f752303
stephenjjones/perceptron-python
/perceptron.py
2,340
4.0625
4
import numpy as np class Perceptron(object): """A perceptron classifier implementation Could be extended to use more than 2 classes by way of the One-vs-All technique Parameters: learn_rate (float): The learning rate between 0.0 and 1.0 epochs (int): The number of epochs/iterations o...
32baf246d2fe954d8128bde029dde918b1766825
MiroslavPK/Python-Advanced
/02 - Sets and tuples/Exercise/05-Phonebook.py
880
3.890625
4
phonebook = set() while True: tokens = input() if tokens.isdigit(): break name, phone_number = tokens.split('-') phonebook.add((name, phone_number)) for _ in range(int(tokens)): name = input() if not any(name in contact for contact in phonebook): print(f'Contact {name} does not...
723c9a23af13e41be2da20bfef84e20be13d2639
CapSOSkw/My_leetcode
/leetcode/205. Isomorphic Strings.py
1,178
4.03125
4
''' Given two strings s and t, determine if they are isomorphic. Two strings 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 the same character but a character ...
7bea8962649bdbb2a3074db92cc23efe431d2012
HelixPark/LeetCodeProjects
/60_PermutationSequence.py
645
3.765625
4
import math def getPermutation(n,k): res=[] nums=[i for i in range(1,n+1)] while n-1 >= 0: # num, k =k // math.factorial(n-1), k % math.factorial(n-1) num =k//math.factorial(n-1) k=k%math.factorial(n-1) if k>0: #不能整除,则只是当前的一个 res.append(str(nums[num])) ...
38682cd09e376b824df57b67178c086cfc93fd16
sachin156/Design-Patterns-Python
/Code/prototype.py
670
3.671875
4
import copy class Prototype: def __init__(self): self.objects={} def register_object(self,name,obj): self.objects[name]=obj def unregister_object(self,name): del self.objects[name] def clone(self,name,**attr): obj=copy.deepcopy(self.objects.get(name)) ...
e61f24141d59bf7b266f49222e4a78fd53d2f412
harry2002731/Stock-programe
/stock_list_convert.py
1,627
3.515625
4
import pandas import SQLserver """获取所有股票的名称和代码 ts_code--股票代码有SZ,SH symbol--股票代码无SZ,SH name--名称 area--所属区域 industry--行业 market--板块 list_date--上市日期""" class Dataframe_reader(): def __init__(self, df): self.df = df self.line_num = 0 self.length = 0 self.header_list ...
00a156fa107365c19fd58be7229f54577266b79f
denkho/CourseraPython
/week7/13_most_frequent_word.py
312
3.59375
4
fin = open('input_most_frequent_word.txt', 'r') text = fin.readlines() words = list() for line in text: words.extend(line.split()) count_words = dict() for word in words: count_words[word] = count_words.get(word, 0) + 1 print(sorted(count_words, key=lambda x: (-count_words[x], x))[0]) fin.close()
015629ef54451effa2870d7aff5485fcc60486f1
RakeshKumar045/Artificial_Intelligence_Complete_1
/Artificial_Intelligence/Complete_AI_DS_ML_DL_NLP/Complete-DS-ML-DL-PythonInterview/algorithms-master/breadth_first_search.py
873
3.8125
4
from collections import deque graph = {} graph['you'] = ['alice', 'bob', 'claire'] graph['alice'] = ['peggy'] graph['bob'] = ['anuj'] graph['claire'] = ['jonny', 'thom'] graph['peggy'] = [] graph['anuj'] = [] graph['jonny'] = [] graph['thom'] = [] def is_person_seller(name): '''look for a person using arbitrary ...
454b0abbaedaba6a710470ebcb75836691bb4be4
Clipboard-Karl/Sudoku-Fun-Project
/Sudoku_rev02.py
3,476
3.671875
4
# Sudoku_rev02.py - Sudoku Problem solver # # 20200730 - Successfully check and solving if a row has a single zero # Saving this and moving to Sudoku_rev03.py for columns :) # 20200729 - New revisoin because the code was working and I don't want # to mess that up when I introduce a do while ...
098a39ffe4fefd0c5334ad14ef3d62afed73f502
Anju-PT/pythonfilesproject
/collections/list/evenlist.py
73
3.546875
4
lst=[1,2,3,4,5,6,7,8,9,10] for i in lst: if(i%2==0): print(i)
7752321a231de0c258fd1de03c8a1895d60ed381
francescaser/https---github.com-francescaser-Sudoku
/creazMatrice.py
534
3.640625
4
import numpy as np import random sudoku=np.array([[1,2,3,4,5,6,7,8,9],[7,8,9,1,2,3,4,5,6],[9,7,8,2,3,1,6,4,5],[8,9,7,3,1,2,5,6,4],[2,3,1,6,4,5,8,9,7],[5,6,4,9,7,8,2,3,1],[3,1,2,5,6,4,9,7,8],[6,4,5,8,9,7,3,1,2]]) print(sudoku) for i in range(81): val1=random.randint(1,9) val2=random.randint(1,9) for i in...
450c49702667eea9288c5f28b9debbe6007f2278
pwgraham91/Python-Exercises
/compare triplets.py
399
3.734375
4
""" Given 2 lines: A: 5 6 7 B: 3 6 10 Compare by spots in line giving points to line A if it is higher and line B if it is higher and no points if they're tied Input: 5 6 7 3 6 10 Output: 1 1 """ a = [5, 6, 7] b = [3, 6, 10] a_points = 0 b_points = 0 for i in range(len(a)): if a[i] > b[i]: a_points += ...
5b07504b15981892e8efa4ad2be2d48a828b7a62
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_34/414.py
1,195
3.640625
4
#!/usr/bin/env python import sys file = open(sys.argv[1]) word_length, num_words, num_cases = map(int, file.readline().split()) def substrings(case): strings = [] paren_flag = False substring = '' for char in case: if char == '(': paren_flag = True substring = '' ...
3c9f06d8e97cde3c8ca808a1ed96c14ff3dbd8e1
ramdevcm/LinkedListPy
/main.py
1,651
3.765625
4
import copy class Node: def __init__(self, data): self.data = data self.next = None def __str__(self): return "Node[]: {}".format(self.data) class LinkedList: def __init__(self, data): self.head = Node(data) self.tail = None def getHead(self): return self.head def setHead(self,...
09c0bf4823cde25d52ca8a8c6a1e9aba15a03820
dustin181/javareference
/docs/python algorithms/mine/leetcode50/coin_change.py
432
3.59375
4
from typing import List def coinChange(coins: List[int], amount: int) -> int: if amount <= 0: return 0 if min(coins) > amount: return -1 dp = [0] + [float('inf')] * amount for coin in coins: for i in range(coin, amount + 1): dp[i] = min(dp[i], dp[i - coin] + 1) ...
9823ca8948ae57f964c8537d5fe883f9f0f45f0a
aryajar/practice-in-7-23
/number100.py
155
4.1875
4
number = int(input("Enter a number: ")) if number < 100: print("the number less than 100") else: print("the number not less than 100")
ba7b3357e4215ab413a6b238d7ee557a164fa2c6
Crypto0/Crypt0Lib-V1
/crypt0/base/decimal_ascii.py
277
3.796875
4
import re def decimal_to_ascii(decimal): try: s = re.sub('3[2-9]|[4-9][0-9]|1[0-1][0-9]|12[0-6]', r' \g<0>', decimal) ascii = ''.join(chr(int(x)) for x in s.split()) return ascii except ValueError: return "Sorry! This is not a Decimal."
47c99b6c992c6cfe74660805fd1bab2f29d5ea26
qordpffla12/p1_201011101
/sumList.py
192
3.53125
4
 def sumList(list): sum=0 for i in range(0, len(list)): sum+=list[i] return sum def lab7(): x=[1,2,3] mysum=sumList(x) print mysum def main() lab7()
f5badb09ea0012dac635957de6e66bb0134b1775
lalobaez120304/actividad-1-y-2
/diccionarios.py
1,388
4.34375
4
""" ES una lista de pares de elementos con estructura clave:valor No se accesa a los elementos por posicion, sino por el valor de su clave La clave puede ser de cualquier tipo imutable (bolean, integer, string, etc.) Se delimita con {} A un diccionario se le refiere tambien como dict """ #creacion de diccionar...
65646568cb9efe59355dd5dbb3cc36dcfb7dbae3
tashakim/puzzles_python
/min_stack.py
545
3.859375
4
class MinStack: """Purpose: Design a stack which, in addition to pop and push, has a function min that returns the minimum element in O(1). (CTCIpg98_3.2) """ def __init__(self): self._data = [] self._min = float('inf') return def pop(self): """Runtime: O(1). """ # raise EmptyStackException if empt...
6e26c1666d84a4c2972a585ec950ce37b169e3f0
clouds16/intro-python
/week6/unique_list.py
656
3.8125
4
class Sequence: def createList(self): usernumbers = [] usernumbers.append((int(input("Enter the first number: ")))) while True: userinput = int(input("Next: ")) if userinput != -1 : usernumbers.append(userinput) else: break...
1b388de0457eeaaf76b7eeb44a1683565852e38d
codeAligned/codewar-python
/6.py
1,119
3.640625
4
# https://www.codewars.com/kata/57814d79a56c88e3e0000786/train/python def encrypt_hzzz(text, n): print(text, n) if n <= 0: return text for j in range(n): lst = [text[i] for i in range(len(text)) if i % 2] lst += [text[i] for i in range(len(text)) if not i % 2] text = ''.join...
61953f67e2923a32770192db955dc8cfe8e993de
TomiSar/ProgrammingMOOC2020
/osa07-06_salasanan_arpoja_2/src/salasanan_arpoja2.py
1,153
3.546875
4
from random import choice, randint from string import ascii_lowercase, digits def luo_hyva_salasana(pituus: int, numero: bool, erikoismerkki: bool): erikoismerkit = "!?=+-()#" # alkuun yksi kirjain salasana = choice(ascii_lowercase) arvontajoukko = ascii_lowercase # Jos halutaan numeroit...
659865fa15adca3e57d1fd443dca223d9ebed17e
rohitjenveja/sample_django_trie
/vsnlookup/validation.py
1,677
3.546875
4
#!/usr/bin/python """Server-side validation logic that can be used before creating, updating, or reading from a data source. In addition to server side validation logic, there is also client-side validation in the javascript. """ __author__ = "rjenveja@gmail.com (Rohit Jenveja)" import re VALIDATE_REGEX =...
8918ae1c0d2a79307a933e59c29ef26d27d3a347
swang2000/DP
/maxsubonematrix.py
816
3.734375
4
''' Maximum size square sub-matrix with all 1s 3.3 Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix. maximum-size-square-sub-matrix-with-all-1s ''' import numpy as np def maxonematrix(a): r,c = a.shape smatrix = np.zeros((r, c)) ...
cc573d4800f8a697e1eb6ce005b0a21dfb6853f1
jkoppel/QuixBugs
/correct_python_programs/quicksort.py
470
4.09375
4
def quicksort(arr): if not arr: return [] pivot = arr[0] lesser = quicksort([x for x in arr[1:] if x < pivot]) greater = quicksort([x for x in arr[1:] if x >= pivot]) return lesser + [pivot] + greater """ def quicksort(arr): if not arr: return [] pivot = arr[0] lesser...
1ba7588886a47524678c16a9bf989bc529cd8c66
kbudukiewicz/ASEiED_project
/test_pandas.py
1,710
4.21875
4
""" Test program to load data from .csv and get the average speed of the month. """ import pandas as pd def read_data(file: str) -> pd.DataFrame: """Get data from csv file. Args: file: name of the file Returns Dataframe with use columns. """ df = pd.read_csv( file, usecols...