blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
ce5115f3222894b144a0c437868fd84fbf6d920b
paulpatault/Algorithmic
/Various/valid_brackets.py
1,241
4.0625
4
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: - Open brackets are closed by the same type of brackets. - Open brackets are closed in the correct order. - Note that an empty string is also considered valid. """ d...
dd999019c6a4545ac0c3e2d8aea9fbd7b83589bf
paulpatault/Algorithmic
/Matrix/existing_word.py
1,100
4.0625
4
""" Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left-to-right, or up-to-down. For example, given the following matrix: [['F', 'A', 'C', 'I'], ['O', 'B', 'Q', 'P'], ['A', 'N', 'O', 'B'], ['M', 'A', 'S', 'S']] 'FOAM'-> retu...
2dfb785a9e99c52a8013c14d5f2c0e5b6dce7d6b
LegionMG/sci_code
/gen_quadra.py
2,039
3.671875
4
from random import choice, random from time import time def get_random_letter(last_letter): a = random()*19 if a < 3/19: return "*" elif a< 8.33333/19: return "a" elif a < 12.66666/19: return "b" return "c" def get_random_letter2(last_letter): alphabet = ["a","b","c"] a = choice(alph...
2de796a9e6c6abc3329e81781f44c6cb74877b77
zabulskyy/Algorithms_UCU
/task_07.py
1,779
3.953125
4
def knapsack(items, weight): """ :param items: [(value, weight), ...] :param weight: int :return: total_value, result_items """ # initialize local variables di = dict() # {weight:(max value, where from, index in original list)} keys = set() # keys of di, must be assigned as dict cann...
1203313ebdfaa425f86d0957b27d5535b49c77d7
zabulskyy/Algorithms_UCU
/task_05.py
4,605
3.75
4
import random class HashTable: def __str__(self): s = "" for i in self.table: s += str(i) + ("\n" if self.hash_type == 1 or self.hash_type == 2 else " ") return s def __init__(self, hash_type, values): self.m = len(values) * 3 self.hash_type = hash_type ...
2c5b327a4407c39fc58e0fd3183737bb136626b3
aryoferdyan/Python-Projects-Protek
/Praktikum 08/langkahkerja.py
1,886
4.25
4
print("1.Buatlah list a = [1, 5, 6, 3, 6, 9, 11, 20, 12] dan b = [7, 4, 5, 6, 7, 1, 12, 5, 9") a = [1,5,6,3,6,9,11,20,12] b = [7,4,5,6,7,1,12,5,9] print(a) print(b) print('') print("2.Sisipkan nilai 10 ke dalam indeks ke 3 dari a, dan 15 ke dalam indeks ke 2 dari b") #insert(indeks ke-9, nilai) a.insert(3,10) b.insert...
739650777b758d8dcbfca0d7177668a1398ea220
aryoferdyan/Python-Projects-Protek
/Praktikum 10/latihan1.py
196
3.78125
4
jumlah = int(input('Jumlah')) kat = int(input('Kategori')) if kat == '1': harga = 255000 if kat == '2': harga = 150000 if kat == '3': harga = 75000 total = jumlah*harga print(total)
bcaffde2c3b028fb194871bcfa17cc7135ed0902
aryoferdyan/Python-Projects-Protek
/Praktikum 06/starFormation1.py
195
3.5625
4
def starFormation1(n): i = 0 while (i < n): j = i + 1 while (j > 0): print('* ', end='') j -= 1 print() i += 1 #starFormation1(5)
c158b8e7e43a3d90d3eeca8635d321b790fca42c
aryoferdyan/Python-Projects-Protek
/test copy.py
648
3.65625
4
print('============================') print('Kode Waktu') print('1. Jam') print('2. Menit') print('3. Detik') a = int(input('Pilih kode waktu yang dikonversi : ')) b = int(input('Pilih kode waktu hasil konversi : ')) c = int(input('Masukan jam = ')) x = 60 if a == 1: if b == 1: hasil = c if b == 2: ...
d001674dd6a054da8536bdfb8565cb423a5e49e2
Onselius/mixed_projects
/factors.py
741
4.34375
4
#! /usr/bin/python3 # factors.py # Finding out all the factors for a number. import sys def check_args(): if len(sys.argv) != 2: print("Must enter a number") sys.exit() elif not sys.argv[1].isdigit(): print("Must enter a number") sys.exit() else: return True check...
aea7731a7a6b8e648991024627380fcdb703bc52
chnandu/practice-problems
/knapsack/rod_cutting.py
715
4.03125
4
#!/usr/bin/python # Cut the rod in pieces such that maximum price can be yielded import sys def rod_cutting(prices, n): """Return the maximum price that can be yielded after cutting the rod in to pieces :param prices: List of prices as price at index reflects the price of the rod length of index :param ...
0c4cd9c30e2aea5cba02438d615de183b3125b6e
chnandu/practice-problems
/string-problems/urlify.py
1,194
3.75
4
#!/usr/bin/python # URLify - # Given a string with spaces in it, replace spaces with %20 and return the updated string # Example: "Mr John Smith", 13 --> Mr%20John%20Smith # # Note - length of the string would also be given def urlify(a_str, a_len): """Urlify given string :param a_str: Given string :para...
882145ab3ef396f1cf082b5a6e912dad48597167
chnandu/practice-problems
/string-problems/unique_chars.py
644
4.25
4
#!/usr/bin/python # Check if given string has all unique characters or not def check_uniqueness(str_): """Check if given string has all unique characters and return True :param str_: Given string :returns: True, if all characters are unique. Else, False. """ char_dict = {} for c in str_: ...
bbf3eaa945e46bdf69d4acfe9e2386ac3e974b58
Nik-Koshlakov/lab_testing_2
/dejkstra/graph.py
1,865
3.609375
4
import random __author__ = 'max' class Node: COUNTER = 0 def __init__(self): self.name = Node.COUNTER Node.COUNTER += 1 self.mark = None self.connects = [] def add_connect(self, value, node_to): if not isinstance(node_to, Node): raise TypeError ...
19d8827e546d342d20bf2ea38791d9452cbd7316
Savitha-python23/python-classes
/evenfunday3.py
186
3.546875
4
s = "SAVITHA" a = list(enumerate(s)) # Method 1 print(a) for k in enumerate(s): # Method 2 print(k) def idx(s): for data in range(len(s)): # Method 3 print(data,s[data]) idx(s)
20100237c0d6ebc3208e53b67d3a58041b808018
wholesomegarden/Challenge18
/QRMatrix.py
14,270
3.78125
4
# QRMatrix.py import sys import numpy from PIL import Image class QRMatrix: """ The QRMatrix Class that will allow users to encode and decode QR Codes. """ type_of_encoding = {0 : "End", 1:"Numeric", 2:"Alphanumeric", 3:"Structred Append", 4:"Byte", 5:"FNC1 in First", 7:"Exten...
a7ea1d5ba98de81e2272d93f316e71604e7e69e6
Tanbery/Pytorch
/Kaggle/important_notes.py
3,556
3.546875
4
######Import Libraries#### import numpy as np import matplotlib.pyplot as plt import pandas as pd ##### Reading data from file###### dataset = pd.read_csv('Data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, -1].values dataset = pd.read_csv('Salary_Data.csv') X = dataset.drop(["Salary"],axis=1) y = dataset...
ecb40ecd9d7df6fda02f3b216c37f1a49c92c95f
LorisMarini/cancer_wisconsin
/utils.py
1,033
3.5
4
from dependencies import * def learn_tree(*, X_train, y_train, X_test, y_test, features, max_features=None, max_leaf_nodes=None): """ Implements training and testing for a decision tree classifier """ if max_features: if max_features < 1 or max_features>len(features): raise ValueErr...
94694998405155678bdb52c69c9d8aac3a274f23
dianatalpos/Fundamentals-of-Programming
/test2/ui/Console.py
793
3.546875
4
class Console(object): def __init__(self, service_ski): self.__service_ski = service_ski def menu(self): print("1. Best 3 jumpers") print("2. Jumps in file") def ui_best(self): list = self.__service_ski.best_jumpers() for elem in li...
7dab387fe264c6e929011a6f65c55692d1562822
dianatalpos/Fundamentals-of-Programming
/written exam/ex1.py
697
3.5
4
''''a = 1 b = [str(a), 1] c = {a : a, str(b[1]) : b} print(c) print(type(a) == type(c[1])) a = ['1'] print(type(a) == type(c[1])) print(type(b[0]) == type(a)) print(str(a) in c) print(str(a)) print('\n') print(str(a) ''' a = {} a[rows] = [1] a[columns] = [2] a[values] = [5] for i in range(0,3...
c30483830dd99323af06b57c829786bb48ae9e10
dianatalpos/Fundamentals-of-Programming
/hangman/ui/Console.py
2,301
3.609375
4
from errors.Errors import ValidError, RepoError class Console(object): def __init__(self, serv): self.__serv = serv def menu(self): print("The commands are:") print("\tAdd a new sentence (add)") print("\tPlay hangman (play)") print("\...
4122e8be0e12806772c70f0775d1f63c57a9f248
dianatalpos/Fundamentals-of-Programming
/written exam/sdsc.py
196
3.515625
4
''' Created on Feb 4, 2019 @author: Andrea ''' a = lambda x: [x+1] b = a(1) c = lambda x: x + b d = c([1]) a = 1 b = 3 print (a, b, c(4), d[1]) print(6/3) print(7/3) print(7//3)
06cf647a4c5500f346844d4d0d47bbce8287b08e
dianatalpos/Fundamentals-of-Programming
/written exam/mergesort.py
327
3.890625
4
''' Created on Feb 13, 2019 @author: Andrea ''' def qsort(l): if l == []: return [] else: pivot = l[0] lesser = qsort([x for x in l[1:] if x<pivot]) greater = qsort([x for x in l[1:] if x>=pivot]) return lesser +[pivot]+greater l=[7,0,17,5,9,24] print(qs...
cf2d979490385c2b7d9ad432e3186f819d197578
xixixixixiC/LeetCode_explore
/math/7_reverse_integer.py
442
3.75
4
class Solution: def reverse(self,x: int) -> int: num=0 sign=1 if x < 0: sign=-1 x=abs(x) while x>0: gw=x%10 x=x//10 num=num*10+gw if num > (2**31-1): return print(0) else: return print...
d2b2ec1de67b97d7e90eac13b125015463d45dca
kkuuba/PwJS_exercises
/ex_1/script_2.py
280
3.890625
4
#!/usr/bin/python print("Enter name:") name = str(input()) print("Enter surname:") surname = str(input()) print("Enter year of birth:") year_of_birth = str(input()) print("\nProvided data:\nName: {}\nSurname: {}\nYear of birth: {}".format(name, surname, year_of_birth))
0b0f7511bc92933b8a7f595d6fcdbe4dace75fab
paulodamaso/aibolit
/aibolit/patterns/bidirect_index/bidirect_index.py
809
3.921875
4
class BidirectIndex: def __init__(self): pass def value(self, filename: str): """ Finds if a variable is being incremented and decremented within the same method :param filename: filename to be analyzed :return: list of LineNumber with the variable declaration lines ...
771d9a4773ba6aaf968437f45676bc46989f0ee0
aCodingTurtle/MiniKings
/MiniKings.py
2,045
3.515625
4
# # MINIKINGS # import random import tkinter as tk class titleScreen(): def __init__(self, window): self.window = window window.title("MiniKings - Title Screen") self.TitleLabel = tk.Label(window, text='miniKings') self.TitleLabel.pack() self.NewButton = tk.Button(window, text='New...
d9d53b682922490d9ec13ca6a1fd67cc89f7e6f2
jessejinnaruiz/training
/udemy_complete_py/Section4/4-65_objectOrientedProgramming.py
1,137
4
4
# the property decorator # at property decorator turns a method into a property class Student: #create a class def __init__(self, name, school) -> None: self.name = name self.school = school self.marks = [] def average(self): return sum(self.marks) / len(self.marks) class ...
234d30449ae13b514f56204fd9f7a1a25c9d4594
Snowmqn/Python-datetime
/meeting/meeting.py
3,180
3.71875
4
""" condense_meeting_times [(20, 22), (21, 22), (25, 30)] => [[(20,22), (25,30)]] 1472782903 """ #contains parse function which is used to parse ISO-8601 strings into datetime from dateutil.parser import * #Assigned function #Determines the format of input, calling the appropriate function. #Returns what the called...
4327f65151e2054c6ece88b694faa02ec3449d09
Shaaban5/Hard-way-exercises-
/py files/ex9+10.py
897
4.15625
4
days = "Mon Tue Wed Thu Fri Sat Sun" months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\tso on" # \n print in new line & \t print tap print "Here are the days: ", days print "Here are the months: ", months print """ There's something going on here. With the three double- quotes. We'll be able to type as...
44f95e83ddebe7cf08f73ca9c9e66e4307b1ae58
Shaaban5/Hard-way-exercises-
/py files/ex27+28.py
1,613
4.1875
4
print True and True # T print False and True # F print 1 == 1 and 2 == 1 # F print "test" == "test" # T print '\n' print 1 == 1 or 2 != 1 # T print True and 1 == 1 # T print False and 0 != 0 # F print True or 1 == 1 # T print '\n' print "test" == "testing" # F print 1 != 0 and 2 == 1 # F print "test" != "te...
0201024e54631ca0304f2ee1cc2244df46dfd9b5
Shaaban5/Hard-way-exercises-
/py files/ex37+38+39.py
943
3.921875
4
region = { # elements here called key 'Riyadh' : 'RYD' , 'Makkah' : 'MK' , 'Madina' : 'MD' , 'Estren' : 'EST' , 'Tabuk' : 'TB' } cities = { 'MK' : 'jeddah' , 'MD' : 'yanbu' , 'EST' : 'damam' } cities['RYD'] = 'in ry' cities['TB'] = 'in tb' print 'citi in Makkah is:', cities['MK'] print 'another way:' , c...
611cb04abd9d7f376c18c51039082360611127af
dllm-pk/ETI_Team02_assignment1
/code/combat.py
923
3.703125
4
import random from class1 import * """ Combat functionalities (Faris) """ def attack(char, enemy): """ Player Attack Function, returns hp lost """ lose_hp = random.randint(char.minDamage,char.maxDamage) - enemy.defence if lose_hp <0: lose_hp = 0 return lose_hp def ratkingattack(char,enem...
e79623316475eaa8f291cd5be1452874c0189918
msabramo/py-dronestore
/dronestore/datastore/basic.py
6,459
3.8125
4
class Datastore(object): '''A Datastore represents storage for serialized dronestore versions. Datastores are general enough to be backed by all kinds of different storage: in-memory caches, databases, a remote cache, flat files on disk, etc. The general idea is to wrap a more complicated storage facility ...
09cd83f1cb463b15df4ae26e93418b1843d5d463
Alimou205/python-formation
/formation python/boucle.py
225
3.78125
4
print("veuillez svp saisir un entier") x=int(input()) a=0 while(a<=20): resultat=a*x if(resultat %3 ==0): print(resultat,"*",end="") else: print(resultat,end="") a +=1
d9045bb4a3445ebae41849f319498206639fdc30
MorKalo/L8_Homework13-10-21
/P35 EX1.py
268
4
4
num=int(input('plz insert a num')) i=0 for i in range(1, 100, 1): num2= int(input('Plz insert a number')) if num>num2: print('the numbers are NOT SORTED') break num=num2 i+=1 if i==100: print('the number are SORTED')
507b36c522d5234c52c976c41f8e420250d5d18b
joseteodoro/experiments
/Python3Tutorial/scope.test.py
1,230
3.859375
4
def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam = "global spam" spam = "test spam" do_local() print("After local assignment:", spam) do_nonlocal() ...
410601a2a9f82a3c2276eabf138525332a4d99a4
Zachary-Westmaas/LabAssignment5
/CardGenerator.py
5,879
3.78125
4
import random class CardGenerator(): def __init__(self): self.__listOne = None self.__listTwo = None self.__dispNumOne = None self.__dispNumTwo = None def generateCards(self,n): cardsOne = [] cardsTwo = [] while n > 26 or n <= 0: n = int(input(...
71c5c232ba5ae5e3b0083015983c10683862076c
FloraChang/Codility
/Triangle.py
1,767
3.578125
4
''' Task description A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and: A[P] + A[Q] > A[R], A[Q] + A[R] > A[P], A[R] + A[P] > A[Q]. For example, consider array A such that: A[0] = 10 A[1] = 2 A[2] = 5 A[3] = 1 A[4] = 8 A[5] = 20 Tripl...
9886dac5ea6d48587e975d64cfb4a23388143911
anepaul/ChallegeQuestions
/StockPrices/StockPrice.py
943
4
4
# source https://www.interviewcake.com/question/python/stock-price def get_max_profit(stock_prices): # Parameter validation if len(stock_prices) < 2: raise IndexError("Input paramter list does not contain atleast 2 values") # Buy values constraint buy_val = stock_prices[0] # Maximizing Pro...
f008285915ed7f12ae4981c2ece7cf9bbdc4632b
cofitiggs/myPracticeProblems
/LeetCode/decompress.py
502
3.53125
4
# https://leetcode.com/problems/decompress-run-length-encoded-list/ def decompress_rle_list(nums: list[int]) -> list[int]: quantity_and_number = {} for i in range(0, len(nums)): if i%2 == 1: quantity_and_number[nums[i-1]] = nums[i] solution = [] for key, value in quantity_and_n...
afd0f1c043c426ab33a81874a972191cddfd1163
skdmajee/interview
/pycode/tree.py
5,442
3.84375
4
#!/usr/bin/python import sys import collections from collections import deque from collections import namedtuple from collections import Counter # # Some basic pycode classes # ## ##### STACK ## class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items =...
b1667f032143857f21f6ff2c4c999c99b0b17912
skdmajee/interview
/pycode/coin.py
1,112
3.75
4
import sys def change(amount, coins): ''' tbl = [0] * (amount+1) ''' tbl = [[0 for j in range(amount+1)] for i in range(len(coins)+1)] tbl[1][0] = 1 for c in coins: for val in range(1, amount+1): if c <= val: ''' Subtract the coin and use the residulal value to see if there is ...
93e53bc561f934dbad087288c18aee359e38bceb
12345929/HelloWorld
/HelloWorld.py
78
3.5
4
for i in range(10): print("Hello World!!!.."+str(i)) print("Hello ycm")
9b78e17fab9b4e8c0a71bf89bacb5a2a4caa7b74
Ruizdev7/pyEjercicios
/listas.py
1,989
4.375
4
miLista=["elem1", 5, 78.35, "elem4"] #estructura de una lista print(miLista[0]) print(miLista[1]) print(miLista[2]) print(miLista[3]) print(miLista[-1]) print(miLista[-2]) print(miLista[-3]) #Accediendo a porciones de listas print(miLista[0:3]) print(miLista[:3]) print(miLista[1:2]) print(miLista[2:]) #Funcion a...
66460488a962a91e153d6c04f0a033e8d67fcf90
IxLabs/vlab
/vlab/node.py
3,859
3.515625
4
""" Node objects for vLab A Node can be seen as an abstraction for a node in a network topology. It can be a Host, a Switch or something. """ from util import run from vmhandler import VmHandler class Node(object): """A virtual network node is the abstraction of a network node.""" def __init__(self): ...
9f43811d8f6477977d1c07c871c5d2ad9965d109
anagouveia1/Python
/helloFunc2.py
531
3.515625
4
#helloFunctionArguments: def Name_Fun(parm_one'default'): class MyClass(..) def Name_Fun(self, param_one=self.one_of_the_vars): Name(0) == 'Alice' print("Last Login: " + Name0) print('Lets try to do something fun, tell me your name:') def Hello(name): input(name) p...
d1c68ca86ea5911fca5e0bcb4b031bf245c90779
FS-TimothyMcCoy/DPW
/PycharmProjects/day6/main.py
1,124
3.90625
4
class Person(object): def __init__(self): print "Person Created" self.name = "TJ" self.age = 21 self.__ssn = 2429843315 def breathe(self): print "I'm Breathing" def sleep(self): return "I'm snoring" + self.name def get_ssn(self): if self.age > 1...
3ddde76776cd09260d4ae59571bfb5274e787237
lynchlcl71/python_exercises
/guessnum5.py
370
4.09375
4
print "I am thinking of a number between 1 and 10." num = int(raw_input("What's the number? ")) myNum = 5 while True: if num == myNum: print "Yes! You win!" break if num > myNum: print str(num) + " is too high." num = int(raw_input("What's the number? ")) else: print str(num) + " is too low." ...
eff3ec4b96db36dbbedae057bb6c0c7549609ecd
lynchlcl71/python_exercises
/triangleNumbers.py
301
3.640625
4
# def all_triangle_numbers(n): # n = 100 # for i in range(1, n + 1): # print("n = {0}, triangle = {1}".format(i, (i ** 2 + i)//2)) # all_triangle_numbers(10) def triangleNumbers() n = 100 for i in range(1, n + 1): print("n = {0}, triangle = {1}".format(i, (i ** 2 + i)//2)) triangleNumbers()
8cc8fbb98ae888f4d1ed330493b399c4739d2962
qiphon/frontend-learn
/python/demo/basic.py
1,116
4
4
# 我是单行注释 ''' 我是多行注释 ''' # print('hello world'); # 打印关键字 # import keyword; # print(keyword.kwlist) # 定义变量名的方式 # 变量名 = 变量值 # name = "qiphon" # height= 175.00 # weight= 75 # # # 打印信息 # # print('我是', name,"体重:", weight) # # 打印数据类型 # print('height:', type(height), 'weight:', type(weight)) # # height: <class 'float'> ...
9fd35de9093f9f05025455b55fb72eb32d2f698d
AsmitaKhaitan/Coding_Challenge_2048
/2048_game.py
1,920
4.40625
4
#importing the Algorithm.py file where all the fuctions for the operatins are written import Algorithm import numpy as np #Driver code if __name__=='__main__': #calling start() function to initialize the board board= Algorithm.start() while(True): t = input("Enter the number (move) of your cho...
be79fc85f023f6aaea2a418621c0949715b60840
eryueniaobp/leetcode
/revised/compare strings.py
601
3.765625
4
class Solution: """ @param A : A string includes Upper Case letters @param B : A string includes Upper Case letters @return : if string A contains all of the characters in B return True else return False """ def compareStrings(self, A, B): # write your code here a = [ 0 ] * 26 ...
0bfd4b27a00eba35d48b50b5858c2f2112dcd865
salgado/python_stuffs
/insort.py
223
3.640625
4
# insertion sort lista=[2, 89, 4, 100, 1] print lista #insertion for i in range(1,len(lista)): temp = lista[i] j=i-1 while(temp<lista[j] and j>=0): lista[j+1] = lista[j] j=j-1 lista[j+1] = temp print lista
0e7080b213b0dce491bf1da1f67506a418a01209
jeanbenoitdaille/Deletedublelist
/main.py
244
3.640625
4
nombres = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7, 8, 9, 10] nombres_sans_duplicats = [] for i in nombres: if i not in nombres_sans_duplicats: nombres_sans_duplicats.append(i) print(nombres_sans_duplicats)
bbab08378125425090805932e229d260c12158d0
iez1784/learn
/Python/PythonLearnRocket/python_rocket/python_5.py
1,094
4.1875
4
# -*- coding: UTF-8 -*- __author__ = 'zhangedison' """ 请写出下面代三运后后的结果,并解释原因 """ def makeActions(N): acts = [] for i in range(N): acts.append(lambda x: i ** x) return acts acts = makeActions(5) print("===makeAction===") for act in acts: print(act(2)) print() """ 第一题当中: 得到结果是: 16,16,16,16,16 ma...
6241894eb14993448a9e9c42a1f092b90a983ac4
BrettMcGregor/udemy-colt-steele
/re_profantiy_filter_challenge.py
299
3.59375
4
import re def censor(string): re_profanity = re.compile(r"[F|f]rack[a-z]*\b") # match = re_profanity.findall(string) return re_profanity.sub("CENSORED", string) # return match print(censor("Frack you")) print(censor("I hope you fracking die")) print(censor("you fracking Frack"))
f012b393d222d9dece907085fb316cc7ef6c7f6e
BrettMcGregor/udemy-colt-steele
/sum_up_diagonals.py
807
3.9375
4
''' EXAMPLES: list1 = [ [ 1, 2 ], [ 3, 4 ] ]; sum_up_diagonals(list1); # 10 list2 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; sum_up_diagonals(list2); # 30 list3 = [ [ 4, 1, 0 ], [ -1, -1, 0], [ 0, 0, 9] ]; sum_up_diagonals(list3); # 11 list4 = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 1...
42eb12c7bf4582183a7eb9597339854765ad0983
BrettMcGregor/udemy-colt-steele
/make_song.py
982
4.09375
4
''' kombucha_song = make_song(5, "kombucha") next(kombucha_song) # '5 bottles of kombucha on the wall.' next(kombucha_song) # '4 bottles of kombucha on the wall.' next(kombucha_song) # '3 bottles of kombucha on the wall.' next(kombucha_song) # '2 bottles of kombucha on the wall.' next(kombucha_song) # 'Only 1 bottle of...
4d6bdacc72de5c883b6b3070888096e8ada2f4c6
zhouweixin/text-process
/sentiment_analysis_20190220/test/xlsx_test.py
431
3.625
4
import pandas as pd import os datas = pd.DataFrame(data={'a':[1, 2, 3], 'b':[4, 5, 6]}) print(datas) datas = pd.DataFrame(data=[{'a': 1, 'b': 4}, {'a': 2, 'b': 5}, {'a': 3, 'b': 6}]) print(datas) results = [] for i, col2value in datas.to_dict(orient='index').items(): print(col2value) if col2value['a'] == 1...
305c649a6481a6027627921c5bbe0d8e7d396e1f
PowerfulCheese/COMP9021_19T1
/quiz_6.py
3,489
3.828125
4
# Randomly generates a grid with 0s and 1s, whose dimension is controlled by user input, # as well as the density of 1s in the grid, and determines the size of the largest # isosceles triangle, consisting of nothing but 1s and whose base can be either # vertical or horizontal, pointing either left or right or up or dow...
3028a227c697e5791b70cedb990ac2aac2df646a
PowerfulCheese/COMP9021_19T1
/quiz_6_test/DocTest_10.py
4,350
4.09375
4
""" >>> print(os.popen('echo 0 0| python3 quiz_6.py').read(), end='') Enter two integers: Here is the grid that has been generated: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
e1c92976ffbe6f0050f003f28739b0e6e14b7b77
Chovhan/Delphi
/Day_1/Task_2.py
1,098
3.828125
4
import numpy as np import random as rnd def create_random_array(): array = np.zeros((2, 10), dtype=int) for i in range(len(array)): for j in range(len(array[i])): array[i][j] = rnd.randint(0, 10) return array def reshape_array(array): one_dimensional_array = [] for i in range...
0a64bb40ca04dd77abbe1431358af969ceca4bb1
thomaslanglois/data-fellowship-code
/modules/01_foundation/01_introduction_to_python/challenges/challenge4.py
1,089
3.953125
4
from datetime import datetime if __name__ == "__main__": questions = ['What is your name?', 'How old are you?', 'What is your favourite colour'] for i, q in enumerate(questions): extra = None answer = input('{} '.format(q)) if i == 0: if len(answer) < 5: co...
062d7e0fefd2e7ea92e7ff5f7b4d086dcb92b368
Kaberungula/test123
/metod-format.py
181
3.8125
4
age = 24 name = 'Vlad' print('Почему этот {1} в свое {0:-^11} года курит кальян?'.format(age, name)) age2 = 34 print(str(age2) + '{0:.3}'.format(1/3))
53690ef1c8dcc0e90d1bca71fd6a1fd389aae0c2
Lucs1590/Algum_Ritmo
/Algoritmo de Kruskal/buscas.py
4,115
3.5625
4
# -*- encoding: utf-8 -*- def geraLista(): n = input('Quantidade de Vertices: ') lista = [] for i in range(int(n)): lista.append([i]) imprimeLista(lista) return lista def imprimeLista(lis): for m in lis: print (m) def insereAresta(lis): x, y = input('I...
3ad8d6c1650d035af063cde545c36a6f0e9375ca
OliverRichter/Coding_Challenge
/coding_challenge/coding_challenge/battleship/battleship.py
5,847
4.21875
4
import gym from gym import spaces import numpy as np """ Battleship Environment. This environment implements a simple one player version of the Battleship game where the player has to sink all a-priori invisible ships as fast as possible by dropping bombs onto the playing field. At the beginning of each episode 10 shi...
b9aacfee3f00b1fc6eb37a1ec05f8c50b23ffa0e
LoupeG94/Coffee_machine
/coffee_machine.py
3,609
4.25
4
def buy(choice): global water global milk global coffee_beans global cups global money if is_enough(choice): print("I have enough resources, making you a coffee!") if choice == "1": water = water - 250 coffee_beans -= 16 cups -= 1 m...
088e7bc3df69150453e7c2754f0e5e5ac67d1f45
KattaVishnuTeja-01/longest-word-coderbyte
/code.py
504
3.859375
4
def LongestWord(sen): # code goes here sen = sen.split() max = 0 for i in sen: punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' l = 1 for j in punctuations: if j in i: l = 0 continue if l == 0: ...
1f81b89b51e46b4fc517ff43d5cccc183e2a6a45
brandonhudavid/blackjack
/Player.py
1,281
3.59375
4
from Person import Person class Player(Person): def __init__(self): super().__init__() self.money = 500.0 self.bet = 0 def placeBet(self): try: bet = float(input()) while bet > self.money or bet <= 0: if bet <= 0: ...
881cb5569e7e124c4e831f2e4f8fc75334a2e9a1
yuminc03/1320_python_AfterSchool
/10_21_03.py
315
3.78125
4
#절대 위치 배치 관리자 from tkinter import * window=Tk() w=Label(window, text="박스 #1", bg="red", fg="white") w.place(x=0, y=0) w=Label(window, text="박스 #2", bg="green", fg="black") w.place(x=20, y=20) w=Label(window, text="박스 #3", bg="blue", fg="white") w.place(x=40, y=40) window.mainloop()
1399bfc32700a0338ea57b80616829090b790182
yuminc03/1320_python_AfterSchool
/09_09_02.py
486
4.0625
4
#자료형 확인하기 print(type(52)) print(type(3.14)) print(type("thanks")) print("#제곱연산자") print("2**2 = ", 2**2) print("안녕" + ("하세요." *3)) #변수 pi = 3.14 print(pi) #복합 대입 연산자 number = 100 number += 10 print("number : ", number) string = "안녕" string += "!" string += "!" print("string : ",string) print() print() #입력 num =...
15cadeb354d10e2dd25ddd56ac546172396cc560
ccaoseeyoutomorrow/myGAN
/src/数据融合.py
1,799
3.625
4
import tensorflow as tf import matplotlib.pyplot as plt from tensorflow import keras from tensorflow.keras import layers, Input, Model from tensorflow.keras.layers import Dense, concatenate from tensorflow.python.keras.utils import np_utils from src.手写CNN import loadmnist x_train, y_train, x_test, y_test = loadmnist()...
37898ea6cda8819dcf96d9d674f7da6c31f6cfde
hangcheers/data_structure
/heap.py
2,992
3.625
4
# -*- coding:utf-8 -*- # 左边是最大堆,右边是最小堆。 # 保障数据的平均分配,左右两边的数据相差1 # 数据的总数目是偶数时,新加入的数据先插入最大堆,经过筛选后,将选出的最大堆的最大元素插入小根堆。 # 数据的总数目是奇数时,新加入的数据先插入最小堆,经过筛选后,将选出的最小堆的最小元素插入大根堆。 # 保证最大堆的最大的数小于最小堆的最小元素 # 如果当前数目是偶数,取最小堆和最大堆根结点的平均值,如果当前数目是奇数,取最小堆的根结点 # 这个方法利用的是priority queue,当插入元素或者删除元素的时候,队列会自动进行调整,保证队首元素 #一定是优先权最大/最小的。 from heapq im...
ebd098d69ce19128812fa257e4e0827b79146b8b
hangcheers/data_structure
/tree_PATH.py
1,617
3.609375
4
class Tree(): def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def binaryTreePathSUm(self, root): res = [] def dfs(root, path): if root: path += str(root.val) if root.left == None and roo...
81d33027f86889d732188edcd5aa184332ddd366
Prathap16/Jenkins_build
/workout/count_dict.py
276
3.609375
4
char_dic={} string1="raman" for ch in string1: if ch not in char_dic: char_dic[ch]=0 char_dic[ch]+=1 print(char_dic) char_dic=dict(sorted(char_dic.items(), key=lambda item: item[1], reverse=True)) for key,value in char_dic.items(): print(key,"-----",value)
ab7a66757a5c3badbc44c51b5b80d0b9e4050684
Prathap16/Jenkins_build
/dictnary/student_details.py
961
4
4
details_dict={} num_std=int(input("Enter number of students:")) for sno in range(1,num_std+1): print(sno,"students details:-") name=str(input("\tEnter Student Name:")).lower() marks=int(input("\tEnter student marks:")) details_dict[name]=marks while True: st_d=input("Enter student name to get detail...
690ed843bc90572627b3ece856f3c28924d87d29
Prathap16/Jenkins_build
/workout/counting_string_letters.py
292
3.921875
4
string=input("enter string to count letters:") length=len(string) s={""} for ch in string: time=0 for ind in range(0,length): if ch==string[ind]: time=time+1 char_times=ch+" "+ "is present "+str(time) s.add(char_times) print(s) #for i in s: # print(i)
4d2b43195e6a005328ab4a3c7314d86fcc79a927
Prathap16/Jenkins_build
/workout/emp_details.py
433
3.625
4
EID=input("Enter Employee No:") ENAME=input("Enter Employee Name:") Age=input("Enter Age of Employee:") ESALORY=input("Enter Employee Salory:") EMS=input("Employee marriage status:") employee_list=[] employee_list.append(EID) employee_list.append(ENAME) employee_list.append(ESALORY) employee_list.append(EMS) employee_l...
0bb712ba383b23b8c8ec53af0fa6f930d94bd254
muazfahim1999/codeforces
/59A.py
219
3.734375
4
a = input() b = list(a) c = [] d = [] for i in range(len(b)): if b[i].isupper(): c.append(b[i]) else: d.append(b[i]) if len(c) > len (d): res = a.upper() else: res = a.lower() print(res)
d210917d538f6076df7bd03b7fd2451510eb9f8c
YimingChen-max/Python_BasicKnowledge
/tenth_chapters.py
14,978
3.5625
4
# 文件和异常;chenyiming-2017-11-9 # 读取整个文件; # (1)数据文件存储在程序文件所在的目录 import json with open('pi_digits.txt') as file_object: contents = file_object.read() print(contents.rstrip()) # 文件路径;Chenyiming-2017-11-10 # (2)相对文件路径:数据文件存储在程序文件所在目录下的一个文件夹中 斜杠(/)和win系统中使用反斜杠(\) with open('text_files/pi_digits.txt') as file_object...
1978e3ac3665e1c5b096ee01da1da17a967873cd
ckitay/practice
/MissingNumber.py
998
4.3125
4
# All numbers from 1 to n are present except one number x. Find x # https://www.educative.io/blog/crack-amazon-coding-interview-questions # n = expected_length # Test Case 1 , Expect = 6 from typing import List from unittest import TestCase class Test(TestCase): def test1(self): self.assertEqual(find_mi...
5907874b0d0bd0c3992cc013e974ee1027fb9ff1
pjalagna/Aryc2019
/ScreenT/listbox2020_02_18.py
1,262
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ file listbox2020_02_18.py pja 02-18-2020 moves selection from list to a label via a button available after exit in StringVar attached to label returns selected and moved value test as import listbox2020_02_18 j = listbox2020_02_18.main() j """ def record_selection():...
75552523afeb3a917eef766f92820a37dd519910
pjalagna/Aryc2019
/Device/EdeviceDev/eDevice/eDeviceDemo/registrationCommon/thread1.py
1,914
3.765625
4
#!/usr/bin/python # main thread process import Queue import threading import time exitFlag = 0 threadList = ["Thread-1", "Thread-2", "Thread-3"] nameList = ["One", "Two", "Three", "Four", "Five"] queueLock = threading.Lock() workQueue = Queue.Queue(10) threads = [] # Create new threads threadID = 1 for tNa...
edd2dc71bd9b0350300291555f64644cd2f20798
szhong16/CMPM-146-P6
/dropout_model.py
1,556
3.5
4
from tensorflow.keras import layers from tensorflow.keras import models from tensorflow.keras import optimizers from tensorflow.keras.layers import Dense, Conv2D, Flatten, MaxPooling2D, Dropout num_classes = 1 # Define a sequential model here model = models.Sequential() # add more layers to the model... # convolution...
cebca247c6a6207ac26386bf414182831b52b562
coogleall/FileUpload
/FileUpload/django/mysite/common/utils/util_date.py
330
3.890625
4
import time # 根据文件上传的时间戳, 格式化为 2020-6-30 12:00:00 def time_stamp_to_date(time_stamp): now = int(round(time_stamp * 1000)) t = time.localtime(now / 1000) return time.strftime('%Y-%m-%d %H:%M:%S', t) if __name__ == '__main__': stamp = time.time() print(time_stamp_to_date(stamp))
a7e4452a638da21b4bbfd25fa6028861b9b0f8f6
Kemenar/Analisis-GR40
/Test.py
2,411
3.65625
4
import time import random ## random.randint(0, 10000) def OdeN (Var): i = 0 Lista = [] while i<Var: Lista = Lista + [i] i = i + 1 print ("#######################################") print ("#Tiempo de ejecucion de forma Acedente#") print ("#######################################"...
828a15347ffae03bad87e51853c2e325867cee78
samodur69/RPS-game-Pycharm-edu
/game.py
2,949
3.875
4
import random as r def process_result(result, string, score): if result == 'win': score += 100 print(f'Well done. The computer chose {string} and failed') elif result == 'lose': print(f'Sorry, but computer chose {string}') else: score += 50 print(f'There is draw ({s...
35ddf0a2f10aada0c476db8680793f0f9193c1e0
Ford-z/Nowcoder
/剑指offer/替换空格.py
545
3.796875
4
#请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 # -*- coding:utf-8 -*- class Solution: # s 源字符串 def replaceSpace(self, s): # write code here a=[] for i in range(len(s)): if(s[i]==" "): a.append("%") a.append("2"...
d6d86af5fb9bdd0e6ed01d5970f30b4ab6dbae0d
Ford-z/Nowcoder
/剑指offer/丑数.py
723
3.828125
4
#把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。 # -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): # write code here if(index==0): return 0 dp=[0]*index dp[0]=1 a=0 b=0 c=0 ...
3908cbb0de5144ec15424c69e60f9f337f8a0ddb
Ford-z/Nowcoder
/排位赛/String II.py
1,143
3.671875
4
#链接:https://ac.nowcoder.com/acm/contest/9715/B 来源:牛客网 给出一个仅包含小写字母的字符串s,你最多可以操作k次,使得任意一个小写字母变为与其相邻的小写字母(ASCII码差值的绝对值为1),请你求出可能的最长相等子序列(即求这个字符串修改至多k次后的的一个最长子序列,且需要保证这个子序列中每个字母相等)。 # # # @param k int整型 表示最多的操作次数 # @param s string字符串 表示一个仅包含小写字母的字符串 # @return int整型 # class Solution: def string2(self , k , s ): ...
1959e616d770fa733d9558c208c01e34204c5544
Ford-z/Nowcoder
/Netease/幸运N串.py
652
3.515625
4
#小A很喜欢字母N,他认为连续的N串是他的幸运串。有一天小A看到了一个全部由大写字母组成的字符串,他被允许改变最多2个大写字母(也允许不改变或者只改变1个大写字母),使得字符串中所包含的最长的连续的N串的长度最长。你能帮助他吗? number = input() for i in range(int(number)): a = input() b=[] if(len(a) - a.count("N") <=2): print(len(a)) else: c = 0 for t in range(len(a)): b.append...
93bdf1771a09371b3d1fa8804c0ed517b2c08e9f
hrhvm/test-unitarios
/OrdenaTresNumeros/main.py
534
3.765625
4
from TresNumeros import TresNumeros from OrdenarTresNumerosIf import OrdenarTresNumeros ### ejemplo usando ordenar 3 numero con while def ordenar_while(): op = TresNumeros() ordenado= op.ordenar(5,4,3) print(ordenado) #### fin ejemplo ordenar 3 numeros con while ### ejemplo usando ordenar 3 numero con...
47bb4ee75b4d630058f73ffc700431e39be53886
TraceOnBrainOff/pp1
/08-DataStructures/zadania/6.py
662
3.65625
4
class matrix(): @staticmethod def create(x,y): w, h = y, x return [[0 for x in range(w)] for y in range(h)] @staticmethod def create_unit(x): #num of rows/columns matrix = [] currIndex = 0 for i in range(x): row = [] for j in range(x): ...
933665f3bd4c542b7242d60b10da2f84fdb75c7a
TraceOnBrainOff/pp1
/03-FileHandling/zadania/18.py
132
3.5
4
file = open('numbers.txt', 'r') lista = [] for line in file: lista.append(int(line)) lista.sort() for i in lista: print(i)
1b3e1b80ee6a4783dafc4d5dba46c4caa3438502
TraceOnBrainOff/pp1
/06-ClassesAndObjects/zadania/9.py
516
3.5625
4
class University(): # konstruktor obiektu (metoda __init__) def __init__(self): # cechy obiektu (pola) self.name = 'UEK' # zachowania obiektu (metody) self.fullname = 'Uniwersytet Ekonomiczny w Krakowie' def print_name(self): print(self.name) def set_name(self, name): sel...
1aa5aa21fddd0b594ac7da328c5b5ab2a2b0387e
TraceOnBrainOff/pp1
/02-ControlStructures/zadania/28.py
323
3.625
4
a = 4 b = 15 for i in range(a): if i==0 or i==a-1: toPrint = "" for j in range(b): toPrint = toPrint + "*" print(toPrint) else: toPrint = "*" for j in range(b-2): toPrint = toPrint + " " toPrint = toPrint + "*" print(toPrint) ...
d0200fd39e17498099542291085936f186d74f34
TraceOnBrainOff/pp1
/02-ControlStructures/zadania/14.py
68
3.65625
4
a = int(input("A: ")) if a=<2: print(10.5) else: print(a*4)
f79dbe81f2b12a62c6c65c8aa4253c4dff012aab
TraceOnBrainOff/pp1
/02-ControlStructures/zadania/25.py
112
3.546875
4
row = 7 column = 3 for i in range(column): a = "" for j in range(row): a = a + "*" print(a)
45cc7892e6b49b4f274516ce5b44189ab92d780e
TraceOnBrainOff/pp1
/05-ModularProgramming/zadania/8.py
342
3.671875
4
import turtle maxSize = 40 pen = turtle.Turtle() def drawSquare(x,y,n): pen.setposition(x,y) pen.pendown() for i in range(4): pen.forward(n) pen.right(90) # Rotate clockwise by 90 degrees pen.penup() for i in range(4): for j in range(4): drawSquare(maxSize*i,maxSize...