blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2dbc1c9b2f2a1c105da8ea1e14442b2cc9fab6bd
DrGodCarl/AdventOfCode
/2015/day_10.py
402
3.671875
4
import itertools INPUT = '1321131112' def look_and_say(string): group = itertools.groupby(string) return ''.join(str(len(list(count))) + num for num, count in group) def iterate_look_and_say(string_in, iterations): for i in range(iterations): string_in = look_and_say(string_in) return strin...
aca5c7789000aacc836c0aafd98917f4f657cfd7
EdisonDevadoss/python-basics
/birthdays.py
502
4.1875
4
birthdays = {'Edison': 'June 21', 'Gibson': 'Aug 12', 'Benny': 'Aug 12', 'Puspha': 'Dec 08'} while True: print('Enter a name: (blank to quit)') name = input() if name == '': break if name in birthdays: print(birthdays[name] + ' is the birthday of ' + name) else: print('I do...
a6b49da48e3d880c34dd975f3b94eac2d497719e
rhender007/python-ps
/hackerrank_ps/string_repeat.py
606
4
4
# https://www.hackerrank.com/challenges/repeated-string/problem def repeatedString(s, n): len_of_string = len(s) n_letters = n quotient = n_letters // len_of_string remainder = n_letters % len_of_string # occurance of 'a' in the quotient solid_ocr = quotient * (s.count("a")) # occurance o...
7024fef57352a02720b7136911ebb1a079d8fdf5
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_206/82.py
622
3.703125
4
def solve(horses, distance): time = 0 for start, speed in horses: other_time = (distance - start) / speed time = max(time, other_time) return distance / time def main(): cases = int(input()) for case in range(1, cases+1): distance, number_of_horses = tuple(int(...
62379058e6f9bc0736dfe0bd582d9c7a9740a5c9
Hector-hedb12/MLPrimitives
/mlprimitives/adapters/pandas.py
1,816
3.65625
4
def resample(df, rule, time_index, groupby=None, aggregation='mean'): """pd.DataFrame.resample adapter. Call the `df.resample` method on the given time_index and afterwards call the indicated aggregation. Optionally group the dataframe by the indicated columns before performing the resampling. ...
de6cb5d3b797ab9f786c83bb0adeef6d3878c003
thaophung/multilayer_perceptron
/util.py
1,725
4
4
# Read each equation and its label from training/test set def print_equation(inputs, labels): # print "4 = 4" # print "4 + 2 = 1" equation_label = "" # Count to see how many element in vector equal 1 # If count == 1 that means the equation only have 1 operand (without operator) # so the print...
aab1b79221548365aef5fcd1947d537f32ea262f
saintifly/leetcode
/一年中的第几天.py
651
3.59375
4
class Solution: def dayOfYear(self, date: str) -> int: year = int(date.split("-")[0]) month = int(date.split("-")[1]) day = int(date.split("-")[2]) month_day_not_run =[31,28,31,30,31,30,31,31,30,31,30,31] month_day_run =[31,29,31,30,31,30,31,31,30,31,30,31] month_day=...
16eeb65f1d26a3003867745d9b4898d62fd0f408
baxievski/exercism
/python/difference-of-squares/difference_of_squares.py
390
4.125
4
def square_of_sum(n): return sum(x for x in range(1, n + 1)) ** 2 def sum_of_squares(n): return sum(x ** 2 for x in range(1, n + 1)) def difference_of_squares(n): return square_of_sum(n) - sum_of_squares(n) if __name__ == "__main__": print(f"{sum_of_squares(1)=}") print(f"{sum_of_squares(2)=}"...
3e692b09f29daf998144f0ba0d193a43d3f79656
sumitrac/Calculate-passive-income
/Calculate.py
2,608
3.875
4
#calculate three passive income such as writing_article, Tutoring, and walking dog #cost of services one_written_article = 80 one_hour_tutoring = 20 one_hour_walking_dog = 10 writing_article = [] tutoring = [] walking_dog = [] totals = [] counter = 1 def subscription_summary(writing_article, tutoring, walking_dog...
b4ffcb529655b6a5f6244a060833f2daa4ca4be1
ksoltan/invent_with_python
/btree.py
587
3.796875
4
import random def Add(tree, value): if not tree: tree.append(value) tree.append([]) return tree tree_value = tree[0] if tree_value == value: return Add(tree[1], [value]) # creates a new branch from this value, allowing for multiple branches else: return Add(tree[1], value) def Print(tree, ...
f30f6783ed6fa9574dea07a856c0206d0305b3c1
Poeschl/adventOfCode17
/adventOfCode2017/common/Utils.py
303
3.5625
4
def readInput(file): return readInputLines(file)[0] def printOutput(resutl1, result2): print("Part One: " + str(resutl1)) print("Part Two: " + str(result2)) def readInputLines(file): with open(file) as f: content = f.readlines() return [line.strip() for line in content]
2869f94dd36a9c04439d6da4c67d2a51dc1e5271
mnauman-tamu/ENGR-102
/roundoffError.py
2,979
3.515625
4
# roundoffError.py # # Compute boolean operations # # Muhammad Nauman # UIN: 927008027 # September 17, 2018 # ENGR 102-213 # # In collaboration with: Patrick Zhong, Daniel Huck, and Alexander Bogdan # # Lab 4A import math a = 1/7 print(a) b = a*7 print(b) print() a = 1/7 print(a) b = 7*a prin...
ac211659a61cb3488ead90946e238fc5b383adda
cyrionp/PythonLectures
/fonksiyonParametreleri.py
880
3.59375
4
''' def changeName(n): n="Sude" name="Sezen" print(name) changeName(name) print(name) def change(n): n[0]='adana' sehirler=['ankara','izmir'] print(sehirler) change(sehirler) print(sehirler) n=sehirler n[0]='antep' print(n) def add(*params): sum=0 for n in params: sum+=n return sum pri...
8e9a940148b05df0214f6659bc6345cdcb2bd9e5
kantal/WPC
/ISSUE-25/SOLUTION-3/manh002.py
1,359
3.515625
4
def mandis(px, py, qx, qy): return abs(px - qx) + abs(py - qy) def manhm(px, py, qx, qy, l, m, n, st, obst): if l==0 and px==qx and py==qy and px>=0 and px<=m and py>=0 and py<=n: print st #Should I use Python yield? else: for k in [[1, 0], [0, 1], [-1, 0], [0, -1]]: px1 = p...
3c7daee6e5ac957b8d53245d057c92968ae8f67c
chrisjdavie/GemStones
/solution/src/FirstGo.py
1,241
4.1875
4
''' Solving the Gem Stones hackerrank puzzle https://www.hackerrank.com/challenges/gem-stones ---------------------- Problem Statement John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lower-case Latin letter from 'a' to 'z'. An element can be present...
221f32dc8c20edb8e9ec07d23cafe0228b723219
pro2020Yuan/BCH5884
/20sep22/futuretime.py
461
3.65625
4
#!/usr/bin/env python Import sys print("Here") Sys.exit() #this is good for debug, put the last two lines anywhere you want to debug. now=int(input("Please enter a time in 24 hour format: ")) hoursahead=int(input("Please enter some number of hours in the future: ")) then24=(now+hoursahead%24)%24 then12=then24%12 day...
2fa2e5d6fccf0346cb495598309def7a411c7c1f
HillYang/PythonExercises
/PycharmProjects/ByteOfPy/continue.py
513
4.28125
4
while True: s1 = input('Please enter something you like (exit to quit):') if s1 == 'exit': break if len(s1) < 3: print('input is too small.') continue print('your input is of sufficient length.') print('continue example is done') while True: s = input('Please enter something...
37d581423afa206b4de9573d86a0ff5894595240
vamsinathani/GateOfIshtar
/gate_of_ishtar.py
5,720
3.65625
4
from datetime import datetime import calendar import ast class Gate: champion="" date_intervals=[] def __init__(self, champion, date_intervals): self.champion=champion self.date_intervals=date_intervals def invincible_days(self, date): invincible_days=calendar.day_name[date.w...
f42b03f47a30f18304be7a129072b28ce4d10e57
sunnysidesounds/InterviewQuestions
/general/house_robber.py
1,184
3.796875
4
# You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, # the only constraint stopping you from robbing each of them is that adjacent houses have security system connected # and it will automatically contact the police if two adjacent houses were broken i...
cbff4a895e2e6a49605df19a21b9b8f97c3d5581
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/preactive/Lesson2/series.py
1,859
3.75
4
def fib(n): if n == 1: return 0 if n == 2: return 1 return fib(n - 1) + fib(n - 2) # print(fib(8)) a,b = 0,1 def fib_gen(): global a, b while True: a, b = b, a + b yield a def fib_gen_teacher(): a,b = 0,1 while True: a, b = b, a + b yield a...
03bb58e4acb19500f16163f468335453d2f843de
lxieyang/python-tutorial
/Functional Programming/Higher-order_Function.py
536
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- print '---------------------------' print 'Assigning functions to var:' print '---------------------------' print 'Assigning abs to func:' func = abs print 'func(-15) is', func(-15) print '\n-----------------' print 'Pass in functions' print '-----------------' def add_le...
24e7e72bdc6a1ff452f3afff11e0eda0a915bc3b
Whee-Z/Test
/test5-insertion_sort.py
748
3.875
4
#插入排序算法,输入数字时以逗号隔开,输入exit退出循环 class Insertion_sort(object): def __init__(self): pass def insertion_sort(self,alist): n = len(alist) for i in range(1,n): for j in range(i,0,-1): if alist[j] < alist[j-1]: alist[j],alist[j-1] = ali...
551be9d724113b5edc32f33ac338ca1dc0f2c266
colgit/aidansFilenameChanger
/filename_changer.py
2,423
3.96875
4
# The purpose of this program is to rename the files in the active folder which # match the names in the first column, a_column, to match the names in the second column, b_column. # If there are duplicate names in b_column they will be renamed such that # (2),(3),(4)...etc is appended to the name. import csv impo...
481a6dc43894091492451252f4394730f450b1d6
WuShangpu/Geany_python_work
/5/5-4外星人颜色#2.py
223
3.71875
4
# -*- coding:utf-8 -*- alien_color = 'red' if alien_color == 'green': print('You get 5.') else: print('You get 10.') alien_color = 'green' if alien_color == 'green': print('You get 5.') else: print('You get 10.')
411bf8bc4a9ee7c310be58f6ec412f0e12bfca8c
yejialin/Coursera
/python/part1/Guess_the_number.py
1,633
4.125
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random import math correct_number = 100 time = 0 # helper function to start and restart the game def new_game(): range100() # define ev...
7e13258fb1c8f19dc390c5052f3414658ca9545c
GeeksIncorporated/playground
/stupid_sort.py
1,014
3.546875
4
import time import random from copy import copy n = 1000 arr = [random.randint(0, n) for i in range(n)] print(arr) def checksorted(arr): last = arr[0] for a in arr: if a < last: return False last = a return True def shuffle(arr): l = 0 r = len(arr) - 1 rint = ran...
8c6609cc3d73ff7568c8434c27806bb0b9c338bd
ObidulKadir/python-code
/New folder/ConditionalOperator/ifelse.py
154
4.21875
4
#if-else num= input("Enter the value:") a=int(num) if (a%2==0): print ("input values is even number") else: print("input values is odd number")
a73e3f71139a72ac1fb4f011a7309f7e55f456d1
mextier/PythonCommon
/MagicMethods.py
518
3.59375
4
#https://www.python-course.eu/python3_magic_methods.php #https://habrahabr.ru/post/186608/ #https://lancelote.gitbooks.io/intermediate-python/content/book/__slots__magic.html #__repr__ #__reversed__ #__len__ #__getitem__ #__round__ #__dict__ class TestLocals(object): def __init__(self, a, b, c, d, e, f=15): ...
3c90333f2e8859594fa69e203d537d09353b4ec5
shreyamalogi/Awesome_Python_Scripts
/BasicPythonScripts/Real-Time Currency Converter/currency_converter.py
2,224
4.25
4
#from the forex-python module import CurrencyRates and CurrencyCodes to perform the tasks required from forex_python.converter import CurrencyRates, CurrencyCodes #create objects for the imported packages rates = CurrencyRates() codes = CurrencyCodes() #Declare the functions according the task def excha...
6179e021b8557a9fe0489b5386c0762af8873d92
bits2018wilp/python-lab
/src/main/prep/stack_using_heap.py
474
3.65625
4
import heapq class StackElement: def __init__(self, val, counter): self.val = val self.counter = counter def __lt__(self, other): return other.counter < self.counter def __str__(self): return str(self.val) + ", " + str(self.counter) arr = [] i=0 heapq.heappush(arr, Sta...
0acae486ab12b3d742ad19d6ce9aa45e3c983a34
c42-arun/coding-challenges-python
/src/meeting_times/working_solution_mine.py
2,272
4.0625
4
def merge_ranges(meetings): # sort the meetings by start time # - sorting a list of tuples by default sorts by first element # - https://algocoding.wordpress.com/2015/04/14/how-to-sort-a-list-of-tuples-in-python-3-4/ meetings.sort() merged_meetings = [] # initialise with first meeting curre...
5ee7af43a1bb806f0fc97184031b099b2295bb49
1Saras/module2
/LPTHW/ex3_sarika.py
1,406
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 3 12:14:28 2018 @author: saras """ #Will print this string# print ("I will now count my chickens:") #adding 2 sets of numbers (hens) and then dividing by 6# print ("Hens", 25 + 30 / 6) #subtracting some roosters, then multiplying it and then finding the remainder# pri...
24d11a1822123fd5b36d1b9c46b4033036aee9a1
luismglvieira/Python-and-OpenCV
/00 - Python3 Tutorials/22 - Default arguments, args and kwargs.py
599
4.0625
4
# -*- coding: utf-8 -*- def student(name='Unknown name', age=0): print("name: ", name) print("age: ", age) student('luis') print() def student(name, age, *marks): print("name: ", name) print("age: ", age) #print("marks: ", marks) for x in marks: print(x) student('luis', 28, 95...
c77916cf56373e0bc9dbf272756411828389dadb
bourneagain/pythonBytes
/hasStringPathMatrix.py
1,059
3.5
4
class Point(): def __init__(self, x,y): self.x = x self.y = y def path(m,r,c,st): visited={} pathl = 0 for i in range(r): for j in range(c): if haspath(m, r,c, i,j, st, pathl, visited): return True return False def haspath(m, rowC, colC, cur_row, cur_col, st, pathl, visited): if pathl == len(st): ...
318494d1419e3075fc586b392f573be4f33a70df
vijayroykargwal/Infy-FP
/PF/Day4/src/Assign33.py
631
3.734375
4
#PF-Assgn-33 ''' Created on Feb 25, 2019 @author: vijay.pal01 ''' def find_common_characters(msg1,msg2): #Remove pass and write your logic here str1="" for i in range(0,len(msg1)): for j in range(0,len(msg2)): if((msg1[i]==msg2[j]) and (msg1[i] not in str1)): ...
9bb431f87d3aa6fa2c87d090d00b16e404162af4
mbuhot/mbuhot-euler-solutions
/python/problem-063.py
534
4.15625
4
#! /usr/bin/env python3 description = ''' Powerful digit counts Problem 63 The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power. How many n-digit positive integers exist which are also an nth power? ''' # 10**k has >k digits, so only need to look at numbe...
a68f5f090b4f9716100d340dc7f4d6127d0e43c6
waynewu6250/LeetCode-Solutions
/127.word-ladder.py
1,105
3.640625
4
# # @lc app=leetcode id=127 lang=python3 # # [127] Word Ladder # class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if not wordList or endWord not in wordList or not beginWord or not endWord: return 0 cache = collections.de...
a8b9c2b4560661a7e4c1143fb96c451ec84b2fe4
sansrit/ObjectOreintedProgramming-Python
/Basics/16.Functions_n_Variables.py
870
3.71875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 29 20:02:24 2020 @author: Sansrit Paudel FUNCTIONS AND VARIABLES """ def cheese_and_crackers(cheese_count, boxes_of_crackers): print("you have %d cheeses!" % cheese_count) print("you have %d boxes of crackers!" %boxes_of_crackers) ...
8cd76b1b22c57055727363853d5b29587f586bf5
davisonan/myPython
/Projects/words/main.py
2,199
3.546875
4
#' % Techniques related to NLP #' % Xu Tian #' % 2017/04/04 #' # Overview #' What are the key issues in natual language processing? The motivation to #' answer this question is from the need of preparing for the data scientist #' interview at BlackRock in Shimon's team. He asked me questions around text #' mining or o...
2ea6926868ff37c2ff0e1008be648c9ffe8e5306
mitubaEX/one_day_one_ABC
/ABC/001-050/012/C/main.py
621
3.515625
4
class Pair: a = 0 b = 0 def __init__(self, a, b): self.a = a self.b = b t = int(input()) sub = 2025 - t import itertools dic = {} for x, y in itertools.permutations([1, 2, 3, 4, 5, 6, 7, 8, 9], 2): an = x * y if an in dic: dic[an].append(Pair(x, y)) else: dic[...
a64be3fc2c3d1738a1e4b709de1db613f1b83209
CodenameCypher/Calculator-Using-Tkinter
/Calculator.py
8,424
3.859375
4
import tkinter from tkinter import* val = "" A = 0 operator = "" def button1_isClicked(): global val val = val + "1" data.set(val) def button2_isClicked(): global val val = val + "2" data.set(val) def button3_isClicked(): global val val = val + "3" data.set(val) def button4_isCl...
ab5b4e81521d122cd859304e5a7acbf687b77bdb
vogtdale/python
/leetCode/reverseInt.py
601
4.46875
4
''' given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. ''' def reverse(x): temp = str(abs(x)) reverse = int(temp[::-1]) # If reversing x causes the value # to go outside t...
aaf34938fc77ccf5181f195ac2826a662fd69786
jyash28/QA-website
/taskapp/check.py
1,046
3.671875
4
# def unique(str): # for i in range(len(str)): # for j in range(i + 1, len(str)): # if (str[i] == str[j]): # return # return True # # # str = "aaaa" # # if (unique(str)): # print("unique") # else: # print("duplicate") from collections import Counter # given= "yashh" ...
b1544923c5dda66728e1fd94f6280c5e6c15e50e
jason3189/Mr.zuo
/Mr.左/month01/代码/day18/code03.py
588
3.65625
4
""" 为学生的学习方法,添加新的功能(打印时间) """ import time def print_execute_time(func): def wrapper(*args, **kwargs): start_time=time.time() result= func(*args, **kwargs) execute_time=time.time()-start_time print("执行时间",execute_time) return result return wrapper class Student: def ...
7fda81c0ab8d8e4d7820d76eff4a3e4817fe9ebf
VVRaghavendra/HANDLING-DATA-USING-PYTHON
/moviedatacode.py
939
3.96875
4
import sqlite3 conn = sqlite3.connect('movies.db') c=conn.cursor() #c.execute("""CREATE TABLE movies( # name text, # actor text, # actress text, # director text, # yearofrelease integer # )""") #c.execu...
b2f45d223c33a9ebaa83763fd5f9f28f33b365cf
Rose-Lin/340_group_pj
/data/basic/parsetxt.py
8,031
3.515625
4
import sys import time import operator def parse_classTimes(file): """" A function used on basic data, returns professors list, rooms list and time slots list""" with open (file) as f: raw_content = f.read().strip() table = raw_content.split('\n') total_time_slots = int(table[0].split('...
c9913fb9b8ee2e7c93bb60244e9986f125b18a95
Dioclesiano/Estudos_sobre_Python
/Exercícios/ex019a - Usando RANDOM.py
450
4.0625
4
# Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude # ele, lendo o nome deles e escrevendo o nome do escolhido import random n1 = input('Primeiro aluno: ') n2 = input('Segundo aluno: ') n3 = input('Terceiro aluno: ') n4 = input('Quarto aluno: ') lista = [n1, n2, n3, n...
a6a323629645d4593b46e5868787e788ee06ce60
mohamed-elghayesh/PyHackerRank
/artificial_intelligence/simple_classification.py
2,153
3.5625
4
# Basic pandas reading, correlating, plotting of iris data # ‘data’, the data to learn, # ‘target’, the classification labels, # ‘target_names’, the meaning of the labels, # ‘feature_names’, the meaning of the features, # ‘DESCR’, the full description of the dataset, # ‘filename’, the physical location of iris cs...
22df1fa324242d5fd1a651ae23c4e068e3e0c001
martincastro1575/python
/8.- Functions/person_Return_a_Dictionary.py
438
3.8125
4
def build_person(first_name, last_name, age = None): '''Return a dictionary of information about a person.''' person = {'first_name': first_name, 'last_name': last_name} if age: person['age'] = age return person musician = build_person(first_name = 'Jimix', last_name = 'Hendrix', age = 35) pr...
248f3d2ffbaab7abdc28652ba2910d2739645b1f
jduelfer/Neural_Network
/network.py
5,984
4.1875
4
""" netowrk.py ~~~~~~~~~~ A module to implement the stochasic gradient descent learning algorithm for a feedforward neural network. Gradients are calculated using backpropogation. It is not optimized and omits many desireable features. """ import random import numpy as np #network object class Network(object): def ...
616c194c51102f31511ccb40b0422287adecd3d7
cyhe/Python-Note
/Base/1.5_If.py
854
3.953125
4
# if 语句的完成形式 注意冒号 : # if <条件判断1>: # <执行1> # elif <条件判断2>: # <执行2> # elif <条件判断3>: # <执行3> # else: # <执行4> inputNumber = input('请输入年份:') year = int(inputNumber) if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print(year, '是闰年') else: print(year, '不是闰年') # height = 1.75 # width = 80....
f650be48d58494f77cc9cc5db701a6ef2812a971
MKerbleski/Intro-Python
/src/python-example/day3_example.py
2,224
3.953125
4
# Implement a class to hold room information. This should have name and # description attributes. class Room: def __init__(self, name, description): self.name = name self.description = description self.n_to = None self.s_to = None self.e_to = None self.w_to = None ...
becc1cba50f7b87798bd64a7de996bebf7912214
ardavast/hackerrank
/python/13_regex_and_parsing/p16.py
366
3.96875
4
#!/usr/bin/env python3 # coding: utf-8 """ Validating Postal Codes https://www.hackerrank.com/challenges/validating-postalcode """ import re def is_valid(s): if (re.match(r'[1-9][0-9]{5}$') and re.findall(r'(\d)(?=\d\1)', s) < 2): return True else: return False if __name__ == '__ma...
cbbb50b2f37c2d1d41308fe946f4c5bb63809bb7
samir-0711/Leetcode-Python
/376. Wiggle Subsequence.py
2,878
3.953125
4
""" A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. For example, [1,7,4,9,2...
d099597f39e558a8172b5d90f27b6c50b1e8646f
Rxdxxn/Operatori-Python
/problema 5.py
442
3.6875
4
x=True y=False print("Functie logica AND:") print(x," ",y," ",x and y) print(y," ",x," ",y and x) print(x," ",x," ",x and x) print(y," ",y," ",y and y,end='\n\n') print("Functie logica OR:") print(x," ",y," ",x or y) print(y," ",x," ",y or x) print(x," ",x," ",...
0867ff2b8542021076d7989764fa96466480bc64
terodox/adventofcode2015
/Day03.py
1,776
3.578125
4
from DataReader import DataReader class AdventDayThree: def get_answer_part1(self): #2572 position = Position(0, 0) houses = {self.get_dict_key_from_position(position): True} for move in DataReader.read_data(day=3)[0]: position = AdventDayThree.adjust_pos_for_move(posit...
2b505f76317c5015214e20c31048871b47f3879e
yns01/leetcode
/116-vertical-order-traversal.py
1,273
3.75
4
from typing import List from collections import deque, defaultdict class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_left(self, value): self.left = TreeNode(value) return self.left def i...
c7df0c2ccf6930af4aa7abf4c211df15ed1934ef
echocho/Leetcode
/Leetcode371_sumOfTwoIntegers.py
299
3.828125
4
# Leetcode371_sumOfTwoIntegers.py def getSum(a, b): """ :type a: int :type b: int :rtype: int """ # Solution 1: use bitwise operation while b: carry = a & b a ^= b b = carry << 1 return a print(getSum(6, 3) == 9) print(getSum(9, 4) == 13)
74f92b19ffd62c01d19ba2cbd64c655dd9cdc9a0
ecks/arimaai
/final/Common.py
502
3.640625
4
import string nextColor = string.maketrans("wb", "bw") def displayBoard(board): print " ", for letter in range(97, 105): print chr(letter), print rowNum = 8 for i in board: print rowNum, for j in i: print j, pri...
f1390883b460353f938df88b9bd5a2441b8037fc
tollefj/AlgDat_Git
/Ovinger/Oving2/innlev2.py
1,302
3.5625
4
from sys import stdin, stderr import traceback class Node: def __init__(self): self.children = {} self.pos = [] def bygg(wordlist): _root = Node() for (word, position) in wordlist: node = _root for letter in word: if not letter in node.children: node.children[l...
237796cb17ce30185608cf3ff147e9d2166e220c
VeePollux/BioPython
/IndFamilias.py
836
4.125
4
'''O usuário deve digitar o nome de uma família biológica. Se o nome da família terminar com -aceae, o programa deve informar que se trata de uma família de plantas; se terminar com -idae, se trata de uma família de animais; se não tiver nenhum sufixo, o programa deve afirmar que se trata de um táxon desconhecido''' n...
45461852f3a3d91bc865050afdf15a7650e9a9b8
AiSDPM/Sorting
/pivot.py
1,678
3.59375
4
import math import random import copy import time class Stacks: def __init__(self): self.tab = [] def push(self, a, b): self.tab.append((a, b)) def pop(self): pom = self.tab.pop(-1) return pom def empty(self): if len(self.tab) > 0: return False ...
b12a28a1ddf9b04aaff855dbcedf541cc6914a42
GaloMago/URI_Answers_py
/uri_1021.py
1,334
3.953125
4
def main(): #entrada valor = float(input()) #processamento nota_100 = valor / 100 resto = valor % 100 nota_50 = resto / 50 resto = resto % 50 nota_20 = resto / 20 resto = resto % 20 nota_10 = resto / 10 resto = resto % 10 nota_5 = resto / 5 resto = rest...
ddca87691a7efa4e57e7cc81098aa10203e8ae1a
srajanpro/xkcd_comic_downloader
/xkcd_comics_downloader.py
1,924
3.796875
4
#Program in python3 to download comics from a range x to y given by a user #Run the code by typing: python3 xkcd_comic_downloader.py to make it work correctly #Also don't forget to change the directory in the program, where you want your downloaded files to be saved #All the downloaded comics are saved in /home/srajan/...
cc93094fc6b55343eb553a9f08144a37eeac9c3c
RubbishBird/BoatGame
/ship.py
1,915
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2018/8/17 11:30 # @Author : feng # @Site : # @File : ship.py # @Software: PyCharm import pygame from pygame.sprite import Sprite class Ship(Sprite): def __init__(self, ai_settings, screen): '''初始化飞船,并设置其初始位置''' super(Ship, self).__init...
8b3e4c42d1a152ddf2b1d6d1e51818a7569addf8
anildoferreira/CursoPython-PyCharm
/exercicios/aula9-ex025.py
113
3.84375
4
import n = str(input('Digite o seu nome: ')).split print('O seu nome tem Silva? {}'.format('silva' in n.lower()))
e1b796995376347e6f4d601f1a194955d3d4fb14
danxie1999/python_test
/9_9.py
145
3.65625
4
#!/usr/bin/env python3 for i in range(1,10): for j in range(1,10): res=i*j print ( '%s * %s = %s' % (i,j,res)) print('')
4c837ea3f9e8d7e51b7c277fbd58590902d8608d
elvyscruz/logica_computacional
/dec2bin.py
227
3.921875
4
# programa que convierte de decimal a binario dec = input("Digite numero-> ") dec = int(dec) bin = [] while dec >= 1: bin.append(dec % 2) dec = dec // 2 bin.reverse() for num in bin: print(num, end='') print("")
bd298eed4d79d2139ff578c33170a3a94ba3b3d4
MridulMarkandey1999/Machine_Learning_and_Artificial_Intelligence
/socket_programming_client.py
1,155
3.65625
4
import socket s = socket.socket() server_ip ="192.168.43.141" server_port =2222 s.connect((server_ip, server_port)) location = input("Enter location (local/remote): ") print(location) location = location.encode() s.send(location) if location.decode() == "local": while True: print("""" ...
fc22ed497ec2d75739f4260f649b2db2110f1399
pabloruancoder/aula-pec-2020
/05t2q4.py
186
3.671875
4
for num in range(99,0,-11): print(f'{num} bugs no software, pegue onze deles e conserte...') print('Tecle "Ctrl+F5"') print('Sem erros no software! Está estabilizado!')
d84b56ed5425e7e0027180f27e3d7e2a741941cd
wu-uw/OpenCompetition
/src/common/pytorch/network/cin/CIN/IO/base_cache.py
277
3.5
4
"""define abstract base class""" import abc __all__ = ["BaseCache"] class BaseCache(object): """abstract base class""" @abc.abstractmethod def write_tfrecord(self, infile, outfile, hparams): """Subclass must implement this.""" pass
28d47f7a7a1c6b6ae7fd586ad3af933f8edf9e74
danorel/KNN
/src/modules/utilities/learning/interface.py
219
3.65625
4
import abc class AbstractLearningKNN(abc.ABC): @abc.abstractmethod def learn_model(self) -> int: """ Return the most efficient K-neighbour number. :return: int """ pass
4bb48df96e85bf156f38fd92dd2ba144f79ebfd2
JAJAKUL/CAP930jj
/ca1Q2.py
697
4.4375
4
name="Md Jajakul Islam" first_name='Md' mid_name='Jajakul' last_name='Islam' #concatenation the name print('concatenate the name '+first_name+' '+mid_name+' '+last_name) #reverse the name string print(name[::-1]) #slice first three charcter from beginig print(mid_name[:3]) #slice first three charcter from opposite prin...
0b75893ec71744e41e6430a9b9d74da36fc67865
zabeerrahman/Python-Flask-BackendShowcase
/draft_PythonFlaskBackendShowcase.py
11,793
3.859375
4
# First import the Flask class from the flask package into Python from flask import Flask # Setting variable "app" to instance of Flask class, since Python will be running the script, __name__ = __main__ app = Flask(__name__) # Create route(s) for home page @app.route("/") @app.route("/home") def home(): ...
4d79e52c1ed2b5755d923fc7d07265d26b70502b
sureshmelvinsigera/cidei
/backend/lab1/lab1_5.py
257
3.921875
4
# No funciona en Python3 sum = 0.0 data = input("Ingrese un numero: ") while data != "": number = float(data) sum+=number data = float(int(input("Ingrese el siguiente numero: "))) number = float(data) sum+=number print("Esa suma extrana es: ", sum)
80ac46af78faf9e360e7bd1a3605bd93676add80
TrickFF/helloworld
/file_read.py
425
3.53125
4
# открываем файл на чтение f = open('first.txt', 'r') # 1й вариант #print(f.read()) # 2й вариант # for line in f: # print(line.replace('\n', '')) # учитывая, что в файле есть переносы строк, # # мы заменяем символ переноса строки на пустой символ print(f.readlines())
07ae709484a691f0c71113cab3800abb9cb40def
AP-MI-2021/lab-1-oargaclaudia
/main.py
1,980
3.8125
4
def is_prime(n): if n<2: return False if n==2: return True for i in range(2,n//2+1): if n%i==0: return False return True def test_is_prime(): assert is_prime(2)==True assert is_prime(3)==True assert is_prime(4)==False def get_cmmdc_v1(a,b): while...
9b29a49a12a4c01614c25e5eef2b7e850fad50dd
BTS-413/1.Hafta
/16701025/kosullar.py
227
3.671875
4
""" == -->>> esit is : varsa girinti birakmaliyiz(4 bosluk her girinti)|kosul fonksiyon sinif olabilir.| """ x = int(input("sayi giriniz: ")) if x == 5: print("Dogru deger") else: print("Yanlis deger")
17cbe2d71fd822533e3d799762393f685b4490de
jc319812/CP1404_Pracs
/counter.py
441
3.96875
4
input_text = input("Text: ") formatted_input = input_text.strip().lower().split() word_counts = {} for word in formatted_input: word_counts[word] = formatted_input.count(word) print(word_counts) longest_word_length = 0 for key in word_counts: if len(key) > longest_word_length: longest_word_length =...
e83225b66c6276246a8ad2be51b4469fc619bbf0
abdullatheef/Python-exercises
/chapter3/makeslug.py
206
4.21875
4
# Program to write a function make_slug that takes a name converts it into a slug import re def make_slug(): ro=re.findall(r'\w+',st) print ('-').join(ro) st=raw_input("Enter the string:") make_slug()
0a60dbd62ab940dfdfdc0510033930914cd2b416
adelq/project-euler
/38.py
957
3.984375
4
# Set to check if a number is pandigital pan = set("123456789") # Not used in this problem but may come in handy # def setmaker(n): # return set(x for x in str(n)) def concatProduct(n, pan): """ Input is a fixed number and a list, function will return concatenated product of the fixed number with individual eleme...
582ca9c5e509ce716289ecce202fcddb5902efbc
hoanghuyen98/fundamental-c4e19
/Session03/homeword/clothes_shop.py
1,639
4.03125
4
shop = ['T-shirt', 'áo len'] loop = True while loop : print() choose = input("Welcome to our shop. What do you want (C, R, U, D)? ") print() if choose == 'R'or choose == 'r': print("Our item ==> ",end = "") print(*shop, sep = ", ") if choose == 'C' or choose == 'c' : ne...
c95223c57a1d9b05bd1b91fca05815025f98afb4
Hyun-JaeUng/TIL
/PythonExam/Day5/listLab3.py
390
3.796875
4
listnum = [10,5,7,21,4,8,18] min_num = 0 max_num = 0 for i in range(len(listnum)): if i == 0: min_num = listnum[0] max_num = listnum[0] else: if min_num >= listnum[i]: min_num = listnum[i] elif max_num <= listnum[i]: max_num = listnum[i] else: ...
ecc9fadc933d413c2f8e8ebb9ba65309f4f90222
manoharaswal/TechgigSolution
/Python/StringLower.py
212
4.0625
4
''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT def main(): str = raw_input() print(str.lower()) main()
0518a471d0ecc9c5cd2b24bffb947043426ef0ab
ChungYujoyce/HW2---Substitution-Cipher-Solver
/solve.py
5,508
3.796875
4
import itertools with open('textfile/ciphertext1.txt') as f: cipher = f.read() count = 0 for c in cipher: if c.isupper(): count +=1 flagg = cipher[1:20] with open('three_no_spaces_freqs.txt') as ff: triscores = {} # type(ff) <class '_io.TextIOWrapper'> # type...
7c134660ff7b254f24316afd23c26cb2d84f0c63
mattheww22/COOP2018
/Chapter06/U06_Ex_04_functions2.py
1,227
4.40625
4
# U06_Ex_04_MacDonald.py # # Author: Matthew Wiggans # Course: Coding for OOP # Section: A3 # Date: 14 Dec 2019 # IDE: PyCharm # # Assignment Info # Exercise: 04 # Source: Python Programming # Chapter: 06 # # Program Description # # This program returns the sum of the first "n" natural numbers and t...
0286a1fad644bab488fc70efd9a01ddfa39ea5cb
Amritpal-001/100-days-of-code
/EulerProject-solvedExamples/Problem 14 - version 2.py
432
3.671875
4
asd = 10 print(asd) def Chainlength(x): b = 0 while x != 1: if x%2 == 1: x = int(3*x + 1) b = b + 1 if x%2 == 0: x = int(x/2) b = b + 1 #print("chain length" , b) return(b) i = 0 while i < 10: z = Chainlength(i) print(z) b = ...
0f1a922340190f17075a8f3d0a4a07568a9647a0
aakashkawale/Python
/Assignment 1/Cheacking Electricity Bill By Taking Elecrtricity unit as input.py
486
3.9375
4
a=int(input("Enter Your Electricity Units : ")) if a<=50: b=a*0.50 ac=(a*20)/100 tb=b+ac print("Your Light Bil Is " + str(tb) + " Rs") elif a>50 and a<=150: b=a*0.75 ac=(a*20)/100 tb=b+ac print("Your Light Bil Is " + str(tb) + " Rs") elif a>150 and a<=250: b=a*1.20 ac=(a*20)/100 ...
e96583f42df1d013e81779cf256b698d56b984c6
Mystery-College-of-The-Adapts/cursus
/Coursera/Python-for-Everybody-Specialization/Python-Data-Structures/assignment7.1.py
303
4.34375
4
"""a program to read through a file and print the contents of the file (line by line) all in upper case""" # Open the file fname = raw_input('Enter the file name:') try: f = open(fname) except: print 'File cannot be opened:', fname exit() for line in f: line = line.rstrip() print line.upper()
38f1c0fa7edfaff7eb13843a8025d582021648a1
abeasock/kanga
/roo.py
4,882
3.984375
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 22 10:15:23 2016 Author: Amber Zaratsian """ from tutorials import tutorial_1_basic_syntax, tutorial_2_var_types_and_basic_operations, tutorial_3_lists, tutorial_4_tuples, tutorial_5_dictionaries, tutorial_6_loops import textwrap print print print "#######...
4a7ae6ab857128789400edfda12c757472aa856f
bmolina-nyc/ByteAcademyWork
/Week1/Week1Day2/5-recursion-hanoi/towers.py
363
3.890625
4
def towers_of_hanoi(n, initial_peg, aux_peg, final_peg): if n <= 0: pass else: for h in towers_of_hanoi(n-1, initial_peg, final_peg, aux_peg): yield h yield (initial_peg, aux_peg) for h in towers_of_hanoi(n-1, final_peg, aux_peg, initial_peg): yield h p...
c23f92d8ea10a699e6b7f78bdbc740a01973f96b
hawksong/pythontest
/pylearn/src/test/sortmaopiao.py
302
3.5625
4
''' Created on 2017年12月14日 @author: user ''' array = [9,2,7,4,5,6,3,8,1,10] L = len(array) for i in range(L): for j in range(L-i): if array[L-j-1]<array[L-j-2]: array[L-j-1],array[L-j-2]=array[L-j-2],array[L-j-1] for i in range(L): print (array[i])
03202a35d62ff20a1f33b738328061377af946db
volodymyrd/ml
/tutorial/pandas/indexing.py
383
4
4
import pandas as pd data = {'col_1': [1, 2, 3, 4, 5, 6, 7], 'col_2': [5, 4, 3, 2, 1, 0, -1], 'col_3': [10, 9, 8, 7, 6, 5, 4], 'name': ['AA', 'BB', 'CC', 'DD', 'EE', 'II', 'KK'], 'col_4': [2, 4, 6, 8, 10, 12, 14], 'col_5': [1, 3, 5, 7, 9, 11, 13], } df = pd.DataFrame(data) print...
130d27c0e90b166e997419968c6962f123eea2cc
dlasing/udemy_python_class
/dailycode/MaxHouseTotal.py
1,367
4.03125
4
# You are a professional robber planning to rob houses # along a street. Each house has a certain amount of # money stashed, the only constraint stopping you from # robbing each of them is that adjacent houses have # security system connected and it will automatically # contact the police if two adjacent houses we...
afc28098e49756a1e7294b96340b44deab634940
LNS98/Blackjack
/player.py
1,208
3.6875
4
class Player: def __init__(self, player_name, intial_bank): self.player_name = player_name self.hand = [] self.tot_money = intial_bank def add_card(self, card): self.hand.append(card) def disp_hand(self): print("{}'s Hand:".format(self.player_name), [str(card...
6a4df57ee4bee91ca20a6c9c51534ad4c30240a2
Louiii/DPPsForRL
/ReinforcementLearningWithDPPs/Environments/BlockingTask.py
5,192
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 17 12:50:49 2019 @author: louisrobinson """ from PrintState import maze_record, makeGIF import numpy as np class BlockerTask: def __init__(self): ''' state is the coords of the agent blockers state is the index of the empty squ...
d472718b5632b66ff995aff414d4830b6a6b8b60
abhishekxix/Programs
/python/formattedstrings.py
307
3.890625
4
first = 'Abhishek' last = 'Singh' message = first + ' [' + last + '] ' + 'is a coder' print(message) #it is not an ideal approach due to limitation in visualisation msg = f'{first} [{last}] is a coder ' #this is a formatted string msg = f'{first} [{last}] is a coder ' #this is a formatted string print(msg)
44f677166c6045db9f67919ea41ae1ba34de7bff
ratatatatat/blackjackEngine
/models/bjCount.py
558
3.546875
4
def scoreCount(cardArray): count = 0 for element in cardArray: value = convertValue(element) if(len(value) == 1): count = count + value[0] elif(len(value) == 2): bufCount1 = count + value[0] bufCount2 = count + value[1] if((bufCount1 > 21 and bufCount2 < 22)): count = bufCount2 elif((bufCoun...
fb3261fa1a486934ea56a209d09c0842b8ad2d89
xiaoxingyu3618/2
/day17/demo01.py
327
4.0625
4
list01 = [3, "54", True, 6, "76", 1.6, False, 3.5] # 生成器函数 def find_int(list_target): for item in list_target: if type(item) == int: yield item # # # re = find_int(list01) # for item in re: # print(item) re = (item for item in list01 if type(item) == int) for item in re: print(item)
af71b4d5bf26c0f670959189a858ebfe54ff36b1
martinmeagher/UCD_Exercises
/Module8_Intro_to_Data_Visualisation_with_Seaborn/3a_Count_Plots_and_Bar_Plots.py
1,353
3.796875
4
# Import Matplotlib and Seaborn import matplotlib.pyplot as plt import seaborn as sns import pandas as pd file = 'young-people-survey-responses.csv' survey_data = pd.read_csv(file) # Create count plot of internet usage sns.catplot(x="Internet usage", data=survey_data, kind="count") # Show plot plt.show() # Change t...