blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
818b175d73e30bdb9ea881060e5bdbcad876ae90
chinnagit/python
/iterator.py
648
3.859375
4
class Iterator: def __init__(self, list): self.list = list # __index will be treated as private variable of class self.__index = 0 def haxnext(self): if self.__index < len(list): return True else: return False def next(self): value =...
e59ad19d126050d7eac15d5fcf8f816d11cef1ee
serinamarie/CS-Hash-Tables-Sprint
/applications/crack_caesar/crack_caesar.py
2,324
3.765625
4
# Use frequency analysis to find the key to ciphertext.txt, and then # decode it. # Unable to solve this one at the moment :/ def crack(filename): # open file with open(filename, 'r') as f: # set string text to variable string = f.read() # create an empty dict letter_dict = {} ...
333e25d8cb6d3650af7e4a3b39b583c8f00254b5
wargile/learning
/Python/ami_summer_camp/qsort/qsort.py
789
3.734375
4
import random def qsort(s): tn = random.randint(0, len(s) -1) temp = s[tn] #print(temp,'\n',s) l = 0 r = len(s) - 1 a = 0 b = len(s) -1 #print(s) while l <= r : while s[l] > temp: l += 1 while s[r] < temp: r -= 1 ...
719c9346cec043c67df51d96c2088f1f274e5ea2
sqq0216/testLearn
/pythonLearn/program/common/sort.py
929
3.5625
4
# 快速排序 时间复杂度为O(n)或O(n^2)平均时间复杂度为O(nlogn) 空间复杂度O(logn)/O(n) import random def qsort(l): if len(l) < 2: return l else: base = l[0] left = [ele for ele in l[1:] if ele < base] right = [ele for ele in l[1:] if ele > base] return qsort(left) + [base] + qsor...
33f7622211dd858d9606d55c02e3547bc89fabfd
galidor/PythonTutorialsSourceCode
/Exercise15.py
293
4.28125
4
def reverse_order(input_string): words = input_string.split() words = words[::-1] output_string = "" for i in words: output_string = " ".join(words) return output_string sample_string = "I like bread but I prefer bananas to it" print(reverse_order(sample_string))
ab8bcda8e43afa9dee575b15a5b6425bb8c1f6ce
ZoranPandovski/al-go-rithms
/math/GCD/Python/GCD_using_Euclidean.py
252
3.875
4
# Python code to demonstrate naive # method to compute gcd ( Euclidean algo ) def computeGCD(x, y): while(y): x, y = y, x % y return x a = 60 b= 48 # prints 12 print ("The gcd of 60 and 48 is : ",end="") print (computeGCD(60,48))
e8c3536f621ba78ccddc756b7080969baa481a45
xCrypt0r/Baekjoon
/src/10/10810.py
414
3.5
4
""" 10810. 공 넣기 작성자: xCrypt0r 언어: Python 3 사용 메모리: 29,380 KB 소요 시간: 64 ms 해결 날짜: 2020년 9월 16일 """ def main(): N, M = map(int, input().split()) basket = [0] * N for _ in range(M): i, j, k = map(int, input().split()) for x in range(i - 1, j): basket[x] = k print(*basket, s...
dedb79af4860c6ec72e9ab7f65d5d14cc7608a23
lettucemaster666/Python3_Bootcamp
/exception.py
4,075
4.40625
4
""" Purpose ------- Introduction to Exception Handling in Python. Summary ------- Exception Handling is used to handle error when a code does not go as planned. You can give a more specific error message depending on the type of error. Structure of Exception Handling: ------------------------------- try: ...
7ad327bdf7d981f3110ef4a14220f9b5a8488487
cameliahanes/Hangman-Game
/Console.py
2,477
3.578125
4
class Console: def __init__(self, controller): self.__controller = controller def run(self): print('{: ^30}\n{:^29}\n{: ^32}'.\ format('=Hangman=',' add <sentence>\n play\n', '')) while True: try: inp = input() ...
951bf78f90fb40b2bb5e8148e814ae42adf16329
pele98/Object_Oriented_Programming
/OOP/Exercise3/Exercise3_8.py
1,075
4.09375
4
# File name: Exercise3_8 # Author: Pekka Lehtola # Description: Creates cellphone class from user inputs class Cellphone: def __init__(self): self.manufact = "" self.model = "" self.retail_price = 0 def set_manufact(self): self.manufact = str(input("Enter the manufacturer : ...
2429e1fa66849a55e4c499fed987c3933ea77eb1
itsmesravs/sravss
/amp.py
138
3.8125
4
n=raw_input(371) temp=n sum=0 while(n>0); digit=n%10 sum=sum+digit**3 n=n//10 if(temp=sum): print("yes") else: print("no")
eb245222e3ec0d84d1d9682ea598bbe46652dee1
maru12117/python_practice
/210622_GUI_practice_1.py
1,273
3.671875
4
#GUI import tkinter as tk '''root=tk.Tk() lbl = tk.Label(root, text="EduCoding",underline=3) lbl.pack() txt = tk.Entry(root) txt.pack() btn = tk.Button(root, text="OK", activebackground ="red", width=5) btn.pack() root.mainloop()''' '''root=tk.Tk() #Tk 객체 인스턴스 생성 루트 자체(윈도우) label = tk.Label(root, text="Hello Worl...
4cb207df25c8c81e8296f8c68cf9164077be6e2c
SergeDmitriev/infopulse_university
/Lecture3/homework/task9.py
1,233
4.40625
4
# Даны четыре действительных числа: x1, y1, x2, y2. Напишите функцию distance(x1, y1, x2, y2), # вычисляющую расстояние между точкой (x1, y1) и (x2, y2). # Считайте четыре действительных числа от пользователя и выведите результат работы этой функции. print('task9: ') # def distance(): # try: # x1 = x2 = y1...
c5a760482d3eb93c5b692019ec75ac5af151fa7c
WanderAtDusk6/python-
/multiplication.py
352
3.65625
4
# -*- coding: gb2312 -*- # ˷multiplication ''' # version1 print() for x in range(1,10): for y in range(1,10): print(x*y,end = '\t') print() ''' # version2 m = 1 while m <= 9: n = 1 while n <= m: print(m*n,end = '\t') n = n+1 m += 1 print() ...
bd58209d68080355a362294a22a60bb2b1af05e8
iamwhil/6.0001
/ps1/ps1a.py
721
3.90625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 12 10:12:23 2018 @author: Whil """ # Retrieve user input. annual_salary = float(input("Enter your annual salary: ")) portion_saved = float(input("Enter the percent of your salary to save, as a decimal: ")) total_cost = float(input("Enter the cost of your drea...
c03bb3952b8782404605a5b365b354d00001a106
glyif/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/6-print_comb3.py
231
3.859375
4
#!/usr/bin/python3 for i in range(0, 10): for k in range(0, 10): if i < k: if i < 8: print("{:d}{:d}, ".format(i, k), end="") else: print("{:d}{:d}".format(i, k))
1cf8e39394a45bb1f29a783bb5913c5d84339b52
SunyoungHa/Python-Tableau-SQL-HTML
/Interactive_Dictionary/dictionary.py
811
3.671875
4
import json from difflib import get_close_matches data = json.load(open("data.json")) def translate(word): word = word.lower() if word in data: return data[word] elif word.title()in data: return[word.title()] elif word.upper()in data: return[word.upper()] elif len(get_clos...
27eb2236cc7f43d9a05d93b2c3dfc45be5f3505e
dennisliuu/Coding-365
/103/001.py
933
3.9375
4
A = [] B = [] while 1: mov = int(input()) if mov == 0: break elif mov == 1: A = [] print('A:%s B:%s' % (A, B)) elif mov == 2: B = [] print('A:%s B:%s' % (A, B)) elif mov == 3: insert = int(input()) A.append(insert) print('A:%s B:%s' % (...
d423d154fce8421ef7211f6ddd0dee6c349814be
Aman221/HackHighSchool
/Parseltongue Piscine/Parseltongue Piscine Part 3/00_parentheses.py
713
3.96875
4
#first part def everyother(s): ret = "" i = True for char in s: if i: ret += char.upper() else: ret += char.lower() if char != ' ': i = not i return ret new_line = everyother(raw_input('Enter a phrase: ')) print new_line #second part newer_lin...
a3314374706d225d7b91155b62ab97bc12a88ac6
ankitbhadu/cs204-riscv_simulator-1
/pipelined/iag_dp.py
1,245
3.65625
4
#control signals pc_select, pc_enable, inc_select are assumed to be given and ra and imm are in binary #if ra and imm are not in binary, we need to make a function to convert them into binary #all values are represented as binary strings # curr program counter is either passed or stored as a global variable(binary stri...
f6f1167ea05469281a566f57bb462dea9033dcc0
julaluk801/Program-Translate
/Program Translate/module_checkfile.py
821
3.671875
4
#!/usr/bin/env python3 # Module check file of word import listfile as fileloc def main(): print("Start operation: Checkfile") checkfile = Checkfile() checkfile.checkFile() class Checkfile(object): def __init__(self): self.filelist = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j...
0d193fb4301920ae32b9298bd42f0bd273d795f8
wisemonkey450/Boston
/boston.py
1,697
3.9375
4
#! /usr/bin/env python3 consonants =['b', 'c','d', 'f', 'g', 'h', 'j', 'k', 'l', 'm' ,'n' ,'p', 'q', 'r', 's', 't','v', 'w', 'x', 'z'] wicked_awesome_words = ["awesome", "good", "great", "fantastic", "weird", "strange", "patriots", "fenway", "red sox", "celtics", "bruins", "leominster", "peabody", "worcester", "boston...
5d93a457882489adfb683207dc35249142e85295
WendyPeng1118/python-learning-project
/class5.py
587
3.53125
4
import math coordinateAX = eval(input('輸入 A 點的 X 座標: ')) coordinateAY = eval(input('輸入 A 點的 Y 座標: ')) coordinateBX = eval(input('輸入 B 點的 X 座標: ')) coordinateBY = eval(input('輸入 B 點的 Y 座標: ')) distance = math.sqrt( (coordinateAX - coordinateBX) ** 2 + (coordinateAY - coordinateBY) ** 2 ) resultA = 'A 點座標為 ({}, {})\...
0c8153f27fb67a668ee75237e7cd43c5388cfa62
Abu-Kaisar/Python3Programming--Coursera
/Chapter7. Iteration/loop.py
459
3.859375
4
# mylist = ["yo","mujju","salman","thuss"] # for i in mylist: # print("Hi", i ,"Dawat hai kheenchny aao") # mylist = "dgsadafdua" # for char in mylist: # print("Hi", char ) s = "python rocks" for ch in s: print("HELLO") import turtle # set up alex wn = turtle.Screen() mujju = turtle.Turtle() f...
f5dd157dc2328ddc8dd9d96a7fb4c669a08616a8
raj5036/Project-Blockchain
/Code/blockchain.py
538
3.546875
4
import hashlib from Block import Block blockchain = [] genesis_block = Block("previous_hash_demo",["transaction1", "transaction2", "transaction3"]) second_block = Block(genesis_block.block_hash, ["transaction4", "transaction5"]) third_block = Block(second_block.block_hash, ["transaction6", "transaction7", "transac...
f4912f766cae95160f51c71e346e725f0ec05d4e
Shreyankkarjigi/Python--Codes
/Basic programs/sum of n numbers.py
280
4.1875
4
#Code by Shreyank #Github-https://github.com/Shreyankkarjigi #problem ''' print sum of n numbers, take n from user ''' n=int(input("enter range")) sum=0 for i in range(n): sum=sum+i print("sum of n numbers is:",sum) ''' output enter range10 sum of n numbers is: 45 '''
a9764f8756270de62e2725ca3d5a210a27dbe693
Shubhrima/TCS-Insight-Supermarket-System
/Sales.py
3,090
4.0625
4
#Importing the libraries import pandas as pd #Storing column tables in a list column_names = ['Date', 'prod_num', 'prod_name', 'quantity', 'price', 'total_cost'] #Creating a dataframe with these columns database = pd.DataFrame(columns = column_names) #Adding a sale to the record def add_product(date, p...
f6adef84c4c40c0590918316a5ce41810f220c8f
velorett-i/pubele-aulas
/exercises/ex1-novo/ex1-2.py
952
3.796875
4
import re import sys def parse_file(filename): res = dict() with open(filename, 'r') as f: #content = f.readlines() content = f.read().splitlines() content = content[3:] in_def = False word = '' for line in content: if line != '': ...
dc1aa5b14f64efe266e2ac176f2011ad19feb13d
shreysingh1/AddressBook
/address app/main.py
2,264
3.6875
4
from tkinter import * import datetime from mypeople import Mypeople from addpeople import Addpeople date = datetime.datetime.now().date() date = str(date) class Application(object): def __init__(self, master): # frames self.master = master self.top = Frame(master, height=150, b...
c8659240333d62ff8947cc40a42af9229c63d505
thomasperrot/python_graphique
/structures/Vector.py
1,292
3.9375
4
#! /usr/bin/env python # -*-coding: utf-8-*- from math import sqrt class Vector(object): ''' classe définissant un vecteur dans l'espace caractérisé par [*] sa coordonnée x (int ou float) [*] sa coordonnée y (int ou float) [*] sa coordonnée z (int ou float) ''' def __init__(self, x, y, z): self.xyz = [floa...
53285a8a2c6b5fb7008af7210be3cf1b93bf5277
blenature/python_advanced-1
/modules/mod4.1.json/json_many_objects_different_types/timeclass.py
1,279
3.765625
4
class Time: def __init__(self, hour, minute, second): self.hour = hour self.minute = minute self.second = second def __str__(self): return f"{str(self.hour).zfill(2)}:" \ f"{str(self.minute).zfill(2)}:" \ f"{str(self.second).zfill(2)}" class Zoned...
22ecae043eab30f4a44329a66ff9228ed09de0f1
zxz2jj/CombinationPattern
/Mnist/test.py
116
4.09375
4
list1 = [[1, 2], [2, 2], [1, 2]] temp = [] for i in list1: if i not in temp: temp.append(i) print(temp)
c403992e09d236585fb91c21b113b78f5b6640ae
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2/KavinSub/b_pancake.py
473
3.609375
4
def all_happy(pancakes): return len(pancakes) == pancakes.count(1) def flip(pancakes, i): for j in range(i, len(pancakes)): if pancakes[j] == 0: pancakes[j] = 1 else: pancakes[j] = 0 T = int(input()) for i in range(T): pancakes = input() L = [] for pancake in pancakes: if pancake == '-': L.append(...
f63b61f006de8b09e8c36dbb0b30b9a1306422ba
norbieG/Algorithms
/Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming/knsapsack.py
1,062
3.53125
4
import numpy as np def reconstruct(array, items): vertices = [] i = NO_ITEMS j = CAPACITY while i >= 1: if array[i-1,j] >= A[i,j]: i -= 1 else: vertices.insert(0, i) j -= items[i][0] i -= 1 print vertices def read_data(): items = {} file = open('task1.txt') for i, line in enum...
c03280cb65657d5c7561dd1fe0beb797c791dce8
Rahima-web/Hamiltonien
/TP4/brouillon1.py
6,849
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 22 14:44:44 2020 @author: rahimamohamed """ import random as rd import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns """ VARIABLE DECLARATION """ #number of parkinks N = 3 #p_max = 0.5 #p_min = 0.2 #size_m...
6d99e0e1912e028fca66bcc334d4db2e3d9f2f13
alfiza-shaikh/Exercise-2
/quick sort.py
568
3.6875
4
def divide(a,s,e): i=s pivot=a[e] for j in range(s,e): if a[j]<=pivot: a[i],a[j]=a[j],a[i] i+=1 a[i],a[e]=a[e],a[i] return i def sort(a,s,e): if(s<e): p=divide(a,s,e) sort(a,s,p-1) sort(a,p+1,e) from array import * n=int(input("Enter numb...
94c3f4b88a376928459df5fbc9d6304a50bc07cb
SilvesSun/learn-algorithm-in-python
/tree/235_二叉搜索树的公共祖先.py
1,672
3.5625
4
# 给定一个二叉搜索树, 找到该树中两个指定节点的最近公共祖先。 # # 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大( # 一个节点也可以是它自己的祖先)。” # # 例如,给定如下二叉搜索树: root = [6,2,8,0,4,7,9,null,null,3,5] # # # # # # 示例 1: # # 输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8 # 输出: 6 # 解释: 节点 2 和节点 8 的最近公共祖先是 6。 # # # 示例 2:...
df09c9557369b2f5c072a70d08f602b989b4effe
NanoRoss/Python-Automation
/Conceptos_Basicos/3_Herencia.py
3,575
3.859375
4
class Vehiculo: def __init__(self,velocidad,marca,modelo,color,velocidad_max): self.velocidad = velocidad self.marca = marca self.modelo = modelo self.color = color self.velocidad_max = velocidad_max def acelerar(self,velocidad): self.velocidad = self.velocidad +...
3cdde904908316fb7ed05c6697b7a83105a349cc
LOVEBAROT/python-basic-programs
/primeno.py
249
4.125
4
def isPrime(n): if n<2: return False for i in range(2,n//2+1): if n%i==0: return False return True no=int(input("enter no:")) if isPrime(no): print(no,"is prime no") else: print(no,"is not a prime no")
3cf669aeba89632bc3c4f025473aa00209e9ad29
NahalRasti/Python_accounts.py
/testAccounts.py
660
3.640625
4
from accounts import BankAccount def balance(): total = 0 for i in range(len(accounts)): print("Name:", accounts[i].name , "\tNumbers:", accounts[i].number, "\tBalance: ", accounts[i].balance) total = total + accounts[i].balance print("\t\t\t\t\tTotal: ", total) accounts = [...
0264f0d9e9b792a1c3139af320e5284c44c3aabf
HannahTin/Leetcode
/二叉树/dp/687_Longest Univalue Path.py
1,006
3.984375
4
''' 最长同值路径 给定一个二叉树,找到最长的路径,这个路径中的每个节点具有相同值。 这条路径可以经过也可以不经过根节点。 注意:两个节点之间的路径长度由它们之间的边数表示。 ''' # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def longestUnivaluePath(...
271b04ed8fab9e2857f7a286f519f8f2aec9bb6f
Tekorita/Cursopython
/conviertehorasasegundos.py
976
4.125
4
#Convierte de horas a segundos #En este ejercicio deberás programar un algoritmo encargado de convertir una #determinada cantidad de horas a segundos. Para ello deberás programar el # código necesario que solicite al usuario que introduzca 5 números (horas) # e imprima por la consola la conversión a segundos. #Si te...
b0d9f2a11ce018b7b84213aeb7321e876664951d
UncleBob2/MyPythonCookBook
/tuple find an element.py
1,435
4.3125
4
def main(): # A tuple of numbers tupleObj = (12, 34, 45, 22, 33, 67, 34, 56) print("**** Find an element in tuple using 'in' & 'not in' *****") # Check if element 34 exists in tuple if 34 in tupleObj: print("Element Found in Tuple") else: print("Element not Found in Tuple") ...
7ae837fc142bb636cea0571c85b7c3219d79b0db
oliverhuangchao/python_study
/string/reverseWordII.py
340
4.09375
4
# reverse word in a string # both iterative and recursive solution # recursive solution goes here def func(str): if len(str) == 0: return str a = 0 while a < len(str) and str[a] != " ": a += 1 str = str[:a][::-1] + " " + func(str[a+1:]) return str str = "hello world chaoh" str = str[::-1] print str str = ...
443be62ca17bdcaf6a64f4c97305b299891c5037
hotheadheather/Python
/GolfProgram/GolfProgram/GolfProgram.py
1,331
4.15625
4
#Program that reads each player's name and golf score as input #Save to golf.txt print( """ ~~ Spring Fork Golf Club ~~ Save golfers name to a record in a file read the name and golf score into a file. Then golfers will be printed for your convenience. """ ) outfile = open...
368abf9f87b378bf668247e40e5b9c759274b76e
alexferreiragpe/Python
/CursoModulo2/Jokenpo.py
2,472
3.609375
4
import random from time import sleep print('\033[1;34m-=-' * 20, '\n Jokenpô \n', '-=-' * 20) verifica = 'S' posicoes = ['Pedra', 'Tesoura', 'Papel'] contPc = 0 contEu = 0 while verifica == 'S': computador = random.choice(posicoes) print('\nVamos começar!') print('\n\033[1;35mComputador: Esto...
b7947630937453b315fc21d4d8fb67a00a526ede
eraserpeel/Project-Euler
/problem_30.py
251
3.5
4
import operator def main(): numbers = [] for num in range(0, 1000000): total = reduce(operator.add, [(int(i)**5) for i in str(num)]) if total == num: numbers.append(total) print numbers print sum(numbers) if __name__=="__main__": main()
e6a89d2496e8b248bf1b2d4e34c8ba49eccbb51f
KyeongJun-Min/DataScience_Practice
/[Solving] Pandas_usingDF.py
379
3.59375
4
import pandas as pd # 코드를 작성하세요. data_list = [['Taylor Swift', 'December 13, 1989', 'Singer-songwriter'], ['Aaron Sorkin', 'June 9, 1961', 'Screenwriter'], ['Harry Potter', 'July 31, 1980', 'Wizard'], ['Ji-Sung Park', 'February 25, 1981', 'Footballer']] my_df = pd.DataFrame(data_list, columns = ['name', 'birthday', '...
cd7541bf26a07400d0f1a37a691719cab3ca1228
hi0t/Outtalent
/Leetcode/1261. Find Elements in a Contaminated Binary Tree/solution2.py
1,013
3.734375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class FindElements: def __init__(self, root: TreeNode): self.root = root self.recover(self.root, 0) de...
fbb2f05b557b83b01175ab37e872fef4a74ae085
Maniramez/python-codes
/beginner level/max.element array.py
117
3.71875
4
N=int(input("")) list=[] for i in range(0,N): m=int(input()) list.append(m) print(list) k=max(list) print(k)
76286cda83fe243920b193d03c337179d2147de4
juancebarberis/algo1
/pre-parcialito/5.py
720
3.921875
4
#Escribir una funci´on que reciba dos secuencias y devuelva una lista con los elementos #comunes a ambas, sin repetir ninguno. secA = [1, 2, 3, 4, 7, 8, 9] secB = [5, 4, 1, 2, 5, 2] #Resultado [1, 2, 4] def valoresComunes(A, B): """Recibe dos secuencias y devuelve una lista con los elementos en común en amba...
1280d44cb829ab37c5d69340bc1a620ab49e7b53
Lam-Git/Learn_oop
/004._RectangleArea.py
799
3.703125
4
class RectangleArea: def __init__(self): # user can input their own numbers when variable = 0 self.length = 0 self.width = 0 def set_parameters( self, input_length, input_width ): # instance method with the set rules self.length = float(input_length) self.width = f...
88a802db6ac593580787a2bfb72909e9bfc383f1
koten0224/Leetcode
/0896.monotonic-array/monotonic-array.py
493
3.5
4
class Solution: def isMonotonic(self, A: List[int]) -> bool: lastNum = None moreThan = None for num in A: if lastNum==None: lastNum = num continue if lastNum == num: continue elif moreThan == None: ...
9d671993ff5494ef1130376523712a32d95c0ef8
reeeborn/py4e
/py4e/chapter13/ex13_coursera2.py
1,173
3.703125
4
# Python for Everyone # Chapter 13 Coursera week 4 assignment 2 from urllib.request import urlopen from bs4 import BeautifulSoup import ssl # retrives and parses the html from url # returns a tuple (url, contents) from the nth anchor tag where n = position # returns None for bad parameters def getNthLinkData(url,posi...
7e73c0c1722c5a3777d794ab8e481615b53dca43
pedromerry/Michelin-project
/Src/acquisition.py
1,072
3.546875
4
def loadDataset(): import pandas as pd import os currentPath=os.getcwd().split("\\Src") print(currentPath) #We load the three datasets sourcePathDataSet1Star = str(currentPath[0]) + "\\Input\\one-star-michelin-restaurants.csv" sourcePathDataSet2Star = str(currentPath[0]) + "\\Input\\two-sta...
c8d96b89885e5aa4949f0769b7bc4586caf2c8ec
sharewind/python-tools
/show_max_factor.py
428
3.640625
4
# -*- coding: utf-8 -*- from timeit import timeit __author__ = 'Caijanfeng' def show_max_factor(num): count = num / 2 while count > 1: if num % count == 0: print 'largest factor of %d is %d' % (num, count) break count -= 1 else: print num, ' is prime' if __n...
f8f2abdbe975eda0df4b79e3266d50ce7e077fd6
aregmi450/MCSC202PYTHON
/Q3.py
824
4.0625
4
# Create an array of 9 evenly spaced numbers going from 0 to 29 (inclusive) and give it the # variable name r. Find the square of each element of the array (as simply as possible). # Find twice the value of each element of the array in two different ways: # (i) # using addition and # (ii) using multiplication. import ...
495560c533f9d749f561c0ee156033ccb291170b
campbellr/pymacco
/pymacco/logic.py
9,468
4.15625
4
""" This module contains the logic for a card game """ import random from pymacco import util import pymacco.rules as rules class Card(object): """ Representation of a single card. """ suits = ['Clubs', 'Spades', 'Diamonds', 'Hearts'] values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', ...
0f4f8baa51eef7730e1333031966196f5207c4bd
gaivits/skill_lab
/anagram-170947.py
227
3.71875
4
a = int(input()) i = 0 while(i<a): s1 = str(input()) s2 = str(input()) y = "".join(sorted(s1)) x = "".join(sorted(s2)) if(x == y): print("ANAGRAM") else: print("NOT ANAGRAM") i = i+1
60b456ee2339aa2be7bdf59f40293eadb8571680
dinanrhyt/change-bg-opencv
/tugas2b.py
609
3.578125
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 25 19:47:42 2019 @author: Toshiba """ import cv2 as cv import numpy as np # Load the aerial image and convert to HSV colourspace image = cv.imread("result.png") image = np.array(image, dtype=np.uint8) hsv=cv.cvtColor(image,cv.COLOR_BGR2HSV) # Define lo...
d2884b178bebc6010fde9632bd4ca03dd1deed3b
dmitrime/algorithmic-puzzles
/leetcode/079-word-search.py
888
3.59375
4
class Solution: def dfs(self, x, y, b, w, idx): if idx == len(w): return True if x >= 0 and x < len(b) and y >= 0 and y < len(b[0]) and b[x][y] == w[idx]: b[x][y] = '#' res = self.dfs(x+1, y, b, w, idx+1) or \ self.dfs(x, y+1, b, w, idx+1) or \ ...
2bc1cde2b28b90e7628cf8171ec7083ee9d9f57a
igabbita/Python-Practice-Code
/sequentialsearch.py
546
4.0625
4
#Input: Array of Elements, Number to be searched #Output: Number found/ not found #Description: Sequential Search def seqsrch (m,n,arr): for i in range(0,n-1): if m== arr[i]: print("Number found at ", i) return () else: print ("Number not found") arr...
d8360b082c6e49b1526755762753a116c6a8a25a
Geothomas1/60-Days-of-Coding
/leap year.py
150
4
4
n=int(input("Enter Year:")) if(n%4==0 and n%100!=0 and n%400!=0): print("{} is leap year".format(n)) else: print("{} Not leap Year".format(n))
296cccda87481470b972b37d393f15da88662647
ucr-hpcc/hpcc_python_intro
/dictionary-type-variables.py
708
4.28125
4
#!/usr/bin/env python dictionary = {'name':'John','code':6734,'dept':'sales',2:'a number'} dictionary = { 'name':'John', 'code':6734, 'dept':'sales', 2:'a number' } print(dictionary['name']) # Prints value for 'name' key print(dictionary[2]) # Prints value for 2 key prin...
b462a21b9589c6f191d9a59f1d8cea0ea06ba22c
smartikaa/dice
/dice.py
669
3.53125
4
import random import tkinter as tk from tkinter import font as tkFont r = tk.Tk() helv36 = tkFont.Font(family='Arial', size=36, weight=tkFont.BOLD) r.geometry("700x450") r.configure(bg="#0C0F38") r.title('Dice') diceLabel=tk.Label(r,text="",font=("times",200),fg="#F8EEEE",bg="#0C0F38") n=[] n.append('\u2681') def roll(...
5aac7038f59c4bd62ca1f424fa3be746ac12b7fc
shanksms/python-algo-problems
/arrays/three-way-partionining-check.py
1,018
4.15625
4
''' Please note that it's Function problem i.e. you need to write your solution in the form of Function(s) only. Driver Code to call/invoke your function is mentioned above. ''' # Your task is to complete this function # function should a list containing the required order of the elements def threeWayPartition(arr, n...
94da434852228f80c4fdef6e8f7d1ec90faf9a6a
juandacd/ST0245-002
/laboratorios/lab01/codigo/Ejercicio1_1.py
520
3.515625
4
def Subcadena(cadena1, cadena2): if((len(cadena1) == 0) or (len(cadena2) == 0)): return 0 if(cadena1[len(cadena1)-1] == cadena2[len(cadena2)-1]): w = cadena1[:-1] z = cadena2[:-1] return Subcadena(w, z) + 1 else: x = cadena1[:-1] y = cadena2[:-1] ...
c96b902293a42500680afdf2d265ddeb6f400632
arshad115/100-days-of-leetcode
/codes/2020-07-17-top-k-frequent-elements.py
1,112
3.828125
4
# ------------------------------------------------------- # Add Two Numbers - https://leetcode.com/problems/top-k-frequent-elements/ # ------------------------------------------------------- # Author: Arshad Mehmood # Github: https://github.com/arshad115 # Blog: https://arshadmehmood.com # LinkedIn: https://www.linkedi...
66d9fe7d730a07b361bf8621306fbfb6205aa31a
cj1597/python_part_2
/part2_item4.py
400
3.84375
4
class Person: """Contains method for returning gender""" gender = '' def get_gender(self): """Returns person's gender""" return self.gender class Male(Person): """A Male person""" gender = 'Male' class Female(Person): """A Female person""" gender = 'Female' if __name__...
4e15a6639fe74c859903c04b60a19e56d7ca0a20
Holmes-pengge/algo
/leetcode/editor/cn/[116]填充每个节点的下一个右侧节点指针.py
2,359
3.984375
4
# 给定一个 完美二叉树 ,其所有叶子节点都在同一层,每个父节点都有两个子节点。二叉树定义如下: # # # struct Node { # int val; # Node *left; # Node *right; # Node *next; # } # # 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。 # # 初始状态下,所有 next 指针都被设置为 NULL。 # # # # 进阶: # # # 你只能使用常量级额外空间。 # 使用递归解题也符合要求,本题中递归程序占用的栈空间不算做...
92dca8295c017d0fc5407807ca899e6b293c9564
KrishnaRauniyar/Python_assignment
/fun9.py
467
4.09375
4
# Write a Python function that takes a number as a parameter and check the # number is prime or not. # Note : A prime number (or a prime) is a natural number greater than 1 and that # has no positive divisors other than 1 and itself. def test_prime(n): if (n==1): return False elif (n==2): retu...
137ffa9c2f60f50f747f196da570b44a775da2b9
FIRESTROM/Leetcode
/Python/314__Binary_Tree_Vertical_Order_Traversal.py
1,427
3.796875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def verticalOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ ...
ec3e3ec39f3cbd3869dc86b45c03aeff273119e6
pradeep122/LearnPython
/swetha/Tutorial_2/For_Loop/app.py
726
4.25
4
# For Loop is used to iterate over items of a collection such as string # for string for item in 'Python': print(item) # P # y # t # h # o # n # for array or list of names for item in ['Swetha', 'Pradeep', 'Nirvaan']: print(item) # Swetha # Pradeep # Nirvaan # for list of numbers for item in [1, 2, 3, 4]: ...
f7e69a6ef2301d337bc947d81f5ef473db39c48c
BiKodes/python-collectibles
/comprehensions/set/set.py
2,264
3.78125
4
# Initialize a Set: empty_set = set() # intialize a set with values: dataScientist = set(['Python', 'R', 'SQL', 'Git', 'Tableau', 'SAS']) dataEngineer = set(['Python', 'Java', 'Scala', 'Git', 'SQL', 'Hadoop']) # Add and Remove Values from Sets. # Initialize set with values: graphicDesigner = {'InDesign', 'Photoshop',...
0a7dc15098a11e2585324fc2d0969841cf17bb22
616049195/random_junks
/random_games/python_syntax.py
1,645
4.15625
4
""" Python syntax... """ # list comprehension ## syntax new_list = [x for x in range(1,6)] # => [1, 2, 3, 4, 5] ## ## examples even_squares = [x**2 for x in range(1,11) if (x)%2 == 0] ## # dictionary my_dict = { 'name' : "Hyunchel", 'age' : 23, 'citizenship' : "Republic of Korea" } print my_dict...
03b6ca945bd30847c80ca2cac94702211392d061
ZhangYet/vanguard
/myrtle/befor0225/longest_common_prefix.py
760
3.625
4
# https://leetcode.com/problems/longest-common-prefix/ from typing import List class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: if not strs: return "" if len(strs) == 1: return strs[0] records = set() standard = strs[0] prefi...
fb1b21e04944c0b6b7a7689aa2fcedf41d944c45
brackengracie/CS-1400
/week-1/thermometer.py
718
4.03125
4
# Thermometer by: Gracie Bracken def main() : #instructions print("---------------------------------------------") print("Hey Dipper, remember your thermometer next time.") print("I'll help for now! Use your stopwatch, count how ") print("many times the cricket chirps in 13 seconds.") print("") ...
cc78cfeea4805a0557011196a9bcdd159724acfc
SiranushSevoyan/Intro-to-Python
/Lecture 2/Homework 2/Problem2.py
348
3.90625
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("Text", type=str) args = parser.parse_args() b=int((len(args.Text)-3)/2) c=int((len(args.Text)+3)/2) print ("The old string:: ", args.Text) print ("Middle 3 characters: ", args.Text[b:c]) print ("Middle 3 characters: ", args.Text[:b]+args.Text...
6fdc7d16748a875d535dfb8070eb8b69568bdb37
IrwinLai/LeetCode
/876. Middle of the Linked List.py
625
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def middleNode(self, head: ListNode) -> ListNode: slow = fast = head while fast and fast.next: slow = slow.next fast = fast.n...
c1f040ae4c4323053e6bfac3bd63436944617109
BLewis739/MarkovTextGenerator
/Markov Text Generator.py
4,295
3.75
4
# Markov Text Generator.py # Adapted from problem set question in Boston University course CS111 # Professor David Sullivan, PhD # This version written by Brad Lewis 9/22/21 import random ''' create_dictionary takes in a string that refers to the name of a text file in the folder of the program. It returns d...
43fd7a56513cc9e37d92463f28b10cc941aa981a
thekingmass/OldPythonPrograms
/aktuwhileeven.py
221
4.25
4
while 1: x=int(input('please provide any input or zero to terminate\n')) if x!=0: if x%2==0: print(x,'is an even number') else: print(x,'is not an even it is an odd number ')
0219070377c3f413f9fa5d44fb38387695d2edea
Samyak2607/CompetitiveProgramming
/Codechef/Find Your Gift.py
615
3.578125
4
def grid(j, x, y): if j=='L': x-=1 elif j=='R': x+=1 elif j=='U': y+=1 else: y-=1 return (x,y) for _ in range(int(input())): n=int(input()) s = input() l=[] dict1={} x,y=0,0 dict1['L']=0 dict1['R']=0 dict1['U']=1 dict1['D']=1 ...
067f9d1c7e6778533982b64e38dacd73ef7260d8
ajcepeda/Calculator
/calc_gui.py
4,738
3.71875
4
from tkinter import * values = '' # event function when any button is pressed (except equal and clear button) def press(num): global values values = values + str(num) equation.set(values) # event function when equal button is pressed def equal(): try: global valu...
12ad51e396e1ca5bffdd62957f8d07dd536b6972
guadalupeaceves-lpsr/class-samples
/for.py
580
3.921875
4
icecreamflavors = ['Chocolate', 'Vanilla', 'Strawberry', 'Salted Caramel', 'Mint Chip'] print("These are our ice cream flavors:") print(icecreamflavors) print("Want to add an ice cream flavor? Enter it now:") newicecreamflavor = raw_input() newicecreamflavor = [newicecreamflavor] newmenu = icecreamflavors + newicecrea...
b7c120355913e5233bf39134ab86914c8437f4d2
yoonmyunghoon/JDI
/알고리즘/프로그래머스/코딩테스트 연습/멀쩡한 사각형.py
219
3.640625
4
from math import gcd def solution(w, h): answer = 1 gcd_ = gcd(w, h) x = w//gcd_ y = h//gcd_ print(x, y) x_ = x // 2 y_ = y // 2 print(x_, y_) return answer print(solution(8, 12))
179ee0ea253318533957be2e031ca67784e4990c
aferreira44/python-para-zumbis
/lista-02/exercicio-04.py
193
3.828125
4
a = float(input('A: ')) b = float(input('B: ')) c = float(input('C: ')) nums = [a, b, c] maior = nums[0] for n in nums: if n > maior: maior = n print('O maior número é %.2f' % maior)
c4e35c30b5d36634d10c8ce73b4320da5fe608bd
311210666/Taller-de-Herramientas-Computacionales
/Clases/Programas/Tarea05/problema5S.py
220
3.65625
4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- import problema5 from problema5 import spnn n= input ("¿Del 1 al cuál quieres calcular la suma?\n") print "La suma de los primeros %d naturales es %d" % (n, spnn (n))
96289ebb75fe896a1836d11faf5defba8f61ff9f
kodyellis/Python
/testingfinal/Kody Ellis Discrete Math Problem #1.py
1,926
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 02 22:32:31 2017 @author: Kody Ellis """ # Program 1. Set operations #Using Python to create a program that can identify and complete set operations: # Set Operations: # # Union # Intersect # Difference # Cross product...
53e5b8c10dbe2889e37480077885e1ef64582438
muryliang/python_prac
/try/if.py
396
4.03125
4
#!/usr/bin/python b=raw_input("input your integer:") ''' if a=='2': print ' you are 2' elif a=="3": print 'you are 3' else: print 'your are nothing' a = int(b) while a > -20: print 'now is ', a a = a-1 else : print 'now done' ''' a = int(b) for x in range(0,a+1): if x % 3 == 0: c...
e839047637d3c6251883e3889ff355f88b345a39
adityaronanki/pytest
/pythoncourse/assignment_01.py
2,295
4.0625
4
__author__ = 'Khali' from placeholders import * notes = ''' Fill up each of this methods so that it does what it is intended to do. Use only the standard data types we have seen so far and builtin functions. builtin functions: http://docs.python.org/2/library/functions.html Do not use any control flow sta...
89428ff9765bf751ec62c9fce51b9e74e3b0c725
luthfirrahmanb/purwadhika_data_science_module1
/fundamental.py
13,831
4.03125
4
import math """ Basic """ # print('Halo') nama = "andi" # print(nama) usia = 23 usia = 32 # print(usia) jomblo = True # Data Type # print(jomblo) # print(type(nama)) # print(type(usia)) # print(type(jomblo)) """ Input """ # name = input('Nama kamu?: ') # age = input('Umur kamu?: ') # sex = input('Kela...
d25f80cc00da4d3500b1e1dc60ce75e4e8d3937f
edwardjs55/Python
/OOP/Bike.py
948
4.3125
4
class Bike(object): def __init__(self,price,speed): self.price = price self.max_speed = speed self.miles = 0 def displayInfo(self): print "Bike Price: $",self.price," Max Speed: ",self.max_speed," Miles: ",self.miles return self def ride(self): self.miles +=...
86f198da1d645c01fc516e11cd27c075e3daba8b
nobe0716/problem_solving
/codeforces/contests/1241/B. Strings Equalization.py
187
3.828125
4
def is_possible(s, t): st = set(t) return any(e in st for e in set(s)) for _ in range(int(input())): s, t = input(), input() print('YES' if is_possible(s, t) else 'NO')
fa69f2f19750b3c8f07d941d68698b5091fc483d
zhenggang587/code
/leetcode/SameTree2.py
863
3.828125
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param p, a tree node # @param q, a tree node # @return a boolean def isSameTree(self, p, q): if not p and not q: ...
13a1ec9f3d69d61fc94ff3883f576395ca6cad7e
jadenpadua/Data-Structures-and-Algorithms
/bruteforce/binarySearch.py
569
3.859375
4
#Uses mid element to narrow array value down until found import random def binarySearch(list,element): list.sort() top = len(list) bottom = 0 while top > bottom: middle = (top + bottom) // 2 if element == list(middle): return middle elif element < l...
ac3134b71a42b889bc513019293c735a4f297bc2
majf2015/python_practice
/test_proj/class.py
1,964
4.21875
4
class dog(): def eat(self,food): self.__foo = "dog eat," + food print self.__foo def __init__(self, color): self.__coor = color def bar(self): print self.__coor, " dog barking" #def __len__(self): # return 23 d = dog("black") d.eat("qwe" ) d.bar() #print "len of dog:" + str(len(d)) class BigDog(...
9344ef8b51ae68b5ece4078de5642af1c783c7ca
chikchengyao/advent_of_code_2017
/07/b7.py
4,776
3.5625
4
########################################################## ## Disgusting hacky code pls don't judge ## ########################################################## # legit this will give you a fucking headache to read # # ABANDON HOPE ALL YE WHO ENTER HERE # # no, seriously, ask me to explain IRL it'll pro...
76f932b3c7ebaaf9afca41a35bd952724e4a4832
Aasthaengg/IBMdataset
/Python_codes/p03252/s568934327.py
322
3.625
4
if __name__ == '__main__': S = input() T = input() set_S = set(S) set_T = set(T) if len(set_S) != len(set_T): print("No") exit() dic = dict() flg = True for x,y in zip(S,T): if x not in dic: dic[x] = y else: if dic[x] != y: flg = False break if flg : print("Yes") else: print("No...
faab9a9fbc2df3b1a8524edcc2a6385866812b4e
anaselmi/simple_python
/simple/up_arrow.py
816
4.3125
4
def parser(xpr: str): """ Parses an up-arrow expression into a tuple containing the parsed expression. Notes: ↑ is used to denote the up-arrow. :param str xpr: Expression. Must be an int, n amount of arrows, and an int, separated by spaces. :return tuple: Parsed expression, represented by three...
3a42f465d154eb4910fa3727c657ad129ca3bc0e
rowan-jansens/triangle_distribution
/simple_ca.py
6,486
3.5625
4
#! /usr/bin/env python3 """Take an initial row and a cellular automaton rule and run the automaton for a given number of iterations. Then look at the triangle size distibution""" import random import math def main(): n_cells = 700 n_steps = 800 distribution = {} simple_distribution(n_steps, n_cell...