blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3e4315c5dcba28bc2ec8d49c18ecf10283800177
Henhenz1/mahjong-calculator-python
/main.py
53,996
3.515625
4
from math import ceil #TODO TEST EVERYTHING class Meld: def __init__(self): # a meld is a grouping of 3 or 4 tiles of the same suit, or 3 or 4 identical # honor tiles, which we designate as their own suit # 4 melds and a pair make up most valid hands, with two exceptions which # ...
f6ab7a2275114e99e412b22cd94231f0380b5131
csrajath/random_programming_problems
/median.py
580
4.34375
4
# Find the median of two sorted arrays """ 1. combine the lists 2. find the length 3. if length is odd, the element at (len/2)+1 position is the median 4. if length is even, the average of the element at (len/2) and (len/2)+1 will be the median """ def median_find(arr1, arr2): arr3 = arr1 + arr2 if len(arr3) %...
46546e4f7768b59a42139ec47d5db2a6534f9260
asherthechamp/Coding-Problems
/Problem Set Two/maximum_stack.py
567
3.921875
4
# Returns The Maximum value in a stack class MaxStack: def __init__(self): self.Stack = [] # Fill this in. def push(self, val): self.Stack.append(val) def pop(self): if (len(self.Stack) != 0): self.Stack.pop(-1) def max(self): maximum = self.Stack[0] for i in range(1, len(sel...
365149f11e1a8162b4232d13d8f15761d36893a7
oversj96/NumericalMethodsHW
/Homework 2/FixedPointTest3.py
513
3.609375
4
# Author: Justin Overstreet # Date: August 31, 2019 # Program: Fixed-point iteration test method # Purpose: Numerical Methods Homework 2, Problem 3a, solution finding. import math # Math expression to evaluate. f = lambda x: math.pi + math.sin(x)/2 # Initial variables. p0 = 0 n = 30 tol = 10e-2 itr = 1 # Iterative ...
6213c5b1a746429a66fa3193b3dc4adb37dd61e4
standrewscollege2018/2021-year-11-python-classwork-JustineLeeNZ
/lists-inside-lists.py
2,796
4.59375
5
# examples of lists inside lists # *** create a master list that contains other sub-lists *** # the master list starts and ends with [] brackets which all the sublists sit inside # each sub-list must be enclosed in [] brackets with commas between the [] brackets # items inside each sub-list are separated by commas # l...
d90b437f89b79865f69a7d9cbb9cfc569128796c
alidashtii/python-assignments
/ex3.py
103
3.609375
4
a = [ 1 , 1, 2, 3, 5 , 8 , 13 , 21, 34, 55 , 89] b = [] for i in a: if i < 5: b.append(i) print b
eaa5932b2380b7f348a3a029ffedde356006e58d
peraktong/LEETCODE_Jason
/709. To Lower Case.py
412
3.5
4
class Solution: def toLowerCase(self, str: 'str') -> 'str': return str.lower() """ class Solution: def toLowerCase(self, str): #type str: str #rtype: str res = "" for s in str: if ord('A') <= ord(s) <= ord('A')+25: res += chr(...
c29b902312b959b231e8e5c27055549f268fea91
chin8628/Pre-Pro-IT-Lardkrabang-2558
/Prepro-Onsite/W4_D2_UltimaEazy06-MamaAddDict.py
305
3.5625
4
""" W4_D2_UltimaEazy06-MamaAddDict """ def main(): """ Giv me kongo I will giv u Mango """ inputn = int(input()) data = {} for _ in range(inputn): inputkey = input().split(" ") data[inputkey[0]] = inputkey[1] print(sorted(data)) print(sorted(data.values())) main()
eb523bde2cec5c42e24afb5e9100e4a6d4894eb9
OnewayYoun/studygroup-for-codingTest
/06주차/1번(박유나).py
2,130
3.5625
4
def Exit(): # 종료 함수 print(0) exit() def check1(arr): # 사다리 확인 count=0 for n in range(1, N+1): newN=n for h in range(1, H+1): if arr[h][newN]==0 or arr[h][newN]==-1: continue newN=arr[h][newN] # 새로운 값 넣기 if n!= newN: #끝과 끝이 다르다면, count+=1 #카운팅 ...
0f11a64d5bb5a8191a8f233bb15bf591cddff5f3
xjchen2008/leakage_cancellation_python
/gradient_descent_v3.py
1,847
4.125
4
# https://towardsdatascience.com/gradient-descent-in-python-a0d07285742f import numpy as np import matplotlib.pyplot as plt def cal_cost(theta, X, y): m = len(y) predictions = X.dot(theta) A = predictions - y cost = 1.0 / (2 * m) * np.dot(np.conj(A).T, A)[0][0] return cost def gradient_descent(X...
5f26b14eeaa4c344d684a92fd5ec86471bfdb0ec
EugeneStill/PythonCodeChallenges
/ll_is_palindrome.py
1,420
3.828125
4
import unittest import helpers.node as nd import helpers.linked_list as linked_list class LLPalindrome(unittest.TestCase): def is_ll_palindrome(self, head): # are values of linked list a palindrome fast = slow = head # find the mid node while fast and fast.next: fast =...
f04ad5404cf5e0699b8e2c3484c3bb3b4e77f66c
joegalaxian/gameoflife
/gameoflife.py
3,649
3.546875
4
#!/usr/bin/env python import random import time import os import sys DEAD = '.' LIVING = '@' class Game(object): def __init__(self, x=30, y=30, population_percentage=30, fps=2): self.generation = 0 self.population = 0 self.x = x # board's x axis self.y = y # board's y axis self.fps = fps # frame...
3dffe9f32182da692894c7a0328f1a36fde4eef3
xuyichen2010/Leetcode_in_Python
/211_add_and_search_word.py
1,498
3.953125
4
# https://leetcode.com/problems/add-and-search-word-data-structure-design/discuss/59725/Python-easy-to-follow-solution-using-Trie. # O(N*M) N = num of words M = length of longest string # O(N*K) N = num of nodes and K = size of the alphabet # When encounter a "." search through all .values of children class TrieNode: ...
b1bd0f33481d71a5dfe18716dd94d76bd3d04c24
AdamOtto/cmput291mp2
/conditions.py
6,963
3.84375
4
from data_retrieval import * ''' A set of queries produces a conditions list, with the following spec for each condition: [qtype, info...] where each condition by qtype looks like: [TEXT, prefix?, term] [NAME, prefix?, term] [LOCATION, prefix?, term] [GENERAL, term] [DATEEXACT, year, month, day] [DATELESS, year, month,...
603b54bc44519f544d6f6502dbcfd6cbfb712a24
paulgrote/cs-study
/MIT-60001/psets/ps1/ps1a.py
881
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 22 11:13:53 2020 @author: paulgrote """ # salary variables annual_salary = float(input("Enter your annual salary: ")) monthly_salary = annual_salary/12 portion_saved = float(input("Enter the percent of your salary to save, as a decimal: ")) # hous...
425f602f2e904ad649c8c43d4da0c03c94ef7cfb
davicosta12/python_work
/Part_01/Cap_03/Lista_3.3.py
588
3.8125
4
# printando cada nome da lista junto com uma frase diferente e especial games = ['Call of duty', 'League of Legends', 'Counter-Strike', 'Bully', 'Doom', 'Quake'] a = games[0] b = games[1] c = games[2] d = games[3] e = games[4] f = games[5] print("\n\tUma das franquia mais bem elaborada é " + a) print("\tO jo...
0a2a2abd3b7217178881180c0fbfda78fae9511a
soblin/algorithm_list
/sort/merge_sort/main.py
1,250
3.515625
4
# -*- coding: utf-8 -*- import sys sentinel = 1000000 def merge(array, left_buf, right_buf, frm, mid, to): # 1 1 2 # 3 6 9 for i in range(0, (mid-frm)+1): left_buf[i] = array[frm+i] left_buf[(mid-frm)+1] = sentinel for j in range(0, (to-mid)): right_buf[j] = array[mid+1+j] ...
2743f84c6e2164874a8dfc242fb6b3179e35b222
ryanarbow/thinkful_lesson_problems
/text1.py
1,482
3.859375
4
class Musician(object): def __init__(self, sounds): self.sounds = sounds #self.name = name #print(sounds) #print(name) def solo(self, length): for i in range(length): print(self.sounds[i % len(self.sounds)] + " ") print() class Bassist(Musician): # T...
f77776f132b1a24494cf189ed0886f2b20da6e8b
sreejithr/BFS
/bfs.py
1,027
3.625
4
EDGE_DIST = 6 def shortest_dist(next_node, start, end): if len(next_node[start]) == 0: return -1 came_from = {} to_visit = [start] dist_so_far = {start: 0} while len(to_visit) != 0: current = to_visit.pop(0) if current == end: break for next in next_n...
427527cdde7d4708cb5dec99f6d3434ff737bebd
PeterUIXIV/DPG
/Node.py
6,678
3.609375
4
import random import math class Node: def __init__(self, lower, higher, h, i, b, u=None, mean=None, count=0, active=False): self.left = None self.right = None self.h, self.i = h, i self.lower, self.higher = lower, higher self.b = b self.u = u self.mean = m...
6c4be8ce843e4335cf74e3014a1f1b4e7351e87e
utkarshsaini19/Utkarsh-Saini
/simple_l_r.py
926
3.90625
4
import numpy as nm import matplotlib.pyplot as plt def getregre(x,y): #no. of observations n=nm.size(x) #mean of x and y vector m_x,m_y=nm.mean(x),nm.mean(y) #calculating cross deviation and deviation about x sxy=nm.sum(x*y)-n*m_x*m_y sxx=nm.sum(x*x)-n*m_x*m_x #definig theta1 and theta0 theta1=sxy/sxx thet...
e864cb838e8b79262bb60b89478888c5c67b13c8
BFavetto/InfoBCPST2
/TP1/exercice7.py
198
3.78125
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 8 00:20:42 2014 @author: Benjamin """ eps=float(input("entrer epsilon:")) S=1. n=0 while abs(3./2. -S)>eps: S=S+1/3**(n+1) n=n+1 print(n)
040dbfc85a1599814df7440b49ce9b70c280583f
rwlarsen/test-doubles-python
/Service.py
497
3.5
4
import abc from typing import List class Validator(abc.ABC): @abc.abstractmethod def validate(self,values: List[str]) -> bool: pass class Service: validator: Validator work_count: int = 0 def __init__(self, validator: Validator) -> None: assert isinstance(validator, Validator) ...
c6b86223eb847d2dd55ae97fded74cc516216b5d
jmaamtehsi/machine-learning
/Week2/machine-learning-ex1/ex1/Python/computeCost.py
386
3.953125
4
import numpy as np def compute_cost(x, y, theta): """Compute cost for linear regression. Computes the cost of using theta as the parameter for linear regression to fit the data points in X and y. X, y, and theta are np arrays.""" m = len(y) # Number of training examples h_minus_y = np.dot(x, th...
69aa068c3342c475b544cce23c9489d662a1ed0b
yo09975/Clue-less
/src/player.py
4,356
3.625
4
"""player.py.""" from src.hand import Hand from src.card import Card from src.location import Location from src.playerstatus import PlayerStatus from src.cardtype import CardType class Player(object): """Represents a player in the game. Player class in the Game Management Subsystem. The object that represent...
8ce4f9eaac4aad118d76081bbb9b621a6d5b5f19
qianlongzju/project_euler
/python/PE031.py
757
3.796875
4
#!/usr/bin/env python def dynamic(): """ Dynamic Programming """ coins = [1, 2, 5, 10, 20, 50, 100, 200] ways = [0] * (200 + 1) ways[0] = 1 for coin in coins: for i in range(coin, 200 + 1): ways[i] += ways[i-coin] print ways[200] def recursive(): """ Recursiv...
d5f7bfed772488b611e066d31ea1653af631d450
alipay/ant-xgboost
/demo/guide-python/custom_objective.py
1,913
3.515625
4
#!/usr/bin/python import numpy as np import xgboost as xgb ### # advanced: customized loss function # print('start running example to used customized objective function') dtrain = xgb.DMatrix('../data/agaricus.txt.train') dtest = xgb.DMatrix('../data/agaricus.txt.test') # note: for customized objective function, we l...
fa4ff6b25a3d6a154527e39c56305926bbc14be5
mateuszkochanek/carcassone-game
/backend/game/Board.py
3,836
3.53125
4
from backend.tile.Tile25Start import Tile25 class Board: """Main class which is responsible for board and tiles in game""" def __init__(self): """Initialize attributes""" self.tile_matrix = [[None for i in range(150)] for i in range(150)] self.tile_matrix[75][75] = Tile25() def g...
8424b31febfd939c4c5f388a343f626572ba484d
Cherevan/gbProj
/code_180328/game_1.py
481
3.96875
4
import random words_list = ['автострада', 'бензин', 'инопланетянин', 'самолет', 'библиотека', 'шайба', 'олимпиада'] secret_word = random.sample(words_list, 1)[0] print(secret_word) while True: letter = input('введите букву: ') if len(letter) != 1: continue if letter ...
7ab70f005baace8cffdc612e8624554985cd67c6
RadekVlcek/weight
/weight.py
3,474
3.53125
4
import json class Weight(): months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] def __init__(self, data_file): self.data_file = data_file try: file_exists = open(self.data_file) except FileNotF...
9a70e482f63529af5a7097c236970ed5c999942e
gan3i/Python_second
/UnitTesting/test_2.py
2,074
4.125
4
def save_change(y): # with (f as open("list.txt")): f = open("list.txt", mode="wt", encoding="utf-8") f.write(y) l=1 print ("Please input five numbers") a=int(input("1.:")) print (a, "is the first number.") print() b=int(input("2.:")) print (b, "is the second number.") print() c=int(input("3.:")) print (c...
f78f18be418b779fa304e38ced6d1f62f8372c78
adambonneruk/millipede
/millipede.py
1,509
3.953125
4
"""millipede is used for multiple consecutive RegEx search and replace opperations on a single text file""" import re def multi_search_and_replace(rows, rules): results = [] row_count = len(rows) # count of the row array (e.g. lines in the .txt file) rule_count = len(rules) # count of RegEx search and repl...
dbebea3377cb0e4189f3eb9eea35ff4f8e982829
chxj1992/leetcode-exercise
/subject_lcof/18/_1.py
1,135
4
4
import unittest # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def deleteNode(self, head: ListNode, val: int) -> ListNode: prehead = ListNode(-1) prehead.next = head curr = prehead whil...
0e319908723b9247e9321a1e75058ce5e5d5b09e
patel1643/Hackerrank
/minimum swaps 2.py
508
3.5625
4
def minimumSwaps(arr): swapCount = 0 minPos = 0 for i in range(len(arr)): minPos = i j = i while(j < len(arr)): mini = min(arr[j:]) swapIndex = arr.index(mini) if (arr[minPos] != mini): temp = arr[minPos] arr[minPos] = mini arr[swapIndex] = temp swa...
246a1ed8f212e519e0b7879a5d5478cf7ff4982b
Vostbur/cracking-the-coding-interview-6th
/python/chapter_1/07_rotate.py
1,397
4.0625
4
"""Имеется изображение, представленное матрицей NxN; каждый пиксел представлен 4 байтами. Напишите метод для поворота изображения на 90 градусов. Удастся ли вам выполнить эту операцию 'на месте'?""" import unittest def rotate(m): n = len(m) for row in range(n // 2): start, end = row, n - row - 1 ...
c42e1804d4a295eff0fe5006d9c7355d02a3353a
rfelts/wsgi-calculator
/calculator.py
5,314
3.984375
4
#!/usr/bin/env python3 # Russell Felts # Assignment 04 WSGI Calculator import traceback """ For your homework this week, you'll be creating a wsgi application of your own. You'll create an online calculator that can perform several operations. You'll need to support: * Addition * Subtractions * Multiplicati...
0dda448d2597cedf123f5c5e765cd9460795da7c
xunihao1993/haohao_code
/test1.py
162
3.59375
4
''' import re math = re.match('Hello[ \t]*(.*)world','Hello aaa Python world') print(math.group(1)) ''' a= [123,'spam',1.23] print(a[:-1]) print(a[1:2]) 11
eec9c60388f0f7e4da84bec272fe8964b42f5504
phoca-lenivica/lesson2
/task6_get_sum.py
213
3.796875
4
def get_summ(): try: num_one = int(input()) num_two = int(input()) return num_one + num_two except ValueError: print('Проверьте вводимые данные.') result = get_summ() print(result)
cd639bd38523f9f689ff2457664bbe65c3e63606
adamjbc/advent-of-code
/day_4/day_4.py
2,474
3.578125
4
import re f = open("input.txt", "r") all_data = [] for line in f: entries = line.rstrip().split(" ") all_data += entries passports = list() passport = dict() for entry in all_data: if entry == "": passports.append(passport) passport = dict() else: [key, value] = entry.split...
381480860df458c87e5cf101bb9259c71ffeca3f
yusuke-hi-rei/python
/23. pip(external_package)/03. pillow/imageProcessing3.py
339
3.578125
4
## Convert to monochrome. from PIL import Image #! Exception processing is performed assuming #! that the image file cannot be opened. try: img1 = Image.open("image.jpg", "r") #! L: grayscale. img2 = img1.convert("L") img2.save("image_saved3.jpg", "JPEG") print("saved...") except IOError as error...
5146d11a4d5dc3435ddf37aa4735df7486172d02
Philipppy/US_Bikeshare
/show_data.py
1,639
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 9 19:57:42 2021 @author: Julia und Philipp """ import time import calendar import datetime import pandas as pd import numpy as np city = 'chicago' month = 'all' day = 'all' #load raw data bikedata = pd.read_csv(city + ".csv") #use Start time column to extrac...
9d302fad2d7ee7673cbba5f82b8ed025361d03df
Aasthaengg/IBMdataset
/Python_codes/p03998/s976944756.py
184
3.765625
4
s = [list(input()) for _ in range(3)] n_row = 0 dic = {0:"A",1:"B",2:"C"} s_fix = {"a":0,"b":1,"c":2} while len(s[n_row]): n_row = s_fix[s[n_row].pop(0)] print(dic[n_row])
009c14b0df17ebea528ab26d74a10578bdd0eba6
kr-amitsinha/hackerrank_10days_stats
/Day1/day1_interquartile_range.py
918
4.28125
4
def find_median(array, length): #median mid_point = int(length/2) if length%2==0: median = (array[mid_point]+array[ mid_point-1])/2 else: median = array[mid_point] return median length = int(input()) value = list(map(int, str(input()).split(' '))) frequency = list(map(int, str(input()).split(' '))) arr...
7ed392a7da7b347394fbec71e2c4d4e6ae989fd6
jaqxues/AL_Info
/Cours_2e/C6_Structures/Ex6_9.py
396
3.796875
4
from random import random n = int(input('Enter n: ')) assert n >= 2 values = [random() * 100 for _ in range(n)] product = 1 for value in values: product *= value inverse_sum = 0 for value in values: inverse_sum += 1 / value print('Arithmetic mean:', sum(values) / len(values)) print('Geometric mean:', produ...
6ab2a1e6bc814c3602fe6c857a5f2fd7556b7dfa
nonnonno/step2020
/sorted_dictionary.py
819
3.5
4
import csv from operator import itemgetter def dictionary_sort(dictionary): new_dictionary = [] for word in dictionary:#new_dictionaryに、小文字・ソート済のものを加えていく new_dictionary.append([''.join(sorted(word.lower())),word]) sorted_new_dictionary = [] sorted_new_dictionary = new_dictionary.sort(key=itemg...
e1f784d12e90e090b5a6e814ff4218150ea1ea0a
rajlath/rkl_codes
/code-signal/validate_sudoku.py
870
3.78125
4
def sudoku2(grid): for i in range(9): if not isValidList([grid[i][j] for j in range(9)] or not isValidList([grid[j][i] for j in range(9)])): return False for i in range(3): for j in range(3): if not isValidList([grid[m][n] for n in range(3 * j, 3 * j + 3) for m in range(3...
4ddc6c833377f8afbbdfc9e9bb966bbca3ee415d
jay-95/SW-Academy-Intermediate
/6일차/삼성 sw test 21 미로의 거리.py
1,274
3.765625
4
def BFS(start_x, start_y): global result distance_level = 0 Queue = [] Queue.append((start_x, start_y, 0)) while Queue: current_x, current_y, distance_level = Queue.pop(0) if not visited[current_x][current_y]: visited[current_x][current_y] = True for dir_...
89c83a179abd4f4be8f459c1fc1c76157901171e
mostafagafer/Pandas--Udemy-course
/Lec-1 .py
919
4
4
import pandas as pd s = pd.Series([10, "Namaste", 23.5, "Hello"]) print(s) # now we can index it s[0] s[1] # for indexing it by a,b,c,d rather than 0,1,2,3 s = pd.Series([10, "Namaste", 23.5, "Hello"], index=['a', 'b', 'c', 'd']) print(s) s['a'] s['b'] # By deict d = {"Seattle": 1000000, "San Francesco": 5000000, "Sa...
4d3c8678b08961ac9b63e7df29d778d84ccde0fa
Tradd-Schmidt/CSC226-Software-Design-and-Implementation
/T/T10/t10_schmidtt_bondurantc.py
4,698
3.828125
4
###################################################################### # Author: Tradd Schmidt and Conner Bondurant TODO: Change this to your names # Username: schmidtt and bondurantc TODO: Change this to your usernames # # Assignment: T10: Oh, the Places You'll Go! # # Purpose: To create a map of...
6ceb61f99f32e12705f902b7bd71d0295d500314
yennanliu/CS_basics
/algorithm/python/insertion_sort.py
606
4.4375
4
#--------------------------------------------------------------- # INSERTION SORT #--------------------------------------------------------------- # https://www.geeksforgeeks.org/python-program-for-insertion-sort/ # Function to do insertion sort def insertionSort(arr): # Traverse through 1 to len(arr) for ...
269cee303398490e60085a0e7c72255516f68f9f
CaptainSherry49/Python-Project-Beginner-to-Advance
/16 Open(), Read() & Readline() For Reading File.py
1,065
4.375
4
# --------------------------- Open File ------------------------------------- # f = open("Sherry.txt") # f is use as a pointer for this file to handle this file content = f.read() # This variable is for accessing the content print(content) # Now print the content f.close() f = open("Sherry.txt") content2 = f.read...
876d6dfbb9c188ba54b5f61188c32d07ffec2a26
omtelecom/python0907
/modul01/dz2_1.py
92
3.546875
4
def square_even(n): return [i * i for i in range(2, n + 1, 2 )] print (square_even(7))
1a78173b04de5db7ec9f0dbc1cde31c6c7749f51
Lucas-vdr-Horst/Mastermind-extraExercises
/exercise-1/Testcheck.py
337
3.78125
4
def difference_index(str_1, str_2): for i in range(min(len(str_1), len(str_2))): if str_1[i] != str_2[i]: return i if __name__ == "__main__": string_1 = input("Geef een string: ") string_2 = input("Geef een string: ") print("Het eerste verschil zit op index:", difference_index(stri...
527ed4eca816393047a1cc652a4fc35fab42bbca
Mooophy/DMA
/ch03/merge_sort.py
968
3.765625
4
def merge(seq, first, mid, last): (left, right) = (seq[first: mid], seq[mid: last]) (l, r, curr) = (0, 0, first) (left_size, right_size) = (len(left), len(right)) while l != left_size and r != right_size: if left[l] < right[r]: seq[curr] = left[l] l += 1 else: ...
240a74d9db267042a8b4788f518f6c6eeef889f7
JohnWang7802/python-100-
/100_10.py
405
4.0625
4
#问题010:按照年月日时分秒的形式打印出当前时间,等待一秒后继续打印 #【思路分析】继续学习time模块里的属性 ''' time.localtime()获取当前时间,time.strftime()把时间型变量变成字符串 ''' import time for a in range(10): print(time.strftime('今天是:%Y-%m-%d ,现在是%H:%M:%S',time.localtime(time.time()))) time.sleep(1)
086ba040691e7521c76060e1efbfe682eeefdf0f
Vizonery/Vizonery-Proof-of-Concept
/Algorithm2.py
3,027
3.8125
4
# Source: https://www.kaggle.com/dileep070/logistic-regression # import libraries from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split import matplotlib.mlab as mlab from sklearn.metrics import confusion_matrix import matplotlib.pyplot as plt import scipy.stats as st ...
6ce13ee09cdde5cb6b92044ce46d43841f813091
BarbarianJan/MyRoadtoPython
/variables.py
1,788
3.578125
4
#!/bin/python3 #Game variables that can be changed! #game background colour. BACKGROUNDCOLOUR = 'lightblue' #map variables. MAXTILES = 50 MAPWIDTH = 15 MAPHEIGHT = 15 #variables representing the different resources. DIRT = 0 GRASS = 1 WATER = 2 BRICK = 3 WOOD = 4 SAND = 5 PLANK ...
1713c86a70ec5a4d83d26ffacca676e91de3ceed
nofatclips/euler
/python/problem1.py
434
4.28125
4
#!/usr/bin/python #Problem 1 #05 October 2001 # If we list all the natural numbers below 10 # that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. #def sumAll(max): # return sum(range(max)) def sures...
6b2e68649b5be95ab51fe21408877702a1d9eefe
stephenosullivan/LT-Code
/merge-sorted-array.py
669
3.640625
4
__author__ = 'stephenosullivan' class Solution: # @param {integer[]} nums1 # @param {integer} m # @param {integer[]} nums2 # @param {integer} n # @return {void} Do not return anything, modify nums1 in-place instead. def merge(self, nums1, m, nums2, n): count = m + n m -= 1 ...
063342912163848b8832259482ab1707a3022131
BeauWilliams97/Practical
/Prac02/openingTxt.py
152
3.8125
4
__author__ = "Beau Williams" temp_file = open("temp.txt", "w") user_name = input(str("What's your name: ")) print(user_name, file=temp_file) temp_file.close()
e9b13919fc878710adceabd565048fa194fd4411
narru888/PythonWork-py37-
/觀念/LeetCode/Medium/Add_Two_Numbers(鏈結數字串列相加).py
1,402
3.78125
4
""" 相加兩個數字鏈表 """ # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # 高手寫的 # 思路: # - 透過指針去操縱鏈表(不影響原鏈表) # - 從尾數開始相加,並計算進位值 class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: # 先設定...
616091b9c30e1540c0795cf2820a5f1df126c8fe
JEMeyer/advent-of-code
/2022/02/rps.py
1,917
4.125
4
#!/usr/bin/env python """ Module Docstring """ __author__ = "Joe Meyer" __license__ = "MIT" move_to_points = {'A': 1, 'B': 2, 'C': 3} def play_game(opponent, player): # tie if opponent == player: return 3 + move_to_points[player] # win elif (opponent == 'A' and player == 'B') or (opponent ==...
b2111bf44d46fa56d221eb57effdd7399802f5fb
dongjunchoi/Python
/HELLOPYHON/day02/defTest05multi.py
121
3.859375
4
def avgsum(a,b,c): return (a+b+c)/3, a+b+c myavg, mysum = avgsum(3, 4, 5) print("myavg:",myavg) print("mysum:",mysum)
a7292be12231218b5b5035ffc5e756136877c891
joaabjb/curso_em_video_python_3
/desafio025_procurando_string.py
225
3.96875
4
nome = input('Digite o seu nome: ') cond = 'SILVA' in nome.upper() print(f'O seu nome tem "Silva"? (True/False): {cond}') #Outra forma nome = input('Digite o seu nome: ') print('Tem Silva no nome?', 'silva' in nome.lower())
a4cce1654065a7e7aaec40dafd403e76513b2007
Yahyakh69/replacenamewithnumber
/replacenamewithnumber.py
548
3.59375
4
names="yahya ali saied nourhan faisal nour " count=[] cnt=1 names1=names.split() # counting the numbers of letters in names1 for i in names1 : for j in i : count.append(cnt) cnt +=1 #turning it to string count_string=[str(counts) for counts in count] count_string1=[] for...
c8dc0352b5c0e86a0406d58dfa8d0a20499b15b6
ArtemAkulov/HackerRank
/Algorithms/Implementation/find_digits.py
470
3.59375
4
############################################ # # # HackerRank Implementation Challenges # # # # Find Digits # # # ############################################ t ...
12988ce6788869ea75a2aee632f7da4ae0ff1e53
desertSniper87/codewars
/python/test_calculator.py
774
3.765625
4
# TODO: Replace examples and use TDD development by writing your own tests # These are some of the methods available: # test.expect(boolean, [optional] message) # test.assert_equals(actual, expected, [optional] message) # test.assert_not_equals(actual, expected, [optional] message) # You can use Test.describe an...
18597a84f34d34304da443b9c6a5d31e613edc3a
blesoft/mapApp_onplay
/chainer_tuto/test1-6.py
524
3.703125
4
class DateManager: def __init__(self,x,y,z): self.x = x self.y = y self.z = z def add_x(self,delta): self.x += delta def add_y(self,delta): self.y += delta def add_z(self,delta): self.z += delta def sum(self): return self.x + self.y + self.z ...
94bb96d8dbf9540053312377e674577ca83a0c52
felipeonf/Exercises_Python
/exercícios_fixação/Compressão-Listas.py
246
3.875
4
lista_palavras = ['gato','rato','coelho'] lista_letras = [] [lista_letras.append(palavra[caracter]) for palavra in ['gato','rato','cachorro'] for caracter in range(len(palavra)) if palavra[caracter] not in lista_letras] print(lista_letras)
2a971d77f7be4700cfe516d3e26b89a88bdeefda
DeanHe/Practice
/LeetCodePython/MaximumLengthOfaConcatenatedStringWithUniqueCharacters.py
1,509
4.1875
4
""" You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximum possible length of s. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining e...
9fed4e4c377112e721b89c0c44af178a0f351006
MACHEIKH/Datacamp_Machine_Learning_For_Everyone
/11_Cluster_Analysis_in_Python/3_K-Means_Clustering/impactOfSeedsOnDistinctClusters.py
1,140
3.671875
4
# Impact of seeds on distinct clusters # You noticed the impact of seeds on a dataset that did not have well-defined groups of clusters. In this exercise, you will explore whether seeds impact the clusters in the Comic Con data, where the clusters are well-defined. # The data is stored in a Pandas data frame, comic_co...
0c259ff231a67ac6c6f3ca13c48624008bcaf32c
androdri1998/algorithms
/recursion/index.py
1,173
4.15625
4
def find_key(arr, current_position): if(len(arr) == current_position): return None if(str(arr[current_position]) == "box_with_key"): return current_position return find_key(arr, current_position + 1) # function's use case my_arr_with_key = ["box_without_key", "box_without_key", "box_with...
502a31fab5d91684bb844dec6ec7a278e5e05079
devyueightfive/lib-chalanger
/thread/schedule.py
1,539
3.515625
4
import sched import random import time import threading max_work_time = 1 max_works = 10 def do_work(name): print("{} performs ...".format(name)) time.sleep(max_work_time) print("!!! {} completed.".format(name)) class TimeWorker(threading.Thread): def __init__(self, max_time): super().__ini...
cf7389aa56da9c6c4fa89e734bdb32ece894c81e
nicolasmonteiro/Python
/Aula funções/funcaocomretorno.py
735
4.28125
4
''' funcoes com retorno return: finaliza a função. Sai da execução da função podemos ter diferentes retornos sendo apenas um executado) função podendo retornar qualquer tipo de dados até multiplos valores ''' def quadrado_de_7(): return 7*7 # print(quadrado_de_7()) # print(quadrado_de_7()) # sai da função '''...
44da664b7cc2dcef951d59519499462f1aa4b4d9
ajayflynavy/Python-1
/Jupyter Notebook/earth/asia/mongolia.py
1,594
4.34375
4
# Task : Print the FizzBuzz numbers. # FizzBuzz is a famous code challenge used in interviews to test basic programming skills. # It's time to write your own implementation. # Print numbers from 1 to 100 inclusively following these instructions: # if a number is multiple of 3, print "Fizz" inste...
1db6e5b424a30aa108a81b31da36e109c39bff63
mengzhuo/BFS_knight_moves_py
/knight.py
3,196
3.921875
4
#!/usr/bin/env python # encoding: utf-8 """ Author: Meng Zhuo<mengzhuo1203@gmail.com> Version: 0.1 """ import sys class Point(object): def __init__(self, x, y, step=0, path=[]): """ Point object for knight_move :x: point x :y: point y :step: current step :returns...
0d6794565d050bd714498031a7ae47da09c7e4a2
indo-seattle/python
/Suresh/Week1Exercise12.py
202
4.1875
4
#Write a Python program that takes x = 1, y = 1.1, and z = 1.2j and print their data type using type function. Ex: print(type(x)) x = 1 y = 1.1 z = 1.2j print (type(x)) print (type(y)) print (type(z))
d7b540fb3d31d4bb45493e5b2fa989928bbf41c6
furas/python-examples
/pyqt5/replace-content-in-window/main.py
1,657
3.703125
4
# date: 2019.08.26 # https://stackoverflow.com/questions/57656340/how-to-show-another-window from PyQt5 import QtWidgets class MainWidget(QtWidgets.QWidget): def __init__(self, parent): super().__init__() self.parent = parent self.button = QtWidgets.QPushButton("Show Secon...
a8cf75168b60d4a0ec3e0765582457d3d38d36c6
f-leno/checkers-AI
/experiment/experiment.py
7,253
3.546875
4
""" Tic Tac Toe Experiment Class. This class will define which agents_checker will be learning in the environment, whether if a GUI should be shown, and initiate all learning process. Author: Felipe Leno (f.leno@usp.br) """ from agents.expertCheckersAgent import ExpertCheckersAgent from environment.checkersEnvir...
b10f63c68a06d6624ed214a3cc6be391540a2b97
chronologie7/killps
/killps.py
2,198
3.671875
4
#!/usr/bin/env python3 import psutil import sys import re def psListFunc(psName): pslist = psutil.pids() psListMach = [] for psid in pslist: p = psutil.Process(psid) if psName in p.name().lower(): psListMach.append({p.name(): psid}) return psListMach def...
21b07e5c812f9785f336a072ce8440055c2d4d26
robbaralla/sql
/sqlSelect.py
202
3.609375
4
#select data import sqlite3 with sqlite3.connect("new.db") as connection: c = connection.cursor() for row in c.execute("SELECT firstname, lastname from\ employees"): print (row[0], row[1])
576af3e15f565562a0090f307a94c5531364913d
agalyaswami/phython
/power.py
84
3.828125
4
x=int(input("input a number:")) y=int(input("input a number:")) z=pow(x,y) print(z)
ab1c1ca2df9d9aacdf6ad35a8e89352e60b21a79
devitos/Task2
/task2.py
1,605
3.5625
4
import hashlib import os import sys def read_sum_file(sum_file='sum_file.txt'): sumfile_list = list() with open(sum_file, 'r') as sum1: data = list(sum1.read().split('\n')) for line in data: if line: sumfile_list.append({'file_name': line.split(' ')[0], ...
8f19be7dd5628375e37eb6cbf0ff186af6c412de
RosemaryDavy/Python-Code-Samples
/Problem2CheckRange.py
492
4.15625
4
#Rosemary Davy #February 25, 2021 #Problem 2: Write a Python function to check whether a #number is in a given range. Use range(1,10). #Print whether the number is in or not in the range import math def checkRange(x): #define how to check if a number is in the range if num in range (1, 10): print("The num...
46e15a9a2c027751d8b638a637eb83fb8521d5bf
albininovics/python
/car.py
405
3.703125
4
class Cars: def __init__(self, name, price, colour): self.name = name self.price = price self.colour = colour def start(self): print(self.name + "Engine Started") car1 = Cars("Kia", 25000, "Red") car2 = Cars("Tata", 15000, "white") car1.colour = "Blue" print(car1.name, car1.pric...
5fabfa7022c300bbe1f0cea99be5956ac4d56df4
ManuelBerrueta/CPTS437-Machine_Learning
/3HW_HumanActivity/3HW.py
8,584
3.703125
4
import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.preprocessing import label_binarize from sklearn.metrics import roc_curve from sklearn.metrics import confusion_matrix # Majority Classifier from sklearn.dummy import DummyClassifier # Tree f...
06886571d599a96edf291a391a8686f04425b200
unsortedtosorted/elgoog
/Easy/dp/climbStairs.py
584
3.625
4
class Solution: def climbStairs(self, n): """ :type n: int :rtype: int """ self.v={} def climb(n): if n in self.v: return self.v[n] if n<=0: return 0 elif n==1: ...
be28ab57d0a0d6923e5b14ed685b112b810a4fb5
calam1/coursera
/ucsd_algorithms/ucsd_course_1/week_2/greatest_common_divisor.py
623
3.5625
4
#python3 import sys input = input() inputs = [int(i) for i in input.split()] a = inputs[0] b = inputs[1] #print('a {} b {}'.format(a, b)) def naive_gcd(a, b): maximum = -sys.maxsize-1 for i in range(1, a+b+1): if a % i == 0 and b% i == 0: maximum=i return maximum def euclidean_solut...
6c9180a85d22827a9063789f4c099e7c5947ecae
parhamgh2020/kattis
/Riječi.py
290
3.671875
4
n = int(input()) s = 'A' for i in range(1, n + 1): if i == 1: s = s.replace('A', 'B') elif i == 2: s += 'A' elif s[-1] == 'A': s += 'B' elif s[-1] == 'B' and s[-2] == 'B': s += 'A' else: s += 'B' print(s.count('A'), s.count('B'))
c3012e45d00a12646232fa63c7eaa43cae9c565f
alex-gehrig/geoextractor
/geoextractor.py
1,803
3.515625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import glob import csv """Grab the country-codes out of already existing txt-files which contain the results of 'whois' and write them in a csv-file ordered descending by occurance""" # define an empty list to store the temporary results country_list = [] # assuming that ev...
0ed31e700c3f744fb8d38f0d0ab3331abdae694f
zhangjiang1203/Python-
/作业/第一天作业/01-zuoye.py
2,938
3.6875
4
import os def login(): flag = True while flag: # 用户是否存在 users = getUseraccount() for user in users: print(user) isexist = False account = input('请输入您的账号:') psw = input("请输入您的密码:") for user in users: if account in user.values(): ...
4315f9e173190d09f7c6503af70764beaddff525
Kadus90/PyChex
/start.py
1,470
3.546875
4
""" This is the main module for PyChex. """ import sys, pygame, logging from constants import * from Board import Board from Square import Square # start pygame pygame.init() screen = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE)) screen.fill(SCREEN_BACKGROUND) done = False clock = pygame.time.Clock() while ...
7bbf26670a2e6dee11d2cad0ab96f15a2b0e52c1
Saurabh-153/IMP_OOPS_Python
/3. self, cls, static method/3. Class Static Method and Static Method.py
4,239
3.953125
4
''' Difference between Instance Variable and Class Variable ? How to change a regular method to a class method ? A regular method is the one which takes self as a 1st argument, where as a class method takes class as an 1st argument. This can be acheived by adding @classmethod on top of any method know as decorato...
aa145075cfa5d12b11e214f96db502753b24c6a3
badlydrawnrob/python-playground
/python-bootcamp/object_oriented.py
1,356
4.15625
4
## A basic object class Circle(object): pi = 3.14 def __init__(self, radius=1): self.radius = radius def area(self): return self.radius * self.radius * self.pi def setRadius(self, radius): self.radius = radius def getRadius(self): return self.radius c = Circle(...
cd8a30211d1011c8912d764aadaaf5eeee4d268e
Axmaaa/mipt_is_proj
/header.py
5,053
3.625
4
"""Module for working with header of encrypted file.""" import header_pb2 import hashpw import kdf import utils from algorithm import Algorithm class Header: """Class for storing information from the encrypted file header.""" def __init__(self): self._header = header_pb2.Header() # Length of...
ac703a0c45ca5c6e45e8e8cd93cd465aa63e1b42
panekwojciech/DC
/ProjectEuler/5-Smallest multiple.py
456
3.578125
4
''' 25/07/2018 https://projecteuler.net/problem=5 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? ''' #All numbers from 1 to 20 factorized to primes and insert i...
75d20db12aeb6ceb8500856ba81ca3d82278742b
dltjrgks/Bigdata
/01_Jump_to_Python/Chap03/function_type.py
478
3.78125
4
# coding:cp949 def my_sum1(num1, num2) : # Է, ϴ ̽ result = num1 + num2 return result # , Ͻ num1 = int(input("ù ° Էϼ.")) num2 = int(input(" ° Էϼ.")) result = my_sum1(num1,num2) print("%d+%d=%d"%(num1, num2, result)) num1 = input("ù ° Էϼ.") num2 = input(" ° Էϼ.")
a8c2e408b1610c97b03a730aac731d5523dbf132
sanyamsxn/competetive_coding
/hackerrank/python/Arithmetic_operators.py
293
3.5625
4
n_1=int(input()) n_2=int(input()) addition=[n_1,n_2] print(sum(addition)) #sum(iterable,start): sum all no.s in list + start #iterable can be list, tuple ,dict but should contain no. sub=(n_1-n_2) print(sub) prod=(n_1*n_2) print(prod)
06af754463772fd8e5c1e6dcb1d4ff1c21feb7db
andreisharshov/FailGoldbah
/FailGoldbah.py
1,585
3.625
4
# coding: utf-8 # In[149]: mnozh_set = set() mnozh_set.add(1) simple_num = set() simple_num.add(1) simple_list = [] simple_list.append(1) def SimpleNum(num): i = 2 ans_list = [] num_main = num while num != 1: if num%i == 0: num = num/i mnozh_set.add(i) else: ...
7718cf4230ce43e2acfb7e763ef9c786aa28cab6
Keydrain/MapReduce
/generateTriangles.py
849
4
4
#!/usr/local/bin/python3 import random def main(sizeOfArray): '''Generates a 2D graph of vertexes that contains an unknown number of triangles. ''' data = [[0 for x in range(sizeOfArray)] for x in range(sizeOfArray)] #print(data) a = 0 for y in range(sizeOfArray): b = random.randint(0,sizeOfArray-1) c = ...