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
57e5eaf89d28721bbd59c53748ce9309764350d9
8787ooo/Python200817
/me.py
287
3.859375
4
e = int(input("english:")) m = int(input("math:")) if (e >= 0 and e<=100) and (m >= 0 and m<=100): if m >= 90 and e >= 90: print("good") elif m < 60 and e < 60: print("bad") elif m < 60 or e < 60: print("soso") else: print('!!ERROR!!')
2e9dc9a1978e85f307d9c81e5441126dec1f8c03
adiazcan/databricks
/Databricks/core-partners-2.0.4/Python/Optional/Delta-demo.py
18,685
3.515625
4
# Databricks notebook source # MAGIC # MAGIC %md-sandbox # MAGIC # MAGIC <div style="text-align: center; line-height: 0; padding-top: 9px;"> # MAGIC <img src="https://databricks.com/wp-content/uploads/2018/03/db-academy-rgb-1200px.png" alt="Databricks Learning" style="width: 600px; height: 163px"> # MAGIC </div> #...
e99c201c807c4844489151d4595003fdcc8a23bb
adiazcan/databricks
/notebooks/Users/adiazcan@hotmail.com/FlightDelays/01 Prepare Flight Data complete.py
15,878
3.53125
4
# Databricks notebook source # MAGIC %md # Prepare flight delay data # COMMAND ---------- # MAGIC %md To start, let's import the Python libraries and modules we will use in this notebook. # COMMAND ---------- import pprint, datetime from pyspark.sql.types import * from pyspark.sql.functions import unix_timestamp im...
7a63e23ebafcc8275fa1307cfa41aa79050538ba
aslishemesh/Exercises
/exercise1.py
692
4.125
4
# Exercise1 - training. def check_div_even(num, check): if num % check == 0: return True else: return False num = input("Please enter a number: ") if check_div_even(num, 4): print "The number %d can be divided by 4" % num elif check_div_even(num, 2): print "The number %d is an e...
8e761e847c1c17448d274371be2e2a7c6cd43e70
anilkrp/python_DAS
/trie.py
1,471
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[4]: class TriesNode: def __init__(self): self.children=[None]*26 self.isEndOfWord=False class Trie: def __init__(self): self.root=self.getNode() def getNode(self): return TriesNode() def _charToIndex(self,ch): ...
787ec4a754228247ba39aab75fce519cfca2136e
edemaine/pegen
/scripts/find_max_nesting.py
2,499
3.703125
4
#!/usr/bin/env python3.8 """Find the maximum amount of nesting for an expression that can be parsed without causing a parse error. Starting at the INITIAL_NESTING_DEPTH, an expression containing n parenthesis around a 0 is generated then tested with both the C and Python parsers. We continue incrementing the number of...
8c485bdf9f0a43f82aa43c0f6870801321d23415
leemthompo/LPTHW
/ex15.py
429
3.90625
4
# LINES 2-4 USES ARGV TO GET A FILENAME. import sys from sys import argv script, filename = argv txt = open(filename) # I added this meself. With the len(sys.argv) function you can count the number of arguments. print("Number of arguments: ", len(sys.argv)) print(f"Here's your {filename}:") print(txt.read()) print...
8bf3064abfcfb2911d752602486234fd6ba87209
leemthompo/LPTHW
/ex40.py
927
3.796875
4
class Song(object): def __init__(self,lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print(line) happy_bday = Song(["Happy birthday to you", "I don't want to get sued" "So I'll stop right there"]) print(f"hap...
b6685f219444a9a062a62450ffbee30b1ebe764f
KhrulSergey/REST_API_Python_QA
/02 Python Refresher/5 Dictionaries.py
1,111
3.890625
4
__author__ = 'Sergey Khrul' # # Fifth task of Section #2 # student1 = {"name": "Jones", "school": "Computing", "grades": (66, 77, 88)} class_of_students = [ {"name": "Jones", "school": "Computing", "grades": (66, 77, 88)}, {"name": "Ken", "school": "Science", "grades": (56, 97, 28)}, {"name": "Ken", "schoo...
00e343e680ca33d085effc6c73ee8924a9775822
jshargrave/coin_bot
/datetime_funcs.py
1,461
3.578125
4
""" This file is responsible for handling all date and time functions """ import datetime as dt def btc_all_data_date_range(): """ Desc: This function is used to get a tuple of two strings which represent a date range of the entire :return: """ return ["2010-07-17", display_date(dt.datetime.n...
ecd674740893b1705af621476cba5394c61b413b
kevincoughlan808/Udemy_MachineLearningPracticals
/BreastCancerClassification/Code
4,185
3.765625
4
#!/usr/bin/env python # coding: utf-8 # # CASE STUDY: BREAST CANCER CLASSIFICATION # # Dr. Ryan Ahmed # # STEP #1: PROBLEM STATEMENT # # - Predicting if the cancer diagnosis is benign or malignant based on several observations/features # - 30 features are used, examples: # - radius (mean of distances from...
e4af4f2bde0cde2a85ea06461b1c508a6eccba8f
satyam0051/github
/github/pattern4.py
228
3.890625
4
for i in range(1,6): for j in range(1,6): if ((i+j==4 and i<=3) or ((i-j==2) and i>3) or ((j-i==2) and j>3) or (i==4 and j==4)): print("*",end=" ") else: print("",end=" ") print()
68c21321700a2ed2fd41a3923e26a7e9f084b9a9
atul2938/Machine-Learning-Codes
/MLP.py
10,332
3.578125
4
import numpy as np from sklearn.neural_network import MLPClassifier from sklearn.metrics import accuracy_score import pickle import matplotlib.pyplot as mtp # Sources Used # https://stackabuse.com/creating-a-neural-network-from-scratch-in-python-multi-class-classification/ class NeuralNet: def __init__(self, num...
5db0c8336d976269440ab89746298616c314654a
DDinCA/Byte-of-Python
/ds_using_tuple.py
973
4.25
4
#推荐总是使用括号来指明元组的开始和结束 #尽管括号只是一个可选选项 zoo = ('python', 'elephant', 'penguin') print('Number of animals in the zoo is', len(zoo)) new_zoo = 'monkey', 'camel', zoo #把zoo作为一个整体带入了new zoo,所以new zoo一共只有三个个体 print('Number of cages in the new zoo is', len(new_zoo)) #这句其实就是计算new zoo里的个体数量 print('All animals in new zoo a...
27f14d8eea4a372a51e50879de23f77d6258b761
xieli20181128/StuPython
/03-2PerfectNumber.py
764
3.859375
4
#-*- coding: utf-8 -*- # Name :求完美数(完全数) # Description: 所谓"完美数"又称完全数或完备数,是一些特殊的自然数,它所有的真因子(即除了自身以外的约数)的和,恰好等于它本身。 # 例如:6,它有约数1,2,3,6,除去它本身6外,其他三个数相加为:1+2+3=6。 # 分析过程:首先,要求一个数n的所有因子,即对1-n分别取余,余数为0即可;其次,再将这个数n的所有因子(除了n本身)求和, # 等于n,那么该数就是完全数 for n in range(1, 10000): #求出10000以内的完美数 n...
d6cfec777b058ea59b25850dc887091ebddcdbd9
burgerdev/lazyflow
/lazyflow/utility/format_known_keys.py
1,109
3.8125
4
import string def format_known_keys(s, entries): """ Like str.format(), but (1) accepts only a dict and (2) allows the dict to be incomplete, in which case those entries are left alone. Examples: >>> format_known_keys("Hello, {first_name}, my name is {my_name}", {'first_...
b662d0570a20b5716c118d4bbf763e82ecb60bdc
peterhchen/100_Python
/02_07_OverrideClass/quiz_0709/quiz_0702.py
551
3.625
4
#!/usr/bin/env python class Animal: says = 'Grrrr' def __init__(self): self.mobile = True def __str__(self): return self.says def __call__(self): print ("run") class Human(Animal): says = 'Hi' class Plant: says = 'Sunshine' def __init__(self): self.mobile = False def __cal...
bba37bad23da916c5d041bc46d8c892d390eb1aa
peterhchen/100_Python
/02_04_DictionaryFile/0402_File/13_walk_stats.py
1,686
3.8125
4
#!/usr/bin/env python """Here is a demonstration of using os.path.walk to accumulate statistics through the files walked.""" import os import total_text def TotalDeep(stats, dir_name, files): """Called by walk to return statistics into stats. stats = [number_of_files, total]""" print ('TotalDeep() is call...
72427b25d5d1f32bf215456611e142f0c64c7e50
CaioHoly/Python-3-Mundo-1
/ex0024.py
117
3.90625
4
cidade = (str(input('Digite o nome da cidade: '))).strip() listar = cidade[:5].upper() == 'SANTO' print(listar)
208e93e078356b858d80524f643c18a370b403ac
CaioHoly/Python-3-Mundo-1
/ex009.py
584
3.5
4
num = int(input()) print('-' * 12) a = print('{} x {:2} = {}'.format(num, 1, num * 1)) b = print('{} x {:2} = {}'.format(num, 2, num * 2)) c = print('{} x {:2} = {}'.format(num, 3, num * 3)) d = print('{} x {:2} = {}'.format(num, 4, num * 4)) e = print('{} x {:2} = {}'.format(num, 5, num * 5)) f = print('{} x ...
1e625fee83f5116abb24fd8bc5c11aee9757f47b
CaioHoly/Python-3-Mundo-1
/ex0011.py
330
3.84375
4
largura = float(input('Largura da parede: ')) altura = float(input('Altura da parede: ')) area = largura * altura qtdTinta = area / 2 print('Sua parede tem a dimensão de {}x{} e sua área é de {}m²'.format(largura, altura, area)) print('Para pintar essa parede, Você precisará de {}l de tinta.'.format(qtdTinta...
40606e675e5c72daab68b01b29428915fddcdd8b
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/sorting_and_searching/peaksAndValleys.py
452
4.03125
4
def sortPeaksValleys(arr): n = len(arr) if n <= 1 : return arr if arr[0] < arr[1]: arr[0], arr[1] = arr[1], arr[0] isValley = True for i in range(2,n): if (isValley and arr[i] < arr[i-1]) or (not isValley and arr[i] > arr[i-1]): arr[i], arr[i-1] = arr[i-1], arr[i]...
1ffa2721336eaadab75981120810300e569781c4
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/trees_and_graphs/commonAncestorI.py
477
3.71875
4
def commonAncestor(u, v): """ Returns lowest common ancestor :param u: node with parent :param v: node with parent :return: node """ depth_u = depth(u) depth_v = depth(v) if depth_u < depth_v : u, v = v, u for _ in range(abs(depth_u-depth_v)): u = u.parent wh...
f5e06d7376b882a580c200764d720dd5ca79e14d
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/moderate/bisectSquares.py
1,740
3.984375
4
class Point(object): def __init__(self, x, y): self.x = x self.y = y class Square(object): def __init__(self, p1, p2, p3, p4): """ Anti-clockwise :param x1: :param x2: :param x3: :param x4: """ self.corner1 = p1 self.corner...
0a6fe142d37c0955778f858f95d781ac74ca0bb8
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/linkedlists/kthFromLast.py
465
3.75
4
def kthFromLast(head, k): """ Print value of kth element from last convention = 1th = last element :param head: LinkedList :param k: int :return: LinkedList """ if not head: return head p1 = p2 = head for _ in range(k): if not p2 : print('Element not acc...
5f7682ac830c954900ce3fa97bbea2d75cc31dff
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/recursion_and_dp/robotInGrid.py
1,305
3.859375
4
class Point(object): def __init__(self, x, y): self.x = x self.y = y def __eq__(self, other): return other.x == self.x and other.y == self.y def __str__(self): return (self.x, self.y) def robotInGrid(grid, r, c): """ Find a path for a robot sitting on the upper lef...
8d58ee63400ada781fbfb7dd6f1eed8d26f16d74
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/recursion_and_dp/magicIndex.py
1,275
3.875
4
def magicIndex(A): """ Finds index i such that A[i] = i with an array of distinct integers :param A: array of integers :return: """ n = len(A) left, right= 0, n-1 while left <= right : mid = (left+right)//2 if A[mid] == mid : return mid elif A[mid] < m...
a8f1e8184e7e9978bf6e12aaefbd380dcdf3ba5a
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/recursion_and_dp/permStrDup.py
661
3.625
4
def getPerms(s): result = [] n = len(s) seen = set() getPermsHelper("",s,n,result, seen) return result def getPermsHelper(prefix, remainder, remaining_length, result, seen): if remaining_length == 0: if prefix not in seen: result.append(prefix) seen.add(prefix) ...
3872ac1ff6aaa3b5c9fbac8d31831095863c293d
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/bit_manipulation/flipBitsAndWin.py
915
3.875
4
def flipBits(x): """ Find the length of the longest sequence of 1 we could get by flipping one 0 to 1 :param x: :return: """ lastZeros = 0 while x%2 == 0 and x: #remove last zeros lastZeros += 1 x >>=1 if not x: #only 0s return 1 prevLength, res, currLength = ...
bf6eb4605fff3eebde0c7bac9d77aac02167cec1
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/linkedlists/intersection.py
404
3.65625
4
def length(head): res = 0 curr = head while curr: res += 1 curr = curr.next return res def intersection(l1,l2): len1, len2 = length(l1), length(l2) if len1 < len2 : l1, l2 = l2, l1 for _ in range(abs(len1-len2)): l1 = l1.next while l1 : if l1 == l...
69f6ab81e0b4bc6331b706eae386409ff8819a9f
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/moderate/sumSwap.py
1,095
3.71875
4
def search(arr, size, target): left, right = 0, size - 1 while left <= right : mid = (left+right)//2 if arr[mid] == target : return mid elif arr[mid] < target : left = mid + 1 else: right = mid - 1 return None def sumSwap(arr1, arr2): ...
8a67534baf7f2d4ad99b1a5dbd6c236e005cd1ba
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/recursion_and_dp/tripleStep.py
187
3.53125
4
def tripleStep(n): if n < 3: return n a, b, c = 0, 1, 2 for i in range(3,n): tmp = a + b + c a = b b = c c = tmp return a + b + c
56e1a21c8645e2641c341c4a3e5320239ff1c2fe
fords/_Practice_
/max_gain.py
729
4.0625
4
"""Given an list of integers, write a method - max_gain - that returns the maximum gain. Maximum Gain is defined as the maximum difference between 2 elements in a list such that the larger element appears after the smaller element. If no gain is possible, return 0. """ def max_gain(input_list): max = 0 min = 0 ...
b4d7841ba3074677f68a0d9b885b42a09dd67379
fords/_Practice_
/find_range.py
565
3.640625
4
"""Given a sorted list and an input number as inputs, write a function to return a Range object, consisting of the indices of the first and last occurrences of the input number in the list. """ def find_range(input_list,input_number): low = 0; upper = 0; flag = 0 for i in range(0,len(input_list)): t...
9f1157b501791c4cac209b2ebacefaf0c04da0aa
benfield97/info-validator
/info_validator.py
1,041
4.1875
4
import pyinputplus as pyip import datetime import re while True: name = pyip.inputStr("What is your name? ") if all(x.isalpha() or x.isspace() for x in name): name_len = name.split() if len(name_len) < 2: print("Please enter both a first and last name") continue ...
c169cfcc1c0786729790df420a5a8c5ab392f604
lunnersword/PyForSubdivision
/util/C_type_conics.py
5,991
3.859375
4
from numpy import * import printAsMatlab def cone(): ''' % ------------------------------------------------------------------------- % Ploting line from i*l to (i+1)*l and so on. % The parametric equation of the line is % x=t; y=a*t+b; % t\in[i*l,(i+1)*l]; u0=1; % ----------------------...
154d4f83a89cd14db4eacd5af88ef75674c09af5
Quanghuy99/Practice_code
/100exempleBasic/all_longest_strings.py
338
3.5
4
def allLongestStrings(s): max = 0 l = [] for i in range(len(s)): len(s[i]) if len(s[i]) >= max: max = len(s[i]) for i in range(len(s)): len(s[i]) if len(s[i]) >= max: max = len(s[i]) l.append(s[i]) print(l) allLongestStrings(s=['s',...
81e16014b7713567ddaf064ce192fe7ebb3e4f53
Quanghuy99/Practice_code
/100exempleBasic/bài4.py
277
3.609375
4
#Viết chương trình chấp nhận một chuỗi số, #phân tách bằng dấu phẩy từ giao diện điều khiển, #tạo ra một danh sách và một tuple chứa mọi số. values = input("nhập giá trị :") l = values.split(",") t = tuple(l) print(l) print(t)
5f53ff9f8d35541ecd83390bb06664ba7939c897
Quanghuy99/Practice_code
/matrix_in_elements_sum.py
502
3.5625
4
# cho bạn 1 ma trận ! hãy tính tổng các số của ma trận # điều kiện , tính theo cột : các ô được tính sum là phải nằm trên ô 0 def matrix(s): # s= [1,2,0,1], # [2,0,3,2], # [0,2,4,3] sum = 0 for j in range(len(s[0])): for i in range(len(s)): if s[i][j]!=0: ...
2b9e01ddc538528fbd778ae4a1db5285ae83f9f9
Atul-Nambudiri/AIMPS
/cs440_pacman/position.py
363
4.03125
4
class Position(object): """ A Position object that is used by the priority queue to get the position with the greatest priority, or low cost """ def __init__(self, pos, cost): self.pos = pos self.cost = cost return def __cmp__(self, other): """ Implement the comparison function for the Position object...
96462c062184481c6cec62c680be4ab6fcdf2dd0
ItsMeMegaMind/HackerRank
/Algorithm/Implementation/encryption/encryption.py
502
3.703125
4
#!/bin/python3 import math def encryption(s): s = s.replace(" ", "") n = len(s) l = math.sqrt(n) r,c = math.ceil(l),math.floor(l) print(r,c) if(r*c<n): c+=1 arr = [list(s[i:i+r]) for i in range(0,len(s),r)] print(arr) out = "" for i in range(r): try: for j in...
3123b39d579fb93e083d0ff5828fb07669a3210d
ItsMeMegaMind/HackerRank
/Algorithm/Implementation/Designer PDF Viewer/Designer PDF Viewer.py
245
3.515625
4
def designerPdfViewer(h, word): return max([h[ord(i)-97] for i in word])*len(word) if __name__ == '__main__': h = list(map(int, input().rstrip().split())) word = input() result = designerPdfViewer(h, word) print(result)
17460e21058f1e3702cfa65765d383e11e2225cb
deeplhub/python-demo
/src/com/xh/demo/verifycode/opencv_verify_code.py
3,996
3.859375
4
""" Title: 使用 opencv-python 生成验证码 Description: 使用opencv-python lib生成验证码(前提:pip install opencv-python) 参考地址: https://www.cnblogs.com/youmuchen/p/8300027.html numpy.random.randint: https://blog.csdn.net/u011851421/article/details/83544853?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogC...
55010a08ab90d4de3a43e2fcb213911e51ddf5f5
deeplhub/python-demo
/src/com/xh/demo/python/demo12_tuple_06_list相互转换.py
613
3.65625
4
''' Title: 元组与list相互转换 Description: @author H.Yang @email xhaimail@163.com @date 2020/03/05 ''' print("== tuple & list 相互转换 ==") print("list 转 tuple") list1 = [1, 345, 456, "abx", "xyz"] tup = tuple(list1) print("tup:", type(tup)) print("value:", tup) print("\n##################\n") print("tuple 转 list") list1 = l...
4e0bf88e6da0aa51ee2c1dbbf086502141bdc819
deeplhub/python-demo
/src/com/xh/demo/python/demo29_命名空间.py
1,667
3.765625
4
''' Title: 命名空间 - 全局变量 Description: 局部变量只能在其被声明的函数内部访问,而全局变量可以在整个程序范围内访问。调用函数时,所有在函数内声明的变量名称都将被加入到作用域中。 global 和 nonlocal关键字:当内部作用域想修改外部作用域的变量时,就要用到global和nonlocal关键字了。 参考地址: https://www.runoob.com/python3/python3-namespace-scope.html @author H.Yang @email xhaimail@163.com @date 2020/03/08 ''' print(1, "全局变量和...
d2d6e1ef28fa5509118570f0af6c7bf57c3354ec
deeplhub/python-demo
/src/com/xh/demo/python/demo10_for.py
1,012
3.515625
4
''' Title: Description: @author H.Yang @email xhaimail@163.com @date 2020/03/04 ''' for letter in "Python": print("当前字母:", letter) print("\n#####################################\n") fruits = ["banana", "apple", "mango"] for fruit in fruits: print("当前水果:", fruit) print("\n#############################...
5f745752007dd91ef24c7ddcd7277bf12644e71b
deeplhub/python-demo
/src/com/xh/demo/python/demo15_str_03_统计.py
317
3.859375
4
''' Title: 字符串统计 Description: @author H.Yang @email xhaimail@163.com @date 2020/03/05 ''' print("== str 统计 ==") str1 = "123355666" count = str1.count("3") print("count : ", count) count = str1.count("30") print("count : ", count) # 字典 dict1 = {} for i in str1: dict1[i] = str1.count(i) print(dict1)
d66e4f37913ce8c15633f2fdc58c24f1dcddc136
deeplhub/python-demo
/src/com/xh/demo/python/demo17_面向对象_01.py
1,226
3.578125
4
''' Title: 面向对象 Description: 在python中方法名如果是__xxxx__()的,那么就有特殊的功能,因此叫做“魔法”方法 类有一个名为 __init__() 的特殊方法(构造方法),该方法在类实例化时会自动调用 self代表类的实例,而非类。类的方法与普通的函数只有一个特别的区别——它们必须有一个额外的第一个参数名称, 按照惯例它的名称是 self。 @author H.Yang @email xhaimail@163.com @date 2020/03/05 ''' class Student: def __init__(self): print("初始化构造...
bbdb22c379ae33f2229429bcbc7fe0dcd82724c1
Batcraft627/TwitchBot
/python-scripts/red.py
212
3.8125
4
#import RPi.GPIO as GPIO #GPIO.setwarnings(False) #GPIO.setmode(GPIO.BOARD) #GPIO.setup(7,GPIO.OUT) #GPIO.output(7,1) print("This would turn gpio pin 7 on which is connected to the red part of the led strip")
6316afe26e8189c1674a551bcb82e69f31ff38a1
lirick42/coding365
/python/LV2/week01/HW42/hw42.py
235
3.90625
4
def foot(n): if n == 1: return 1 elif n == 0: return 1 elif n == 2: return 2 else: return foot(n-1) + foot(n-2) + foot(n-3) def main(): num = int(input()) print(foot(num)) main()
02429d8c2fc02a6dc769ea76f64182c22d641205
combscCode/project_euler
/71.py
575
3.828125
4
''' NOTES for some fraction n/d, if n/d < 1 and HCF(n,d)=1 it's reduced proper fraction. So if it just can't be reduced anymore and less than 1. ok we're looking for the fraction that is the closest to 3/7 while still being less and we can choose any n,d st n/d <= 1000000 ''' target = 3/7 d = int(1e6) best_n = 0 b...
7b41433cb0299cb59a5736a3debe231d2bed7f1d
combscCode/project_euler
/24.py
1,072
3.84375
4
''' NOTES We can think of these permutations being laid out into sections for a permutation of n elements: let m be the number of permutations available there are n sections of size (m/n) that make up the total list of perms which of these sections you land in determines the first number in the permutation. Let C be...
47b7eb246766f7eb5bb0ed1834a4eddb9807a0fa
rehanprima12/kuylah
/no3.py
177
3.875
4
# 3. MENENTUKAN BILANGAN GANJIL ATAU GENAP bilangan=int(input("Masukan Bilangan : ")) if (bilangan%2)==0: print("Bilangan Genap") else: print("Bilangan Ganjil")
3dde75f77b8ad76ec30dba742f8dc43a6582ed94
hao134/My_Leetcode
/844_TypedOutStrings.py
1,794
3.609375
4
class CompareBackspace: def __init__(self, Sstring, Tstring): self.Sstring = Sstring self.Tstring = Tstring @staticmethod def buildString(StringArray): builtArray = [] for elem in StringArray: if elem == "#" and builtArray!=[]: builtArray.pop() ...
22cfb31ee0c0d2a4894d634ef87059cac8a0ee64
Xuezhi94/learning-and-exercise
/.vscode/数据结构的Python实现/02.数组结构/02.03.三维数组.py
277
3.78125
4
num=[[[33,45,67],[23,71,66],[55,38,66]],[[21,9,15],[38,69,18],[99,101,89]]] value=num[0][0][0] for i in range(2): for j in range(3): for k in range(3): if value >=num[i][j][k]: value = num[i][j][k] print('最小值={}'.format(value))
7e2a2ca00bbaac892cd350564e296d9fc06b3b76
Xuezhi94/learning-and-exercise
/.vscode/数据结构的Python实现/02.数组结构/02.09.左下三角矩阵.py
924
4.125
4
#设计一个Python程序,将左下三角矩阵压缩为一维数组 global arr_size #矩阵维数大小 arr_size = 5 #一维数组的数组声明 num = int(arr_size * (arr_size + 1) / 2) b = [None] * num def get_value(i, j): index = int(i * (i + 1) / 2 + j) return b[index] #下三角矩阵的内容 a = [[76, 0, 0, 0, 0], [54, 51, 0, 0, 0], [23, 8, 26, 0, 0], [43, 35, 28, 18, 0], [12,...
4da42538eaf32fb1b874ef8f4559f3607170a776
alexandervozzhenikov/third_lab
/L3z3.py
409
3.703125
4
import math n = int(input("Кол-во элементов в последовательности n=")) z = 0 x = 0 for i in range(1, n+1): if i % 2 == 0: z = z+i**2 else: x = x+i**3 print('сумма квадратов чётных элементов:', z) print('сумма кубов не четных элементов:', x) print('общая сумма z+x =', z+x)
8e34b385b9924c9995eae846af0a6ebd8528331d
AnthonyFloyd/2015-AdventOfCode-Python
/day17.py
1,662
3.65625
4
# Advent of Code # Day 17 containerList = '''11 30 47 31 32 36 3 1 5 3 32 36 15 11 46 26 28 1 19 3 ''' class Container(object): def __init__(self, capacity): self.capacity = capacity def getInventory(capacityList): containers = [] for item in capacityList: newContainer = Container...
af7f982fe73a955fa444d6b1f44bcbe7c25264b1
jsimkoff/GraphAlgs
/Module3/bipartite/bipartite.py
1,185
3.65625
4
#Uses python3 import sys from collections import deque def bipartite(adj): V = len(adj) if V <= 2: # graphs with 0-2 vertices are always bipartite return 1 class_list = [V+1]*(V) # V+1 will be at least 4, so no issue with 0/1 comparison later classes = [1, 0] Queue = deque() s = 0 ...
5d2438f5a29197e5c51b36c1db0405858e5d1323
dalpm/Goldbach-s-Conjecture-Camp-Euclid-2021
/goldbach.py
3,157
3.78125
4
from primePy import primes import matplotlib.pyplot as plt import numpy as np from matplotlib.figure import Figure from matplotlib.ticker import MaxNLocator # n for the maximum of the interval primes are selected n = 200 prime_list = primes.upto(n) # remove 2 form prime_list because adding an even number to an odd num...
08499af11f2fb0076bb1cc617338bc4007fa95ff
irynkaaa/15-Puzzle-Algorithm-Comparisons
/main.py
5,551
4
4
""" Created by: Ashour Dankha main.py is the driver program that prompts the user for a board state (or press r to randomize). It will then solve the board (if it was correctly inputted) using all the search algorithms implemented. """ from __future__ import print_function from iddfs import iddfs, nr_iddfs from rando...
77b2432307702232cf3174514400d1b9a9c5041d
dave-msk/CarND-Advanced-Lane-Lines-Submission
/utilities/thresholding.py
4,408
3.6875
4
import numpy as np import cv2 def abs_sobel_threshold(image, orient='x', sobel_kernel=3, thresh=(0, 255)): """ Performs x or y directional derivative magnitude thresholding. Arguments --------- image: input image orient: orientation, only 'x' and 'y' are allowed sobel_kernel: side length of Sobe...
a4e828ffddc57348328a53dae0208e7be7044902
nerdycheetah/lessons
/recursion_practice.py
339
4.28125
4
''' Recursion Practice 10/17/2020 Example: Let's make a function that takes in a number and recursively adds to the total until the number reaches 1 ''' def recursive_total(n:int) -> int: if n == 1: return n else: print(f'n is currently: {n}') return recursive_total(n - 1) + n print(r...
c668406003b12908663b36afb0fa05180d094830
clintsearl/hiking-app-testing
/AddGear.py
826
3.84375
4
print("hello World") from selenium import webdriver from selenium.webdriver.support.ui import Select driver = webdriver.Chrome() loadpage = driver.get("https://hiking-gear.herokuapp.com/addgear") name = driver.find_element_by_name("name") driver.implicitly_wait(5) name.click() name.send_keys("Rain Coat") brand = dri...
b9761b24122a9857e9f7b24d7d3907795fb12a31
simrit1/PyKryptos
/pykryptos/mengenlehreuhr.py
2,760
3.578125
4
import sys from datetime import datetime, timedelta from time import sleep from pykryptos.view import Clock, LogItem, TimeItem from pykryptos.cipher import Decipher from pykryptos.parser import Parser class Mengenlehreuhr(): """ The Mengenlehreur clock tells the time by utilising Set-Theory This version o...
0d594ca0c8d96396bbf861cc975930ad4a0f9227
jaemin93/SimilarPictures
/src/visualize.py
1,941
3.546875
4
""" t-SNE 를 사용한 visualization 모듈입니다. """ import os import numpy as np from sklearn.manifold import TSNE import matplotlib.pyplot as plt import matplotlib.colors as colors import matplotlib.cm as cmx from config import * def visualize(): # loading datasets features = np.load(os.path.join(DATA_DIR, FEATURES + "...
5785a7029439f7c0e9a9108d571436152f2f7427
Valveros/cedm610_280_GH_Lab5-
/cedm610_Lab2_in_Lab5/test_maths.py
1,778
3.578125
4
import unittest # Import the Python unit testing framework import maths # Our code to test #from factorial import factorial #from nntplib import first class MathsTest(unittest.TestCase): ''' Unit tests for our maths functions. ''' def test_add(self): ''' Tests the add function. '...
87fc274a4c1980fd57b58d5660b33a4a6885263a
skrishna1978/CodingChallenge-March-2019-
/3.24.2019 | sumExists.py
1,155
3.984375
4
#3.24.2019 - shashi #program accepts an array of numbers A and a number N. #it returns whether or not a SUM of any 2 numbers in A result in N. def sumExists(arrayList,number): #Ex: ([10, 15, 3, 17],27) setOfNumbers = set() #empty set for eachNumber in arrayList: ...
b65ba05b1d364bc28e808483e673c72d292e6ffd
personalrobotics/magipy
/src/magi/parameters.py
2,094
4.03125
4
"""Define RealParameter, DiscreteParameter, DictParameter.""" from abc import ABCMeta, abstractmethod from random import choice, uniform class Parameter(object): """Parameters return samples from their distribution.""" __metaclass__ = ABCMeta @abstractmethod def sample(self): """ Ret...
e5627e0c1a5072622b39e9bd593a165f2ff1794b
shasneXD/Machine-Learning-Algos
/LinearRegression.py
1,028
3.609375
4
X=[1000,2000,20000,30000,75000] Y=[50,90,4000,5000,20000] def mean(list): sum=0 mean=1 length=len(list) for i in list: sum=sum+i mean=sum/length return mean x_mean=mean(X) y_mean=mean(Y) def covariance(x,y): x_error=[] y_error=[] xy_error=[] for i ...
0bc1d273f44f85fc6c70e7509c97776976ae28ae
bkr111/bkrtest
/demo01.py
87
3.640625
4
a = input("请输入:") b = input("请输入:") print("长度为:",len(a)+len(b))
5119769ba1b026ec47ed8aee274c5f7c46eab131
jigyasunayyar/unitestshowcase
/codefile/methods.py
365
3.65625
4
''' method to test the unit test cases ''' import functools def add(*args): ''' addition method ''' return sum(args) def subtract(*args): ''' subtract method ''' return functools.reduce(lambda x, y: x-y, args) def multiply(*args): ''' multiplication method ''' return fu...
58a8e51ff60c59f91d382045198be0d8dedf2a74
coreyarch1234/Data-Structures
/source/sort_alg.py
4,127
4.25
4
#A way to test if a list is sorted: def is_sorted_ascending(input_list): #assume ascending order # if len(input_list) <= 1: # return True # # previous = input_list[0] # for number in input_list: # if number < previous: # return False # previous = number # retur...
215f3f7dd2ce1265a641d7e4ffdd7dadf6b54978
coreyarch1234/Data-Structures
/source/test_string_search_index.py
1,803
3.5625
4
from string_search_index import string_contains_pattern_index import unittest class TestStringSearch(unittest.TestCase): #these tests are for patterns that are in strings exactly the way they are written. def test_is_pattern_in_string(self): assert string_contains_pattern_index('hello', 'hell') is 0 ...
833b866773d903f2d75797fbb5a16a9b78a2c5e1
cxhiano/mapred
/src/utils/sortfiles.py
1,113
3.609375
4
""" Implementation of merge sort files in distributed file system """ import heapq, tempfile import time from utils.conf import * from mrio.record_file import RecordFile def _make_block(buf, tmpdir): file_ = tempfile.TemporaryFile(dir=tmpdir) buf.sort() for record in buf: file_.write(record) f...
01f9a9ed822cd01572879b9216289cbbd5132be9
LoganPletcher/Python_OpenGL
/Balls/lowestnum.py
859
3.6875
4
import collections from collections import * class bunchofstuff: def __init__(self): self.int = 21 self.float = 3.3 self.string = "words" self.list = [2, 3, 4, 4, 5, 6] def MinNumFinder(*argv): minnum = 100000 for arg in argv: if type(arg) is int: if ar...
0b71605226362ddad5ee1f4491387d75470f4169
Holmes-221/health
/health.py
2,666
3.53125
4
#注意:在第一次填报时需要手动填写信息,之后才能使用该程序运行 #该程序以谷歌浏览器为例,其他浏览器类似 from selenium import webdriver as web from time import sleep import threading from selenium.webdriver.chrome.options import Options def autoHealth(STUDENTID,PASSID): try: # chrome_options = Options() # chrome_options.add_argument("--head...
46a542926219289f15a102715f58c3c21420d189
ironywrath/pyStation-CourseraPy
/Course1/W4/hourspay.py
86
3.703125
4
hrs = input("Please enter hours:") pay = float(hrs) * 2.75 print('Pay: ' + str(pay))
6faad5bda3165618e1200df91635558a6c5c3a60
mihaibujanca/hackthealps
/BackEnd/hta_utils.py
2,032
3.546875
4
import urllib.request import json import pandas as pd import geopy.distance NOVICE_AVG_SKIING_SPEED = 6 # meters / second -> 21.6 km/h def get_elevation_open_api(lat, lng): """ Returns the elevation of a specific location on earth using open-elevation API. """ ## build the url for the API call ...
35b304a0a3f5282787854742fe89fc17a77dc5e5
DronDima/NAM
/MPI.py
597
3.75
4
import math eps = 0.0000000001 x0 = 0.8 y0 = 0.1 def f1(x,y): return y - 0.5*x**2 + x - 0.5 def f2(x,y): return 2*x + y - (y**3)/6 - 1.6 def fi1(x,y): return y**3/3+0.8-y/2 def fi2(x,y): return 0.5*x**2-x+0.5 def method(x, y): X = fi1(x,y) Y = fi2(x,y) count = 0 while(max(math.fabs(X-x)...
82353361ac70d4d7d5269d852eca8cf551475015
DronDima/NAM
/constJacobi.py
602
3.703125
4
import math eps = 0.0000000001 def f1(x, y): return y-0.5*x**2+x-0.5 def f2(x, y): return 2*x+y-(y**3)/6-1.6 def method(x, y): X = x - (-0.55*f1(x, y)+0.56*f2(x, y)) Y = y - (1.11*f1(x, y)-0.11*f2(x, y)) count = 0 while(max(math.fabs(X-x), math.fabs(Y-y))): x = X y = Y ...
bdab06e551fb93a8537e747c24d463e8aedb1761
Anshrivastava9/Data-Structures
/Searching/2PointerWay.py
2,670
3.90625
4
#Two POinter Approach for solving sorted array questions # @return true if there is a pair present in the array having sum equals to given number #this is only for sorted array import time start_time = time.time() def Sum(arr,x,h,l=0):#Doubles if l==h: return False if arr[l]+arr[h]==x: return T...
7f1074e7794b254aa71a9f176b47ac51b786852b
Talalyan-Hayk/ASUE-P4E-Homeworks
/Homework4/problem2.py
616
4
4
def func( x ): return 0.05 * x * x * x * x + 0.1 * x * x * x + 0.5 * x * x +10 * x + 5 def derivFunc_1( x ): return 0.2 * x * x * x + 0.3 * x * x + x + 10 def derivFunc_2( x ): return 0.6 * x * x + 0.6 * x + 1 def newton( x ): h = derivFunc_1(x) / derivFunc_2(x) iteration = 0 while abs...
e43d810dfadf662d85f94f53993fc48eae4916ff
nicowjy/practice
/Leetcode/044通配符匹配.py
688
3.546875
4
#!/usr/bin/python # -*- coding: utf-8 -*- # 通配符匹配 class Solution: def isMatch(self, s, p): dp = [[False]*(len(p)+1) for i in range(len(s)+1)] dp[0][0] = True for j in range(1, len(p)+1): if p[j-1] == '*' and dp[0][j-1]: dp[0][j] = True for i in range(1, le...
6ba8ce14e03e0acff5793deba561e12a6d79356d
nicowjy/practice
/JianzhiOffer/49数字在排序数组中出现的次数.py
1,742
3.765625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2019-07-24 12:05:29 # @Author : Nico # @File : 数字在排序数组中出现的次数 """ 题目描述 统计一个数字在排序数组中出现的次数。 """ class Solution: def GetNumberOfK(self, data, k): # write code here if not data or (len(data)==1 and data[0]!=k): return 0 ...
40e3bf58a91faf8e2bb148c3d3a134e7497043c3
nicowjy/practice
/Leetcode/078子集.py
399
3.78125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # 子集 class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if not nums: return [[]] return [x+[nums[-1]] for x in self.subsets(nums[:-1])] + self.subsets(nums[:-1]) ...
42877adf9632f962fe79294e85527437ffb08b8a
nicowjy/practice
/JianzhiOffer/60不用加减乘除做加法.py
861
3.96875
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2019-07-27 14:05:11 # @Author : Nico # @File : 不用加减乘除做加法 """ 题目描述 写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 """ class Solution: def Add(self, num1, num2): # write code here if num1 ^ num2 > -2147483648: a = num1 ^ num2 ...
55fe98e422cb893f445f5635371375d341e4aefe
nicowjy/practice
/JianzhiOffer/01二维数组中的查找.py
1,433
3.96875
4
""" 题目描述 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 """ # -*- coding:utf-8 -*- class Solution: # array 二维列表 def Find(self, target, array): # 考虑最大最小和空数组 if array == [[]]: return False # 从右上角开始,排除不可能的列 i = len(arr...
2b776095766241f15a9f682a7cf7751c506676bc
nicowjy/practice
/Leetcode/055跳跃游戏.py
614
3.84375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # 跳跃游戏 # 贪心算法 class Solution(object): def canJump(self, nums): """ :type nums: List[int] :rtype: bool """ n = len(nums) if n == 1: return True reach = 0 for i in range(n): if i > reach: ...
edcab377fe47ccda40631e5c4a906446972c0ca3
nicowjy/practice
/Leetcode/101对称二叉树.py
753
4.15625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # 对称二叉树 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode ...
f47b606fb1979eedeeb978ede8e2a72d8f1e54f6
AleeUdri/Tp1Recursividad
/Tp1-Recursividad/ejercicios_entrega.py
2,076
3.71875
4
#Ejercicio 5 ENTREGAR def Buscar_valor_letra_romana(Letra_Romano): Valor = 0 if Letra_Romano == 'M': Valor = 1000 elif Letra_Romano == 'D': Valor = 500 elif Letra_Romano == 'C': Valor = 100 elif Letra_Romano == 'L': Valor = 50 elif Letra_Romano == 'X': Va...
57a3da74516b1596cf05060a6a57db83886c3a6f
jianshe2014/pythoncore
/ex/ex2.py
479
4.03125
4
#coding:utf-8 ''' ''' print 18/5 #3 print float(18)/5 #3.6 print 18/float(5) #3.6 print 18/5.0 #3.6 print 18%5 #3 #ǿת a=9 print float(9) #9.0 print "hello"+str(3) #hello3 print bool(3) #True ''' while 3: a=8 b=90 if a>9: print a ''' #ظֵ x=1 x=x+1 x+=1 x-=1 x=y=z=1 print x,y,z #1 #Ȼֵ x,y,z=1,2,"hello" prin...
4efc7ff2c352ab64304264a694e64fe35b9c887b
uminho-miei-engseg-19-20/Grupo1
/aula11/safe.py
2,183
4.09375
4
#Programa em Python para o trabalho prático 11 import re, string while True : #inserção do valor pelo utilizador valor = input("\nInsira valor a pagar (no formato xx(...)xx.xx): ") #verificação do valor inserido if not re.match("[0-9]{2,20}(\.[0-9][0-9])?$", valor) : print("Inseriu um valor errado!") else : ...
a5059b61802f8866ac0bf9b191e7fd8362395911
invokerkael918/TwoPointor
/Kth Largest Element.py
1,314
3.8125
4
class Solution1: """ @param n: An integer @param nums: An array @return: the Kth largest element """ def kthLargestElement(self, n, nums): # write your code here nums.sort() return nums[-n] class Solution2: # @param k & A a integer and an array # @return ans a ...
40b8c072c133e8c93858c0cb82652f19df2f4e56
invokerkael918/TwoPointor
/Two Sum II - Input array is sorted.py
480
3.5625
4
class Solution: """ @param nums: an array of Integer @param target: target = nums[index1] + nums[index2] @return: [index1 + 1, index2 + 1] (index1 < index2) """ def twoSum(self, nums, target): # write your code here h = {} # [2,7,10,15] # {2: 1} for i, n...
c3e1c553db7227e0a1738e02a2264a89ce8f9750
farzmas/Feedforward-neural-net
/skeleton/two_layer.py
7,478
3.578125
4
import numpy as np from tqdm import tqdm import matplotlib.pyplot as plt class TwoLayerNet(): """ A two-layer fully-connected neural network. The network has a cross entropy loss function and. The input layer uses a ReLU or Sigmoid activation function. The output uses sigmoid only. The outputs ...
cc2281a5d5ae0ff6ead4bda4f2836d93c1c408ae
martip23/Physics-Scripts
/LHS RHS calculations.py
891
3.8125
4
#Name: Patrick Martinez #Date: 11/14/2017 #Program: LHS & RHS Calculations #Purpose: Used for lab 9 to calculate LHS and RHS for torque lab. import math #Constants WEIGHT_MASS = 212 #Variables m1 = int(input("enter m1: ")) m2 = int(input("enter m2: ")) m3 = int(input("enter m3: ")) ...
9bd6fab03f3bee47bc639c7ad6d778728d3bdddb
ecastan960/holbertonschool-higher_level_programming
/0x03-python-data_structures/3-print_reversed_list_integer.py
189
4.28125
4
#!/usr/bin/python3 def print_reversed_list_integer(my_list=[]): if my_list is None: return for x in range(-1, -len(my_list)-1, -1): print("{:d}".format(my_list[x]))
d6c396179f3e1ceaab4395097a47c0501bc4a559
ecastan960/holbertonschool-higher_level_programming
/0x11-python-network_1/1-hbtn_header.py
453
3.65625
4
#!/usr/bin/python3 """Write a Python script that takes in a URL, sends a request to the URL and displays the value of the X-Request-Id variable found in the header of the response. """ import sys from urllib import parse, request if __name__ == "__main__": """Don't execute if imported """ with request.url...
05ca288aed10c2db692d59c83fa2e1f554aa296b
ecastan960/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/0-square_matrix_simple.py
167
3.65625
4
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): a = [] for i in range(len(matrix)): a.append(list(map(lambda x: x*x, matrix[i]))) return a