blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
03cf74ca321ee100a1efcd1028cd59d0a7b56449
JoseCordobaEAN/ProgramacionEAN20191
/semana_17/Fruta.py
1,670
4.1875
4
class Fruta: sabor = '' cantidad = 0 pelada = False __TIPOS__ = {'banano': [5, 100], 'manzana': [6, 50], 'pera': [5, 70], 'piña': [60, 1500], 'papaya': [130, 2200] } def __init__(self, sabor, cantidad): "...
7c6de1a61795f5db82a9d779308299a49ec4296b
CodeThales/Blue_Ed_Tech_Python
/Aula 06 - Funções - Parte1/Ex04.py
670
3.96875
4
#Faça um programa que calcule o salário de um colaborador na empresa XYZ. #O salário é pago conforme a quantidade de horas trabalhadas. # Quando um funcionário trabalha mais de 40 horas ele recebe um adicional # de 1.5 nas horas extras trabalhadas. def salario(horas,valor_hora): if horas > 40: h_ex...
1dfb293002adb33e9ab64aa04b2c13d147501cc2
hakank/hakank
/cpmpy/four_numbers.py
2,040
3.53125
4
""" Four number problem in cpmpy. From http://stackoverflow.com/questions/17720465/given-4-numbers-of-array-of-1-to-10-elements-find-3-numbers-whose-sum-can-gener 'Given 4 numbers of array of 1 to 10 elements. Find 3 numbers whose sum can generate all the four numbers?' ''' I am given an array containing a list of 4...
129c52f7ce8972ed3ce5a1a340c297956b9529af
Frankyyoung24/SequencingDataScientist
/Algrithms/week4/brute_force.py
553
3.828125
4
import itertools as it from overlap import overlap def scs(ss): # ss means the set of strings shortest_sup = None # the permutations function is very useful for ssperm in it.permutations(ss): sup = ssperm[0] for i in range(len(ss) - 1): olen = overlap(ssperm[i], ssperm[i + 1]...
e623a3ad436693c332544633e53eb2561daefa41
aepuripraveenkumar/Data-structures-and-algorithms-in-python-by-michael-goodrich
/R-1.6.py
238
4.3125
4
'''Python code to find sum of odd positive integers''' def sum_of_squares_of_odd_positive_integers(n): return sum((i*i) for i in range(1,n,2) if(n>=0)) if __name__=='__main__': print(sum_of_squares_of_odd_positive_integers(5))
674f03b064431907392afc619fba103c325294fa
biobeth/snake_club
/resources/5.functions_and_imports/is even.py
102
3.59375
4
def is_even(n): if n/2 == True: print True else: print False is_even(6)
4cff30390fb7234047e592f02cfbe0d9f7045f4f
OneGuyy/python-syntaxes
/LISTS.py
772
3.75
4
import random import sys import os grocery_list = ['Juice', 'Tomatoes', 'Apples', 'Eggs'] print('First Item is', grocery_list[0]) grocery_list[0] = "Soda" print('First Item is', grocery_list[0]) print(grocery_list[1:3]) other_events = ['Wash Car', 'Cash Check', 'City Tour'] to_do_list = [other_even...
a50a50425a1c92f9105e9e0b4ffffee4053d1087
manjot-baj/My_Python_Django
/Python Programs/Decorators_5.py
500
3.703125
4
from functools import wraps def only_int_allow(Function): def wrapper(*args, **kwargs): Data_types = [] for arg in args: Data_types.append(type(arg) == int) if all(Data_types): return Function(*args, **kwargs) else: return "Invalid input" re...
41dcf1fc27367972330271aa33d0ac791457e69c
ErmantrautJoel/Python
/Buscar en lista.py
320
3.796875
4
def buscarenlista(): n = int(input("Digame la cantidad de palabras:")) lista = [] for nn in range(1,n+1): print ("Digame la palabra",nn,":",end=" ") n2 = input() lista += [n2] s = input("Digame la palabra a buscar:") n = lista.count(s) print ("La palabra",s,"aparece",n,"veces") buscarenlista()
ad45e9398df0da8ae425c9ebf788781893622399
xCrypt0r/Baekjoon
/src/9/9366.py
552
3.546875
4
""" 9366. 삼각형 분류 작성자: xCrypt0r 언어: Python 3 사용 메모리: 29,380 KB 소요 시간: 68 ms 해결 날짜: 2020년 9월 23일 """ import sys def main(): for i in range(1, int(input()) + 1): A, B, C = sorted(map(int, sys.stdin.readline().split())) if A + B <= C: print(f'Case #{i}: invalid!') else: ...
0ba28f868a736f6d4321a43a69f91a6f22cfe4aa
Shehaab/CodeSignal
/FindEmailDomain.py
252
3.65625
4
import re def findEmailDomain(address): """Return the legitimate domain part of an Email address""" # Find @ sign, then one or more alphanumeric character, then one or more dots. return re.search("@[\w].+",address).group()[1:]
f33d7c318e22be05e8b33b60613b9fb4356fe9a1
rudasi/euler
/euler15.py
630
3.765625
4
factorial_hash = {} def factorial(n): if (n in factorial_hash.keys()): return factorial_hash[n] elif (n == 0 or n == 1): factorial_hash[n] = 1 return 1 else: val = factorial(n-1) * n factorial_hash[n] = val return val def combinations(a,b): return (factorial_ha...
c22d96e5287b81135c7e627afe67c0b82ae8ca0a
Lenferd/deep-learning-course
/Lab 1/tests.py
1,864
3.609375
4
import unittest import numpy as np class TestNumpy(unittest.TestCase): def test_generate_array(self): arr = np.array([2, 2], float) print("test_generate_array\n {}".format(arr)) def test_matrix_not_rec_creation(self): matrix = np.matrix([[1, 2], [3, 4]]) print("test_matrix_not_...
ff4071d28e245e705aece238b955e94c95dd502a
sakshirits/python-automation-scripts
/collatzSequence.py
352
4.0625
4
def collatz(n): if n%2==0: return n//2 else: return 3*n+1 def main(): try: n=int(input("Enter the number:")) d=n while True: val = collatz(d) print(val) d = val if val == 1: break except ValueError: print(" You must ...
917f79b4b2b5c9b02e1b7e8831d0b4310828dd5c
suziW/KBQA
/porg.py
708
3.640625
4
import argparse parser = argparse.ArgumentParser(description='search related things(movie,music or book) you might wanna know') parser.add_argument('input', type = str, help = 'input what u wanna search') parser.add_argument('-s','--specify_search', type = str, choices=['movie', 'music', 'book'], ...
1020fb02ec9bd90e946e3d1d8ce4467a3bce273a
NavneetKourSidhu/Python
/basics/armstrong.py
218
4.125
4
number = int(input('number: ')) sum = 0 temp = number while temp > 0: cube = temp % 10 sum += cube**3 temp //= 10 if number == sum: print('armstrong number') else: print('not a armstrong number')
c8e0c3526115aec4ae205ac77db4de6750de6723
nedbat/blogtools
/PathGlob.py
1,468
3.5625
4
""" Filename globbing utility. """ import os import fnmatch import re __all__ = ["glob"] def glob(pathname, deep=0): """ Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. """ result = [] if not hasMagic(pathname): ...
b516a195c118762d2a8506588b92833857eb88a4
dsbatov/PythonHSE
/lesson1.py
192
3.90625
4
number = int(input()) print("Следующее за " + str(number) + " число: " + str(number + 1)) print("Предыдущее до " + str(number) + " число: " + str(number - 1))
88698e0b3841c45d1661dd69e99864b7b658d9c8
kiyohiro8/Lombardia
/control.py
18,301
3.609375
4
#ゲームの操作に関する関数をここに格納 #捨て札を山札に混ぜて切り直す関数 def reshuffle(library, graveyard): import random while len(graveyard) > 0: library.append(graveyard.pop()) random.shuffle(library) #一般ドロー関数の定義 def general_draw(player, opponent, library, graveyard): from AI import draw_priority #公開される3枚のカード o...
452785019f14a79c1eacec65d85a61399daa8e91
vadsimus/Python
/HackerRank/Python Challenge/Piling Up!.py
425
3.59375
4
# https://www.hackerrank.com/challenges/piling-up/problem n = int(input()) for _ in range(n): answer = True input() line = list(map(int, input().split())) while len(line) > 1: if line[0] >= line[1]: del line[0] continue elif line[-1] >= line[-2]: del...
9e85691042d8875534553d284090f9989a4baab0
elahea2020/6.00
/6.0001PSET/PSET4/part_a/test_ps4a.py
6,712
3.609375
4
# for running unit tests on 6.00/6.0001/6.0002 student code import unittest import ps4a as student # A class that inherits from unittest.TestCase, where each function # is a test you want to run on the student's code. For a full description # plus a list of all the possible assert methods you can use, see the # docum...
66bc35080051c02d611ab2fc1295eda2aaa8d747
ysei/project-euler
/pr026.py
1,712
4.0625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: 1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = 0.(1) 1/10 = 0.1 W...
d1ba360f29a7adde24062172272a7d27e50c1b16
ApurvaJogal/python_Assignments
/Assignment6/Assignment6_1.py
1,025
4.4375
4
#Write a program which contains one class named as Demo. #Demo class contains two instance variables as no1 ,no2. #That class contains one class variable as Value. #There are two instance methods of class as Fun and Gun which displays values of instance variables. #Initialise instance variable in init method by accepti...
d75f8ddd111330678d913425a33d662b270026fd
Kamil-Jan/LeetCode
/medium/ZigZagConversion.py
892
3.5625
4
def convert_border_row(s, i, numRows): convertion = "" step = 2 * (numRows - 1) for j in range(i, len(s), step): convertion += s[j] return convertion class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == 1: return s convertion = convert_bo...
ad66f5c67364e3b3a5355857e7f9ad3d4cf9293b
woochan-hwang/Algorithms-DS-Practice
/Linked Lists/loopdetect.py
1,577
3.921875
4
# Write a code to detect the beginning of a loop in a singly linked list # Standard Python implementation of Node object class Node: def __init__(self, x): self.val = x self.next = None class Solution: def __init__(self, dummy = 0): self.dummy_head = Node(dummy) # Loop back from...
9f60ccd490cce516c3fb192b806bd02635d59a33
nyctigers007/interviewer
/datastructures/bst.py
1,717
3.71875
4
# jian li implemented July 5, 2019 class Node (): def __init__(self, val): self.data = val self.right = None self.left = None class binaryTree(): def __init__(self): self.root = None def insert(self, root, val): newnode = Node(val) if self.root == None: ...
1d7dd2cba6277ba405e9e8d23d73b5d9897f293e
Parizval/CodeChefCodes
/Python/Beginner/FBMT.py
506
3.765625
4
for a in range(int(input())): n = int(input()) if n == 0 : print("Draw") else: TeamA = input() ScoreA= 1 ScoreB = 0 TeamB = "" for i in range(n-1): j = input() if j == TeamA: ScoreA += 1 else: ...
f9bf1622e964f5746de6f4f47fa0c1931c43e771
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/INTERVIEW-PREP-COMPLETE/Leetcode/56.py
501
3.53125
4
class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: if not intervals: return [] if len(intervals) < 2: return intervals intervals = sorted(intervals, key=lambda x: x[0]) stack = [] for interval in intervals: if s...
5cbda72d1faef442e81fdef088160c86a66e6f32
ucandoitrohit/Python3
/Python_Basic_script/Python_Basic/12.set.py
170
3.53125
4
s = set() print(type(s)) xyz = set([1,2,3,4]) print(xyz) print(type(xyz)) num = set() num.add(1) num.add(2) s.union({3,4}) num1= s.union({3,4}) print(num) print(num1)
f80548226f3427819193c323cdcbc2047a29490c
maymashd/webdev2019
/week10/CodeingBat/logic-1/date-fashion.py
169
4.125
4
def f(a,b): if a>=8 or b>=8: return 2 elif a<=2 or b<=2: return 0 else: return 1 a=int(input()) b=int(input()) print(f(a,b))
b4ff9dcf5c6e5da9770ae6a6be6e36fd0fbd3d2c
Piachonkin-Alex/EarleyAlgo
/app/main.py
3,751
3.515625
4
# terminals - a-z # non-terminals A-Z # start - non-terminal S # empty symbol is an empty string class Rule: def __init__(self, left_side: str, right_side: str): self.lhs = left_side self.rhs = right_side class Situation: def __init__(self, left_side: str, right_side: str, point_cord: int, off...
092b060118b68c9d4460e4a1732e9fc4a05096b4
MannyIOI/Competitive-Programming
/Week-2/Day-1/intersection.py
244
3.890625
4
class Solution: def intersection(self, nums1, nums2): intersection = [] for i in nums1: if i in nums2 and i not in intersection: intersection.append(i) return intersection
0a0168a9c5d45ffde0572545efad7b9734a97c38
YahyaQandel/CodeforcesProblems
/Boy_or_Girl.py
114
3.71875
4
username = input() s = "".join(set(username)) if len(s)%2 == 0: print("CHAT WITH HER!") else: print("IGNORE HIM!")
1d63cea4cfb0bfe50daad29c54d14aebcc12a960
FoxGriVer/PythonLabs
/lab4/list_utils.py
556
3.828125
4
def last(l): return l[-1] def middle(l): try: if(len(l) % 2 == 0): raise Exception("Number of elements in the list is not odd") middleIndex = int((len(l) - 1)/2) return l[middleIndex] except Exception as e: print(e) def product(l): result = 1 for...
233b063498df464c7aa3f104966c021be31c4a3a
sonivaibhav27/Data-Structure
/BST/DrawBSTFromPreorder.py
1,369
3.84375
4
class Node: def __init__(self,data): self.data= data self.left =None self.right=None class BST: def __init__(self): self.root =None def insertElement(self,dataOfArr): self.root= Node(dataOfArr[0]) i = 1 while i < len(dataOfArr): i...
c281b52abd61ddb9bd091ecabf4223ddbced2694
jasontwright/coursera
/pythonlearn/week08/split.py
100
3.984375
4
abc = 'With three words' stuff = abc.split() print stuff print stuff[0] for w in stuff : print w
355869fff1a459757a34e47e39fe1a4f276f2626
viethngn/Bloxorz-Game-AI
/searchBiDir.py
4,559
3.5625
4
from display import Displayable, visualize from searchProblem import Path, Arc from searchGeneric import Searcher class BidirectionalSeacher(Searcher): """returns a searcher for a problem. Paths can be found by repeatedly calling search(). This does depth-first search unless overridden """ def...
be6e4323fff5bf526e0b08412ff9ced119bb066a
JonLevin25/coding-problems
/daily-coding-problems/problem001/solution/solution.py
398
3.5
4
from typing import List def solve(arr: List[int], k: int) -> bool: missing_nums = set() for n in arr: if n in missing_nums: return True # Calculate the number needed to sum with n (and get our target k) # add this to a hash set that we can compare later missing_dif...
5bb29e31c340ee1983a8aaeecd28cfe10351680f
moonlimb/scheme_to_js_translator
/xml_to_js/helper/decorate.py
711
3.828125
4
# file containing decorator / helper functions # Q: Use decorators/wrapper function to add curly braces? def make_fcn(fn): def wrapper(): return fn() + "()" return wrapper def add_parens(fn): def wrapper(): return "(" + fn() + ")" return wrapper def add_curly_braces(content): def wrapper(): return "{" + ...
21ceb3902e962f4bcc4cdd1e8879e8b48f0048d0
Altynaila/homework-month1
/lesson3/lesson3.1.py
392
3.984375
4
age = int(input()) if age > 18: name = input() if name == "Daniiar": hobby == input() if hobby == "drawing": print("Вы не умеете петь") else: print("Вы умеете петь") print("Вас зовут Данияр") else: print("Вы не Данииияр") else: print("Вам ...
aeb30d508701c06925a062a9deb99eeb3c70c7f6
srajsonu/InterviewBit-Solution-Python
/Maths/Maths III/palindrome_integer.py
598
3.671875
4
class Solution: def Solve(self, A): divisor = 1 while A / divisor >= 10: divisor *= 10 while A: leading = A // divisor trailing = A % 10 if leading != trailing: return 0 # Removing the leading and # tr...
21301ed824f9b48d0285cbe0e2d35889d391ff2a
gosch/Katas-in-python
/2018/august/codesignal/minesweeper.py
809
3.53125
4
def minesweeper(matrix): res = [] top = [False] * (len(matrix[0]) + 2) down = top[:] matrix_temp = [] matrix_temp.append(top) for i in matrix: matrix_temp.append([False] + i[:] + [False]) matrix_temp.append(down) for i in range(1, len(matrix_temp) - 1): row = [] ...
f870d5f3ad6909cff78e009cbf572d5d3db53a36
sayalichakradeo/class-work
/8.4.py
202
3.890625
4
fhand = open("romeo.txt") my_list=list() for line in fhand: line = line.lower() words = line.split() for word in words: if word not in my_list: my_list.append(word) my_list.sort() print(my_list)
257f01af2442f2ffacc35d4fe2672eff27bb00b3
linvieson/json-navigator
/json_navigator.py
2,909
4.4375
4
''' This module gets the json file from the user. It asks a user, which part of the json object he or she wants to see and outputs its value. ''' import json def get_json() -> dict: ''' Make a get request on a server. Return json object as a python dictionary. ''' path = input('Enter a path to json fil...
e583f00f298fb7e4cbe49cfb28526044c7b08f88
verde-green/NLP_100
/Chapter1/nlp_06.py
519
3.546875
4
# -*- coding: utf-8 -*- def n_gram(obj, n): return [obj[i:i+n:] for i in range(len(obj) - n + 1)] if __name__ == "__main__": text = ["paraparaparadise", "paragraph"] X = set(n_gram(text[0], 2)) Y = set(n_gram(text[1], 2)) se = ["True" if "se" in X else "False", "True" if "se" in Y else "False"] ...
f35f74649e6a42d00cc03a4079cb9b9f0ba02047
akshaytiwari0203/python_3
/06_LoopingInPython/for_test.py
168
4.28125
4
limit=int(input("Enter upper bound: ")) for num in range(1,limit) : print(f" {num} \n") string=input("Enter a string: ") for char in string : print(char + "\n")
e1d52d6f91555c9a29cd8fa75d8b71e927fdac85
caolina1314/UI-test
/8_def.py
1,964
4.1875
4
# 在python中用def关键字来定义函数,后接函数标识符名称和圆括号() # return[表达式]结束函数,选择性地返回一个值给调用方。不带表达式的return相当于返回None ''' 语法: def function name(parameters): "函数_文档字符串" function_suite return [expression] 或 def my_abs(x): if x >= 0: return x else: return -x ''' ''' # 定义add()函数 def add (a,b):...
396da1c0337b3b13ae7cbc1c2503c23c758135c5
nathanesau/AdventOfCode
/day2/problem2.py
1,149
3.53125
4
# https://adventofcode.com/2019/day/2#part2 OPCODE_ADD = 1 OPCODE_MULTIPLY = 2 OPCODE_FINISHED = 99 def get_output(arr, noun, verb): arr[1] = noun arr[2] = verb for op_index in range(0, len(arr), 4): opcode = arr[op_index] if opcode is OPCODE_ADD: arr[arr[op_index + 3]] = arr[...
56d157b267f13ab2f733da71e7aa2ec4ac4cc026
zischuros/Introduction-To-Computer-Science-JPGITHUB1519
/Lesson 1 - How to get Started/Selecting sub-sequencies/sub-sequencies.py
254
3.625
4
string = "programacion" # string [start : stop-1] print string[0:8] print string [5:] #from start to end print string [:6] #from begin to stop print string [5:5] # do not exist print string[:] # from begin to end input()
a405a3a5ee50ca4a31393390786eb3cc1b986925
fransHalason/IndonesiaAI
/Basic Python/Part 4 - Python Data Types/default.py
323
4.40625
4
''' PYTHON: FUNCTION DEFAULT PARAMETER Python allows function arguments to have default values. If the function is called without the argument, the argument gets its default value. The default value is assigned by using assignment(=) operator. ''' def my_function(name=""): print("Hello " + name) my_function("Jame...
3a7abc7dad839ee448a8f89b75fec61ac2baf4f8
bozhikovstanislav/Python-Fundamentals
/PythonIntroFunc_debug/06.RiseNumberOnNumber.py
212
3.875
4
def rise_number(base_number: float, number_to_rise: float) -> float: return base_number ** number_to_rise number_one = input() number_tow = input() print(rise_number(float(number_one), float(number_tow)))
1c8c97afb4977a500ba6914d0e819b20f37724b0
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/1015.py
1,021
3.71875
4
import math import sys def is_palindrome(s): s=str(s) for i in range(0, len(s)//2): if (s[i] != s[len(s)-i-1]): return False return True #source: http://stackoverflow.com/questions/2489435/how-could-i-check-if-a-number-is-a-perfect-square # - "Babylonian algorithm" def is_square(apositiveint): if( apositive...
2c4fde429af0dbfdf9c32e52fcacc58eae71fc5e
dmehta504/DecisionTrees-RandomForests
/submission.py
26,219
3.53125
4
import numpy as np from collections import Counter import time class DecisionNode: """Class to represent a single node in a decision tree.""" def __init__(self, left, right, decision_function, class_label=None): """Create a decision function to select between left and right nodes. Note: In th...
65e225411c7a8f1fd5179b13d2aa825668e5d651
yusufazishty/Kaggle-WDI-Mining
/Energy/A_energy_fetching.py
9,147
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu May 26 11:19:05 2016 @author: yusufazishty """ #For converting the sqlite to the json files, the dataframe in spark need json inputs import sqlite3 as lite import sys import json import copy from pprint import pprint # fetch from sqlite data def fetch_db(quer...
24f444f8c0bc2a8f6b7133a31e97fef2dad6e94f
Shruti280598/simple-chat-bot
/chat.py
1,265
3.796875
4
# simple-chat-bot import random import sys Questions = [ "How to use firefighting robot ?", "what care should ?", "for what purpose it can use" ] Answers = [ "First fill container of robot which will help to extinguise fire then switch on it's batttery to give power to the robot to work .", "kee...
42426643e0b17b4e407d8ef4bff1301b7ce2034f
pdst-lccs/lccs-python
/Section 6 - Modular Programming/Breakout 6.4 Check Digits/extractDigit - 2 digits.py
344
3.734375
4
# Event: LCCS Python Fundamental Skills Workshop # Date: Dec 2018 # Author: Joe English, PDST # eMail: computerscience@pdst.ie # Breakout 6.4 Check digits # Extract the digits from a 2 digit number n = int(input("Enter a 2 digit number: ")) d2 = n%10 # %10 extracts the final digit d1 = n//10 # //...
6aac8b7973cb7a70a86215d3bb18f730f1e7c595
neralwar/Python-Training
/Python Programming Basics/bubblesort.py
298
3.96875
4
#Bubble Sort def bubblesort(itmelist): for i in range(len(itmelist)): for i in range(0,len(itmelist)-i-1): if itmelist[i] > itmelist[i+1]: itmelist[i],itmelist[i+1] = itmelist[i+1],itmelist[i] print(itmelist) listitem = [1,4,3,6,15,18,19,0,17] bubblesort(listitem)
0ae8f744ccf3cd9cfbd88f6f010c2c2e506bf043
markhend/pe
/python/66.py
1,189
3.609375
4
from math import factorial, sqrt from time import time t = time() squares = {x*x for x in range(1,10**6)} sol = dict() for D in range(998,997,-1): if D in squares: continue print "D is", D, x = 1 while True: x += 1 y2 = divmod((x*x-1), D) print y2 input() if y...
a149133d2b3c56dd3c187f69fce5f5792ea58dd8
swdrich/python-challenge
/PyPoll/main.py
3,729
3.90625
4
#Import modules import os import csv #Don't panic, something is happening. print("Calculating...") #Establish file path csv_path = os.path.join("Resources","election_data.csv") #print(csv_path) #read CSV # Open the CSV with open(csv_path) as csv_file: election_data = csv.reader(csv_file, delimiter=",") #prin...
bda6756d7cff2f90513e717a7428b61842b041d8
vivver4/Python_Spider
/验证码的识别/普通图形验证码.py
748
3.578125
4
''' 安装tesserocr的时候用pip intall tesserocr pillow总是发生错误,用 conda install -c simonflueckiger tesserocr可以成功,-c直接从https://conda.anaconda.org搜索 simonflueckiger的tesserocr库安装 这个内容需要复制到C盘符下的scratch.py中运行,具体原因不清楚 ''' import tesserocr from PIL import Image image=Image.open('C:/Users/shangya/Desktop/a.jpg') ''' 转灰度处理 ''' image=im...
a67d89b8d8396f2ccfebac170e867427a557e471
SoloExitus/SANDPT
/Task2.py
418
3.734375
4
def is_numeric(x): if type(x) == int or type(x) == float: return True return False def coincidence(*args) -> list: res = [] if len(args) < 2: return res array = args[0] range = args[1] min = range[0] max = range[len(range) - 1] + 1 for x in array: if (is_n...
ac1b06a6d15c6c16b49c6fbb6a7e0c87810d156f
jinhyun-so/CodedPrivateNN
/models/activ_func.py
5,005
4.03125
4
import torch from torch import nn import torch.nn.functional as F from torch.nn.parameter import Parameter # import Parameter to create custom activations with learnable parameters # simply define a silu function def silu(input): ''' Applies the Sigmoid Linear Unit (SiLU) function element-wise: SiLU(x)...
d70165ce93014d5baaa9610b284daea03fa59fe2
Ummyers/ProbabilidadPython
/MemoProgramas/UsuarioProba.py
371
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 26 17:04:14 2020 Curso introductorio de Proba para python. @author: ummyers """ while True: try: entero = int(input("Ingresa un número: ")) except ValueError: print("Ingresaste un número inválido") else: print("Ele...
1b8d8aa0f8caf88106d09b0248fa05453ece622e
GitSeob/programmers
/all/lv1/secret_map.py
468
3.65625
4
def solution(n, arr1, arr2): res = [] for a, b in zip(arr1, arr2): line = '' div = 2**(n-1) # print(a, b) for _ in range(n): if a // div > 0 or b // div > 0: line += '#' else: line += ' ' a = a%div b = b%div div = div//2 res.append(line) return res arr1 = [9, 20, 28, 18, 11] arr2 = ...
93e61f82256ef3cd620315b19d60ddc8b88716e5
dongupak/Basic-Python-Programming
/Ch20_Coding/coding_stype_bad.py
524
3.5625
4
# ( a * x^2 ) + ( b * x ) + c = 0 # a != 0 인 x에 관한 2차 방정식, 근의 공식으로 해 구하기 # 매개변수를 사용해서 해를 출력해 봅시다 def get_root( a, b, c) : r1 = (-b + (b ** 2 - 4 * a * c ) ** 0.5)/ (2 * a) r2 = (-b - (b ** 2 - 4 * a * c) ** 0.5)/( 2*a ) return r1 , r2 # 함수 호출시 인자를 상수값을 사용함 # result1, result2를 이용해서 결과값을 반환 받아온다 result1...
a5e572307bac8170cdc13454131fb95fff5b1ee1
cpeixin/leetcode-bbbbrent
/linklist/LRUCache.py
3,308
3.828125
4
""" https://github.com/wangzheng0822/algo/blob/master/python/06_linkedlist/LRUCache.py """ class DbListNode(object): def __init__(self, x, y): """ 节点为哈希表+双向链表 :param x: :param y: """ self.key = x self.value = y self.next = None self.prev = Non...
ce3af49196e4413c9806f348444cef3b1477cdc7
vrushti-mody/Leetcode-Solutions
/Reverse_Bits.py
249
3.5625
4
# Reverse bits of a given 32 bits unsigned integer. n=str(bin(n)) a="" for i in range(0,len(n)-2): a = a + n[len(n)-i-1] for i in range(len(n)-2,32): a=a+"0" print(a) return int(a,2)
72cee0bbc26a869d04a25f40584f571f67e67f6f
MajkelT/Python_Bootcamp_ALX_03102018
/Collections/Zadanie #1.py
220
3.875
4
x=(1,2,3,4,5,6,7,8,9,10) print(x[1]) #drugi element print(x[-2]) #przedostatni element print(x[2:7]) #elementy od trzeciego do siódmego print(x[::3]) #co trzeci element print(x[::-2]) #co drugi element licząc od końca
d11da144abcdce75b0bf8803edc827f0f5740abc
GabeAboy/PythonScripts
/NewLine.py
226
3.640625
4
x = 'There is a dog and fox fighting in the park and there is an apple falling down.' x = x.split(' ')#insert veriable for i,word in enumerate(x): if i != 0 and i % 3 == 0: x[i] = word + '\n' print ' '.join(x)
54f3e7d61e6610ddaf8374f2a1841d0ea37817dd
ProgrammingMuffin/major
/filter.py
347
3.78125
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize def removeStopWords(sentence): words = word_tokenize(sentence) stopWords = set(stopwords.words('english')) newWords = [word for word in words if not word in stopWords] return newWords def extractUselessWords(words): #handle...
65a9de9c8f70b3bae2bfa0c58a720c2cad9380b3
bowmanjd/pycsvdemo
/simplereader.py
299
3.5625
4
import csv from pathlib import Path inpath = Path("sample.csv") with inpath.open("r", newline="", encoding="utf-8-sig") as infile: reader = csv.DictReader(infile) for row in reader: fullname = f"{row['First name']} {row['Middle name']} {row['Last name']}" print(fullname)
5a79d217ef029e7ba047358526e7408423855066
demlook/Python_test
/testcode/function.py
5,679
4.03125
4
#函数 def favorite_book(book): print("One of my favorite book is " + book + ".") favorite_book('Alice in Wonderland') ############################################### # 1 位置实参,顺序必须与形参一致 def make_shirt(size,phrase): print("This T-shirt's size is " + size + ".") print("Imprinted phrase is " + "\"" + phrase + "\"") make...
dee96038457eb3f2c39173409ef7d367750b21a5
dan88934/portfo
/server.py
2,551
3.609375
4
from flask import Flask, render_template, url_for, request, redirect import csv app = Flask(__name__) #Here we use the flask class to instantiate an app print(__name__) #Frameworks give us a higher level of abstraction - meaning t #-hat we don't need to know what the code is doing underneigh #We just need to know tha...
35bccdcf6bbbc5fb7519e6db032b9df30a80a5bf
silvervulpus/storage
/myprogram2.py
957
4
4
''' def age_foo(age): new_age = (age) + 50 return new_age age = float(input("Enter your age?: ")) if age < 150: print(age_foo(age)) else: print ("You are far too old") ''' def Cel_to_Fahr(c): if c <= -273.15: return ("Invalid Input") else: f = c*9/5 + 32 return f temp...
8b8aafca9ef3b3384231ca7e4cbf6dbbfcae187c
rciurlea/py-ctci
/1.2.py
615
3.96875
4
# Check Permutation: Given two strings, write a method # to decide if one is a permutation of the other. def is_perm(a, b): chars = {} for c in a: if c in chars: chars[c] += 1 else: chars[c] = 1 for c in b: if c in chars: chars[c] -= 1 els...
5ec42e033170261361700e31540afddb8f14b9b5
arnabs542/Data-Structures-And-Algorithms
/Bit Manipulation/Different Bits Sum Pairwise.py
1,399
3.765625
4
""" Different Bits Sum Pairwise Problem Description We define f(X, Y) as number of different corresponding bits in binary representation of X and Y. For example, f(2, 7) = 2, since binary representation of 2 and 7 are 010 and 111,respectively. The first and the third bit differ, so f(2, 7) = 2. You are given an ar...
01ca8a939f2b04bf6f4628418703d61050499ceb
jaybhanushali3195/Datapreprocessing-Visualization-Tutorials
/data cleaning/chapter5/FillMissingValues.py
272
3.5
4
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(2, 2), index=['1', '3'], columns=['key_1', 'val_1'] ) df = df.reindex(['1', '2']) print(df) print("NaN replaced with '0':") print(df.fillna(0))
36b18f675eb648774a6e8af2fef79123024e4ff8
goutkannan/HackerRank
/python/design_pattern/decorator.py
438
3.875
4
import time def timeit(func): def decorated(*args,**kwargs): start = time.time() result = func(*args,**kwargs) end = float(time.time() -start) print("Ran in seconds",end) return result return decorated #typical decorator usage @timeit def factorial(num): fact =1 ...
0e00dd96a21b54913d9e79fb869e3ebf26d5b30b
kibazohb/Leetcode-Grind
/Medium/similarSentences/solution_01.py
1,255
3.59375
4
from collections import defaultdict class Solution: def areSentencesSimilarTwo(self, words1: List[str], words2: List[str], pairs: List[List[str]]) -> bool: #base cases if len(words1) != len(words2): return False if len(pairs) == 0 and words1 == words2: return True ...
b02229082b43f1fd777606f88f2c9b80ac2e6c59
adqz/interview_practice
/algo_expert/p55_suffix_trie.py
909
3.890625
4
class SuffixTrie: def __init__(self, string): self.root = {} self.endSymbol = "*" self.populateSuffixTrieFrom(string) def populateSuffixTrieFrom(self, string): for i in range(len(string)): self.createSuffixTrie(i, string) def createSuffixTrie(self, i, string): ...
260e4a07beec9abbaab641ea3750fc606e939e2d
padma108raj/python
/String_Programs/splitnJoin.py
197
3.765625
4
s="Diabetic paitents are more in india" l=s.split() ll=[] for x in l: ll.append(x) print('list',ll) #syntax join string = seperator.join(group of strings) s=":".join(ll) print("The String:",s)
60385e178b9ade4d54f454efa22bd83aad956f0e
apalania/python2018
/PlackettBurmanDesign/PB_design.py
2,126
3.890625
4
from pyDOE import pbdesign import math #for arranging F values in increasing order def BubbleSort(Fval): sort=Fval n = len(sort) #corresponding to every element in the array for i in range(n): for j in range(0, n-i-1): if (sort[j] > sort[j+1]): # swapping if the element i...
26d5e42bb4593d6c8c5fc9cdc6cbd4bb87822f29
ksenia629/IvanovaK
/Lab1/mygroup.py
1,358
3.546875
4
def print_students(students): print(u"Имя".ljust(10), u"Фамилия".ljust(10), u"Экзамены".ljust(50), u"Оценки".ljust(20)) for student in students: print(student["name"].ljust(10), student["surname"].ljust(10), str(student["exams"]).ljust(50), str(student["marks"]).lju...
5df79f7e46efcdafc3235c7114ab7d9e5c4cb6ea
p-lots/codewars
/7-kyu/shorter-concat-[reverse-longer]/python/solution.py
198
3.671875
4
def shorter_reverse_longer(a, b): short, long = min(a, b, key=len), max(a, b, key=len) if len(a) == len(b): short = b long = a return f'{short}{long[::-1]}{short}'
755c42fc3cefd94e5787bfba8c05b9cfbf06fce9
jbanerje/Beginners_Python_Coding
/coding_bat_1.py
122
4
4
test_str = input('Enter the String:') rep = int(input('How many times you want to repeat:')) print(test_str * rep)
a0550d3bf01acc4d856953015a0bd399b37a7fb4
Aasthaengg/IBMdataset
/Python_codes/p03352/s635501060.py
211
3.75
4
from math import sqrt x = int(input()) l = [] if x == 1: print(1) exit() for i in range(1, int(sqrt(x))+1): for j in range(2, x+1): if 1 <= i**j <= x: l.append(i**j) print(max(l))
ca4e104d974e044175012491a49639e5a523f33d
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/9_3.py
2,733
4.375
4
Python Program to Compute Life Path Number Given a String of date of format YYYYMMDD, our task is to compute the life path number. **Life Path Number** is the number obtained by summation of individual digits of each element repeatedly till single digit, of datestring. Used in Numerology Predictions. **Ex...
b06c9b2939028d88752735eb12ba4299f54f54b2
Thorjezar/pythonDemo
/laowang/main.py
3,880
3.5
4
# coding=utf-8 ''' 老王开枪 ''' class Person(object): '''人的类''' def __init__(self, name): super().__init__() self.name = name self.weapon = None # 用来保存枪的引用 self.hp = 100 # 剩余的血量 def __str__(self): if self.weapon: return "%s 的血量是%d,持有武器:%s"%(self.name, se...
ef6632364a8c432d24181d2f3b1c2137a0b63553
Lasa-beer/python_exp
/exp15.py
561
3.65625
4
# *coding:utf-8 * # Author : silence # Time : 2018/8/8 17:46 # File : exp15.py # IDE : PyCharm # 质数判断 while True: try: num = int(input('请输入一个数字:')) except ValueError: print('您输入的数字不是整数:') continue if num > 1: for i in range(2,num): if num % i == 0: ...
b8244fe8736ddfbdf163fae96550885587b3daa2
MoonChaserChen/hello
/hello-algorithm/exercise/calcReversePolishNotation.py
1,222
3.5
4
def priv_com(a, b): mul_dev = ['*', '/'] add_sub = ['+', '-'] if (a in mul_dev and b in mul_dev) or (a in add_sub and b in add_sub): return 0 elif a in mul_dev and b in add_sub: return 1 elif a in add_sub and b in mul_dev: return -1 def is_operation(ope): operation = ['...
f872337a86991e7c77a27a1252eaaf9c11b76fbe
Blackxin/project-random
/Python/Juni 2021/turunan.py
798
3.546875
4
import os def tampilan(x): print("PROGRAM PENGHITUNG TURUNAN FUNGSI") print(f"f(x) = {x}") def turunan(k,v,p): if v=='' : k=0 p=0 h= "0" else : k = k * p p = p - 1 h = f"{k}{v}^{p}" return h tampilan("") k = int(input("Masukkan konstanta : ") or 0) ...
50d847ee96367085af47f92bfc77bdc9b811387a
Ebi-aftahi/Python_Solutions
/data visualization/data_visualization.py
1,476
3.953125
4
title = input('Enter a title for the data:\n') print('You entered: ' + title) print() header_1 = input('Enter the column 1 header:\n') print('You entered: ' + header_1); print(); header_2 = input('Enter the column 2 header:\n') print('You entered: ' + header_2); print(); data = input('Enter a data point (-1 to stop...
c20da1c54a557c83bd12542ecb10d7d93bc726dd
NiteshTyagi/geeksforgeeks_solutions
/linkedlist/josephus_problem.py
839
3.828125
4
class Node: def __init__(self, val=None:int): self.val = val self.next = None def getJosephusPosition(m, n): head = Node(1) prev = head for i in range(2, n + 1): prev.next = Node(i) prev = prev.next prev.next = head # Connect last ptr1 = head ...
c66a9998244c20dfbb8f371a721f6cf1ce40a3b0
AndrewStudenic/magic-8-ball
/magic8ball.py
932
3.828125
4
import random def magic8ball(AnswerNumber): if AnswerNumber == 1: return 'It is certain.' elif AnswerNumber == 2: return 'Yes.' elif AnswerNumber == 3: return 'It is decidedly so.' elif AnswerNumber == 4: return 'Reply hazy, try again.' elif AnswerNumber =...
16867813afc09f8214fdae2c05a3b50e921bd991
aabhishek-chaurasia-au17/MyCoding_Challenge
/assignments/week12/day05/Q.03.py
630
3.703125
4
""" Q-3) Same Tree (5 marks) https://leetcode.com/problems/same-tree/ """ # 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(object): def isSameTree(self, p, q)...
03a6d1da6caca0a6027c715a4a8eb25628707e2d
ctbgx797/class_sample
/customer.py
978
3.9375
4
class Customer: def __init__(self, first_name, family_name, age): self.first_name = first_name self.family_name = family_name self.age = age def full_name(self): return f"{self.first_name} {self.family_name}" def info_csv(self): return f"{self.full_name()},{self.age...
efd3c60dc9d44cc00369ae93bc693632407a82ad
octaviaaris/salesperson-report
/sales_report.py
1,937
3.859375
4
""" sales_report.py - Generates sales report showing the total number of melons each sales person sold. """ # salespeople = [] # melons_sold = [] # f = open("sales-report.txt") # open file # for line in f: # iterate through lines in file # line = line.rstrip() # strip ...
95c534314dc29dcd1ff95da4fe1460d549beb3ab
iamdika31/test-arkademy
/5.py
466
3.625
4
import numpy as np def createMatrix(dimensi): a = 1 matrix = [] for i in range(dimensi): row = [] for j in range(dimensi): row.append(a) a+=1 matrix.append(row) matrix = np.array(matrix) print(matrix) diag1=0 diag2=0 for i in range(dimensi...
2a63e351410050d2fa7ee195fec3406ae7f9aa44
jbathel/holbertonschool-higher_level_programming
/0x03-python-data_structures/4-new_in_list.py
263
3.65625
4
#!/usr/bin/python3 def new_in_list(my_list, idx, element): if my_list: temp_list = my_list[:] if idx < 0 or idx > len(temp_list) - 1: return temp_list else: temp_list[idx] = element return temp_list
5cbd1bf3bb6d29c4803d0271739dbb3ffc0b98fb
Gilsunho/python_lecture
/for_01.py
175
3.5625
4
for i in "이젠컴퓨터학원": print(i) for i in range(1, 10): print(i) for i in range(10): print(1) if(i%2 == 0): continue print(2)