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
f3802300f124f4396007e148df2c7d7f85b88be1
rafin007/Machine-Learning
/Assignment - 1/Task2.py
1,405
3.65625
4
#dataset link: https://archive.ics.uci.edu/ml/datasets/banknote+authentication import numpy as np from Perceptron import Perceptron if __name__ == '__main__': #read from file file_data = np.genfromtxt('data_banknote_authentication.txt', delimiter=',') #-----------------initialize Perceptron variables---...
9f79d87748151fa7d7aaa5592db7493f9f7bc366
drdread987/ParseSortCreate
/main.py
8,003
3.625
4
# imports from os import listdir # used in order to see all files in the folder __author__ = "Drdread" # just cuz i guess ##################### Functions ####################################################################### def sql_generator(data,vendors, EC): # will be created once I know for sure how you ...
877c3eba6519ea505bd1a61b6c56fc825e774370
danielprofili/scripts
/getup.py
296
3.53125
4
# Motivates the user to get up every once in a while and get ripped import random things = ['sit ups', 'leg raises', 'push ups', 'jumping jacks', 'leg circles', 'lunges', 'squats'] print('Get up and do ' + str(random.randint(1, 40)) + ' ' + things[random.randint(0, len(things) - 1)]) input('? ')
fed137cfc133ead074e2b1a14098b152a81cb790
TheProvisionGames/AITutorial
/pythonProject/NeuralNets Tutorial13/main.py
3,418
3.65625
4
import pygame # pygame has all kinds of interesting features, only some of them are used below from defs import * # import properties from defs.py from pipe import PipeCollection # Import pipe to use it here from bird import BirdCollection def update_label(data, title, font, x, y, gameDisplay): # This is the form...
c3c00d246955c37a75bf6839b5c836c38d8eaba5
agneya-1402/Browser
/Browser.py
2,525
3.546875
4
import webbrowser import tkinter as tk from tkinter import * import speech_recognition as sr r=sr.Recognizer() a=tk.Tk() a.title("Browser") a.iconbitmap("C:/Users/dhiraj/Pictures/Browser_img/Google_logo.png") def search(): word=SearchBar.get() webbrowser.open(word) def voice(): with sr...
cd0e31fec220f4c3e9a04262de709ed86c91e37f
posguy99/comp644-fall2020
/L3-12.py
270
4.125
4
# Create a while loop that will repetitively ask for a number. # If the number entered is 9999 stop the loop. while True: answer = int(input('Enter a number, 9999 to end: ')) if answer == 9999: break else: print('Your number was: ', answer)
5da4e0552096abe360fcab61e2cf883924fa8baf
posguy99/comp644-fall2020
/L5-13.py
378
4.125
4
# python lab 5 10-6-20 # l5_13 shallow copy of a list, the id() are the same indicating # that they are both pointers to the same list object the_list = ['Apples', 'Pears', 'Oranges', 'Mangoes', 'Tomatoes'] print('the_list: ', the_list) the_new_list = the_list print('the_new_list: ', the_new_list) print('the_list...
266855d66e3b769f19350e5fa22af81c7b367811
stfuanu/Python
/basic/facto.py
268
4.125
4
num = input("Enter a number: ") num = int(num) x = 1 if num < 0: print("Factorial doesn't exist for -ve numbers") elif num == 0: print("Factorial of 0 is 1") else: for i in range(1,num + 1): x = x*i print("Factorial of",num,"is",x)
3ab084579276659c14fca1a6421903dc47227b27
jrngpar/PracticePython
/15 reverse word order.py
1,273
4.28125
4
#reverse word order #ask for a long string with multiple words #print it back with the words in backwards order #remove spaces? Maybe print back with words in reverse #2 functions, one to reverse order of words, one to reverse letters in words? #Can call both functions to reverse order and letters if wanted def rever...
9ac1a97e8ca03c839ee8fb47d75543439dca84e5
jrngpar/PracticePython
/roll dice.py
539
4.09375
4
#simulate some dice #how many rolls? #how many sides on the dice? #want to roll again? import random def get_sides(): sides = int(input("How many sides: ")) return sides def get_rolls(): rolls = int(input("How many rolls: ")) return (rolls) def main(sides, rolls): side_number = 1 my_die = [] for x in rang...
76f27655c430d7ccdf6b497fc87c0478b1d2f385
rhnvrm/mini-projects
/test_driven_dev/tests/test_car.py
1,326
3.5
4
import unittest from app.car import Car class TestCarCreation(unittest.TestCase): def test_new_car(self): car = Car("KA-01-HH-1234", "White") reg_no = car.reg_no self.assertEqual("KA-01-HH-1234", reg_no) color = car.color self.assertEqual("White", color) def test_c...
1063438ebb7bf1b41bf7beb53b7a2622f2a13eef
JoaozinhoProgramation/Exercios_LP_1B
/Exerc11.py
148
3.640625
4
produto = float(input("Preço do produto:")) produto = (((produto * 5)/100) - produto) print("Seu produto com 5% de desconto é {}".format(produto))
fedd617018af1eeb902c0100db1d55824e31d7e9
evamal93/repo-py
/lesson1/task3.py
183
3.796875
4
n = int(input("Пожалуйста, введите число")) result = (n + int(str(n) + str(n)) + int(str(n) + str(n)+ str(n))) print("Сумма равняется" , result)
0b1484d68ba1c8014bc2653ae664180f723f02d7
ZiLi-meowzz/y1math
/t01primeshcflcm_evennumbers.py
119
4.03125
4
# What are the even numbers from 1 to num? num = 123 for i in range(1, num+1): if i % 2 == 0: print(i, end=' ')
eca2917eedf647f3b98e7badbcb01b222011771d
shankrmahadevan/DSA
/Binary Trees/Python/BST/Some Problems/101. Symmetric Tree.py
322
3.640625
4
# Node.value;Node.left_child;Node.right_child def is_symmetric(root1, root2): if root1 is None and root2 is None: return True elif root1 is None or root2 is None: return False return root1.value == root2.value and is_symmetric(root1.right, root2.left) and is_symmetric(root1.left, root2.right...
6c47f621bae0628719567ac01e357262a27979c1
ryanholzapfel/FlairCompiler
/src/flair_tokens.py
4,971
3.578125
4
from enum import Enum class TokenType(Enum): #Identifiers and data types NUMBER = 1 IDENTIFIER = 2 BOOLEAN = 3 #Mathematical Operations ADD = 4 SUBTRACT = 5 MULTIPLY = 6 DIVIDE = 7 LESS = 8 EQUAL = 9 #Punctuators LEFTBRACKET = 10 RIGHTBRACKET = 11 COMMA...
1341c50fd7e58931c55c79478479d0b29deb0787
MrazTevin/100-days-of-Python-Challenges
/SolveQuiz1.py
695
4.15625
4
# function to determine leap year in the gregorian calendar # if a year is leap year, return Boolean true, otherwise return false # if the year can be evenly divided by 4, it's a leap year, unless: The year can be evenly divided by 100 it is# not a leap year,unless the year is also divisible by 400, then its a leap yea...
c24625c534a78e6277a58c2331844b8a76590bd1
jeffcappa25/Advanced-Software-Engineering
/3and5.py
118
3.734375
4
total = 0 for natnum in range(1000): if (natnum%3 == 0 or natnum%5 == 0): total = total+natnum print total
6c02e023f13eede64a67e13dd7d3bd44475daf1d
nunrib/covid19-webinar
/covid/presentation/welcome.py
1,293
3.515625
4
import streamlit as st def content(): st.title("Before we Start") st.header("Your Hosts Today") st.markdown(""" * **Husnu Sensoy** as the main presenter for today. * **Dorukhan Afacan** * :fearful: Fixing my potential errors * :sweat: Helping me in case of an unexpected co...
b8b27e5bfb06efea0392d25441778c7ac72b46cb
Alicia0629/SELDYM-2.0-Encriptar
/main.py
7,691
3.609375
4
import numpy informacion=[] abecedario=[] for i in range(0,256): abecedario.append(chr(i)) mensaje1=[] for i in input('Inserte el mensaje que desea cifrar: '): mensaje1.append(abecedario.index(i)) clave=[] for i in input('contraseña: '): clave.append(abecedario.index(i)) #vamos a calcular el número mí...
82573c7abbdd044e489e75c4b53f7840c10873ae
rdstroede-matc/pythonprogrammingscripts
/week5-files.py
978
4.28125
4
#!/usr/bin/env python3 """ Name: Ryan Stroede Email: rdstroede@madisoncollege.edu Description: Week 5 Files Assignment """ #1 with open("/etc/passwd", "r") as hFile: strFile = hFile.read() print(strFile) print("Type:",type(strFile)) print("Length:",len(strFile)) print("The len() function counts the numb...
0c0cdf005d7b7ceb27af58070158140e81e84776
gitskying/learn_kying
/Mine/DateStructure/tree.py
1,839
4
4
class Node(object): def __init__(self, item): self.item = item self.lChild = None self.rChild = None class Tree(object): def __init__(self): self.__root = None def add(self, item): node = Node(item) if self.__root is None: self.__root = node ...
163e8761b18450e7a239bf9f32cf3e16fc48d5ff
LizAitken/PythonPractice
/index.py
234
4.09375
4
first_name = input("What is your first name? ") last_name = input("What is your last name? ") fav_color = input("What is your favorite color? ") print("Hello %s %s! My favorite color is also %s!" %(first_name, last_name, fav_color))
6ba921ed4f30b8986795500322fe7ac595ac1d0c
lizihaoleo/Maze-Runner
/src/mazeManager.py
1,675
3.53125
4
from src.maze import Maze from src.graph import Graph from src.solver import DFS,BFS,Dijkstra class MazeManger(object): def __init__(self): self.graphs = [] self.mazes = [] def add_maze(self,row,col,id=0, show = True, debug=False): # return a optimize graph instead of maze instance if ...
c450d09811a6c3cd6071c57fd6ad743305438ea9
turing85/graal-playground
/benchmarks/src/main/resources/python/fibonacci_iterative.py
207
3.734375
4
def fibonacci(n): if n <= 1: return n nMinusOne = 1.0 nMinusTwo = 0.0 for index in range(2, n + 1): nMinusOne = nMinusOne + nMinusTwo nMinusTwo = nMinusOne - nMinusTwo return nMinusOne
db94609032b9e63b2117f46bebf73239c4e01427
akvara/CodeWars
/5kyu/Gap_in_Primes.py
692
3.625
4
def gap(g, m, n): print m prime1 = None while m <= n: if prime(m): if prime1 and m - prime1 == g: return [prime1, m] prime1 = m m += 1 def prime(p): if p % 2 == 0: return False for d in range(3, int(p ** 0.5 + 1), 2): if p % ...
b64575e0dae9dde6cd19bc33d9cdd95d482be6c6
akvara/CodeWars
/3kyu/Can_you_get_the_loop.py
961
3.640625
4
class Node(object): def __init__(self): self.next = None def loop_size(node): chain = [] count = 0 while id(node) not in chain: chain += [id(node)] count += 1 node = node.next return count - chain.index(id(node)) from KataTestSuite import Test test = Test() # Mak...
baef8eae3711ab0aaa507a6700c6b786051fb5e0
Merical/education_ai
/leetcode/16_3sum_closest.py
886
3.609375
4
def threeSumClosest(nums, target) -> int: nums.sort() length = len(nums) memo = {} if length == 0: return 0 elif length == 1: return nums[0] elif length == 2: return nums[0] + nums[1] else: closest = nums[0] + nums[1] + nums[2] for l in range(length-2...
c36101dcab66a944d4d37cb9225a1d380cf33c55
Merical/education_ai
/nullmax/2.py
1,826
3.59375
4
import sys # def my_ascii(n): # if 48 <= ord('n') <=57: # return ord('n') # else: # return ord(n) * 2 if n.islower() else ord(n.lower())*2 - 1 # # def quicksort(names, compare=0): # if len(names) < 2: # return names # else: # pivot = names[0] # less = [i for i in...
2e00928b5fcb9afbb99d9fb930cfe18e7193768d
Merical/education_ai
/leetcode/7_reverse_integer.py
305
3.625
4
def reverse(x: int) -> int: flag = None if x == 0 or x > 2 ** 31 - 1 or x < -2 ** 31: return 0 elif x < 0: x = -x flag = '-' s = str(x)[::-1] while s[0] == '0': s = s[1:] s = flag + s if flag is not None else s return int(s) print(reverse(1534236469))
fb44c82483646dbf393d9662d15b10497c342604
zenium/playground
/python/problem_200.py
1,964
3.609375
4
''' We want to optimally compress a sequence of numbers uniformly drawn from the [0, a) range. Why? Well, for instance to transmit the subsequent draws from a 12-dice (in this case, a = 12). If we use four plain bits for each result, we'll lose some compression efficiency, since some values are unreachable. To optima...
2fe0a9bbc8bb8a26a3c2ce7035ba4270724bcae8
zenium/playground
/python/the_swivel_chair_game.py
5,628
3.65625
4
''' challenge question You and your friends grab some powered swivel chairs and head out to a field. The goal of the game is to pass a ball from the lower left corner of the field to the upper right corner. How do you do this? The field is a 2-dimensional grid of people in swivel chairs. When two people next to each o...
239ce113fef85e0e3ac8f03edf65ff262c9ec53a
zenium/playground
/python/stockSpan.py
1,407
3.984375
4
import unittest def stockSpan(input): """The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock’s price for all n days. The span Si of the stock’s price on a given day i is defined as the maximum number of consecutive days ju...
b3718c7d0951c9ce5ef3c2944f86b5b89822a758
ganeshhubale/python_programs
/function_def.py
137
3.953125
4
def sum(a, b): return a + b a = int(input("Enter first number: ")) b = int(input("Enter Second number: ")) print("Sum: ",sum(a, b))
68c4319234789ba249479f92a926c4f5ec26570d
ganeshhubale/python_programs
/average.py
255
3.96875
4
n = int(input("Enter number of subjects:")) sum = 0 a = 0 while a < n: m = int(input("Enter Marks:")) if m > 100: print("Invalid Data") else: sum = sum + m a = a + 1 sum = sum / n print("Average of Marks= " + str(sum))
c3b99bc5e65ad1611f421774df11b26f100da178
ganeshhubale/python_programs
/iftest.py
104
3.9375
4
string1 = "Hello World" if 'hello' in string1: print("Hello is present") else: print("not present")
27e0a24644661394ed63bd97b376ad2b25266827
ganeshhubale/python_programs
/dict_all_op.py
89
3.765625
4
a = {'a':'ganesh', 'b':'ram'} print(a) del a['a'] print(a) a['c'] = 'ganesh' print(a)
e598d9ab26bffe7a74720978a330b802572b0465
singofwalls/KSU_Programming_Competition_2017_Solutions
/main3.py
481
3.578125
4
numerals = "IVXLCDM" numbers = [1, 5, 10, 50, 100, 500, 1000] string = input("NUMERALS: ") ind = 0 total = 0 skip = False for i in string: if skip: ind += 1 skip = False continue if ind + 1 < len(string) and numerals.index(string[ind + 1]) > numerals.index(i): total += numbers[...
6aa7d00b51249956e82278cca3f303a97cfb0e3f
stak21/DailyCoding
/leetCodeChallenge/997_squares_of_array.py
149
3.921875
4
""" Square an array and sort it """ def sortedSquares(A): return sorted([item**2 for item in A]) li = [1, -2, 0, 20] print (sortedSquares(li))
1bdfad55963a5ca778fc06d402edc95abcf8fb16
stak21/DailyCoding
/codewarsCodeChallenge/5-anagram.py
1,300
4.28125
4
# Anagram # Requirements: # Write a function that returns a list of all the possible anagrams # given a word and a list of words to create the anagram with # Input: # 'abba', ['baab', 'abcd', 'baba', 'asaa'] => ['baab, 'baba'] # Process: # Thoughts - I would need to create every permutation of the given word...
14c62eb7c1deeb895064233d5f875c7393d5f971
stak21/DailyCoding
/codewarsCodeChallenge/reviews/r1_valid_parenthesis.py
875
4.0625
4
# Requirements: # given a string, return True if the parenthesis are valid # else False # Input: # "()" | True # "(())" | True # "()()" | True # "())" | False # "" | True # "(dwa) | True # Process: # Approach 1: # because we are only looking for a parenthesis, we can keep track of...
13257dbda4866ee03d5d499a049f376dcee8c313
SiliconValley007/Metadata-Extractor
/metadata.py
2,831
3.671875
4
""" Approach: • Import the pillow module. • Load the image • Get the metadata. The metadata so obtained • Convert it into human-readable form There are many types of metadata but in this we are only focusing on Exif metadata. Exif These metadata, often created by cameras and other capture devices, include t...
63c353762bd45fbfa28b5305eaa15964a88c241e
kokojong/algo-study-catch
/2021_10_08/16236_아기 상어.py
1,066
3.515625
4
from collections import deque n = int(input()) board = [] distance = [[0 * n] * n] for _ in range(n): board.append(list(map(int, input().split()))) print(board) size = 2 shark = [] # 상어의 위치 for i in range(n): for j in range(n): if board[i][j] == 9: shark.append([i, j]) bre...
bbd21b8867ca547ecf26620bbc8ca46f91593042
FB-18-19-PreAP-CS/wordplay-JacobJJoness
/textreader.py
2,503
3.796875
4
import re #def read_file(): # with open('word.txt')as file: # count_the = 0 # for line in file: # for word in line.strip().split(): # count_the += 1 # print(count_the) def twenty_O_mo(): with open('words.txt') as file: for line in file:...
ea572df967957d230afe6885211c9cc0c61d80c9
mahdise/data_visualization
/data_visulazation_with_deffernt_plot_type/steam_plot.py
2,599
3.546875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import stats def create_steam_plot(data): # Create a copy of your data set stem_data = data.copy() # Compare two data sets or variables using `diff()` stem_data[['big_data_comp', 'machine_learning_comp']] = data[['big d...
2f606d5f983f4021c727b5b0004767b3f0e1a63e
HarithaPS21/Luminar_Python
/Advanced_python/object_oriented_programming/Polymorphism_with_Inheritance/Method_overloading/PersonEmployee.py
440
3.765625
4
class Person: def printDetails(self,name,age): self.name=name self.age=age print(self.name,self.age) class Employee(Person): def printDetails(self,empid,salary,dept): self.empid=empid self.salary=salary self.dept=dept print(self.empid,self.salary,self.dept...
afc80165e3d0f02bbc8d49ce2ba2dae80092abc2
HarithaPS21/Luminar_Python
/Advanced_python/Functional_Programming/dictionary.py
632
4.125
4
employees={ 1000:{"eid":1000,"ename":"ajay","salary":34000,"Designation":"developer"}, 1001:{"eid":1001,"ename":"arun","salary":38000,"Designation":"developer"}, 1002:{"eid":1002,"ename":"akhil","salary":21000,"Designation":"hr"}, 1003:{"eid":1003,"ename":"anu","salary":45000,"Designation":"Analyst"} } id=int(input("...
888f14994f9e8271e98af722fa7e5b13d12ad884
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/iterating_statements/even_in_range.py
191
4.125
4
min=int(input("Enter initial range")) max=int(input("Enter final range ")) print("Even numbers between",min,"and",max,"are\n") for num in range(min,max+1): if num%2==0: print(num)
1c5f81b9659b413abbad000bd723aab2c040c3ce
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/decision_making/if_else/bank.py
238
3.78125
4
fixed_amount=10000 print("Your fixed amount is Rs.",fixed_amount) amount=int(input("Enter the amount to be withdrawed ")) if amount>fixed_amount: print("Insufficient balance") else: print("Your balance is Rs,",fixed_amount-amount)
6f12b29f50e5207412c01217d4df2f60e78ccc1e
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/iterating_statements/sum_range.py
89
3.859375
4
limit=int(input("Enter a number")) sum=0 for num in range(limit): sum+=num print(sum)
3707446a44d8c1ac6248b044efc786d447f320bd
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/iterating_statements/string_iteration.py
122
3.984375
4
a="hello world" for char in a: print(char) # a="malayalam" # for char in a: # if char=="l": # print(char)
aaad26766dbaf3819cebe370c7f5117283fd1630
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/iterating_statements/while_loop.py
339
4.15625
4
# loop - to run a block of statements repeatedly # while loop -run a set of statements repeatedly until the condition becomes false #Syntax # while condition: # code # inc/dec operator a=0 while a<=10: print("hello") # prints "hello" 11 times a+=1 print("\nwhile decrement example") i=10 while i>0: ...
184aff52a360f72d5359b5a448c3989ce26afd89
FabianSchuetze/gym-continuousDoubleAuction
/gym_continuousDoubleAuction/envs/account/cash_processor.py
3,696
3.9375
4
from decimal import Decimal class Cash_Processor(object): """ Handles the cash & cash_on_hold for the trader's account. note: When the trader places an order, certain amount of cash (the order's value) is placed on hold so that his amount of cash will decrease accordingly. ...
85ecee8b621d76b856fc0aaa62e26701b9dc6d57
eggplanty/basicAlgorithm
/components/heap_sort.py
1,448
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # ---------------------------------- # @Date : 2020/4/3 # @Author : Zhicheng Qian # @Version : 1.0 # @Brief : # @Description : # @Reference : # ---------------------------------- from components.sort_test import SortTest class HeapSort(SortTe...
e2007b47b0d617440d18b7f97d0bbf1172f0877c
GuilhermeLegal/curso-python
/PythonExercicio/ex005.py
143
3.984375
4
n1 = int(input('Digite um valor: ')) print('Analisando o número {}, o seu antecessor é {}, e seu sucessor é {}'.format(n1, (n1-1), (n1+1)))
27c87493d87265e4b0477f81166682be4c20a28f
GuilhermeLegal/curso-python
/PythonExercicio/ex014.py
138
3.9375
4
c = float(input('Informe a temperatura em °C: ')) f = ((9 * c) / 5) + 32 print(f'A temperatura de {c:.2f}°C corresponde a {f:.2f}°F!')
40f238c1863e8450dad43ba7d745cbdb1eb281e2
shashanka-adiga/Algorithims-and-datascrtures
/Sort/mergesort.py
910
3.78125
4
def merge(arr,low,mid,high): n1 = mid - low + 1 n2 = high - mid l = [0]*n1 r = [0]*n2 for i in range(n1): l[i] = arr[low+i] for j in range(n2): r[j] = arr[mid+1+j] i = j = 0 k = low while i< n1 and j < n2: if l[i] < r[j]: arr[k] = l[i] ...
9b29b745abc8bbd081b08ce878b4afc9f82558be
shashanka-adiga/Algorithims-and-datascrtures
/Array/min_jumps.py
698
3.71875
4
def min_jumps(arr): if arr[0] < 1: print(" end can not be reached") return length = len(arr) positions = [] count = 1 i = 0 while i < length: positions.append(arr[i]) reach = i + arr[i] if reach >= length - 1: print("minimum number of jumps:",...
074e9d00dbbdf8d7fa3b06acbe6600fc7e8bcb53
shashanka-adiga/Algorithims-and-datascrtures
/Array/ZeroSumPrefix.py
1,160
3.671875
4
def zero_sum_prefix(arr, num): summ = 0 count = 0 s = list() for value in arr: summ = summ + value if summ == num or (summ-num) in s: start = s.index(summ-num) + 1 end = arr.index(value) if start!= end: count += 1 print(...
4ca0163ec164fe6eb4042bf5b241feae6b7ea431
shashanka-adiga/Algorithims-and-datascrtures
/Trees/no_of_leaves.py
457
3.8125
4
class Tree: def __init__(self, key): self.val = key self.left = None self.right = None def no_of_leaves(root): if root is None: return 0 elif root.left is None and root.right is None: return 1 else: return no_of_leaves(root.left) + no_of_leaves(root.right...
a56506215e2c33c2a473eb546340e9e999ad2910
shashanka-adiga/Algorithims-and-datascrtures
/Trees/HeightOfBtree.py
366
3.78125
4
class Tree: def __init__(self, key): self.val = key self.left = None self.right = None def height(root): if root is None: return 0 return 1 + max(height(root.left), height(root.right)) root = Tree(10) root.left = Tree(8) root.right = Tree(9) root.left.left = Tree(6) root.l...
4c8d3b6ddc0559780ea0c478e7ee1a16b9a7b259
shashanka-adiga/Algorithims-and-datascrtures
/LinkedList/MergeSortedLL.py
1,381
4.0625
4
class LinkedList: def __init__(self, data): self.value = data self.next = None def append(self, head, data): if head is None: head = LinkedList(data) temp = head while temp.next is not None: temp = temp.next new_no...
6721cc95d7ef7369c794e261f1be6b1febd5e220
shashanka-adiga/Algorithims-and-datascrtures
/Array/PrefixSum.py
498
3.546875
4
# # def prefix_sum(arr, n, l): # summ = 0 # l[0] = arr[0] # for i in range(1, n): # l[i] = l[i-1] + arr[i] # for val in l: # summ = summ + val # print(summ) # # def array_queries(q, n): # li = [0]*(n+1) # l = [0]*(n+1) # for i in range(q): # left = int(input("left...
e0fa12c817653d1fe03f72c3751601ced04b7934
shashanka-adiga/Algorithims-and-datascrtures
/Array/LongestPalindromicSubstring.py
1,748
3.671875
4
# def is_palindrome(arr): # i = 0 # n = len(arr) # while i < (n-1-i): # if arr[i] != arr[n-i-1]: # return False # i+=1 # return True # # def lps(arr): # longest_string = [None] # n = len(arr) # max_length = 1 # length = 0 # for i in range(n): # for j in ...
85b7319bc24340a96ce0e3a97791d6eee2643c32
Syconia/Harrow-CS13
/Stacks.py
1,611
4.125
4
# Stack class class Stack(): # Put in a list and set a limit. If limit is less than 0, it's basically infinitely large def __init__(self, List, INTlimit): self.Values = List if INTlimit < 0: INTlimit = 99999 self.Limit = INTlimit # Set up pointer. It's set by list in...
bb4c2dd02b9cf38fc1e290835e8d30ca5118ac79
JoshTheBlack/Project-Euler-Solutions
/060.py
1,781
3.765625
4
# coding=utf-8 # The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. # For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four # primes wit...
26cd8c508f86fe5d40c43f0779aaca6d50bd4034
JoshTheBlack/Project-Euler-Solutions
/069.py
1,435
3.515625
4
# coding=utf-8 from comm import * def rprime(n): result = n p = 2 while p * p<= n : if n % p == 0 : while n % p == 0 : n = n // p result = result * (1.0 - (1.0 / float(p))) p = p + 1 if n > 1 : result = result * (1.0 - (1.0 / float(n))) ...
0224b42aae59121dbc3a9bcf9702a6ad5a5b42e2
JoshTheBlack/Project-Euler-Solutions
/053.py
327
3.515625
4
# coding=utf-8 from comm import * def combinations(n,r): return int(factorial(n)/(factorial(r)*factorial(n-r))) @timed def p53(): result = 0 for n in range(23,101): for r in range(2, n): if combinations(n,r) > 1000000: result += 1 return result if __name__ == "__main__": print...
c353be9014cb341a5a04e1f55ef53661f88175ef
JoshTheBlack/Project-Euler-Solutions
/075.py
1,584
4.125
4
# coding=utf-8 '''It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples. 12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17) 48 cm: (12,16,20) In contrast, some lengths of...
51a8e5c707f86cb5f96467b0f40f0a9a59523f81
JoshTheBlack/Project-Euler-Solutions
/015.py
480
3.5625
4
# coding=utf-8 # Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. # How many such routes are there through a 20×20 grid? from comm import timed def factorial(n): if n == 0: return 1 else: ret...
4bced541158d917e25a36147d0a1f46e3763cfa7
JoshTheBlack/Project-Euler-Solutions
/009.py
383
3.921875
4
# coding=utf-8 # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. from comm import timed @timed def p009(): for a in range(1,500): for b in range(1,500): c = (a**2 + b**2)**0.5 if c == int(c) and a + b + c == 1000: retu...
17dc5304ed5e97a2edb89f334e8c44e20e7ec691
praneethkumar-Sherla/Programming-Assignment
/Folder/1.Binary Tree.py
1,671
3.796875
4
class Node: def __init__(self, info): self.info=info self.left = None self.right = None self.level = None def _str_(self): return self.info class binarytree: def __init__(self): self.root = None def insert(self, val): if se...
dc3d8921f9cef7f758f67e53c686727d5371e53f
cmarquezvz/CarlosM
/quiz5.py
499
3.953125
4
op=0 print ("Lista de Supermercado\n") print ("1.\tAgregar elementos a su lista") print ("2.\tEliminar elementos de su lista") print ("3.\tVer elementos de su lista") print ("4.\tSalir") lista=[] while op<4: op=int (input("Ingrese su opcion a elegir\n")) if op==1: ele=input("Ingrese un elemento\n") ...
a1238f632d4b33271b6b793d359bbd43d163504a
normanalie/NSI-TicTacToe-974
/Game.py
2,052
3.609375
4
from head import * class Game: def __init__(self): self.board = [ [B, B, B], [B, B, B], [B, B, B] ] self.current_player = HUMAN self.wait_player = COMPUTER self.win_player = str() def get_board(self, i=None, j=None): if i...
ce5bb7af9fa3a0c1af436ef0f2b5431254b64b1e
dishantjain97/Assignment-3
/Python/Max_con_sum.py
312
3.953125
4
print("Enter all the numbers in the list in a single line :") num_list = [int(i) for i in input().strip().split()] max_here=0 max = num_list[0] for num in num_list : max_here+=num if max_here >max : max = max_here if max_here<0: max_here = 0 print("maximum consecutive sum of integers",max)
611a57ed519fe24b1246ef386987bd0963e08310
bounabyazid/Co-reference-Summarization-NLP
/Cataphora2.py
8,453
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 25 15:54:22 2018 @author: Yazid Bounab """ #https://www.geeksforgeeks.org/removing-stop-words-nltk-python/ #https://www.tutorialspoint.com/python/python_remove_stopwords.htm #https://pythonspot.com/nltk-stop-words/ import nltk import json from nlt...
43c0713678b3286bea79126a25c85590ac79b752
CottonVats/homework3
/fules1.py
1,688
3.6875
4
cook_books = [] with open('test.txt') as recipies: while True: ingridient_list = [] ingr_dicts_list = [] name = recipies.readline().strip() cook_book = {name:ingr_dicts_list} if not name: break ingr_num = int(recipies.readline().strip()) ...
e7e5ee7db39f783061416f85839d88fd644734f4
venkymullapudi/DevOps_SRE_Scripts
/Accurate_Experience.py
514
3.84375
4
import time from datetime import date,datetime #Add your date in the variable b #Output will be in the format ('11 Years', '0 Months', '9 Days') def convertSeconds(seconds): y_tmp = round(seconds/60/60/24/365.25,3) y=round(y_tmp) m_tmp = (y_tmp*12 - y*12) m=round(m_tmp) d_tmp = (y_tmp*12 - y*12)*3...
37a564699a7eb07fe4fa117bb9a61e168b11e5cb
CAM603/cs-interview-prep
/remove_nth.py
1,793
4.0625
4
# Given a linked list, remove the n-th node from the end of list and return its head. class Node(object): def __init__(self, val=0, next=None): self.val = val self.next = next node = Node(1) node.next = Node(2) node.next.next = Node(3) node.next.next.next = Node(4) node.next.next.next.next = Node(...
859f81c6d192efb47bbfa1dde199705e597c9607
corbinrobb/Sprint-Challenge--Data-Structures-Python
/names/names.py
2,599
3.578125
4
import time class BSTNode: def __init__(self, value): self.value = value self.left = None self.right = None # Insert the given value into the tree def insert(self, value): if self.value > value: if self.left is None: self.left = BSTNode(value) ...
0b80dbb1d72808a9ef1897f83f377cf41329046c
BDFD-Online-Project/Python-for-Everybody-Specialization-Coursera
/Using Python to Access Web Data/Assignment-Following Links in HTML Using BeautifulSoup.py
1,129
3.828125
4
''' Following Links in Python In this assignment you will write a Python program that expands on http://www.py4e.com/code3/urllinks.py. The program will use urllib to read the HTML from the data files below, extract the href= vaues from the anchor tags, scan for a tag that is in a particular position relative to th...
01c78c4f46961b640de13550d53a037932f6c4a0
jeffw17/PathfindingVisualizer
/node.py
2,117
3.75
4
import pygame import random class Node: """ Node class """ def __init__(self, position): """ Constructor for Node class :param position: Tuple[int] """ self.position = position self.f_score = 0 self.g_score = 0 self.h_score = 0 ...
c8509d347b9d8dce353f1e40f9ba2a1c4d3df4f2
RaviC19/Dictionaries_Python
/more_methods.py
625
4.375
4
# pop - removes the key-value pair from the dictionary that matches the key you enter d = dict(a=1, b=2, c=3) d.pop("a") print(d) # {'b': 2, 'c': 3} # popitem - removes and returns the last element (key, value) pair in a dictionary e = dict(a=1, b=2, c=3, d=4, e=5) e.popitem() print(e) # {'a': 1, 'b': 2, 'c': 3, 'd'...
841e2203b058b0cfa3f927b98951b9087fe47c9f
andreshugueth/holbertonschool-web_back_end
/0x00-python_variable_annotations/1-concat.py
217
3.65625
4
#!/usr/bin/env python3 """ function concat @str1: string @str2: string returns: a concatenated string """ def concat(str1: str, str2: str) -> str: """type-annotated function concat""" return f"{str1}{str2}"
f6b40ca9be853668b46d733217076ae3508f52c8
andreshugueth/holbertonschool-web_back_end
/0x00-python_variable_annotations/5-sum_list.py
317
3.609375
4
#!/usr/bin/env python3 """type-annotated function sum_list""" from typing import List def sum_list(input_list: List[float]) -> float: """type-annotated function sum_list Args: input_list (List[float]): List of floats Returns: float: sum as a float """ return sum(input_list)
db1cb46d4d913ab5345ec512bc09bd4e9bf08920
andreshugueth/holbertonschool-web_back_end
/0x04-pagination/0-simple_helper_function.py
457
3.6875
4
#!/usr/bin/env python3 """Simple helper function index range""" from typing import Tuple def index_range(page: int, page_size: int) -> Tuple[int, int]: """[summary] Args: page (int): [description] page_size (int): [description] Returns: Tuple[int, int]: particular pagination p...
54e4009374bef3816165b069358fb45a74a3da17
andreshugueth/holbertonschool-web_back_end
/0x00-python_variable_annotations/2-floor.py
209
3.96875
4
#!/usr/bin/env python3 """ function floor @n: float returns the floor of the float. """ def floor(n: float) -> int: """type-annotated function floor""" if n < 0: n = n * -1 return int(n)
37b9305eccf27ff0c85ed118bcbb90107f349b43
Jwbeiisk/daily-coding-problem
/jan-2021/Jan14.py
3,324
4.21875
4
#!/usr/bin/env python3 """ 14th Jan 2021. BONUS! Daily Coding Problem skipped an email through some glitch. I've made a sudoku solver instead here. """ """ Solution: We use backtracking to put in a possible value for an empty space and checking if it is a valid field. If true, we continue to the next em...
44291c2c7fe818202a9d424139eba73e90dfd5ce
Jwbeiisk/daily-coding-problem
/mar-2021/Mar15.py
1,643
4.4375
4
#!/usr/bin/env python3 """ 15th Mar 2021. #558: Medium This problem was asked by Google. The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method. Hint: The basic equation of a circle is x^2 + y^2 = r^2. """ """ Solution: We sample random points that would appear in the f...
c15c5d9f4dcefd405fa8a41fef7891d885cb2b3e
Jwbeiisk/daily-coding-problem
/jan-2021/Jan5.py
3,253
4.21875
4
#!/usr/bin/env python3 """ 5th Jan 2021. Medium This problem was asked by Yelp. The horizontal distance of a binary tree node describes how far left or right the node will be when the tree is printed out. More rigorously, we can define it as follows: The horizontal distance of the root is 0. The horizo...
f2c376ba14e0c328cc64f9985d080d4968a57431
Jwbeiisk/daily-coding-problem
/mar-2021/Mar10.py
1,667
4.5
4
#!/usr/bin/env python3 """ 10th Mar 2021. #553: Medium This problem was asked by Google. You are given an N by M 2D matrix of lowercase letters. Determine the minimum number of columns that can be removed to ensure that each row is ordered from top to bottom lexicographically. That is, the letter at each column is ...
14b70002c95cdd503190e523f840b543a272f481
Jwbeiisk/daily-coding-problem
/feb-2021/Feb17.py
1,784
4.40625
4
#!/usr/bin/env python3 """ 17th Feb 2021. #532: Medium This problem was asked by Google. On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i.e. bishops can attack through pieces. You are given N bishops, re...
f98b5090fbc532098ebbcd8026efae383bfcc507
Jwbeiisk/daily-coding-problem
/jan-2021/Jan30.py
1,092
4.34375
4
#!/usr/bin/env python3 """ 30th Jan 2021. #514: Medium This problem was asked by Microsoft. Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. ...
837bdd7af4a78c17327299417514c4407d4bb204
Jwbeiisk/daily-coding-problem
/feb-2021/Feb18.py
2,986
3.765625
4
#!/usr/bin/env python3 """ 18th Feb 2021. #533: Easy This problem was asked by Facebook. Boggle is a game played on a 4 x 4 grid of letters. The goal is to find as many words as possible that can be formed by a sequence of adjacent letters in the grid, using each cell at most once. Given a game board and a dictiona...
e08c9f11aab1e0131d5f37feeb01f6475ae6ec23
Jwbeiisk/daily-coding-problem
/feb-2021/Feb22.py
1,107
4.3125
4
#!/usr/bin/env python3 """ 22th Feb 2021. #537: Easy This problem was asked by Apple. A Collatz sequence in mathematics can be defined as follows. Starting with any positive integer: if n is even, the next number in the sequence is n / 2 if n is odd, the next number in the sequence is 3n + 1 It is conjectu...
10a5dcf874960d5b8065fc4470f175bf3bc310b6
Jwbeiisk/daily-coding-problem
/feb-2021/Feb24.py
1,059
3.984375
4
#!/usr/bin/env python3 """ 24th Feb 2021. #539: Easy This problem was asked by Pandora. Given an undirected graph, determine if it contains a cycle. """ """ Solution: BFS of a grid created from the list of edges gives us an easier way of determining if a graph is cyclic. """ class Graph: def __init__(self, e...
bfe6035e64dcdc3d45e3694923cadc17425dc6d9
Jwbeiisk/daily-coding-problem
/feb-2021/Feb11.py
1,376
3.984375
4
#!/usr/bin/env python3 """ 11th Feb 2021. #526: Easy This problem was asked by Yahoo. You are given a string of length N and a parameter k. The string can be manipulated by taking one of the first k letters and moving it to the end. Write a program to determine the lexicographically smallest string that can be cre...
dceffa86640e727cf46095103ef856ea465b9fbb
TFNeto/calculator_with_gui
/calc.py
8,835
3.515625
4
from tkinter import Tk, Label, Button, Entry, IntVar, END, W, E, StringVar class calcgui: def __init__(self, master): self.master = master self.total = 0 self.result = StringVar() self.totalstring = "0" self.parcel = "" self.number = 0 self.result.set(self.t...
0fd649d7ecf9ee81543769071ccc4bf4c23ee541
jesuspaleta/prueba_tecnica
/marcador.py
1,454
3.6875
4
class Marcador(object): def __init__(self): self.puntos = {'A': 0, 'B': 0} self.set_ganados = {'A': 0, 'B': 0} self.estado = 0 self.set_act = 1 self.juego_terminado = 0 def agrega_puntos(self, jugador, puntos): self.puntos[jugador] += ...
32bd2b08c8396082396f0e8306eca7f609143930
vaibbhav-kalra/Financial-Engineering
/Binary Search Tree.py
1,048
3.921875
4
#Search in BST def BST(root,key): if root is None or root.val == key: return root elif root.val < key: return BST(root.right,key) else: return BST(root.left,key) #Insertion in BST class Node: def __init__(self,key): self.left = None sel...