blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2db607a082883f797dbb726ee982b15d6c35758d
prijindal/hackeearth
/problem/algorithm/rest-in-peace-21-1.py
234
3.765625
4
for i in xrange(input()): N = input() if N%21 == 0: print("The streak is broken!") elif str(N).find('21') >=0: print("The streak is broken!") else: print("The streak lives still in our heart!")
7760e403dcb34f8f9bf4b736443ab69230bb9375
hoodielive/modernpy
/2022/beazley/closures.py
462
3.84375
4
x = 10 y = 'hello, world' items = [10, 20] names = ['dave', 'Thomas', 'Lewis', 'paula'] names = names.sort(key=lambda name: name.upper()) print(names) def greeting(name): print("hello", name) greeting('Guido') print(greeting) g = greeting g('Guide') items.append(greeting) print(items[2]) print(items[2]('O...
c49836f2e56130e13c2dacd1c19ed24793523e5b
hirak0373/AI-Practices
/marksheet.py
672
4.0625
4
eng =input("Enter marks of English: ") bio = input("Enter marks of Biology: ") chem = input("Enter marks of Chemistry: ") pak = input("Enter marks of Pakistan Sudies: ") sin = input("Enter marks of Sindhi: " ) obtain =int(eng)+int(bio)+int(chem)+int(pak)+int(sin) print (obtain) per =int(obtain)/425 per1=per*100 print("...
a1e36e9263692b0e4a178d57b6334878051b3aee
ppli2015/leetcode
/9 Palindrome Number.py
410
3.515625
4
# -*-coding:cp936-*- __author__ = 'lpp' class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0: return False x = str(x) print x for i in range(len(x) / 2): if x[i] != x[0 - i - 1]: ...
0e66d86b3ac7f5322e1d0e940ceafa8e5d5228d4
JeffHanna/Advent_of_Code_2018
/day_09.py
6,887
4.09375
4
# -+- coding utf-8 -*- """ --- Day 9: Marble Mania --- You talk to the Elves while you wait for your navigation system to initialize. To pass the time, they introduce you to their favorite marble game. The Elves play this game by taking turns arranging the marbles in a circle according to very particular rules. The ma...
9ed588d3366c2690f2368fb9de70e8746cf4b17d
Fengyongming0311/TANUKI
/Zero_Python/0-2章.Python的基本语法/python基本语法.py
11,399
3.90625
4
python内置函数 Python dir() 函数 https://www.cnblogs.com/mq0036/p/7205626.html self.assertEqual('Action Bar', els[1].text) self.assertEqual(a,b,msg=msg) #判断a与1.b是否一致,msg类似备注,可以为空 self.assertNotEqual(a,b,msg=msg) #判断a与b是否不一致 self.assertTrue(a,msg=none) #判断a是否为True self.assertFalse(b,msg=none) #判断b是否为false Python程序语...
91788e186c882685265ea2ac9eedb4728f14621a
saghevli/conway_life
/conway_life.py
2,952
4.21875
4
# conway's game of life # rules: # any live cell with fewer than two live neighbors dies # a live cell with two or three live neighbors lives # a live cell with four or more live neighbors dies # a dead cell with > 3 live neighbors import time BOARD_SIZE = 41 generation = 0 def main(): interval = .5 board = ...
08b524796160ba0b12a7b580d5197e66b0f73a1e
russellgao/algorithm
/dailyQuestion/2020/2020-04/04-27/python/py1.py
1,099
3.890625
4
# 方法一 # 顺序合并 # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None def mergeKLists(lists): """ :type lists: List[ListNode] :rtype: ListNode """ def mergeTwo(list1, list2) : head = ListNode() pre_head =...
2f3eeeaf13c553dc35eaf4ec5e5acf8ebf040e2e
AndreasHae/tictactoe-py
/model/test_game.py
823
3.6875
4
import unittest from model.game import Game class GameTest(unittest.TestCase): def setUp(self): self.game = Game() def test_next_player(self): first_player = self.game.next_player self.game.turn(0, 0) second_player = self.game.next_player self.game.turn(1, 0) ...
a35bffa98fef5c129aefcb1a776f97f5d4c26ed0
Dylan-Barclay/fundamentals
/functions_basic_ii/functions_basic_ii.py
707
3.75
4
# 1. def countDown(max): for x in range(max,-1,-1): print(x) countDown(10) print('') #2. def printReturn(first, second): print(first) return(second) print(printReturn(1,2)) print('') #3. x = [1,2,3,4,5,6,7,8,9] def firstPlusLength(x): print(x[0] + len(x)) firstPlusLength(x) print('') #4. ...
d745b37537b120f5ba8789f87c1c7940ddda64f6
fzingithub/SwordRefers2Offer
/3_Offer2nd-HandWriting/3_Queue&Stack/2_队列和栈_队列中的最大值.py
848
3.9375
4
class MaxQueue: def __init__(self): self.queue = [] self.IO2Queue = [] # 维护一张单调非减的双端队列 [5,3,3,1_最短回文串.py] def max_value(self): if not self.queue: return -1 else: return self.IO2Queue[0] def push_back(self, value): while self.IO2Queue and se...
27225a0aa68a2ff5d62182850c1c8c9ccc8270d4
IlyaNazaruk/python_courses
/HW/10/task_10_4.py
804
3.65625
4
# Имеются два текстовых файла с одинаковым числом строк. # Выяснить, совпадают ли их строки. # Если нет, то получить номер первой строки, в которой эти файлы отличаются друг от друга. def compare_lines(lines_1, lines_2): for number, line in enumerate(lines_1): if line != lines_2[number]: retur...
b373b3fcbc02ad49b3582da332394ecaa60902c9
brajesh-rit/hardcore-programmer
/Rough/fibonacci_memo.py
201
3.625
4
def fib (n, memo = {}): if (n in memo): return memo[n] if (n <= 2): return 1 memo[n] = fib(n-1 , memo ) + fib(n-2, memo) return memo[n] print(fib(6)) print(fib(7)) print(fib(8)) print(fib(50))
44767425956f3596d6a1eac5d9ceae408d4a2beb
qianhk/ToChildren
/main.py
1,417
4.15625
4
#!/usr/bin/env python3 # coding=utf-8 import time def print_hi(name): print(f'Hi, {name}') def is_leap_year(year): if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): print(f'{year}年是闰年') # print(f'\033[0;32m{year}年是闰年\033[0m') else: print(f'{year}年不是闰年') # print(...
2fee5df6830ffb59ad18aac03f87731c209de0ac
reokashiwa/KyotoPythonDrill
/section2.py
863
3.859375
4
a = 1 + 2 # aの値を標準出力に出力します。 print(a) # => a # idはpythonのbuilt-in functionです。 # Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. # オブジェクトとしての固有値を出力してくれる、という理...
1b68a8e7dda9a6d812c4f6c2407797177ad9c621
campbellmarianna/Code-Challenges
/python/spd_2_4/two_sum_solutions.py
1,426
3.921875
4
''' Two Sum Problem: Given an array a of n numbers and a target value t, find two numbers whose sum is t. Example: a=[5, 3, 6, 8, 2, 4, 7], t=10 => [3, 7] or [6, 4] or [8, 2] There are multiple ways to solve Two Sum. What is described below: - solution ideas - code implementations ''' # Solution Idea #1 # - cr...
9ad1d92dbe259f710b86505589c321e07b3365c5
zhuliangnan/Python_Learning-journey
/untitled/Day3_function.py
1,422
3.765625
4
#函数的使用与定义 #abs(x) 绝对值 print(abs(-97.4)) #max(a,b,c,d...) 返回最大值 print(max(1.9,1.7,9.0,6)) l=[1,6,9,4,79] print(max(l))#显然它也可以接受 list类型 #类型转换函数 int() str() bool() print(int('657')) #print(int('a')) 这个是不行的 print(str(234.8)) print(bool(-1),bool(4),bool('a'),bool(''),bool(0))#空字符串和0都是false print('this is following is def fu...
6fcbd4940406ebaacdd52d2a1136e1bfc14797d8
stephenchenxj/myLeetCode
/isomorphicString.py
3,110
3.921875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 17 20:56:26 2019 @author: dev 205. Isomorphic Strings Easy Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced w...
e66d56d490163e074f2903239510c82a6010c524
jyoon1421/py202002
/Ch3_2.py
212
3.5625
4
test_size = int( input() ) for i in range (test_size): num, text = input().split() num = int(num) text = str(text) for j in range (len(text)): print( num * text[j], end='' ) print()
5604e0759263490a051edeef94af96ac14e7a4de
billyxs/notes.md
/python/learning/code/student_manager/hs_student.py
290
3.703125
4
# Class inheritance class HighSchoolStudent(Student): school_name = "Springfield High" def get_school_name(self): return "This is a High School Student" def get_name_capitalize(self): orig_value = super().get_name_capitalize() return orig_value + "HS"
ab0dfc3eb968dbb106aa79ac5a44ac30d75c3e12
norwald/ThinkStats
/first.py
2,199
3.921875
4
#!/usr/bin/python from resources import survey class First: """ Calculates number of live birds Args: list of pregnancy records Returns: number of live birds """ def calc_live_births(self): live_births = 0 for record in self.get_records(): if record.out...
6510ba9b132db8838f7243200ba22b73094cdaa8
jordanchenml/leetcode_python
/0101_SymmetricTree.py
825
4.3125
4
''' For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 ''' # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSymmetric(self, root: TreeNod...
b7d8ecdd9c367717410adbddc131170569ea9bea
filipzivanovic/57-Exercises-for-Programmers
/3_Calculations/13_Determining_Compound_Interest.py
1,003
3.9375
4
import math def inputNumber(what): while True: try: userInput = float(input("Enter the %s: " % what)) if(userInput <= 0): print("Not a positive number! Try again.") continue except ValueError: print("Not a number! Try again.") ...
bd7ce9e260eaf740b3e33badc6a39ac9bbda7a0e
Sabinu/6.00x
/2.03 Lecture 16 - Sampling & Monte Carlo Methods/01_rollDice.py
1,005
3.5625
4
import random def rollDie(): return random.choice([1, 2, 3, 4, 5, 6]) def rollN(n): result = '' for i in range(n): result += str(rollDie()) return result print('5 random rolls of a Die:', rollN(5)) def getTarget(goal): numTries = 0 numRolls = len(goal) while True: numT...
58d5badfaa74bc2e318ee4af1cc7822b56f8722e
rayhan60611/Python-A-2-Z
/8.Chapter-8/05_pr_01.py
630
4.125
4
def maximum(num1, num2, num3): if (num1>num2): if(num1>num3): return num1 else: return num3 else: if(num2>num3): return num2 else: return num3 m = maximum(13, 55, 2) print("The value of the maximum is " + str(m)) # different Solve...
a4eee347a9bf8c969cdb29cc2e8c3ca3c37d27f1
BryanSWong/Python
/ex21/ex21sd4.py
785
4.15625
4
# for study drill part four make a simple formula and use the functions to make it. def add(a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return a - b def multiply(a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b ...
f451fa6bde2aa192e23f8ffca14ba439465759b7
spiderr7/cls-python
/Desktop/Program/Variable's/8.non_local.py
193
3.65625
4
a,b=1,2 print(a,b) def outer(): a,b=10,20 print(a,b) def swap(): nonlocal a,b a,b=b,a print(a,b) print(a,b) swap() print(a,b) outer() print(a,b)
282b22b45fd627098c97c4cc1859a49424b29f8c
hanbyeol94628/demoHanbyeol
/src/main/webapp/WEB-INF/uploadFiles/5slvsVtpwJnD67y2I0DokN2UQKJ0a352.py
825
3.921875
4
""" print('\n\n') print("태어난 년도를 입력하세요 : ", end="") years = input() print(int(years) >= 90) print('\n\n') print("파이썬 영어 철자를 입력하시오 : ", end="") str = input() print(str == 'python') print('\n\n') print('첫번째 수 입력 : ', end='') num1 = input() print('두번째 수 입력 : ', end='') num2 = input() print(int(num1) % int(num2) == 0) ...
e79181b0dcd9b59101eebba191777426fff80dc6
vasantidatta/PythonProjectDemo
/Demo_1/String_demo1.py
859
3.953125
4
# String is immutable sequence of characters a="The only truth is Death" print(a) print(a[6]) print(len(a)) print("only" in a) print("love" not in a) for x in "shreesh": print(x) y=0 while y<len("shreesh"): print(y) y=y+1 if "truth" in a: print("yes, 'free' is present") if "love" not in a:...
0cac1acd6fad5bcf776f4048aaa3dd8403698ee0
CodeGuardianAngel96/OOPS-I-Posted
/Automobile.py
1,034
4.46875
4
''' Create a class Automobile with an attribute color with default value “black”. It contains instance variables name,mileage,max_speed.  Class vehicle is inherited by both classes lorry and bus. These classes doesn’t contain any properties of their own. Color: White, Vehicle name: ashokleyland l...
5ee2e17802fd394d5fdc62081794a547b2698047
TestACCOUNT2112/labpy02
/TugasPraktikum2.py
355
3.78125
4
A = int(input("Masukkan bilangan A: ")) B = int(input("Masukkan bilangan B: ")) C = int(input("Masukkan bilangan C: ")) if A > B and A > C: maks = A; print("Bilangan Terbesar adalah: A.",maks); elif B > C and B > A: maks = B; print("Bilangan Terbesar adalah: B.",maks); else: maks = C; print("Bi...
c63c516d35764153c2f5fe17bb752621aeedb225
udaycoder/Minance
/minance1.py
1,850
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 19 19:43:07 2018 @author: udaycoder """ def isLeapYear(year): if((year%400 == 0) or (year%100!=0 and year%4==0)): return True else: return False def findNumberOfExtraDays(year): count = 0; if(year>2000): ...
4e5cfb93e785ced4c3344709c46bf95dabec016b
lianglee123/leetcode
/101~200/151~160/151.reverse_words_in_a_string.py
328
3.765625
4
class Solution: def reverseWords(self, s: str) -> str: tokens = list(filter(lambda x: x, s.split())) tokens.reverse() return " ".join(tokens) if __name__ == '__main__': s = Solution().reverseWords print(s("the sky is bule")) print(s(" hello world! ")) print(s("a good ex...
2a90fc1df38db0cb5e69c4ebe843e0d5d7bc6fd4
mcintoshsg/soccer_league
/soccer_league.py
3,437
4.25
4
import csv # create a list to hold the entire league football_league = [[],[],[]] # Manually create a single collection that contains all information for all 18 players. # Each player should themselves be represented by their own collection.''' def get_all_players(): # open the file and read intp a single dict...
a9e24e57fd591199cdc9317372bdacb119c18d96
wangyendt/LeetCode
/Easy/557. Reverse Words in a String III/Reverse Words in a String III.py
305
3.75
4
# !/usr/bin/env python # -*- coding: utf-8 -*- # author: wang121ye # datetime: 2019/7/16 19:38 # software: PyCharm class Solution: def reverseWords(self, s: str) -> str: return ' '.join([l[::-1] for l in s.split(' ')]) so = Solution() print(so.reverseWords('Let\'s take LeetCode contest'))
4abbe3bae03cdf75c815b208b553c01e63236889
benwatson528/advent-of-code-20
/main/day10/adapter_array.py
789
3.5
4
from collections import defaultdict from typing import List def solve_diffs(adapters: List[int]) -> (int, int): sorted_adapters = sorted(adapters) one_diffs = 0 three_diffs = 1 last_val = 0 for adapter in sorted_adapters: diff = adapter - last_val if diff == 1: one_diff...
eaa9e5b6401ce2d03e083ed82b7d20434766207b
diegobraga92/Algorithms
/Algorithms/Fibonacci/fibonacci_partial_sum.py
966
3.5625
4
# Uses python3 # Gets the last digit of the sum between two fibonacci numbers. # Since both have the same period size (60 for mod 10), adds in this range def calc_fib_mod(n, to, m): period = [0,1, 1 % m] i = 2 while not (period[i] == 1 and period[i-1] == 0): i = i+1 period.append((period[...
ef6ebcfd8b24024545cb232fb75fc1351fe90924
AMx12/Python
/Application.py
1,207
4
4
from random import randint import re cont = True while cont == True: g = input("Guess a number between 1 and 10: ") while g == "": g = input("Enter a number between 1 and 10: ") # regex = re.search('[a-zA-Z]+',g) # amt = regex.group() #use = len(amt) ...
0e0d4e01a94355a15b22de3343d8937e4c123279
trofik00777/EgeInformatics
/probn/05.04/14.py
185
3.5625
4
def f(a, to): n = a s = "0123456789" answ = "" while n > 0: b = n % to answ += s[b] n //= to return answ[::-1] print(f(67, 3))
f4917affc7849e5cdfdb359cd467151d4b651cbf
kaisersamamoon/py-notes
/作业/任务3.py
1,895
3.734375
4
""" print ("圆的计算") print ( '1 ("通过半径计算") 2 ("通过面积计算") 3 ("通过周长计算")' ) times = 1 while times < 1000: flyme = int( input ( "请选择你的模式:" ) ) a ,b , c = 1, 2 , 3 if flyme == a: banjin = input ( "请输入圆的半径r:" ) ban = float (banjin) r = ban s = 3.14*( r * r ) print ( "面积:" , s ) ...
5267d6ee06c00a2d493a4b819744f78ae42f0209
nayana09/assesment4.1
/initfun.py
814
4.0625
4
class person: #init method or constructor '''here name and age are the 2 parameters''' def __init__(self, name, age): self.name = name self.age = age #sample method def my_fun(self): print("My name is " + self.name) p1 = person ("Ram", 40) p2 = person ("sham",...
fff4e75c64dc51f2102ca33a7339ebbbbe88d129
tenqaz/crazy_arithmetic
/leetcode/剑指offer/剑指 Offer 11. 旋转数组的最小数字.py
745
3.75
4
""" @author: zwf @contact: zhengwenfeng37@gmail.com @time: 2023/6/24 12:48 @desc: https://leetcode.cn/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/?envType=study-plan-v2&envId=coding-interviews """ from typing import List class Solution: def minArray(self, numbers: List[int]) -> int: """ ...
d3503833fb51cfa36522167090ce838be67fc2f5
pushparajkum/python
/13lecture_17feb/disjoint_lists.py
461
4.03125
4
def disjoint(list1, list2): flag = True for i in range(len(list1)): if list1[i] in list2: flag = False return flag def main(): list1 = eval(input("Enter list1 : ")) list2 = eval(input("Enter list2 : ")) res = disjoint(list1,list2) if res: ...
01283815db276f99bccfda264239303108f8ae5d
kaushikacharya/cpp_practise
/online_judge/hackerrank/python/poisson_distribution_3.py
1,111
3.640625
4
# https://www.hackerrank.com/challenges/poisson-distribution-3/problem # Sept 12, 2018 from math import e def compute_prob(lambda_val, k): numer = pow(lambda_val, k) * pow(e, -1 * lambda_val) denom = reduce(lambda x, y: x * y, range(1, k + 1) if k > 0 else [1]) prob = numer / denom return prob val_l...
b10bbbaed265f274e81b8dc589673bd1e2e177f0
EPlatonenkova/beginner_python
/lesson_1/2.py
254
3.515625
4
a = None while a != 0: a = int(input('Введите время в секундах: ')) h = a // (60 * 60) ost = a - h * 60 * 60 m = ost // 60 s = ost - m * 60 print(f'{str(h).zfill(2)}:{str(m).zfill(2)}:{str(s).zfill(2)}')
63a9d247ec9769bb84e5d100b53541cecc72ca38
issarakoat/problems_with_py3
/dynamic-programming/fibonacci.py
343
3.78125
4
def fibonacci(n): if(n == 0): return 0 a = 0 b = 1 for i in range(2, n): c = a + b a = b b = c return a + b assert(fibonacci(1) == 1) assert(fibonacci(2) == 1) assert(fibonacci(3) == 2) assert(fibonacci(4) == 3) assert(fibonacci(5) == 5) assert(fibonacci(6) == 8) ass...
d9e79b4d8bf245d7eafcd6e89bdf1ed30798b2a4
mattssonj/potential-couscous
/main/python_server.py
1,833
3.65625
4
''' Server class that sends the data to its listeners ''' import socket import threading HOST = '' #this will be device ip PORT = 8888 def clientthread(conn, listener): # shadow-naming s becomes conn from here on. # Sending message to connected client print('Someone connected to server...') # infin...
d7c2f9d4f3d2b739b882367a8cae5838bd3b3d00
mgbo/My_Exercise
/2018_2019/_Simple_analogClock/analog_clock.py
1,871
4.375
4
# Simple Analog Clock in python3 # by @TokyoEdTech # Part 1: Getting Started import turtle import time wn = turtle.Screen() wn.bgcolor('black') wn.setup(width=600, height=600) wn.title("Simple Analog Clock by @TokyoEdTech") wn.tracer(0) # create our drawing pen pen = turtle.Turtle() pen.hideturtle() # Не показывать...
c6c309756ebc2bb0f7e53a5056d22d4b5482b088
ZX1209/gl-algorithm-practise
/leetcode-gl-python/leetcode-21-合并两个有序链表.py
2,250
4
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ mergel = ListNode(0)...
99e93a3a865d98adb2fd06f4574b172165d8f111
KiwiShow/PythonWeb
/data_structure_and_algorithm/binary_tree.py
517
3.84375
4
class Tree(object): def __init__(self, element=None): self.element = element self.left = None self.right = None def traversal(self): print(self.element) if self.left is not None: self.left.traversal() if self.right is not None: self.right....
ff99819c2c7f7350d69c519015134f2f504cbbb0
ryangillard/misc
/leetcode/885_spiral_matrix_III/885_spiral_matrix_III.py
1,381
3.65625
4
class Solution(object): def spiralMatrixIII(self, R, C, r0, c0): """ :type R: int :type C: int :type r0: int :type c0: int :rtype: List[List[int]] """ spiral = [] spiral = self.everySquare(R, C, r0, c0, spiral) return spiral def ev...
b6deada4c47e1b12131a0b60a32988ed01a4b618
epmoyer/cascade
/web/cascade/bomstrip.py
974
3.6875
4
""" Strip the UTF-8 Byte Order Mark (BOM) from a file (if it exists) """ import codecs BOMLEN = len(codecs.BOM_UTF8) def copy_and_strip_bom(infilename, outfilename): """Copy file into a new file, excluding the BOM (if it exists) """ buffer_size = 4096 with open(infilename, "r+b") as infile...
8cbfee17ba8f5de9a11f4449c116314fe16fa11a
crazycharles/coding-interview-in-python
/69 扑克牌的顺子.py
660
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 2 15:13:06 2019 @author: an """ class Solution(object): def isContinuous(self, numbers): """ :type numbers: List[int] :rtype: bool """ if len(numbers) == 0: return False zero_lst = [] orig_lst = [] ...
ad0b906f7aba16c5d3068c4f61e3bc3fe81d3a7a
tusvhar01/python.project
/IF ELSE.py
149
3.8125
4
a=("harry","HARRY","Harry") b=input("write your post: ") if(b in a): print("yes it is about harry ") else: print("no it is not about harry ")
17e74d5191b3cad65a6573084b5cb9786a37aadc
Prabhat-Thapa45/flask-flower-bq
/src/check.py
975
4.28125
4
def check_flower_by_name(results: tuple, flower_name: str) -> bool: """Checks if the given flower_name is available in results if yes returns True else False Args: results (tuple): a tuple consisting of dict type as elements from rows of sql tables. e.g: for table with one row ({'id': 1, 'fl...
34a9201993106c7b0a276c611d0fd2ee95d6d68e
morteza404/code_wars
/UniqueOrder.py
670
4.15625
4
""" Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. For example: unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B'] ...
3fba912822b37b4673b582c7c0fbcb69969ff0f0
nahida47/kaggle_competitions
/03_Zillow/kaggle_lib/Utils/KA_utils.py
654
3.59375
4
from __future__ import print_function, division import time class process_tracker: ''' A simple process tracker and timer. ''' def __init__(self, process_name, verbose=1): self.process_name = process_name self.verbose = verbose def __enter__(self): if self.verbose: ...
e111275e1bf03656392f94093a0f478a1352b4e8
mariahmm/class-work
/5.2Answer.py
731
4.15625
4
count = 0 total = 0 while True: test = input("Enter a number: ") if test == "done" : break try: num = float(test) except: print("Invalid input") continue count = count + 1 total = total + num print("") print("Sum is", total) print("Count is", count) print("Averag...
edcf4806b76354b587f095afcca36e38d5920b4c
mveselov/CodeWars
/tests/kyu_8_tests/test_transportation_on_vacation.py
450
3.625
4
import unittest from katas.kyu_8.transportation_on_vacation import rental_car_cost class RentalCarCostTestCase(unittest.TestCase): def test_equals(self): self.assertEqual(rental_car_cost(1), 40) def test_equals_2(self): self.assertEqual(rental_car_cost(4), 140) def test_equals_3(self): ...
3865156c177107ae3b55c85b18e45154693507ca
skyuniv/A-Kata-A-Day
/Python/Naughty_or_Nice.py
1,102
4.0625
4
# Naughty or Nice? # Level: Beta ''' In this kata, you will write a function that receives an array of string and returns a string that is either 'naughty' or 'nice'. Strings that start with the letters b, f, or k are naughty. Strings that start with the letters g, s, or n are nice. Other strings are neither naughty ...
e256f8fc2fc559028699e0b98b321ed86acd8108
wayne-liberty/euler_python
/Digit cancelling fractions.py
806
3.890625
4
from fractions import Fraction # help(fractions) # print(fractions.Fraction(3, 6)) def judge(num, denom): a_set = {int(num / 10), num % 10, int(denom / 10), denom % 10} if len(a_set) != 3 or 0 in a_set: return num_list = [int(num / 10), num % 10] denom_list = [int(denom / 10), denom % 10] ...
fb72de2180c9fd034e6e96f19a626d1a0337cf88
fau-masters-collected-works-cgarbin/cot6405-analysis-of-algorithms
/longest-common-subsequence/alternatives/lcs_recursive.py
1,347
3.703125
4
'''LCS with recursion. This is the simplest recursive solution, with memoization. It is not an efficient implementation. It is here to illustrate conceptually how to solve the problem. Even with memoization, this solution hits the number of recursive calls in the Python environment for input strings around 10,000 cha...
e2a22e7777f7ff884ce70664048bb07e352e6315
cleysondiego/curso-de-python-dn
/semana_1/exercicios_aula_2/Exercicio13.py
147
3.875
4
numero = int(input('Digite um número: ')) def goiabada(numero): return 'goiabada' if ((numero % 5) == 0) else numero print(goiabada(numero))
e8e3fdd4556b24eb357aa7f669fb751dc08bbd40
CescWang1991/LeetCode-Python
/python_solution/151_160/BinaryTreeUpsideDown.py
1,176
4.0625
4
# 156. Binary Tree Upside Down # Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same # parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into left # leaf nodes. Return the new root. # Given a binary...
56a7259e9ec3ae779d563b045859615ac22c4fe3
backmay/tisco_exam
/test_1.py
438
3.609375
4
input_a = '9876543' input_b = [ '3467985', '7865439', '8743956', '3456789', ] def is_same_ditgit_in_same_index(input_a, input_b): for index in range(len(input_a)): if input_a[index] == input_b[index]: print('{} : is Invalid'.format(input_b)) return print('{} : is...
da42e428c82ffb3049f97684837596991e7ba83d
sdemingo/algol
/acm-icpc/2011-PA-add-or-mul.py
4,357
3.796875
4
''' Problem A To Add or to Multiply ''' import sys # Clase para recoger todos las posibles soluciones. Cuando construyo un # nodo puedo ejecutar su método build. Esto provocará que se construyana # a su vez sus hijos de forma recursiva. class Tree(): def __init__(self,config,output,op): self.config=con...
b7a774bfc1f5960792250a0f585935a7d7ad0e7a
yaxche-io/dig-bioindex
/bioindex/lib/locus.py
5,251
3.5625
4
import abc import itertools import locale import re class Locus(abc.ABC): """ A location in the genome. Abstract. Must be either a SNPLocus or a RegionLocus. """ LOCUS_STEP = 20000 def __init__(self, chromosome): """ Ensure a valid chromosome. """ self.chromos...
dcc9e6fddfb094520058056a468b4f134a7e4e48
pweb6304/two-qubit-simulator
/two_qubit_simulator/initial_state.py
471
3.796875
4
def random_quantum_state(): """ Returns a random qubit state. The qubit will be a column vector with complex elements a+ib and c+id. a,b,c and d are randomly chosen. The norm ensures the state is normalised. """ import numpy as np import random a = random.random() b = random.random() c = random.random() d...
ec59d7fd195c031cd673fc6a075b057c4bbdc6fb
serbyshek/LB_4
/individual3.py
583
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #1. Дано слово. #Удалить из него третью букву. #Удалить из него k-ю букву if __name__ == '__main__': s = str(input('Введите слово')) k = int(input('Введите порядковый номер буквы, которую желаете удалить')) с = k + 1 v = s[:k] + s[с:] j ...
b7f08d79214db29607c830c06eee7f1ee294f785
ahsueh1996/NomBot
/archive/v3/physics_model.py
2,751
3.609375
4
import math import numpy as np from scipy.optimize import fsolve ''' 2017 Aug 26 Albert Hsueh Describes a model for predicting tragetories. ''' G = 9.8 g = G CABINET_PORPORTION = 0.3 # measured form screen the ratio the cabinets take up on the game screen def adjust_gravity(play_field_height): ''' Th...
71b886890fe0339993f7b5ef6e1d7e27d5bd97a3
rulidor/Python-Course
/assign.9/untitled1.py
265
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 19 21:10:13 2019 @author: Lidor """ import numpy as np import matplotlib.pyplot as plt x=np.array([1,2,3,4,5]) y=np.array([50,20,30,90,100]) #plt.plot(x,y) #plt.show(x) print(x.mean()) print(x.min()) print(x.max())
62bf9474640f68d26ad231a243ab1a6fa5705cfd
erlengra/mqttSUB-httpPOST
/config.py
3,326
3.609375
4
import sys import getopt ''' Config class used to hold all options available from runtime. The options are placed in a directory and loaded to the initialization of the application. -configure_init() initializes the object -config_input() returns a directory of options by using the sys class. options are set in the...
d6c3159ba85bb32167d57ea0d5f543d5d01ba39c
artbohr/codewars-algorithms-in-python
/7-kyu/age-in-days.py
639
4.4375
4
from datetime import date def ageInDays(year, month, day): return 'You are {} days old'.format((date.today() - date(year, month, day)).days) ''' Did you ever want to know how many days you are old? Write a function ageInDays which returns your age in days. For example if today is 30 November 2015 then ageInDay...
67bac2d3c77270406360272da5999ef25321f328
zhanglongqi/python-study
/myTimer.py
2,233
3.828125
4
__author__ = 'longqi' ''' import time run = raw_input("Start? > ") mins = 0 # Only run if the user types in "start" if run == "start": # This is saying "while we have not reached 20 minutes running" while mins != 20: print ">>>>>>>>>>>>>>>>>>>>>", mins # Sleep for a minute time.sleep(60)...
b6b6b5120805c2bf4fe08d88b36cd460c31735c5
amani021/100DaysOfPython
/Day_8.py
1,685
4.3125
4
# -------- DAY 8 "Generate Password" -------- # Goal: Learn about random library. import random, string from tkinter import * root = Tk() root.title('100 Days Of Python - Day 8') root.configure(background='#E0E0E0') # --------------- CREATE A FRAME --------------- frame = LabelFrame(root, text=' GENERATE PASSWORD ',...
70cb21a2cfb8e5fcf8066e1fb887593352e79b87
garderobin/Leetcode
/leetcode_python2/lc654_maximum_binary_tree.py
905
3.921875
4
# coding=utf-8 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from abc import ABCMeta, abstractmethod from data_structures.binary_tree import TreeNode class MaximumBinaryTree(object): __metac...
55f3fb61ee0d06fe52dbae821ca9b3a439724488
kwantaing/CD_Python_Fundamentals
/functions_basic2.py
782
3.8125
4
def countdown(number): newlist = [] for i in range(number,-1,-1): newlist.append(i) return newlist # print(countdown(5)) def print_return(list): print(list[0]) return(list[1]) # print(print_return([1,2])) def first_plus_length(list): return list[0]+len(list) # print(first_plus_lengt...
61fa8f4cbbd7c51c1fe25b0d7bb7bce6fef53a92
zopepy/leetcode
/flip_equivalent.py
824
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def flipEquiv(self, root1, root2): """ :type root1: TreeNode :type root2: TreeNode :rtype: bool "...
ab3f5c76f3706b2fe46faa5ae3804e3081e2f746
navazl/cursoemvideopy
/ex029.py
385
3.828125
4
vel = int(input('Qual a velocidade do carro? ')) # Lê a velocidade do carro. if vel > 80: # Verifica se a velocidade do carro é maior que 80km/h. multa = (vel - 80) * 7.00 # Descobre quantos Km/h ele está acima do limite e multiplica por R$7,00 (preço da multa). print(f"Você foi multado e terá que pagar R${mult...
095ff133bd0633b7f2554f9592a1b721bb21158e
jeremiedecock/snippets
/python/scipy/discrete_random_with_distribution.py
1,160
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # see http://stackoverflow.com/questions/11373192/generating-discrete-random-variables-with-specified-weights-using-scipy-or-numpy import numpy as np from scipy.stats import rv_discrete # IF VALUES ARE INTEGERS ######################## values = [1, 2, 3]...
f932774e5c531a96cb257cbe82b39babe4e98b46
delafrouzmir/Udemy-Data-Science
/Advanced Statistics/Section 34/l212.py
866
3.71875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sbn sbn.set() from sklearn.linear_model import LinearRegression data = pd.read_csv('real_estate_price_size.csv') print (data.head()) x = data['size'] y = data['price'] x = x.values.reshape(-1,1) print(x.shape) reg = LinearRe...
5150d0112a19ed1f6b9b1cdc4ab6f967d748e1c1
pengzhefu/LeetCodePython
/hashtable/easy/q204.py
2,449
3.921875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 27 11:39:47 2019 @author: pengz """ ''' Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. ''' def countPrimes(n): ## written by my own, time li...
8a5d81907a0eb9e43e0b4c5d034cf23860828dc4
colinpollock/pong-ladder
/app/elo.py
1,254
3.90625
4
"""Elo score computation. See https://en.wikipedia.org/wiki/Elo_rating_system. """ from __future__ import division def elo_update(winner_rating, loser_rating, to_11=True): """Compute the new rating for the winner and loser. Args: winner_rating - the winner's rating. loser_rating - the loser...
4a7cda727d0be4647b9aff5b6981f88acc03a859
qilin-link/test
/test/ATMsystem/atm.py
6,141
3.5625
4
#!/usr/bin/env python #_*_ coding:utf-8 _*_ from card import Card from user import User import random class ATM(object): def __init__(self,allUsers): self.allUsers = allUsers #卡号-用户 #开户 def createUser(self): #目标:向用户字典中添加一对键值对(卡号-用户) name = raw_input("请输入您的姓名...
35bbec33ae4deedb1619952c9be42a18908cd4fd
lujiaxuan0520/Python-exercise
/python课后习题/3.7.py
267
3.765625
4
#3.7 #!/usr/bin/python #encoding=utf-8 def method1(): sum=0 for i in range(1,100,2): sum+=i print(sum) def method2(): sum=0 for i in range(100): if(i%2==1): sum+=i print(sum) if __name__=='__main__': method1()
9ab2c582bf6a5d4127c1deb486b2a3133bcff260
renruru/homework
/sum(while).py
496
3.59375
4
# i=0 # sum = 0 # while i<=1000: # sum=sum+i # i=i+1 # print(sum) #1+2+。。。+1000的值 # i=0 # while i<=100: # i+=i # print("hello,打印次数:",i) # range表示,从0数到1001,参数可以放字符串,等等 # s=0 # for i in range(1001): # s=s+i # print(s) # str = "hello my name is hanmeimei" # for s1 in str: # print(s1) classmates ...
031a10782319255ada7207ab33b49d989a0e582d
avinashreddy21/Data-Mining
/1.Correlation/Pearson_Corr_Coeff.py
769
3.515625
4
import pandas as pd from statistics import mean import math data = pd.read_csv('overdoses.csv') data.Population = data.Population.str.replace(",", "") data.Deaths = data.Deaths.str.replace(",", "") a = list(data.Population) b = list(data.Deaths) float_a = [float(i) for i in a] float_b = [float(j) for j in b] mean_a...
296fa51b74a2ef70861972c2f45233b6af229ca4
fport/feyzli-python
/26.0 fonk2.py
742
3.8125
4
"""def fonksiyon(belirle): try: liste = [x for x in range(100) if x % belirle ==0] print(liste) except TypeError: print("Fonksiyona Gönderilen deger hatali") fonksiyon("mert") """ """ def fonksiyon(p1,p2,p3): return p1+p2+p3 print(fonksiyon(1,2,3))""" #arg yerine baska ...
06eacfd81166cca9ac0354b6dc00b6490489d78c
barathviknesh/GUVI
/Frls.py
134
4
4
n=int(input("Enter the number to print:")) l=n l=l%10 while(n>=10): n=n//10 f=n print("first digit:",f,"last digit",l)
0c2e36a6f4e8c464a9b415f972be96c5b4a6787f
wajishagul/wajiba
/Task7.py
1,208
4.28125
4
print("********Task 7 Functions********") print("1. Create a function getting two integer inputs from user.& print the following:\nAddition of two numbers is +value\nSubtraction of two numbers is +value\nDivision of two numbers is +value\nMultiplication of two numbers is +value") a=int(input("Enter the first number : "...
dc5bf9e6b2b9e5061dc028b3f16f4fd30a843777
patriciaslessa/pythonclass
/Decision_2.py
322
3.859375
4
def lista_2_ex_2(): """ Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo. """ a = int(input("digite um número: ")) if float(a) >= 0: print ("O número digitado é positivo" ) else: print ("O número digitado é negativo") lista_2_ex_2()
fb42bb06734d0de92faa15c47bf387d350ae9cd6
13jonerik/SimpleDFArunner
/DFA.py
1,450
3.921875
4
__author__ = 'jonerik13' import string as s mapping = {} def runDFA(): #total number of states in the DFA states = raw_input("How many states are in this DFA?: ") #designate accepting states aStates = str(raw_input("Which of these states are accepting states? Enter in 01234 format: ")) #used...
57d3a6e7648ac75758cde5dc610f2d69ed2e4f9b
kcoppola88/Python
/password_generator.py
1,402
3.890625
4
import sys import secrets import string def gen_pass(): while True: try: pass_length = int(input('Please enter an integer between 8 and 12: ')) if pass_length < 8: print ("Not long enough. Please try again. \n") pass ...
dad394612600ecca3f9fbb6265c58d0ee1077d5c
JustSage/electricity_bill_calculator
/src/console/menu.py
831
3.609375
4
from utils.utils import clean_function_name, list_previous_bills from bills.elec_bill import calculate_my_electric_bill def menu(): commands = { 1 : calculate_my_electric_bill, 2 : list_previous_bills} print("_______ WELCOME _______") print("Function Menu: ") while True: for key, val in comman...
c5ee470d812b23f80c947e31bec9ba818b5ce407
oilmcut2019/final-assign
/jupyter-u07157113/Quiz_Python_20190309.git/Quiz_6.py
117
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[2]: a=int(input()) b=3 while a>b: print(b) b+=3 # In[ ]:
94d793f08f54080b6b2ff63134aecf73e4d4e7e9
MacBook-Pro-gala/supinfo.python
/自学项目/pygamemods.py
318
3.609375
4
def pygamefrom(x, y, x1, y1, w): aa = x1 bb = y1 for a in range(y + 1): pygame.draw.line(screen, (0, 0, 0), (x1, y1), (x1, x * w + y1)) x1 = x1 + w x1 = aa y1 = bb for b in range(x + 1): pygame.draw.line(screen, (0, 0, 0), (x1, y1), (x1 + y * w, y1)) y1 = y1 + w
e083844725017db22cb839e7e44ee0ffd6a12729
LouiseCerqueira/python3-exercicios-cursoemvideo
/python3_exercicios_feitos/Desafio048.py
352
3.796875
4
#Faça um programa que calcula a soma entre todos os numeros ímpares que são múltiplos de três e que se encontram no intervalo de 1 até 500. cont=0 cont2 = 0 for i in range(1,501, 2): if i%3==0: cont+=i cont2 += 1 #Para saber quanto números foram somados print(f'O somatório dos {cont2} múltiplos de 3...
08bdf748d33ca292b05fec5895bc1361d2ade7ff
epicmichael3257/RockPaperScissors
/game.py
2,257
3.875
4
import random as r name = input("Enter your name:") print("Hello,",name) newName = False d = {} with open("rating.txt",'rt') as f: #create dictionary from list values for line in f: a = line.split() key,values = a[0],int(a[1]) d[key] = values f.close() if name not in d: #initalize them i...
27e841de7f3b15fd5f76b0294cb3e4ff1c90b90e
jayaimzzz/Numseq-Package
/numseq/fib.py
702
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Returns the nth Fibonacci number """ __author__ = "jayaimzzz" import sys import argparse def fib(n): if n == 0: return 0 if n == 1: return 1 if n > 1: return fib(n - 1) + fib(n - 2) else: return "error" def create_...
df2f141450aa5520805dc70bc7df5541d8bc4587
MakeSchool-17/sorting-algorithms-python-kazoo-kmt
/sort.py
1,678
3.9375
4
import time import unittest def timed_sort(list, key, algorithm='insertion'): sort_func = globals()[algorithm] start_time = time.time() sorted_list = sort_func(list, key=key) end_time = time.time() elapsed_time = end_time - start_time return (sorted_list, elapsed_time) # --- # Define yo...