blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
75f551f4b1ec7d141953f1b6d91b8c0bcf95e7a7
AnkhMorporkian/lemon-operating-language
/lemon_logger.py
1,093
3.53125
4
"""Defines logging system specifically for lemon.""" __author__ = 'ankhmorporkian' import logging class LemonLogger(): """Logging class for lemon.""" def __init__(self, logger_name='lemon_main'): logging.basicConfig(level=logging.INFO) self.__logger = logging.getLogger(logger_name) def er...
38eaf86b1097aca04a206265ea69ae7eb40acf0d
decryptedlayer/Coursework-4
/ColourImage.py
2,088
3.53125
4
# Matthew Ball MSc Information Technology 04/04/2018 from GUIconnect import GUIconnect from BinaryImage import BinaryImage class ColourImage(GUIconnect): def getThreshold(self, meanIntensity): # Getting intensity value intensity = sum(meanIntensity) // len(meanIntensity) return intensity...
123a4e3a9712fe7f66241f2f8bf86eacca926328
heyu-rise/pytest
/5/5.1.py
1,503
4.125
4
# 列表 列表是动态的,长度大小不固定,可以随意地增加、删减或者改变元素 # num = [1, 4, 3, 3] # append # num.append(10) # print(num) # extend # b = [678, 876, 4] # b.extend(num.__iter__()) # print(b) # index # print(num.index(3, 0, len(num) - 1)) # count # print(num.count(3)) # x = ["aaddddddddddddd", "hghb", "cghghgc", "ddg"] # sort # x.sort(key...
3af51321a5e8cfa7f75ff8898713152e13fb660d
bootphon/word-count-estimator
/wce/word_count_estimation/rttm_processing.py
4,803
3.53125
4
"""Rttm processing Module to extract segments of speech from the original wavs by reading its related .rttm file and gather the results of the WCE on the segments that come from the same audio. The module contains the following functions: * extract_speech - extract speech for one file. * extract_speech_from...
a966bbba1bc54bb9be118512c364b5e754afb282
Mojo2015/PythonFun
/Tkinter/Tkinter1.py
566
3.9375
4
from tkinter import * #Imports all classes, attributes, and methods of tkinter into the current workspace root = Tk()#Creates an instance of the class tkinter.Tk. This creates the root window (the basic blank window) root.mainloop() #executes the event loop method of the root object. This is what keeps the window visib...
5ec4c9588ce58725e782905649a791e48ee041bf
nixawk/hello-python3
/re/re.findall.py
592
4.28125
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ re.findall(pattern, string, flags=0) Return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups;...
726ed792379d83f8695301b587bc560d8df328da
ogiste/ireporter
/app/api/helpers/user_validation.py
8,412
3.609375
4
""" Describes helper functions used in providing validation logic for: user GET methods user PUT method user POST method """ from flask import make_response, jsonify from .errors import get_error, Validation FL_NAME_MAX = 30 # First name, Last name max value FL_NAME_MIN = 2 # First name, Last name min value EMAIL_M...
f73ff103d0caaf6501e2939805e83ad3d36bd27d
moran-ai/shujujiegou
/数据结构(python版)/test 直接插入排序.py
1,524
3.875
4
# coding:gbk # 㷨8-1 ʼ㷽 ####################### class ListItem(object): def __init__(self, key, value): self.key = key self.value = value class SortSequenceList(object): def __init__(self): self.SeqList = [] def CreateSequenceListByInput(self, nElement): self....
223426cd5ad80e24d96c201d32739b732578a7c2
Seungpang/Algorithms
/Python/others/deciphering_code.py
302
3.515625
4
import re def solution(cryptogram): answer = '' temp_cryptogram = '' for i in cryptogram: temp_cryptogram = re.sub(r'([a-z])\1+', r'', cryptogram) for j in temp_cryptogram: answer = temp_cryptogram = re.sub(r'([a-z])\1+', r'', temp_cryptogram) return answer
be66524551d5fd295e9e514b5a98185a2d06ca36
JudgementAngel/Notes
/22_Geekbang_Python3/zodiac.py
1,506
3.53125
4
zodiac_name = (u'摩羯座', u'水瓶座', u'双鱼座', u'白羊座', u'金牛座', u'双子座', u'巨蟹座', u'狮子座', u'处女座', u'天秤座', u'天蝎座', u'射手座') zodiac_days = ((1, 20), (2, 19), (3, 21), (4, 21), (5, 21), (6, 22), (7, 23), (8, 23), (9, 23), (10, 23), (11, 23), (12, 23)) (month, day) = (12, 23) zodiac_day = filter(lambda x:...
cb8ed399fe4f5509e0e33fee9e6886481ae523e8
Silverkinzor/NumberReversal
/NumberReversal.py
916
4.0625
4
print("Number Reversal (not string reversal!)") print("eg. 00034 will be interpreted as 34\n") while True: # input and validation try: number = int(input("Enter a number: ")) if number < 0: print("Positive numbers only!") else: break except ValueError: ...
788c9d7752bf435b6651f6216e0100e68d2652e6
Aasthaengg/IBMdataset
/Python_codes/p03043/s955494866.py
533
3.53125
4
import sys from fractions import Fraction def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N, K = LI() kakuritu = [] for i in range(1,N+1...
b9592da0e6abfa6807310184328b97a584e7f2eb
CDAlecsa/Finite-Difference-Methods---OOP
/VectorClass.py
2,538
3.71875
4
#%%%% ''' A basic vector class ''' class Vector() : def __init__(self,N) : self.VectorLength = N self.rows = [0 for x in range(N)] def __getitem__(self, IndexVector) : return self.rows[IndexVector] ...
cfe03b9f53175e8346eb4f040360be68425b91a4
lkkliukeke/pythondemo1
/teststr.py
4,446
3.765625
4
#公众号字符串练习题 #1.2 判断字符串是否是回文 3223 反过来也是3223 # a = list(input('请输入:')) # if a == a[::-1]: # print(True) # else: # print(False) #1.3 字符串切割 ['hello', 'world', 'yoyo'] s = 'hello_world_yoyo' b = s.split("_") print(b) #1.4 拼接字符串 hello_world_yoyo a = ['hello', 'world', 'yoyo'] print("_".join...
25903a51be227acd303b0ee77162d125af6d3956
algreenbert/46_Exercises
/ex1.py
237
4.09375
4
def max(num_one, num_two): if num_one >= num_two: return num_one elif num_two > num_one: return num_two else: print "What did you do?" return num_one - num_two print max(3, 5) print max(7,7)
8b56941931a2833b2ee718f9ab08ae06f65512b3
rahul-sundaresan/6114-p2
/parse_text_to_graph.py
1,626
3.671875
4
import graph_adjaceny_matrix as graph def read_file(filename): with open(filename, 'r') as graph_file: vertex_list = [] is_directed_graph = False start_vertex = "" # read first line, remove trailing whitespace and split on space graph_details = graph_file.readline().rstrip(...
7e5407f09e081dcf4cc1a252116f749fdde872e0
amritavarshi/guvi
/repeatedletter.py
418
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 6 12:09:46 2019 @author: hp """ ASCII_SIZE = 256 def getMaxOccuringChar(str): count = [0] * ASCII_SIZE max = -1 c = '' for i in str: count[ord(i)]+=1; for i in str: if max < count[ord(i)]: max = co...
e3cb0d418408bf011e016953ef3c5d4e6e0d9e43
DanielFHermanadez/Readme
/Trabajo#1/Python/Trabajo#8.py
268
3.765625
4
n1 = int(input("ingrese el numero 1: ")) n2 = int(input("ingrese el numero 2: ")) n3 = int(input("ingrese el numero 3: ")) n4 = int(input("ingrese el numero 4: ")) n5 = int(input("ingrese el numero 5: ")) print("El resultado promedio es: ",(n1+n2+n3+n4+n5)/5)
def516588f1467f221a042d6b7c8f527dd3c9318
KushagrJ/PY-00
/21/21.py
200
3.640625
4
# -*- coding: utf-8 -*- # Python 3.8.6 inputList = [int(i) for i in input().split()] inputList.sort() if (len(inputList) == 1): print(2*inputList[0]) else: print(inputList[1]+inputList[-2])
e6116a3bc1e0f5e73e3884831d3e965acc3958ca
kbrummert/TeachMePythonLikeIm5
/functions/using-functions.py
1,900
4.71875
5
# ------------------------------------------------------------------------------------ # Tutorial: how to declare and call a function # ------------------------------------------------------------------------------------ # the 'def' keyword is used to declare a function. the structure of a function is: def a_function(...
975416be08dd2295ba4ebe40c027dc992d4cd0dc
jenimech/python-test
/test.py
516
3.828125
4
class Animal: def prueba(): print('heredado') class Person(Animal): city = "Montevideo" def __init__(self, name, lastname): self.__name = name self.__lastname = lastname def __str__(self): return 'Person(' + self.__name + ', ' + self.__lastname + ')' def __repr__(self...
8fe9e36d7ef74fc2e14d9338fe61e9b5a460d65f
philltran/johnwargo-raspberry-pi-relay-timer
/relay.py
1,702
3.921875
4
import gpiozero # used to track the current state of the relay. At the start, the # application turns the relay off then sets this variable's value # the application can then later query this to determine what the # current state is for the relay, in the toggle function for example. _relay_status = False relay = None...
365f8d176b088420a846678c3f3a647b215e4fd7
naphelly24/euler
/p14.py
347
3.53125
4
def sequence(num): chain_num = 1 while num != 1: if(num%2 == 0): num /= 2 else: num = num*3 + 1 chain_num += 1 return chain_num max_chain = [0,0] for i in range(1, 1000000): if sequence(i)>max_chain[1]: max_chain[0] = i max_chain[1] = seque...
ea942843e3116cd0d47607a3b0f5f0411c0bc196
teddygunawan/codility_lessons
/3.TimeComplexity - TapeEquilibrium/answer.py
997
3.796875
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): # write your code in Python 3.6 # For Left Side Minus Right Side leftSide = A[0] rightSide = sum(A[1:]) # For Right Side Minus Left Side reverseLeftSide = sum(A[:-1]) reverse...
9f09f77ea0f64c5821234e463dba5e35660a2b14
dhruvmalik95/coordinator-pomcp-correct
/root.py
1,852
3.703125
4
import numpy as np import math class Root: def __init__(self, game, belief, visited): """ Initializes the root of the search tree. :param game: the game object that needs to be solved. :param belief: the initial belief of the coordinator. :param visited: the number of times the root has been visited """ ...
644f797d86062c6395463f84dda15f9ae8f954c4
jeffersonamoriim/python-algorithms
/sort/quick_sort.py
647
3.78125
4
import numpy as np def partition(array, start, end): pivot = array[end] i = start - 1 for j in range(start, end): if array[j] <= pivot: i += 1 array[i], array[j] = array[j], array[i] array[i + 1], array[end] = array[end], array[i + 1] return i + 1 def quick_sort(...
34b133afcf53fcae37b382f82ef17950fcd4828a
ClarkeJ2000/CA268-Programming-3
/week-05/make_list.py
273
3.78125
4
# # Arrange a list so that when added to a tree will cause the tree to be completely balanced # def make_list(lst): if lst == []: return [] lst = sorted(lst) mid = len(lst) / 2 return [lst[mid]] + make_list(lst[:mid]) + make_list(lst[mid + 1:])
16dac85976816db4ee63abb6089fa4eec6ca3ab2
PrajaktaTakate/Hackerrank-python-solutions
/Hackerrank/2_Strings/string_validator.py
693
3.71875
4
if __name__ == '__main__': s="uihu8" cnt_alphanum=0 cnt_digit=0 cnt_alpha=0 cnt_low=0 cnt_up=0 for i in range(len(s)): if s[i].isalpha(): cnt_alpha=cnt_alpha+1 if s[i].isdigit(): cnt_digit=cnt_digit+1 if s[i].islower(): cnt_low=cnt_...
de95a69c30b511362450acd3ea5b1f77b976f261
zizu1985/100daysOfDataScience
/day7/python_scratch_course.py
4,012
3.578125
4
from collections import defaultdict, Counter # Line indentation for i in [1, 2, 3, 4, 5]: print(i) for j in [1, 2, 3, 4, 5]: print(j) print(i + j) print(i) print("done logging") # Long identifier across several lines long_winded_computation = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + ...
acc33e0296b126a21f21dd54710f515487397aec
ww1026753951/pytest
/mnist2.py
2,150
3.59375
4
import tensorflow as tf # 下载或者加载 加载数据集合 start from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # 下载或者加载 加载数据集合 end # 建立占位符,用于存储每个图片的 向量值 ,图片宽高为 所以图片 共有 28*28 =784 个像素点 x = tf.placeholder(tf.float32, [None, 784]) # 创建 784 *10 的权重 矩阵, 因为是 分类 1...
763f4b7427c4820fed7e4ffab689ab3adb2ae42b
tdominic1186/Python_Crash_Course
/ch_4_Working_with_Lists/cube_comprehension_4-9.py
227
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 11 18:14:35 2018 make a list of the first 10 cubes using list comprehension @author: Tony_MBP """ cubes = [value**3 for value in range(1,11)] print(cubes)
a8fa60cbcc08a299cbd00852f1cb98c1d7436092
ryu-0406/study-python
/basic/pythonweb/string/Pythonweb01-01-08.py
211
3.84375
4
# coding:utf-8 str1 = "Hello" print(str1[0]) print(str1[1]) print(str1[2]) print(str1[3]) print(str1[4]) str2 = "こんにちは" print(str2[-5]) print(str2[-4]) print(str2[-3]) print(str2[-2]) print(str2[-1])
c55fbb280e8985140cecddd51be017f143e86945
tarunvelagala/tact-datascience-intern-assignment
/Numpy-Assignment/np_common.py
265
3.703125
4
import numpy as np a = np.array([1, 2, 3, 4, 5]) b = np.array([5, 6, 7, 8, 9]) # common items in the arrays print(np.intersect1d(a, b)) # uncommon items in the arrays print(np.setdiff1d(a, b)) # print index of matched items print(np.where(a == b))
ac5de93d520c37fe2d2e964f48b290593c41a024
amelia678/python107
/phonebook_dict.py
390
3.65625
4
phonebook_dict = { 'Alice': '703-493-1834', 'Bob' : '857-384-1234', 'Elizabeth' : '484-584-2923' } #print Elizabeth's phone number print(phonebook_dict['Elizabeth']) #add entry to directory phonebook_dict['Kareem'] = '938-489-1234' #delete Alice's phone entry del phonebook_dict['Alice'] #change bob's ph...
b21e82b72f12d3b3d1da76ed3843784efee3fa85
szzheng/CSE150
/Assignment 3/solutions/p1_is_complete.py
954
4
4
# -*- coding: utf-8 -*- from assignment3 import Variable, Variables, Constraint, Constraints, BinaryCSP def is_complete(csp): """Returns True when the CSP assignment is complete, i.e. all of the variables in the CSP have values assigned.""" # Hint: The list of all variables for the CSP can be obtained by csp.vari...
84a374d2e0e53a25779bf5eba65e60c6a199d5fb
nikhil-pitta/Machine-Learning-Triage-Prediction
/Synopsys Project/GUI.py
3,717
3.703125
4
import tkinter as tk from Algorithm import predict # storage for people triage = [[] for x in range(5)] rowLevelLabel = 0 rowLevelEntry = 0 root = tk.Tk() # Things to make GUI for Triage triageLabel = tk.Label(root, text="Current Triage") triageLabel.grid(row=rowLevelLabel, column=10) level1 = tk.Label(root, text=...
44827ea671be6bfebe6ed823a53fe8a4264b20f2
jedoyt/my-datacamp-notes
/Python_Data_Science_Toolbox-pt2/exercise6.py
1,412
3.546875
4
import pandas as pd import matplotlib.pyplot as plt # Writing an iterator to load data in chunks (1) print('Writing an iterator to load data in chunks (1)') # Initialize reader object: df_reader df_reader = pd.read_csv('world_ind_pop_data.csv', chunksize=10) print('\nFIRST CHUNK:') print(next(df_reader)) print('\nSEC...
6db3505b4a55ba3230d51487ab42e242ab1545b1
ujicaesar95/ujian
/PR6.py
1,060
3.875
4
# listData = ["Merdeka", "Hello", "Hellos", "Sohib", "Kari ayam"] # print(listData) # inputUser = input("Search : ") # def searchList(keyWord, theList) : # newList = list(filter(lambda item: keyWord.lower() in item.lower(), theList)) # return newList # searchedList = searchList(inputUser, listData) # print(se...
9fa1efb5afaff35de6deb9a1ae9425a63018ff1c
mahesh671/Letsupgrade
/YOUTUBE DOWLOADER.py
583
3.546875
4
!pip install pytube from pytube import YouTube url =input("Enter url of the youtube video") myvid=YouTube(url) print("Details of the video as follows") print("Title: ",myvid.title) print("Thumbnail url:",myvid.thumbnail_url) print("If you wanna download enter the following numbers:\n1.Highest resolution\n2.lowest resol...
b77d189941967430fa852ce4e4143240222b613e
alexander89116/python_workshop
/contest4/A.py
286
3.625
4
def pascal_triangle(): a = [1] while 1 == 1: i = 0 while i < len(a): yield a[i] i += 1 b = list() b.append(1) for j in range(len(a) - 1): b.append(a[j] + a[j + 1]); b.append(1) a = b[:]
b0aff178194b7d134d03a8e2e10ef3167492b546
xiadx/InterviewAlgorithm
/offer/47_LastRemaining.py
646
3.578125
4
# -*- coding:utf-8 -*- class ListNode: def __init__(self, val): self.val = val self.next = None class Solution: def LastRemaining_Solution(self, n, m): # write code here if n == 0: return -1 h = ListNode(0) p = h for i in range(1, n): ...
c842b9d5b5342e91b9e84dbeecf698e1a8ce8570
wulinlw/leetcode_cn
/初级算法/mathematics_2.py
1,763
3.984375
4
#!/usr/bin/python #coding:utf-8 # https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/25/math/61/ # 计数质数 # 统计所有小于非负整数 n 的质数的数量。 # 示例: # 输入: 10 # 输出: 4 # 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。 # 厄拉多塞筛法 # 西元前250年,希腊数学家厄拉多塞(Eeatosthese)想到了一个非常美妙的质数筛法, # 减少了逐一检查每个数的的步骤,可以比较简单的从一大堆数字之中,筛选出质数来,这方法...
26b673be35773125d61265d9060483bebbd0dc18
pururaj1908/leetcode
/ConstructBinaryTree.py
703
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 12 21:57:18 2019 @author: Puru """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def buildTree(self,inorder,postorder): flag = 0 root = TreeNode(postorder[...
510136cd823d890df764551f5675e15ea3af02fd
ymccarter/flashcard_project
/Test_class/Renshu_folder/automationPython/lesson18_datatructure.py
991
3.6875
4
#List and data as dictionary allCats =[] allCats.append({'name':'Zophie','age':7,'color':'gray'}) allCats.append({'name':'Pooka','age':5,'color':'white'}) allCats.append({'name':'Fat-Tail','age':5,'color':'gray'}) print(allCats) # Tic Tac Toe import pprint theBoard={'top-L':' ','top-M':' ','top-R':' ', 'mid-L':' '...
b8f34973d573efeda0ae3c8fccd3f5a9757d1160
sballard222/Python_Tutorials
/pythagorean.py
315
3.96875
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 24 11:38:37 2019 @author: sballard """ import math def pythagorean(a, b): hypotenuse_squared = a**2 + b**2 hypotenuse = math.sqrt(hypotenuse_squared) print("The hypotenuse is: ", hypotenuse) #call function pythagorean(3,4)
1cf95e27a215648c5eafccc3a600c6e775ecc965
kaijuking/pythonlearning
/drawingwithturtle/drawwithturtle.py
982
3.953125
4
import turtle # Instructor's solution (which makes way more sense) def draw_polygon(length, sides): angle = 360 / sides for i in range(sides): turtle.fd(length) turtle.lt(angle) # My original approach def draw_object(): print("test") draw_square(50, 90) draw_triangle(50, 120) ...
15aaf78fc6ca714ddf8217849e1cad31a923610b
jose-brenis-lanegra/Verificadores-en-Python
/FuncionBasica-nro12.py
479
4
4
#input pi=float(input("ingrese el valor de pi:")) radio=float(input("ingrese radio:")) #processing volumen_esfera=(4*pi*(radio**3))/3 #outpout print("###################################") print("#hallar el volumen de una esfera") print("###################################") print("#") print("#########################...
8a52f9b8491777881780893807c403f4f55139d1
HrithikArya/MyInitialProjects
/countDown.py
805
4.1875
4
t = int(input('''It's a short script in which you have to provide a list and a number and this script search through the list if it can find the countDown from the provides number like if you inserted 4 this will search for 4,3,2,1 . Enter testcases: ''')) for i in range(t) : length, num = map(int, input('Enter l...
ec30c0499fb640ef4fb75206c79317a335cb6aa7
serdarkuyuk/LeetCode
/1394-find-lucky-integer-in-an-array.py
203
3.71875
4
arr = [1,2,2,3,3,3] mydict = {} for num in arr: mydict[num] = mydict.get(num, 0) + 1 count = -1 for key, value in mydict.items(): if key == value: count = max(count, key) print(count)
031864f54174dbab4896766bd436d0d265922207
Mabloq/DataStructuresCourse
/BinaryTrees/tree_orders.py
3,849
3.671875
4
# python3 import sys, threading sys.setrecursionlimit(10**6) # max depth of recursion threading.stack_size(2**27) # new thread will get stack of such size class Node: def __init__(self, key): self.key = key self.left = None self.right = None class BST: def find(self, key, root): ...
d41cf1778102f4d7f6c42d7b64feacb08a09e6fa
wangchonglie/python_data_structures_and_algorithms
/剑指offer/question17.py
2,856
4.21875
4
""" 合并两个排序的链表 输入两个递增排序的链表, 合并这两个链表并使新链表中的结点仍然是按照递增排序的。 """ from linked_list import LinkedList def merge(link1, link2): if link1.next is None: return link2 if link2.next is None: return link1 link1 = link1.next link2 = link2.next new_link = LinkedList() cur_node = new_link.root ...
8c5bc49728a7ec46ce511eb43a4d56cef6503e02
yuukou3333/study-python
/55knock_py/knock_50.py
409
3.890625
4
# モジュールのインポート ===================== import math # θ=π2 theta = math.pi / 2 # sinθ2+ cosθ2=1.0 ans = math.sin(theta)**2 + math.cos(theta)**2 print(ans) # エイリアス ============================= # import後にasをつけることで別名を付けれる。 import math as m # θ=π2 theta = m.pi / 2 # sinθ2+ cosθ2=1.0 ans = m.sin(theta)**2 + m.cos(theta)...
d15d44473c7ab2fc5da633775afe0b5cc96b2024
karlhub/Python-Initial-Programs
/Py01-Initial Programs/Programa_7_Python_Functions.py
903
4.28125
4
# Basic program in Python - Store and Reuse - Functions # Define new function called "thing" def thing(): print("Hello") print("Inside function thing") # Call or invoke function "thing" thing() print("Zip") thing() # Call existing function "max" - Returns the biggest letter of a given string big=max("hello w...
8f9caec682fa4d545e8c1216ee7c49f73004b0db
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/allergies/3ff2a05a034346beafe6d021ec5f27e8.py
530
3.828125
4
class Allergies: THINGS = ['eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats'] def __init__(self, allergies): self.allergies = allergies self.list = [Allergies.THINGS[i] for i in range(len(Allergies.THINGS)) ...
cf07550e27c470102dc33e26d7044cfdc1ac8ebe
pbauer99/basic
/ex11_personal.py
224
3.59375
4
# Trying out some math! print "What is your age?", x = int(raw_input()) print "What is your mom's age?", y = int(raw_input()) print "So, you're %s years younger than your mom!" % ( y - x) # So proud of myself right now
17ab33e8b228466d8cd901151df6f0ef4f21b00f
YasserKa/B-Tree
/key_search.py
2,788
3.578125
4
''' Search for a key in a B+Tree ''' import json import functools import time def search(relation, key): ''' search for a key using linear search a btree ''' def btree_search(relation, key): ''' search for a key method ''' def get_bucket(path, node): ''' ...
cab7d32f5ddf3aa492745be74ac7159ddeb8e595
voltz92/ATBS-Files
/Flow Control/flowcontrol_loops.py
979
4.34375
4
# while loops i = 1 while i < 5: print('This is being repeated') i = i+1 # can be used to run something indefinitely until a condition is met name = '' while name != 'Zafar': print('Please type you name') name = input() print('Thank You') # ^ an example of input validation << Getting the user to inpu...
2a4c107d64fa43547f9b48a385ad0297a5862a70
AlelksandrGeneralov/ThinkPythonHomework
/capitalize_nested_v01.py
462
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 5 19:59:50 2019 @author: aleksandr """ l = [["a", "b"], ["c", "d"], "e"] new_l = [] def capitalize_all(l): for a in l: new_l.append(a.capitalize()) return def capitalize_nested(l): for a in l: if isins...
3142b3a4d6d8d732149af9c93c1a2b567fd5fdd3
songszw/song
/day00/a10.py
1,414
3.5625
4
import time as t class MyTimer(): def __init__(self): self.unit = ['年','月','日','时','分','秒'] self.prompt = '未开始计时!' self.lasted = [] self.begin = 0 self.end = 0 def __str__(self): return self.prompt __repr__ = __str__ def __add__(self,other):...
301789847fcf39e0eb1227caf4b5ffd2cc7b5075
IvanWoo/coding-interview-questions
/puzzles/count_odd_numbers_in_an_interval_range.py
879
4.15625
4
# https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/ """ Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). Example 1: Input: low = 3, high = 7 Output: 3 Explanation: The odd numbers between 3 and 7 are [3,5,7]. Example 2: Input: low = 8,...
dfc8e1b3800c2cb9bec42c87c970fc4aac4dd3b2
faruk2961/PythonExamples
/helloworld/venv/functions.py
1,138
4.09375
4
#####FUNCTIONS###### '''def greet_user(): print("Hi there!") print("How is it going") print("Start") greet_user() print("Finish")''' #######PARAMETERS###### '''def greet_user(first_name,last_name): #name is the parametr print(f"Hi {first_name} {last_name}!") print("How is it going") print("Star...
dc95de380db466fced79bcd41ccd9b55defa55ac
code-carbon/Python-3.6
/Armstrong.py
191
3.5
4
ar=input("~)") m=[] for a in ar: l=int(a) d=l**len(ar) m.append(d) if(sum(m)==int(ar)): print("~} Truly Armstrong") input() else: print("[E] Not Armstrong") input()
40d01abfc9837a99cae22fdbe04a0f461f64d42f
hana1689/boston_property_assessment
/MrJob/rental.py
2,203
3.765625
4
def create_rental_table(cur, conn): """ This function is used to define schema and data types :param cur: pass the cursor to execute query :param conn: pass the connection """ cur.execute("""DROP TABLE IF EXISTS property_assessment""") cur.execute("""CREATE TABLE short_term_rental_eligibilit...
636f74044d018b35d00b82d25ec0ffe1b92429f4
Jyotiranjan767/59_effetctive
/py_cur/property1.py
198
3.65625
4
class P: def __init__(self, x): # self.__x = x self.set_x(x) def get_x(self): return self.__x def set_x(self, x): self.__x = x p1 = P(12) p2 = P(23) print(p1.get_x() + p2.get_x())
c6a4bfda061ce6d25514e2afae144d83145c4eb2
EPlatonenkova/beginner_python
/lesson_3/3-4.py
568
4.0625
4
# def my_func(x, y): первый вариант # print(x**y) # # # my_func(7, -2) # def my_func(x, y): a = x if y == -1: print(x*-1) return elif y ==1: print(x) return elif y == 0: print(1) return else: while y > 1: x = x * ...
9ac50533a6fbf7dfcc341e8cef44a53be1871a48
patalwell/spark
/dataframeFromCSV.py
3,988
3.640625
4
from pyspark import SparkContext from pyspark.sql import * sc = SparkContext spark = SparkSession(sc) #Load the CSV File In Raw Format # Note: we will need to parse the fields and create a row object to load a DF data = sc.textFile("/Users/palwell/PycharmProjects/localCode/CCA175/2008.csv") # Load the CSV with Spark...
484ace2cbbf8d70c21a22e2588e8906aa15c1c2f
Johndsalas/space_commander
/spend.py
4,015
3.6875
4
''' Handels Spend phase ''' import hud as h import random as r def feed_crew(food, crew): ''' Feed crew ''' # set food_consumed equal to number of crew food_consumed = crew # remove the food consumed from the supply and display results food -= food_consumed # if the player has food r...
85adb279eab79f7a10525a4352de2488f72ad66b
hifish78/mypython
/two_poniters/remove_duplicate_nums_in_array_lint521_easy.py
1,658
3.875
4
class Solution: """ 这个问题有两种做法,第一种做法比较容易想到的是,把所有的数扔到 hash 表里,然后就能找到不同的整数有哪些。 但是这种做法会耗费额外空间 O(n)。面试官会追问,如何不耗费额外空间。 此时我们需要用到双指针算法,首先将数组排序,这样那些重复的整数就会被挤在一起。然后用两根指针, 一根指针走得快一些遍历整个数组,另外一根指针,一直指向当前不重复部分的最后一个数。 快指针发现一个和慢指针指向的数不同的数之后,就可以把这个数丢到慢指针的后面一个位置,并把慢指针++。 感觉这道题其实算三指针了吧?一对前后比较用的指针,相差1 和一个resu...
dfdaf77e839e836d00e5eee0ea2b6bb3b855328c
shotasenga/algorithm
/python/grokking-algorithms/06/mangoseller.py
1,154
3.90625
4
from collections import deque def is_mango_seller(name): return name[-1] == "j" def find_mango_seller(graph, start="you"): checked = set() queue = deque() queue += graph[start] while queue: maybeseller = queue.popleft() # use Queue for BFS # we need to check if we already chec...
feda8b1d70cbae8a98b6cdfd87e32e120d31ea88
Akhilkumar94/practice1
/oops/module.py
169
3.78125
4
import coin def main(): mycoin1=coin.Coin() print("the side is up:",mycoin1.get_toss()) for count in range(10): mycoin1.toss() print(mycoin1.get_toss()) main()
f5048ef5553b52139c4b9d6ce8c4ad1954b03324
Samuel1043/leetcode
/code/1342.py
418
3.796875
4
class Solution: def numberOfSteps (self, num: int) -> int: step=0 while num>0: if (num & 1 == 1) and num!=1: step+=2 elif (num & 1 == 1) and num==1: step+=1 else: step+=1 num=num >> 1 ...
e27476fb0454ea762b4c7f49b31d7c1b1b391cb3
dmitriyanishchenko/Teach_My_Skills_Python_base
/src/Home-_and_classworks/Work_7_and_8[functions]/cw_7_task_7_7.py
435
3.984375
4
# Создать функцию, которая принимает на вход неопределенное количество # именных аргументов и выводит на экран те из них, длина ключа которых четна. def func_print(**kwargs): for key, value in kwargs.items(): if not len(key) % 2: print(key, value) func_print(aaa=1, bb=2, cccc=3, ddddd=4)
909c1c369acdace6e4b99735f0285d8ca2a9daa8
ourcach/scripts
/python/file_parse/main.py
2,614
3.625
4
# !/usr/bin/python import sys import simplejson as json def parse_file(infile): """ Parses the file to extract the information """ data = {} with open(infile) as inf: for line in inf: values = line.split(' ') if len(values) != 4 : print "Invalid line. Skippi...
034ee13bf13f0223e7a17aeff1ede1ff5b4dac9d
duanwandao/PythonBaseExercise
/Day04(列表及嵌套列表)/Test01.py
1,655
4
4
""" 1.嵌套循环的使用: 2.for循环 for 变量 in range(start,end,step): 循环体 3.for循环的嵌套 for for 4.99乘法表的练习 倒序99乘法表 for 循环.__reversed__(): 5. 等腰三角形/菱形 * *** ***** 6.字符串的使用 6.1定义 6.2输出 6.3输入 6.4求长度 6.5索引值范围 [0,字符串长度-1] 6.6切片操作 字符串[start:end:step] ...
0c0490dda9d1506770fb1a875a5be8c241627a03
tisnik/python-programming-courses
/Python2/examples/generators/gen_list.py
156
3.71875
4
def n_items(max_n): n, numbers = 0, [] while n <= max_n: numbers.append(n) n += 1 return numbers lst = n_items(20) print(lst)
39c43c20234d022ab405420687e8888294a068d4
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Basics/4_Conditional_Statements/greater_number.py
344
3.78125
4
""" Conditional Statements - Lab Check: https://judge.softuni.bg/Contests/Practice/Index/1012#0 02. Greater Number Condition: Write a program that reads two integers entered by the user and prints the larger of the two. """ number_1 = int(input()) number_2 = int(input()) if number_1 > number_2: print(number_1) el...
06f7e09769de79693ff9fc6106cc6b937d539229
rjmarshall17/miscellaneous
/leet_code_prison_cells_after_n_days.py
5,154
3.875
4
#!/usr/bin/env python3 from typing import List from time import perf_counter from copy import deepcopy """ 957. Prison Cells After N Days There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a ce...
a26648e67a10f56ad9a6d796e9bccddca2e530f2
Oshalb/HackerRank
/shiptoys.py
386
3.53125
4
# Priyanka and Toys def count_weight(w): w.sort() r = 1 f = w[0] for i in w: c = list(range(f, f+5)) if i not in c: f = i r += 1 return r if __name__ == "__main__": number_of_toys = int(input()) list_of_weights = list(map(int, input().rstrip().split...
1ddced4022a81eee0fa477b7f7be1ae8027bc945
OfiliPatrick/python-algos
/Trees/Flatten Binary Tree To Linked List.py
370
3.578125
4
def flatten(root): if root == None: return None stack = [root] while stack: curr_node = stack.pop() if curr_node.right: stack.append(curr_node.right) if curr_node.left: stack.append(curr_node.left) if stack: curr_node.ri...
b27206f5050e4180004f2236ef517e427f1c12dc
gorakh7/shigo_python
/Flow Control/if_elif_else.py
170
3.859375
4
# -*- coding: utf-8 -*- # Author : Gorakhnath Suryawanshi n=input("Enter the name:") if n=="Gorakh": print("Hello",n) elif n=="Surya": print("Hello",n) else: print("by")
d5303116590bff443f5c236c2852032c10a5b4af
chinu1996/pythonPrac
/nonlocal.py
272
3.78125
4
def echo_shout(word): """Change the value of the nonlocal variable echo_word""" echo_word = word * 2 print(echo_word) def shout(): nonlocal echo_word echo_word = echo_word + '!!!' shout() print(echo_word) echo_shout('hello')
39140ffcd90f1cfa063641651964cf339f808659
tomlepaine/arsenal
/arsenal/algorithms/mst.py
1,687
3.53125
4
from arsenal.datastructures.unionfind import UnionFind ''' def mst(G): """ Find the minimum spanning tree (mst) of an undirected graph G. `G` should be a symmetric adjacency matrix. The mst is returned as a list of edges. """ N = G.shape[0] assert G.shape[0] == G.shape[1] # Krusk...
208306c652a9ac6c64eaf475a3b692dce914b05b
Shusovan/Basic-Python-Programming
/String Pallindrome.py
218
4.375
4
def String_pallindrome(): txt=input('Enter a string: ') if txt==txt[::-1]: print('The string is pallindrome') else: print('the string is not pallindrome') print(String_pallindrome())
fe91bf9a0d8b428663467d77529dce317606d91b
lvjiujin/algorithm016
/Week_01/20.有效的括号.py
1,665
3.5625
4
# # @lc app=leetcode.cn id=20 lang=python3 # # [20] 有效的括号 # # @lc code=start class Solution: def isValid(self, s: str) -> bool: # 第一种栈的方法 # if len(s) %2 == 1: # return False # pairs = { # ')' : '(', # '}' : '{', # ']' : '[' # } ...
e99ba05aa4ea8993d12dbcb1b7e5c0e573074afd
7ergbb/weather-report
/backend/model.py
570
3.53125
4
from .app import db class Weather(db.Model): """Data model for weather info.""" __tablename__ = 'weather' days = db.Column(db.DateTime(), primary_key=True) temperature = db.Column(db.Float()) pressure = db.Column(db.Float()) def __init__(self, days, temperature, pressure): self.days ...
bbc3a2a71072785c341ca41f2df2668264e94a17
wellingtonoliveira96/PythonProjects
/Algoritmos/055 MaiorMenorSequência.py
396
3.890625
4
menorP = 0 maiorP = 0 for count in range(1, 6): peso = float(input('Peso da {}ª pessoa: '.format(count))) if count == 1: maiorP = peso menorP = peso else: if peso > maiorP: maiorP = peso if peso < menorP: menorP = peso print('O maior peso lido foi de {...
17959c77e1173ab2725a7e97454a00a2be0f52da
kderoulet/phillies
/improved_palindrome.py
128
3.875
4
def is_palindrome(s): for x in range(0, len(s) // 2): if s[x] != s[-1 - x]: return False return True
2b889e090b3cfe55a54c369fc98acb7d8e73b00c
RamonMTNZ/CustomerUIOverhaul
/ProgSDBikeShare1/main/customer/Login.py
3,769
4.03125
4
""" the log in and register page """ import random import sqlite3 from main.customer.customer import Customer def login(entry1, entry2): name = entry1.get() password = entry2.get() db = sqlite3.connect('../../bicycle_db/db_file/bicycle.db') cursor = db.cursor() sql = "SELECT user_pa...
dc238ba102e9aaf4e14434a88239f5efe29addfa
jtstodola/AdventuresInPython
/Introduction/number_of_characters.py
167
3.9375
4
print "What is the input string?" input_string = raw_input() characters = len(input_string) print "The string \"%s\" has %i characters." % (input_string, characters)
cc221b760f7f8174a76a0ed680b82bea9b003a67
bemagee/LearnPython
/newthinktank/Python-onevideo-functions-8.py
192
3.578125
4
#!/usr/bin/env python3 import os import sys import random def addNumber(fNum, lNum): sumNum = fNum + lNum return sumNum print(addNumber(2,4)) string = addNumber(5,8) print(string)
0276858da63c810a869b22a6395772e58b300636
AdoreL/210CT-Coursework
/9.py
714
3.984375
4
a = [2,3,5,7,9,13] def binary(a): low = 10 high = 14 if len(a) == 0: #5 Repeat from step 1 until len(sequence)==0. return False else: mid_value = len(a)//2 #1 Find middle value of sequence. if a[mid_value] >= low and a[mid_value] <= high: return True #2 if the middle...
2b0a227b37d26939eaca8fc51673d8d96147c572
wangmengyu/pythontutorial27
/ch04/for.py
929
3.71875
4
# -*- coding: utf-8 -*- # 循环一个列表,并且,打印每个元素的长度 words = ['cat', 'window', 'defenestrate'] for item in words: print item, len(item) print id(words) # 错误范例: 把长度超过6的单词一次插入到序列头部,由于没有用切片复制原来的列表 # index每次到最后个元素发现要插入到列表最前端,死循环 print 'Wrong way:' words = ['cat', 'window', 'defenestrate'] cnt = 0 for index, item in enumerate(...
3f214efa0b7076680d5264caf75482c624a7c6d3
stamp465/01204111-Computer-and-Programming
/lab07/04.py
770
3.734375
4
#04 def can(subtext,sub,can1) : #print(subtext,sub) countt = 0 save = [] for i in range(len(sub)) : if subtext[i] != sub[i] : countt += 1 return True if countt <= can1 else False def change(subtext,sub) : for i in range(len(sub)) : if subtext[i] != sub[i] : subtext = subtext[:i] + '?' + su...
dec7fcd2ef8742818e8f827aa15d9afb682649d3
rofernan42/Bootcamp_Python
/day01/ex02/vector.py
2,522
3.734375
4
class Error(Exception): def __init__(self, string): self.string = string class Vector: def __init__(self, values): try: if isinstance(values, list) or isinstance(values, range): self.values = [float(i) for i in values] elif isinstance(values, int): ...
01ce897207e56a0996c0cbf262043ccb368a4122
gp-learning/Python_educative_assignment
/LC266. Palindrome Permutation.py
765
3.609375
4
def canPermutePalindrome(s): """ :type s: str :rtype: bool """ res ={} cnt=0 if not s: return True for char in s : if char not in res : res[char] = 1 else: res[char] += 1 for i in res.values(): if i%2 !=0: cnt+= 1...
439e8e9734d2263137d3f70760f535ea7a656648
Potehter/GB_python
/hw_01_03.py
481
3.53125
4
''' Определить, какие из слов «attribute», «класс», «функция», «type» невозможно записать в байтовом типе.''' def main(): start_list = ["attribute", "класс", "функция", "type"] for word in start_list: try: encode_word = bytes(word, 'ascii') except: print('Word: {0} cann...
3eb270da7a115046266d9565a5d980cf8ae62842
leoandrade20/Aprendendo
/Passatempo Fail :p/contracheque1.py
1,636
3.9375
4
#NOME: LEONARDO ANDRADE #DATA: 23/04/2019 #DESCRIÇAO: print('Entre com o valor do salário bruto', end = ': ') salBruto = float(input()) print('Entre com o desconto do Imposto de Renda (porcentagem)', end = ': ') valor_IR = float(input()) print('Entre com o desconto do INSS', end = ': ') valor__INSS = float(input()...
657a4d2131b40f406f3a8b80907f5ba09c2f4808
arnabmaji1981/thirdday
/classpractice/Student.py
217
3.515625
4
class Student: def _init(self, name): print("This is a paremeterized constructor") self.name=name def show(self): print("Hello", self.name) student = Student( "arnab" ) student.show()
e250c50d36ac8d414b61bf63d07e958e859f87ea
HLNN/leetcode
/src/0659-split-array-into-consecutive-subsequences/split-array-into-consecutive-subsequences.py
2,079
4.03125
4
# You are given an integer array nums that is sorted in non-decreasing order. # # Determine if it is possible to split nums into one or more subsequences such that both of the following conditions are true: # # # Each subsequence is a consecutive increasing sequence (i.e. each integer is exactly one more than the prev...
0ef700525da187c2cbe5ff845f42613538dea7d7
taruntmk2712/1BM17CS116
/Lab1/1a.py
292
3.9375
4
def func(a): b = [] for i in a: if i%2 == 0: b.append(i) print("Even List:") print(b) a = [] n = int(input("Enter the size of list:")) print("Enter elements:") for i in range(n): item = int(input()) a.append(item) print("List:") print(a) func(a)