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
48f90fd3936c5404ef89fe12dceab1d0205917ef
AdyGCode/Python-Basics-2021S1
/Week-13-2/gui-5-guessing-game.py
1,576
3.75
4
# -------------------------------------------------------------- # File: Week-13-2/gui-5-guessing-game.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 13/05/2021 # Purpose: GUI Guessing Game version 5 # # Duplicate the fourth version of the guessing game. # # ...
20220b19b70882bd2608ff640a47a409c4096b6c
AdyGCode/Python-Basics-2021S1
/Week-11-1/turtle-0.py
456
3.609375
4
# -------------------------------------------------------------- # File: Week-11-1/turtle-0.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 27/04/2021 # Purpose: ... # # -------------------------------------------------------------- import turtle def main(...
db13074a2c8dca8e5d1708a80760d6626f3b0b9b
AdyGCode/Python-Basics-2021S1
/Week-7-1/functions-4.py
1,251
4.34375
4
""" File: Week-7-1/functions-4.py Author: Adrian Gould Purpose: Demonstrate taking code and making it a function Move the get integer code to a function (see functions-3 for the previous code) Design: Define get_integer function Define number to be None While nu...
00f774425fef375c49488ab6a600fd7a6446eaa9
AdyGCode/Python-Basics-2021S1
/Week-14-1/gui-3-guessing-game.py
5,734
3.921875
4
# -------------------------------------------------------------- # File: Week-13-2/gui-3-guessing-game.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 13/05/2021 # Purpose: GUI Guessing Game version 3 # # Duplicate the second version of the guessing game. # # ...
425571e8bb0512c2a92f9068883189291acb771b
AdyGCode/Python-Basics-2021S1
/Week-13-1/gui-7-exercise.py
1,242
4.1875
4
# -------------------------------------------------------------- # File: Week-13-1/gui-7-exercise.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 11/05/2021 # Purpose: Practice using GUI # # Problem: Create a GUI that asks a user for their name and # ...
296cb1eb8c60dcbb970f9cfe8c2143567f1ee5a9
AdyGCode/Python-Basics-2021S1
/Week-12-1/Head.py
8,930
4.03125
4
# -------------------------------------------------------------- # File: Week-12-1/Head.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 4/05/2021 # Purpose: Define a Head class that provides the properties # and methods to work with a "Head" # # ----...
4f231845ecc5b8b82e00868f0a79c4589687677e
AdyGCode/Python-Basics-2021S1
/Week-14-1/gui-4-guessing-game.py
7,587
3.953125
4
# --------------------------------------------------------------------- # File: Week-13-2/gui-4-guessing-game.py # Project: Python-Class-Demos # Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au> # Created: 13/05/2021 # Purpose: GUI Guessing Game version 4 # # Duplicate the third version of the guessing game...
c8e88317f84254d02f1960db841a2d059f45b9ef
nwillouis/Bilangan-Prima
/Bilangan Prima Python.py
348
3.6875
4
angka1=int(input('Masukkan Bilangan Awal :')) angka2=int(input('Masukkan Batas Bilangan :')) def prime(x): prim = True if x >= 2: for i in range (2,x): if x % i == 0: prim = False else: prim = False return prim for i in range(angka1,angka2): if ...
8a02c742373184f3bff204699f65cd633e1743ac
jfbeyond/Coding-Practice-Python
/104_max_depth_BT.py
584
3.6875
4
# 104 Max depth of Binary Tree # Recursively def maxDepth(root): if not root: return 0 left = maxDepth(root.left) right = maxDepth(root.right) return 1 + left + right # O(2**n) 0(1) # Iteratively def maxDepth(root): if not root: return 0 queue = [root] h = 0 ...
93b88115beb91ba6ca1454fc945ffd892f6af039
jfbeyond/Coding-Practice-Python
/88_merge_sorted_array.py
756
4.0625
4
# 88 Merge Sorted Array # m and n are the numbers of initialized elements in both lists respectively # nums1 has a total lenght of m+n def merge(nums1, m ,nums2,n): # as both arrays are sorted I can compare the biggest elements in each and the # greater goes towards the last available position. Then ...
8e37afd4974810531570c685449be25c8d9f7de9
jfbeyond/Coding-Practice-Python
/count_paths_matrix.py
681
3.5625
4
# Number of ways in matrix # Find number of ways to go to the bottom-right corner from the origin # Use of DP to acumulate the number of ways from bottom-up def countPaths(matrix): rows = len(matrix) cols = len(matrix[0]) nways = [[0 for i in range(cols)] for i in range(rows)] ...
b306448e151d13b2caeb8cfced3a9650affc29ba
jfbeyond/Coding-Practice-Python
/101_symmetric_tree.py
1,026
4.15625
4
# 101 Symmetric Tree # Recursively def isSymmetric(root): # current node left child is equal to current node right child if not root: return False return checkSymmetry(root, root): def checkSymmetry(node1, node2): if not node1 and not node2: return True if node1 and node2 and node1...
1054fe4e7275b70f08241e76b647fbc7ae08f5e0
Badjeck/-savamarsh-
/Pong/testtttt.py
268
3.5
4
from tkinter import * root = Tk() root.geometry('500x500') root.title('Good morning :)') frame1 = Frame(root, bg='green') frame1.pack(expand=True, fill=BOTH) button1 = Button(frame1, text='Hello') button1.place(relx=0.5,rely=0.5) root.mainloop()
26c7b72e5ab402e6cb306e94760d687cfa0e5f98
ojp13/FYP_Python_1
/FYP_Python_1/Practice_Code/tkinter_practice_1.py
2,314
3.921875
4
import tkinter as tk LARGE_FONT = ("Verdana", 12) # Specifying a constant large font class SeaofBTCapp(tk.Tk): #inheriting for Tk class in tkinter def __init__(self, *args, **kwargs): #Initialise method, always runs when creating object # *args - arguments, can pass as many arguments as possible ...
66af000d857f6ae85e1364fed1aa83419795c1a8
aylusltd/python_experiments
/blackjack/blackjack.py
4,594
3.828125
4
#!/usr/bin/python import random import constants import deck deck = deck.Deck() bank = constants.starting_bank # bank = 100 def show_all_hands(hands): for hand in hands: displayHand(hand) def resolve(hands, dealerHand, bets, display=True): winnings=0 print "Dealer has the following cards in their...
e7c878f3ee0d5f281dcd681ca3abbbd8d6d89816
aylusltd/python_experiments
/hello_gui.py
1,714
3.703125
4
from Tkinter import * import random class Application(Frame): MIN = 1 MAX = 10 guesses=0 def guess(self): text = self.entry_text.get() try: i=int(text) self.guesses+=1 if i<self.n: text="Higher" elif i>self.n: ...
d025e8bb20ac6773f0fa2661ef65b1539a3749f0
netvolutionfr/NSI
/triselection.py
152
3.53125
4
def is_sorted(t): for i in range(len(t)-1): if t[i] > t[i+1]: return False return True def selection_t(t): return t
1c99ba2cc7b4208ac0562984a6308bd253fc47e1
netvolutionfr/NSI
/factorieltest.py
1,655
3.640625
4
# fact1 : On commence par 0 et on teste si i <= n donc on fait n+1 boucles : on obtient donc (n+1)! # trouver un contre exemple def fact1(n): i = 0 F = 1 while i <= n: i += 1 F *= i return F """ fact2 : démonstration de la correction partielle invariant : P(F,i) = "F = i!" et i<=n 1. I...
a27e465a32b0515b3703323b5a7f34bb85b64348
Mensyne/python_crawler
/re_execrises/re_split.py
263
3.765625
4
#-*- coding:utf-8 -*- import re # 分割字符串,返回列表 s = "a.. ,, .. ;;ab ..a" pattern = re.compile(r'[\s\.;,]') result_list = pattern.split(s) print(result_list) pattern = re.compile(r'[\s\.;,]+') result_list = pattern.split(s) print(result_list)
35c761b946ac1180bb68118b8e683f1482a1da18
dirtoise/practice-archive
/practice god 16.py
702
3.671875
4
try: line = input("What is your file: ",) handle = open(line) except: errs = line.find(".txt") errs = False print("File doesn't seem to exist.") exit() dito = dict() for line in handle: line = line.rstrip() # print(line) splitter = line.split() # print(splitter) for splits in...
db797dc2fce5cec8bebf880901ba42e97a7b239f
k0vbaska/passgen
/passgen.py
710
3.921875
4
# Простой генератор паролей import random symbols = '+-/*!&$#?=@<>abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' def generate(len): len = int(len) if len > 50: print("Длина пароля не может быть более 50 символов") main() else: password = '' for i in range(len): password += random.choic...
3390e1fa726690425b21263d22ab9dc26e560e16
Environmental-Informatics/06-graphing-data-with-python-ankitghanghas
/matplotlib_tutorial/makeplots.py
1,828
3.984375
4
"""" Created on 2020-02-21 Friday Creator: Ankit Ghanghas makeplots.py This Script takes input and output file name from the command line and makes a plot with three subplots and saves the result as the output file specified by the user. The first plot is year vs streamflow indicating mean flow with black line, max f...
cac16cbd620976ee6ce684986f8271c5a919f390
JoPfeiff/Coursework_Machine_Learning
/HW4/Submission/Code/cluster_utils.py
2,107
3.578125
4
import numpy as np import matplotlib.pyplot as plt import math def cluster_quality(X,Z,K): ''' Compute a cluster quality score given a data matrix X (N,D), a vector of cluster indicators Z (N,), and the number of clusters K. ''' score = 0 for i in range(len(X)): for j in range(len(X)):...
5a746b2c55bed5719560f0fd3bab426d498a3c25
Voilencer/AlgorithmDaily
/linear_regression/线性回归.py
1,204
3.53125
4
import torch import numpy as np import matplotlib.pyplot as plt """如何用pytorch拟合线性模型 model: y = 5 * x + 7 """ # 训练数据 x = np.random.rand(256) y = x * 5 + 7 + np.random.randn(256) / 4 # Linear: y = w * x + b # 输入1,输出1 model = torch.nn.Linear(1, 1) # 损失函数 criterion = torch.nn.MSELoss() # 优化器 SGD # SGD ,每一次迭代计算min...
078321f7605f615819be4ae9b9065480a38004a0
Voilencer/AlgorithmDaily
/logitic_regression/logistic_regression.py
1,899
3.546875
4
import numpy as np import matplotlib.pyplot as plt """逻辑回归 假设方程:h_θ(x) = g(θt * X) g(z) = 1 / (1 + e^(-z)) 代价函数: 优化方法:梯度下降法 """ def sigmoid(z): return 1.0 / (1 + np.exp(-z)) def cost_function(theta, X, Y): X = np.matrix(X) Y = np.matrix(Y) Theta = np.matrix(theta) first = np.mult...
203bcabecf74838bdd9db23e1423c1531f2400d3
Voilencer/AlgorithmDaily
/直线和点/点在直线投影.py
1,397
3.71875
4
import math import matplotlib.pyplot as plt """ 直线:P1P2 直线外一点:P3 (1) """ def cal_proj1(P1, P2, P3): # 直线求交点 if P1[0] == P2[0]: x = P1[0] y = P3[1] elif P1[1] == P2[1]: x = P3[0] y = P1[1] else: k_12 = (P2[1]-P1[1]) / (P2[0] - P1[0]) b_12 = P1[1] - k...
ac3c4de06570bf7eeb231899a3bc1c6304884493
SarinSwift/Tweet-Generator
/linkedlist.py
7,415
4.21875
4
class Node(object): def __init__(self, data): """Initialize this node with the given data.""" self.data = data self.next = None def __repr__(self): """Return a string representation of this node.""" return 'Node({!r})'.format(self.data) class LinkedList(object): ...
b1929517361b0b18c53aca6e7d7d2c17bd1722b4
purelind/DataStructure-Algorithm-python
/basic-data-structure/double_list_node.py
438
3.765625
4
class DListNode: def __init__(self, val): self.val = val self.prev = self.next = None def reverse_iter(head): """ :param head: DListNode, head double list node :return: DListNode, the new head double list node when reversed """ current = None while head: current = ...
a5e135c8b65b5283ad415d9658584076712c5a0b
jhoinner/python
/ejerciciospython/ejemplo6.py
508
3.859375
4
edad = int(input("digite su edad")) genero = input("digite sexo, H para hombre, M para mujer") if edad>=18: if genero in'Hh': print ("Señor usted es mayor de edad") elif genero in 'Mn': print ("Señorita usted es mayor de edad") else: print ("dato incorrecto") else: if ...
84c4b854684b130ea967278319705da39d455cc3
qilong1980/python3
/平均两个数列.py
1,536
3.78125
4
#!/usr/bin/env python #-*- coding:utf-8 -*- #FileName:平均两个数列 #CreateDate: 2016/6/15 17:01 """ 有两个序列a,b,大小都为N,序列元素的值为任意整数,无序; 要求:通过交换a,b中的元素,使序列a与b的元素中之间的差值最小 a = [7058, 4720, 9419, 9979, 4069, 3191, 3158, 3958, 3870, 1967] b = [4242, 7299, 6784, 1170, 3650, 1886, 626, 3923, 4168, 8938] 解: 1,将两个序列合并为一个序列,并排序.为序列new 2,拿出...
173df8e1015e4204db51a6b5f672db3a36ab2356
jcallow/Data-Science
/Twitter Data/frequency/frequency.py
623
3.625
4
import sys import json def get_frequency(tweet): tweet_lines = tweet.readlines() my_list = [] for line in tweet_lines: my_list.append(json.loads(line)) new_words = {} for listk in my_list: if "text" in listk: tweet_text = listk["text"] tweet_words = tweet_text.split() for word in tweet_words: ...
3e465fd69bf5888c29479c5b3f256571646200c4
sainihimanshu1999/Interview-Bit
/LEVEL 6/Trees/binarytreefrompostorderandinrorder.py
301
3.515625
4
class Solution: def buildTree(self,A,B): if not A: return None root_pos = A.index(B[-1]) root = TreeNode(B[-1]) root.left = self.buildTree(A[:root_pos],B[:root_pos]) root.right = self.buildTree(A[root_pos+1:],B[root_pos:-1]) return root
d06c1eadb17c5c21b0acad4b89019ccc0236e1e8
sainihimanshu1999/Interview-Bit
/LEVEL 3/Binary/sortedinsertposition.py
625
3.546875
4
class Solution: # @param A : list of integers # @param B : integer # @return an integer def searchInsert(self, A, B): if B<A[0]: return 0 l = 0 h = len(A)-1 nearest_min = float('-inf') index = 0 while l<=h: m = l+(h-l)/2 ...
4df8cba90a1a53e95d9c95e2a4c496aee36f4c14
sainihimanshu1999/Interview-Bit
/LEVEL 4/Stack and Queue/simplifypath.py
654
3.53125
4
class Solution: # @param A : string # @return a strings def simplifyPath(self, A): s = A.split('/') res = '/' stack = [] for i in range(len(s)): if s[i] != '' and s[i].isalpha() == True: stack.append(s[i]) elif s[i] != '' and l...
ae062444fee3e48f7c66055ab392149f7860f77d
sainihimanshu1999/Interview-Bit
/LEVEL 6/Trees/postordertraversal.py
351
3.546875
4
''' Post order without recurrsion ''' def postorder(self,A): stack = [] ans = [] curr = A while stack or curr: while curr: ans.append(curr.val) if curr.left: stack.append(curr.left) curr = curr.right if stack: curr =...
48a9059d9ca5745fe88e625c8c45679128d83b24
sainihimanshu1999/Interview-Bit
/LEVEL 6/Trees/inordertraversalofcartesiantree.py
349
3.5625
4
''' building tree from given inorder traversal ''' class Solution: def buildTree(self,A): if not A: return None maxval = max(A) maxindex = A.index(maxval) root = TreeNode(maxval) root.left = self.buildTree(A[:maxindex]) root.right = self.buildTree(A[maxi...
1cca5cc40e84e7e4b314ded2f82786d5e845b0f2
rocooper7/5.Webscraping
/3.Curso_Scrapy/1.Gen_Iter/15.iteradores.py
284
4.3125
4
my_list = [1, 2, 3, 4, 5] #Iterable, como funciona for my_iter = iter(my_list) #Se convierte en iterador print(type(my_iter)) # Extraer los elementos print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter))
7db2f4f02a31f5132a81a498ed3682e6b3ddab7d
hafei/Practice-Project
/OO/OOSr.py
739
3.703125
4
from types import MethodType class Student(object): # __slots__ = ('name', 'age', 'score','set_age') #__slots__变量,来限制该class实例能添加的属性 动态添加 # @property装饰器就是负责把一个方法变成属性调用的 def __init__(self): self.score = 0 @property def say(self): return 'Hello world' @property def score(sel...
a7f0bb0e211f38bcb4f14f443d42ff9c5bb9c9af
hafei/Practice-Project
/OO/ClassDemo.py
1,175
3.53125
4
class Zhangmeng(): __slots__ = ('name', 'age', 'work', 'action', 'career') def __init__(self): self.name = 'zhangmeng' self.age = 28 self.career = 'Programmer' def __len__(self): return len(self.name) def __str__(self): return 'name is %s' % self.name __r...
2415a29b9392bb35bb49fdf1d00316529311481b
caiotorrez/CodeForce
/Guest From the Past.py
561
3.546875
4
dinheiro = int(raw_input()) plastico = int(raw_input()) vidro = int(raw_input()) retornavel = int(raw_input()) qt_vidro = 0 qt_plastico = 0 if dinheiro >= plastico: qt_plastico = dinheiro / plastico if dinheiro >= vidro: qt_vidro = ((dinheiro - retornavel) / (vidro - retornavel)) dinheiro = dinheiro - ((...
274f7be9fa4b9c58817103b435e198291842c099
caiotorrez/CodeForce
/A. Broken Clock.py
970
3.65625
4
def relogio(formato, horas, minutos): h = '' m = '' if formato == 12: if int(minutos) >= 60: m = '0' + minutos[1] elif int(minutos) < 60: m = minutos if int(horas) > 12: if int(horas[0]) > 1 and (int(horas[1])) < 3: h = '1' ...
942da6a0f596539dedf3a15dc170f59dc278df57
MalloryHuston/TicTacToe
/TicTacToe.py
4,781
4.34375
4
class TicTacToe: """ A game of TicTacToe includes a board with nine spaces and its current win state. """ def __init__(self): """ Instantiates a new game of TicTacToe with nine blank spaces on the board and current_state "UNFINISHED". """ self.board = [["","",""],["","",...
22a62e594dd67d6cfbbe37b3f87d684288c1391b
o-hill/air-quality
/predict.py
1,762
3.84375
4
''' Predict the next couple days of AQI, and plot it. ''' import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression from matplotlib import pyplot as plt import seaborn as sns import matplotlib as mpl mpl.style.use('seaborn') from dataset import build_network_data, build_df MEAN ...
1353ee42c247cd5d9a30cb3bd9fc5f33639d181a
F4Francisco/Algorithms_Notes_For_PRofessionals
/Section1.2_FizzBuzzV2.py
777
4.125
4
''' Optimizing the orginal FizzBuzz: if divisable by 3 sub with Fizz if divisable by 5 sub with Buzz if divisable by 15 sub with FizzBuzz ''' # Create an array with numbers 1-5 number = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] #iterate through the array and check which numbers are fizz and which are Buzz for num ...
d1b6129a28c49c0c533595a4ab1b1c25f63aba7f
lalitsshejao/Python_PractiseCode
/scripts/list_comp.py
647
3.765625
4
# List Comprehension ''' ex1 ''' name=["lalit", "sagar", "abcd", "xyz"] l=[] for person in name: l.append(person) print(l) print([person for person in name]) print([person + ' worked with me.' for person in name]) # Dictionary Comprehension movies_and_rating = {"abc":3, "www": 5, "XXX": 8, "qqq": 9, "sss": 1} ...
04b97f09791407a13124c6514aced04917491a2a
lalitsshejao/Python_PractiseCode
/scripts/OOPs_StaticVariable.py
783
4.09375
4
''' Various Places to declare static Variable 1. within class directly 2. Inside constructor using Class Name 3. Inside Instance Mentho by using Class Name 4. Inside classmethod by using cls variable or Class Name 5. Inside static method by using class name 6. from outside of the class by using classname ''' class Te...
d181eef8156995d972d41d93fe6ec978be937b69
lalitsshejao/Python_PractiseCode
/scripts/Pattern_RightStart.py
279
3.546875
4
#RevercePyramid def pattern(n): for i in range (0, n): for j in range (0, i + 1): print("* ", end = "") print("\r") for i in range (n, -1, -1): for j in range (0,i + 1): print ("* ", end="") print("\r") pattern(5)
368b27465e0cea1c8d0c788cfe45266751af63e1
lalitsshejao/Python_PractiseCode
/scripts/lambda.py
1,610
4.09375
4
from functools import reduce #import functools or from functools import * #lambda argument : expression x= lambda a : a*a print(x(4)) #Lambda within User defined function def a(x): return (lambda y : x + y ) t= a(8) print (t(7)) u = a(10) print(u(10)) #Lambda within filter() #filter(function, iterables) #...
275482cb5866ebb040f4116807d7dab78289bd8a
lalitsshejao/Python_PractiseCode
/scripts/reverseString.py
641
4.0625
4
# string=input("Enter String :") # n=len(string) # i=0 # print("String In Forward Direction :") # while i<n: # print(string[i],end="") # i=i+1 # print() # print("String In Reverse Direction :") # i=n-1 # while i>=0: # print(string[i], end="") # i = i - 1 # # print() # print("String In Reverse Direction ...
48b083291e65fd2d7aed1ba825c9290370b98bfc
HangJie720/ML_DecisionTree
/predic_titanic_survived
1,689
3.671875
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ========================================================= Decision Tree Prediction of titanic_survived_condition ========================================================= This example uses datasets titanic.txt from URL:http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSet...
e5e7ef14baa4d4b7b3596bb4adf7cadaddea2e07
SimaFish/python_practice
/class_practice/auto.py
2,571
4.40625
4
# Zen of Python import this # The definition of a class happens with the `class` statement. # Defining the class `Auto`. # class Auto(object): is also an allowable definition class Auto(): # ToDo class attributes vs. instance attributes # https://www.toptal.com/python/python-class-attributes-an-overly-thorough...
43594d3f6b04fcee5ff2285226da49fd96471d89
SimaFish/python_practice
/modules/mod_string.py
1,027
4.25
4
import string # String constants (output type: str). # The lowercase letters 'abcdefghijklmnopqrstuvwxyz'. print('1: ' + string.ascii_lowercase) # The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. print('2: ' + string.ascii_uppercase) # The concatenation of the ascii_lowercase and ascii_uppercase constants descri...
57d66045ea57f048efaa86409b4f16ce96cd58e9
Dzhud/PyCal
/PyCal.py
3,102
3.671875
4
from tkinter import * import datetime import time root= Tk() root.title("Quick-Cal") root.geometry("600x600") # On Grid """label_1= Label(root, text="Name", padx=2, fg="grey") label_2= Label(root, text="Password", padx=2, fg="grey") entry_1= Entry(root, bg="grey") #Entry() in Tkinter is like 'input()'. W...
bf762ccbb24d3fb46c7d33913a0baa37a893b804
BAGABR1/Bogomolov_Ivan_dz_11
/task_11_1.py
803
3.609375
4
class Date: def __init__(self, date): self.date = date @staticmethod def valid(d, m, y): if 0 < d < 32 and 0 < m < 13 and 0 < y < 2022: print(f'дата {d}-{m}-{y} верна!') else: print(f'значение даты {d}-{m}-{y} ошибочно!') @classmethod def int_date(cl...
63d0e3c76e62260981dea4fe2c6db8ee710cc4a3
MurtazaBadshah121/python_OnlineBankingAppCli
/helper.py
1,627
3.984375
4
class Account(object): def __init__(self, number, owner, balance, limit=1000.0): self.__number = number self.__owner = owner self.__balance = balance self.__limit = limit def view_balance(self): print("The current balance of your account is {}".format(self.balance)) ...
8a6a977af0a354fc77e2375b8cfef729973618ec
lanlan47879/adventofcode2020
/day02/day02_part01.py
1,331
3.859375
4
import sys def get_entries(input_file): with open(input_file, 'r') as f: entries = f.readlines() entries = [entry.strip() for entry in entries] return entries def get_split_entries(entries): split_entries = [] for entry in entries: count, char, pw = entry.split(" ") min_...
a5e6d20c7a20e30283cad2d99a1425b8ea3f9d1f
lanlan47879/adventofcode2020
/day09/day09_part02.py
1,830
3.8125
4
import sys def get_entries(input_file): with open(input_file, 'r') as f: entries = f.readlines() entries = [int(entry.strip()) for entry in entries] return entries def is_valid_sum(num, preamble): for i in preamble: for j in preamble: sum = i + j if sum == nu...
79e6ed5d5dc2130f04c8ca1ce3c8d154e8ef8a46
seo0/MLstudy
/adsa_2016/module10_text_analysis/part01_lexical_complexity/text_analysis_one.py
3,997
4.28125
4
""" Your task is to complete the implementation of the functions below. Some functions implement different metrics to evaluate the "lexical richness" of a "text" The rank_on_lex_complexity() functions allows to rank 3 texts based on lexical richness The function get_nltk_text_from_string() is GIVEN and allows yo...
f88081441a595bb5e682ab59cd654c8f67e122ac
seo0/MLstudy
/adsa_2016/module10_text_analysis/part02_pos_analysis/text_analysis_two.py
3,537
4.25
4
""" Your task for this week is to implement some functions to understand the complexity of a text based on the info provided by nltk PoS (Part-of-speech) tagging. The function get_nltk_tagged_from_text() is GIVEN and it returns a pos-tagged nltk text from a generic string. This function can be used to tag any gen...
971160b9a639e70ac77188567bd9656dfe1b38a3
seo0/MLstudy
/day1/part01_helloworld/FruitSeller.py
1,195
3.8125
4
#make the relationship class #관계형 클래스 구축 class fruitSeller: def __init__(self, apple, money, price): self._numberOfApple = apple self._money = money self._price = price def SaleApple(self,payment): payment == BuyApple[payment] pass #예외처리하기, 가진개수보다 더 많이 살때는 가진것만...
6896682b041713dff84ab145274b7858f3f3c7bc
seo0/MLstudy
/adsa_2016/module13_graphs01/part02_basics02/graphs_etc.py
1,760
4.3125
4
import networkx as nx import matplotlib.pyplot as plt from module13_graphs01.part01_basics.graphs_basics import print_graph, display_and_save def modulo_digraph(N,M): """ This function returns a directed graph DiGraph) with the following properties (see also cheatsheet at: http://screencast...
4dd7d4e15a3d7a28b5e588a1dfe33c10e6c993a4
EdsonAlonso/PFG_FallaLuza
/modules/sphere.py
3,757
3.53125
4
# -------------------------------------------------------------------------------------------------- # Title: Grav Codes # Author: Edson Alonso Falla Luza # Description: Source codes # Collaboratores: Rodrigo Bijani # -------------------------------------------------------------------------------------------------- #...
27a4f17cca33da9b7840df1959f1996655ae8b73
Isai-gomez/Reglas-B-y-V
/regla_b.py
1,538
3.953125
4
#importamos los otros modulos import reglas_b_con_terminaciones_funciones import b_buscado continuar = 1 #print(type(continuar)) while continuar == 1: palabra = input("Ingresa un VERBO, PREFIJO O PALABRA para saber si se escribe con B o V:_") palabra = palabra.upper() if palabra =="": print("No escribiste nada") ...
6b921fe3122fb98f8c42a7fab0e7c558c660c93e
effervescentFibration/AdventOfCode
/2020/day/4/part/1/solution.py
1,579
3.75
4
''' byr (Birth Year) iyr (Issue Year) eyr (Expiration Year) hgt (Height) hcl (Hair Color) ecl (Eye Color) pid (Passport ID) cid (Country ID) ''' def validate_passport(l): fields = { "byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pi...
7f904f7323e4ce32079ef9e19da30e5b4c1c7f11
Antonio1980/PythonAlgoritm
/lesson1/linked_list.py
2,989
4.0625
4
from lesson1.node import Node class LinkedList: def __init__(self): self.head = None self.tail = None def add_in_tail(self, node): if self.head is None: self.head = node node.prev = None node.next = None else: self....
a6d6a364461cc20ea52411e1c1db5bfa079a67ce
luckydimdim/grokking
/merge_intervals/minimum_meeting_rooms/main.py
2,343
4.0625
4
from heapq import * class Meeting: def __init__(self, start, end): self.start = start self.end = end def __lt__(self, other): return self.end < other.end def min_meeting_rooms2(meetings): ''' Given a list of intervals representing the start and end time of ‘N’ meetings, find the minimum number ...
3ee3a72792df8bef4778b22b796f04f05134d9cc
luckydimdim/grokking
/dynamic_programming/equal_subset_sum_partition/main.py
1,471
3.625
4
def can_partition2(nums): ''' Given a set of positive numbers, find if we can partition it into two subsets such that the sum of elements in both subsets is equal. ''' s = sum(nums) if s % 2 != 0: return False dp = [[-1 for x in range(s + 1)] for y in range(len(nums))] retu...
1895a345a9021d25dcdc91982ff00b6f3090474a
luckydimdim/grokking
/tree_breadth_first_search/minimum_depth_of_a_binary_tree/main.py
1,086
4.1875
4
from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def find_minimum_depth(root): ''' Find the minimum depth of a binary tree. The minimum depth is the number of nodes along the shortest path from the root node to the nearest leaf...
28ab4ec0dcffa6625f4aba984dda562f6efed06d
luckydimdim/grokking
/fast_and_slow_pointers/start_of_linked_list_cycle/main.py
1,544
4.09375
4
from __future__ import print_function class Node: def __init__(self, value, next=None): self.value = value self.next = next def print_list(self): temp = self while temp is not None: print(temp.value, end='') temp = temp.next print() def find_cycle_start(head): ''' Given the he...
a13bc097fc48c6962d06515e6e72b7a357f19b70
luckydimdim/grokking
/k_way_merge/kth_smallest_number_in_m_sorted_lists/main.py
1,307
3.78125
4
from heapq import * def find_Kth_smallest2(lists, k): ''' Given ‘M’ sorted arrays, find the K’th smallest number among all the arrays. ''' result = -1 max_heap = [] pointer = 0 while lists: if len(max_heap) < k: heappush(max_heap, -lists[pointer][0]) del ...
48f1fa5d3668a54ec73e49e377c610b3bfdba024
luckydimdim/grokking
/modified_binary_search/search_bitonic_array/main.py
1,139
4.15625
4
def search_bitonic_array(arr, key): ''' Given a Bitonic array, find if a given ‘key’ is present in it. An array is considered bitonic if it is monotonically increasing and then monotonically decreasing. Monotonically increasing or decreasing means that for any index i in the array arr[i] != arr[i+1]. ...
a50d496618f6197d36d11e72c75186975ddf48e8
luckydimdim/grokking
/topological_sort/alien_dictionary/main.py
1,489
4.0625
4
from collections import deque def find_order(words): ''' There is a dictionary containing words from an alien language for which we don’t know the ordering of the characters. Write a method to find the correct order of characters in the alien language. ''' result = '' if len(words) == 0: ...
9e429a3d67b58bd3e34e0868fa203e80c8215925
luckydimdim/grokking
/modified_binary_search/next_letter/main.py
1,092
4.125
4
import string def search_next_letter(letters, key): ''' Given an array of lowercase letters sorted in ascending order, find the smallest letter in the given array greater than a given ‘key’. Assume the given array is a circular list, which means that the last letter is assumed to be connected with ...
5921d9a5ee2ca9e587ea6d8a54cdaf6126ffd510
luckydimdim/grokking
/subsets/permutations_recursive/main.py
535
4.1875
4
from collections import deque def find_permutations(nums): ''' Given a set of distinct numbers, find all of its permutations. ''' result = [] permutate(nums, 0, [], result) return result def permutate(nums, i, current, result): if i == len(nums): result.append(current) return for l in range(...
55f81a624717ea4b49ce74dfa8704d8e79c6a8c2
luckydimdim/grokking
/cyclic_sort/find_the_smallest_missing_positive_number/main.py
533
4.0625
4
def find_first_missing_positive(nums): ''' Given an unsorted array containing numbers, find the smallest missing positive number in it. ''' i, n = 0, len(nums) while i < n: j = nums[i] - 1 if nums[i] >= 0 and nums[i] < n and nums[i] != nums[j]: nums[i], nums[j] = num...
f493fc23c5cd1432737f6686e881da536705a709
luckydimdim/grokking
/kth_smallest_number/main.py
948
3.984375
4
from heapq import * def find_Kth_smallest_number(nums, k): ''' Given an unsorted array of numbers, find Kth smallest number in it. Please note that it is the Kth smallest number in the sorted order, not the Kth distinct element. ''' max_heap = [] for i in range(len(nums)): if i < k:...
57bf01794444f9e3fc31973d50f33a3cdbd9639b
luckydimdim/grokking
/tree_breadth_first_search/zigzag_traversal/main.py
1,289
4.15625
4
from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def traverse(root): ''' Given a binary tree, populate an array to represent its zigzag level order traversal. You should populate the values of all nodes of the first level from lef...
667a2a4a9b01eb0f6705f6846263c634ee9405f2
luckydimdim/grokking
/two_heaps/find_the_median_of_a_number_stream/main.py
1,373
4.25
4
from heapq import * class MedianOfAStream: ''' Design a class to calculate the median of a number stream. The class should have the following two methods: insertNum(int num): stores the number in the class findMedian(): returns the median of all numbers inserted in the class If the count of numbers inser...
d41cdb2b381dcc5191472b52e2e4fee8025324b9
luckydimdim/grokking
/top_k_elements/k_closest_numbers/main.py
1,259
4.0625
4
from heapq import * def find_closest_elements(arr, K, X): ''' Given a sorted number array and two integers ‘K’ and ‘X’, find ‘K’ closest numbers to ‘X’ in the array. Return the numbers in the sorted order. ‘X’ is not necessarily present in the array. ''' result = [] start, end = 0, len...
f4b437c09975e2a9f17dddaa4dcd9b836695254b
luckydimdim/grokking
/top_k_elements/kth_largest_number_in_a_stream/main.py
1,006
3.984375
4
from heapq import * class KthLargestNumberInStream: ''' Design a class to efficiently find the Kth largest element in a stream of numbers. The class should have the following two things: The constructor of the class should accept an integer array containing initial numbers from the stream and an integer ‘K’....
dee2ecde3b5e04ec57a41618db6c81325f3d84cf
tracyhn/Chapter-6-PE.11
/Huynh_Chap6_PE11.py
1,940
3.96875
4
#======================================================================================= #Author: Tracy Huynh #Program ID: Huynh_Chap6_PE11.py #Due Date: 05/06/2019 #Description: This program prompts the user to enter their name and # personal description. Using the user's inputs, th...
79a97b5fef6a9bfdb8be3c71090ace9450dd297e
emurph1/unit1
/binary.py
461
3.90625
4
#Emily Murphy #2017-09-06 #binary.py - enter 8 digit binary number and converts it into base of 10 num = int(input('Enter 8-digit binary number: ')) digit1 = bin%10 digit2 = (num//10)%10 digit3 = (num//100)%10 digit4 = (num//1000)%10 digit5 = (num//10000)%10 digit6 = (num//100000)%10 digit7 = (num//1000000)%10 digit8 ...
5049c0e46a486596e88a642b477e612ca2c9fe65
emurph1/unit1
/inputDemo.py
187
4.03125
4
#Emily Murphy #2017-08-31 #inputDemo.py - how to do user input name = input('What is ou name?') print('Hello', name) age = int(input('How old are you? ')) print('You are', age+1, 'years old')
6548a216412f9767646ac33307f7caf677ea8f86
emurph1/unit1
/eggs.py
177
3.90625
4
#Emily Murphy #2017-09-06 #eggs.py - eggs and egg cartons egg = int(input('Enter number of eggs: ')) cartons = int(input('Enter number of egg cartons: ')) print((egg/12)<= cartons)
26d0710097359544a6b3d7b55281ff18b3881cb8
JulianCarvajal/Basic-python
/condicionales.py
157
3.859375
4
edad = int(input('Ingrese su edad: ')) if edad > 17: print('Eres mayor de edad, vamos por unas Polas!!!') else: print('Eres menor, no puedes entrar')
51b750c6461549ecc9485949b5840cec44924643
adriquinp/Clase-3-
/matematicas.py
952
3.75
4
def suma(a,b): return a + b def resta(a,b): return a-b def producto(a,b): return a*b def division(a,b): return a/b def factorial(a): temp=1 for i in range(1,a): temp =temp*(i+1) return temp def factorial1(a): temp=1 for i in range(1,a): ...
b49679bced081624851a740444f8ce1c9fb24620
VivekKrG/Python-3-Practice-Problems-and-Solutions
/CoderForce/global 3.py
204
3.5
4
n, m = map(int, input().split()) if n == 1 and m == 1: print(0) else: for row in range(1, n+1): # print('hello bro', row) for col in range(n+1, n+m+1): print(row*col, end=' ') print()
2d57516356b27d625bd24ec1e869519654f59d40
VivekKrG/Python-3-Practice-Problems-and-Solutions
/Jio code Gladitor TechGig/new Year party.py
5,252
3.546875
4
''' Neighbours and New Year Party (100 Marks) In the XYZ society, the neighbours hate each other for their attitude. Various activities are organized in the society for Welcoming the New Year. The tickets were provided to each house with an integer written on it. Some got tickets with positive integers and some got...
22205d22d4d407c6b0ce782f372f857b6322898a
VivekKrG/Python-3-Practice-Problems-and-Solutions
/CoderForce/coderforce 607 2.py
527
3.9375
4
tests = int(input()) for __ in range(tests): string = input() if string[-2:] == 'po': print('FILIPINO') elif string[-2:] == 'su': print('JAPANESE') else:# string[-1:-3] == 'da': print('KOREAN') ''' 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida haji...
04d6a86c4075c6244ec8ec17111be5db5998aa49
VivekKrG/Python-3-Practice-Problems-and-Solutions
/Jio code Gladitor TechGig/practice.py
2,616
3.59375
4
''' Read input from STDIN. Print your output to STDOUT ''' # Use input() to read input from STDIN and use print to write your output to STDOUT def check(matrix): temp = 1 for i in range(len(matrix)): temp = min(matrix[i]) if temp == 0: break return temp def main(): n, m = map(int, input().s...
dad3653aa67891333ea8c563e858859b64a7190c
sunnarun/verklegt1
/employee.py
687
3.515625
4
class Employee(): def __init__(self, ssn, name, role, rank, address, phone_no, license): self.ssn = ssn self.name = name self.role = role self.rank = rank self.address = address self.phone_no = phone_no self.email = self.name.replace(" ",".").lower() + "@" + "...
995d723bcd3e83d7b0154051c0d093711b0b64fa
rupindermonga/HackerRank30DayChallenge
/HackerRank_26.py
1,018
3.921875
4
#https://www.hackerrank.com/challenges/30-nested-logic/problem import datetime def fine_library(): return_date_input = input() expected_date_input = input() return_day, return_month, return_year = return_date_input.split() expected_day, expected_month, expected_year = expected_date_input.split() ...
ec3ff1a4394019a4601832a587769bda4131f333
Pmtague/algos-cs26
/stock_prices/stock_prices.py
977
3.90625
4
#!/usr/bin/python import argparse def find_max_profit(prices): current_max = 0 # Start with the first price and loop through for i in range(0, len(prices) - 2): # Compare with each of the following prices for k in range(i + 1, len(prices) - 1): diff = prices[k] - prices[i] # Allow for negative profit ...
5d3ce860f84ea2aa733eb11630301e515ca38597
bmontambault/GP-structure-search
/ABCD/Language.py
2,301
3.734375
4
class Language: """ Define a language for translating strings to kernels. Attributes: kernel_mappings: Dictionary mapping kernel_strings to kernels. operation_mappings: Dictionary mapping operation_strings to operations. """ def __init__(self,kernel_strings,operation_strings,kernels,...
aa90788ded41dd315cf1539d518d332dd48b70a4
bryanlferguson/CS352_Symbolic_Programming
/PA1_fergusonb.py
3,603
4.1875
4
import math ''' ====================== TASK 1 ====================== ''' ## # Computes the number of tiles needed and the gap at each end when # placing tiles along a wall. # # Define the dimensions. totalWidth = 100 tileWidth = 5 # Calculate the tiles and gaps. numberOfPairs = (totalWidth - tile...
77d12eeca676f6018dfc6c90494a3033e99fc060
geopandas/geopandas
/doc/nyc_boros.py
2,381
3.71875
4
""" Visualizing NYC Boroughs ------------------------ Visualize the Boroughs of New York City with Geopandas. This example generates many images that are used in the documentation. See the `Geometric Manipulations <geometric_manipulations>` example for more details. First we'll import a dataset containing each borou...
3606db2da6879a675d880ee4da9c45b8016d3d01
Stanhoucke/Karaoke_hw
/classes/room.py
1,857
3.515625
4
class Room(): def __init__(self, input_room_number, input_capacity): self.room_number = input_room_number self.playlist = [] self.guests = [] self.capacity = input_capacity self.tab = 0.00 def add_song(self, song): self.playlist.append(song) def remove_gues...
4db45f071aafab9743505a1fc7baf51c81a7d002
Akwa/old-fakeemall
/helping_functions.py
418
3.640625
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- import random import settings as s from string import (ascii_lowercase, ascii_uppercase, digits ) characters = ''.join((ascii_lowercase, ascii_uppercase, digits)) def generate_seed(): if s.random_seed is N...
5e6882d1589feae81f73f84c9408712bfe8d6efc
bahdotsh/Python_Explorations
/tuples_sets.py
461
3.9375
4
# A tuple is a collection which is ordered and unchangeable. Allows duplicate numbers #create tuple fruits = ('Apples', 'Oranges', 'BlueBerries') #single value needs trailing comma fruits2 = ('Apples',) #Cannot assign values to tuples # fruits[1] = 'Pears' #won't work #A set is a collection which is unordered an...
e57d2048ff65665cd10d3f1e668352f2486ce844
caitig131/Homework-
/chapt6_H_2.py
180
4.25
4
def is_divisible(x,y): """ Test if x is exactly divisible by y """ return x % y == 0 num1 = 3 num2 = 12 if is_divisible(num1,num2): print("yes") else: print("no")