blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8389c2391d5ea11090be1a8e397cc81851b6c7ad
Cold-Front-520/valgundriy
/domashka3-zd1.py
710
3.765625
4
x = [] razm = int(input("введите количество элементов и сами значения ")) for i in range(razm): x.append(int(input())) print("это твой массив короче: ", x, "теперь введи циферку - скажу где она") f = int(input()) for i in range(razm): if f == x[i]: slot = i + 1 print("эта циферка стоит на ", s...
ba4ffc484817dc4c4237ced6ccda6c4e834134b4
vp5dt/LAB_python
/LAB1/tripletssumtozero.py
618
3.984375
4
values=input("Enter the list of numbers seperated by space: ") values= values.split(" ") if values[(len(values)-1)]=='': values.remove('') print("Given List:") print(values) def findtriplets(arr, n): flag = True for i in range(0, n - 2): for j in range(i + 1, n - 1): for k in range(...
afa7c2136d62d34e484b913bdcda4d93ae868ff3
JFernandez696/Edge-Detection-Techniques-Sobel-vs.-Canny
/canny_with_OpenCV.py
715
3.546875
4
import cv2 import numpy as np import grayscale import blur_image def canny_CV2(image,low_threshold, high_Threshold): edges = cv2.Canny(image,low_threshold, high_Threshold) return edges if __name__ == "__main__": im_location = '/home/lina/Desktop/' file_name = 'dragon.jpeg' # read the imag...
04ae7c06f98e112a0e7fb4f4f1319acb022d8b5f
LEEHOONY/my-project
/week01/company.py
733
3.859375
4
# 회사 조직도 만들기 # 사람 클래스를 만든다(사람의 기본요소는 이름, 나이, 성별로 한다) # 직장 동료 클래스를 사람 클래스를 이용하여 만든다.(사람 기본 요소 외 직급을 추가한다.) ## Human class class Human: company = "Python" def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex human1 = Human("홍길동", "23", "M") human2 = Human("...
6b52fddb553cb895c2bebe58a58e99884da8e956
duanht-tester/www_python
/实例/xx_0408_阿姆斯特朗数.py
4,671
3.921875
4
# -*- encoding: UTF-8 -*- # __author__ = 'lenovo' # 如果一个n位正整数等于其各位数字的n次方之和,则称该数为阿姆斯特朗数。 # 例如1^3 + 5^3 + 3^3 = 153。 # 1000以内的阿姆斯特朗数: 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407。 # 以下代码用于检测用户输入的数字是否为阿姆斯特朗数: # Python 检测用户输入的数字是否为阿姆斯特朗数 # 获取用户输入的数字 # num = int(input("请输入一个数字: ")) # # # 初始化变量 sum # sum = 0 # # 指数 # n ...
5fad1f31e6e4f5de653c6313fad925d48307d99a
Agaonm/SimplePassManager
/Database.py
1,022
3.8125
4
import pandas as pd ### Check if database exists ### def checkdb(): # If database Exists, Open and convert to Pandas DataFrame try: _forgopassdf = pd.read_csv('database.csv') #_forgopassdf = pd.DataFrame() print(_forgopassdf) return _forgopassdf # If database doesn't exist, cre...
b0f503154fd86225d25d0e8aba37f76ff0b5a07b
Nutpapat/Python_Lab
/KEYS/Sequence XXX.py
788
3.640625
4
""" PSIT Midterm Examination (Rerun) - Sequence XXX Teerapat Kraisrisirikul (60070183) """ def main(size, num): """ Main function """ #Spacing variables side = 0 center = size-4 #Upper borders print(("*" * size + " ") * num) #Upper lines for _ in range((size-3)//2): print((...
2c61a8ee59cdb6637d4076de860cc20c02c12323
liuyuzhou/ai_pre_sourcecode
/chapter3/average_1.py
485
3.78125
4
import numpy as np num_np = np.array([1, 2, 3, 4]) print('初始数组:{}'.format(num_np)) print('调用 average() 函数:{}'.format(np.average(num_np))) # 不指定权重时相当于 mean 函数 wts = np.array([4, 3, 2, 1]) print('再次调用 average() 函数:{}'.format(np.average(num_np, weights=wts))) # 如果 returned 参数设为 true,则返回权重的和 print('权重的和:{}'.f...
c116928b27a7d41abf2543c2c40a94aeaa21ec8e
ReinaKousaka/core
/src/data_cleaning/friends_neighborhood.py
1,845
3.640625
4
class FriendsNeighborhood(): def __init__(self, user_neighbourhood_getter, user_neighbourhood_setter, user_wordcount_getter): self.user_neighbourhood_getter = user_neighbourhood_getter self.user_neighbourhood_setter = user_neighbourhood_setter self.user_wordcount_getter = user_wordcount_get...
150586f9351584798807aacffdcda9ca45258829
Bbowen100/crypt
/crypt.py
4,054
3.796875
4
'''Crypt This file contains encryption & decryption Functions. This will be imported into any encryption related programs. REQ: for simplicity I have refined this algorithm to members of the alphabet ie. special characters and numbers will not be decrypted accurately ''' import random global __start__ __start__ = o...
b60f768088e83aca193e6d46b40672169ed0bda7
4nickpick/assembler-3000
/lib/util.py
9,819
3.703125
4
# # # Util # This module contains many functions and objects reused throughout the software # # import sys # My Hash Function # Produces a hash of a string, based on a particular hash table size # # input_string - string to create hash value for # hash_table_size - size of hash table, required to create a hash ...
faef80fe8ad837c5be2c6637b260b28269c54655
MrShafay/MarketingStack
/Sentence_split.py
210
3.75
4
def split(): a = input("Copy text and paste it, then press ENTER ") b = a.split() print(b) split() # If you Join def join(): b = split() join2 = ' '.join(b) print(join2) join()
c483a96ce074ba181e6757a427eed28e5d664bee
Abhinav-Bala/ICS3U
/problem_set_6/name_bank.py
9,166
4.71875
5
# Abhinav Balasubramanian # March 31, 2021 # ICS3UO-C # This program will ask the user to input names and then store them in a list. # Then the user will be presented with a menu of actions to perform including: displaying # all the names, editing, adding, or removing a name. # this functions prints the main menu def...
24c3923a268646490541d43ea510982cbbe8b1be
bretonics/MSSD
/CS521/Homework/hw_2/hw_2_3_3.py
2,521
3.6875
4
#!/usr/bin/env python import math # Decimal coordinates (latitude, longitude): atlanta = [33.7489954, -84.3879824] savannah = [32.0835407, -81.09983419999998] orlando = [28.5383355, -81.37923649999999] charlotte = [35.2270869, -80.84312669999997] radius = 6371.01 # Distance between Atlanta and Savannah as_distance =...
f07bea9a630c6bf2fdb3ad98b7a19dfa0fe8fc13
NapFiend/Bag-Value-Optimisation-Using-EA
/util.py
5,623
4.03125
4
import random def get_weight_limit(line): """ Simply returns the cleaned weight limit as an integer from teh first line of the document """ return int(line.split(':')[1]) def init_pop(weights, pop_size): ''' Generate a population of random solutions. params: weights: ...
b9577576822ae7fbb939fab4147747cf3d0d1355
LucaGreenshields/Averages-challenge
/main.py
1,114
3.984375
4
def user_input(): input_list = input("Enter a list elements separated by space ") string_list = input_list.split() num_list = [ float(item) for item in string_list ] return(num_list) def average(n_list): n = len(n_list) sum_n = sum(n_list) average = sum_n / n return(average) def ...
d009d16b54fd6505babc0aa65cc09fd31b07f6a8
sminez/Cryptopals
/cplib/utils.py
3,333
3.6875
4
''' Utility functions for https://cryptopals.com ============================================ More specific functions and library functions are found in the other files in this module. ''' from codecs import encode, decode from string import ascii_lowercase ############################################################...
40767de08b3038ee8a67394704209c7d8970fdc9
KennySoh/PythonNotes
/Problem Set & Answers/week3_hw_5.py
382
3.71875
4
import math def approx_ode(h,t0,y0,tn): x=tn/h counter=1 while counter<=int(x): y0=y0+h*f(t0,y0) t0=h+t0 #print(y0,counter,x,t0) counter=counter+1 return round(y0,3) def f(t, y): return 3.0+math.exp(-t)-0.5*y print approx_ode(0.1,0,1,3.0) print approx_ode(0.1,0,1,4....
f7c6bcd6c1225c26dfbf740778767980e9b6f061
Dipakece701/Python-Lab
/17-11-2019/for_2.py
158
4.3125
4
#!/usr/bin/python countries=['India','SriLanks','USA','Bangladesh','Pakistan'] print("Printing the countries name as below: ") for i in countries: print(i)
a99cb2d20e41325c2d8997441c63655d48a59685
advaitsp/PS-1-Summer-2020
/Numpy/Other Functions/extract.py
274
3.734375
4
import numpy as np x = np.arange(9.).reshape(3, 3) print 'Our array is:' print x # define a condition condition = np.mod(x,2) == 0 print 'Element-wise value of condition' print condition print 'Extract elements using condition' print np.extract(condition, x)
62e95db13611d9a6ecbdbb070b9b176d673b81f2
petyakostova/Software-University
/Programming Basics with Python/First_Steps_in_Coding/04_Triangle_Of_55_Stars.py
300
3.984375
4
''' Write a Python console program that prints a triangle of 55 asterisks located in 10 rows: * ** *** **** ***** ****** ******* ******** ********* ********** ''' for i in range(1,11): print('*'*i) ''' for i in range(1, 11): for j in range(0, i): print('*', end="") print() '''
432290726098d67f18e57dfc37a233bae5bd3e18
vbos70/KodKlubben
/pgzero/codebattle/boatbattle.py
6,105
3.5625
4
from random import choice, random, randrange from game import * import sys class Move: def __init__(self, heading, dist, target, fran): self.heading = heading self.dist = dist self.target = target self.fran = fran def __eq__(self, other): return ( self.heading == other...
9eb1582c7bd9f24ed4af54a9de07ba70c3351c99
hz336/Algorithm
/LintCode/DFS/Permutation Index.py
906
3.84375
4
""" Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1. Example Given [1,2,4], return 1. """ class Solution: """ @param A: An array of integers @return: A long intege...
42d39703174c2bc74535e9c5dac7082acaac3cca
Nimger/LeetCode
/561.py
432
3.71875
4
# -*- coding:utf-8 -*- # https://leetcode.com/problems/array-partition-i/#/description class Solution(object): def arrayPairSum(self, nums): """ :type nums: List[int] :rtype: int """ list = sorted(nums) result = 0 for index,value in enumerate(list): if index%2 == 0: result += value return resu...
64c7defa25dd2b6934cb2a6ed4e3a10160d92908
ynsong/Introduction-to-Computer-Science
/a07/a07q2.py
6,141
3.671875
4
##============================================================================== ## Yining Song (20675284) ## CS 116 Spring 2017 ## Assignment 07, Problem 2 ##============================================================================== import check ## Constants for ternary_search equal_string = "Checking if {0} ...
01b99bb0bcf27ebcc23e6be17f5f80bc14b5e51d
ziolkowskid06/grokking_algorithms
/selection_sort.py
795
4.25
4
def findSmallest(arr): """Finds the smallest element in a array""" smallest = arr[0] # stores the first value smallest_index = 0 # stores the index of the first value for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] # stores the smallest val...
2cd170ce68a387116ff6889e242ad6da1183b105
shantanudwvd/PythonHackerrank
/ReversalAlgo.py
529
3.796875
4
def rverseArray(arr, start, end): while start < end: temp = arr[start] arr[start] = arr[end] arr[end] = temp start += 1 end = end - 1 def leftRotate(arr, d): if d == 0: return n = len(arr) rverseArray(arr, 0, d - 1) rverseArray(arr, d, n - 1) rve...
b32a8c6e819d3d8e4eca065772a13c2dc58d8be9
thekiminlee/random_data_generator
/pyDataGenerator.py
2,198
3.546875
4
# Author: Ki Min Lee import sys import csv import random # List of attributes, stored in list format [name1, name2, ...] ATTR_NAME = [] # List of ranges of attributes # Number of ranges must match the number and order of attributes. ATTR_RANGE = [] # Name of the output file FILE = None # Decimal place for randomly ge...
f42360652b1ce83448dfce63a7df518b2786c833
SS4G/AlgorithmTraining
/exercise/leetcode/python_src/by2017_Sep/Leet380.py
1,470
4.1875
4
import random class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.nums = [] self.posFind = {} def insert(self, val): """ Inserts a value to the set. Returns true if the set did not already contain the speci...
772e4e9df712785927a019e4931dcf4a5e85bf8e
Sakura-lyq/test
/absert.py
365
3.671875
4
def my_abs(x): if not isinstance(x,(float,int)): raise TypeError('bad operand type') if x>=0 : return x else: return -x print(my_abs(88)) import math def move(x,y,step,angle=0): nx = x + step * math.cos(angle) ny = y - step * math.sin(angle) return nx,ny x,...
25bd4552dabc3ee6a7e93f5049ea38fb79968140
sowmenappd/ds_algo_practice
/arrays_strings/rearrange_pos_neg_array_with_extra_space.py
509
4.1875
4
print("Program to rearrange positive and negative numbers in an array\n"); # This algorithm doesn't maintain the relative order def rearrange(array): l = len(array) idx = 0 for i in range(l): if array[i] < 0: array[idx], array[i] = array[i], array[idx] idx += 1 p = id...
9272ec57d006dec7432aa15f7897189d8cfd06d6
emkoltsova/two_tasks
/2.py
202
3.90625
4
def func_up(text): new_text ='' for current_word in text.split(): new_text += current_word[0].upper()+current_word[1:]+' ' return new_text print(func_up('hello world how are you'))
2930aab1fc8cf11bd29ac173122fc6270eb7823b
FrankieZhen/Lookoop
/LeetCode/otherQuestion/商汤/Q3.py
363
3.65625
4
# coding:utf-8 # 股票最大利润,只能买卖一次 def solver(nums): minNum = nums[0] maxProfit = 0 for n in nums: maxProfit = max(maxProfit, n - minNum) if n < minNum: minNum = n return maxProfit def test(): nums = [7,1,5,3,6,4] ret = solver(nums) print(ret) if __name__ == '__ma...
d5fb4c92dc7ad93358e4be309e17d66c6a227167
Khamisali61/Homeday2-bootcamp
/max_min_num.py
353
3.9375
4
def find_max_min(n): resultList = [] max_number = max(n) min_number = min(n) if min_number == max_number: #if min and max are equal return number of elements in list number_of_elements = len(n) resultList.append(number_of_elements) else: resultList.append(min_number) resultList.append...
5ea74d54986e50290bcd54f9bc46f9b1eb6fe8d8
varunn807/Coding-Exercise
/climbingStairs.py
406
3.625
4
class Solution(object): def __init__(self): self.stairs={} def climbStairs(self, n): """ :type n: int :rtype: int """ self.stairs[0]=1 self.stairs[1] = 1 for i in range(2,n+1): self.stairs[i]=self.stairs[i-1]+self.stairs[...
a662cdf93613ce4e1d87eed4cbdbd2a29f2bc16a
flaviojussie/Exercicios_Python-Inciante-
/EstruturaDeRepeticao - PythonBrasil/exec10.py
110
4.03125
4
num1, num2 = int(input('Digite dois numeros:')), int(input()) while num1 < num2: num1 += 1 print(num1)
e37ab4c57ff0a3623349bfcd9bd2af477883aa13
statham/spellchecker
/spellchecker.py
1,684
3.71875
4
import sys from trie import Trie def readDict(): #get words from /usr/share/dict/words f = open('/usr/share/dict/words', 'r') words = Trie() #load words into trie for word in f.read().split('\n'): words.insert(word) return words def get_possible_words(word): #get all possible words for duplicate letter...
1ff42058c3c3582b5714dec2a89bf6d2b942380c
Razdeep/PythonSnippets
/OCT09/05.py
538
3.78125
4
# Builtin method and variables in classes # @CAUTION: Not working class Employee: def __init__(self,name,age): self.name=name self.age=age def display(self): print('Name',self.name,' Age',self.age) emp=Employee('Rajdeep',19) print('Documentation of the class',emp.__doc__) print('Name of...
0f0d2f37a80a5a665084a734f520c46a6115c6d6
RaadUH/RBARNETTCIS2348
/8_10.py
184
4
4
input1 = input() input2 = input1.replace(" ","") reverse = input2[::-1] if(reverse==input2): print(input1,"is a palindrome") else: print(input1,"is not a palindrome")
b62c8b84e88c6c1084ee37f6d686d6d4c6b01c8a
rafaelperazzo/programacao-web
/moodledata/vpl_data/21/usersdata/112/8553/submittedfiles/exercicio24.py
198
3.625
4
# -*- coding: utf-8 -*- from __future__ import division import math n=0 for i in range (3,n+1,1): for i in range (2,a,1): cont=cont+1 if cont==0: print(a)
366ef6f61c394aa4e47eb5c86d9df02ffc6a56e4
neironus/100DaysOfPython
/TalkPython/55/program.py
1,306
3.609375
4
from api import MovieSearchClient def ask_for_searchword(): return input('Search for: ') def prints_results(results): if results: for result in results: print('{} by {} rate {}'.format( result.get('title'), result.get('director'), result.get('imdb_score') ...
298b0e436431887e011e93394dcfae914091a8af
gitudaniel/pythonchallenge
/level10_regex.py
427
3.625
4
import re """ refer to https://stackoverflow.com/questions/8624345/whats-the-meaning-of-a-number-after-a-backslash-in-a-regular-expression && https://regex101.com/ with regex:(\d)(\1*) and test string:13211311123113112211 """ value = '1' for i in range(0, 6): values_compiled = re.compile(r'(\d)(\1*)') values...
5b13e78178f96997fc0ff4d26a036f60adbbe921
aydansuleymanova1/testlab1
/calculator.py
417
3.59375
4
def sum(m, n): result = m if n < 0: for i in range(abs(n)): result -= 1 else: for i in range(n): result += 1 return result def divide (m,n): result=0 negativeResult= m>0 and n<0 or m<0 and n>0 n= abs(n) m= abs(m) while (m-n>=0): m=-...
4c827a5a29854ad8c5a0d3033e6e609ea3bc7d22
vasc/quicksort
/quicksort.py
299
4.03125
4
#!/usr/bin/env python import sys def quicksort(l): if not l: return l pivot = l[0] smaller = [x for x in l[1:] if x < pivot] larger = [x for x in l[1:] if x >= pivot] return quicksort(smaller) + [pivot] + quicksort(larger) l = map(int, sys.argv[1:]) print " ".join(map(str, quicksort(l)))
5afff72436e53b28e568e7bf27128077f3f40aa2
pablo-grande/Aula
/Benchmark/sort.py
1,208
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -* from timing import * @print_timing def sort(bad_list): """ Dada una lista desordenada (bad_list) la ordena utilizando el programa por defecto de python :param bad_list: """ bad_list.sort() # merge sort @print_timing def merge_sort(bad_list): """ ...
5901a4a5537394f8ff5b7af5df0d3cc2e018f2cd
MounishKokkula/RandomWorks
/BarChartWithTurtle/BarwithTurtle.py
7,101
3.84375
4
#!/usr/bin/env python # coding: utf-8 """ This program is to convert values from '.xlsx' file to a bar chart. The inputs are parsed and to check for empty values and format. The bar chart is plotted using "turtle" a inbuilt library with python. """ import pandas as pd import turtle class DrawGraph(): de...
250a7e04cda64b71afaa2964746706075a3f3110
capric8416/leetcode
/algorithms/python3/guess_number_higher_or_lower_ii.py
1,044
4.125
4
# !/usr/bin/env python # -*- coding: utf-8 -*- """ We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you whether the number I picked is higher or lower. However, when you guess a particular number x, a...
4742dbff7ea02aa4a5b5b84bcab26a246431b1fa
deepakdashcode/myPy
/removeWordsOfLengthK.py
165
3.703125
4
sen=input('Enter the Sentence\n') n=int(input('Enter the Word Length\n')) wordList=sen.split() s='' for i in wordList: if len(i)!=n: s=s+i+' ' print(s)
e7d32e9fc424697dd231f03f004ac436aa7ecf1a
drumgiovanni/simple_calendar
/calendar1.py
1,441
3.890625
4
from tkinter import Frame, Button, LEFT, RIGHT, BOTTOM, StringVar, Label, Entry, END, CENTER import calendar class Calendar1(Frame): def __init__(self, master=None): super().__init__(master) self.pack() self.master.title("カレンダー") self.year = 2018 self.month = 1 # タ...
40ddc71a42f176e703cd4723d6e8f009742d9b00
anovacap/daily_coding_problem
/smaller_elms_right.py
391
3.875
4
#!/usr/bin/python # ex 1.4 find the number of smaller elements to the right O(n2) # for loop and sum (sum has a O(n) loop def smaller_elm_right(arr): res = [] for i, num in enumerate(arr): count = sum(val < num for val in arr[i + 1:]) res.append(count) print("result = ", res) return res if __name__ == "__main__...
de0ef44b42166c27c1e43243839b0f0fbdbad97d
applesir20191001/Python001-class01
/week04/weekfour.py
1,560
3.546875
4
import pandas as pd import numpy as np # 1. SELECT * FROM data; group = ['x', 'y', 'z'] data = pd.DataFrame({ "group": [group[x] for x in np.random.randint(0, len(group), 20)], "salary": np.random.randint(5, 50, 20), "age": np.random.randint(15, 50, 20) }) data1 = pd.DataFrame({ "group": [group[x] for x...
483698ab90c50dbfa373938d89ad5eee2e7ba409
sausheong/bookspeak
/speak.py
1,550
3.5625
4
#!/usr/bin/python3 import sys, getopt, pyttsx3 # a simple script to speak out a book or write it into an mp3 # either read the book out aloud or save it to an mp3 file def speak(bookfile, audiofile, voice, rate): engine = pyttsx3.init() if voice != '': engine.setProperty('voice', voice) if rate != ...
c252dce9a92d4768185c9cb5b53575fcbe0964a8
foob26uk/coding-questions
/ch1/ch110.py
589
3.59375
4
# 1.10 def anonymousLetter(letter, magazine): H = {} for l in list(letter): if l != " ": if l in H: H[l] = H[l] + 1 else: H[l] = 1 for m in list(magazine): if m != " ": if m in H: H[m] = H[m] - 1 for h ...
767566ccfc935ef7d59804558c1c39b20544c4c2
HoodCat/python_practice02
/prob01.py
197
3.625
4
money = int(input("금액: ")) kind_of_money = [50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1] print() for m in kind_of_money: print(str(m) + "원: " + str(money//m) + "개") money %= m
bccc300a047ddccacfaf874223468a07e906c955
ibaomu/Hello-World
/莫名.py
640
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 31 09:27:53 2018 @author: 某树 """ name=input("请输入您的姓名:") if name in ("褚晓雪"): print("您好,{}小姐,主人给您留了一封信,请确定是否要开启?".format(name[0])) y=input() if y in ("快,好,打开,,好的,嗯"): print("丑晓雪,我喜欢你。") if name in("抱木"): print("My master,can I help you?") x=inpu...
c84fd2378a3aa641bbab42e26ccae940d0fbe926
atriekak/LeetCode
/solutions/36. Valid Sudoku.py
1,193
3.6875
4
class Solution:    def isValidSudoku(self, board: List[List[str]]) -> bool:        #Approach: Hashing        #Time Complexity: O(1) // constant board size        #Space Complexity: O(1) // constant board size                m = len(board)        n = len(board[0])                row_map = [set() for i in range(...
d0e8900081da836fd0d65e4b46c088ab314b15ed
kopytova/pythonProject
/task_1_1.py
224
3.953125
4
seconds = int(input('Введите временной интервал в секундах: ')) ss = (seconds % 60) minutes = seconds // 60 mm = (minutes % 60) hh = (minutes // 60) print("%02d:%02d:%02d" % (hh, mm, ss))
e1936381661855f0909d9e4354d7b46300828a47
PyThingy/bearded-octo-ironman
/Spotkanie3/marcin_flatten_pickle.py
626
3.5625
4
import pickle def flatten(elem_nested): all_flatten = tuple() if isinstance(elem_nested, list): for item in elem_nested: all_flatten += flatten(item) elif isinstance(elem_nested, tuple): for item in elem_nested: all_flatten += flatten(item) elif isinstance(elem_n...
82cc70df9dc223cf576015638c15e5e934bfb6b5
muhmunt/python
/latihan ket/lat3.py
1,254
3.671875
4
def batas(): print("==========================================") batas(); print("APLIKASI LAUNDRY KILOAN") print("\nKODE LAUNDRY\t JENIS LAUNDRY\tTARIF/KILO") print("\t\t\t1\t\tPAKAIAN\t\t\t10.000") print("\t\t\t2\t\tSELIMUT\t\t\t20.000") print("\t\t\t3\t\tKARPET\t\t\t30.000") batas(); pl = int(input("Masukkan Kod...
145b08f057efb2de119f8c5f99dd4b17f8c5d21d
serg-kanarskiy/Osnovi-programmirovaniya-na-Python
/Homework №2.py
2,847
4.21875
4
#Задачи на циклы и оператор условия ''' Задача 1 Вывести на экран циклом пять строк из нулей, причем каждая строка должна быть пронумерована. ''' i = 0 while i < 5: i += 1 print(i,'0') ''' Задача 2 Пользователь в цикле вводит 10 цифр. Найти количество введеных пользователем цифр 5. ''' x ...
5433a5d198829134758ea0ad6bbf236a59f958bf
seeprybyrun/project_euler
/problem0031.py
985
3.5625
4
# -*- coding: utf-8 -*- # In England the currency is made up of pound, £, and pence, p, and there # are eight coins in general circulation: # # 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). # It is possible to make £2 in the following way: # # 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p # How many different ways ...
bcb7f35d207707b3b546345be1118721ae47b096
esoteric24/python_training
/bar_graph.py
881
3.796875
4
import matplotlib.pyplot as plt def createBarChart(values, catLabels, xLabel, yLabel, title): numBars = len(values) barCenters = range(1, (numBars + 1)) plt.barh(barCenters, values, align='center') plt.yticks(barCenters, catLabels) plt.xlabel(xLabel) plt.ylabel(yLabel) plt.title(title) ...
e143fa93f725abbbfddba4d70281a65bfea9dcae
brenoskuk/Breno_and_Kogler
/Images/01 - Basicos/06 - histograma_da_imagem-metodo_ ineficiente.py
788
3.734375
4
# Programa para calcular e mostrar o histograma de uma imagem # metodo INEFICIENTE - varre a imagem 256 vezes # contando as frequencias do valor no pixel em cada varredura # import Image import numpy import matplotlib.pyplot as plt from sys import exit as fim # le image de um arquivo M = Image.open('.\Lena.png') wid...
bac1b0c035b5aa39817b985f8e391f8b2e63dc01
brunoharlein/POO_recall
/attributs_classe2.py
497
3.796875
4
class Test: a = "attribut de classe" def __init__(self): self.b = "attribut d'objet" if __name__ == "__main__": attribut = Test ( ) print(attribut.b) print(Test.a) # Pour utiliser le(s) attribut(s) de classe, # il est inutile de créer un objet de cette classe puisque l’attribut est une pr...
b684f68991abb37d0d992fb083a738b64add9321
Instructor-Devon/Python-ONL-June
/Algos/Arrays/balanceIndex.py
717
3.75
4
def balance_index(arr): if len(arr) == 0: return False if len(arr) == 1: return 0 # [2,2,5,2,2] => 2 (balanced at index 2) # [23,4,5] => False # [10,15,7,25] => 2 # remember to not include pivot point in sums sum1 = arr[0] sum41 = 0 # loop rest of array to find sum of...
a0d965f8deac73d592891d3447a30cc436f74cff
wjdwls0630/2018-1-Web-Python-KHU
/Week10-Exam2/Exam2(월,수 1시수업)/Exam2_1(5).py
1,169
3.5
4
class SmartPhone() : def __init__(self,maker="",model="",spec=[],price=0.0): self.maker=maker self.model=model self.spec=spec[:] self.price=price def setInfo(self,maker,model,spec,price): self.maker=maker self.model=model self.spec=spec[:] self.pr...
890c845a13116f965f477642737c8fc8a36c5f92
terodea/DSA
/practice/data_engineering/array/10.find_2_repeating_elements.py
8,334
4.125
4
import math class BruteForce: """ >>> obj = BruteForce() >>> arr = [4, 2, 4, 5, 2, 3, 1] >>> arr_size = len(arr) >>> obj.printRepeating(arr, arr_size) Time Complexity: O(n*n) Auxiliary Space: O(1) """ def printRepeating(self, arr, size): for i in range (0, size-1): ...
16b0d5ea6dc2f573177a681924496830d4c46813
ZZY2357/auto-workflow
/scripts/caesar-password.py
1,629
3.578125
4
#/usr/bin/env python3 chars_down = list('abcdefghijklmnopqrstuvwxyz') chars_up = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') nums = list('0123456789') def round_index(index, length): if index >= 0 and index < length: return index if index >= length: return index % length return round_index(length + index, length) ...
800fd8ed6539a56b79db2cd64688d38396c72394
aseembrahma/projeuler
/prob37.py
1,622
3.546875
4
import sys from time import time from itertools import product from copy import copy prime_list = [2,3,5,7] def extend_prime_list(n): global prime_list current_last_prime = prime_list[-1] if current_last_prime >= n: return numlist = [True for x in range(current_last_prime+1, ...
4ebc645d16971233620d61d1f159d3da06bb378c
ferb2015/TargetOfferByPython
/59. 机器人的运动范围.py
2,591
3.578125
4
""" 题目描述 地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格, 但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。 但是,它不能进入方格(35,38),因为3+5+3+8 = 19。请问该机器人能够达到多少个格子? """ # 回溯法。有了上一题“矩阵的路径”的经验,在上一题的基础上更改代码就行了。 # return还是遇到了问题,这里flag=1之后不用再flag=0,依然是看牛客网讨论区的回答才AC. class Solution: def movingCount(s...
15fda221e4dd7325e75c5a29167f4c4c9baa3ffe
feecoding/Python
/Classes/Program 4.py
1,982
3.765625
4
##created by feecoding class stagair: pass t=list() n=0 while True: print("1:ADD a trainner") print("2:Edit a trainner") print("3:DELETE a trainner") print("4:List") print("5:Quit") c=int(input()) if(c==1): t.append(stagair()) n=n+1 t[n-1].nom=input("Enter first ...
734b813dcb65c7fc5acd390769f24c9ad439754e
IoanHadarean/Python-exercises
/learn_python/basic_operators.py
762
4
4
""" The target of this exercise is to create two lists called x_list and y_list, which contain 10 instances of the variables x and y, respectively. You are also required to create a list called big_list, which contains the variables x and y, 10 times each, by concatenating the two lists you h...
d9269652e47baf8c2a470fe9bd220fdb84190de8
sendurr/spring-grading
/submission - lab6/set2/ELLEN A UNDERWOOD_9452_assignsubmission_file_Lab 6/ELLEN A UNDERWOOD_9452_assignsubmission_file_Lab 6.py
596
3.953125
4
degF=float(input("Enter the degrees F:")) degC=(degF-32)*(5/9.0) print ("Degrees in celsius:",degC) import sys print ("Enter degrees F:") degF=float(sys.argv[0]) degC=(degF-32)*(5/9.0) print ("Degrees in Celsius:",degC) import argparse parser = argparse.ArgumentParser() parser.add_argument('-f', action='store', d...
76cafac773d83a281fdf2bd8d68a1ad9974cb186
nareshdb/codechefSolutions
/JAN19B_FANCY/answer.py
204
3.84375
4
noOfTestCases = input() for n in range(0, noOfTestCases): answerChecks = 0 wordsArray = map(str, raw_input().split()) if "not" in wordsArray: print("Real Fancy") else: print("regularly fancy")
408ae70b14a9494274c6e5ef2dcd71a1205f6dba
jacksonyoudi/AlgorithmCode
/PyProject/leetcode/history/design-circular-deque.py
2,056
4.03125
4
class MyCircularDeque: def __init__(self, k: int): """ Initialize your data structure here. Set the size of the deque to be k. """ self._deque = [] self._size = k def insertFront(self, value: int) -> bool: """ Adds an item at the front of Deque. Return t...
e3868e20cebd0d1339638b3aeee6eae56485d908
Andrew-C-Peterson/Project-Euler-Andrew
/PE031.py
294
3.796875
4
#How to make 2 lbs using different cominbations of coins #Dynamic programming coins = [1,2,5,10,20,50,100,200] count = [1]+[0]*200 for coin in coins: for i in range(coin, 201): count[i] += count[i-coin] print("Ways to make change =", count[200]) print("count = ", count)
61c1ec58a848250237740aa4c3388ad89287e70e
darraes/coding_questions
/v2/_leet_code_/0681_next_closest_time.py
1,097
3.5625
4
import itertools class Solution(object): def nextClosestTime(self, time): ans = start = 60 * int(time[:2]) + int(time[3:]) elapsed = 24 * 60 for h1, h2, m1, m2 in itertools.product( {int(x) for x in time if x != ":"}, repeat=4 ): hours, mins = 10 * h1 + h2, ...
03432204ee4b2cf92387b0564d854d4be857602d
gg4race/projecteuler
/problem4/problem4.py
994
3.796875
4
import math def main(): # loop through pairs of integers and return largest palindrome product a = 999 def isPalindrome(a, b): product = str(a * b) endIndex = len(product)/2 isPalindrome = True for i in range(0, endIndex): if (product[i] != product[len(produc...
d2ae84ecd8a6bab229d858b213ba28be7eaad282
lucypeony/stanford_algs
/merge_sort.py
934
4
4
# -*- coding: utf-8 -*- """ Stanford Algorithm Week 1 : Merge Sort Created on Tue Aug 9 20:24:23 2016 @author: Lucy """ def merge_sort(arr): #l = len(arr) if len(arr) < 2: return arr print("arr length: ",len(arr)) half = len(arr) // 2 left = merge_sort(arr[:half]) right = merge_sort(a...
c1780aa1abaf0fd3fd0602ba7b4bf5b62be036c7
sahusaurabh65/linear-regression-with-train_csv
/knn1.py
2,176
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 22 14:24:33 2018 @author: ADMIN """ import os import pandas as pd import numpy as np #Setting the path os.getcwd() os.chdir('C:/Users/ADMIN/Desktop/github') df=pd.read_csv('airbnb.csv',encoding='ISO-8859-1') #Load the csv and create a copy dc_listings = pd.read_csv('a...
2ea5d27083c8f31fca90c24662b8a327d8d14baa
JamesHaobo/test
/test01.py
501
3.609375
4
str1=input("请输入你所想要转换的温度(温度的格式是:134F、33C)\n") try: flag=str1[-1] num1=float(str1[0:-1]) if flag in ["F","f"]: print("华氏摄氏度"+str1+"转换后摄氏温度为"+str((int(num1)-32)/1.8)+"C") elif flag in ["C","c"] : print("摄氏摄氏度"+str1+"转换后华氏温度为"+str(int(num1)*1.8+32)+"F") else: print("请重新...
444532e5649313dd72676a0498dcf7c5bee8f8dd
mrodolfo1981/python
/dicionarios.py
137
3.515625
4
meu_dicionario = {"A": "AMEIXA","B":"BOLA","C":"CACHORRO"} for chave in meu_dicionario: print(chave)+":"+meu_dicionario[chave])
698b7924ecf551693245ecd4c99f9b9c05d49d7d
RickyZhong/CheckIO
/Home/Express Delivery.py
4,352
3.625
4
from collections import namedtuple from heapq import heappop, heappush, heapify Node = namedtuple("Node", ("Priority", "Cost", "Position", "Path", "Box")) def heuristic(position, goal): return abs(position[0] - goal[0]) + abs(position[1] - goal[1]) def get_neighbour(position, maze): directions = {'L': (0,...
caf68110a22327707fedec8085386695f283422d
Aasthaengg/IBMdataset
/Python_codes/p02713/s982627561.py
173
3.609375
4
k = int(input()) from math import gcd s = 0 for a in range(1, k+1): for b in range(1, k+1): g = gcd(a, b) for c in range(1, k+1): s += gcd(g, c) print(s)
944415e28c7f252879c9306e2002e79e6363df79
isthatjoke/projects
/python algorithm/lesson_6/Task_1_b.py
1,188
3.96875
4
# В одномерном массиве целых чисел определить два наименьших элемента. # Они могут быть как равны между собой (оба являться минимальными), так и различаться. # задание №7 урока 3 import random import sys def size(*values): summ = 0 for el in values: summ += sys.getsizeof(el) return summ def get_s...
57a645b84b8b011010568dda252d40ba138db329
lytvyn139/udemy-complete-python3-bootcamp
/15-loop-tasks.py
6,528
4.21875
4
########################################################### # FOR LOOP # for (let i=0; x< 10; i++) {} # for i in range(0, 10, 1): # print(i) # # increment of +1 is simplied # for y in range(0, 10): # print(y) # # increment of +1 and start at 0 is implied # for z in range(10): # ...
c29db44630a67380246aaf0f65aefaba0f85135d
mrshakirov/LeetCode
/30-Day LeetCoding Challenge/Week 1/Counting Elements 2v.py
708
3.84375
4
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3289/ from typing import List import collections class LeetCode: def countElements(self, arr: List[int]) -> int: result = 0 dict = {} for i in arr: if i in dict: dict[i]...
3ab3768c19874720b561e025150fa10ae19b3533
rrybar/pyCourseScripts
/SMRdemos/SMRdemos/Python3xDemos/smr_mapfilter.py
203
3.5625
4
#!/usr/bin/env python string_data = [ '-1', '0', '1', '2'] ints = map(int, string_data) doubled = map(lambda x: x * 2, ints) positives = filter(lambda x: x > 0, doubled) for n in positives: print (n)
32af9164a88870165264149d219d1f1e5a3ed7f6
huanzhizhixing/Learn-Python-The-Hard-Way
/ex21.py
1,071
4.09375
4
# -*- coding: utf-8 -*- def add(a,b):#这里的冒号经常丢 print "Adding %d +%d " % (a,b) #缩进出现错误。这里好多次了,总是改一下就行,不知怎么回事。以后试试tab return a + b def subtruct(a,b): print "Subtructing %d - %d" % (a,b) return a - b #这个函数一方面是赋值,另一方面是打印!实现了两个功能! def multiply(a,b): print "Multiply %d * %d" % (a,b) return a *...
677c63290691170de6fdbb271c3d6d3a06f12795
dhawal123456/Regex-Hackerrank
/Utopian Identification Number
209
3.578125
4
import re p = re.compile('^[a-z]{0,3}[0-9]{2,8}[A-Z]{3,}') n = int(input()) for i in range(n): x = str(input()) if(len(re.findall(p, x)) > 0): print("VALID") else: print("INVALID")
999196f569da9be2ba5e6b7edeaaab7b146f8032
MaryBeth8/Stand-alone-docs
/loops-greetings.py
566
4.34375
4
"""Adds the string 'Hello, ' in front of each name in names and appends the greeting to the list. Returns the new list containing the greetings. """ #version1 def add_greetings(names): greetings = [] for name in names: greetings.append('Hello, ' + name) return greetings print(add_greetings(["Owen", "Max...
2f1e04bfad44e2cbbafdbedb4e4f1be5402f6326
SchoBlockchain/ud_isdc_nd113
/8. Computer Vision and Classification/Temp/helpers_anim_1.py
6,394
3.625
4
""" Given a list of standardized images (same size), 1. It crops (given) 2. Creates separate red,yellow,green lists based on attached labels 3. Creates HSV for each image and display all as an animation This helps to get a overview of HSV variations for all images instead of having to go through one by one Author: ...
a30d60601344eff3e45ec523f535102f928fdba9
malikumarhassan/python
/loopexample.py
438
3.953125
4
count = 0 while (count <= 3) : print(count) count =count + 1 print('loops end') count = 0 while(count <=3): print(count) count = count + 1 else : print('while loop ends') count = 0 while(count <=3): print(count) count = count + 1 if (count ==2): print('if ...
7c619a5368e0691a4393f6f527e2e2b776ba6e79
ShubhamNagarkar/Pegasus_workflows
/Workflow_3/separate.py
596
3.8125
4
#!/usr/bin/env python3 import glob def separate(odd, even): """ separates numbers from the files into even and odd numbers. returns odd_nums.txt and even_nums.txt """ for filename in glob.glob("nums*.txt"): f = open(filename,"r") for line in f: num = line.strip("\n") ...
49cea55f4ad5a067a1b8467aea66eab19d57535f
jisshub/python-development
/pythonAdvanced/stack_queues.py
760
4.21875
4
# stack and queue operations using list # numbers = [] # # stack # numbers.append(30) # numbers.append(16) # numbers.append(15) # numbers.append(13) # print(numbers) # # # pop in list # # numbers.pop() # # print(numbers) # # # add an element # numbers.append(77) # # print(numbers) # # # pop # numbers.pop() # print(numb...
2b4f3f7b53c933d5d8ac743158a43f1bad2dfb1c
anjor/Coding-Problems
/elevation/elevation_study.py
2,403
3.75
4
#!/usr/bin/python ''' Solution to the Farmers' elevation problem''' class Tile: '''Defines a Tile class which contains the co-ordinates of the cell, along with its height''' def __init__(self, x, y, ht): '''Default constructor for Tile Class''' self.x = x self.y = y self.ht...
a3f81e16de0ed6351f21d8ebc049079dbbacf8eb
Jegardo/ML-Prwto
/MultipleReg/main.py
914
4.15625
4
import pandas from sklearn import linear_model df = pandas.read_csv("cars.csv") # Independent values in a variable called X: X = df[['Weight', 'Volume']] # Dependent values in a variable called y: y = df['CO2'] # The method called fit() takes the independent and dependent # values as parameters and fills the regress...
630f26bb29231f175fd37416adffbd627799c9dc
dpuman/CodeWithMoshPython
/CompleteCodewMOsh/Randoms/ClassVsInstanceMethods.py
277
3.75
4
class Point: default_color = 'Red' def __init__(self, x, y): self.x = x self.y = y @classmethod def zero(cls): return cls(12, 0) def print_It(self): print(f"{self.x} and {self.y}") point = Point.zero() point.print_It()
06e598236978d7056aa8072a84d42d8c9826eef4
olibyte/automation
/selenium/get_name.py
283
3.671875
4
#locate elements by their HTML name attribute from selenium import webdriver driver= webdriver.Chrome() driver.get("file:///C:/Users/ocben/automation/selenium/page.html") username = driver.find_element_by_name('username') print("My input element is:") print(username) driver.close()
7ee96a7d5e0522c70380904b99438a4c4a3e3d3f
evgeniyv6/fotor38
/ya_runup/algorithms/matrix_diag_sum.py
415
3.8125
4
#!/usr/bin/env python ''' 1 2 3 4 5 6 7 8 9 ''' def matrix_sum_diag(l: list) -> int: ''' :param l: list of lists :return: sum of main and opposite diagonals ''' n = len(l) sum = 0 for i in range(n): sum += l[i][i] + l[i][n-i-1] if n % 2 == 1: sum -= l[n // 2][n // 2] ...