blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
5bba0d96c47ff7b3af05bcdd333516f7bb2b0724
drunkwater/leetcode
/easy/python3/c0119_479_largest-palindrome-product/00_leetcode_0119.py
619
3.546875
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #479. Largest Palindrome Product #Find the largest palindrome made from the product of two n-digit numbers. #Since the result could be very large, you sho...
d012389c84498238c869b3341a76e77f83041d6b
drunkwater/leetcode
/medium/python3/c0246_494_target-sum/00_leetcode_0246.py
1,069
4.03125
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #494. Target Sum #You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you s...
b7cfac60ef2e73a70402f01715431f24152f5794
drunkwater/leetcode
/hard/python3/c0139_757_set-intersection-size-at-least-two/00_leetcode_0139.py
1,274
3.765625
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #757. Set Intersection Size At Least Two #An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a an...
c4a9cd29e54a6a0284568e5cd4970fa43223eb18
drunkwater/leetcode
/medium/python3/c0129_264_ugly-number-ii/00_leetcode_0129.py
722
3.703125
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #264. Ugly Number II #Write a program to find the n-th ugly number. #Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For examp...
efc19a5f67b3139e97c88d2fc065709b35c2a0dd
dkrft/handwriting_detection
/hwdetect/visualization/heat_map.py
10,989
4.09375
4
"""Module for visualizing predictions as heat maps. This module provides tools for creating and visualizing heat maps. The heat map of a given image is created by taking samples from the image, predicting the labels of the samples and assembling the predictions in the heat map. Example ------- Train a neuronal netw...
00b7227ebbe2421cf89dc93989f7872dd86d7dd8
psj8532/Data-Structure-Algorithm
/이진탐색트리-연습.py
2,400
3.875
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class BinarySearchTree(object): def __init__(self): self.root = None def set_root(self,data): self.root = Node(data) def insert(self,data): if self.root is None: ...
c01234c4864d1fe2547ca17f5e899c732244701f
br71/py_examples
/test_two_sum.py
842
3.5625
4
from two_sum import Solution import unittest.test.test_program class TestProgram(unittest.TestCase): def test_1(self): self.assertEqual(Solution().two_sum(([3,5,-4,8,11,1,-1,6],10), [-1, 11])) def test_2(self): self.assertEqual(Solution().two_sum([3,5,-4,8,11,1,-1,6,1,5,-9,-4,-6.6,8],19), [8...
a5f4d37c09fcbc4d531d666bec92b4623854ffae
br71/py_examples
/nth_fibonacci.py
765
3.765625
4
# Recursive solution # O(n^2) time | O(n) space def get_nth_fib1(n): if n == 2: return 1 elif n == 1: return 0 else: return get_nth_fib1(n - 1) + get_nth_fib1(n - 2) # Recursive solution with dictionary # O(n) time | O(n) space_ def get_nth_fib2(n, mem={1: 0, 2: 1}): if n in ...
f29ff93377a748c2ae98a9baa831a54a6b255dc6
michaelerule/NFCP_release
/Documentation/_auto/matrix/gaussian2DblurOperator.py
2,617
3.515625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- def gaussian2DblurOperator(n,sigma,truncate): r''' Returns a 2D Gaussan blur operator for a n x n sized domain Constructed as a tensor product of two 1d blurs of size n. See gaussian1DblurOperator for an example of how to perform a 2D Gaussian blur tha...
a21ef75e7a1ad5af81cada429876d9d06b317e17
Jose1697/crud-python
/16. OperacionesConListas.py
1,284
4.125
4
# + (suma) a = [1,2] b = [2,3] print(a+b) #[1,2,2,3] # * (multiplicacion) c = [5, 6] print(c*3) #[5, 6, 5, 6, 5, 6] #Añadir un elemento al final de la lista d = [3,5,7] d.append(9) print(d) #[3, 5, 7, 9] print(len(d)) #4 el tamaño de la lista #Para sacar el ultimo elemento de la lista, tambien se puede utilizar ...
c835af08321405e425335e4409235b2f40a82612
HasanKaval/Daily-Tasks
/Temp.py
2,627
3.5625
4
#first_list = [999, 333, 2, 8982, 12, 45, 77, 99, 11] #second_list = [] #count = 0 #loop_time = len(first_list) #while count < loop_time: #second_list.append(min(first_list)) #first_list.remove(min(first_list)) #count += 1 #print(second_list) #print() def order_lists_asc(temp_list): new_list = [] count = ...
80072b861678302c6cf149816dc7b313756d4c69
HasanKaval/Daily-Tasks
/Assignment - 5 (Front-Back Char).py
513
3.78125
4
#version 1 def front_back1(word) : if len(word) > 1 : words = list(word) words.insert(0, words.pop(len(words)-1)) words.insert((len(words)-1), words.pop(1)) word1 = "" return word1.join(words) else : return word print(front_back1('clarusway')) print(front_back1('...
136a2c572d6ffebfbaed190eb189d45c2cfa581e
Renderhaf/KakaKoin
/BlockchainHashed.py
6,420
3.75
4
''' #Instance Variablesm -- Later, these will be loaded through reading blockchain.txt #For now, this will start with 3 blocks in it -- in production, it will contain the entire blockchain blockchain = [{"To":3,"From":0,"Amount":1},{"To":5,"From":0,"Amount":5},{"To":5,"From":3,"Amount":0.15}] ''' import hashlib import ...
816ba90fdb38c071b86ad8f34f91afc8e6630fd8
LEE2020/leetcode
/coding_100/202_happynumber.py
1,890
3.984375
4
''' 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」定义为:对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和,然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变不到 1。如果 可以变为  1,那么这个数就是快乐数。 如果 n 是快乐数就返回 True ;不是,则返回 False 。   示例: 输入:19 输出:true 解释: 12 + 92 = 82 82 + 22 = 68 62 + 82 = 100 12 + 02 + 02 = 1 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/happy-number 著作权归领扣网...
c7511b55a3278156d057c7d0dc24a54317bd6fca
LEE2020/leetcode
/coding_jianzhibook/57_sumequals.py
1,143
3.75
4
''' 输入一个递增排序的数组和一个数字s,在数组中查找两个数,使得它们的和正好是s。如果有多对数字的和等于s,则输出任意一对即可。   示例 1: 输入:nums = [2,7,11,15], target = 9 输出:[2,7] 或者 [7,2] 示例 2: 输入:nums = [10,26,30,31,47,60], target = 40 输出:[10,30] 或者 [30,10]   two pointers low high 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/he-wei-sde-liang-ge-shu-zi-lcof 著作权归领...
5f9cb5c749dad8787e5cd7a67045616bbf065885
LEE2020/leetcode
/coding_100/16.26_calculator.py
3,941
3.8125
4
''' 给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。 表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格  。 整数除法仅保留整数部分。 示例 1: 输入: "3+2*2" 输出: 7 示例 2: 输入: " 3/2 " 输出: 1 示例 3: 输入: " 3+5 / 2 " 输出: 5 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/calculator-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ************************************...
f4f9ad4e9d72485eafe96eb528f4c164dc02efbf
LEE2020/leetcode
/coding_backtracing/46_permute.py
1,249
3.84375
4
'''' 给定一个 没有重复 数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/permutations 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution(object): def permute(self, nums): """ :type nums: List...
a8d73f6bb0ba9113ff6085622ebf7a6de7a0861f
LEE2020/leetcode
/coding_jianzhibook/64_1+2+...+n.py
716
3.640625
4
'''求 1+2+...+n ,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。   示例 1: 输入: n = 3 输出: 6 示例 2: 输入: n = 9 输出: 45 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/qiu-12n-lcof 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution(object): def sumNums(self, n): """ :type n: int ...
9dc27c25e37ecd32bcb5bb47d73f2e61fa92a75d
LEE2020/leetcode
/coding_100/300_lengthOfLIS.py
1,946
3.8125
4
''' 给你一个整数数组 nums ,找到其中最长严格递增子序列的长度。 子序列是由数组派生而来的序列,删除(或不删除)数组中的元素而不改变其余元素的顺序。例如,[3,6,2,7] 是数组 [0,3,1,6,2,2,7] 的子序列。   示例 1: 输入:nums = [10,9,2,5,3,7,101,18] 输出:4 解释:最长递增子序列是 [2,3,7,101],因此长度为 4 。 示例 2: 输入:nums = [0,1,0,3,2,3] 输出:4 示例 3: 输入:nums = [7,7,7,7,7,7,7] 输出:1 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/pro...
50d4980946d800354e5c7f61b2ca980e1fdc88a8
LEE2020/leetcode
/coding_100/1610_maxAliveYear.py
1,812
3.96875
4
''' 给定 N 个人的出生年份和死亡年份,第 i 个人的出生年份为 birth[i],死亡年份为 death[i],实现一个方法以计算生存人数最多的年份。 你可以假设所有人都出生于 1900 年至 2000 年(含 1900 和 2000 )之间。如果一个人在某一年的任意时期处于生存状态,那么他应该被纳入那一年的统计中。例如,生于 1908 年、死于 1909 年的人应当被列入 1908 年和 1909 年的计数。 如果有多个年份生存人数相同且均为最大值,输出其中最小的年份。   示例: 输入: birth = {1900, 1901, 1950} death = {1948, 1951, 2000} 输出: 1901 ...
d29c6fba1569748626cc5e5cb5cacd3ca44ced7a
LEE2020/leetcode
/coding_reversion/783_nodedistance.py
1,307
3.71875
4
''' 给定一个二叉搜索树的根节点 root,返回树中任意两节点的差的最小值。   示例: 输入: root = [4,2,6,1,3,null,null] 输出: 1 解释: 注意,root是树节点对象(TreeNode object),而不是数组。 给定的树 [4,2,6,1,3,null,null] 可表示为下图: 4 / \ 2 6 / \ 1 3 最小的差值是 1, 它是节点1和节点2的差值, 也是节点3和节点2的差值。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/prob...
ab30e8e66f9c5c70b6688770b821f85df5b1017c
LEE2020/leetcode
/coding_100/1669_mergeInBetween.py
1,889
4.625
5
''' 给你两个链表 list1 和 list2 ,它们包含的元素分别为 n 个和 m 个。 请你将 list1 中第 a 个节点到第 b 个节点删除,并将list2 接在被删除节点的位置。 下图中蓝色边和节点展示了操作后的结果: 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/merge-in-between-linked-lists 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 输入:list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002] 输出:[0,1,2,...
0be60f582a51462f809403a910d789dd3358416d
LEE2020/leetcode
/coding_100/0809_generateParenthesis.py
1,124
3.875
4
'''括号。设计一种算法,打印n对括号的所有合法的(例如,开闭一一对应)组合。 说明:解集不能包含重复的子集。 例如,给出 n = 3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/bracket-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution(object): def generateParenthesis(self, n): """...
2501c35e44be4af82b2d46b48d92125109bb245f
DevYam/Python
/filereading.py
967
4.125
4
f = open("divyam.txt", "rt") # open function will return a file pointer which is stored in f # mode can be rb == read in binary mode, rt == read in text mode # content = f.read(3) # Will read only 3 characters # content = content + "20" # content += "test" # content = f.read(3) # Will read next 3 characters...
e7ddc640319e91b422cbee450ecb6ce69c13f534
DevYam/Python
/lec10.py
1,270
4.375
4
# Dictionary is a data structure and is used to store key value pairs as it is done in real life dictionaries d1 = {} print(type(d1)) # class dict ==> Dictionary (key value pair) d2 = {"Divyam": "test", "test2": "testing", "tech": "guru", "dict": {"a": "dicta", "b": "dictb"}} print(d2) print(d2["Divyam"]) # Keys o...
a42e4fce2736ca3bcf39aa3076ade26519b55472
DevYam/Python
/lec16.py
393
4.5
4
# for loop in python list1 = ["Divyam", "Kumar", "Singh"] for item in list1: print(item) # Iterating through list of lists (Unpacking list of lists) list2 = [["divyam", 23], ["kumar", 36], ["singh", 33]] for item, weight in list2: print(item, weight) dict1 = dict(list2) print(dict1) for item in dict1: ...
2321f02a0fd6762e56c58da27bbfb37704f1d54e
DevYam/Python
/lec17.py
73
3.671875
4
# While loop in python i = 0 while i < 43: print(i) i = i + 1
ad2b2ca04ed556f89b1361a95baf3091a37bf3fa
VictorGamble/Day-3-Exercises
/dayOfTheWeek.py
340
4.0625
4
userInput = int(input("Please enter 0-6: ")) if userInput == 1: print("Monday") elif userInput == 2: print("Tuesday") elif userInput == 3: print("Wednesday") elif userInput == 4: print("Thursday") elif userInput == 5: print("Friday") elif userInput == 6: print("Saturday") elif userInput == 0: ...
23ce7c02114d2a0a5d7c6ede0b9206eb3b593c5c
Snipesengan/TicTacToe
/TicTacToe.py
1,799
3.78125
4
#Author: Nhan Dao #Date : Wed 20/06/18 #Description: import numbers import os gameBoard = [['1','2','3'], ['4','5','6'], ['7','8','9']] def printGameBoard(gameBoard): board = """ ? | ? | ? ---+---+--- ? | ? | ? ---+---+--- ...
5033c51ae268671390e26e24d2be1ab1393ba230
raiavincent/NHL-Analysis
/scrapeTestingSR.py
3,555
3.828125
4
# import needed libraries from urllib.request import urlopen from bs4 import BeautifulSoup import pandas as pd # create a function to scrape team performance for multiple years def scrape_NBA_team_data(years = [2017, 2018]): final_df = pd.DataFrame(columns = ["Year", "Team", "W", "L", ...
69c56249896e306fe80e40ce278505d5be077cc4
minwuh0811/DIT873-DAT346-Techniques-for-Large-Scale-Data
/Programming 1/Solution.py
928
4.25
4
# Scaffold for solution to DIT873 / DAT346, Programming task 1 def fib (limit) : # Given an input limit, calculate the Fibonacci series within [0,limit] # The first two numbers of the series are always equal to 1, # and each consecutive number returned is the sum of the last two numbers. # You should ...
6dbf182ee4624e998d86436c9123e497ba6343ab
Arshad221b/Python-Programming
/multipleinheritance.py
714
4.34375
4
# In python we can use mutiple inheritance class A: def __init__(self) -> None: super().__init__() self.mike = "Mike" self.name = "Class A" class B: def __init__(self) -> None: super().__init__() self.bob = "bob" self.name = "Class B" class C(A, B): #...
a209247fbdd81113253746e995e0f8eb03b7506c
PMKeene/SoftwareDesign
/SoftwareDesignExplore/Day04/inClass4.py
953
3.828125
4
# -*- coding: utf-8 -*- """ Spyder Editor This temporary script file is located here: /home/maire/.spyder2/.temp.py """ #from math import * # #def double(n): # return 2*n # #def mtsqrt(n): # return sqrt(n) def get_complementary_base(b): """Returns the complementary base nucleotide b: the base repre...
0669b924bcfb655484dd08c7b6020cd77f46ad12
Yutang-Liao/OpencvLearning
/DrawingFunction.py
723
3.734375
4
import numpy as np import cv2 #create a black image img = np.zeros((512,512,3), np.uint8) #arg1 = shape , arg2 = datatype img = cv2.rectangle(img,(384,0),(510,128),(0,255,0),5)#增加長方形 img = cv2.circle(img,(447,63),63,(255,0,0),-1)#arg2:圓心座標,arg3:圓心半徑,-1代表填滿整個circle ing = cv2.ellipse(img,(256,256),(100,50),0,0,180,25...
9f5a7efc4b4b371b69320010de8f0352a4eca44e
Spain2394/Computer_Graphics
/p4_3d_projection/scale_3d.py
1,083
3.6875
4
#!/usr/bin/env python3 import numpy as np import numpy as np import cv2 from math import * import colorsys from random import randint import sys def basicScale(Sx, Sy, Sz): """ Input: Sx and Sy floats are the horizontal and and vertical scaling factors; center of scale is at the orig...
ce366a047c0ed8b4003098f9aae02ae5cd906635
FredC94/MOOC-Python3
/Exercices/Mod2.5.3 Gateau.py
603
3.828125
4
"""Auteur: Thierry Massart Date : 5 décembre 2017 But du programme : calcule les ingrédients nécessaires pour préparer de la mousse au chocolat pour n personnes Entrée: n (nombre de personnes) Sorties: nombre d'oeufs, quantité en gramme de chocolat, nombre de sachets de sucre vani...
bbc3a3dcda2398a4fd2f57430d0cfc8dde4c6241
FredC94/MOOC-Python3
/Exercices/test5.py
144
3.6875
4
def bytes_to_int(bytes): result = 0 for b in bytes: result = result * 256 + int(b) return result print(bytes_to_int(256))
507a2ac5ce1e48a9692dd851c2aa5521b24f5691
FredC94/MOOC-Python3
/UpyLab/UpyLaB 5.05 - Manip tuples - Longueur points.py
1,531
4.0625
4
""" Auteur = Frédéric Castel Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire une fonction longueur(*points) qui reçoit en paramètres un nombre arbitraire de points (tuples de deux composantes), et retourne la longueur de la ligne brisée correspondante. Cette...
a509f3fa6ed91012ceb290f7f3e98d6acde69578
FredC94/MOOC-Python3
/UpyLab/UpyLaB 3.06 - Instructions conditionnelles.py
949
4.1875
4
""" Auteur: Frédéric Castel Date : Mars 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire un programme qui imprime la moyenne géométrique \sqrt{a.b} (la racine carrée du produit de a par b) de deux nombres positifs a et b de type float lus en entrée. Si au moins un de ces...
e2364ae84c7b2b34d2b9b588dcfdb7c7c8e72a60
FredC94/MOOC-Python3
/Exercices/Mod3.2.1 Pluie.py
251
3.9375
4
maximum = 10 releve = int(input()) if releve == 0: print("Pas de pluie aujourd'hui") elif releve > maximum : maximum = releve print("Nous avons un nouveau record") else: print("Pas de nouveau record") print("Maximum retenu :", maximum)
aa346e2b255bf3ac66d34d5bb0880a2a6cb6ade9
FredC94/MOOC-Python3
/Exercices/Mod5.1.5 Tempete ou Cyclone.py
1,121
3.703125
4
def historique_tempetes(vent_max): """affiche pour chaque année la catégorie de vents subis cette année-là entrée : vent_max: liste des vents maximums enregistrés en km/h chaque année (composante 0 étant pour l'an 2000)""" annee = 2000 for vent in vent_max: if vent < 64: print("En...
dd8ec5954a400f30b2af555dc79650c1712437c7
FredC94/MOOC-Python3
/Exercices/20200430 Sudoku Checker.py
1,672
4.15625
4
# Function to check if all the subsquares are valid. It will return: # -1 if a subsquare contains an invalid value # 0 if a subsquare contains repeated values # 1 if the subsquares are valid. def valid_subsquares(grid): for row in range(0, 9, 3): for col in range(0,9,3): temp = [] for r in ra...
016ce400f7ac98794f19ebecd01ef0608f175ec9
FredC94/MOOC-Python3
/UpyLab/UpyLaB 4.08 - Fonctions_Eq-Second-Degre.py
2,221
3.953125
4
""" Auteur = Frédéric Castel Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire une fonction rac_eq_2nd_deg(a, b, c) qui reçoit trois paramètres de type float correspondant aux trois coefficients de l’équation du second degré ax^2 + bx + c = 0, et qui renvoie la ou ...
7cee4c3d7df7f1adc67ef7482d0cf9aa3a0b1093
FredC94/MOOC-Python3
/UpyLab/UpyLaB 3.18 - Boucle For.py
1,959
4.375
4
""" Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire un programme qui lit un nombre entier strictement positif n et imprime une pyramide de chiffres de hauteur n (sur n lignes complètes, c'est-à-dire toutes terminées par une fin de ligne). La première ligne im...
b97c79695318d3e6ded18a4fa35edcaf5db213c7
FredC94/MOOC-Python3
/UpyLab/UpyLaB 5.16 - Compréhension Listes.py
1,195
3.984375
4
""" Auteur = Frédéric Castel Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire une fonction my_pow qui prend comme paramètres un nombre entier m et un nombre flottant b, et qui renvoie une liste contenant les m premières puissances de b, c’est-à-dire une liste cont...
309648078a0af5d8b9b6d9ec8bad22bb005f0f0d
FredC94/MOOC-Python3
/UpyLab/UpyLaB 6.06 - Ensembles et Dictionnaires.py
1,380
4.09375
4
""" Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire une fonction substitue(message, abréviation) qui renvoie une copie de la chaîne de caractères message dans laquelle les mots qui figurent parmi les clés du dictionnaire abréviation sont remplacés par leur significa...
4531ff5c78b5a15d08ccff5cb53ceb021bb09720
TecProg-20181/03--AmandaMuniz
/hang.py
5,364
3.6875
4
""" Codigo para jogo da forca. Refatorado por Amanda Muniz. """ import random import string import sys WORDLIST_FILENAME = "words.txt" class Word(): """ Essa classe lida com o arquivo de palavras e escolhe a palavra. """ def __init__(self): self.wordlist = "" self.infile = "" s...
ab0a08ab5761fe113c7db4b3209ef523450ea0f2
BDANG/google_study_guide
/graphs/traversal/Dijkstra.py
1,548
3.640625
4
import sys import heapq def simplify_parent_list(parent, start, end): new = [] current = end while current != -1: new.append(current) current = parent[current] return list(reversed(new)) def path(graph, start, end=None): return path_and_value(graph, start, end)[0] def value(gra...
d64e77f8e883a21968646156b246d595798475c5
AndresReyesRangel/Ejercicios
/AreaHelado.py
225
3.625
4
#Autor: Andrés Reyes Rangel #Calcular el área de un helado (vista lateral) radio = int(input("Ingrese el radio: ")) altura = int(input("Ingrese la altura: ")) area= (3.141592*radio**2)/ 2 + radio*altura print ("Área= ", area)
b441d9cbcccdfa77932e707e4e9c4490cb0e4c78
Shyonokaze/mysql.py
/mysql.py
2,656
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 7 12:41:02 2018 @author: pyh """ ''' This class is for creating database and table easier by using pymysql ''' import pymysql class mysql_data: def __init__(self,user_name,password): self.conn=pymysql.connect(host='127.0.0.1', ...
780b70ec524383bd6894bf35fe659d28144ea0d7
Panchaljimi/Mywork
/Ass5_4.py
361
3.890625
4
def fun_my(filename): with open(filename,'r')as file: words=file.read().split() max_len=len(max(words,key=len)) return [word for word in words if len(word)==max_len] print(fun_my('new.txt')) #text file with the code as Below: #Hi, #how r u? #i am really very good. #...
9146f5b30fe6a6c47b8dd50fe4a7981974c4d52f
Panchaljimi/Mywork
/Ass1_2.py
187
3.734375
4
print("IN VERSION 3") x=input("Enter the name or num") print(x) print(type(x)) print("After type casting") b=int(input("Enter the item u want to print:")) print(b) print(type(b))
d43ed57424ca2c2f516ec0ac212d4dd00f8870aa
carlosfabioa/TDS_exercicios_logica_programacao
/3-Lacos de repeticao/Enquanto/exercicio8.py
392
4.09375
4
''' Escreva um programa que apresente a série de Fibonacci até o décimo quinto termo. A série de Fibonacci é formada pela sequência: 1, 1, 2, 3, 5, 8, 13, 21, 34...etc. Esta série se caracteriza pela soma de um termo posterior com o seu anterior subsequente ''' anterior = 0 seguinte = 1 for i in range(15): anter...
da19cbd3fc74f37575386ea27867e09584e4f460
carlosfabioa/TDS_exercicios_logica_programacao
/2-Tomadas de decisao/exercicio1.py
549
4.09375
4
''' Efetuar a leitura de três valores (variáveis A, B e C) e apresentar os valores dispostos em ordem crescente ''' a = int(input('Entre com o primeiro número: ')) b = int(input('Entre com o segundo número: ')) c = int(input('Entre com o terceiro número: ')) if a < b and b < c: print(a, b, c) elif a < b and b > ...
62eb7a775f5d75af407ea7dba1ea4266dab00b89
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/05exercicio.py
1,052
4.125
4
''' e. Ler duas matrizes do tipo vetor A com 20 elementos e B com 30 elementos. Construir uma matriz C, sendo esta a junção das duas outras matrizes. Desta forma, C deverá ter a capacidade de armazenar 50 elementos. Apresentar os elementos da matriz C em ordem decrescente. ''' TAMANHO_A = 20 TAMANHO_B = 30 a = []...
7fe0d3a00eb4d208cc68115f43c0aa15dc21e386
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/04exercicio.py
1,502
4.28125
4
''' d. Ler uma matriz A com 12 elementos. Após a sua leitura, colocar os seus elementos em ordem crescente. Depois ler uma matriz B também com 12 elementos. Colocar os elementos de B em ordem crescente. Construir uma matriz C, onde cada elemento de C é a soma do elemento correspondente de A com B. Colocar em orde...
342e208d29d4ab099b5efc8c79fff7f53b16dd5d
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/07exercicio.py
942
4.15625
4
''' g. Ler 20 elementos de uma matriz A tipo vetor e construir uma matriz B da mesma dimensão com os mesmos elementos de A acrescentados de mais 2. Colocar os elementos da matriz B em ordem crescente. Montar uma rotina de pesquisa, para pesquisar os elementos armazenados na matriz B. ''' TAMANHO = 20 a =[]; b=[] #...
cf3677073665c94a11809faca79b5ea7fb2ff809
carlosfabioa/TDS_exercicios_logica_programacao
/4- Matriz de uma dimensao - vetor/exercicio5.py
550
3.984375
4
''' Ler duas matrizes A e B do tipo vetor com 15 elementos cada. Construir uma matriz C, sendo esta a junção da duas outras matrizes. Desta forma, C deverá ter o dobro de elementos, ou seja, 30. ''' LINHAS = 15 a =[]; b = []; c = [] #Vetor A print('Vetor A') for i in range(LINHAS): n = int(input('Entre com um ...
834ad44c9751f166c21ec8c327eb3edd949851e2
carlosfabioa/TDS_exercicios_logica_programacao
/1-Estrutura Sequencial/exercicio9.py
498
3.953125
4
''' Uma loja de animais precisa de um programa para calcular os custos de criação de coelhos. O custo é calculado com a fórmula CUSTO = (NR_COELHOS * 0.70) /18 + 10. O programa deve ler um valor para a variável NR_COELHOS e apresentar o valor da variável CUSTO ''' ### ENTRADA ### nr_coelhos = int(input('Entre com o ...
ff020a0140712db78f1c430b68c80c976de9f9d7
kausic-eunimart/June-month-progress
/June/oops_python/singleton.py
480
3.515625
4
class Admin: instance = None def __init__(self): if Admin.instance is None: Admin.instance = self else: raise Exception("Only once created an object you can go with that instance") @staticmethod def get_instance(): if Admin.instance is None: A...
c48d04c5d3f9d0a0085b84697c17f3160704b02b
glennga/sql-process
/lib/parallel.py
3,487
3.609375
4
# coding=utf-8 """ Contains functions to run tasks in parallel, be it through threads or processes. Usage: Parallel.execute_n(iterable, operation, argument_constructor) Parallel.execute_nm(outer_iterable, inner_iterable, operation, argument_constructor) Parallel.spawn_process(operation, argument_list) ...
9089b6a05aae608673c871aa2c641b46af796c8f
jolenewai/flask-questions-blank
/08-crud/data.py
2,911
3.71875
4
import csv def read_books(): fp = open('books.csv', 'r', newline='\n') reader = csv.reader(fp, delimiter=",") next(reader) database = [] for each_book in reader: book = { each_book[1]:{ "isbn": each_book[0], "author": each_book[2], ...
5176ec617c8d661bfcec01520b5403e0516bb0ed
ianpavlovic/Number-Guessing-Game
/guessing_game.py
1,285
3.921875
4
import random import sys SOLUTION = random.randint(1,10) def intro(): print("--------------------------------------") print("Hello, Welcome to Number Guessing Game") print("--------------------------------------\n") def game(): try: tries = 1 number_chosen = int(input("Please pick a n...
b1f23f5ed1d91a70cf0b6da8ab49bc3b762f1113
sohannaik7/python-fun-logic-programs-
/mean_median_and_standard_div_using_python.py
902
3.75
4
import statistics as stat import random def calculate(lists): for i in range(1,n): lists.append(random.randint(1,r)) meanlist=stat.mean(lists) medList=stat.median(lists) stddev=stat.stdev(lists,meanlist) return meanlist, medList, stddev if __name__ == '__main__': li...
cc97ce85e52b9f22abf08dfe72af60e7fc9308ec
rriol97/Redes
/RedesII/practica1/code/www/scripts/saludo.py
800
3.5
4
############################################################################ # saludo.py # # Script que recibe un nombre y responde con la cadena "Hola <nombre>!" # # Autores : Ricardo Riol Gonzalez y Alejandro Sanchez Sanz ############################################################################ #!/usr/bin/python...
061b1f29b6c5bc4f2717b07a554e3dd5eac13dab
metehankurucu/data-structures-and-algorithms
/Algorithms/Sorting/BubbleSort/BubbleSort.py
399
4.21875
4
def bubbleSort(arr): n = len(arr) for i in range(n): swapped = False #Every iteration, last i items sorted for j in range(n-i-1): if(arr[j] > arr[j+1]): swapped = True arr[j], arr[j+1] = arr[j+1],arr[j] # One loop without swapping mean...
12dfd56fc4e96316e73f0037deed54c9912eb309
yhhu2049/learn_git
/map&reduce.py
1,081
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 8 09:33:02 2018 @author: hyh """ def add(a,b,f = abs): return f(a)+f(b) c=add(1,2) print(c) def f(x): return x**2 #list1 = [1,2,3,4] #r = map(f,list1) list2 = list(map(f,[1,2,3,4])) list3 = list(map(str,[1,2,3,4])) from functools import reduce def fn (x,y): ...
0cc009d2fc515be2739f5ca9d80461e1566ebade
yhhu2049/learn_git
/test_module.py
1,412
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 10 11:42:39 2018 @author: hyh """ ' a test module ' __author__ = 'Michael Liao' import sys def test(): args = sys.argv if len(args)==1: print('Hello, world!') elif len(args)==2: print('Hello, %s!' % args[1]) else: print('Too man...
a8aadf7b9b7dd7cf8c3bf376ef281343bc0b5381
P-dot/Python-scripts
/while_loop.py
116
3.5625
4
#!/usr/bin/python x = 0 while x < 100: print x x = x+1 print "x is now more than 100"
bd55fe02ec962b8ff67f65fdb4eb4e32109c9d9d
codeuncoded/python4jntuk
/Basics.py
8,483
4.0625
4
#Exercise 2a import math x1 = int(raw_input("enter x1:")) y1 = int(raw_input("enter y1:")) x2 = int(raw_input("enter x2:")) y2 = int(raw_input("enter y2:")) distance = math.sqrt(math.pow(x2-x1, 2) + math.pow(y2-y1, 2)) print distance #Exercise 2b from sys import argv script, first, second = argv print float(first) + f...
345bdd07f0eb6d7ccfafb7f252c012921bba9242
talpallikar/cashbag
/bags.py
3,051
3.640625
4
#bags.py import random import os #Constants BAGNUM = 14 #Number of bags CASHVAL = 1 #The value of cash in each bag. This is not that important. HISTORY = [] class Bag: #Bags have an identifying number. They can be empty or full of cash. bagCount = 0 totalCash = 0 def __init__(self, num, cash, ): ...
b64d0e6ace4494c1ca1310766c3ddfa9bee95f89
NihasAhamed/nihhhh
/factorial.py
80
3.5625
4
import math a=int(input("Enter the factorial number")) print(math.factorial(c))
ff92df3a718cd90a0fb7ec9c458ec8ca1b71e44e
Govindchaudhary/FunWithDataStructures
/queue/queue.py
515
3.9375
4
class queue(object): def __init__(self): self.items = [] def isEmpty(self): return self.items==[] def enqueue(self,item): self.items.insert(0,item) #insert at begining def dequeue(self): self.items.pop() # removal from end def size(self): return len(self.i...
cb299fb24c4768436db2404a26e58e6b02c86757
sebiba/ia
/venv/test2.1/grille.py
1,292
3.53125
4
import balle class Grille: size = 0 step = 0 default = "0" tab = [] def __init__(self, size, step): self.size = size self.step = step def createTab(self, caractere): self.default = caractere tab = [] m = 0 while m < (self.size/self.step)**2: ...
3c9a725ba0c782893e169d1fbecc66d572d38f3a
febwinter/skinfoNote
/python/day2/ex_find.py
227
4.09375
4
s = 'Life is too short, You need Python' print(s.find('short')) print() s = 'Eighty percent of $ucce$$ is Showing up.' s = s.replace('$', 's') print(s) print() s = 'Life is too short, You need Python' print(s.split()) print()
b6940f7168dfdea5713ec979dab30c5a77d993b9
NayeemH/Data-Structure-python
/Sorting Algorithms/Merge-Sort/MergeSort.py
1,193
4.375
4
def mergeSort(arr): if len(arr)>1: # Finding the mid of the array mid = len(arr)//2 # Dividing the array elements left_array = arr[:mid] right_array = arr[mid:] # Sorting the first half mergeSort(left_array) # Sorting the second half merge...
fdc1e38708d2d91acaad06ea6cb73545921f6305
jonathan-pasco-arnone/ICS3U-Unit5-02-Python
/triangle_area.py
1,075
4.15625
4
#!/usr/bin/env python3 # Created by: Jonathan Pasco-Arnone # Created on: December 2020 # This program calculates the area of a triangle def area_of_triangle(base, height): # calculate area area = base * height / 2 print("The area is {}cm²".format(area)) def main(): # This function calls gets input...
793a7c5025d4cda3d7242fc732dee6d3c28b3ec1
drransom/challenges
/euler_problems/euler43.py
1,509
3.65625
4
import sys def is_pandigital(n): string_arr = list(str(n)) string_arr.sort() return string_arr == ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] def pandigital_property_sum(): sum = 0 num = int(10 ** 9) while num < (10 ** 10): if (num == int(10 ** 9)): print "number is ...
cf338d4020ca159eb2605e82a54a4d0b75b0b84e
zelahi/Algorithms
/data_structures/trie.py
1,671
4.0625
4
class Node: def __init__(self): self.child = {} self.isEnd = False class Trie: def __init__(self): """ Initialize your data structure here. """ self.root = Node() def insert(self, word: str) -> None: """ Inserts a word into the trie. ...
32a7acb3d2d77e31c343d09d2f1b1d60d289d77f
asurendrababu/nehprocpy
/alphabetRangoli.py
714
4.15625
4
# You are given an integer, . Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.) # # Different sizes of alphabet rangoli are shown below: # # #size 3 # # ----c---- # --c-b-c-- # c-b-a-b-c # --c-b-c-- # ----c---- import string alphaArr = list(strin...
1d6d2793eee85f0ddfe0fcd98500ec53e42e91cb
asurendrababu/nehprocpy
/pilingUp.py
534
3.84375
4
# https://www.hackerrank.com/challenges/piling-up/problem # Output Format # # For each test case, output a single line containing either "Yes" or "No" without the quotes. # # Sample Input # # 2 # 6 # 4 3 2 1 3 4 # 3 # 1 3 2 # Sample Output # # Yes # No for x in range(int(input())): mi = int(input()) ml = list(...
94d20e0ba9f163623b28e8ff06830f4f2db53c58
asurendrababu/nehprocpy
/teaching.py
2,151
4
4
# age = int(input("What is your age: ")) # if age < 12: # print("I am a kid ") # elif age < 18: # print("I am a teenager ") # else: # print("I am an adult ") # # thisDict = { # "name ": "Aakash ", # "place ": "Roundrock ", # "Birth ": 2009 # # } # print(thisDict) # # myList = [9, 5, 9, 2, 7] # m...
c7565d0119fc1eefab42a6793942f5fb4f0521f8
puneetchopra16/Functions
/assignmen6.py
746
3.671875
4
#question1 def areaOfSphere(radius): area=4/3 * 3.14 * (radius**2) return area a=int(input ()) area=areaOfSphere(5) print(area) #question 2 def perfect(number): sum=0 for i in range(1,number): if number%i is 0: sum=sum+i if sum == number: return n...
ddb014aee3e92cffab6f52ae78bd3d300e0ffecd
JianFengY/collections_overview
/chapter7/ordereddict_demo.py
776
3.90625
4
""" Created on 2018/3/29 @Author: Jeff Yang """ from collections import OrderedDict user_dict = OrderedDict() # user_dict = dict() # Python3中dict默认也是有序的,Python2中是无序的 user_dict["b"] = "Jack" user_dict["a"] = "Bob" user_dict["c"] = "Tom" print(user_dict) print("========") user_dict = OrderedDict() user_dict["b"] = "J...
4e770058545d72fd2836bef8231510bf4194441f
makism/dyconnmap
/examples/python_mp.py
832
3.5625
4
import multiprocessing as mp import random import string # Define an output queue output = mp.Queue() # define a example function def rand_string(length, output): """ Generates a random string of numbers, lower- and uppercase chars. """ rand_str = ''.join(random.choice( string.ascii_lowe...
96726067253cfccb433d234ed27bdc26a9986e59
sabina2/DEMO4
/Armstrong number.py
208
4.03125
4
num = int(input("Enter our number")) num1 = num arms_num = 0 while num>0: arms_num = arms_num+(num%10) ** 3 num=num//10 if arms_num==num1: print("Armstrong") else: print("Not Armstrong")
2afd56c7025d58b3bb2eed03f1a5f692a117657e
radhika98/112TermProject
/helper.py
1,970
3.625
4
class Button(object): #Near-universal button class. #got template from https://github.com/blob/master/HelperWidgets.py def __init__(self, topleft, bottomright, text, color, outline, function, data, size=" 30"): self.text = text self.bg = color self.outline = outline self.callback = ...
4d691205a4bb3a1438093d9a425ed33b88396d13
artemiev86/polochka
/contr_2.py
2,463
3.5625
4
# C_1 = (35, 78, 21, 37, 2, 98, 6, 100, 231) # C_2 = (45, 21, 124, 76, 5, 23, 91, 234) # if sum(C_1) > sum(C_2): # print("сумма больше в кортеже", C_1) # elif sum(C_1) == sum(C_2): # print("сумма чисел кортежа равна") # else: # print("сумма больше в кортеже", C_2) # print(C_1.index(min(C_1)), C_1.index(ma...
c302d38cc435710e8ca764d4fb3af6c296abfcf8
y0sh12/GatorHoldEmCP
/card.py
557
3.640625
4
class Card: _suits = ("Heart", "Diamond", "Club", "Spade") _ranks = (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) # 14 - Ace, 11 - Jack, 12 - Queen, 13 - King def __init__(self, suit, rank): if suit in self._suits: self._suit = suit if rank in self._ranks: self._...
a80210552c4810d0b9d7a1b710934aaddda73b9d
lindagrz/python_course_2021
/day5_classwork.py
2,850
4.46875
4
# 1. Confusion T # he user enters a name. You print user name in reverse (should begin with capital letter) then extra # text: ",a thorough mess is it not ", then the first name of the user name then "?" Example: Enter: Valdis -> # Output: Sidlav, a thorough mess is it not V? # # # 2. Almost Hangman # Write a program t...
4c077ff2f02c72a61209c17dba91ca99c6fe4513
lindagrz/python_course_2021
/day6_classwork.py
3,672
4.375
4
# 1a. Average value # Write a program that prompts the user to enter numbers (float). # The program shows the average value of all entered numbers after each entry. # PS. 1a can do without a list def average_value_1a(): i = 0 total = 0 while True: user_input = input("Input a number or 'q' to quit:...
2717e48d9b71550775cf44959a90fd39a8ef6985
muhammadzaki693/Chat
/main.py
990
3.84375
4
def chat(): while (True): #var UserInput = "" ChatBot_Name = "zaki" ChatBot_Name_Error = "console" UserInput = str.lower(input("guest: ")) import pyfiglet textascii = pyfiglet.figlet_format("test") #say quit if UserInput == "quit" or UserInput == "end": print(ChatBot_Name + ": ...
d380d968f5c036924eafbd86de293d43249d7725
blancoek/tarea3
/BilleteraElectronica.py
1,133
3.734375
4
class BilleteraElectronica: def __init__(self, identificador, nombres, apellidos, CI, PIN): self.identificador=identificador self.nombres=nombres self.apellidos=apellidos self.CI=CI self.PIN=PIN self.recargas=[] self.consumos=[] self.balance...
1c5397e784a5e3eda117768dd50f181041dec370
metalcyanide/Star-Hopping
/Hop_sequence.py
3,689
3.84375
4
import math import pandas as pd class Point(): def __init__(self, x, y): self.x = x self.y = y def distance(a,b): x_term = int(a.x) - int(b.x) y_term = int(a.y) - int(b.y) return math.sqrt((x_term * x_term) + (y_term * y_term)) # this function will return the value of the nearest #...
fea4105e59c94663279ab28a71defdc51c763fae
Rotem-Lev-Lehman/TomatosProject
/photos_organization/folders_organizer.py
3,207
3.671875
4
import os from distutils.dir_util import copy_tree from PIL import Image, ImageTk import matplotlib.pyplot as plt import matplotlib.image as mpimg import tkinter as tk ''' def change_pic(path): root.photo = ImageTk.PhotoImage(Image.open(path)) vlabel.configure(image=root.photo) print("updated") ''' def s...
2b7a758e15f6cd2be76e6cf416a07860663da96b
emilybee3/deployed_whiteboarding
/pig_latin.py
1,611
4.3125
4
# Write a function to turn a phrase into Pig Latin. # Your function will be given a phrase (of one or more space-separated words). #There will be no punctuation in it. You should turn this into the same phrase in Pig Latin. # Rules # If the word begins with a consonant (not a, e, i, o, u), #move first letter to end...
24c5e989129d7fd29d2a85ea32ea9bf16fecd959
chibitofu/Coding-Challenges
/apple_and_orange.py
862
3.609375
4
## s - t range of house ## a = apple tree location, b = orange tree location ## apples = array of apple locations ## oranges = array of orange locations ## Determine how many apples and oranges fall on the house def countApplesAndOranges(s, t, a, b, apples, oranges): total_apples = 0 total_oranges = 0 max_...
a046b9c5aa3fff8ccc7eaafdb10bd3e7991c2a63
vignesh1204/wikipedia-search
/wikipedia.py
1,031
3.84375
4
import sys import datetime ''' In cli mode, run python3 wikipedia.py <search-term> <log-file-name> for example, python3 wikipedia.py "india" "log2.txt" In interactive mode, run python3 wikipedia.py ''' def wikipedia_search(keyword, file_name): keyword = keyword.replace(' ', '%20') url = "https://en.wikipedia...
55a100f8658a25e2003a382f91c430f993c11a21
findango/Experiments
/linkedlist.py
1,407
4.21875
4
#!/usr/bin/env python import sys class Node: def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return "[Node value=" + str(self.value) + "]" class SortedList: def __init__(self): self.head = None def insert(self, valu...
114b973cb74a21446c5e1248c0fd4d7bfaa18c2e
Bhavyapatel96/Download_Xbrl_for_Ciks
/download_xbrl_for_ciks.py
5,037
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 25 17:19:53 2018 @author: bhavy @README: Download cik files for particular year, from the list of CIKS given in an Excel file. This program basically downloads zipfile for given cik and year. This program must be executed before you try to run "download_xbrl_tag_d...