blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4e7667591affc79bb488d29f6b8867eda5445470
lunarpearl/rosemary.py
/modified_pancakes.chef.py
1,103
3.5
4
from kitchen.ingredients.Collections import Collection, Mixture, Portion from kitchen.Rosemary import Rosemary from kitchen.utensils import Pan, Plate, Bowl from kitchen.ingredients import Egg, Salt, Flour, Milk, Butter #making a batter again but now as a mixture(class) batter=Mixture(name='batter to make pancakes') fo...
0248ef6c07fe234921a6b5a64b5575b93f9a0bc9
shuaih7/Huawei_coding_interview
/HJ21.py
806
3.90625
4
# -*- coding: utf-8 -*- d={ "abc":2, "def":3, "ghi":4, "jkl":5, "mno":6, "pqrs":7, "tuv":8, "wxyz":9, } if __name__ == "__main__": while True: try: a,res=input(),"" for i in a: if i.isupper(): # check whether the character is upper ...
48f20510daa56b7d2488f92013ee2ea9b1b15543
thomastien/hackerrank
/euler/euler004.py
1,475
3.75
4
# Enter your code here. Read input from STDIN. Print output to STDOUT # Strategy # Given a #, (assume <=998001) # Need to verify # A: number is palindromic # B: number is product of 3-digit #s # brute-force could start from 998001, downwards # and divide by all #s 100-999, until modulous 0 # STRATEGY TWO (the one us...
b762a72e787332a90cd732f517a9cf908f832ac6
Cleber-Woheriton/Python-Mundo-1---2-
/desafioAula063.py
817
4
4
#(Desafio 63) Escreva um programa que leia um número n inteiro qualquer e mostre # na tela os n primeiros elementos de uma sequência de fibonacci. # Ex 0→ 1→ 1→ 2→ 3→ 5→ 8→ print(f'\033[1;30;43m{" Sequência de Fibonacci ":=^60}\033[m') valA = f = 0 valB = valC = cont = 1 print('Quantos números de sequência deseja ver?...
edfc42971e705ba71444978089ef1023c51a34cc
devdiogofelipe/Introduction-to-python
/Módulo 1/Practice/if_elif_else.py
476
4.25
4
def num_to_letter_grade(grade): if grade >= 90: print ("YAAAAY DID U GET AN A!!!!!") elif grade >= 80: print("WOW DID U GET AN B!!!") elif grade >= 70: print("WELL DONE MATE, U GET A C!!") elif grade >= 60: print("WELL DONE MATE, AN D CAN MAKE U PASS THROUGH") else :...
ab36eaded604e4efbd1bf9f67fa8c5c477ecedec
Jalcivarg2/Trabajos-en-clase
/Sintaxis.py
1,722
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 25 14:01:17 2021 @author: Jose Alcivar Garcia """ #num=20 #if type(num)==int: # print("respuesta: ", num*2) #else: # print("el dato no es numerico") #def mensaje(men): # print(men) #mensaje("mi primer progama ") #mensaje("mi segundo programa ") c...
4ec52e5bf20bb7d4d3d0f915c686c2aecb87777c
LorenzHW/Coding-Competitions
/code_jam/2018/round_1-c/2_problem/lollipop.py
1,563
3.5625
4
class Flavor: def __init__(self, id, sold=False, likes=1): self.id = id self.sold = sold self.likes = likes class ShopStatistic: def __init__(self): self.statistic = {} def update(self, prefs): for flav_id in prefs: flavor = self.statistic.get(flav_id, ...
d3de5aff87631180e43f78543a78c9890b3d548c
huyanhvn/hackerrank
/python/map_reduce.py
491
3.515625
4
# https://www.hackerrank.com/challenges/string-validators if __name__ == '__main__': s = raw_input() print reduce((lambda y,z : y or z), map(lambda x: x.isalnum(), list(s))) print reduce((lambda y,z : y or z), map(lambda x: x.isalpha(), list(s))) print reduce((lambda y,z : y or z), map(lambda x: x.isdi...
47de4a68d816026e027c53dec9bef2fee9484f08
knakajima3027/pycoder
/ABC210/main_B.py
287
3.515625
4
def solve(S: str) -> str: for i in range(len(S)): if S[i] == "1": if i % 2 == 0: return "Takahashi" else: return "Aoki" if __name__ == "__main__": n = int(input()) s = input() ans = solve(s) print(ans)
bd56678d4bace7df952543a1ab0b177c7acbb2fa
jaford/thissrocks
/Python_Class/py3intro3day 2/EXAMPLES/simple_class.py
372
3.515625
4
#!/usr/bin/env python class Simple(): # <1> def __init__(self, message_text): # <2> self._message_text = message_text # <3> def text(self): # <4> return self._message_text if __name__ == "__main__": msg1 = Simple('hello') # <5> print(msg1.text()) # <6> msg2 =...
1d64ce4ae4feb45fdc8953d952e403daad63c4ef
leyvamn2/Learning-python
/p5.py
244
3.90625
4
#práctica if print("evaluacion de notas") notas=input("Introduce la nota del alumno: \n") def evaluacion (nota): valoracion="aprobado" if nota<5: valoracion="suspenso" return valoracion print(evaluacion (int(notas)))
276c1ed69713f649a25df2878abef8e6e8216e3d
LavanyaLahariRajaratnam/100-days-coding
/XOR in list.py
425
3.734375
4
''' given an integer n and an integer start. define an array nums where nums[i]=start +2*i(0-indexed) and n==nums.length. Return the bitwise XOR ("^") of all elements of nums. ''' #sir ''' n=int(input())#5 start=int(input())#0 for i in range(n): x^=s+(2*i) print(x) ''' n=int(input()) start=int(inp...
bcc2e20e10d269f0ea04a5143ecbb51839c6c1e4
advecchia/leetcode
/top_interview_questions/13_roman_to_integer.py
1,748
3.859375
4
# https://leetcode.com/problems/roman-to-integer/ import unittest MINIMUM_WORD_LENGTH = 1 MAXIMUM_WORD_LENGTH = 15 class SolutionValidator(object): def validate_word_length(self, word: str) -> None: if MINIMUM_WORD_LENGTH > len(word) or len(word) > MAXIMUM_WORD_LENGTH: raise ValueError('Inval...
a685193b165b2871a5445f2e8181cf459bf5fd8b
algohell/ALGOHELL
/Sherlock_and_the_Valid_String/pgo.py
611
3.65625
4
#!/bin/python3 import math import os import random import re import sys from collections import Counter # Complete the isValid function below. def isValid(s): s_v = sorted(list(Counter(s).values())) #print(s_v) if s_v.count(s_v[0]) == len(s_v) or (s_v.count(s_v[0]) == len(s_v) - 1 and s_v[-1] - s...
e876ef49e1b9d3a9581105dde2ab807f5c054c98
cappuccinooo/python20210201
/1-7.py
213
3.84375
4
a=int(input('輸入數學成績')) b=int(input('輸入英文成績')) if a<60 and b <60: print('要處罰!') elif a>90 and b>=90: print('有獎品!') elif a<60 or b <60: print('再加油')
20d977800b807448ecf8581d9aa65d00b72f498b
dmc200/Python-Projects
/List_Touple_Sets.py
1,974
4.375
4
# List Examples ''' courses = ["History", "Math", "Physics", "ComSci"] courses_2 = ["Education", "Statistics"] courses.append("Art") courses.insert(0, courses_2) print(courses[0]) print(courses) courses.remove(courses_2) courses.extend(courses_2) print(courses) courses.remove("Math") print(courses) popped = c...
fe20050718cd1761464b07b48bc5daf4ef5e430e
danielcorroto/projecteuler
/problem016.py
311
4
4
''' Created on Mar 19, 2014 @author: Daniel Corroto 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? ''' def sumBiPower(x): y = 2 ** x temp = 0 while y > 0: temp += y % 10 y /= 10 return temp print sumBiPower(1000)
5b8a00092c5a64ce612cf178fe7ac5e22e1e9d9d
nishamadaan/learning_space
/fun1.py
224
3.671875
4
def changeMe(mylist): #mylist.append([1,2,3]) list1 = [1,2,3] print("Values inside the function: ",list1) return mylist = [10,20,30] changeMe(mylist) print("values outside the function: ",mylist)
9c969b0b96422cc028f3bc1de4917012892cfdb0
LauraBrogan/2021-Computational-Thinking-with-Algorithms-Project
/bubblesort.py
1,266
4.46875
4
#CTA Project 2021 #Bubble Sort #Resourse used: https://realpython.com/sorting-algorithms-python/#the-bubble-sort-algorithm-in-python def bubblesort(array): n = len(array) for i in range(n): # If there's nothing left to sort terminate the sort function already_sorted = True #Look at each...
2c6bee348b180f1b3fca5c46bafee932aa6682a1
RuzhaK/pythonProject
/Fundamentals/FinalExamPreparation/Regex/EmojiDetector.py
587
3.796875
4
import re line=input() pattern_emojis=r"(\*{2}|:{2})([A-Z][a-z]{2,})\1" pattern_digits="\d" matches_emojis=re.finditer(pattern_emojis,line) matches=re.findall(pattern_digits,line) threshold = 1 for m in matches: threshold*=int(m) all_emojis=[m for m in matches_emojis] print(f"Cool threshold: {threshold}") print(...
59a3731fecb16ae9ae13386f4e60342dda020548
GuiltyD/PythonCookbook
/Chapter 8/8.16 在类中定义多个构造函数.py
353
3.65625
4
import time class Date: def __init__(self,year,month,day): self.year = year self.month = month self.day = day @classmethod def today(cls): t = time.localtime() return cls(t.tm_year,t.tm_mon,t.tm_mday) def __str__(self): return '{}/{}/{}'.format(self.year,self.month,self.day) a = Date(2019,7,11) b...
b899c0f3010aabe43039c51f37d4a75eeb18700a
cjgarcia/diplomado_python
/exes/exe4.py
90
3.609375
4
def es_palindromo(p1, p2): return p1 == p2[::-1] print(es_palindromo('amor', 'roma'))
7ebc0562b63d5ded763f61552d5b88dba6d8adb5
kzarms/robot
/essun/remote.py
5,609
3.546875
4
#!/usr/bin/env python3 """This is the initial module to control the car.""" # import sys import time import pygame import serial from serial import Serial # Check number of the COM port after BT paring COMPORT = 'COM3' COMPORT = '/dev/rfcomm0' ser = serial.Serial('/dev/rfcomm0') # open serial port >>> print(ser.nam...
2f7fc26bb98b65db0f59c9dd1c7a83b2a8790310
danieldfc/curso-em-video-python
/ex003.py
225
3.875
4
first_value = int(input('Digite um valor: ')) second_value = int(input('Digite um valor: ')) sum_total = (first_value + second_value) print('A soma entre {} e {} é igual a {}!'.format(first_value, second_value, sum_total))
dc962abbc09bb705c9440f9884724787804e92b4
Yixuan-Lee/LeetCode
/algorithms/src/Ex_78_subsets/solution_discussion_cascading.py
604
3.78125
4
""" Reference: https://leetcode.com/problems/subsets/solution/ Idea: start from an empty subset in output list, then at each step, one takes an new integer into consideration and generates new subsets from the existing ones. Time complexity: O(n * 2^n) Space complexity: O(n * 2^n) """ from typing import List clas...
ae51b048888f89784b6fd387c90e2972fb159a2c
ampledata/sdk-samples
/modbus_simple_bridge/cp_lib/split_version.py
3,788
3.6875
4
def split_version_string(value, default=None): """ Given a string in the form X.Y.Z, split to three integers. :param str value: a string version such as "6.1.0" or "7.345.beta" :param str default: :return: major, minor, and patch as ints :rtype: int, int, int """ if value is None or va...
742986271a880c28a43cb3947277c2f99f90038c
eselyavka/python
/leetcode/solution_40.py
1,191
3.65625
4
import unittest class Solution(object): def combinationSum2(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ ans = [] local_ans = [] n = len(candidates) candidates.sort() def...
fdc3d9bc53fd0fd6d70eab7e8f89e1871f1d1ddf
Candy-u/python
/序列化.py
1,078
3.875
4
#序列化 #在程序运行的过程中,所有的变量都是在内存中,比如,定义一个dict: #d = dict(name='Bob', age=20, score=88) '''可以随时修改变量,比如把name改成'Bill',但是一旦程序结束,变量所占用的内存就被操作系统全部回收。如果没有把修改后的'Bill'存储到磁盘上,下次重新运行程序,变量又被初始化为'Bob'。 我们把变量从内存中变成可存储或传输的过程称之为序列化,在Python中叫pickling,在其他语言中也被称之为serialization,marshalling,flattening等等,都是一个意思。 序列化之后,就可以把序列化后的内容写入磁盘,或者通过网络传输...
b1cad027f8ed34286074b177d1046c420ec91630
jxhangithub/leetcode
/solutions/python3/290.py
496
3.71875
4
class Solution: def wordPattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ if len(str.split())!=len(pattern): return False dic={} for word in str.split(): if not pattern[0] in dic.values() and not word in di...
f84833155703043c56f3649874af353ef8b2d8a4
MellamoTrung/PythonPractice
/Ex3-2.py
143
4.1875
4
length = float(input("Enter the lenth: ")) width = float(input("Enter the width: ")) print("The area of the room is {}".format(length*width))
ce1d9b04b9b42d85febf7cdf2d95739f9a9c1aaa
anantkaushik/Competitive_Programming
/Python/GeeksforGeeks/odd-even-level-difference.py
2,989
4.34375
4
""" Problem Link: https://practice.geeksforgeeks.org/problems/odd-even-level-difference/1 Given a a Binary Tree, your task is to complete the function getLevelDiff which returns the difference between the sum of nodes at odd level and the sum of nodes at even level . The function getLevelDiff takes only one argument...
6cd7d926f04146ce263ca83633ba86046c6a014b
nickhand/cosmology
/cosmology/utils/functionator.py
7,836
3.640625
4
import scipy.interpolate import numpy as np class trapolator: """ The base class for the different extrapolating/interpolating classes. Parameters ---------- min_x : float, optional The minimum x value that the function is defined over. Default is ``None``, which is interpreted...
1b5d373e50f02ff16b614219cc212c126b1c3006
Mpprobst/Rumors
/source/objects/actor.py
26,516
3.65625
4
""" actor.py Purpose: Implements the data structures and mechanics of an actor """ import copy import sys import string from objects.relationship import Relationship from objects.area import Area from objects.rumor import Rumor import math import random class Actor(): # assumes it is given a .txt filename def...
231c893ab6b0d51d7490acdae93f6ce9c5ca459e
santiagoom/leetcode
/solution/python/129_SumRoottoLeafNumbers_1.py
890
3.5625
4
from typing import List from utils import * class Solution_129_SumRoottoLeafNumbers_1: def sumNumbers(self, root: TreeNode): root_to_leaf = 0 stack = [(root, 0) ] while stack: root, curr_number = stack.pop() if root is not None: ...
c6c473cde684ad25f6184fc0adf934984e1c4aa7
shigithub/buildscript2
/zipper.py
608
3.578125
4
import os, sys, zipfile from zipfile import ZipFile as zip def zipAll(zipName, outputDir): z = zip(zipName, 'w', zipfile.ZIP_DEFLATED) for root, dirs, files in os.walk(outputDir): for file in files: absPath = os.path.join(root, file) z.write(os.path.join(root, file), os.path.relpath(absPath, outputD...
520cb94d14660c93b05511d36a91bc3f8d0ea3b6
imhyo/codejam
/kruskal.py
499
3.53125
4
from graph import Graph from union_find import UnionFind # Kruskal's minimum spanning tree algorithm def kruskal(graph): ret = 0 result = [] edges = [] for u in graph: for v, c in graph[u]: edges.append((u, v, c)) edges.sort(key=lambda x: x[2]) uf = UnionFind(len(graph.V)) ...
1ce2b83586c1513dbab3e2f3c9e132bf1605489e
yzl232/code_training
/mianJing111111/geeksforgeeks/array/Find the smallest and second smallest element in an array_find the second largest element in an array.py
845
3.78125
4
# encoding=utf-8 ''' 如果是找2个,或者3个。都是类似解法。 Write an efficient C program to find smallest and second smallest element in an array. Difficulty Level: Rookie Algorithm: 1) Initialize both first and second smallest as INT_MAX first = second = INT_MAX 2) Loop through all the elements. a) If the current element is sm...
4ebeaac59bdcba607c5b31d89ce0f5fc6fbfc719
arieldunn/PyMeUpCharlie
/PyBank/main.py
2,327
4
4
import os # Module for reading CSV files import csv import statistics csvpath = os.path.join('Resources', 'budget_data.csv') # # Method 1: Plain Reading of CSV files # with open(csvpath, 'r') as file_handler: # lines = file_handler.read() # print(lines) # print(type(lines)) # Method 2: Improved Readin...
23899a7dae4b0600416186cbc5ebc80fca5e3f9f
wonjongah/multicampus_IoT
/인터페이스 실습코드/workspace/workspace/01_python/chapter15/ex02.py
971
4.0625
4
class Stack: def __init__(self, size=5): self.data = [] self.size = size def push(self, push_value): if len(self.data) == self.size: # full print("스택이 가득 찼습니다. pop()을 통해 지워주세요") return else: self.data.append(push_value) print(push...
1042a1baabe1082977c5059f3cd1faa05cf4a6ef
MOIPA/MyPython
/practice/function_class/function.py
4,185
4.3125
4
''' 方法的参数问题:变长参数 ''' # default arguments import types def student(name, age, city='none', sex='m'): pass # enroll student('tr', 18) student('tr', 18, city='bj') # changable arguments def calc(*num): for n in num: print(n) calc(1) calc(1, 2) # changable arguments by ** def person(name, age...
bcc1c47a37645857067be3b40cf1e7a3076d779f
ryanthomasdonald/python
/week-1/homework/python101_RyanDonald.py
3,052
4.25
4
print("\r") print("***))) Exercise 1 (((***") # Prints fancy titles!!! print("\r") cost = float(input("What is the final total of your meal? $")) service = input("Was your service good, fair, or bad? ") if service.lower() == "good": tip = cost * 0.2 elif service.lower() == "fair": tip = cost * 0.15 elif servi...
98ff1ed9d4216df74093ace8866bd9fd3fd9c7a1
Sidheartt/py
/dog.py
362
4.1875
4
Create a basic function that returns True if the word 'dog' is contained in the input string. Don't worry about edge cases like a punctuation being attached to the word dog, but do account for capitalization def findDog(var): if 'dog' in var.lower().split(): return True else: return ...
2e1c6e4402cb9ffbebe2cad51f9b9d8044d246fc
arduino-monkey/6.0001-MIT-EDX-pset-solutions
/pset1/problem3.py
476
3.8125
4
temp = '' lis = [] orignal_word = s for i in range(len(s)): temp = '' for i in range(len(s)-1): if s[i] <= s[i+1]: temp += s[i] else: temp += s[i] lis.append(temp) s = s[i+1:] break longest = '' for i in lis: if len(i)...
8ebcc827142bc94f4ace1344862e04f18d61cd76
artificiallifeform/asm
/dec_to_bin.py
488
3.609375
4
def dec_to_bin(num): divisor = num bits = [] if num > 0: while divisor != 1: temp = divisor % 2 bits.insert(0, str(temp)) divisor = int((divisor - temp) / 2) # pdb.set_trace() bits.insert(0, '1') for i in range(16 - len(bits)): bi...
f125a0dba4b43b81211e588c7f91b64751866dde
Scott8440/490Project
/tests/line_test.py
3,871
3.53125
4
import unittest from py.CodeLine import CodeLine from py.LineTypes import LineTypes class TestLineMethods(unittest.TestCase): lineNumber = 7 # Dummy lineNumber indentation = 1 # Dummy indentation def testLineCreation(self): string = "this is a line" line = CodeLine(string, self.lineNumbe...
2d9e0ddec477eae94658f7f377799db4d63f4b71
suddi/coding-challenges
/python/data_structures/stack.py
6,376
4.0625
4
class Stack(): def __init__(self, value=None): # O(1) if value is not None: # O(1) self.stack = [value] # O(1) self.length = 1 # O(1) ...
d2389fe830d1a70f160f41f1bb75cb1fb188eb96
bucho666/pyrl
/demo/consoledemo.py
1,101
3.53125
4
# -*- coding: utf-8 -*- import parentpath import random import coord from console import Console from console import Color class Walk(object): KeyMap = { "h": (-1, 0), "j": (0, 1), "k": (0, -1), "l": (1, 0), "y": (-1, -1), "u": (1, -1), "b": (-1, 1), "n": (1, 1) } def __init__(self): self._coord =...
7f8043d4f32a9fc5619d8590fdad50e924eb0994
BhaveshChand/cs50-edx
/pset6/vigenere.py
690
3.84375
4
import cs50 import sys def main(): if len(sys.argv)!=2 or not str.isalpha(sys.argv[1]): print("Usage: python vigenere.py k") exit(1) key=str.upper(sys.argv[1]) ptext=cs50.get_string("plaintext: ") ctext=[] j=0 for c in ptext: if str.islower(c): ctext.append(c...
368f13db6a7fecbc1e231f92fded0af15ac3ba30
sdvacap/Python--Spring2020
/average.py
960
4.34375
4
#average.py #Calculate average #Sarah Vaca #February 24,2020 #Part 1 #Using a for loop and range, calculate the mean of all the numbers between 1 and 20 (include number 1 to 20) #Calculation of sum #Print results #enter number to calculate sum 0 #ANSWER sum=0 for num in range(1,21): sum=sum+num ...
bfa1036e61d3190c0cce234b5eab3e67099c2b14
viswambhar-yasa/AuToDiFf
/test_NN.py
5,278
3.71875
4
""" Author: Viswambhar Yasa Basically all the test cases below have same structure. Aim : To test the forward propagation of the Neural Network Expected : The calculations are done for a Neural Network with one hidden layer whose weights are set to 1. Obtained : The output of the Neural Network class Remar...
7935f38e9bd6067322eec534d90b66d52888b0f3
amax14/Codewars-Katas
/kata5.py
766
3.890625
4
def find_short(s): l=0 sstr=[] sl = [] for w in s.split(): sstr.append(w) sl = sorted(sstr, key=len) l = len(sl[0]) return l # l: shortest word length def find_short1(s): s2=[] sl = [len(x) for x in s.split()] for x in s.split(): s2....
89be9747fd60ed15b137bd6092e537d5d299cfed
srihariprasad-r/workable-code
/Practice problems/foundation/recursion/printkeypadcombinations.py
500
3.515625
4
def printkeypadcombinations(str,ans): if len(str) == 0: print(ans) return ch = str[0] rest = str[1:] chr_from_dict = dict[int(ch)] for i in range(len(chr_from_dict)): printkeypadcombinations(rest, ans + chr_from_dict[i]) dict = { 1 : 'abc', 2 : 'd...
3095a139671aee95620ba26faa21e57f242cf5fe
AyberkKilicaslan/Python-XML-CSV-JSON-Converter
/xmlToCsv.py
3,493
3.59375
4
import xml.etree.ElementTree as ET import csv def xmltocsv(input_file,output_file): ##parsing the xml file with ET xml_Parser = ET.XMLParser(encoding="utf-8") tree = ET.parse(input_file,parser=xml_Parser) root = tree.getroot() # open a file for writing csv_data = open(output_file, 'w', encoding...
97057cce48e6a22c540d6c9d2a531a0002965696
IvanYukish/PycharmProjects
/Test/2.1.5.py
143
3.765625
4
A, B = (int(input() )for _ in range(2)) it = sums = 0 for _ in range(A, B+1): if _%3 == 0: sums += _ it += 1 print(sums/it)
553775fc705cd709de289fb498c5b72744aa88d8
mgcarbonell/30-Days-of-Python
/04_basic_py_collections.py
3,368
4.6875
5
# In python we have lists names = ["Jerry", "Elaine", "Kramer", "George"] # and we can spread them over multiple lines, or mix datatypes friend_details = ["Andy", 33, "big boss"] # we can access them like standard javascript notation print(friend_details[0]) # => Andy print(friend_details[1]) # => 33 print(friend_d...
ac5ca46acfa85bf9be4d4f2d3ea55b5273ebe483
lord3612/GB_Python
/lesson_7/task_7_4.py
1,353
3.5
4
""" Написать скрипт, который выводит статистику для заданной папки в виде словаря, в котором ключи — верхняя граница размера файла (пусть будет кратна 10), а значения — общее количество файлов (в том числе и в подпапках), размер которых не превышает этой границы, но больше предыдущей (начинаем с 0), например: { ...
6d7faf3fddbe0290a6f2f352452e9ef00cbd22f1
knparikh/IK
/Sorting/nearest_neighbors.py
1,466
3.921875
4
import heapq import math #Given a point P and other N points in two dimensional space, find K points out # of N points which are nearest to P. class point(object): def __init__(self, tup, p): self.x = tup[0] self.y = tup[1] # Since python only has min heap, and we want max heap, negate the e...
44242558c3c785ae0135952e6087d592d22bb517
Mamata720/hangaman
/hangman.py
7,616
3.609375
4
import string from words import choose_word from images import IMAGES # in this line meaning from images i am import IMAGES variable list. # End of helper code # ----------------------------------- def InValide(guess):# def is pree difine keyword invalide is a variable i pass the guess argument inside the paremeter. ...
fcd44f0666acfb40ff4bad42ca0384997a87ceaf
bakker4444/Algorithms
/Python/leetcode_076_minimum_window_substring.py
5,937
4
4
## 76. Minimum Window Substring # # Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). # # Example: # # Input: S = "ADOBECODEBANC", T = "ABC" # Output: "BANC" # # Note: # # If there is no such window in S that covers all characters in T, ...
a2a417faae9269b9cb7e8f4839ec85b21a90ec4f
cblumenf/bootcamp
/longest_common_substring.py
618
4.28125
4
def common_str_finder(str1, str2): """This function takes in two strings and finds the longest common substring.""" str1_list = list(str1) str2_list = list(str2) if len(str1) <= len(str2): shortlist = str1 longlist = str2 else: shortlist = str2 longlist = str1 ...
668d408118d3343f0f705470b8ecc343ba06ca3f
IbraSuraya/Semester2
/py UAS_PSD/UASPSD_1.py
3,455
3.875
4
''' === NO.1 === UAS Praktikum Struktur Data 2021 Nama : Ibra Hasan Suraya Kelas : IF-B NIM : 2010511053 Jurusan : Informatika Dosen : Pak Jayanta Sumber : Ebook Data Structures and Algorithms with Python (Kent D Lee) Referen https://www.geeksforgeeks.org/find-paths-given-source-destination/ '''...
8cb2d1230348c080691c0785c5d1e22597aeed80
rajatgarg149/Daily_python_practice
/listlessthan.py
512
4.375
4
'''This file prints to list 1) List of numbers > N 2) List of numbers <= N ''' list_all =input('Give the list you want to divide\n') N = int(input('Type the pivot\n')) #covert list of strings to int list_all = [int(x) for x in list_all.split()] list_gt = [x for x in list_all if x > N] list_lt = [x for x in l...
b5b56d93d1a5b1df537698ed16e1c4ba7978a8f9
michelegorgini/excersises
/TimeZone challenge.py
3,381
4.21875
4
# Create a program that allows a user to choose one of # up to 9 time zones from a menu. You can choose any # zones you want from the all_timezones list. # # The program will then display the time in that timezone, as # well as local time and UTC time. # # Entering 0 as the choice will quit the program. # # Display the...
a2ae4de18c17efae0e779499e5521ef049cf0ec2
eBLDR/Misc_Projects
/paint.py
3,251
3.625
4
import turtle import pickle """ Mapping functions so we can repeat previous drawings: 1 = increase_line_width() 2 = decrease_line_width() 3 = color() 4 = shape() 5 = stamp() (x, y) = goto() """ LIST = [] # Action sequence memory def goto(x, y): atlas.pendown() atlas.goto(x, y) LIST.append([x, y])...
6c5c9219ed4341f2e0502816541e924de61c03cf
salihenesbayhan/Homework-Assigment-6
/Assignment 6.py
1,188
4.03125
4
import math # returns True if n is prime number # returns False otherwise def is_prime(n): # n is less than 2 if n < 2: return False # compute square root + 1 sq = int(math.sqrt(n)) + 1 # check if divisible by any other number for i in range(2, sq): if n...
04df4c568081ef5acf2a31dd07ba6f65d2076fa0
LouStafford/My-Work
/week02/hello2.py
156
4.03125
4
#Lab 2.2 continued - creating a new file that reads a persons name & outputs same #Author: Louise Stafford name = input ("Enter your name:") print ( 'Hello ' + name)
2a3a33b785e30c883160a8f87699565f16af6905
joellimrl/Practicals
/prac02/ascii_table.py
748
4.34375
4
LOWER = 33 UPPER = 127 """ char = input("Enter a character: ") print("The ASCII code for {} is {}".format(char,ord(char))) code = int(input("Enter a number between {} and {}: ".format(LOWER,UPPER))) while code < LOWER or code > UPPER: code = int(input("Please re-enter a number between {} and {}: ".format(LOWER,UPP...
6c8a4ee5b828e39393f54686aaa4135f81f2665a
grain111/Learn_CS
/Databases/Many_to_Many/main.py
2,006
3.640625
4
import sqlite3, json conn = sqlite3.connect('studentdb.sqlite') cur = conn.cursor() cur.executescript(""" DROP TABLE IF EXISTS Student; DROP TABLE IF EXISTS Course; DROP TABLE IF EXISTS Member; DROP TABLE IF EXISTS Funct; CREATE TABLE Student (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, ...
b857491af0df256c7eecb44920436c01a8490903
s1lya/secutiryScriptsMIPT
/4.2.py
1,888
3.859375
4
# coding: utf-8 # In[25]: def pow_h(base, degree, module): binary = "{0:b}".format(degree) # print("Возводим число %d в %d степень по модулю %d"%(base,degree,module)) if len(binary) != 8: binary = '0' * (8 - len(binary)) + binary # print("Двоичное представление степени - " + binary) s ...
3fb8d821638212a3a663fb3a54d33bcc705f3f63
jalondono/holbertonschool-machine_learning
/math/0x04-convolutions_and_pooling/0-convolve_grayscale_valid.py
885
3.78125
4
#!/usr/bin/env python3 """Valid Convolution""" import numpy as np def convolve_grayscale_valid(images, kernel): """ performs a valid convolution on grayscale images: :param images: is a numpy.ndarray with shape (m, h, w) containing multiple :param kernel: is a numpy.ndarray with shape (kh, kw) con...
7e26f8b329dd34f714512142a30ef411c3d77509
wulab/falling
/person.py
1,736
3.609375
4
import config from deck import * from table import * class Person(object): def __init__(self, name): self.name = name def join(self, table): self.table = table if config.debug: print self.name + ' joined ' + table.getName() class Player(Person): def __init__(self, name...
84b0c18874f7790396455d29893489600828304f
DanielAShurmer/PythonBootcamp
/Day 5/FindLongestWordInFile.py
718
4.28125
4
def SplitWordsIntoList(String): OutList = [] CurrentWord = "" for Character in String: if Character == " ": OutList.append(CurrentWord) CurrentWord = "" else: if Character != "\n": CurrentWord += Character OutList.append(CurrentWord) print(OutList) return OutList FileToEdit = input("Enter the Fi...
3b22a9f22afbbbdf6f42785c3a0c1497684b4cff
an-lam/python-class
/functions/printtext1a.py
498
3.8125
4
def print_hello(): print("Hello world!") return 2 def print_fruits(): width = 80 text = "apple and orange" left_margin = (width - len(text)) // 2 print(" " * left_margin, text) # Parameter: text def centre_text(text): text = str(text) left_margin = (80 - len(text)) // 2 ...
559288821a3b703c84a49a4ccdac618640155e47
Toruitas/Python
/Practice/Daily Programmer/DP13a.py
951
3.859375
4
__author__ = 'Stuart' import sys class DaysException(Exception): def __init__(self, day, month): self.day = day self.month = month def __str__(self): months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'Dece...
786c5e96ee07446aa8f15acb1af79a6ab36aa945
djbinder/DojoAssignments
/Python/Python_Fundamentals/Dictionary Basics/dictionary_basics.py
334
3.75
4
def about_me(dictionary): print 'My name is', dictionary["Name"] print 'My age is', dictionary["Age"] print 'My country of birth is the', dictionary["Born"] print 'My favorite language is', dictionary["Language"] dictionary = {"Name" : "Dan", "Age" : "34", "Born" : "USA", "Language" : "Python"} about_m...
d6c1d09ff1bb2218a66f03db4320f6391b39f804
kmankan/python_crash_course_exercises
/Chapter 11/test_cities.py
728
3.984375
4
import unittest from city_functions import city_info class CitiesTestCase(unittest.TestCase): """Tests for city_functions.py""" def test_city_country(self): """"Does it print a city and country?""" city_country = city_info('medellin', 'colombia') self.assertEqual(city_country,"Medelli...
35fb93c51e51e49db83925ba0913c95aab3fd311
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/159/44778/submittedfiles/testes.py
150
4
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO n=int(input('Digite n:')) i=n produto=1 while i>0: produto=produto*i i=i-1 print(produto)
33c1337a0e0f77bb5ce0bdb5ec2eb2bdd0e1fbc1
Tijauna/CSC180-Python-C
/dev_ttt_print_board.py
970
3.625
4
# coding: utf-8 # %load dev_ttt_print_board.py def printBoard (T): rowcounter = 0 smallcounter = 0 limit = 2 if (len(T) > 9): #for too many positions return False for i in range (0, 8, 1): #for invalid list values if ((T[i] != 0) and (T[i] != 1) and (T[i] != 2)): return ...
a59ab39c64f399b7cdf917d4fdb8bbcd0481d235
franzip/project-euler
/python/problem005.py
666
3.859375
4
from fractions import gcd def lcm(a, b): return a * (b / gcd(a, b)) def smallest_multiple(upper_limit): assert upper_limit >= 3 and type(upper_limit) == int # save the sequence as a list sequence = range(1, upper_limit + 1) def helper(sequence, accumulator): # use tail recursion and retur...
13629c3952eef13eb26e6f8c1ea97490271f5b73
wanghan2789/CPP_learning
/algorithm/Practice/链表环的入口.py
895
3.609375
4
# -*- coding:utf-8 -*- #OJ : newcoad class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def EntryNodeOfLoop(self, pHead): # write code here if pHead is None: return None current_quick = pHead current_slow = pHead ...
cf717a25717a7b20128450adfcb46fa5bfabdf38
saddhu1005/Coursera-DataStructuresAlgorithms
/Algorithm-on-Graphs/10_paths_in_graphs_starter_files_2/shortest_paths/shortest_paths.py
2,016
3.546875
4
#Uses python3 import sys import queue def BellMan_Ford(adj,cost,distance,s,reachable): distance[s]=0 reachable[s]=1 for i in range(len(adj)-1): for u in range(len(adj)): for v,w in zip(adj[u],cost[u]): if distance[v]>distance[u]+w and distance[u]!=10**19: ...
e7cdc0630d3f3ad25ea208bbcdf2212feb2bb895
Vanguard90/automate-python
/Section 2/if_else_example.py
180
4.125
4
#If-else example name = 'Enes' age = 3000 if name == 'Alice': print('Hi Alice.') elif age < 12: print('You\'re not Alice.') elif age > 2000: print('Good try vampire!')
95348cae48187f48072b7b80172fe79ddfabddee
orez-/Hexcells-Solver
/hex_model.py
21,328
3.578125
4
import contextlib import enum import itertools import util class Color(enum.Enum): blue = (0x05, 0xa4, 0xeb) yellow = (0xff, 0xaf, 0x29) black = (0x3e, 0x3e, 0x3e) @classmethod def closest(cls, value): """ Return the enum element closest in color to the given color. `val...
52fbd83641d5b9abf0d65f386476cf25af8e1c21
george-ognyanov-kolev/Learn-Python-Hard-Way
/18.ex18.py
601
3.515625
4
#this one is like argv and scripts def print_two(*args): arg1, arg2 = args print(f'arg1 is {arg1} and arg2 is {arg2}') #ok that *args is pointless we could have do this def print_two_again(arg1, arg2): print('using .format arg1 is {} and arg2 is {}'.format(arg1, arg2)) #this takes one argument d...
30203f950ceda9d0d1f1a417ec75f84d191f1f02
rkhood/advent_of_code
/2019/day01.py
561
3.671875
4
def read_masses(filename='data/day01.txt'): with open(filename) as f: masses = f.read().strip().split('\n') return masses def fuel_required_by_mass(mass): return (mass // 3) - 2 def fuel_required_by_fuel(mass): fuel = fuel_required_by_mass(mass) if fuel <= 0: return 0 return ...
6d93126dae53cd41b90b094ff780ed99375dae57
sakshigarg22/python-projects
/fghj.py
378
3.640625
4
def f(number): return number print(f(5)) def func(message,num = 1): print(message*num) func('welcome') func('viewers',3) def func(x = 1,y = 2): x = x+y y += 1 print(x,y) func(y = 2,x = 1) num = 1 def func(): global num num = num+3 print(num) func() print(num) def test(x = 1,y = 2)...
46a7242c9cc4de06b85cf6ef34f625e0c1b637fb
Brice808/Calculator
/calculator_2.py
13,826
3.828125
4
#!/usr/bin/env python3 from tkinter import * import math import parser import tkinter import tkinter.messagebox root=Tk() root.title("Scientific Calculator") root.configure(background="DarkOrange1") root.resizable(width=False, height=False) root.geometry("500x580+0+0") calc = Frame(root) calc.grid() class Calc(): ...
08ea5d2d8c137b3536eda3ea78ea2bd13385a382
junedsaleh/Python-Programs
/Programs/1city.py
153
3.9375
4
i = input("Enter Number") i = int(i) j = 0 cnm= [] for j in range(i): n=input("Enater City Name") cnm.append(n) cnm. print(cnm)
142376bb56fa6c4f988533bc181a423c482e5eeb
Ayu-99/python2
/session2(e).py
322
3.8125
4
# Identity and Membership operators n1 = 10 n2 = 10 print( n1 is n2) # identity operators print( n1 == n2 ) #print( n1 is not n2) #print( n1 != n2) rollNumbers = [1, 2, 3, 4, 5] print(4 in rollNumbers) # MemberShip operators print( 40 not in rollNumbers) # Explore Membership operators on Tuple, Set and Dictionary...
d328a20420e46b690568e4a28a50740cf6a7094b
LouisHadrien/Big-data-algorithm
/join2_reducer.py
760
3.640625
4
#!/usr/bin/env python import sys # imput from the mapper are: show,number of view or show,ABC (name of Channel) show = None #initialize these variables prev_show= None count= 0 for line in sys.stdin: line = line.strip() #strip out carriage return key_value = line.split(' ') #split line, into key and value, re...
725136709eeda01167ace6061b9d540ae6c98eca
ChangxingJiang/LeetCode
/1301-1400/1325/1325_Python_1.py
1,035
3.78125
4
from toolkit import TreeNode from toolkit import build_TreeNode class Solution: def removeLeafNodes(self, root: TreeNode, target: int) -> TreeNode: def dfs(node): if node.left and dfs(node.left): node.left = None if node.right and dfs(node.right): no...
ccda3f49b30aa82a6115cfa1e2f08e173d704be9
ilailabs/python
/tutorials/linkedList.py
524
3.890625
4
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self.head while(temp): print(temp.data) temp = temp.next llist = LinkedList() l...
d6f2929d44dbd5f1fe4d15354726518a8cf0ef5c
HEroKuma/leetcode
/1277-largest-multiple-of-three/largest-multiple-of-three.py
1,608
4.15625
4
# Given an integer array of digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. # # Since the answer may not fit in an integer data type, return the answer as a string. # # If there is no answer return an empty string. # #   # Example 1: # # # Input: d...
e6e83f36fde9f3e3615c5a42eb6073fed9e0df43
MonteYang/do_leetcode
/code/14.最长公共前缀.py
1,017
3.59375
4
# # @lc app=leetcode.cn id=14 lang=python3 # # [14] 最长公共前缀 # # @lc code=start class Solution: def longestCommonPrefix(self, strs): """获得 list of string 的公共子串 Args: strs (list): a list of string Returns: str: 公共自创 """ if not strs: retur...
40da8ab73740dc3ccd54e7c88dfc56c8fbe411f9
woomin-Shim/Python
/car/car.py
355
3.75
4
class Car: def __init__(self): self._speed = 0 def get_speed(self): return self._speed def start(self): print("Engine Start.") self._speed = 10 def accelerate(self): print("가속합니다.") self._speed += 30 def stop(self): print("정지합니다.") ...
831e5bb5428964879e6cf64ca8291cd1771db5dc
wenqiang0517/PythonWholeStack
/day23/01-内容回顾.py
1,619
3.609375
4
# 面向对象 # 类 对象/实例 实例化 # 类是具有相同属性和相似功能的一类事物 # 一个模子\大的范围\抽象 # ***************** # 你可以清楚的知道这一类事物有什么属性,有什么动作 # 但是你不能知道这些属性具体的值 # 对象===实例 # 给类中所有的属性填上具体的值就是一个对象或者实例 # 只有一个类,但是可以有多个对象都是这个类的对象 # 实例化 # 实例 = 类名() # 首先开辟空间,调用init方法,把开辟的空间地址传递给self参数 ...
3ac4d1fdcb2de17dba638fa12c46bacac65901e6
tanmaybanga/Carleton-University
/COMP-1405/Assignment2/2a/a2q1b.py
1,206
4
4
#Imran Juma 101036672 #Assignment 2 #Question 1 Part 2 #Guess Who Goes to "No" Statement #-----------------------------------------------------------------------Citations-----------------------------------------------------------------------# #Book Citation: #Giddis, T. (2014) Starting Our With Python (Third Edditon...
b803f6654714023b99d3238084ce7fda3d16cd14
GitBulk/pyone
/p35/fs/PyFirst/PyFirst/text.py
614
3.734375
4
x = "There are %d types of people." % 10 print(x) binary = "binary" doNot = "don't" y = "Those who know %s and those who %s." % (binary, doNot) print(y) i = int(-5.7777) print(i) s = int("1231", 5) print(s) hello = None res1 = hello is None res2 = hello is not None print(res1) print(res2) print(bool(0)) print(b...
41dd4b4d3c8cdeecb7145d0cb525b0665a3cf9e7
WilliamSimoni/Neural_Network_Simulator
/Test/test_loss.py
932
3.5
4
""" Module test_loss test the loss Module """ import unittest import numpy as np from loss import * class TestLoss(unittest.TestCase): """ TestLoss is an unittest Class to test the Loss module """ def test_euclidean_loss(self): """ Test the euclidean loss with valid values ...
b7a2a3be31c05c30b0a7681671aa8bb632a370f5
Maulikchhabra/Python
/LearningPython/sets.py
2,617
4.34375
4
#Syntax => set={val1,val2,val3} days={"Mon","Tue","Wed","Thurs","Fri","Sat","Sun"} print(type(days)) print(days) list=[1,2,3,4,5] setList=set(list) #convert any other data structure into sets print(setList) #Heterogenous set1={True,"abc",12} #with immutable elements print(set1) #set2={12,25,[1,2,3]} with mutable...