blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
57c1e0609db4f4d55b6d172427771cf5da84dff1
aselker/SpecialTopicsHW
/VRP/solver.py
2,993
3.703125
4
"""Code file for vehicle routing problem created for Advanced Algorithms Spring 2020 at Olin College. These functions solve the vehicle routing problem using an integer programming and then a local search approach. This code has been adapted from functions written by Alice Paul.""" import picos as pic import numpy as ...
3c79f4f87dce8c4c66b70e137fa7cfa437880304
eidehua/HackerRank
/101 Hack 43/minimizing-the-summation.py
2,339
3.625
4
#!/bin/python import sys filename = sys.argv[1] with open(filename) as f: n,k = f.readline().strip().split(' ') n,k = [int(n),int(k)] a = map(int,f.readline().strip().split(' ')) ''' We simplify the equation to: (A) = 2*k*sum(b_i^2) - 2*sum(b_i)^2 So we only need to keep track of sum(b_i^2) and sum(b_i) ''' '''...
d590510f304bd24b1792cc95b0eb77f704b781f7
fhcwcsy/python_practice
/hw2/main.py
6,968
3.53125
4
from openpyxl import load_workbook import re import requests import urllib.request from bs4 import BeautifulSoup import argparse from argparse import RawTextHelpFormatter # Parser settings parser = argparse.ArgumentParser(prog='AutoLookup', usage='$ python main.py [optional arguments]', description= 'Goal: ...
5edcb95beec426052585ee4bcc9bd5821f2e4717
zinosama/snake_game_python
/board.py
1,629
3.65625
4
from snake import * from random import randint import sys class Board(object): game_board = [] def __init__(self, row, col): self.row = row + 2 self.col = col + 2 #add border for gameboard self.create_board(self.row, self.col) def link_snake(self, snake): self.snake = snake def check_candy(self): if s...
f0fabed3ff9877301750e4d8c36d9377be1660f5
stellayk/Python
/ch04/4_4_Set.py
330
3.796875
4
s = {1,3,5,3,1} print(len(s)) print(s) for d in s: print(d, end=' ') print() s2={3,6} print(s.union(s2)) print(s.difference(s2)) print(s.intersection(s2)) s3={1,3,5} print(s3) s3.add(7) print(s3) s3.discard(3) print(s3) gender=['M','F','M','F'] sgender=set(gender) lgender=list(sgender) print(lgender) print(l...
216d23717796eef991d923f9051d4e45cf9e186d
gaga2455066166/gaga_python3
/Practice_2020/递归算法实现冒泡排序算法的函数MpSort.py
388
3.71875
4
def sort(str): count = len(str) for i in range(0, count): for j in range(i, count): if str[i] > str[j]: t = str[i] str[i] = str[j] str[j] = t sort(str) return str if __name__ == '__main__': a = list(map(int,input().split...
43d8f7af13da742245a46339393d1b693c53fcf4
Tiuku/olio-ohjelmointi
/exercise8_task5_main.py
925
3.78125
4
# File name: exercise8_task5_main.py # Author: Tiia Iire # Description: quiz where user need to answer the right country to capital she/he gets quiz = {} with open("/Users/Iire/Desktop/olio-ohjelmointi-main/olio-ohjelmointi-main/olio-ohjelmointi/countries.txt") as c: for line in c: (key, val) = line.split...
bd56225150c0ba2233743aa140fe174cb88c0539
AnalyticsCal/AnalyticsCal-Classroom
/arima/utils.py
2,470
4.125
4
from fractions import Fraction from linear_algebra import LinearAlgebra def mean(x): """ Calculate the mean of a array of numbers :param x: Input array of numbers :return: Mean """ return sum(x) / len(x) def sd(x): """ Calculate standard deviation of an array :param x: Input arr...
12dd14f9591c268ac925645caef5a91a51a6173a
davidamitchell/school_comp422_project2
/question1/xor_nn_plot.py
1,525
3.5
4
import numpy as np import pandas as pd from sklearn.metrics import confusion_matrix from sknn.mlp import Classifier, Layer import matplotlib.pyplot as plt def load_data(): dt = pd.read_table("data/xor.dat", header=None, sep=" ") X = dt.iloc[:,:-1].as_matrix() y = dt.iloc[:, -1].as_matrix() return X, y...
26a156bdb85433518051e856f1d929a22fe4d636
wulinlw/leetcode_cn
/常用排序算法/selectsort.py
670
3.953125
4
#!/usr/bin/python #coding:utf-8 #直接选择排序 # 首先在未排序序列中找到最小(大)元素,存放到排序序列的起始位置, # 然后,再从剩余未排序元素中继续寻找最小(大)元素,然后放到已排序序列的末尾。 # 以此类推,直到所有元素均排序完毕。 def selectsort(arr): for i in range(len(arr)): min_idx = i for j in range(i+1, len(arr)): if arr[min_idx] > arr[j]: min_idx = j#更新为小的坐标 arr[i], arr[min_i...
b64f16c414e5bceb37afa3b5c9133afa4ecad551
u1207426/password-retry
/password.py
531
3.703125
4
# 密碼重試程式 # password = 'a123456' # 讓使用者重複輸入密碼 # 最多輸入3次 # 如果正確就印出"登入成功!" # 如果不正確就印出"密碼錯誤! 還有_次機會" try_time = 0 while True: try_time = try_time + 1 if try_time <= 3: password = input("請輸入密碼: ") if password == 'a123456': print('登入成功') break elif try_time < 3: have_time = 3 - try_time print(f'密碼錯誤! 還有{ha...
15005fda09c532ad8d95df1920fc4aac9d5025cb
rkeeves/munchausen
/src/e01_munchausen_property.py
604
3.515625
4
#!/usr/bin/env python3 import time def is_munchausen(num): accu = 0 for digit_char in str(num): digit = int(digit_char) accu += 0 if digit == 0 else digit ** digit return accu == num def test(func_to_apply, func_arg): delta = time.time() ret = func_to_apply(func_arg) delta =...
1b78fc866f869b9c3a8f2a19e7a66dc039f5731f
Nancy214/Python_clg
/Assignment 2/A2_Q2.py
248
4.1875
4
#Fibonacci series using recursion def fibo(n): if n <= 1: return n else: return fibo(n-1)+fibo(n-2) terms = int(input('Enter no. of terms: ')) print('Fibonacci Series:') for i in range(terms): print(fibo(i))
5af5ee9f28d30cbcb3680a3ba9db491e4a69d2a2
morrisa-n/100-days-of-code
/tutorial-answers/STP-loops.py
2,222
4.0625
4
# Exercises from The Self-Taught Programmer # Challenge 1 # 1. Print each item in the following list: [" The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"] list = ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"] for show in list: print(show) # Challenge 2 # 2. Print al...
25aa8e187154ee3b5ed26911e7287eb0b23e636b
RegCookies/Offer-Sward
/List/abs_min.py
669
3.5
4
def absMin(arr): if arr[0] >0: return arr[0] if arr[-1] <0: return arr[-1] low = 0 high = len(arr) while low < high: mid = (low + high)//2 if arr[mid] == 0: return 0 elif arr[mid] >0: if arr[mid-1] <= 0: re...
9fb0d084c18692f7970bc17756a027ef30c36847
goagain/Contests
/leetcode/25/main.py
1,667
3.859375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None def __str__(self): if self.next == None: return str(self.val) else: return str(self.val) + " " + self.next.__str__() def CreateListNode(arr...
0d23a6a29661ea9bc9255b8591f54ef9028b7c3d
jlcs/python
/goodrich_2.py
3,485
3.75
4
class Progression: def __init__(self, start=0): self._current = start def _advance(self): self._current += 1 def __next__(self): if self._current == None: raise StopIteration() else: answer = self._current self._advance() ...
88c65c7cd9ec895d59e6ec39e5602060859deeb4
chirsxjh/My-project
/Learning Records and Essays/数据结构与算法/排序算法/冒泡排序.py
817
4.03125
4
def bubbleSort(myList): #首先获取list的总长度,为之后的循环比较作准备 length = len(myList) #一共进行几轮列表比较,一共是(length-1)轮 for i in range(0,length-1): #每一轮的比较,注意range的变化,这里需要进行length-1-长的比较,注意-i的意义(可以减少比较已经排好序的元素) for j in range(0,length-1-i): #交换 if myList[j] >...
47eb21b1aa4bbb50f7b2bbc468b2d482298ce109
back2basics01/KNN
/knn.py
828
3.671875
4
#!/usr/bin/env python # coding: utf-8 import pandas as pd from sklearn.neighbors import NearestNeighbors melbourne = pd.read_csv("Melbourne_housing_full.csv") print(melbourne.head(3)) print(melbourne.columns) melbourne.dropna(axis = 0, how = 'any', thresh = None, subset = None, inplace = True) # axis 0 drop...
1f22bace2e13e4fe4f8edea966d55e57d69bd3c9
scqsryws/DemoPractice
/blg/PM2.5.py
392
3.5
4
# PM2.5空气质量 def pmwarm(pm): pmi = {"0,35": '优', "36,75": "良", "76,115": "轻度污染", "116,150": "中度污染", "151,250": "重度污染", "251,500": "严重污染"} for i in pmi: warning = pmi[i] i = i.split(",") l = [x for x in i] if int(l[0]) <= pm <= int(l[1]): print(l[0], l[1]) p...
68872f7584320b2bb41d29231277c8bd92b909d9
MichaelFrngs/Store-Daily-Sales-Budget-Neural-Network
/Compile Daily Sales Budget.py
3,353
3.640625
4
import pandas as pd import os import datetime as dt from datetime import date import holidays from pandas.tseries.holiday import USFederalHolidayCalendar os.chdir("C:/Users/mfrangos/Desktop/Annual Sales Budget") Annual_Budget = pd.read_excel("Annual Sales Budget.xlsx") Historical_Daily_Sales = pd.read_excel("...
7bf0e21379fa76f8e466bcf352867911459af526
hemagb/Python-Challenges
/PyPoll/pypoll.py
2,406
3.71875
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 6 16:27:53 2018 @author: Hema """ import os import csv ttl_votes=[] Num_votes=0 dict_candidates={} count =0 names=[] file_to_output="Vote_analysis" winner=0 winner_Name="" #Open file to read the data with open("election_data.csv", 'r') as csvfile : csvreader =csv.r...
4a36b19bb0813a20d9c43659a1f0f2e3899e38a3
vidyashre/python_programs
/prime_number_check.py
224
4.09375
4
n=int(raw_input("Enter the number :")) count=0 for i in range(1,(n+1)//2) : if n % i == 0 : count+=1 print(count) if count==1 : print("{} is a prime number".format(n)) else: print("{} is not a prime number".format(n))
b22996c5f964d584ca3dab4e128ee3ef0dd0ecad
msbuddhu/PythonBasics
/q51.py
52
3.59375
4
i=0; while True : i=i+1 print("Hello",i)
35b848ba808b937abfb7e535a0023af0b1e9fb7a
MusaTamzid05/PythonDatabase
/simple_database/str_to_list_converter.py
884
3.640625
4
class Str_List_Converter: def __init__(self):pass def get_remove_list(self,remove_word,string): words = string.split() try: words.remove(remove_word) except ValueError as e: print(e) return words def get_all_words_starting_from(self,starting_word,string): words = string.split() word...
dcacf8ae980af467566d771c963853b4bad39915
a625687551/Leetcode
/TargetOffer/21、调整数组顺序使奇数位于偶数前面.py
2,232
3.75
4
# -*- coding:utf-8 -*- """ 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分, 所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变 PS 比较坑的是这个要求相对位置不能变化 """ class Solution: def reOrderArray(self, array): if not array: return [] odd = [] even = [] for i in array: if i & 1: ...
8dc8a4c410fb6fe742a14f0b577b10c5d47498e3
wanghaininggg/msbd
/一、Python基础/一、基础语法/2.3 考虑以下Python代码,如果运行结束,命令行中的运行结果是什么?.py
348
3.71875
4
l = [] for i in range(10): l.append({'num': i}) print(l) l = [] a = {'num': 0} for x in range(10): a['num'] = i l.append(a) print(l) # 字典是可变对象,在下方的l.append(a)的操作中把字典a的引用传到列表l中, # 当后续操作修改a['num']的值的时候,l中的值也会跟着改变,相当于浅拷贝。
2c9f464e485293eb0d6abc9ce99c84b0f1a0ee7f
kevin115533/projects
/stats.py
228
3.671875
4
""" File: stats.py This programs finds the median, mode, and mean of a set of numbers """ keepGoing = True def main(): while (keepGoing == True) number = float(input("Enter a number or press Q to quit: ")) main()
a83e1e4705982c47c12ca5cd1fc942c261e4dc01
PedroTrujilloV/Python
/Python MIT course/Quiz.py
2,686
3.8125
4
x = 'pi' y = 'pie' x, y = y , x x = 4 def f(x): print x while x>3: break print 'hi'/x #f(x) a1 = {'a'} a2 = {'b'} #print a1 == a2 myst = ( { 1: [1,1], 2: [2,2]}, { 'a': ['a',1], 'b': ['b',2] } ) #print type(myst) kl = [(1,2,3,4)] #kl[1] = 5 mt = (1,2,3,4) #mt[1] = 5 #print kl ...
e432306e2c9da9bfa6b6fb72c5f68c233a600bb9
JoshCheung/CMPS5P
/Hw4/project2.py
1,987
3.921875
4
#project def story_time(): print("1: Christina's adoption story") print("2: Famous Rapper") print("3: Frank's Night Out") print("4: My Crush (for guys)") print("5: Rosette's Story") story_list = ["garbage", "Christina's_adoption.txt", "famous_rapper.txt" , "franks_night_out.txt", "my_crush.txt"...
cd200e19072a89686adfc8fa50c0a0cd9d5d4cf5
Paul199199/THU-transfer-data
/預設值參數.py
315
3.96875
4
#計算值參數 def total(*value): t = 0#不然基本上都設0 for i in value: t += i#*= 此代號可變成乘法,當*=變成乘法時t需等於1 print(value)#加這行可以變成運算數值 return t print(total()) print(total(10,20,30)) print(total(1,2,3,4,5,6,7,8,9,10))
917c9529925be1c99beb08d2d786f7aef5671e7f
g10guang/offerSword
/app/robust/has_subtree.py
1,413
3.515625
4
# coding=utf-8 # author: Xiguang Liu<g10guang@foxmail.com> # 2018-04-27 17:44 # 题目描述:https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking class TreeNode: def __init__(self, x): self....
ca6939c9fd4fb7913104212bd80bb255644e4568
s-surineni/atice
/leet_code/arranging_coins.py
215
3.5
4
# https://leetcode.com/problems/arranging-coins/ import math def arranging_coins(coins): steps = math.floor(math.sqrt((2 * coins) + 1 / 4) - (1 / 2)) return steps coins = 5 print(arranging_coins(coins))
f21df99ad8b25b3038e3c606b1230b34a1eb3eca
AliShih109/Learn-Leetcode
/Algorithm/Easy/0844.py
1,549
3.8125
4
''' 844. Backspace String Compare Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty. Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both S and T bec...
f48cc0ce678fd464f5baeea37741eb545d4f3483
sebarias/python_classes_desafioltm
/clase_6/menu_banco.py
1,374
4.0625
4
saldo_global = 0 def mostrar_menu(saldo = 0): saldo_global = saldo print('¡Bienvenido al Banco Amigo!. Escoja una opción:') print('-' * 20) print('1) Consultar saldo') print('2) Hacer depósito') print('3) Realizar giro') print('4) Salir') print() def depositar(saldo, cantidad): ret...
6e654fd1c8443859c6aeb3dd3248e0f5a5823e0f
hungnd6966/PythonBasic
/While_star.py
315
4.09375
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 4 10:42:39 2020 @author: hungnd """ def count_to_n(n): for i in range(1, n + 1): print('*', end=' ') print() def main(): i = 1 while i <= 10: count_to_n(i) i = i + 1 print() if __name__ == '__main__': main()
2326d7cfcb8728f5cf7d03a6ac466e278b09b3e8
tjmann95/ECEC
/Homework 6/Cup2.py
1,437
4.0625
4
class Cup2: def __init__(self): self.color = None # no change here, still public self._content = None # now it's a protected variable. It has one underscore. def fill(self, beverage): self._content = beverage def empty(self): self._content = None if __name__ == "__m...
c38dbda5fd17828cca98df76eb424fd7bc1502df
cravo123/LeetCode
/Algorithms/1437 Check If All 1's Are at Least Length K Places Away.py
435
3.5
4
# Solution 1, simulation, memorize distance class Solution: def kLengthApart(self, nums: List[int], k: int) -> bool: curr = float('inf') for c in nums: if c == 1 and curr < k: return False if c == 1: curr = 0 e...
c6bce191de337646699fab84b26b2baa2bd5ccd8
zhouchuang/pytest
/test29.py
354
3.828125
4
""" 题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。 程序分析:学会分解出每一位数。 """ n = 0 def parse(num): print(num%10,end=",") if num<10: return else: parse((int)(num/10)) num = 12345 parse(num) print("长度为:%d" % len(str(num)))
137258fe17a1cd245b551cb8087da5497d5a9407
phaelteixeira/exercicios_python
/Atividade10-10.py
350
3.71875
4
l = ['Abacaxi','Maça','Kiwi','Melancia','Melao','Jaca','Jambo'] def in_bisect(t,palavra): total = len(t) metade = int(total / 2) if palavra in t[0:metade-1]: print('Na primeira metade') elif palavra in t[metade:]: print('Na segunda metade') else: print('Palavra nao encontra...
34f54ef92e4164173335556f95019580e39de94d
devOneto/matematica-fisica-jogos-smd
/02 - Representação Numerica 2/questao-05.py
545
4.15625
4
''' QUESTÃO 5 – Escreva um programa que converta um número decimal d para uma base numérica b>0. ''' def reverse_string(x): return x[::-1] print('Numeric Conversion.') print('') b = int ( input('Type numeric base.') ) i = int ( input('Type an non negative number on decimal base .') ) m = i % b q = int ( i / b ) ...
47422193a0524c209574bfa3439295f253261200
Joseph-Whiunui/Project-Euler
/SumSquareDiff.py
386
3.5
4
def main(): num = 100 sumSquares = sumOfSquares(num) squareSum = squareOfSums(num) answer = squareSum - sumSquares print(answer) def sumOfSquares(num): answer = 0 for i in range(num+1): answer += i**2 return answer def squareOfSums(num): answer = 0 for i in range(num+1)...
20257682266bebdb3427a426f5bcc09d0abad8f1
Sohail7699/python-programs
/lab exe 1/lab ex.py
112
3.765625
4
a=int(input("enter first no")) b=int(input("enter second no")) c=int(input("enter third no")) s=a+b+c print(s)
1e5b7350bfa438f19e32e57f2395fa5c8262debc
emptybename/Ds-Algo
/array/sliding_window_maximum.py
2,300
4.3125
4
""" https://leetcode.com/problems/sliding-window-maximum/ You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the m...
3d1f969a42bec7719c63a4c992df544d48ae80b5
Ilja-Lom/Finding-the-Consensus-String
/consensus_string_analyser.py
1,852
3.984375
4
''' Author: Ilja Lom... GitHub: https://github.com/Ilja-Lom Publication-Date: 17/09/2021 Description: An algorithm to find the consensus string given two or more homologous DNA sequences. See the included documentation in the repository for more detail ''' '''Initialising the variables''' nuc_dict = {"adenine...
cc8cf9d9b031beb4430e2deb4fb7322cec6bfe73
SkiAqua/CEV-Python-Ex
/exercícios/ex081.py
574
3.875
4
nums = [] five = 0 while True: n = int(input('Digite um número: ')) nums.insert(0,n) r = str(input('Quer continuar?[S/N]: ')) if r[0].lower() == 'n': break nums.sort(reverse=True) print('Você digitou {} valor'.format(len(nums)),end = '\n' if len(nums) == 1 else 'es\n') print('Os valores foram: ...
5e379a7dd6724b7298056996104159abd0d82240
roomyt/dancoff_util
/expandFIDO.py
829
3.9375
4
import sys import re def expandFIDO(list_): """ Given a list of strings, this function will check each element for FIDO style input and expand it if found. """ read_shorthand = re.compile(r'^(\d+)([rp])([a-zA-Z0-9.\-+]*)') # ie for 4p5.43e-5 the returned list will contain ['4', 'p', '5.43e-5'] for i ...
41f58abd97c6ed9095ef9d56f2d8a35e6d7950af
geniscuadrado/Crafting-Test-Driven-Software-with-Python
/Chapter01/04_unit.py
679
3.71875
4
import unittest class AdditionTestCase(unittest.TestCase): def test_main(self): result = addition(3, 2) assert result == 5 class MultiplyTestCase(unittest.TestCase): def test_main(self): result = multiply(3, 2) assert result == 6 def main(): import sys num1, num2 = s...
ed919d1e58ae7a8966a761820f6f2ce22ae2be61
syurskyi/Python_Topics
/080_tracing/_exercises/templates/traceback – Extract, format, and print exceptions and stack traces/001_.py
1,472
3.71875
4
# The traceback module works with the call stack to produce error messages. A traceback is a stack trace from the point # of an exception handler down the call chain to the point where the exception was raised. You can also work with # the current call stack up from the point of a call (and without the context of an er...
b169606909f518c088188622d73f46af0ece93c2
WangjinghongL/learn_python_git
/learn/gopy.py
124
3.8125
4
i=311 s=input('请输入整数') s=int(s) if i==s : print('OK') elif i<s : print('小了') else: print('大了')
9580946d22d0288318ca44faaedf092ebdb2b94b
kryptocodes/college-projects
/python/sumofdig.py
111
3.96875
4
#program to find the sum of digit a=int(input("entert value for a")) s=0 for i in range(1,a): s=s+i print(s)
74ece8437902ec4084da2688995f11c98ec0ab98
adityashetty0302/python-practice-programs
/Classes.py
3,416
3.65625
4
""" Created by ADITYA.SHETTY on 10/12/2018 """ ''' class MyClass: """docstring""" i = 12 def f(self): return 'hello world' x = MyClass() # print(x.__doc__) xf = x.f # print(xf()) x.i = 15 y = MyClass() y.i = 18 # print(x.i, y.i) # print(x.__class__) # print(isin...
b7cbb43371d1972af8ddbe1401eb0fe119c5abb1
leo96tush/python-programs
/Lamps to Illuminate.py
424
3.703125
4
def lamps(S): count = 0 for i in range(1,len(S)-1): if(S[i-1]=='.' and S[i]=='.' and S[i+1]=='.'): count=count+1 if(S[i]=='.' and S[i-1]=='.' and S[i+1]=='*' and i==1): count = count+1 if(S[i]=='.' and S[i-1]=='*' and S[i+1]=='.' and i==len(S)-2): ...
34d4c31dd8c7673591e25c567340db70c7e34332
slama34849/Learnig_python
/vowelsandconsonents.py
403
3.578125
4
def Check_Vow(my_string, vowels): final = [each for each in my_string if each in vowels] return final def consonents(s): s = s.replace('a', "") s = s.replace("e", "") s = s.replace("i", "") s = s.replace("o", "") s = s.replace("u", "") return s my_string = 'hackerrank' vowels = 'aeiou' ...
de257003c200e582f6d7461c900ee27a80a3c725
roger254/Linear_Regression
/categorical_variables.py
915
3.75
4
import pandas as pd from sklearn.linear_model import LinearRegression data = { 'Age (X1)': [42, 24, 47, 50, 60], 'Monthly Income (X2)': [7313, 17747, 22845, 18552, 14439], 'Gender (X3)': ['Female', 'Female', 'Male', 'Female', 'Male'], 'Total Spend (Y)': [4198.385084, 4134.976648, 5166.614455, 7784.4476...
c934a7ebce4899867a4ce41629b399c2cecd70c3
jswetnam/exercises
/interviews/is_bst.py
1,098
4.1875
4
#!/bin/python # Write a function that checks to see if a # binary tree is a binary search tree. # I use the property that an in-order traversal of a # binary search tree will produce an ordered list to # determine whether the tree is sorted. # Phone interview conducted on 2/15/2013 class Node: def __init__(self,...
70bb1f5abdfd3b1d6112230c04202c5a5faccd76
Sahil12S/DataCompass
/Python/functions_basic2.py
796
3.875
4
# 1 def countdown( a ): retval = [] for i in range( a, -1, -1 ): retval.append( i ) return retval print( "1:" ) print( countdown( 5 ) ) # 2 def print_and_return( l ): print( l[0] ) return l[1] print( "2:" ) print( print_and_return( [1, 2] ) ) # 3 def first_plus_length( l ): return l[0...
3dc5c5cf3ffacb4bdadb78649663533a36a31cd0
chozabu/TiltMusic
/tiltmusic.py
1,365
3.5
4
# TiltMusic by Alex "Chozabu" P-B. September 2016. # # Tilt Y to change Pitch # press A or B to change note length, and turn sound on or off # # A quick demo can be found at https://youtu.be/vvECQTDiWxQ # # This program has been placed into the public domain. from microbit import * import music #A selection of sharp ...
dd03454e3e8784d7f99c7e0aa17c828f2eeea7e3
ekomlev/grokaem_algoritmy
/python/dijkstra.py
1,833
4.125
4
def find_shortest_path_weight(): node = find_lowest_cost_node(costs) # find node with lowest costs from not processed nodes shortest_path_weigh = costs[node] while node is not None: # if all nodes are processed cycle is finished cost = costs[node] neighbors = graph[node] for n in ...
3cc58595d5e76ef830d6f4507d7ad89c2279734a
nikhilcusc/LearningRepo
/LCP/P1/p1try.py
1,225
3.90625
4
list1 = [3,5,2,6,2] slist1 = [] slist1 = list1 slist1.sort() print (list1,slist1) print(list1.index(3)) def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ #nums.sort() for num in nums: k=0 while k...
774eff84b1bc32569f4959a5fced3c5ef662aaf4
amandamurray2021/Programming-Semester-One
/labs/Week04-flow/isEven.py
284
4.1875
4
# This program asks the user to enter a number # The program will tell them if it's even or odd # Author: Amanda Murray number = int (input("enter an integer:")) if (number % 2) == 0: print (" {} is an even number".format(number)) else: print ("{} is an odd number".format(number))
f37c2f02cef9cfc82fdc6c5ff30413453e5d392a
assia-el-majjaoui/ATELIERS
/set.py
261
3.6875
4
MY_SET={4,16,90,26,6,7} MY_SET2={16,3,26,4,5} print("l'intersection de deux set est" ,MY_SET.intersection(MY_SET2)) print("la difference entre deux set est" ,MY_SET.difference(MY_SET2)) MY_SET=MY_SET.difference(MY_SET2) print( "le noveau SET : ",MY_SET)
b4f81aaa20ffbca5b8b56a5338b3fe3121bf5940
macgibbons/deck_of_cards
/Classes/Deck.py
970
3.640625
4
from Classes.Card import Card from random import shuffle class Deck: def __init__(self): self.cards = [] for suit in Card.suits: for card in Card.card_values: self.cards.append(Card(card, suit)) def __repr__(self): return f'deck of {len(self....
dda3a461e56b6e303ec910a419339fa52cb5eeb6
Sresht/evolutionarySquareRoot
/evolutionarySqrt.py
1,375
4.0625
4
import random # defines an individual in the population class Individual: def __init__(self, currentValue): self.val = currentValue self.fit = 0 # initializes the population. We assume that we know that each member of the population # is greater than 0 ...
94ddf0bb64cc01f1bb4563f8f79d3c1c928c41ce
yskang/AlgorithmPractice
/baekjoon/python/sortNumbers.py
209
3.6875
4
# Sort Numbers # https://www.acmicpc.net/problem/2750 numOfNums = int(input()) nums = [] for i in range(numOfNums): nums.append(int(input())) nums.sort() print('\n'.join(list(map(str, nums))))
afe26fe25ac043e72d776cb773ffcebc925f9510
chung-anching/PBC109-2
/try_GitHub.py
294
3.90625
4
import math x_limit = int(input('Enter the type: ')) y_limit = int(input('Enter a number: ')) def cal(t, n): if x_limit == 1: print(math.log(y_limit, 2)) elif x_limit == 2: print(math.log(y_limit)) elif x_limit == 3: print(y_limit**3) cal(x_limit,y_limit)
002844096b922c46319c05ee6fde64f7af07f66d
Err0rdmg/python-programs
/14.py
472
4.03125
4
s = input("Enter your string:") le = 0 c_alpha = 0 c_digit = 0 c_sp = 0 for i in s: if i.isalpha: c_alpha += 1 elif i.isnumeric: c_digit += 1 elif i.isspace: c_sp += 1 print("Length of the string is:", len(s)) print("Number of alphabets is:", c_alpha) print("Number of digits is:",...
a6fbb88b1d1a59958417907e99e0397f6447df03
JesusLibrado/practice-python
/palindrome/palindrome.py
481
4.1875
4
word = input("Enter word: ") def isPalindrome(input_string): input_length = len(input_string) if input_length == 1: return True half_index = input_length//2 first_half = input_string[0:half_index] second_half = input_string[half_index:input_length] if input_length % 2 == 0 else input_string[half_i...
d795af711574968c0a1fe786d88b091e16e87d05
huynhkGW/ICS-Python-Notes
/notes/47 - PyGame Angular Movement/angular movement.py
3,235
3.796875
4
import pygame import random import math class Ball(): def __init__(self, posIn, sizeIn, colorIn): self.pos = posIn self.size = sizeIn self.color = colorIn self.xDirection = 0 self.yDirection = 0 self.speed = 1 def draw(self, surfaceIn): ...
56b5b15d8bfdb8017fb3ee0d10cfcda985ab8e5b
AEFeinstein/Commander-Spellbook-Graph
/comboMapper.py
4,397
3.59375
4
import json import urllib.request import json def recursiveSearch(comboGraph, subGraph, key, rLevel, minWeight): """ Recursively search through a graph to find a subgraph based on weight and distance. This removes the subgraph from the original graph Keyword arguments: comboGraph -- The graph to sea...
4cd369a8a45bd233aa0c396b69f2bc50614c9262
majmoud1/chartJS
/classes.py
416
3.5
4
import pandas as pd """ Fonction permettant de lire le fichier CSV """ def lectureFichier(): fichier = pd.read_csv('table_vente_jumia.csv', sep=',', header=None) produits = [] for j in range(1, 12): # print(fichier[0][j]) p = {'produit': fichier[0][j]} for i in range(1, 14): ...
a2ebbc64ef6a25ad427497f0a5df7aaa65c0cd57
MatthewKosloski/starting-out-with-python
/chapters/13/08.py
631
3.75
4
# This program demonstrates a Quit button. import tkinter import tkinter.messagebox class MyGUI: def __init__(self): self.main_window = tkinter.Tk() self.my_button = tkinter.Button( self.main_window, \ text='Click me!', \ command=self.do_something ) self.quit_button = tkinter.Button( self.mai...
8305a8bfae9ee64d3f446e485c8c602e50e6abb5
matbc92/learning-python
/flow control/if_e_while.py
1,619
4.25
4
#if condiciona o programa a executar um bloco de instruções se certas condições forem atendidas # e outro(s) se condições diferentes ocorrerem, as condições diferentes podem ser especificadas # por meio do comando elif, que efetivamente cria um outro nó de if, ou simplesmente permanecerem # como qualquer coisa diferen...
3475a94f78da206c0b13a16d655e48b27f721885
Aasthaengg/IBMdataset
/Python_codes/p02731/s286088090.py
75
3.75
4
L=int(input()) a=L/3 if L%3==0: print((L//3)**3) else: print(a**3)
7dad7c8316a41c5d0c642d9a33ecb0be748b02cf
TeleginAnton/PythonPY100_hom
/Занятие3/Практические_задания/task2_1/main.py
191
3.90625
4
def pow_func(base, pow_=2): # base ** pow_ -> реализовать через цикл while ... # TODO if __name__ == "__main__": a = 5 n = 3 print(pow_func(a, n))
dcc65a25d5c4246244962a5c2ea60fd90a261e76
alexparunov/leetcode_solutions
/src/1200-1300/_1221_split-a-string-in-balanced-strings.py
419
3.578125
4
""" https://leetcode.com/problems/split-a-string-in-balanced-strings/ """ class Solution: def balancedStringSplit(self, s: str) -> int: tot_num_strs = 0 r, l = 0, 0 for char in s: if char == 'R': r += 1 else: l += 1 if ...
e08b058679aa24db9836161793298f05c8b1423c
nesdown/PythonistaWay
/Python Data Structure/Tuples.py
754
3.890625
4
tup = ('Jan', 'Feb', 'Mar'); tup1 = (); tup2 = (50,); # TUPLE ASSIGNMENT tup1 = ('Robert', 'Carlos', '1965', 'Terminator 1995', 'Actor', 'Florida'); tup2 = (1, 2, 3, 4, 5, 6, 7); print(tup1[0]) print(tup2[1:4]) # Packing x = ("Z-Digital", 20, "Outsource") # Unpacking (company, emp, profile) = x print(company) print(...
95e881cbfce8de59f82c73178a5b747584b4c44c
MOURAIGOR/Python
/Mentorama/Modulo 3 - POO/Pessoa.py
1,821
4.09375
4
class Pessoa: #Atributos def __init__(self, nome="Pessoa", idade=0 , altura=0.0 , peso=0): self.nome = nome self.idade = idade self.altura = altura self.peso = peso #Metodos def crescer(self, cm): self.altura += cm / 100 print("{} cresceu {} cm, e...
335bc424495e46811ea069291cad05a0f5c23951
unbleaklessness/learn
/python3/basics.py
883
4.59375
5
# You can use single or double quotes for strings. They are the same. print("Hello, world!") # Print with new line. ''' This is the multiline comment! ''' name = "John" # Variable assignment. print(name) name = 15 # Variables are weakly typed. print(5 % 4) # Remainder of the division. OUTPUT: 1. print(5 ** 4) # Rais...
30555711317a7590a54cdb2210ac99cbcf30521b
ojhermann-ucd/comp47600
/16203034_hermannOtto_practical2/1c.py
1,392
3.640625
4
# imports # input variables wc_input = "This is my text. It contains about thirty words, of which I expect roughly half to be excluded as stop words. If I modified the input of the R command, I could change the results." wc_output = "input results half thirty expect change this words stop command contains text ex...
cf4995553f4055f75d0ce76d620be5d20536d118
JAGDI/python-eg.
/cal.py
1,996
3.796875
4
import tkinter from tkinter import* cal=Tk() cal.title("calculator") operator="" text_input =StringVar() dispalay=Entry(cal,font=('arial',30,'bold'),textvariable=text_input,bd=30,insertwidth=4,bg="purple",justify='right').grid(columnspan=5) #1st line b7=Button(cal,padx=20,pady=20,bd=10,fg="black",font=('arial...
95edd0cdcc6418a2ab3efb6b457281f38890d1ec
dodoman111/Python_practice
/French_number convert.py
1,353
4
4
def digit(num,pos): #n자리수에 위치한 숫자 값 찾기 return (num//10**(pos-1))%10 def num_in_french(num): ones_list = ['zero','un','deux','trois','quatre','cinq','six','sept','huit','neuf','dix','onze','douze','treize','quatorze','quinze','seize','dix-sept','dix-huit','dix-neuf'] tens_list = ['','dix','ving...
a7a52f28020faf40566225f91b144239479e855a
dineshbeniwall/Machine-Learning
/Ass2_GD/Ass2_GD.py
4,768
3.703125
4
import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model import time X = np.random.random(100).reshape(-1, 1) c = np.random.random(100).reshape(-1, 1) m = 5 Y = m * X + c # no. of itiration W = 10000 # LinearRegression_sklearn def LinearRegression_sklearn(): # Split th...
fe8d63f711878328e343155f511573cc96bf5054
SHASHANK-MOURYA-1106/python-programming-lab
/divisible.py
217
3.53125
4
#divisible by 2 or 4 div=[] for i in range(2,22): if(i%2==0 or i%4==0): div.append(i) print(div) # delete even div1=[] for i in range(1,10): if(i%2!=0): div1.append(i) print(div1)
fa94e90a7f77b6ad8d933447e1841840bf7bb4ec
hbgamer555/number-guessing-game
/hello.py
436
4.125
4
import random number=random.randrange(0,100) guess="wrong" print("Welcome to Number Guessing game!") while guess=="wrong": answer=int(input("Please input a number between 0 and 100:")) num=int(answer) if num<number: print("This is lower than the number.try again!") elif num>number: print("This is...
e5dc417121bde80cdc9325c7d86b39c4462b41c5
arasharn/Data-Science-Deep-Learning-Machine-Learning-with-Python
/Activities/Activity 7/plotting.py
1,909
3.9375
4
# Arash Nouri # Data Science, Deep Learning, & Machine Learning with Python # Activity 7 # Try creating a scatter plot representing random data on age vs. time spent watching TV. Label the axes. # Loading the toolboxes_________________________________________________________________________________________________ im...
c94861ef10f25891dd75992fba020a554c067692
xiexr151e/PADScrape
/chain.py
5,693
4
4
''' Determines the chain and does the actual counting ''' import English from multiprocessing import Pool # Used to store endpoints endpoints = {} # Used to store the main chain itself mainChain = [] # Used to store the requirements for the chain requirements = {} ''' Asks user for input to look for...
ed8312e9a3d21210446a669b66fa8f7cd2eae198
mattmurray/advent_of_code_2020
/day_03/answer.py
1,870
3.640625
4
# --- Day 3: Toboggan Trajectory --- # https://adventofcode.com/2020/day/3 # data with open('input.txt', 'r') as f: data = [line.strip() for line in f] # create list of lists data = [list(row) for row in data] # simple function to check the coordinates of the numpy array def check_for_tree(tree_map, coords): ...
054989c8c4616547462f2adf6891658afd7bdac8
kzhgun/coursera_py_hse
/Week 5/lesenka.py
92
3.5625
4
n = int(input()) for i in range(1, n+1): i += 1 print(*tuple(range(1, i)), sep='')
24e02eed6667a8ed83fe3f043a04453423cbcbde
Mostofa-Najmus-Sakib/Applied-Algorithm
/Leetcode/Python Solutions/Common Algorithm Templates/Trees/KruskalMST.py
3,185
3.828125
4
""" Kruskal's Minimum spanning tree Language: Python Written by: Mostofa Adib Shakib Reading Material: https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/ https://www.ics.uci.edu/~eppstein/161/960206.html Time Complexity: O(E log E) Optimization Techniques: 1) Un...
eddbef1e6ea6d60da0950c711ab59e319b060f7a
arknave/project-euler
/python/pe077.py
870
3.578125
4
def gen_primes(n): # returns a list of primes sieve = list(range(n)) primes = [2] for d in range(3, n, 2): if sieve[d] == d: primes.append(d) for j in range(d * d, n, 2 * d): sieve[j] = d return primes memo = {} def count(primes, a, b): if a == ...
72a1e7013d60fca047c0f26c8298e6dc7229d677
hwrdyen/python_lab2
/LAB 2/LAB2_1_3.py
789
3.765625
4
import math def angle_between(v, w): ''' Fill in docstring ''' variable_control = 0 total1 = 0 total2 = 0 total3 = 0 for i in v: dot_product = (v[variable_control])*(w[variable_control]) first_v = (v[variable_control])**2 first_w = (w[variable_control])**2 ...
211c0029e5f066d337f0cfeee2c4f420fce325fd
theyeahman/all-things
/mastermind/mastermind_game_app.py
5,987
3.703125
4
from mastermind_code_class import colour_choice, mastermind_code, colour_choices from mastermind_player_class import player import time import csv print("\n") print("Welcome to Mastermind!") time.sleep(1) print("Mastermind is a code-breaking game for two players.") time.sleep(1) print("However, in this version it wil...
1a10a73374f5b4486714f641f4538bd45f687d2b
evroon/adventofcode
/2016/aoc2016/day05.py
716
3.5
4
import hashlib def part1(input: str) -> str: password = [] i = 0 while len(password) < 8: to_hash = input + str(i) hash = hashlib.md5(to_hash.encode()).hexdigest() if hash[:5] == '00000': password.append(hash[5]) i += 1 return ''.join(password) def par...
110cdaf95c134ee54a7c20bcff1dd6b04ac76a99
vechiatto/python-fundamentals
/curso_python/aula1/hands/exec2.py
263
3.734375
4
user = 'andre' passwd = '123' usuario = raw_input ('Digite o usuario: ') senha = raw_input ('Digite a senha: ') if usuario == user and senha == passwd: print 'Usuario autenticado com sucesso' print 'Seja bem vindo, %s' % usuario else: print 'Acesso Negado'
80665c640b3f22420850c885d6a5244e1e82ad80
DBerger31/myProjects
/automate_boring_stuff/ch12_webscraping/comic project/mapIt.py
613
3.59375
4
#! /usr/bin/python3.7 # mapIt.py - script will use command line arguments otherwise use clipboard if no arguments given # in order to open the web browser to that specific area # Usage: ./mapit.py Street, City, State Zip code # Usage: ./mapit.py import webbrowser, sys, pyperclip if len(sys.argv) > 1: # Get the ad...
dd33d0913fb46bd7764ff28cdc538ce1971f1e5c
oneplum7/learngit
/study_pythoncode/hm_09_%格式化输出.py
613
3.875
4
# 定义一个小数 price、weight、money # 输出 苹果单价 9.00元/斤,购买了 5.00 斤,需要支付 45.00元 price = 9.0 weight = 5.0 money = price * weight print("苹果单价 %.2f%% 元/斤,购买了 %.3f 斤,需要支付 %.4f 元" % (price,weight,money)) student_no = 100123456 print("我的学号是 %d" % student_no) print("我的学号是",student_no) # 有两种输出方式,%是格式化输出。 # 当最后输出的数据与输入数据不一致的...
1e62ea37739c0a5033a9f1cfb6a169364ce199ce
gracequeen/workplace_python
/fileReader.py
398
3.875
4
dictA = {} count = 0 fileX = open('wordtest.txt', 'rU') for line in fileX: fileWord = line.split() for word in fileWord: #print 'the word now is: ', word #print word is str word = word.lower() if word not in dictA: dictA[word] = 1 else: dictA[word] += 1 print 'the dict is: ', dictA print 'the keys a...
313fc0eca2f0dbbfc6d62b102f8a95fb41959eea
phdfreitas/python
/Mundo 03 - Estruturas Compostas/Aula 17/080.py
343
3.953125
4
# # Created by Pedro Freitas on 14/01/2020. # lista = [] for e in range(0, 5): numero = int(input('\033[1;33mDigite um número: ')) if len(lista) == 0 or numero > lista[-1]: lista.append(numero) else: for i in range(0, len(lista)): if numero < lista[i]: lista.insert(i,numero) break print(f'A lista ...
87298ba96f91f5c1db3ccad39fda57186cb5702d
giannavalencia/rock-paper-scissors-game
/game.py
996
4.0625
4
import random print("Welcome 'Player One' to my Rock, Paper, Scissors, Shoot Game!") user_choice = input ("Choose 'rock' or 'paper' or 'scissors':") print("User chose:") print (user_choice) options = ["rock", "paper","scissors"] if user_choice not in options: print ("NOT VALID OPTION") exit() computer_choic...