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
65726d7357262b9a0971c797b728a070ad705d2c
nandans-summer-camp/learning-python-dictionaries
/exercises.py
3,670
4.4375
4
# # INSTRUCTIONS: # For this exercise we will work with a # "scoreboard" for an imaginary game. # You will be required to write functions # that operate on the "scoreboard" data # structure and compute certain results. ###################################### # TUPLES # # For these functions, the "scoreboard" # will b...
4da64b57effc5861e3a413860846887174d9a213
PeterWaIIace/ManyPythonsCodes
/codes/matrixproduct.py
821
3.703125
4
import random length = 8 height = 8 def createMatrix(Nmatrix): for l in range(length): tmp = [] for h in range(height): value = random.randint(0,8) tmp.append(value) Nmatrix.append(tmp) def product(Amatrix,Bmatrix): C = [] for l in range(length): ...
9a4d20f8f74ae8e6d9bd75d72eb9bca20f113cfd
ItachiUchiha001/New-REP
/xyz.py
427
3.609375
4
class car: def cardet(self): self.cnumber=int(input("Car No.? ")) self.ccompany=input("Company: ") self.cmodel=input("Model: ") self.cprice=int(input("Price: ")) def showcardet(self): print(self.cnumber) print(self.ccompany) print(self.cmodel) prin...
48158bb02ce53869bf1fa39bfaac262edc5c93d1
radubogdan/cn-joc
/main.py
2,443
3.953125
4
""" Desciption: CLI version of Mastermind with numbers Name: main.py Purpose: Having fun with numbers Author: Radu-Bogdan Croitoru Version: 2 """ from random import randint def hasUniqueDigits(testString): ''' testString: string, number compounded by pseudo number generator return: integer, the number fro...
7162dfd563cf865d3a84071b7293684c89a8f95c
francosion042/Dice-game-with-Python
/two_player_dice_1.py
1,819
4.0625
4
from random import randint from time import sleep def play(): player_one_scores = 0 player_two_scores = 0 for i in range(3): print("Player 1 it's your turn.") userOneInput = input( " Do you want to roll [Y/N]: ") if userOneInput == "y": valueOne = randin...
9f81839b47239ffad79c676773efd9b99342431c
eli0lson/AdventOfCode2020
/programs/day6-1.py
746
3.65625
4
def countAns(group): unique = set(()) for item in group: for letter in item: unique.add(letter) return len(unique) if __name__ == '__main__': total = 0 answers = [] with open("../input/day6.txt", 'r') as f: group = [] line = f.readline() while line: ...
ccabb271f4bef7679ced6d05953ca11c7b831cbf
eli0lson/AdventOfCode2020
/programs/day9.py
1,534
3.6875
4
preamble = 25 def find_invalid(numbers): global preamble num_ind = preamble while num_ind < len(numbers): valid = False i = num_ind - preamble while not valid and i < num_ind - 1: while (i < num_ind - 1): j = i + 1 while (j < num_ind): ...
b9885696dace072f4aee7d55b1f89a3cedd95050
nihilus/ida-decompiler
/src/filters/simplify_expressions.py
10,633
3.734375
4
""" This module runs an expression through a series of filters. When a filter matches, a new expression is created from the old one and returned to the caller, which should call again until all filters are exhausted and no simpler expression can be generated. """ from expressions import * __all__ = [] def simplifie...
3fc81e93dfaa43d6cf82e271c993bc860f4bb011
shr945/Marchine-Learning-Study
/softmax2.py
1,807
3.546875
4
# coding=utf-8 import numpy as np import pandas as pd import math import matplotlib.pyplot as plt #有本地数据 def softmax(x): return np.exp(x)/np.sum(np.exp(x)) #数据提取 def load(): x= pd.read_csv("thyroid.txt",header=-1,usecols=[i for i in range(21)]) y= pd.read_csv("thyroid.txt",header=-1,usecols = [21]) ...
36e69fd7ca89153f4a65b22b4fefbc703d2e123d
Harika19/GUVI-CODEKATA
/repeatedsorting.py
216
3.59375
4
#repeat sorting n=int(input()) a=list(map(int,input().split())) b=[] c=[] for x in a: if x not in b: b.append(x) else: c.append(x) d=set(c) c=list(d) c.sort() for i in c: print(i,end=' ')
417a3f9dd68d41b6a8153ed0b05112d33709d3a9
Harika19/GUVI-CODEKATA
/permutation.py
121
3.5
4
from itertools import permutations s=input() f=[] l=[] per=permutations(s) for x in list (per): print(''.join(x))
832439c69ddbcbeb4b2ad961e7427b760306fb92
Th0rt/LeetCode
/how-many-numbers-are-smaller-than-the-current-number.py
999
4.125
4
# https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ import unittest from typing import List class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: length = len(nums) temp = sorted(nums) mapping = {} for i in range(lengt...
44ca47a59793c871728e860c75fb93b89f457101
iaveiga/PythonCodeMatrix
/Week1/hw0/hw0.py
1,203
3.703125
4
# Please fill out this stencil and submit using the provided submission script. ## Problem 1 def myFilter(L, num): M = [x for x in L if x % 2 == 0] return M ## Problem 2 def myLists(L): result = [] for x in L: for i in range( ## Problem 3 def myFunctionComposition(f, g): gof = ...
934a2bbd2e2d7708bb4683cd419a3a6b1b8d1192
LucaZugic/leetcode-solutions
/median_2sorted_arr.py
362
3.53125
4
# Median of two sorted arrays class Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: nums = nums1 + nums2 nums.sort() x = len(nums) if x % 2 ==0: median = (nums[int(x/2-1)] + nums[int(x/2)])/2 else: median = nums...
9f0d9d5ee1f94937f54a70330e70f5c3b5dc0358
JoeD1991/Quantum
/Joe_Problem_1.py
361
4.3125
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ myList = set() N5 = 1000//5 N3 = 1000//3+1 for i in range(1,N3): myList.add(3*i) if i<N5: myList.a...
52eb87a9ba7571077a5d09edd83ecf2ec98b2874
guptavedansh2002/university-assignments-2nd-Year
/PythonProjects/function.py
751
4.03125
4
"""a = int(input()) b = int(input()) c = int(input())""" """def str(): '''Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,''' return a+b print(str.__doc__) print(str())""" """def operation(): return a +...
cf8e083ee0fda4cadb91e998c183def6e5dec532
guptavedansh2002/university-assignments-2nd-Year
/PythonProjects/Assignment 3 Group A.py
747
4
4
name = input("Enter your name : ") roll = input("Enter your Roll Number : ") div = input("Enter your Division : ") print("All marks enter below should be OUT OF 100") eng = float(input("Enter your English Marks : ")) phy = float(input("Enter your Physics Marks : ")) chem = float(input("Enter your Chemistry Marks : ")) ...
e473c1ec03f607bb9779ae8259307bcffd1db39f
guptavedansh2002/university-assignments-2nd-Year
/PythonProjects/Identify prime and composite.py
156
3.765625
4
n = int(input("Enter a number : ")) lstp = [] for i in range(1, n): if n % i != 0: ele = i lstp.append(ele) print(lstp) print()
d62ae247f21539ad85edf46615a1348a78f6989e
NGPHAN310707/C4TB13
/session 8/appendfrominput.py
114
3.578125
4
Menu = ['Hamburger','Pizza','pot roast'] Anything = input('What do you want? ') Menu.append(Anything) print(Menu)
53684088e0af3d314c602a4c58439b76faf161cb
NGPHAN310707/C4TB13
/season6/validpasswordstourheart.py
212
4.125
4
while True: txt = input("Enter your password?") print(txt) if txt.isalpha() or len(txt)<=8 or txt.isdigit: print(txt,"is a name") break else: print("please don't")
fa0b360164023bf9e4fc3f58130945560a765d75
NGPHAN310707/C4TB13
/session 8/listappend.py
113
3.875
4
Menu = ['pasta','salad','burger'] additionaldish = input('which dish? ') Menu.append(additionaldish) print(Menu)
f8fd8a2726d931128bf9b2fe9c7d60a2785855a4
NGPHAN310707/C4TB13
/turtle1.py
239
3.5625
4
import turtle turtle.circle(100) for i in range (10): turtle.right(36) turtle.forward(100) for i in range (20): turtle.right(18) turtle.forward(50) for i in range (720): turtle.right(0.5) turtle.forward(2)
c628775bdac5d99a8431c2cfc0b6b6de27143dac
Masterprogrammers123/Fam-Website
/Sockets/server.py
1,350
3.5625
4
def main_program(): import socket import threading # Will change most of the ADDR stuff HEADER = 64 PORT = 5050 SERVER = socket.gethostname() ADDR = (SERVER, PORT) FORMAT = "utf-8" DISCONNECT_MESSAGE = "!EXIT" server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server...
8a7f16c5e921c9eb775dd2c03e4f721d3b6280c7
pradeep1412/Coursera-Algorithmic-Toolbox
/week3_greedy_algorithms/largestno.py
452
3.6875
4
# python3 n = int(input()) lst = list(map(int, input().split())) lst.sort(reverse=True) def largestnumber(lst): answer = [] while lst != []: max_digit = 0 for digit in lst: if int(str(digit)+str(max_digit)) >= int(str(max_digit)+str(digit)): max_digit = digit ...
91543d5c9c56785590c16bdd6afe9bbdf12b5c8c
pradeep1412/Coursera-Algorithmic-Toolbox
/week3_greedy_algorithms/prize.py
291
3.609375
4
nth = int(input()) if nth <= 1: print(nth) print(nth) quit() w = nth maxprize = [] for i in range(1,nth): if w > 2*i: maxprize.append(i) w -= i else: maxprize.append(w) break print(len(maxprize)) print(' '.join([str(i) for i in maxprize]))
b3ef756b473db77bd92391d151aa0349cf254245
ctxrr/learnPython
/StaticMethod.py
469
3.78125
4
"""This module is about the usage of Static method in python You can get more help from:http://stackoverflow.com/questions/735975/static-methods-in-python """ class Foo(): # use staticmethod as a decorator @staticmethod def thestaticmethod(x): print x # use staticmethod as a function if you...
cc345a1c366f1c18c17cdc85f10b283f806e4d20
ctxrr/learnPython
/MultInheritance.py
457
3.65625
4
class A: def funa(self): print 'this is class a' class B: def funb(self): print 'this is class b' def funa(self): print 'this is class bb' class C1(B,A): def func(self): print 'this is class c' class C2(A,B): def func(self): print 'this is class c' if __nam...
144a61b43eab0992d60e4b0e8146734ed53347d0
JitinKansal/My-DS-code
/tree_imlementation.py
1,048
4.1875
4
# Creating a new node for the binary tree. class BinaryTree(): def __init__(self, data): self.data = data self.left = None self.right = None # Inorder traversal of the tree (using recurssion.) def inorder(root): if root: inorder(root.left) print(root.data,...
99d376480cbe618d51854ffb7cda6a86c8e8fe56
EmlynQuan/Programming-Python
/InterviewQ/02_05.py
1,341
3.703125
4
# coding=utf-8 class ListNode(object): def __init__(self, x, next=None): self.val = x self.next = next def addTwoNumbers(l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ head = ListNode(0) curNode,preNode = head, head ca = 0 if l1 == None...
afa3a795235de4dca3147fdac9bae1bd398d2acd
EmlynQuan/Programming-Python
/Leetcode/leetcode36.py
1,897
3.6875
4
#coding=utf-8 def isValidSudoku(board): # 判断行是否有重复数字 for i in range(9): flag = [False for _ in range(9)] for j in range(9): if board[i][j] == '.': continue else: idx = int(board[i][j])-1 if flag[idx] == True: ...
8553902f8ce07b891f5c26ff052047c8390e96a4
EmlynQuan/Programming-Python
/InterviewQ/17_13.py
743
3.671875
4
!!!! def respace(dictionary, sentence): length = len(sentence) i = 0 ret = [] while i < length: j = i while j < length: print sentence[i:j + 1] if sentence[i:j+1] in dictionary: ret.append(sentence[i:j+1]) i = j bre...
97297964d4a3c5df311aada2afa624997e6b3f1a
EmlynQuan/Programming-Python
/Leetcode/leetcode230.py
866
3.765625
4
# coding=utf-8 class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def kthSmallest(root, k): ''' 给定一个二叉搜索树的根节点 root ,和一个整数 k ,请你设计一个算法查找其中第 k 个最小元素(从 1 开始计数)。 ''' arr = [] midOrder(root, arr, k) return...
cf974647f0d2334ca24aa49e5fd7dfd22aa72b5d
EmlynQuan/Programming-Python
/Leetcode/leetcode289.py
1,469
3.53125
4
# coding=utf-8 def gameOfLife(board): n = len(board) m = len(board[0]) flag = [] # 遍历每个位置 for i in range(n): for j in range(m): # print str(i) + ", " + str(j) # 四种规则 # 如果活细胞周围八个位置的活细胞数少于两个,则该位置活细胞死亡; # 如果活细胞周围八个位置有两个或三个活细胞,则该位置活细胞仍然存活; ...
d4b3d937b6a0ed20343d4443f2e1e4d8ffcb9941
EmlynQuan/Programming-Python
/EfficientInterview/15.py
865
3.609375
4
# coding=utf-8 def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ # 存储结果 ret = [] n = len(nums) if n < 3: return ret # 首先对数组进行排序 nums.sort() # 如果第一个元素都大于0 if nums[0] > 0: return ret for one in range(0, n - 2): if ...
91a32c1738364283503a35022bd54ac50f77ea3f
EmlynQuan/Programming-Python
/Leetcode/leetcode781.py
493
3.53125
4
# coding=utf-8 def calRabbitNum(arr): ''' 计算森林里有多少只兔子 ''' # 记录所有的数 myDict = {} for i in range(len(arr)): if arr[i] in myDict.keys(): myDict[arr[i]] += 1 else: myDict[arr[i]] = 1 sum = 0 # 遍历字典 for key in myDict.keys(): counter = myDic...
9f5d28089410015ae47afd57261bd184801aa376
EmlynQuan/Programming-Python
/JZOffer/JZOffer31.py
1,628
3.796875
4
# coding=utf-8 class Solution(object): def validateStackSequences(self, pushed, popped): """ :type pushed: List[int] :type popped: List[int] :rtype: bool """ if len(pushed) == len(popped): stack = [] i = 0 while i < len(popped): ...
e408c0cb6eebb6a2a8bad79020c3d9e840a3a975
EmlynQuan/Programming-Python
/Leetcode/leetcode1190.py
632
3.5
4
# coding=utf-8 def reverseParentheses(s): """ :type s: str :rtype: str """ myStack = [] pos = 0 while pos < len(s): # 不是右括号就入栈 if s[pos] != ")": myStack.append(s[pos]) pos += 1 # 遇到右括号就出栈 elif s[pos] == ")": temp = [] ...
c256d239363139c03eb847df394370fe679ed2d4
EmlynQuan/Programming-Python
/Leetcode/leetcode105.py
2,015
3.65625
4
# coding=utf-8 class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTree(preorder, inorder): ''' 通过给定的前序和中序遍历构建二叉树 ''' if len(preorder) > 0: # 根节点 root = TreeNode(val=preorder[0]) ...
94361197031b258c1e384748f358e25526d48106
limwonki0619/Python-algorithm-training
/알고리즘 연습/Baekjoon/단계별로 풀어보기_Part1/11365_!밀비 급일.py
110
3.78125
4
for _ in range(5): sc = input() if 'END' in sc: print('') else: print(sc[::-1])
5871e29896d3df6e8752fdfbca977454fb17ddf4
limwonki0619/Python-algorithm-training
/알고리즘 연습/Baekjoon/단계별로 풀어보기_Part1/10809_알파벳 찾기.py
164
3.953125
4
s = input() for i in range(26): alphabet = chr(i+ord('a')) if alphabet in s: print(s.find(alphabet), end=' ') else: print(-1, end=' ')
d5af9814ffe0a878ef6c7651a912d8ddc6b2bf2b
pundriks3103/Customer-Segmentation-using-Clustering
/Visualize_using_Kmeans1.py
769
3.6875
4
# Visualising the Clusters plt.scatter(X[y_kmeans == 0, 0], X[y_kmeans == 0, 1], s = 100, c = 'red', label = 'Cluster 1') plt.scatter(X[y_kmeans == 1, 0], X[y_kmeans == 1, 1], s = 100, c = 'blue', label = 'Cluster 2') plt.scatter(X[y_kmeans == 2, 0], X[y_kmeans == 2, 1], s = 100, c = 'green', label = 'Cluster 3') ...
f624c9d60353f0d77d96e42d107be2257ca5e007
cogpark/100daysrep
/3-APIs/SessExplore/csv_to_json.py
482
3.640625
4
import csv import json def converter(file): with open(file) as csvfile: reader=csv.DictReader(csvfile, fieldnames=("sessionID","Page","Hit Timestamp", "Unique Pageviews","nodeID")) out = json.dumps([row for row in reader]) print("File converted") new_file_name = input("Save ...
be4af81f42222bb4cb60937d036fc6f91b6fea67
a421101046/-python
/ex45.py
1,024
4.5
4
# -- coding: utf-8 -- # 习题 45: 对象、类、以及从属关系 # 针对类和对象 "is_a" 讨论两个类的共同点 “has_a”指 两个类无共同点,仅仅供互相参照 # is_a class Animal(object): pass class Dog(Animal): def __init_(self, name): # has_a self.name = name # is_a class Cat(Animal): def __init__(self, name): # has_a self.name = name # is_a class Person(obje...
559758bbe21a907e414f482cc05b7740e4f9c7ff
a421101046/-python
/ex6.py
483
3.65625
4
# -- coding: utf-8 -- x = "这里有 %d 类型的人." % 10 binary = "binary" do_not = "don't" y = "Those who know %s and those who %s. " %(binary , do_not) print x print y print "I said: %s. " % x # 为什么这里使用 %r print "I said: %r. " % x print "I also said: '%s'. " % y hilarious = False joke_evaluation = "Isn't that...
ad6b67267fd448694b28c6a020a7efbf7aa1639e
a421101046/-python
/ex18.py
698
3.609375
4
# -- coding: utf-8 -- # 命名 变量 代码 函数 # 函数可以给代码的片段命名,并可以接受参数,可以通过#1 和 #2 可以让你创建微型的脚本 def print_two(*args): # def 函数名(*args): 之后 缩进的四行都是函数的内容 arg1,arg2 = args # 解参数包 print "arg1: %r,arg2: %r " % (arg1,arg2) def print_two_again(arg1,arg2): print "arg1: %r,arg2: %r " % (arg1,arg2) # 只带一个参数 def print_one(arg1 ) ...
1331b1a4afddc6ec606032e9ef1d24bfd30e316f
caladdd/NumericalMethods
/segundocap/incremental.py
1,041
4
4
import math def incremental(f, x0, delta, ite): fx0 = f(x0) if(fx0 == 0): print(str(x0)+" es raiz") else: x1 = x0 + delta cont = 1 fx1 = f(x1) while((fx0*fx1 > 0) and (cont < ite)): x0 = x1 fx0 = fx1 x1 = x0 + delta fx1...
9cec2351b63ccc8e54d9f12446ebacb6fbe72987
hofmanng/algoritmos-faccat
/prog094.py
648
3.984375
4
# # Melhore o exercicio 93 para aceitar somente valor maior ou igual a # zero para o numero lido e tambem para testar se o numero for igual a # zero. O fatorial de zero e 1(0!=1). # # Declaracao das variaveis e entrada de dados n = int(input("Insira um valor: ")) mlt = 1 # Testes condicionais e loop if n >= 0: if...
d87789a3e29232912112f8c5a33052e55e63245a
hofmanng/algoritmos-faccat
/prog106.py
445
3.84375
4
# # Faca um programa que leia 10 valores positivos e, no final, # escreva o maior valor lido. # # Observacao: Considere que todos os valores lidos serao positivos. # # Processamento for num in range(1, 10 + 1): #Entrada de dados valor = int(input("Insira um valor: ")) # Teste condicional if num == 1:...
bca39491428e13ed031e2092a48e27627497b540
hofmanng/algoritmos-faccat
/prog099.py
371
3.8125
4
# # Ler 10 valores, calcular e escrever a media aritmetica desses # valores lidos. # # Declaracao das variaveis soma = 0 cont = 0 # Processamento for num in range(1, 11): # Entrada de dados valor = int(input("Insira um valor: ")) soma = soma + valor cont = cont + 1 # Saida de dados print "O media ...
6bff5c895d76eb95817c4e5bc7d2cefc8a312cd4
hofmanng/algoritmos-faccat
/prog087.py
382
4
4
# # Escreva um algoritmo para ler 3 numeros e escrever a soma # total dos 3 numeros lidos (usando a estrutura de repeticao # for). # # Declaracao das variaveis ac_num = 0 # Processamento for n in range(1, 3 + 1): # Entrada de dados num = int(input("Insira um valor: ")) # Acumulador ac_num = ac_num + n...
b3d8a7a1b10c55d21b4b43177ad7a63f2736d4a6
drvinceknight/Nashpy
/docs/_static/learning/fictitious_play/divergent_example/main.py
844
3.546875
4
""" Code to draw plot for the documentation. This plots a divergent fictitious play example. The code should match the reference code in the documentation. """ import matplotlib.pyplot as plt import numpy as np import nashpy as nash A = np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]) B = np.array([[0, 0, 1], [1, 0, 0],...
b9e8e6335884fec02df051487d5ab989bd627afb
tom3108/Python-basic-exercises.
/pop.py
105
3.578125
4
list = ["ManCity","Barca","Real","PSG"] while len(list) > 0: a = list.pop() print(a) print(list)
bfde0123cf689e3fa395a8702283a65b966a0a0f
tom3108/Python-basic-exercises.
/Kodolamacz again/Kodolamacz 2 ver2.py
1,090
3.890625
4
parametr= True while parametr: print("Podaj w oddzielnych wierszach liczbę, operację matematyczną: +,-,*,/,%, a następnie kolejną liczbę:") liczba1 = float(input("Wprowadź pierwszą liczbę:")) operacja = input("Wprowadź operację:") liczba2 = float(input("Wprowadź drugą liczbę:")) if operacja == "+"...
87ac0f6f2976acbc2f092bf55130983b312b8abe
diplodocuslongus/Pyllusion
/pyllusion/Contrast/Contrast.py
6,827
3.59375
4
from .contrast_image import _contrast_image from .contrast_parameters import _contrast_parameters from .contrast_psychopy import _contrast_psychopy class Contrast: """ A class to generate the Simultaneous Contrast illusion. Simultaneous contrast, identified by Michel Eugène Chevreul, refers to the ma...
281c003ca32c0ecc2fd448759507bd605847d9c0
Organi/karanprojects
/palindrome.py
359
4.09375
4
word = raw_input() length = len(word) start = word[0:length/2] if length % 2 == 0: end = word[length/2:length] else: end = word[length/2+1:length] isPalendrome = True for i in range(0,len(start)): if start[i] != end[len(end)-(i+1)]: isPalendrome = False break if isPalendrome: print word+" is a palendrome" el...
c6fc2b5d41444e994fa1bc0e95c7e318341ff9a9
aviator737x/SD
/CLI/Commands/pwd1.py
216
3.5625
4
"""This module contains a method for pwd command""" import os def pwd(*args): """Returns current directory""" if len(args): print("pwd command takes no args") else: return os.getcwd()
91e65bb918bafdc9feb8ddb3880c03b8747bd737
anuviswan/UtilScripts
/mp3-sort.py
1,344
3.734375
4
# Intends to sort and group Mp3 files in given folder to nested folders. from eyed3 import id3 import os import sys import shutil import re # read command line arg : Folder Name arg = sys.argv[1] # Get Album/Artist Name for given mp3 def GetAlbumName(filename): tag = id3.Tag() tag.parse(filename) albumName = tag._...
9db3fdc694f2b8c9efa7b255e84a6cd14a571c3e
chamin96/Python4Everybody
/15-searching-through-a-file.py
489
3.984375
4
fname = input('Enter file name: ') try: fhand = open(fname) except: print('Error! File cannot be opened.') quit() # print lines starting with specific word for line in fhand: line = line.rstrip() if line.startswith('From:'): print(line) # count lines lines starting with specific word # ...
6ccfeb619becc5afa5a9aee360fffbe7fc5710b1
stompingBubble/SchoolStuff
/PythonClasses/person.py
506
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 16 09:59:26 2017 @author: Isa """ class Person(object): def __init__(self, name, address): self._name = name self._address = address def getName(self): return self._name def getAddress(self): return self._address ...
c3d57a7d2a940092af6923ce85e4210bc32ee40d
TheWinczi/AI_Job_Change_Prediction
/classification/k_nearest_neighbors.py
2,353
3.5625
4
import numpy as np from sklearn.neighbors import KNeighborsClassifier from sklearn.model_selection import GridSearchCV from sklearn.metrics import accuracy_score def k_nearest_neighbors(X_train: np.ndarray, y_train: np.ndarray, X_test: np.ndarray = None, y_test: np.ndarray = None): """ ...
5322a58baca276a72fb47ee385d28552f4b6bc32
RenataRochaAlves/jogodeadvinhacao
/adivinhacao.py
473
3.90625
4
print("********************************") print("Bem vindo ao jogo de adivinhação") print("********************************") numero_secreto = 42 # input sempre devolve str / a função int() converte chute = int(input("Digite o seu número: ")) print("Você digitou", chute) # não usa {} e sim :, precisa estar indentad...
fcf73436c41d032043467a6f6643ddf15a71624f
mattshakespeare/pythonPractise
/Password.py
2,213
3.671875
4
import csv def get_data(): file = list(csv.reader(open("Passwords.csv"))) tmp = [] for x in file: tmp.append(x) def create_user_id(tmp): name_again = True while name_again == True: user_id = input("Enter a new user ID: ") in_list = False row = 0 if tmp != No...
dd8b0a917448e07836ef4cf24ca37c41987fc6ab
mattshakespeare/pythonPractise
/sql.py
6,722
4.125
4
import sqlite3 #with sqlite3.connect("Phonebook.db") as db: #cursor = db.cursor() #cursor.execute(""" CREATE TABLE IF NOT EXISTS Names( #id interger PRIMARY KEY, #firstname text, #surname text, #phonenumber, text); """) #cursor.execute(""" INSERT INTO Names(id, firstname, surname, phonenumber) #VALUES("1", "Simon...
506e0046656a85560b3b8706a3722b3f442a2b72
Mrseeyou/python
/爬虫/案例/v26.py
202
3.578125
4
import re pattern = re.compile(r'\d+') s = pattern.findall("I am 18 years odl end 175 high") print(s) s = pattern.finditer("I am 18 years odl and 175 high") print(s) for i in s: print(i.group())
d222b44e2c9b9d1d883b57aa607538bb9457e879
darsovit/pyRayTracerChallenge
/renderer/bolts.py
4,320
3.6875
4
#! python # from math import isclose, sqrt EPSILON = 0.00001 def equality(float1, float2): return EPSILON > abs(float1 - float2) class Tuple: def __init__(self, x, y, z, w): self.val = (x, y, z, w) def isPoint(self): return equality( self.val[3], 1.0 ) def isVector(self): re...
e7d4e862daec81d7cb178b5114cdc76befc7a16b
yangrencong/pythonstudy
/2.0/order.py
318
3.609375
4
order_prompt = "请输入pizza的配料" order_prompt += "(输入quit退出) : \t" order_message = " " while order_message != "quit": order_message=input(order_prompt) if order_message != 'quit': print("我们将会在菜单中加入 "+order_message+"\n") else: print("谢谢你的光临")
a86faffeaa78d370c35e8e5de86b456070728526
yangrencong/pythonstudy
/3.0/pet.py
153
3.8125
4
pets=['pig','dog','cat'] for pet in pets: print("A "+pet.title()+" would make a great pet") print('Any of these animals would make a great pet!')
4b6e6e0c460c8a3bd09e60009cac823ab52fed4b
yangrencong/pythonstudy
/3.0/copy.py
389
4.125
4
My_foods =['pizza','falafel','carrot','cake'] Friend_foods =My_foods[:] My_foods.append('cannoli') Friend_foods.append('ice cream') print('my favorate foods are:') print(My_foods) print("\nmy friend's favorate food are: ") print(Friend_foods) print('the first three items in list are:') food1=My_foods[0:3] print(food...
22a77e249da7d9bd1b8521ffeed6b36802e6986c
yangrencong/pythonstudy
/text/test.py
593
3.5625
4
import unittest from name_function import get_formatted_name class NameTestCase(unittest.TestCase): """测试name_function.py""" def test_first_last_name(self): """能够正确的处理Jains Joplin这样的姓名吗?""" formatted_name = get_formatted_name("jains","joplin") self.assertEqual(formatted_name ,"Jains Jo...
d3b35ffe669547fdb25633b621beee0dd53a812b
michaelrbock/codeeval
/moderate/sum_of_integers.py
603
3.75
4
""" Write a program to determine the largest sum of contiguous integers in a list. """ import sys # read in from file input = open(sys.argv[1], 'r') lists = [] for line in input: lists.append([int(x) for x in line.strip().split(',')]) input.close() def max_subarray(arr): max_ending_here = max_so_far = 0 ...
6c88876f9783ad0e6c0f3c06ef3f04e92d58b565
michaelrbock/codeeval
/easy/lowercase.py
214
3.828125
4
""" Given a string write a program to convert it into lowercase. """ import sys # read in from file input = open(sys.argv[1], 'r') lines = [] for line in input: sys.stdout.write(line.lower()) input.close()
604eb3f05c80fcc77b566499a5413c32ffd7168c
deepakSrinivas29/External_sort_of_large_file
/merge_sort_file/split_file.py
1,717
3.59375
4
# lines_per_page : max_lines set for small files into which large_file gets divided def file_splitter(large_file, lines_per_page): """ :param large_file: File to be sorted :param lines_per_page: Max number of lines in your file chunk :return: Names of small files """ my_files = []...
067f00f064a187aaabc7989a2977bdb5c5d841d3
Jailtons7/conversor
/api/integrations/awesomeapi.py
1,025
3.671875
4
import requests class AwesomeApi: """ This class implements the integration with Awesome API """ HEADERS = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0'} URL = 'https://economia.awesomeapi.com.br/json/last/%s-%s' def __init__(self, from_currency...
67279fc5c82d63ac1a210e5e37ee21bf7780723c
RamachandiranVijayalakshmi/Concatenate-two-lists-in-the-following-order
/Conconate.py
119
3.609375
4
list1 = ["Hello ", "take "] list2 = ["Dear", "Sir"] resList = [x+y for x in list1 for y in list2] print(resList)
b373091e1937edf88b9318877215fa79bdc1401e
vellascogabriel/Data_Science_and_Machine_Learning_Exercises
/Social_Network_Ads - Decision Tree Classification/arvore_de_decisao_classificacao.py
2,718
3.578125
4
# Decision Tree Classification # Importing Libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt #Reading the Data set dataset = pd.read_csv('Social_Network_Ads.csv') # Independant variables and Dependant Variables X = dataset.iloc[:, [2, 3]].values Y = dataset.iloc[:, 4:5].values # Trainni...
319e6c28faae5e87360f88ac06fa4b092701ba93
Shreesha-28/105-c104
/median.py
731
3.640625
4
import csv with open('Height-Weight.csv',newline='')as f: reader=csv.reader(f) file_data=list(reader) #to pop the titles out of the list file_data.pop(0) #sorting data to get the height of the ppl which is in first position new_data=[] for i in range(len(file_data)): n_num=file_data[i][1] ...
bbbdade184e874b5db861b7c1eae2988c0d2f733
adace123/Python
/time.py
879
3.90625
4
import time class Time: def __init__(self): self.__hour = int(((time.time() // 60) // 60) % 24) self.__minute = int((time.time() // 60) % 60) self.__second = int(time.time() % 60) def getHour(self): return str(format(self.__hour,"2d")) def getMinute(self): return s...
94636f8509b91207fe817cb21ee17486e2a49e89
markwy1/py
/more_lambda.py
471
3.8125
4
# demo from A Byte of Python # markwy # points = [{'x': 2, 'y': 3}, {'x': 4, 'y': 1}, {'x': 6, 'y': 2}] points.sort(key=lambda a: a['y'], reverse = True) print(points) student_tuples = [ ('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)] # last item is not followed comma, is ok print(student_tupl...
54774f70ec3135f750fe91a5613ccce89e76ecab
TomLisankie/TensorFlow-Examples
/Intro/the_basics.py
707
3.6875
4
import tensorflow as tf # Create computation graph x = tf.Variable(3, name = "x") y = tf.Variable(4, name = "y") f = x*x*y + y + 2 # Create session, initialize variables, and run session on variable `f` sess = tf.Session() sess.run(x.initializer) sess.run(y.initializer) result = sess.run(f) print(result) sess.close(...
b0f8304637fdd3ed3677e204a496f081693974bd
ebolten/Rock-Paper-Scissors-Python
/RockPaperScissorsPython.py
1,992
3.546875
4
#Rock, Paper, Scissors Game! import sys from PyQt5.QtWidgets import * from random import randint gameArr = ['rock','paper','scissors'] application = QApplication([]) rock = QPushButton('Rock') paper = QPushButton('Paper') scissors = QPushButton('Scissors') window = QWidget() layout = QVBoxLayout() window.setWindo...
1acd23df2704a2f4b9a71f76a805302e6f3c3bbf
hoangkiet1906/python-Core
/array.py
213
3.703125
4
import array arr = array.array('i',[1,2,3]) #from array import* #arr = array('i',[1,2,3]) print(arr) arr.append(4) print(arr) arr.insert(2,5) print(arr) arr.pop(2) print(arr) arr.remove(3) print(arr)
2d4e61723c86ed1a21ce6bb36a93bbe770abf079
hamsini505/learning
/multiples.py
202
3.515625
4
#sum = 0 #sum1 = 0 #for i in range(1,1000): # if(i % 3 == 0 or i % 5 == 0): # sum = sum + i #print(sum) limit = 1000 li = (set(range(3,limit,3)) | set(range(5,limit,5))) print(sum(li))
c8c8a84040b5caa471bb2ea60f8456b0aa984dc2
FernandoSVasconcelos/GerenciaGastos
/Programa/gerenciadorComp.py
3,357
3.734375
4
import os class Contas: def __init__(self): self.ano = input("Ano: ") self.mes = input("Mês: ") self.net = float(input("Internet(99.9): ")) self.condo = float(input("Condomínio(322.6): ")) self.aluguel = float(input("Aluguel(1120.92): ")) self.luz = float(input("Luz: ...
27c12375aecf536a348b13e2986a5f7ae2e9667b
alinafaluta/Proiecte
/Fundamentele Programarii/Numere/Interfata/Afisare.py
5,264
3.765625
4
def Meniu_Initial(): """ afiseaza principalele comenzi necesare la initializarea aplicatiei :return: comanda aleasa de utilizator """ print("\n1.Inserați o listă de numere complexe reprezentate prin partea lor reală și partea lor imaginară") print("0.Inchideți aplicația") comanda=in...
1f48c47f0e5f0cb4fc01b9c22d453f4079d80a96
alinafaluta/Proiecte
/Fundamentele Programarii/Avioane/Domain/Flight.py
870
3.78125
4
from enum import Enum class Flight_type(Enum): ARRIVAL = 1 DEPARTURE = 2 class Flight: def __init__(self,flight_number,type,company_name,city): self.__flight = flight_number self.__type = Flight_type[type] self.__enum = type self.__company = company_name self.__city...
90addd2424560b2f814239e740934bfa1af670d3
alinafaluta/Proiecte
/Fundamentele Programarii/Numere/Domeniu/Verificare.py
8,098
3.796875
4
from Domeniu.Complex import * def VerificareComenziUI2(comanda): ''' verifica daca valoarea introdusa de utilizator este una dintre comenzi ''' if comanda not in {'0', '1', '2', '3', '4', '5', '6','7','8','9','10','11','12','13','14','15','16','17'}: while True: try: ...
b9650237e364ca89d8eea19a13e2baffca0fc3d9
zengln/leetcode_pj
/其他/多数元素.py
1,051
3.828125
4
# -*- coding:utf-8 -*- # @Time : 2021/7/30 16:43 # @Author : zengln # @File : 多数元素.py # 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊ n/2 ⌋ 的元素。 # # 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 # # # # 示例 1: # # # 输入:[3,2,3] # 输出:3 # # 示例 2: # # # 输入:[2,2,1,1,1,2,2] # 输出:2 # # # # # 进阶: # # # 尝试设计时间复杂度为 O(n)、空间复杂度为 O(1) 的算法...
eb5ae2f12d7d454bb1762446b4c7973df240d12c
zengln/leetcode_pj
/数组/一维数组的动态和.py
969
3.796875
4
# -*- coding:utf-8 -*- # @Time : 2021/8/28 15:59 # @Author : zengln # @File : 一维数组的动态和.py # 给你一个数组 nums 。数组「动态和」的计算公式为:runningSum[i] = sum(nums[0]…nums[i]) 。 # # 请返回 nums 的动态和。 # # # # 示例 1: # # 输入:nums = [1,2,3,4] # 输出:[1,3,6,10] # 解释:动态和计算过程为 [1, 1+2, 1+2+3, 1+2+3+4] 。 # # 示例 2: # # 输入:nums = [1,1,1,1,1] # 输出:...
a73a3474c5dcb5c07969bf950e2bdc584fdcb954
zengln/leetcode_pj
/双指针/有序数组的平方.py
1,828
3.8125
4
# -*- coding:utf-8 -*- # @Time : 2021/8/23 10:29 # @Author : zengln # @File : 有序数组的平方.py # 给你一个按 非递减顺序 排序的整数数组 nums,返回 每个数字的平方 组成的新数组,要求也按 非递减顺序 排序。 # # # # # # # 示例 1: # # # 输入:nums = [-4,-1,0,3,10] # 输出:[0,1,9,16,100] # 解释:平方后,数组变为 [16,1,0,9,100] # 排序后,数组变为 [0,1,9,16,100] # # 示例 2: # # # 输入:nums = [-7,-3,2,...
b6ef5af1e28c21f510b2bba50ca7cb47d8380bdf
zengln/leetcode_pj
/动态规划/翻转数位.py
1,217
3.734375
4
# -*- coding:utf-8 -*- # @Time : 2021/7/30 9:16 # @Author : zengln # @File : 翻转数位.py # 给定一个32位整数 num,你可以将一个数位从0变为1。请编写一个程序,找出你能够获得的最长的一串1的长度。 # # 示例 1: # # 输入: num = 1775(110111011112) # 输出: 8 # # # 示例 2: # # 输入: num = 7(01112) # 输出: 4 # # Related Topics 位运算 动态规划 class Solution: def reverseBits(self, ...
a8b69b1f6b0ce6ec6bdc71a9025d517c700841ab
zengln/leetcode_pj
/动态规划/丑数 II.py
1,951
3.765625
4
# -*- coding:utf-8 -*- # @Time : 2021/8/9 8:39 # @Author : zengln # @File : 丑数 II.py # 给你一个整数 n ,请你找出并返回第 n 个 丑数 。 # # 丑数 就是只包含质因数 2、3 和/或 5 的正整数。 # # # # 示例 1: # # # 输入:n = 10 # 输出:12 # 解释:[1, 2, 3, 4, 5, 6, 8, 9, 10, 12] 是由前 10 个丑数组成的序列。 # # # 示例 2: # # # 输入:n = 1 # 输出:1 # 解释:1 通常被视为丑数。 # # # # # 提示: # # ...
90ed7d6a60baea3f573224ec3054a11c320327ba
zengln/leetcode_pj
/数组/只出现一次的数字.py
1,096
3.828125
4
# -*- coding:utf-8 -*- # @Time : 2021/7/27 15:37 # @Author : zengln # @File : 只出现一次的数字.py # 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。 # # 说明: # # 你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗? # # 示例 1: # # 输入: [2,2,1] # 输出: 1 # # # 示例 2: # # 输入: [4,1,2,1,2] # 输出: 4 # Related Topics 位运算 数组 class Solution:...
4c31cf8ead9453250a9509a612facd48a9b5fd21
zengln/leetcode_pj
/双指针/三数之和.py
3,102
3.828125
4
# -*- coding:utf-8 -*- # @Time : 2021/9/8 13:40 # @Author : zengln # @File : 三数之和.py # 给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重 # 复的三元组。 # # 注意:答案中不可以包含重复的三元组。 # # # # 示例 1: # # # 输入:nums = [-1,0,1,2,-1,-4] # 输出:[[-1,-1,2],[-1,0,1]] # # # 示例 2: # # # 输入:nums = [] # 输出:[]...
a885bdc488b2d2e9459f8ef65c22cdb4afe163fa
zengln/leetcode_pj
/二分查找/搜索二维矩阵.py
1,676
3.828125
4
# -*- coding:utf-8 -*- # @Time : 2021/9/6 19:36 # @Author : zengln # @File : 搜索二维矩阵.py # 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性: # # # 每行中的整数从左到右按升序排列。 # 每行的第一个整数大于前一行的最后一个整数。 # # # # # 示例 1: # # # 输入:matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3 # 输出:true # # # 示例 2: # # # 输入:matrix = [[...
7037234cac4bc876342ad39334420d6d92d5b208
zengln/leetcode_pj
/其他/回文数.py
1,309
3.8125
4
# 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 # # 示例 1: # # 输入: 121 # 输出: true # # # 示例 2: # # 输入: -121 # 输出: false # 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 # # # 示例 3: # # 输入: 10 # 输出: false # 解释: 从右向左读, 为 01 。因此它不是一个回文数。 # # # 进阶: # # 你能不将整数转为字符串来解决这个问题吗? class Solution: def isPalindrome(self,...
20a64ebd303f373f06e16d3cee4803e834c88b56
zengln/leetcode_pj
/栈/基本计算器II.py
5,178
3.578125
4
# 实现一个基本的计算器来计算一个简单的字符串表达式的值。 # # 字符串表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格 。 整数除法仅保留整数部分。 # # 示例 1: # # 输入: "3+2*2" # 输出: 7 # # # 示例 2: # # 输入: " 3/2 " # 输出: 1 # # 示例 3: # # 输入: " 3+5 / 2 " # 输出: 5 # # # 说明: # # # 你可以假设所给定的表达式都是有效的。 # 请不要使用内置的库函数 eval。 # ''' 解题思路: 题目中给出,仅包含非负整数,+, - ,*,/ 四种运算符和空格 。 整数除法仅保留整数部分 1. ...
46a05a7f88330e96fe762882468639b05074ef93
zengln/leetcode_pj
/其他/二进制求和.py
1,522
3.53125
4
# -*- coding:utf-8 -*- # @Time : 2020/7/2 8:39 # @Author : zengln # @File : 二进制求和.py ''' 给你两个二进制字符串,返回它们的和(用二进制表示)。 输入为 非空 字符串且只包含数字 1 和 0。 示例一 输入: a = "11", b = "1" 输出: "100" 示例二 输入: a = "1010", b = "1011" 输出: "10101" ''' def addBinary1(a:str, b:str) -> str: # return str(bin((int(a, 2) + int(b, 2))))[...
d151ebb9efd44437e4cdcdde396d33e1b790f409
zengln/leetcode_pj
/深度优先&广度优先/地图分析.py
1,982
3.90625
4
# -*- coding:utf-8 -*- # @Time : 2021/8/30 16:30 # @Author : zengln # @File : 地图分析.py # 你现在手里有一份大小为 N x N 的 网格 grid,上面的每个 单元格 都用 0 和 1 标记好了。其中 0 代表海洋,1 代表陆地,请你找出一个海洋单 # 元格,这个海洋单元格到离它最近的陆地单元格的距离是最大的。 # # 我们这里说的距离是「曼哈顿距离」( Manhattan Distance):(x0, y0) 和 (x1, y1) 这两个单元格之间的距离是 |x0 - # x1| + |y0 - y1| 。 # # 如果网格上只...
8b53a8e6bd2257f1836e77192432f3cfec4d028a
zengln/leetcode_pj
/二分查找/在排序数组中查找元素的第一个和最后一个位置.py
3,075
3.625
4
# -*- coding:utf-8 -*- # @Time : 2021/1/19 11:38 # @Author : zengln # @File : 在排序数组中查找元素的第一个和最后一个位置.py # 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 # # 如果数组中不存在目标值 target,返回 [-1, -1]。 # # 进阶: # # # 你可以设计并实现时间复杂度为 O(log n) 的算法解决此问题吗? # # # # # 示例 1: # # # 输入:nums = [5,7,7,8,8,10], target = 8 #...
93906782abd9aeb5276bfa54c79aa065a415e739
Andrew-Hillman/Area-Calculator
/number guessing game funny.py
334
3.9375
4
import random name = input("Hello there!, please enter your name.: ") print(f'Hello, {name}!: ') n1 = int(input('Alright, pick a number..: ')) random = random.randint(1, 100) if n1 > random : print('you win! \o/') elif n1 < random : print('https://www.youtube.com/watch?v=2ZIpFytCSVc') else : print('T...