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
ac896f90c9213c8bee169ffd3fbc74a6b4dc15e3
ICS3U-Programming-JonathanK/Unit4-01-Python
/sum_of_numbers.py
1,257
4.40625
4
#!/usr/bin/env python3 # Created by: Mr. Coxall # Created on: Sept 2019 # Modified by: Jonathan # Modified on: May 20, 2021 # This program asks the user to enter a positive number # and then uses a loop to calculate and display the sum # of all numbers from 0 until that number. def main(): # initialize the loop c...
40c3562f1343fd9eab60a3a2a60c8378fd77c46a
garp55/RealPython
/sql/homew6cars.py
1,758
3.875
4
# INSERT Command with Error Handler # import the sqlite3 library import sqlite3 # create the connection object with sqlite3.connect("cars.db") as connection: c = connection.cursor() c.execute("DROP TABLE IF EXISTS orders") c.execute("""CREATE TABLE orders(Make TEXT, Model TEXT, Order_date DATETIME)""...
ca301924c252766ed2dedc1d84c21f6bc034edd8
baeseongsu/neural_programmer_iclr2016_implementation
/src/data_generators/question_generator.py
1,845
3.59375
4
""" This question generator currently generates only the following questions for the specified scenarios - Single column experiment: - sum - count - greater [number] sum Each function will return a tuple in the format: (question_string, answer) """ import random def generate_single_colu...
e811211d279510195df3bbdf28645579c8b9f6de
megler/Day8-Caesar-Cipher
/main.py
1,497
4.1875
4
# caesarCipher.py # # Python Bootcamp Day 8 - Caesar Cipher # Usage: # Encrypt and decrypt code with caesar cipher. Day 8 Python Bootcamp # # Marceia Egler Sept 30, 2021 from art import logo from replit import clear alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',...
a49e475673aca80e243ec4470cec9b98a66e4372
Telixia/leetcode-3
/Medium/0095-Unique Binary Search Trees II/Recursion.py
666
3.796875
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 generateTrees(self, n: int) -> List[TreeNode]: def helper(m: int, n: int) -> List[TreeNode]: ...
aa3d8000f0f08cde8d5f91a3815077103bf32213
Cabarne/NumberProvider
/app.py
957
3.59375
4
from NumberProvider import NumberProvider def positiveAction(number): print("Got an positive number >>>", number) def negativeAction(number): print("Got an negative number >>>", number) provider = NumberProvider() provider.whenPositive(positiveAction) provider.whenNegative(negativeAction) prov...
528af8c01eacc11530f15c90a29315866365c02a
jingkunchen/image_tools
/method/cluster.py
4,974
3.5625
4
import numpy as np import random import math random.seed(1) np.random.seed(1) """ 函数功能:选择初始中心点 points: 数据集 pNum: 数据集样本个数 cNum: 选取聚类中心个数 """ def initCenters(points, pNum, cNum): #初始中心点列表 centers = [] #在样本中随机选取一个点作为第一个中心点 firstCenterIndex = random.randint(0, pNum - 1) centers...
9f86f06c28faabfe75a466030e3295e0eb6fde3c
hikmatullah-mohammadi/python_matplot-tutorial
/matplot_subplote.py
1,099
3.703125
4
import numpy as np from matplotlib import pyplot as plt # our x values ages = np.arange(25, 36) # All developers' salary all_dev_salary = np.array([38496, 42000, 46752, 49320, 53200, 56000,\ 62316, 63928, 67317, 68748, 73752]) ##Python developers' salary py_dev_salary = np.array...
81822a456ea62002f89ec79e7ec8de159a6cd6fe
xuehui3/00_tensorflow
/面试题/丑数计算.py
1,865
3.609375
4
# def isUgly(self, num): # """ # :type num: int # :rtype: bool # """ # if num < 1: # return False # while num % 2 == 0 or num % 3 == 0 or num % 5 == 0: # if num % 2 == 0: # num //= 2 # elif num % 3 == 0: # ...
3ef69f8658812cf0ad75452b18906576778837ab
xuehui3/00_tensorflow
/面试题/矩阵旋转.py
1,165
3.515625
4
''' 写一个小程序,将形状位MxN的2维矩阵顺时针旋转K位 例如:将下面左边的 M=3 N=4 的矩阵,旋转 K=1位,得到右边3x4的矩阵 [[1, 2, 3, 4], [[10, 1, 2, 3], [10, 11, 12, 5], >>>> [9, 12, 11, 4], [9, 8, 7, 6]] [8, 7, 6, 5]] ''' import numpy as np # MxN 3x4 matrix = [[1, 2, 3, 4], [10, 11, 12, 5], [9, 8, 7, ...
ecd4c4395e7d0663c55c6db6fcf171712cd13d8a
litst/leetcode
/JumpGameII.py
536
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 03 14:13:32 2015 @author: yzy """ def subJump(nums,step,ans): maxStep = nums[0] for i in range(1,maxStep+1): if len(nums[i:]) == 1: ans.append(step+1) else: if i < len(nums) and nums[i] != ...
de40b66919ca9d821843eb1c3e9a9c6843afe5ac
hhf-hd/Deep-learning-schedule
/Python/eg/eg37.py
411
3.515625
4
#!/usr/bin/python3 def Func(): N =10 L = [] print("please input 10 numbers") for i in range(N): x = int(input()) L.append(x) for i in range(N): k = i minum = L[i] for j in range(i+1,N): if L[j] < minum: k = j minum ...
03839c78723e70f763d8009fea4217f18c3eff42
agustinaguero97/curso_python_udemy_omar
/ex4.py
1,624
4.15625
4
""""Your teacher asked from you to write a program that allows her to enter student 4 exam result and then the program calculates the average and displays whether student passed the semester or no.in order to pass the semester, the average score must be 50 or more""" def amount_of_results(): while True: t...
7be5665d75207fd063846d31adfc0012aaeee891
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/quick_sort.py
512
4.21875
4
"""Example of quick sort using recursion""" import random from typing import List def quick_sort(data: List[int]) -> List[int]: if len(data) < 2: return data pivot, left, right = data.pop(), [], [] for item in data: if item < pivot: left.append(item) else: ...
ee7658e97cca85eba4ad74e159317abf372dd9e7
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/memory_allocation.py
662
3.640625
4
""" List allocation with teh same value using different techniques Output: first: 0.717055 second: 1.021743 third: 0.046112 forth: 0.005384 """ from timeit import timeit from itertools import repeat import numpy SIZE = 10000 INIT_VALUE = 0 def first(): """Using itertools.repeat""" return [x for x in repe...
5783a9475fb0cfc254b115e15e390a0a07ff05e6
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/heap.py
3,453
4.25
4
""" Heap (min-heap) implementation example """ from random import sample HEAP_SIZE = 20 class EmptyHeapError(Exception): def __init__(self): super().__init__("No elements in the heap") class Heap: def __init__(self): self.__heap = [0] @property def size(self) -> int: retu...
1c45df9c8c8efcbf2e8d61f00494b0940415055b
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/max_sum_subarray.py
696
3.90625
4
"""Maximum sum subarray problem. In the array find subarray with the max value. """ from typing import List def max_sum_subbarray(data: List[int]) -> int: current_max = max_value = data[0] for i in range(1, len(data)): current_max = max(current_max + data[i], data[i]) max_value = max(max_val...
bc6ae6b22b1655f74273b8e90234a64224cafab3
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/grouper.py
317
4.09375
4
""" Groups list of items in tuples of size n """ from typing import Iterable, Any, Tuple def grouper(data: Iterable[Any], n: int) -> Iterable[Tuple[Any]]: iters = [iter(data)] * n return zip(*iters) if __name__ == "__main__": print(list(grouper(range(9), 3))) # [(0, 1, 2), (3, 4, 5), (6, 7, 8)]
762d76a11f5bc7f780585d8a1f10bb32644223ad
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/producer_consumer.py
915
3.984375
4
""" Producer - Consumer (pub-sub) example """ import threading from queue import Queue from time import sleep from random import random def producer(q, n): """Generates fibonacci number and put it in queue.""" a, b = 0, 1 while a <= n: q.put(a) print(f"Producer: {a}") sleep(random...
ea235c2fd7caa1b5e0480457833099746d0666b6
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/is_bst.py
1,200
3.875
4
"""Checks if Binary Search Tree (BST) is balanced""" from __future__ import annotations import sys from dataclasses import dataclass from typing import Optional MAX_VALUE = sys.maxsize MIN_VALUE = -sys.maxsize - 1 @dataclass class Node: value: int left: Optional[Node] right: Optional[Node] @propert...
57918b350250791dd1b4fc796c5c6539a3f3ece3
sandeepkumar17212/texigroupapp
/caller.py
100
3.546875
4
def printname(name): print("my name is "+name) def addition(a,b,c): d=a+b+c print(d)
ac2df7a40f380c483abdff60c6d20a90fe6d74e3
metalauren/InsightCodingChallenge
/src/insightsource.py
1,761
3.796875
4
tweetfile = open("tweet_input/tweets.txt", "r") # open file alltweets = tweetfile.read() # read the file tweets = alltweets.splitlines() # a list where each element is an tweet runningmedians = [] wordsintweet = [] tweetdict = {} def median(x): x.sort() mid = len(x) // 2 if len(x) % 2: return ...
4e5596e77d9208a82a94e674f66464987144e8d0
lakshay-saini-au8/PY_playground
/hackerrank/python/map_lambda.py
324
3.953125
4
# cube = lambda x: x*x*x def cube(x): return x*x*x def fibonacci(n): # return a list of fibonacci numbers res = [] if n > 2: res = [0, 1] for i in range(2, n): res.append(res[i-2]+res[i-1]) elif n == 1: res = [0] elif n == 2: res = [0, 1] return ...
818bf1acf02cd1170b3c19290fcb10151599053e
lakshay-saini-au8/PY_playground
/hackerrank/ds/Array/left_rotation.py
264
3.9375
4
# https://www.hackerrank.com/challenges/array-left-rotation/problem def rotateLeft(d, arr): # Write your code here if len(arr) == d: return arr else: arr1 = arr[0:d] arr2 = arr[d:] arr2.extend(arr1) return arr2
7d3a0be5b655e5b8dd2fd8dbd1ea768ff921b2a0
lakshay-saini-au8/PY_playground
/hackerrank/ds/LinkedLists/find_merge.py
461
3.890625
4
# https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists/problem?isFullScreen=true # sol1 def findMergeNode(head1, head2): temp1 = head1 while temp1 is not None: temp2 = head2 while temp2 is not None: if temp1 == temp2: print("hello") ...
021b2c9563dd6903672c9ca23ecce35371e49ddc
lakshay-saini-au8/PY_playground
/hackerrank/ds/LinkedLists/del_at_pos.py
507
3.828125
4
# https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list/problem # # For your reference: # # SinglyLinkedListNode: # int data # SinglyLinkedListNode next # # def deleteNode(head, position): currentNode = head if position == 0: head = head.next currentNode.next = None ...
7b8a4d89da37c947909b393a8a957cf759a4d7cc
lakshay-saini-au8/PY_playground
/random/sorting.py
1,254
3.765625
4
# def merge(left, right, a): # i = 0 # j = 0 # k = 0 # while i < len(left) and j < len(right): # if left[i] > right[j]: # a[k] = right[j] # k += 1 # j += 1 # else: # a[k] = left[i] # k += 1 # i += 1 # while i < ...
ddaf839fe211a052a944aefe908e03e3c74665f0
lakshay-saini-au8/PY_playground
/DSAlgo/merge_sort.py
641
3.84375
4
def merge(L, R, arr): i = 0 j = 0 k = 0 l = len(L) r = len(R) while i < l and j < r: if L[i] < R[j]: arr[k] = L[i] i = i+1 else: arr[k] = R[j] j = j+1 k = k+1 while(i < l): arr[k] = L[i] i += 1 k ...
4059405985761b3ae72fff1d6d06169cc35b1823
lakshay-saini-au8/PY_playground
/random/day03.py
678
4.46875
4
#question ''' 1.Create a variable “string” which contains any string value of length > 15 2. Print the length of the string variable. 3. Print the type of variable “string” 4. Convert the variable “string” to lowercase and print it. 5. Convert the variable “string” to uppercase and print it. 6. Use colon(:) operator to...
ddafce18cadb24e46ae3e2c5ede9e5aa5f07660f
lakshay-saini-au8/PY_playground
/hackerrank/python/string_validator.py
402
3.75
4
# que https://www.hackerrank.com/challenges/string-validators/problem?isFullScreen=true #solution if __name__ == '__main__': s = input() print(any([True for c in s if(c.isalnum())])) print(any([True for c in s if(c.isalpha())])) print(any([True for c in s if(c.isdigit())])) print(any([True for c i...
1c682af5973580973d0c06ab1c46c413e1356a64
lakshay-saini-au8/PY_playground
/hackerrank/algorithm/string/sepreate_the_number.py
636
3.9375
4
# https://www.hackerrank.com/challenges/separate-the-numbers/problem?isFullScreen=false # Complete the separateNumbers function below. def separateNumbers(s): if len(s) == 1: print("NO") return else: # Half iter no need to go further for i in range(1, len(s)//2 + 1): ...
267b7a16ad09168d324a6c235154d9343517bf8e
lakshay-saini-au8/PY_playground
/hackerrank/algorithm/string/panagrams.py
409
3.9375
4
# Complete the pangrams function below. def pangrams(s): list_check = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"] for i in s: if i.lower() in list_check: list_check.remove(i.lower()) ...
6a29cb24698e9390ac9077d431d6f9001386ed84
lakshay-saini-au8/PY_playground
/random/day26.py
1,164
4.28125
4
# Write a program to find a triplet that sums to a given value with improved time complexity. ''' Input: array = {12, 3, 4, 1, 6, 9}, sum = 24; Output: 12, 3, 9 Explanation: There is a triplet (12, 3 and 9) present in the array whose sum is 24. ''' # brute force apporach def triplet(arr, sums): n = len(arr) ...
d988704e370a7b20970ec30934fe78bffc09ce86
lakshay-saini-au8/PY_playground
/hackerrank/python/iteratror.py
301
3.578125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import * n = int(input()) arr = input().split() k = int(input()) count = 0 all_combination = list(combinations(arr, k)) for i in all_combination: if 'a' in i: count += 1 print(count/len(all_combination))
bd315dc79ea21ff628a4cb3f36df0f9bacde0068
lakshay-saini-au8/PY_playground
/hackerrank/algorithm/implementation/cat_and_a_mouse.py
339
3.828125
4
# https://www.hackerrank.com/challenges/cats-and-a-mouse/problem?isFullScreen=true # Complete the catAndMouse function below. def catAndMouse(x, y, z): catA_dis = abs(z-x) catB_dis = abs(z-y) if catA_dis > catB_dis: return "Cat B" elif catA_dis < catB_dis: return "Cat A" else: ...
a047f3b6df7cb746cb75a5dfac93b092bf4daa54
lakshay-saini-au8/PY_playground
/leetcode/448_array.py
663
3.828125
4
# que https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/solution/ # solution 1 def findDisappearedNumbers(arr): n = len(arr) arr = list(set(arr)) for i in range(1, n+1): if(i in arr): arr.remove(i) else: arr.append(i) return arr print(find...
e6ea83c9370f40835f317bec49f30993e520933e
lakshay-saini-au8/PY_playground
/hackerrank/ds/stack/balanced_brackets.py
635
3.96875
4
# https://www.hackerrank.com/challenges/balanced-brackets/problem # Complete the isBalanced function below. def isBalanced(s): s1 = [] for i in range(len(s)): if len(s1) == 0: s1.append(s[i]) else: check = None if s1[-1] == "(": check = ")" ...
17d30a1481df46f1905e09f47d1c5cc552f22947
rkapali/python_assignment
/set1/pywc
216
3.53125
4
#!/usr/bin/python import sys, gzip filename = str(sys.argv[1]) if filename.endswith('gz'): f = gzip.open(filename,'r') else: f = open (filename,'r') counter = 0 for line in f: counter += 1 print counter f.close()
c1e4c5da5de11fb4ba05e69e211688738c610028
yvonneyeh/ufo-hangman
/game.py
6,704
3.65625
4
import re import random import string from ufo import ufo ALPHABET = set(string.ascii_uppercase) # all valid playable letters # NOUN LIST noun_file = open("nouns.txt", "r") content = noun_file.read() noun_list = content.split("\n") noun_file.close() # MESSAGE LIST msg_file = open("messages.txt", "r") content = msg_...
65d5d74353e6bb63a1817367f631e996e9cc001a
Niraj-Suryavanshi/Python-Basic-Program
/10.chapter/13_pr_05.py
830
3.78125
4
class Train: def __init__(self,name,fare,seats): self.name=name self.fare=fare self.seats=seats def getStatus(self): print("********") print(f"The name of the train is {self.name}") print(f"The fare of the train is {self.fare}") print("********") def...
fce872e76b3da0255f503a85d718dc36fd739dd6
Niraj-Suryavanshi/Python-Basic-Program
/7.chapter/12_pr_03.py
224
4.125
4
num=int(input("Enter a number: ")) prime=True for i in range(2,num): if(num%i==0): prime=False break if prime: print("Number is prime") else: print("Number is not prime")
674befa989acb67aefcaf986f897fe3ec8b52c60
Niraj-Suryavanshi/Python-Basic-Program
/2.chapter/06_pr_02_remainder.py
36
3.828125
4
a=10 b=5 print("remainder is:",a%b)
3e8ad597bfff688ebb3b2bd482434ce00286fbdb
Niraj-Suryavanshi/Python-Basic-Program
/3.chapter/03_string_functions.py
377
4.03125
4
story='''hello ji kaise ho sare this is love babbar to chaliye shuru krte hai''' # print(story) # string fuctions: # print(len(story)) # print(story.endswith("hai")) # print(story.count("a")) # print(story.capitalize()) # print(story.find("love")) # print(story.replace("love babbar","Niraj Suryavanshi")) ...
1c4cea7b464fd5f0c73acb9df338bf93edfd73a0
Niraj-Suryavanshi/Python-Basic-Program
/7.chapter/o2_quick_quiz.py
90
3.578125
4
# i=1 # while i<51: # print(i) # i=i+1 i=0 while i<5: print("Harry") i=i+1
8d15cc01aa2db01da9ea285fc234cae188e5c0cf
Niraj-Suryavanshi/Python-Basic-Program
/3.chapter/06_pr_02.py
210
4.40625
4
letter='''Dear <|Name|> you are selected date: <|date|>''' name=input("Enter your name:") date=input("Enter a date:") letter=letter.replace("<|Name|>",name) letter=letter.replace("<|date|>",date) print(letter)
078b45bb79ee6d04eae262d3a75dd1b09c22c04f
Niraj-Suryavanshi/Python-Basic-Program
/4.chapter/06_pr_o1_store_fruit.py
288
3.84375
4
f1=input("Enter fruits name 1: ") f2=input("Enter fruits name 2: ") f3=input("Enter fruits name 3: ") f4=input("Enter fruits name 4: ") f5=input("Enter fruits name 5: ") f6=input("Enter fruits name 6: ") f7=input("Enter fruits name 7: ") myfruits=[f1,f2,f3,f4,f5,f6,f7] print(myfruits)
3fc8402b189c340ec3497eb455752f33a1bc5b16
Niraj-Suryavanshi/Python-Basic-Program
/3.chapter/02_string_slicing.py
232
3.953125
4
# greeting="good morning," # name="Niraj"; # # print(type(name)) # # Concatenating string # c= greeting + name; # print(c) name="nirajisgoodperson" # print(name[:5]) # c=name[-3:-1] # c=name[-5:] # print(c) d=name[0::3] print(d)
d86dd844f971803b4a1a4d60efd18a8281dd21c5
Niraj-Suryavanshi/Python-Basic-Program
/5.chapter/02_dictionary_methods.py
519
3.796875
4
mydict={ "harry":"coder of youtube", "niraj":"student of SIT", "marks":[43,3,33,3], "anotherdictionary":{ "harry":"youtuber" } } print(list(mydict.keys())) print("\n") print(mydict.values());print("\n") print(mydict.items()) # print the key value for all content of value updateDict={ "lo...
cf8fc3a611222b927c9e722b62055a77ae89a005
chanchiyakishan/challenges
/permu_and_name.py
202
3.640625
4
from itertools import permutations com = input().split(" ") li = list(permutations(com[0], int(com[1]))) for i in range(len(li)): li[i] = "".join(li[i]) li.sort() for x in li: print(*x, sep="")
250cab70a73f6ec84677781b3b2917f99bf4882e
ALMR94/practica-2-python
/6- Pedir un numero de 1-999.py
236
3.921875
4
# -*- coding: cp1252 -*- print "Dime un nmero de como mximo 3 cifras:" a= int(raw_input()) if a<1000 and a>0: print "El nmero",a,"es vlido." else: print "El nmero introducido no es vlido o no es de 3 cifras."
399b6519175e39f500bb34c25ac6647a1f894368
stqc/LogisticRegression_sgd
/LogisticRegressionSGD.py
1,727
3.984375
4
class LogisticRegression: ''' datax = Independent Variable datay = Dependent Variable alpha = Learning rate train(iterations=10) ---------------------------------------------------- Train method takes one argument as input i.e itertions default = 10 predict(x) ---...
a6e95395b141c86ad404b5d8690c07953d2fabad
Mihir-AI/Project
/Dictionary.py
778
3.671875
4
import json from difflib import get_close_matches data=json.load(open("data.json")) def translate(w): w=w.lower() if w in data: return data[w] elif len(get_close_matches(w,data.keys()))>0: yn=input(f"did u mean {get_close_matches(w,data.keys())[0]} instead?Enter Y or N:") if yn=="...
deb2282cae83b4fdd82cf34d6afd4911fe8a50b4
montlebalm/Scrabbler
/scrabbler/player/wordfinder.py
1,918
3.609375
4
import itertools import scrabbler.dictionary class WordFinder(): def get_matches(self, string, constraints=[]): """Get all hashed that can be made from any combination of letters in the provided string""" real_keys = self.__get_real_keys(string) matches = [] if real_keys: # Find all the real hashed th...
98358a5dd94f1a18198c4935c554420bc3ba10dc
ramya-creator/InnovationPython_Ramya
/Task7.py
3,794
4
4
"""1. Write a program that calculates and prints the value according to the given formula: Q= Square root of [(2*C*D)/H] Following are the fixed values of C and H: C is 50. H is 30. D is a variable whose values should be input to your program in a comma-separated sequence. """ import math C = 50 H = 30 result = [] D = ...
f208db323af29ccf0111a0d5a54ecc60177c0676
ramya-creator/InnovationPython_Ramya
/Task2_Operators_DecisionMaking_py_files/4_question.py
170
3.9375
4
#4_question while 1: i = int(input("Enter an integer: ")) if i < 0: print("Its Over") break else: print("Going good") continue
7330dc0f3f50ec43849ca879fe2e9e8907ecafb1
jiwoooooo/ibk
/mycode/first.py
398
3.609375
4
def add(n1,n2): #pass return n1+n2 print(add(10,20)) #실행 단축키 ctrl shift f10 add2 = lambda n1,n2 : n1+n2 print(type(add2)) print(add2(100,200)) class USer: #생성자 선언 def __init__(self, name): self.name = name #toString() def __str__(self): return self.name #객체 생성 user = User(...
91c554b28d22ec7518eb34b46a7f2fa53cc559b6
jimbrayrcp/turtler
/turtler/car_manager.py
1,912
3.859375
4
# ################################ # Copyright (c) 2021 Jim Bray # All Rights Reserved # ################################ from turtle import Turtle import random COLORS = ["red", "orange", "khaki3", "green", "blue", "purple", "LightBlue3"] STARTING_MOVE_DISTANCE = 5 MOVE_INCREMENT = 10 class CarManager: ...
953ed440d979b8d630b868bcbd004315bb14e26e
merrittd42/HackerRankCode
/PythonTut/Intro/ex6.py
65
3.609375
4
N = int(input()) x = 0 while(x<N): print(x*x) x = x + 1
d72a4781665603d1046ce3d833fd57c18a816862
rahulk007/war
/war.py
3,478
3.703125
4
suits=['hearts','diamonds','spades','clubs'] ranks=['two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen'] values={'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9,'ten':10,'eleven':11,'twelve':12,'thirteen':13,'fourteen':14} # each car is descr...
a8e4037f1cd7ccef00eba8602f996fc64f08caa0
tjuva3/Prepoznava-stevil
/main.py
2,288
3.625
4
from keras.models import Sequential #Archytecture for our network from keras.layers import Flatten, Dense #Layers for our neural network from keras.datasets import mnist #handwritten images 28x28px from keras.utils import normalize import numpy as np (xTrain, yTrain), (xTest, yTest) = mnist.l...
12b3ce649326dd58dfc08086f8cc5ef644f3453d
rpathak38/OpenCV-Tutorial
/image_gradients_and_canny_edge_detection.py
1,431
3.6875
4
import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread("sudoku.png", cv2.IMREAD_GRAYSCALE) img = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 101, 2) # whenever we encounter an edge in a picture, there is a great change in the intensity. For example, c...
0f36de4072a59c3d1ce392a3198c9ddaef3e28c2
Flor246/PYTHONEF
/MODULO1/prob2.py
373
3.796875
4
#2 problema de cuenta de ahorros dinero=float(input('Ingrese la cantidad de dinero: ')) interes=0.04 año1=round(dinero*(1+interes),2) año2=round(año1*(1+interes),2) año3=round(año2*(1+interes),2) print('Ahorro del primer año es: {}'.format(año1)) print('Ahorro del segundo año es: {}'.format(año2)) print('Ahorro...
aa8aaf2c9b9c8b82b4e4fb2a124554586de37a00
aasthahooda811/python-basics
/Assignment24.py
209
3.875
4
''' Created on 26-Jan-2018 @author: Vijay ''' string1 = input("Enter a string") count = 0; c = '' for x in string1: if(x.isupper()): count += 1 c = c + x print(count) print(c)
c383ed3dddec3b4adca2f2e176b3c2db9dea6ae3
Jennycbx/Making_tests_homework
/start_code/tests/compare_test.py
925
3.796875
4
import unittest from src.compare import * # from src.compare import colour_of_apple class TestCompare(unittest.TestCase): def setup (self): self.twin_1 = ("Jenny", 30, 5.5) self.twin_2 = ("Claire", 30, 5.6) def test_compare_3_1_returns_3_is_greater_than_1(self): self.assertEqual("3 is...
52315cfb7ebbe5f6d9d03e0b1f70c9a681305e08
kcam100/DataVisualization
/titanic_cleaning.py
1,900
3.671875
4
# -*- coding: utf-8 -*- import pandas as pd # Read in titanic csv titanic = pd.read_csv('titanic-data.csv') # View first 5 rows of dataframe titanic.head() # Delete all unnecessary columns titanic_clean = titanic.drop(['PassengerId','Name','Ticket','Cabin', 'Fare','Embarked', 'Parch', ...
0da4f9a8d4ff1332d1039ab95d595b2172b05213
Chofito/ejercicios-1-2
/Solutions.py
1,458
3.53125
4
def task_1(a_sacar): pass # Creo que era mas sencillo el del archivo de texto triangle.txt xD def calcular_5(cantidad): return ["5C" for i in range(int(cantidad * 20))] def calcular_10(cantidad): cantidad_10 = ["10C" for i in range(int(cantidad * 10))] sobrante = cantidad % 0.1 return [cantidad, s...
83838f103161cfc3f71bbb1865a9052bef65036b
caketi/cake
/heap_sort_objects.py
973
4
4
from heapq import heappop, heappush class Movie: def __init__(self, title, year): self.title = title self.year = year def __str__(self): return str.format("Title: {}, Year: {}", self.title, self.year) def __lt__(self, other): return self.year < other.year def __gt__(s...
08703d48dac44c29429f1dc5af0ac7de2d41bf2d
huegli/PythonWorkOut
/chap03/mysum.py
184
3.609375
4
def mysum(*items): output = () if not items: return () else: output = items[0] for item in items[1:]: output += item return output
af020fb179051849f8489361c2d2aa0d0b2b0d3b
huegli/PythonWorkOut
/chap01/guess.py
430
4.09375
4
import random number = random.randint(0, 100) while guess := input("Enter a number guess: "): if not guess.isdecimal(): print("Please enter a number from 0 - 100") else: guess = int(guess) if guess < number: print(f"{guess} is too low") elif guess > number: ...
729817cb29e8b7f6cbe1a7e39adfb394ac593bbd
huegli/PythonWorkOut
/chap01/hexadecimal.py
410
3.53125
4
def hex_output(hexnum): decnum = 0 for power, num in enumerate(reversed(hexnum)): try: decnum += 16**power*int(num, 16) except ValueError: return -1 return decnum if __name__ == "__main__": print(f"0x50 is {hex_output('50')}") print(f"0x20 is {hex_output('...
2686affb610a772f54c93b3730ce22d11655d317
JoyDajunSpaceCraft/leetcode_job
/hash/549-最长和谐子串.py
1,255
3.5
4
# 594. 最长和谐子序列 # 和谐数组是指一个数组里元素的最大值和最小值之间的差别正好是1。 # 现在,给定一个整数数组,你需要在所有可能的子序列中找到最长的和谐子序列的长度。 # 示例 1: # 输入: [1,3,2,2,5,2,3,7] # 输出: 5 # 原因: 最长的和谐数组是:[3,2,2,2,3]. class Solution: def findLHS(self, nums: List[int]) -> int: res = 0 num = len(nums) for i in range(num): count...
ecf9a867a183ad98ccb14b147e458a338a9ff33c
JoyDajunSpaceCraft/leetcode_job
/tree/1382. 将二叉搜索树变平衡.py
1,496
3.78125
4
# 1382. 将二叉搜索树变平衡 # 给你一棵二叉搜索树,请你返回一棵 平衡后 的二叉搜索树,新生成的树应该与原来的树有着相同的节点值。 # 如果一棵二叉搜索树中,每个节点的两棵子树高度差不超过 1 ,我们就称这棵二叉搜索树是 平衡的 。 # 如果有多种构造方法,请你返回任意一种。 # 示例: # 输入:root = [1,null,2,null,3,null,4,null,null] # 输出:[2,1,3,null,null,null,4] # 解释:这不是唯一的正确答案,[3,1,4,null,2,null,null] 也是一个可行的构造方案。 # 提示: # 树节点的数目在 1 到 10^4 之间。 # 树节点的值互不...
af5f80868ba24a2e59bf79f9977ac3f2635450dd
JoyDajunSpaceCraft/leetcode_job
/array/1038. 从二叉搜索树到更大和树.py
1,243
3.609375
4
# 1038. 从二叉搜索树到更大和树 # 给出二叉 搜索 树的根节点,该二叉树的节点值各不相同,修改二叉树,使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 # 提醒一下,二叉搜索树满足下列约束条件: # 节点的左子树仅包含键 小于 节点键的节点。 # 节点的右子树仅包含键 大于 节点键的节点。 # 左右子树也必须是二叉搜索树。 # 示例: # 输入:[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8] # 输出:[30,36,21,36,35,26,15,null,null,null,33,null,null,null,8] # 提...
952075fc18f7754d30a41695e41f630c70141168
jdalzatec/EulerProject
/Problem_34/main.py
449
3.6875
4
import math def main(): limit = 10**5 #This number is a guess total_sum = 0 for i in range(1,limit+1): num = str(i) suma = 0 for j in range(len(num)): factorial = math.factorial(int(num[j])) suma += factorial if suma == i: print(i, True) ...
e0239d0f067404e6d177a30341328d2ecd00c0c1
jdalzatec/EulerProject
/Problem_20/main.py
225
3.625
4
from functools import reduce from math import factorial def main(): num = 100 value = factorial(num) suma = reduce(lambda x, y: int(x) + int(y), str(value)) print(suma) if __name__ == '__main__': main()
c76e5f3aa5fbca04d7a4844a48b3303bb9999156
jdalzatec/EulerProject
/Problem_8/main.py
523
3.6875
4
import numpy def function(number, i, len_adjacent): result = 1 for j in range(len_adjacent): if j + i < len(number): result *= int(number[j + i]) else: return 0 return result def main(): number = open("data.dat", mode = "r") number = number.read() ...
4e5e21db55e6653b725c93f9a80ebfa607952ec0
faraaz-ahmed/Competitive-Coding
/DBS/minimum_sum.py
643
3.546875
4
def round(num): if num % 2 == 1: return int((num + 1)/2) else: return int(num/2) def brute_minSum(arr, k): sum_ = sum(arr) for i in range(0, k): sum_ -= round(max(arr)) arr[arr.index(max(arr))] = round(arr[arr.index(max(arr))]) print(arr) return sum(arr) # def m...
5526dcd35ecf66533f5414ab4604752ce258adcd
rwwinfree/udemy_deep_learning_A-Z
/Deep_Learning_A_Z/Volume_1-Supervised_Deep_Learning/Part 1 - Artificial Neural Networks (ANN)/Section 4 - Building an ANN/Artificial_Neural_Networks/ann-rw.py
5,372
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 25 13:26:26 2018 @author: ryanwinfree """ # Artificial Neural Network # Installing Theano # pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git # Installing Tensorflow # pip install tensorflow # Installing Keras # pip install ...
cc70946e288aef2c09fe0a9b56bc4f38b88a2069
jeremie1207/coffee_machine_python_procedural
/main.py
5,291
4.15625
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "c...
f9d978e5e18f5dada8acdce5f2d46650dc843c3c
flerdacodeu/CodeU-2018-Group8
/aliiae/assignment3/tests_trie.py
1,088
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import unittest from trie import Trie class TestTrie(unittest.TestCase): def setUp(self): self.word_list = 'CAR, CARD, CART, CAT'.lower().split(', ') self.dictionary = Trie(self.word_list) def test_trie_empty_word(self): self.assertFals...
3e12235cd20dfbfbc25f8f5505c87793a71f51af
flerdacodeu/CodeU-2018-Group8
/ibalazevic/assignment3/q1.py
6,395
4.25
4
from collections import defaultdict import unittest def find_valid_words(grid, prefix_dict): """ A method that finds all the valid words from a dictionary in a grid of letters. The assumption is that all the letters in the grid are lowercase. - grid - list of lists, a 2D grid of characters ...
d8931aab5a51da776af9af705b12e6f3d90c175a
flerdacodeu/CodeU-2018-Group8
/group/assignment6/parking_lot.py
7,807
4.03125
4
# -*- coding: utf-8 -*- """Computes a sequence of moves from the start state to the target state. Uses: - Data structure which represents the start and target states which support validation and swapping functionality (see class ParkingState); - Representation of the sequence of moves (List[MoveType]). Compu...
69f491abbf9b757d6dc5b7fe6d5e7cd925785389
flerdacodeu/CodeU-2018-Group8
/cliodhnaharrison/assignment1/question1.py
896
4.25
4
#Using Python 3 import string #Input through command line string_one = input() string_two = input() def anagram_finder(string_one, string_two, case_sensitive=False): anagram = True if len(string_one) != len(string_two): return False #Gets a list of ascii characters alphabet = list(string.pr...
c425fd70a75756fa84add2f21f7593b8e91b1203
flerdacodeu/CodeU-2018-Group8
/aliiae/assignment3/trie.py
2,519
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Optional follow-up​: Implement a dictionary class that can be constructed from a list of words. A dictionary class with these two methods: * isWord(string): Returns whether the given string is a valid word. * isPrefix(string): Returns whether the given string is a pr...
ea2263a284564b3074b19aca5ce03c36909f1fda
flerdacodeu/CodeU-2018-Group8
/TatjanaCh/assignment4/utils.py
3,632
4.15625
4
class DisjointSet: """ Implements a class DisjointSet, which represents a set of disjoint sets. Two sets are disjoint if they have no elements in common. It uses dict to speed up finding an element of the subsets. Attributes: disjointSets List of the disjoint sets. element_s...
6ddf930b444a33d37a4cc79308577c45cf45af96
Saraabd7/Python-Eng-54
/For_loops_107.py
1,117
4.21875
4
# For loops # Syntax # for item in iterable: mean something you can go over for e.g: list # block of code: import time cool_cars = ['Skoda felicia fun', 'Fiat abarth the old one', 'toyota corola, Fiat panda 4x4', 'Fiat Multipla'] for car in cool_cars: print(car) for lunch_time in cool_cars: print(car) ...
5cd8799dc1b3ca6b5458338a02a4b118e959ec85
Saraabd7/Python-Eng-54
/103_integers.py
416
3.984375
4
# Numerical Types # Integers and Float, Complex, Numbers , big ints # Integers # Full Numbers print(10) print(type(10)) print(type('10')) #Float #decimal numbers print(10.0) print(type(10.0)) #They can be used together print(10/3) print(10 * 10)) #Add print(3 + 4) # Subtract print (3 - 4) #divide print (10/2) #...
2aabcb1ef493e647d36f9ee49d7ea3785fafcedb
NaveedShaikh78/system-equip
/treadexample.py
315
3.9375
4
import thread import time # Define a function for the thread def print_time(): time.sleep(5) print "%s: %s" % ( time.ctime(time.time()) ) i=0; while i < 3: # Create two threads as follows try: thread.start_new_thread( print_time ) print "end thread" except: print "Error: unable to start thread" i=i+1
000bb0f9ab4b34e8278d5df3c797d2723028066b
nifemiojo/Algorithms
/Arrays/NewYearChaos/src/test.py
941
3.65625
4
import unittest from .solution_inefficient import minimumBribes class TestMinimumBribes(unittest.TestCase): def test_one_bribe(self): q = [1, 2, 4, 3] number_of_bribes = minimumBribes(q) self.assertEqual(number_of_bribes, 1) def test_two_single_bribes(self): q = [1, 2, 4, 3, 6...
85033f9d0938a1a5af4ae5c241fdf9b530565471
nifemiojo/Algorithms
/dismath/recursion/coin_problem/change.py
436
3.734375
4
def change(amount): assert (1000 >= amount >= 24) if amount == 24: return [5, 5, 7, 7] elif amount == 25: return [5, 5, 5, 5, 5] elif amount == 26: return [7, 7, 7, 5] elif amount == 27: return [5, 5, 5, 5, 7] elif amount == 28: return [7, 7, 7, 7] co...
949e1de8aaf4bc99fc04ac991c936d9455640730
monlie/LeetCode
/263.py
354
3.546875
4
class Solution: def isUgly(self, num): """ :type num: int :rtype: bool """ d = [2, 3, 5] while 1: f = num for i in d: if num % i == 0: num = num//i if f == num: break ...
3eaaaad898909b745a4e4d1c986e6ba5c4fbe049
monlie/LeetCode
/58.py
324
3.53125
4
class Solution: def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ length = 0 for char in s[::-1]: if char == ' ' and length: break if char != ' ': length += 1 return length ...
c5c272c639aef7f306df597af4a1d405d4464108
monlie/LeetCode
/43.py
328
3.53125
4
class Solution: def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ s = 0 for n, i in enumerate(num1[::-1]): for m, j in enumerate(num2[::-1]): s += int(i)*10**n * int(j)*10**m return str(s) ...
3e3961e8cadc01e0b73ed1e5d1846538d4a9ef36
monlie/LeetCode
/46.py
622
3.71875
4
from copy import deepcopy class Solution: def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ def permute_iter(n): if n: last = permute_iter(n-1) p = nums[n] new = [] ...
2d56e3b4cd768ff456a090bd782bd4989c2e3c86
techacademybd/python-automate-sc
/11.py
1,673
3.5
4
import imaplib import email from collections import defaultdict '''Read the last few emails and display the message content''' src = "techacademy1234@gmail.com" password = "t3chn0tt@b0t5" count = 2 book = {} mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login(src, password) mail.list() mail.select("inbox") # con...
f34afbf2104adb8622f09489a8b4bc9b4c9a6d77
dmonzonis/advent-of-code-2017
/day7/day7.py
2,246
3.84375
4
from collections import Counter def find_root_node(parent_tree): node = list(parent_tree.keys())[0] # Get a starting node # Go backwards until we find the root while node in parent_tree: node = parent_tree[node] return node def generate_trees(inp): """ Generates a bottom-up parent t...
933c9d74c3dee9ac64fefe649af9aba3dcffce02
dmonzonis/advent-of-code-2017
/day24/day24.py
2,809
4.34375
4
class Bridge: """Represents a bridge of magnetic pieces. Holds information about available pieces to construct the bridge, current pieces used in the bridge and the available port of the last piece in the bridge.""" def __init__(self, available, bridge=[], port=0): """Initialize bridge variabl...
a68e2b0be94ba93bb4e9d123c55af80297ddc5d6
dmonzonis/advent-of-code-2017
/day19/day19.py
1,866
4.34375
4
def step(pos, direction): """Take a step in a given direction and return the new position.""" return [sum(x) for x in zip(pos, direction)] def turn_left(direction): """Return a new direction resulting from turning 90 degrees left.""" return (direction[1], -direction[0]) def turn_right(direction): ...
00ad262b85b87c8740f09b5e71575ef496f03e49
mahidhar93988/python-basics-nd-self
/bulb.py
581
3.703125
4
n = int(input()) list1 = [] for i in range(n): element = input() list1.append(element) bulb = "OFF" Count = 0 for i in range(n): if(list1[i] == "ON"): if(bulb == "OFF"): bulb = "ON" Count += 1 else: continue elif(list1[i] == "OFF"): ...
34d60c5614f9f11d5b8d7970c33651040ee8ac7b
mahidhar93988/python-basics-nd-self
/implement_quick_sort.py
1,709
3.96875
4
# implement Quick Sort class QuickSort: arr = [] def __init__(self, arr): self.arr = arr # swap def swap(self, i, j): temp = self.arr[i] self.arr[i] = self.arr[j] self.arr[j] = temp # partition def partition(self, l, h): pivot = self.arr[...