blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1c60ed28095fad95d8d2ca3e2a9274c6e60e9aef
ShenDeng75/LeetCode
/牛客_重建二叉树.py
993
3.5625
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # 根据前序遍历和中序遍历,构造二叉树 class Solution: # 返回构造的TreeNode根节点 def reConstructBinaryTree(self, pre, tin): i = 0 def divi(node, subtin: list): root = Tre...
b5baf9ade545a5d6013a1cf17552d17114348d84
OSUrobotics/me499
/Week_0_python/f_tutorial_dictionary.py
7,559
4.25
4
#!/usr/bin/env python3 import numpy as np # What are dictionaries? # # Dictionaries are values (pretty much any data structure/variable type you can think of) paired with keys (unique # identifiers). Common key types are integers and strings. The best mental image for dictionaries are: I have a bunch of # items t...
6072d6977c2b7e3a7d9b86625789d4177d8d4484
jonathanvdc/datastructures-project
/Implementations/StackedMap.py
1,444
3.859375
4
from IMap import * class StackedMap(IMap): """ A stacked map is a map "stacks" two mapping function by applying a mapping function to the result of a first mapping function. A use case for this is when a key extracted from a record needs to be converted to its string representation. """ def __init__(s...
64a1c76d3fd8714e58ca8337ad149076245df725
sankalp33/python-programs
/out.py
139
3.625
4
x=2 print(x,x+1,x+2,x+3) x=4 print(x,x+2,x+4,x+6) x=6 print(x,x+3,x+6,x+9) x=8 print(x,x+4,x+8,x+12) x=10 print(x,x+5,x+10,x+15)
629a0137bd924fb4e96d21db8e50b69e031e3cfe
kingofyeti/leetcode-py
/324_wiggle_sort.py
343
3.65625
4
class Solution(object): def wiggleSort(self,nums): nu = sorted(nums) half = len(nums[::2]) # both two side has to be [::1], because the concatenate part may have problem nums[::2],nums[1::2] = nums[:half][::-1],nums[half:][::-1] nums = map(int,raw_input().split()) solution = Solution() print sol...
81fcb60af2783187ee030e0c3c914f52d8eb50fd
GithubLucasSong/PythonProject
/day010/day10作业.py
1,556
4.25
4
# 1.使用列表推导式求出50以内能被3整除的数的平方,并放入到一个列表中。 # list = [i**2 for i in range(1,51) if i%3 == 0] print(list) # 2.使用列表推导式构建这样一个列表:['python1期', 'python2期', 'python3期', 'python4期', 'python6期', 'python7期', 'python8期', 'python9期', 'python10期'] # list = [f'python{i}期' for i in range(1,11)] print(list) # 3.求结果(面试题) # v = [lambda :x f...
511115901c902d70d0439bfc0b830ba4fa4fb190
edkrueger/joblib-demo
/resc/functions.py
227
3.84375
4
""" Some math functions. """ def factors(a_int): """Find factors of an integer.""" factors_list = [] for i in range(1, a_int): if a_int % i == 0: factors_list.append(i) return factors_list
c743c12e2b0e327f813edf9c9a6ba1ef0d17c478
runiat/grade12
/a3recursion/ex1.py
714
4.21875
4
# this is an example of a recursive method def sum_num(num): ''' This function will recursivly determine the sum of the digits in an integer number. :param num: a positive integer :return: an integer that is the sum of the digits ''' # base case. if there is only one digit return it. if(nu...
50ceb1c8c6178b9d7975a0750d9a937f5dd269ac
aduV24/python_exercises
/2.input, processing, output/sales_tax.py
616
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 9 16:12:01 2019 @author: NOTEBOOK """ def main(): purchase = float(input("Enter the total amount of purchase: ")) tax(purchase) def tax(pur): sales_tax = pur * 0.04 county_tax = pur * 0.02 total_tax = sales_tax + county_tax total = pu...
0c1d392e4303a006e172a379d970460d31c407c1
elderberry-smells/zygosity-report-tool
/report.py
1,450
3.515625
4
import csv import sqlite3 # prompting for which QC#'s the user would like to report print "What QC#'s would you like to report?" start = int(raw_input('Starting QC#: ')) finish = int(raw_input('End QC#: ')) samples = ['QC-2016-' + str("%03d" % i) for i in range(start, finish + 1)] print 'Report Generated for...
a15f28b218a71842b2b4e86f3521d336b7884f86
Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021
/answers/MridulMohanta/Day15/question2.py
181
3.921875
4
def numpaths(m , n): if m == 1 or n == 1: return 1 return numpaths(m -1 , n) + numpaths(m, n-1) m = int(input("M: ")) n = int(input("N: ")) print(numpaths(m , n))
4c8d1d342ba31b79ae5dfca1e3bf95d4d3b830f4
HONOOUR/Algorithm_Test
/Algorithm_Python/solu.py
1,654
3.5
4
from collections import deque class Solutions: def getTime(self, n, start, end, roads, traps): answer = 0 graph = {} for road in roads: p = road[0] q = road[1] s = road[2] if p in graph: graph[p].append((q, s)) els...
f0e3d693e09fd134e790e01002bc66444c36c1ff
laky/advent_of_code_2020
/advent_of_code_2020_09.py
917
3.765625
4
from advent_of_code_2020_01 import find_numbers_summing_to def find_non_sum(numbers): window = numbers[:25] for n in numbers[25:]: sorted_window = window.copy() sorted_window.sort() if find_numbers_summing_to(sorted_window, n) == None: return n window.pop(0) window.append(n) def find_con...
0ff05f138b0d910a816a6d6ab4102983eb54d0a3
tanuj208/CipherForces
/encryption_codes/rsa_encoded/generate_large_prime.py
2,431
3.65625
4
# Large Prime Generation for RSA import random # Pre generated primes first_primes_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, ...
32725267b45cce51a7284072f355a235eec19934
yinili/PythonTest
/fib.py
153
3.5
4
def fib(max): n,a,b = 0,0,1 while n < max: yield b a, b = b, a+b n += 1 return 'well done' f = fib(5) print(list(f))
3ea32bafd7f10592a6c60a8328ce0846de0bdd07
Tejas-Naik/Python-ZTM-course-Andrei-Negoie
/Decorators/decorators.py
1,446
4.34375
4
# the syntax of Decorators is they have @name_of_decorator # @classmethod # @staticmethod def hello(): print('Hello') greet = hello() del hello print(greet) # functions in Python are the First Class Citizen # they act as the Variables def hello(func): func() def greet(): print("Helloooo") print...
063869cf221c9d968404d5958d145702d14b8ba6
katherine-hough/backend
/pantry/classes/MeasurementUnit.py
2,073
3.71875
4
#------------------------------------------------------------------------------- # Purpose: Represents an imperial unit of volume, imperial unit of weight, or other unit that is typically used in the United States when cooking # Author: K. Hough # Created: 11/06/2017 #-----------------------------------...
3609684669855cfd9ccf5d34a4f1376afb2c3c9d
ArchanGhosh/WhiZZ_Builds
/Python/View_and_Combine_STL/view.py
900
3.65625
4
from stl import mesh from mpl_toolkits import mplot3d from matplotlib import pyplot def view_stl(file_dir): '''The following function renders a 3D geometry mesh in Matplotlib, if helps you visualize a 3D object in a simple and fast way'''' figure = pyplot.figure(figsize=(30,30)) axes = mplot3d.Axes3D(figure) ...
4a00755da491a329e331e41a7e63c32fad36bd49
satishsolanki1990/Leetcode
/9_Palindrome.py
1,201
4.1875
4
""" 9. Palindrome Number Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is n...
f813142c196a3405d177684f88e3c77dcb83a33b
wsargeant/httlacs
/13.11.1_exercises.py
644
4.15625
4
def reverse_file_by_lines(oldfile, newfile): """returns newfile which contains all the lines from oldfile with the order of lines reversed """ infile = open(oldfile, "r") outfile = open(newfile, "w") list_of_lines = [] while True: text = infile.readline() if len(text) == 0: ...
fd6837f8de6e64a1c5c2a558c650660d090145b7
Soluspero/coding_practice
/techgig_solutions/python_practice/numpy/shape_reshape.py
1,618
3.875
4
''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT """ I needed to write reshape and finddim functions of my own as Techgig platform was not supported or install numpy module. Anyone can make this program with the help of n...
a457734c306ff0c42950a593d086e6d4349aeff9
kavyamaria/chatbot
/chatbot3.py
3,099
3.734375
4
from functions3 import * #from speech import * import re #from textblob import TextBlob #from textblob.taggers import NLTKTagger #nltk_tagger = NLTKTagger() import random import sys #say hi name = hello() firstIteration = True prompted = 0 exit = False while (not exit): # print("f") #read user input and change to...
7b36ec90930cc6ede7b947105a38c4d8eecbb2af
bennysetiawan/DQLab-Career-2021
/Data Manipulation with Pandas/Part 2/14.review-data-inspection.py
609
3.5
4
import pandas as pd # Load data global_air_quality.csv global_air_quality = pd.read_csv('https://dqlab-dataset.s3-ap-southeast-1.amazonaws.com/LO4/global_air_quality_4000rows.csv') print('Lima data teratas:\n', global_air_quality.head()) # Melakukan pengecekan terhadap data print('Info global_air_quality:\n', global_ai...
683a171492dc5b2025a97c190217df32455b0f8c
saiphaniedara/HackerRank_Python_Practice
/PythonFunctionals_MapLambda.py
376
4.03125
4
cube = lambda x: x*x*x # complete the lambda function def fibonacci(n): li = list() #li.append(0); li.append(1) if(n == 0): return [] elif(n==1): return [0] else: li.extend([0,1]) for i in range(2,n): li.append(li[i-1]+li[i-2]) r...
45285e4aff38b95b58184b14bf16a5922947e9a1
LakshK98/video-summarizer
/backend_logic/models/tsum_1000.py
798
3.8125
4
from torch import nn import torch.nn.functional as F class Model(nn.Module): def __init__(self): """ In the constructor we instantiate two nn.Linear module """ super(Model, self).__init__() # self.l1 = nn.Linear(3000, 300) # self.l2 = nn.Linear(300, 10) ...
29390f2f7a34dfd75bfee7ad5ac382a5877b7b49
Trash-Bud/FPRO
/REs/RE11/Function root.py
416
3.6875
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 10 12:12:17 2019 @author: Joana """ def bisect(f, n): i = 0 lb = 0 ub = 1 while i != n: mid = (ub + lb) /2 if (f(lb) < 0 and f(mid) < 0) or (f(lb) > 0 and f(mid) > 0): lb = mid else: ub = mid i += 1...
94ae9da1ec2c595f2748b1aa66b44a15c30768bb
pablma/Game_Development_2019_2020
/Automatic Learning/Mandatory 1/Practica1.py
3,678
3.78125
4
import numpy as np from pandas.io.parsers import read_csv import matplotlib.pyplot as plt # Function to load a csv file def carga_csv(file_name): """ carga el fichero csv especificado y lo devuelve en un array de numpy """ valores = read_csv(file_name, header=None).values # we are going to work wit...
66d22185b509602a50a3dfcf3bdfb7c340d06ed1
BryanMauricio/Codeforces
/codeforces/281/A.py
60
3.59375
4
string = input() print(string[0].capitalize() + string[1:])
68d8a0af961aa0951360f20a1d2069a9b8cd4ada
limjeongmin/p2_201611101
/w11Main_2.py
934
3.625
4
def survey(): DataA=[ [13.1, 37.1], [10.6, 34.6], [27.1, 40.0], [16.2, 37.8], [11.4, 29.8], [12.2, 26.5], [13.5, 29.7], [13.7, 37.6]] DataB=[ [8.7, 1.5], [13.4, 1.9], [2.9, 1.5], [6.8, 0....
521dcbc4bff47b2bf9fba2d5e170fd4b7e29528c
Frankiee/leetcode
/string/1056_confusing_number.py
1,865
4.09375
4
# https://leetcode.com/problems/confusing-number/ # 1056. Confusing Number # History: # Google # 1. # Mar 9, 2020 # Given a number N, return true if and only if it is a confusing number, which satisfies the # following condition: # # We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotat...
6116609d0e612940adf7d18f1644614ad2b5ef69
kimhyeongju/coding_practice
/APPENDIX/5_map.py
1,528
3.71875
4
""" --- input과 map함수이용 예제 --- input() -> 데이터를 입력받음 : 90 80 99 100 88 -- string input().split() -> 입력받은 문자열을 공백으로 나눠서 리스트로 바꿈 : [99,80,99,100,88] -- string map(int, input().split()) -> 위의 리스트 모든 elements에 int()함수 적용 : 99 80 99 100 88 -- integer list(map(int,input().split())) -> 위의 값을 list로 저장 : [99,80,99...
fe2f287c66e1d05c2d71340b90de6f034104c3b1
Sharim-Spartan/lesson4
/batches.py
1,090
3.765625
4
class batches(): def __init__(self,studentID,module, student, start_date): self.studentID=studentID self.module=module self.student=student self.start_date=start_date def list_batch(students): list_students = [] list_students.append(students.studentID) li...
4dec9b2362d40bc4598d600193ded2e5442f2338
raffomartini/pyclass-intermediate
/circuitous_client.py
2,918
4.0625
4
''' Our customers' code. ''' from circuitous import Circle from random import random, seed def customer_0(): ''' Customer 0: Our academic friends :return: ''' print 'Aproposal to reserach the areas of circles' print 'with Circuitous(tm)', Circle.version n = 5 seed(42) #circles =...
e983c7f130255d652dda884ba23d86f76d0579a6
noozip2241993/dictionary-python
/task13.py
239
4.0625
4
def mapping_two_lists(l1,l2): """Write a Python program to map two lists into a dictionary.""" return dict(zip(l1,l2)) list1 = ['Khang','Trang','Me','Ba'] list2 = ['Jack','Kristy','Tho','Ninh'] print(mapping_two_lists(list1,list2))
fcb4f4f8d30f85d07a5248c851109df32f25b8ed
erjan/coding_exercises
/sum_of_digits_in_base_k.py
649
3.921875
4
''' Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10. ''' class Solution: def sumBase(self, n: int, k: int) -> int: ou...
52935c6b398795cb7e2d2f363c5e6a943b328d3b
tianyudwang/ECE276B
/ECE276B_HW2/code/test.py
2,527
3.53125
4
import heapq import numpy as np class PriorityQueue: def __init__(self): self.elements = [] def empty(self): return len(self.elements) == 0 def put(self, item, priority): heapq.heappush(self.elements, (priority, item)) def get(self): return heapq.heappop...
e8d6aaafbf3ee5de6b62684f3e5db5421419dc92
Feesterra/epam_course
/task 6.1.py
1,117
4.03125
4
class Price: """Checks parameters (0-100).""" def __init__(self, label): self.label = label def __get__(self, instance, owner): print("Descr.__get__") return self.__dict__[self.label] def __set__(self, instance, value): print("Descr.__set__") if value < 0 o...
d6cb83df000f9a43a54f46d3955028738b424bee
obround/ppci
/examples/python/mandelbrot.py
484
3.765625
4
# def print(txt: str): # pass # def println(txt: str): # pass def mandelbrot(): w = 50.0 # h = 2.0 h = 50.0 y = 0.0 while y < h: x = 0.0 while x < w: Zr, Zi, Tr, Ti = 0.0, 0.0, 0.0, 0.0 Cr = 2.0*x/w - 1.5 Ci = 2.0*y/h - 1.0 i = 0 while i < 50 and Tr+Ti <= 4.0: Zi = 2.0*Zr*Zi + Ci ...
3670064e84011d35bedb04677cc1a0d81657e8ff
Datateknologerna-vid-Abo-Akademi/gulis-chat
/part5/examples/5.1/chat_gui.py
436
3.75
4
from Tkinter import * def update_label(): value = str(entry.get()) label_value.set(value) entry.delete(0, END) root = Tk() app = Frame(master=root) label_value = StringVar() label_value.set("Hello world!") label = Label(master=app, textvariable=label_value) label.pack() entry = Entry(master=app) entr...
0503ef6d69dcb40bf977a023521246abaa6a38e9
apu1995/appucodes
/findDuplicates.py
751
3.71875
4
# Duplicates in array def findDuplicates(arr): n=len(arr) track={} dups=[] for i in range(n): if arr[i] in track: if track[arr[i]]==1: dups.append(arr[i]) track[arr[i]]=track[arr[i]]+1 else: track[arr[i]]=1 return dups def findDuplicatesOptimal(arr): res=[] for i in range(len(arr)): pos=ab...
3a86e38b573a8ee6f002f86c34e647fe80492372
misaka-10032/leetcode
/coding/00061-rotate-list/solution.py
971
3.65625
4
#!/usr/bin/env python3 # encoding: utf-8 class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def get_len(head: ListNode): it = head cnt = 0 while it is not None: it = it.next cnt += 1 return cnt def move_to_last_k(head: ListNode...
31108aec2d838b5beaace50eeaa5d03ede48d5a3
testyingbo/study_python2.7
/search/search.py
517
3.984375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # 顺序查找 def sqeuentialSearch(alist, item): pos = 0 found = False while pos < len(alist) and not found: if alist[pos] == item: found = True else: pos = pos + 1 return found def search(alist, item): found = False ...
0bef4110c5aa23ca2f746203345778b0e11008a8
DavidFerri7/Ejercicios-de-dise-o-en-OOP
/EJERCICIOS PDF/4.py
729
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #4. Crea una clase Fraccion con métodos para sumar, restar, multiplicar y dividir fracciones. class Fraccion(): def __init__(self,numero,num): self.numero = numero self.num = num def sumar(self): return self.numero + self.num def rest...
d1189aeea303cfcc41f002790b2c90197b18c520
KavinRaj2k01/challenges
/fibanocci in dynamic.py
177
3.953125
4
n=int(input("Enter the fibanocci num")) arr=[0,1] def func(num): for i in range(2,n+1): a=arr[i-2]+arr[i-1] arr.append(a) return arr[num] print(func(n))
529bdf27e703f3dc6f5735fa2a1166d69dfdd473
999masks/python_projects
/sandbox/my/tests/BreakableQueue.py
1,000
3.515625
4
from Queue import * # import time class QueueStop(Exception): """Break out of queue wait requested""" pass class QueueTimeout(Exception): """break out of queue wait requested""" pass class BreakableQueue: def __init__( self ): # super(BreakableQueue,self).__init__() self.q =...
449a8f0adab49c7b169a53bf2ccc09af4e5d85df
lhogan2018/inClassCollabExamples
/scope3.py
202
3.78125
4
def func2(): global s print(s) s = "hello hello" print(s) def func1(): s = "hi hi" print(s) s = "Hello World" func2() print(s) #will print hello world then hello hello then hello hello again
652afaa4e6d5053b9d81129d364d99f29d18b10d
Orderlee/tjoeun
/pycharm/ch02/ex03.py
702
3.75
4
#문자열 : 큰따옴표 또는 작은따옴표로 묶음 a = 'Hello World' print(a) print(type(a)) a = "Hello World" print(a) print(type(a)) #문자열에 작은따옴표가 포함될 경우 a = "I'm sorry" print(a) a ='I\'m sorry' print(a) #문자열에 큰따옴표가 포함될 경우 a = '"파이썬"은 쉽다.' print(a) a = '\"파이썬\"은 쉽다.' print(a) #문자열에 작은따옴표+큰따옴표가 포함될 경우 a = '\"I\'m sorry"' prin...
d6fe632ba0d7cebd9ea47d7423422f2f0a420a43
faruk9984/language_translator
/project33.py
287
3.625
4
# Build language translator python code from googletrans import Translator translater=Translator() story='''Tell me who does not love baby yoda from Mandolarian? Baby yoda, Baby yoda, Baby yoda has shaken me like soda. ''' out=translater.translate(story,dest="bn") print(out.text)
7d6c619af9cde96cb4e41f0057fb449194335a5d
love4code/pythonTricks
/Automate_task/Delete_Files_Folders/delete_stuff.py
853
3.78125
4
import os, shutil # to delete a file or a single empty folder you use functions from the os # module # To delete a folder and all of its contents you use shutil # Be careful when running the kinds of functions. # run the code with print statements as a dry run before deleting forever! # delete all .txt files in a g...
27ce32494070b81c811263fedf7013ad20afb89a
RIKnight/Exercism_exercises
/python/little-sisters-vocab/strings.py
2,046
4.125
4
#! /usr/bin/env python """ Name: strings.py Purpose: exercism, python track, strings: 1. Add a prefix to a word 2. Add prefixes to word groups 3. Remove a suffix from a word 4. Extract and transform a word Written by: Z Knight, 2021.11...
7a8d8347967bbf83a59207141c208a9d5bcbab33
Hu-Wenchao/leetcode
/prob125_valid_palindrome.py
895
4.03125
4
""" Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. """ class Solution(object): def isPalindrome(self, s): """ :type s: str :rtyp...
751a0292d7f84b53fc00ed0ad383672d8562de3a
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/eric_grandeo/lesson03/logic_1.py
631
3.515625
4
#cigar_party def cigar_party(cigars, is_weekend): if not is_weekend: return 40 <= cigars <= 60 else: return is_weekend and cigars > 40 assert cigar_party(30, False) == False assert cigar_party(50, False) == True assert cigar_party(70, True) == True print("Cigar party tests passed") #date_fa...
33f1b47d77ac2ed453a4bc9bc026f86ffc0e005b
gabriellaec/desoft-analise-exercicios
/backup/user_393/ch121_2020_10_04_22_31_12_524965.py
451
3.5
4
def subtracao_de_listas(lista1,lista2): lista= [] i=0 while i < len(lista1): a= 0 while a < len(lista2): if lista1[i]== lista2[a]: lista1[i]= 'x' a= a + 1 else: a= a + 1 i= i + 1 n= len(lista1) k= 0 w...
542a74028c0ac2ab43fbf2e7556f5ceb0245741c
jinglongzou/Sword_Offer
/Sword_Offer/issue40.py
2,726
3.515625
4
# -*- coding:utf-8 -*- # 一个整型数组里除了两个数字之外,其他的数字都出现了两次。 # 请写程序找出这两个只出现一次的数字。 # 输入:一个数组(一个列表) # 输出:找出数组中只出现一次的数字 # 考察算法技巧,如何使得时间复杂度更小;考察位运算,逻辑运算的应用; # 暴力法:借助字典,遍历并计数每个数字出现的次数,然后遍历字典返回计数为1的数字,时间复杂度为O(n) # 异或法,由于题强调了两个数字出现一次,其他都出现两次,因此对数字异或后只有出现一次的数字为1. # 异或法实现的思路: # 1、对于出现两次的元素,使用“异或”操作后结果肯定为0, # 那么我们就可以遍历一遍数组,对所有元素使用...
a2b8e9d744289a1b6d5d8617b4f945b1e65f6c65
PythonClassRoom/capitulo_5
/generator_ejemplo.py
195
3.609375
4
def cuenta_atras(item): while item > 0: yield item item -=1 for i in cuenta_atras(5): print(i) lista = [1,2,3] gen = (7*item for item in lista) for i in gen: print(i)
2f7302f622692f8f55251af221072c23a24cecd8
AmigaTi/Python3Learning
/inout/io-json.py
3,133
3.8125
4
#!/usr/bin/python # -*- coding: utf-8 -*- import json # ================================================================= # json # Python内置的json模块提供了非常完善的Python对象到JSON格式的转换 # 由于JSON标准规定JSON编码是UTF-8, # 所以总能正确地在Python的str与JSON的字符串之间转换。 # 把Python对象变成一个JSON # dumps()方法返回一个str,内容就是标准的JSON # dump()方法可以直接把JSON写入一个file-lik...
a8a687d14207be3b5f06580122c15ac89aa273dc
here0009/LeetCode
/Python/428_SerializeandDeserializeNaryTree.py
2,699
3.9375
4
""" Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize ...
8701d29c48aa35e347a143982ee5d7bd048e23f4
vovanua4/python
/oop/peopleClass.py
230
3.5625
4
class People: secondName='None' firstName='None' age='0' city='0' def __str__(self): strReturn = str(self.secondName.capitalize()) + ' ' + str( self.firstName.capitalize()) return strReturn
388750266b7a50afa7ffb353f2a0aad4816bf9e4
Raamkishore/30-Days-of-Coding
/Encryption/solution.py
582
3.828125
4
#!/bin/python3 import math import os # Complete the encryption function below. def encryption(s): result = [] s = ''.join(s) l = math.floor(math.sqrt(len(s))) h = math.ceil(math.sqrt(len(s))) for i in range(h): var = "" for j in range(i, len(s), h): va...
b81e9d20bb8e41cbee3dced1b03e331042e54bc3
ApiliDiaz/tutorials
/DataStructures/Problems/Mobile_Manufacturing/mobile_manufacturing.py
5,193
4.125
4
import random from itertools import permutations def merge(list_1, list_2, pos): """ This method will merge the given two items and return the sorted output """ l1, l2 = len(list_1), len(list_2) # Store the length of each list merged_output = [None for i in range(l1 + l2)] i, j = 0, 0 # Compare e...
43ff4c3b3d2582653f22e8f9fd7478bc98bb799b
phgodoy/api_movie
/main.py
328
3.703125
4
#importa arquivo movie import movie as mv #declaracao das variaveis esc = False dictionary = False #menu while not esc: op = input('Escreva o nome de um filme ou exit para fechar: ') if op == 'exit': esc = True else: movie1 = mv.Movie(op,dictionary) print(movie1.printDetai...
233c9b22973fad2cdb165d67df86d70c0938997b
AlphaCaprice/grokking_algorithms
/grokking_algorithms/chapter4/divide_and_conquer.py
857
3.9375
4
import random def recursion_sum(array_list: list) -> int: if not array_list: return 0 return array_list[0] + recursion_sum(array_list[1:]) def recursion_max(array_list: list) -> int: if len(array_list) == 1: return array_list[0] max_element = recursion_max(array_list[1:]) return ...
979b9219e75411a8091870cfae2b8bb89e49bbe7
Say10IsMe/SVBA-ED
/Practica5-Pila(MetodoPush).py
1,395
3.953125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 26 18:09:16 2018 @author: pc """ #Aqui declaramos el arreglo y la variable que definirá el tamaño máximo de #nuestra pila pila=[] numerodatos=5 #Se define el metodo push, el cual se encarga: primero de verificar si la #actual longitud de la pila es menor a el...
8bd626f6502f4c2f813ed681481de47ea6295f39
DidierPH/Portefolio
/Programming/Py3_5.py
204
3.703125
4
def Ifeven(number) : if number % 2 == 0 : return True else: return False Getallen = [ 4,5,1,2] for integer in Getallen: if (Ifeven(integer)): print(integer)
70bcc023cddc4400bc82a59584e064f0d58d3e9f
dkrotx/leetcode
/477-hamming.py
1,773
3.5625
4
import unittest import random # Input: 4, 14, 2 # # Output: 6 # # Explanation: In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just # showing the four bits relevant in this case). So the answer will be: # HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6. cla...
40e0c0e5da2e15658bb7181a17952a37e8dcd772
bharatgupta99/beginner-python-projects
/coin-wrapper.py
1,295
3.828125
4
from math import ceil weight_unit = input('enter g for grams or p for pounds ') while weight_unit != 'g' and weight_unit != 'p': print('enter proper units!') weight_unit = input('g->grams/p->pounds ') weight_of_pennies = float(input('enter weight of pennies: ')) * (453.6 if weight_unit == 'p' else 1) weight_of_nic...
e2230c7b571f24a2af9e881bda63eaeb809c4434
nur-hafiz/Hangman-Py
/hangman.py
3,288
3.671875
4
from random import choice import re class Bank: colours = ['red','blue'] animals = ['dog','cat'] topic_names = ['Colours','Animals'] topics = {'Colours':colours,'Animals':animals} def __init__(self): self.current_topic = '' self.current_word = '' self.current_word_display =...
c5549ded1f8d30be943a37b0423a2590e92c5bdf
nimbfire/o-nome-do-repositorio-nao-me-importo
/atividade_2/Lista.py
3,220
3.515625
4
from No import No class Lista: def __init__(self): self.inicio = None self.tamanho = 0 def __len__(self): return self.tamanho def __str__(self): if self.inicio: retorno = "\033[96m---------------------------------------------------------------------------------------------------------|\03...
e4430bf11b8c49f1060199e2aba29824815a3850
pruksmhc/KPCB
/tests.py
3,745
3.765625
4
import unittest from HashMap import HashMap import random import numbers import string class TestHashMap(unittest.TestCase): def setUp(self): self.size = random.randrange(1, 200) self.hash_map = HashMap(10) def test_initial_state(self): ''' Test initial state after object creation ...
b2f8301adc3dcffa0f4d7a5805d109761856cac8
gabriellaec/desoft-analise-exercicios
/backup/user_328/ch116_2020_04_11_22_57_58_736340.py
237
3.546875
4
def raiz_quadrada(numero): time = 0 i=0 x= True while i <= numero: numero -= i print('Valor do contador: ', i) if numero == 0: x = False i += 2 time += 1 return time
2b94f88b1be7976429a62cf29a2a62d271b7039b
gabriellaec/desoft-analise-exercicios
/backup/user_373/ch32_2020_04_22_18_19_55_978081.py
309
3.5
4
def lista_primos (n): primo= True while primo: if n% 2 = 0: primo = False elif n%3 = 0: primo = False elif n% 5 = 0: primo = False elif n%7 = 0: primo = False else: primo True return n
a2e43df1e5d0a8d8a029d287110ded4bfb1938a3
mishthefish/CodeHS-Python-Rainforest-
/Conditionals/4.5.4: Correct Portion
478
4.0625
4
# Amount of food and number of people tons_of_food = 0.07 num_people = 25 # Determine how much food each person gets tons_of_food_per_person = tons_of_food / num_people print tons_of_food_per_person # Ask the user how much food they took tons_taken = float(input("How many tons of food did you take? ")) if round(tons_...
15c15352244691dc95409f9855affa59b7b57efb
evanapplegate/geocomputing
/Lab 5/task2.py
2,015
3.828125
4
import os import sys import csv # for some reason my python install cant find stuff in the current directory # of the script, so this tells it to change directories to wherever the heck # the script lives os.chdir(os.path.dirname(sys.argv[0])) # this opens the CSV file spreadsheet = open("CityPop.csv","rt") restart...
78a30342783a2fcc1167618e50a779c6130e7271
luzperdomo92/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
586
4.40625
4
#!/usr/bin/python3 """add_integer module """ def add_integer(a, b=98): """ add_integer: Check input if correct, Float arguments are typecasted to ints before addition is performed. Return the integer addition of a and b by default return 98. TypeError: If either of a or b is a non-integer and non-...
1c6e8ba365de155a11715050fde23f6f6c58724f
whimax07/DietCoke
/MyFirstGUI.py
836
3.71875
4
from tkinter import * class Window(object): def __init__(self, master): self.master = master self.master.title('Nice GUI V2') self.master.geometry('400x400+700+1') self.master.config(bg='#fff') self.master.resizable(0, 0) self.AddWidgets() def AddWidgets(self):...
ff050b15e136a25d4bb8bbea640f91bb8396edcd
ofreshy/Rosalind
/problems/madel.py
569
3.640625
4
""" Given: Three positive integers k, m, and n, representing a population containing k+m+n organisms: k individuals are homozygous dominant for a factor, m are heterozygous, and n are homozygous recessive. Return: The probability that two randomly selected mating organisms will produce an individual possessing a domi...
e2e765f6a8b73594eba2b52e74de6aa015b0f30a
boodscode237/regEx_python
/deepRegex.py
2,099
3.78125
4
import re # The Caret and Dollar Sign Characters beginsWithHello = re.compile(r'^Hello') endsWithWorld = re.compile(r'world!$') print(beginsWithHello.search('Hello, world!')) print(endsWithWorld.search('Hello, world!')) print(beginsWithHello.search('He said hello.') == None) alldigitsRegex = Regex = re.compile(r'^\d+$...
8b1b01b27f54c2f416679922ceec2471b7a001d9
remixknighx/quantitative
/exercise/leetcode/sum_of_root_to_leaf_binary_numbers.py
1,244
3.75
4
# -*- coding: utf-8 -*- """ 1022. Sum of Root To Leaf Binary Numbers @link https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/ """ from tree_node import TreeNode class Solution: def __init__(self): self.binary_list = [] def sumRootToLeaf(self, root: TreeNode) -> int: if root is...
9b51e0a2df8fc134dfc979d83fbd393b5d187669
hackingmath/puzzles
/pickleball3.py
5,005
3.96875
4
"""Pickleball Tournament 12 teams 6 courts, 11 rounds 2 pickleball courts 1 dink court 1 left handed court 1 swim noodle court 1 one-bounce court Each team should play 3-4 rounds PB 1 or 2 rounds each of the other games""" import random from itertools import combinations import time start = time.ti...
0232b6600a0620f0ab65945668327c5f7f67ca2c
kammitama5/Distracting_KATAS
/countvowelsinstring.py
536
3.640625
4
def count_vowels(s = ''): if type(s) == str: a = s.lower() b = list(a) count = 0 for i in b: if (i == 'a'): count = count + 1 elif (i == 'e'): count = count + 1 elif (i == 'i'): count = count + 1 ...
1ea18f6b0720a975f57d60aa5d311895563a1558
pmba/algorithms
/python/kruskal.py
1,687
3.640625
4
import heapq class UnionFind: def __init__(self, size): self.parent = [-1 for x in range(size)] def root(self, v): if self.parent[v] < 0: return v else: self.parent[v] = self.root(self.parent[v]) return self.parent[v] def sameSet(self, v, u): ...
e29a9eb7bea6bc1eed8e16b51d4f277efa720d90
smlund/warp_uem
/config/my_config.py
3,732
3.640625
4
import re import numpy from ConfigParser import * class MyConfigParser(ConfigParser): """ Extends config parser to do some post processing. """ def get(self,section,key): """ Translates the markup in the config file. Specifically, returns a dictionary if both ',' and ':' are present, returns...
f64b5c79b0275fdfb9c08c9c97bfb2e0728c464b
pinturavi/assignment1
/arrays0.py
281
3.8125
4
if __name__ == '__main__': score = 100 score2 = 50 score3 = 75 for i in range(score): print("#", end="") print() for i in range(score2): print("#", end="") print() for i in range(score3): print("#", end="") print()
eb17d8848a013c952532568940907aea24564809
reachviji/ML_Assignment1
/Asign1.4_Prime_with_Break.py
864
3.9375
4
# Python Program to check given number is Prime number or not (using break) """ In Assignment 1.2 we used Python library sympy In this case we will achieve the same using the regular for loop and break statement""" print("Hi, welcome to assignment 1.4: Program to check if number is prime or not using break") whil...
c185dbf3dfe92d80bc26c9b3b3ab522c6378962a
nichenxingmeng/PythonCode
/蓝桥杯/数学/___完数.py
342
3.53125
4
'''import time start = time.time()''' from math import sqrt n = int(input().strip()) count = 0 for i in range(1, int(sqrt(n))+1): if n%i == 0: count += i count += n//i if count == 2: temp = count else: temp = count - n if temp == n: print('yes') else: print('no') '''end = time.time(...
6ef293f726b91a711bd4df11a268e66f295eff67
Sahil4UI/PythonRegSept7-00Evening
/if statement.py
341
4.03125
4
''' n = int(input("Enter your number : ")) #if statement - one single condition #indent/indentation - spacing if n%2==0: print("Even") else: print("odd") ''' a = int(input("Enter first number :")) b = int(input("Enter second number :")) if a>b: print("a is large") elif a==b: print("b == a ") else: ...
2614b62622464daf9a9469f6b3e1b53bf9a3e31c
munyumunyu/Python-for-beginners
/docs/OOPS/Reference_variable_4.py
506
4.21875
4
''' Just like the balloon with multiple ribbons, if we change the attribute of an object through one reference variable, it immediately reflects in other reference variable as there is only one balloon ultimately! ''' class Mobile: def __init__(self, price, brand): self.price = price self.brand =...
da8122f05c41197dfbfe2dfb773168121d1fac6c
Aasthaengg/IBMdataset
/Python_codes/p03035/s366610933.py
141
3.578125
4
import math A, B =map(int,input().split()) if A >=13 : print(B) elif A >= 6 and 12 >=A : print(math.floor(B/2)) else : print(0)
315803153d5ab8c240e2ee25787139862df026dc
1324aman/test
/assignment24july/sudoku.py
2,996
3.671875
4
'''A 16x16 sudoku solution must satisfy all of the following rules: 1. Each of the digits 1-G must occur exactly once in each row. 2. Each of the digits 1-G must occur exactly once in each column. 3. Each of the digits 1-G must occur exactly once in each of the 16 4x4 sub-boxes of the grid. ''' from math import sqrt ...
bcdc5fc63479180cda585a8627db63cdaed7d577
gbmikhail/pyalg
/lesson_8/task_1.py
1,119
4.0625
4
# 1. Определение количества различных подстрок с использованием хеш-функции. Пусть на вход функции дана строка. # Требуется вернуть количество различных подстрок в этой строке. # Примечание: в сумму не включаем пустую строку и строку целиком. # # Пример работы функции: # func("papa") # 6 # func("sova") # 9 def substr...
ebdbcdc08ec64ad087f7384301a1c7c318d89e92
piyushkashyap07/linked-list
/Print ith node.py
2,747
3.8125
4
# For a given a singly linked list of integers and a position 'i', print the node data at the 'i-th' position. # Note : # Assume that the Indexing for the singly linked list always starts from 0. # If the given position 'i', is greater than the length of the given singly linked list, then don't print anything. ...
0063a4b2dae1ced3dcf070674214b14b5d0eb023
TataSatyaPratheek/Tic-Tac-Toe
/Problems/Vowel count/main.py
163
3.953125
4
string = "red yellow fox bite orange goose beeeeeeeeeeep" vowels = 'aeiou' count = 0 for letter in string: if letter in vowels: count +=1 print(count)
8aab74c99db8b9a9b0a0b9e531865078eaa0637c
bishalsarkar77730/work-management-system-in-python
/project.py
1,972
3.59375
4
import datetime def getdate(): return datetime.datetime.now() def take(): b = int(input("enter 1 for python classes \n enter 2 for python projects \n enter 3 for c clases \n enter 4 for c projects")) if b == 1: value = input("type here \n") with open("my python classes.txt", "a") as o...
89e33a10753456bd64736a304785389c549bf9b8
cursosfernedy/cursoBasicoPython
/Ejercicio_2.py
1,670
4.28125
4
#Saludo al usuario print("Hola") name = input("¿Quien eres?") while name == "": print("ingrese su nombre") name = input() print("Hola,", name, "Esta es asistente de calculadora básica") #Fin del Saludo #Contador contador = 0 #Solicitud de números numero1 = float(input("Ingrese el primer número:")) n...
e851bb938c2e2ab328eb29c4675d574ef9835011
code4happylife/Python-100-Days
/Day01_15/code/Day05/guess.py
1,207
4.125
4
""" 猜数字游戏 计算机出一个1~100之间的随机数由人来猜 计算机根据人猜的数字分别给出提示大一点/小一点/猜对了 Version: 0.1 Author: 骆昊 Date: 2018-03-02 """ import random answer = random.randint(1, 100) counter = 0 while True: counter += 1 number = int(input('请输入: ')) if isinstance(number,int) and number > 0: print("Right! You input correct format ...
2f413f47869620cb6710c2b83d286b5473433a47
michellegleed/Python-Tasks-Week-4
/loops/loops_exercises.py
1,096
4.125
4
# Question 1 number = input("Type a number ") result = 0 while len(number) > 0: num = int(number) result = result + num number = input("Type a number ") print(result) # Question 2 mailing_list = [["Roary", "roary@moth.catchers"],["Remus", "remus@kapers.dog"],["Prince Thomas of Whitepaw", "hrh.thomas...
2fce3062133859e546f6cf98585d8711ae833a22
kktn/AOJ
/Introduction_to_Algorithms_and_Data_structures/ALDS1_7_RootedTrees.py
929
3.625
4
import sys def get_depth(id, depth_dict, parents): if id in depth_dict: return depth_dict[id] if parents[id] == -1: depth_dict[id] = 0 return 0 depth_dict[id] = 1 + get_depth(parents[id], depth_dict, parents) return depth_dict[id] children = dict() parents = dict() depth_dict =...
b1a14f44a5a47c1d584d56367eef7d600dc3de8a
Sabarikn/python_project
/phno.py
179
3.609375
4
import re import sys ph =sys.argv[1] rule=re.compile(r'(^[+0-9]{0,3})([0-9]{10,11})$') if not rule.search(ph): print('Invalid mobile number') else: print('number validated')
140ff17ff82e97b0fdef987562df59acc5963ad3
soysoss12345/The-Blind-King-s-Chess
/pieces.py
11,695
3.640625
4
class Piece: def __init__(self, color, row, col): self.color = color self.row = row self.col = col class Pawn(Piece): def __init__(self, color, row, col): Piece.__init__(self, color, row, col) self.first_move = True if color == "W": self.va...
e5303b838df713edc4e80e4bd6b22de76b45b828
Diego4Cornejo/python-exercise
/basic-py/between.py
270
4.125
4
var = 3 if (var > 0 and var < 10): print ("Number is between 0 and 10") elif (var > 10 and var < 20): print ("Number is between 10 and 20") elif (var > 20 and var < 30): print ("Number is between 20 and 30") else: print ("NUmber is not between 0 and 30")