blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6ea86e022c7a6b455a409a5919ccb1254d1042be
vmred/codewars
/katas/7kyu/Simple Fun #152 - Invite More Women/solution.py
830
3.609375
4
# Task # King Arthur and his knights are having a New Years party. # Last year Lancelot was jealous of Arthur, because Arthur had a date and Lancelot did not, and they started a duel. # To prevent this from happening again, # Arthur wants to make sure that there are at least as many women as men at this year's party. ...
91bfa9f67a27ed45f62c995be5644fa2997623dd
vmred/codewars
/katas/6kyu/Bug Fix - Quick Sort/solution.py
350
3.890625
4
# There is an implementation of quicksort algorithm. # Your task is to fix it. # All inputs are correct. # See also: https://en.wikipedia.org/wiki/Quicksort def quicksort(arr): if len(arr) < 2: return arr # base case p = arr[0] return quicksort([i for i in arr[1:] if i <= p]) + [p] + quicksort([...
e9a61e8092140f888780ac381550f9d1e17a20d6
vmred/codewars
/katas/6kyu/Find the odd int/solution.py
249
4.125
4
# Given an array, find the int that appears an odd number of times. # There will always be only one integer that appears an odd number of times. def find_it(seq): r = 0 for i in seq: r ^= i print('--> r:', r) return r
2eed2e82e9d5b90e500f0e3a514f3160490883a0
vmred/codewars
/katas/6kyu/Longest alphabetical substring/solution.py
758
4.25
4
# Find the longest substring in alphabetical order. # Example: the longest alphabetical substring in "asdfaaaabbbbcttavvfffffdf" is "aaaabbbbctt". # There are tests with strings up to 10 000 characters long so your code will need to be efficient. # The input will only consist of lowercase characters and will be at lea...
37533f6df48ca523d6e855c28202f4ed6f859048
vmred/codewars
/katas/6kyu/Sum two arrays/solution.py
1,270
4.125
4
# Your task is to create a function called sum_arrays() in Python or addArrays in Javascript, # which takes two arrays consisting of integers, and returns the sum of those two arrays. # The twist is that (for example) [3,2,9] does not equal 3 + 2 + 9, it would equal '3' + '2' + '9' # converted to an integer for this k...
97e2ed0b17072e56870486a9eb7ac6328892af75
vmred/codewars
/katas/6kyu/Number Zoo Patrol/solution.py
971
4.15625
4
# You're working in a number zoo, and it seems that one of the numbers has gone missing! # Zoo workers have no idea what number is missing, and are too incompetent to figure it out, # so they're hiring you to do it for them. # In case the zoo loses another number, they want your program to work regardless of how many...
0094462e4c0ae546aa21c0783d248a1d4ce08dbb
vmred/codewars
/katas/6kyu/Valid phone number/solution.py
584
4.34375
4
# Write a function that accepts a string, and returns true if it is in the form of a phone number. # Assume that any integer from 0-9 in any of the spots will produce a valid phone number. # Only worry about the following format: # (123) 456-7890 (don't forget the space after the close parentheses) # Examples: # vali...
c5298c27ddf65ee4e572a77e80c37abfbc0eb093
vmred/codewars
/katas/4kyu/Sum of Intervals/solution.py
1,536
3.703125
4
# Write a function called sumIntervals/sum_intervals that accepts an array of intervals, # and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. # Intervals # Intervals are represented by a pair of integers in the form of an array. # The first value of the interval will al...
3ef35d98eaa66bf35f4775797c5ad8e2727abec2
vmred/codewars
/katas/7kyu/Highest and lowest/solution.py
409
4.1875
4
# In this little assignment you are given a string of space separated numbers, # and have to return the highest and lowest number. # Example: # high_and_low("1 2 3 4 5") # return "5 1" # high_and_low("1 2 -3 4 5") # return "5 -3" # high_and_low("1 9 3 4 -5") # return "9 -5" def high_and_low(numbers): numbers =...
f370793feeb3c360330af1c566953a99c1c9e001
vmred/codewars
/katas/5kyu/First N prime numbers/solution.py
1,019
4.03125
4
# First N prime numbers # A prime number is an integer greater than 1 that is only evenly divisible by itself and 1. # Write your own Primes class with class method Primes.first(n) that returns an array of the first n prime numbers. # For example: # Primes.first(1) # => [2] # Primes.first(2) # => [2, 3] # Primes.fir...
f5fe5f38dab1f86d18dfce4863cdbe410a47611c
vmred/codewars
/katas/6kyu/Not prime numbers/solution.py
1,111
4.09375
4
# You are given two positive integers a and b (a < b <= 20000). # Complete the function which returns a list of all those numbers in the interval [a, b) # whose digits are made up of prime numbers (2, 3, 5, 7) but which are not primes themselves. # Be careful about your timing! def not_primes(a, b): if a == 2 an...
2fd96922277d393e34b481ff8b582968dab6e6d9
vmred/codewars
/katas/7kyu/Beginner series #3 - Sum of numbers/solution.py
320
4.28125
4
# Given two integers a and b, which can be positive or negative, # find the sum of all the numbers between including them too and return it. # If the two numbers are equal return a or b. # Note: a and b are not ordered! def get_sum(a, b): if a > b: a, b = b, a return sum(i for i in range(a, b + 1))
3016b74957f555826402d66f6ce3684d951fb74d
vmred/codewars
/katas/7kyu/Incrementer/solution.py
814
4.125
4
# Given an input of an array of digits num, return the array with each digit incremented by its position in the array. # For example, the first digit will be incremented by 1, the second digit by 2 etc. # Make sure to start counting your positions from 1 and not 0. # incrementer([1,2,3]) => [2,4,6] # Your result can o...
785afe274a6e2247efb05bcaebc570c5a5857d0a
vmred/codewars
/katas/5kyu/Square Matrix Multiplication/solution.py
1,228
4.3125
4
# Write a function that accepts two square (NxN) matrices (two dimensional arrays), # and returns the product of the two. Only square matrices will be given. # How to multiply two square matrices: # We are given two matrices, A and B, of size 2x2 (note: tests are not limited to 2x2). # Matrix C, the solution, will be...
9f8639c9c84cce68896f5b13267b8bc7aa89559c
vmred/codewars
/katas/6kyu/Does my number look big in this/solution.py
772
4.125
4
# A Narcissistic Number is a number which is the sum of its own digits, # each raised to the power of the number of digits in a given base. # In this Kata, we will restrict ourselves to decimal (base 10). # For example, take 153 (3 digits): # 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 # and 1634 (4 digits): # 1^4 + 6^4 + 3...
4b07d814974d39aa890741bb542e85dc87397dcc
vmred/codewars
/katas/7kyu/Build the square/solution.py
305
3.890625
4
# I will give you an integer. Give me back a shape that is as long and wide as the integer. # The integer will be a whole number between 0 and 50. # Example # n = 3, so I expect a 3x3 square back just like below as a string: # +++ # +++ # +++ def generate_shape(v): return '\n'.join(['+' * v] * v)
a0148d032772e4090fe9b76237b316298c549f10
vmred/codewars
/katas/4kyu/Most frequently used words in a text/solution.py
1,824
4.375
4
# Write a function that, given a string of text (possibly with punctuation and line-breaks), # returns an array of the top-3 most occurring words, in descending order of the number of occurrences. # Assumptions: # A word is a string of letters (A to Z) optionally containing one or more apostrophes (') in ASCII. # Apos...
d31505b71c18ace33bf56babfd5469a429bb2edb
vmred/codewars
/katas/6kyu/Stop gninnipS My sdroW/solution.py
623
4.0625
4
# Write a function that takes in a string of one or more words, and returns the same string, # but with all five or more letter words reversed (Just like the name of this Kata). # Strings passed in will consist of only letters and spaces. # Spaces will be included only when more than one word is present. # Examples: #...
cfbf0c59c4f4b9ea106a20f1ac188dc3568d9d47
vmred/codewars
/katas/5kyu/Perimeter of squares in a rectangle/solution.py
800
4.0625
4
# The drawing shows 6 squares the sides of which have a length of 1, 1, 2, 3, 5, 8. # It's easy to see that the sum of the perimeters of these squares is : 4 * (1 + 1 + 2 + 3 + 5 + 8) = 4 * 20 = 80 # Could you give the sum of the perimeters of all the squares in a rectangle when there are n + 1 squares disposed in # t...
9b6f21f1c87594fc14bbc2d106740f1dae1e572a
vmred/codewars
/katas/7kyu/Vowels count/solution.py
388
3.953125
4
# Return the number (count) of vowels in the given string. # We will consider a, e, i, o, and u as vowels for this Kata. # The input string will only consist of lower case letters and/or spaces. def getCount(strng): def is_vowel(ch): return ch in ['a', 'e', 'i', 'o', 'u'] count = 0 for i in strn...
9cc808ae0f0d05ba700c676dfa068c1add0b66e0
vmred/codewars
/katas/7kyu/Currying functions multiply all elements in an array/solution.py
525
3.953125
4
# To complete this Kata you need to make a function multiplyAll/multiply_all # which takes an array of integers as an argument. # This function must return another function, which takes a single integer as an argument and returns a new array. # The returned array should consist of each of the elements from the first a...
d9bd11984bb73d2d517b3c753c87b6f920113134
vmred/codewars
/katas/6kyu/Shortest steps to a number/solution.py
875
4.34375
4
# Summary: # Given a number, num, return the shortest amount of steps it would take from 1, to land exactly on that number. # Description: # A step is defined as: # Adding 1 to the number: num += 1 # Doubling the number: num *= 2 # You will always start from the number 1 and you will have to return the shortest count...
52ac78bf9e96c8ffc5ef799c7dc1cb6eaa53dc1b
vmred/codewars
/katas/7kyu/Largest prime number containing n digit/solution.py
448
3.625
4
# Just as the title suggestes :D . For example -> # largest(1); //Should return 7 # largest(2); //Should return 97 # .... # Do not mind the pattern as it is just an incident ! # And make sure to return false if the input is not an integer :D # This might seem simple at first, it is, but keep an eye on the performance....
888d56645b6ba60e9f7952a8c277c6701b946b9f
vmred/codewars
/katas/6kyu/Roman numerals encoder/solution.py
903
3.875
4
# Create a function taking a positive integer as its parameter and returning a string # containing the Roman Numeral representation of that integer. # Modern Roman numerals are written by expressing each digit separately starting # with the left most digit and skipping any digit with a value of zero. # In Roman numera...
4e45e4f46d050f8046188b40b2e14c79332a098a
vmred/codewars
/katas/7kyu/Method for counting total occurence of specific digits/solution.py
1,019
4
4
# We need a method in the List Class that may count specific digits from a given list of integers. # This marked digits will be given in a second list. # The method .count_spec_digits()/.countSpecDigits() will accept two arguments, # a list of an uncertain amount of integers integers_lists/integersLists (and of an unce...
adcfa3dd802952908c916d8136380b66791d678b
vmred/codewars
/katas/7kyu/GauB needs help! (Sums of a lot of numbers)/solution.py
1,166
3.5
4
# Due to another of his misbehaved, the primary school's teacher of the young Gauß, Herr J.G. Büttner, # to keep the bored and unruly young schoolboy Karl Friedrich Gauss busy for a good long time, # while he teaching arithmetic to his mates, # assigned him the problem of adding up all the whole numbers from 1 through ...
5f3a93b194aaeb2c5e849eda3136cc5f65a197fa
remove158/cutpyramid
/question_3.py
2,611
3.828125
4
import turtle import math num = int(input()) # trangle components = "/ \ _".split() cos60 = math.cos(math.pi/3) sin60 = math.sin(math.pi/3) window = turtle.Screen() window.title("CUT Pyramid") turtle.tracer(False) x,y = window.screensize() length = y/num*2 turtle.penup() turtle.setposition(-length/2,y - 50) turtle...
25db2f8cdf6c338aefca0770b80748a98871d2c9
propuk/pythontestcode
/3.py
297
3.71875
4
import random chars ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*" inp = str(input("Press 1 to generate Password:")) if inp == "1" : password = "" for a in range(8): password += random.choice(chars) print(password) else: print("Please press 1!")
db50df1137165d1aff7a41ac689ab75b4879324c
MC2914Coding/Python_School
/PY/SCHUEL_TEST_GUESSINGGAME.py
519
4.0625
4
import random n = random.randint(1,10) guesses = 1 a = input("Enter a number: ") while(guesses != 3): if(a == n): print("Correct") print("Your guesses: ", guesses) break elif(a < n): a = 0 guesses += 1 print("Too low! Guess again") a = input("Enter a number: ") ...
a5627922cd6cf9d4a516babd4c356f0c84ea35d5
MC2914Coding/Python_School
/PY/AUFG_2.py
257
3.9375
4
from datetime import datetime from datetime import date import time as t today = date.today() now = datetime.now() print("Today's date:", today) while True: t.sleep(1) current_time = now.strftime("%H:%M:%S") print("Current Time =", current_time)
837e9facbb174ef605f51511fb049c24c15aea9d
JoarGruneau/bio-alg
/suffix_tree.py
9,307
3.53125
4
import math tree_depth = -1 class Node(object): def __init__(self, leaf_node): self.leaf_node = leaf_node self.parent = None self.children = {} self.string_pointers = [] self.start =None self.end = None self.suffix_link = None def length(self): i...
82ec5d6c8a22510239358e33e5f130b99a846cc8
AgnirajB/Python-Programs
/fib.py
237
3.875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) def fib(n): if(n == 0): return 0 elif(n == 1): return 1 else: return fib(n-1)+fib(n-2) print n a = fib(n) print a
a8ac7bf9361dbb6531f68d710c798a40fba3cc9b
AgnirajB/Python-Programs
/binary_search.py
797
3.5625
4
#Your task is to complete this function #Function should return integer denoting the index # indexing is done according to 0 # Left=0 and High=0 import timeit def bin_search(arr, left, high, key): #Code here if(left <= high): m = (left+high)/2 if (key == arr[m]): return m eli...
1fc3dec5b23652f185d8024c9e63ffcb70eab61a
gitfabianmeyer/ml_ss20
/Code/ex5.py
4,352
3.5
4
import numpy as np import matplotlib.pyplot as plt import os import random # from src.utils import load_data_txt class WeakClassifier: def __init__(self, x, y, smaller): self.x = x self.y = y self.smaller = smaller def __call__(self, point): if self.smaller: if se...
33c9ac6c409e71404e86742ceba4465a49ae1bff
lyyyuna/zhi_xu_zhe
/5/replacespace.py
446
3.8125
4
def replacespace(str1): str1 = list(str1) p1 = len(str1)-1 for s in str1: if s == ' ': str1.append(None) str1.append(None) p2 = len(str1)-1 while p1 != p2: if str1[p1] != ' ': str1[p2] = str1[p1] p2 -= 1 else: str1...
1c7852f650a10abc0e16b2ae0fba58b88a91a3bd
lyyyuna/zhi_xu_zhe
/32/printbinarytree.py
1,078
3.734375
4
class TreeNode(): def __init__(self, value, left_child=None, right_child=None): self.value = value self.left_child = left_child self.right_child = right_child from collections import deque def printBinaryTree(pRoot): if pRoot is None: return d = deque() d.append(pRoot)...
33e90847dae4aec3c5b1e113108b939fda6408dd
lyyyuna/zhi_xu_zhe
/27/mirror.py
1,032
3.75
4
class TreeNode(): def __init__(self, value, left_child=None, right_child=None): self.value = value self.left_child = left_child self.right_child = right_child def mirror(pRoot): if pRoot == None: return if pRoot.left_child is None and pRoot.right_child is None: ret...
2bd73271c8b568823610ba3053f2cdd4a0a0f35c
lyyyuna/zhi_xu_zhe
/50/firstoncechar.py
275
3.5625
4
def findFirstOnceChar(stri): cnt = {} for ch in stri: if ch not in cnt: cnt[ch] = 1 else: cnt[ch] += 1 for ch in stri: if cnt[ch] == 1: return ch return None print findFirstOnceChar("abaccdeff")
8291ed5bfc3b6033821eca6f16ed7091bba30e46
lyyyuna/zhi_xu_zhe
/7/reconstruct.py
1,228
3.765625
4
class BtreeNode: def __init__(self, v): self.value = v self.left = None self.right = None def createTree(preorder, inorder): # precheck if not isinstance(preorder, list) or \ not isinstance(inorder, list) or \ len(preorder) != len(inorder): return for x...
072dbc68d43a6f83cd5ff7c3db499e6582cdb424
lyyyuna/zhi_xu_zhe
/38/permutation.py
321
3.71875
4
def permutaion(str1, index): if len(str1) == index: for ch in str1: print ch, print for i in range(index, len(str1)): str1[index], str1[i] = str1[i], str1[index] permutaion(str1, index+1) str1[index], str1[i] = str1[i], str1[index] permutaion(list('abc'), 0...
c1d482e83ce4a224c0ed56a121f58621d1231086
thepedroferrari/DataStructuresAndAlgorithms
/2. Data Structures/reverseString.py
386
4.40625
4
def string_reverser(our_string): """ Reverse the input string Args: our_string(string): String to be reversed Returns: string: The reversed string """ # TODO: Write your solution here strLen = len(our_string) newStr = "" for i in range(strLen): newStr += our_s...
26c6d966c56f4fe97918d154fbd9793a4753754c
JosephBarkate/Hangman-in-Python
/hangmanGame.py
5,338
4.09375
4
# Hangman game # #Joseph Barkate # ----------------------------------- import random WORDLIST_FILENAME = "words.txt" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. ...
bd6f95882366051a0177511cde723c2a9620081c
Keremk98/Module-10
/Chapter 3 Mission.py
219
3.953125
4
#Chapter 3 userInput = input("Press 'x' to break the window of cab/bus").capitalize() window_broken = 'x' if window_broken: print("The window is broken, you are one step closer to saving your father.")
3cdb44928e31c03c92a9b05afc85aaf291e54a10
olaramoni/Zeller-s-Congruence
/Zeller_YearInput.py
362
4.3125
4
def inputYear(): yearValid = False while yearValid == False: try: year = input("Please enter the year: ") year = int(year) if year > 0: return year else: print("Please enter a positive number: ") except ValueError: ...
57432ec2811e4e72a353b772b2ef2f4204083e25
whhxf/PythonQtGUI
/chapter2/c2_e2.py
413
3.796875
4
# -*- coding: UTF-8 -*- def charcount(text): dict = {'whitespace':0,'others':0,'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0} for i in text.lower(): if i in ' \t\n\r\f': dict['whitespace']...
58846d34477c8675216198142091907b1b7d17c0
luyajie/python-example
/chapter9-homework/addressBook.py
1,249
3.65625
4
#!/usr/bin/python # Filename : addressBook.py import cPickle as p import os class Person: """ Person class """ def __init__(self, name, email): self.name = name self.email = email def __str__(self): return 'name: %s, email: %s' % (self.name, self.email) class AddrBook: ...
82e520629228763368a40387bcf3162985821833
d-lazenby/final-project
/TomeRater.py
9,015
4.03125
4
#TomeRater. An application that stores books and their users and reviews. #Creates User class User: def __init__(self, name, email): self.name = name #string self.email = email #string self.books = {} #gets user email def get_email(self): return self.email #changes us...
a19f4842ccfcb073bfa01161fd6ae7e0a94dd7f8
samiko1/budget
/budget.py
1,466
3.84375
4
class Budget: def __init__(self, budget): self.balance = 0 self.budget = budget print(f'You created a {budget} object ') def deposit(self, amount): self.amount = amount self.balance += self.amount try: print(f'Your deposit of {int(self.amount)} was Su...
33f79c2ed024040684c59f2dc7f6879071b889e1
alexshchegretsov/algorithms
/tests.py
506
3.671875
4
def singleton(cl): instance = None print(id(instance)) def wrapper(*args): nonlocal instance if not instance: instance = cl(*args) return instance return wrapper # @singleton class Employee: def __init__(self, name, salary): self.name = name sel...
d49e9145a305eeb1fa1da81f7ef3647b04841778
alexshchegretsov/algorithms
/data_structures/binary_tree/traversal.py
4,048
3.875
4
from collections import deque class Node: def __init__(self, v): self.v = v self.left = None self.right = None self.parent = None def bfs(node: Node): nodes = [] dq = deque() dq.append(node) while dq: curr_node = dq.popleft() nodes.append(curr_node.v...
5ca6d6c16c2e0fb3ecd7e376a1ce3d3b87b6aafa
alexshchegretsov/algorithms
/data_structures/binary_tree/is_cousins.py
2,445
4.03125
4
class Node: def __init__(self, v): self.v = v self.left = None self.right = None self.parent = None class BST: def __init__(self, v): self.root = Node(v) def insert_value(self, v): self.__insert_value(self.root, v) def __insert_value(self, node: Node, ...
c1275da9587097dac8f34131cca590742ab1e2b3
alexshchegretsov/algorithms
/data_structures/linked_list/merge_two_linked_lists.py
1,829
4.25
4
# algorithm # 1. find smallest node by comparison nodes values from two lists # 2. save next node to temporal variable # 3. set next link to None in current node # 4. add this node to merged linked list # 5. shift pointer curr to temporal variable in which we're saved next node class Node: def __init__(self, v=Non...
e709532396ebd13681a76111a8c4be060f17143c
edu-417/Practical-Reinforcement-Learning
/week1/crossentropy_method/crossentropy_method.py
9,963
3.921875
4
# coding: utf-8 # # Crossentropy method # # This notebook will teach you to solve reinforcement learning problems with crossentropy method. # In[1]: import gym import numpy as np, pandas as pd env = gym.make("Taxi-v2") s = env.reset() env.render() # In[2]: n_states = env.observation_space.n n_actions = env.a...
9e1087357dfc8d1d9cdb59c483694da4e029b0ff
katherfrain/python-exercises
/grocery-application.py
2,188
4.28125
4
class GroceryStore: def __init__(self): self.stores = [] self.itemlist = [] def add_store(self): answer = input('What store would you like to add to the list? Please enter "q" to exit this menu. ') while answer != 'q': self.stores.append(answer) self.stor...
91dd321ee3dc800c3f54562055ca7f4d9af224af
katherfrain/python-exercises
/day5.py
1,206
3.953125
4
def ask_first_name(): return input('Please input your first name: ') def ask_last_name(): return input('Please input your last name: ') def ask_street(): return input('Please enter your address. First, the street address:\n') def ask_state(): return input('Please enter your state: ') def ask_zip...
53712c073b835f57ccc1e4ff5eef19ba8979365b
ChungViet/Homework
/Homework/homework6.py
596
3.75
4
#Дано целое, положительное, ТРЁХЗНАЧНОЕ число. Например: 123, 867, 374. # Необходимо его перевернуть. Например, если ввели число 123, # то должно получиться на выходе ЧИСЛО 321. ВАЖНО! # Работать только с числами. Строки, оператор IF и циклы использовать НЕЛЬЗЯ! a = int(input('введите трехзначное число ')) m = ( a % 10...
80005f3941f14599ca406b74bc5eab54905496b3
ChungViet/Homework
/Lesson3/Operator.py
2,706
3.96875
4
#арифметические операторы """ + сложение A + B 'Hello' + 'World' = 'Hello World' - вычитание A - B * умножение A * B 'Hello' * 3 = 'Hello Hello Hello; / деление A / B 10/3 = 3.3333 // целочисленное деление A ...
078db01cf6a6738963d271fd1c65bd80bbef923a
sunniside/adventOfCode_2017
/4.py
995
3.59375
4
inputFile = open("4.input", "r"); def partOne(): validPhrases = 0; for line in inputFile: line = line.rstrip('\n'); words = line.split(' '); before = len(words); after = len(set(words)); if(before == after): validPhrases += 1; print validPhrases; def isA...
7a72522d69aa9978dd2b22fc4cacba8a6e297027
pvreddy/DevOps
/sort_list_WO_lib.py
189
3.578125
4
l = [2,4,1,5,9,7,13,3] li=[] for x in xrange(0,len(l)-1): print l[x] if l[x]<l[x+1] and l[x+1]>l[x+2]: li.append(l[x+1]) else: continue print li
d5b0aab376629a9b9b7694d9daa7a7a84afb19e3
pvreddy/DevOps
/fabinocii.py
140
3.8125
4
x = int(raw_input('enter value: ')) def febonocii2(x): a,b = 0,1 while b<x: a,b = b,a+b print a s = febonocii2(x)
ad4dc7d55b89b023079c5c73d1b46d9dcfdeba19
sh1nu11bi/nmapy
/nmapy/utilities/stats.py
919
3.640625
4
import numpy as np def calc_stat(arr, stat_name, axis=None): """ Parameters: ----------- arr: ndarray the input array stat_name: str the name of the statistics. "max", "min", "mean", "var", "std" axis: int, optional the axis over which the statistics is calculate...
a32bffa7445121689fbe6e2a685ac9c20e4f67f5
RealMaskedTitan/python-projects
/menu-maker/Versions/v2/main.py
1,058
4.21875
4
def make_menu(menu_items, tb_border = '-', s_border = '|', space = 1, numbered = False): ''' a function for printing menus: example of this output is: ------------ | thanks | | for | | using | | this | ------------ this can be achieved by running this co...
755c84c2b0e19201b6747442eab256890e479925
hannuo/learning-python
/P_Asyncio/02asynccoroutine.py
2,592
3.5625
4
import asyncio import threading #1.asyncio的编程模型就是一个消息循环,从asyncio模块直接获取一个EventLoop循环,然后 #把需要执行的协程扔到EventLoop中执行,就实现了异步IO @asyncio.coroutine def hello(): print("hello world") r = yield from asyncio.sleep(2) print("hello again!") #loop = asyncio.get_event_loop() #loop.run_until_complete(hello()) #print("m...
1bd6dcc6a53b660f2a0f6a5000997009b090e872
PeanutAndSoil/shiyanlou-code
/jump7.py
101
3.53125
4
for i in range(1,101): if i%7!=0 and i%10!=7 and i not in range(70,80): print('%3d' % (i),end='')
62554ef8c2a6438a7a3bfa9c82e10ea86dead918
kevinktom/Googly-Eyes
/Arrays/56.py
1,815
4.09375
4
#Data Structure: Lists #Algorithm: Sorting and iteration """Notes: Sort Iterate through and create the answer arrays by comparing the end value to the current first value Brute Force pseudo code: -Sort -Initialize Answer = [] -Initialize prev_start as arr[0][0] -Initialize prev_end as arr[...
293e482e8e50672007eb7d34bf7bef625ee35024
mathstar13/letterer
/__init__.py
2,521
3.859375
4
def isfirstwordtitle(txt): allchars = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '] for char in allchars: if txt.startswith(char): return True return False def islower(txt,checknum=0): txt = txt.replace(' ','') allchars = ['a', 'b', 'c', ...
8a09c4728f7734bd423b9d8ad5244458b2e75ce9
CapAsdour/Advance-Python-Training
/jumbledWord.py
1,596
4.09375
4
# this is a game of guessing the word import random def choose(): ar=["rainbow","winter","coming"] pick=random.choice(ar) return pick def jumble(word): jumbled="".join(random.sample(word,len(word))) return jumbled def play(): p1=input("player 1 plz enter your name") p2=in...
efa18fedf6d45733f0879e4f8954e2d167a86404
snachazel/CS313E
/Blackjack.py
7,733
4.0625
4
# -*- coding: utf-8 -*- # ============================================================================= # # File: Blackjack.py # # # Description: A program that simulates a game of blackjack # # # Student's Name: Stephen Nachazel # # # Student's UT EID: sdn443 # # # Course Name: CS 313E # ...
7ab3392e50a7b18d770ee043fdd12ba532ae2a84
majorgowan/wpwp
/Python/wUnderground.py
8,022
3.515625
4
############################################################### ###################### RETRIEVE WUNDERGROUND PAGE ############# ############################################################### # def readStationDay(stationCode, year, month, day, echo=False): # use HTML parser to download web page with day of ...
08e27209e26035274f5a70c6772930f6d6301a81
TechnoConserve/python_101
/file_handling/csv/csv_writer.py
1,390
4.03125
4
import csv def csv_dict_writer(data, path, fieldnames): """ Writes a CSV file using DictWriter. :param data: Data to be written to output CSV file. :param path: File path to save output CSV file. :param fieldnames: Defines column/fieldnames. :return: None. """ with open(path, 'w', newl...
e878730796ad21a2d9bdb69957c100ce06e59469
dorincrist/python
/float_input.py
446
4.1875
4
a = float(input("Please enter a float value?")) # input a float value for variable a here b = float(input("Please enter a second float value?")) # input a float value for variable b here print(a + b) # output the result of addition here print(float(a - b))# output the result of subtraction here print(float(a * b))# ou...
70cbd0ab6a8a23cb07fcb7124946c7fc9a64b1c8
ritwikbera/leetcode
/quickselect.py
863
3.515625
4
import random def Partition(a): if len(a)==1: return([],a[0],[]) if len(a)==2: if a[0]<=a[1]: return([],a[0],a[1]) else: return([],a[1],a[0]) p = random.randint(0,len(a)-1) pivot = a[p] right = [] left = [] for i in range(len(a)): if not i == p: if a[i] > piv...
6f0b1bed3702457f5b82b6a2a0151fefb1000bff
tzieba1/IntroPythonFiles
/PythonCodeSnippets/sumAndAverageNumbers.py
432
3.96875
4
tests = [[50, 82, 47], [60, 94, 90], [87, 32, 83], [25, 63, 78], [95, 47, 62], [72, 71, 58]] sum = 0 row = 0 while row < 6: col = 0 while col < 3: sum += tests[ row ][ col ] col += 1 row += 1 print( "The sum of all test scores is: ", sum ) print( "There are " ...
2c9689988a20d06c43554ab44ce3cd0c4d10715c
tzieba1/IntroPythonFiles
/PythonCodeSnippets/uppercaseFirstWord.py
636
4.09375
4
# Uppercase ONLY the first word of a sentence. # ASSUME Words are separated by " " and there are at least 2 words in # every sentence. myString = input("A sentence of 2 or more words: ") loopCounter = 0 keepLooping = True while keepLooping: if myString[ loopCounter ].isspace(): spaceP...
9746d53290cf636267549ab5cc22d1495812807e
andmigu/ElRompebolas
/rompebolas_menu.py
3,518
3.828125
4
import random from random import randint def menu(): print"Elija el nivel del juego:" print"1. Facil" print"2. Medio" print"3. Dificil" print"4. Tablero fijo" print"5. Mejores puntuciones" print"6. Borrar mejores puntuaciones" print"0. Salir del juego" ...
9b23c791b40e5dae4084a37907ac67785585518e
X-Jian/-5-5-9
/HW1/python35new/HW1.py
5,755
3.5625
4
import math from plotDecBoundaries import * # import all functions #temp其实就是distance #这一块先将train cvs文件拆分成x轴的,y轴的以及标签页面的 def read_and_mean(filename, choice, choice2): with open(filename) as train_data: reader = train_data.read().splitlines() #按照行进行分隔,产生包含各行为元素的列表 x_data = [] y_data = [] ...
9c18ca8c5e0e36e84aee90c7e0c7610b15ae0f0d
mayank-02/boolean-retrieval-model
/query.py
1,789
3.921875
4
from Stack import Stack def precedence(token): """ Precedence of supported operators """ __precedence = {"&": 2, "|": 1} try: return __precedence[token] except: return -1 def is_left_bracket(token): """ Returns true if left bracket """ return token == "(" def is_right_brack...
922cea55fad4a73133451179c28824af2676c48c
XxdpavelxX/sociopages.com-website-
/fb_popularity.py
1,197
3.625
4
import facebook # pip install facebook-sdk import json g = facebook.GraphAPI('CAACEdEose0cBAJ3ZBtQKs7WScgahjoOXVxOGXl3tXxfOZAQyVbZB3aCuudGE6v5ijaDP8WoxZCNaKkKldW0h66tJw3gr7pDVA8tkS4r0slYyNZA1G20bBT6ZAkLp9Gmq7TfuZA0P2GOZCvh1r2ddQgf6dltRzDBGDh0POyLeEMgfKechgYMwOtn1STTbFcG0BoRCk1aNrN1xQpjNnMDowgAzZAOr91dSVTtgZD') # Fin...
e16ddc3ce283062f10914bfbc1711bcc5f4dd160
Algogator/50-days-of-Python
/floor.py
563
4.15625
4
w = float(input()) h = float(input()) c = float(input()) """ http://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x The difference is that raw_input() does not exist in Python 3.x, while input() does. In Python 2, raw_input() returns a string, and input() tries to ru...
3c950f230d370a74df80abe3a9ba2710994f58a1
srikanthpotipi/market_palce_for_loans
/loan_market_place.py
5,384
3.515625
4
# Solution Author : Srikanth # data structure to combine the buyers particpation and percentage class Bid: def __init__(self,participation, percentage, index ): super().__init__() self.participation = participation self.percentage = percentage self.index = index # return the sorted...
5b0ece8feab69a7a336a32bfa7818c2fb1b95f86
imtengyi/Oldboy-1
/day3/sendmail.py
1,254
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: WangHuafeng #1.关键字def,创建函数 #2.函数名 #3.() #4.函数体 ''' def sendmail(): import smtplib from email.mime.text import MIMEText from email.utils import formataddr try: msg = MIMEText('邮件内容', 'plain', 'utf-8') msg['From'] = formataddr(["王华峰"...
e556a2b63a132df54d3e68be23ad58acc917219b
imtengyi/Oldboy-1
/day3/动态参数.py
1,287
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: WangHuafeng # *默认传值,传什么接收什么 # ** 指定key、value #动态参数,直接放入元组中,如果传入列表,则将列表转换为元组的一个元素 #1.普通参数(严格按照顺序,将实际参数赋值给形式参数) #2.默认参数(必须放置在参数列表的最后) #3.指定参数(将实际参数赋值给指定的形式参数) #4.动态参数: # * 默认将传入传入的参数,全部放置在元组中,f1(*[11,22,33,44]) # ** 默认将传入的参数,全部放置在字典中,f...
5c5fb4a468f82068f209ec1e613e10d04eb45e65
baskaufs/msc
/python/froggy.py
3,220
3.515625
4
# Steve Baskauf 2018-02-23 Freely available under a GNU GPLv3 license. #libraries for GUI interface import tkinter from tkinter import * from tkinter import ttk import RPi.GPIO as GPIO ## Import GPIO library GPIO.setmode(GPIO.BOARD) ## Use board pin numbering GPIO.setup(17, GPIO.OUT) ## Setup GPIO Pin 17 to OUT; ton...
0b175449c8af05fdd679bd325706d05bd236f736
KevinYaguar/estudios-python
/clase 3/ejemplo-for-nombres.py
277
3.921875
4
nombres = ["Harry", "Hermione", "Ron"] print(len(nombres)) #Imprimir nombres for i in range(len(nombres)): print(nombres[i]) #Version mas corta for unNombre in nombres: print(unNombre) print("______") nombre = "Kevin" for caracteres in nombre: print(caracteres)
5519b4c8e664a8c9189767fbbdfb27e3aa908ccb
C-CCM-TC1028-102-2113/tarea-4-IanCapetillo
/assignments/10.1AlternaCaracteresContador/src/exercise.py
336
3.890625
4
def main(): #escribe tu código abajo de esta línea num = 0 i = 0 print("Please type the number") num = int(input()) while i != num: i = i + 1 if (i%2) == 0: print(str(i) + "-%") elif (i%2)!=0: print(str(i) + "-#") else: print("Error") pass if __name__=='__main__': ...
c066d3eb3f55b0de23e62773f21a4c682e8b95df
bsaakash/SummerInternship2018
/ABAQUS_Run_Model/matrixTable.py
2,985
3.9375
4
"""Write a python function which takes 3 inputs - 1 list of strings, 1 filename, and a matrix(lists of lists) of numbers. The objective of this function is to use a template file and create input files for the models. The function first checks to see if the number of columns of the matrix is the same as the length o...
60c82bdcf213ee121e80a3d130bd9cc38ff957f0
debby975241/stancodeproject
/stanCode Project/SC101_Assignment5/anagram.py
3,616
4.1875
4
""" File: anagram.py Name: ---------------------------------- This program recursively finds all the anagram(s) for the word input by user and terminates when the input string matches the EXIT constant defined at line 19 If you correctly implement this program, you should see the number of anagrams for each word liste...
d7e249190e82793d0eff8a35fd9fac0a740b5bde
Jaipecas/practica1
/Ejercicio8.py
314
3.875
4
listaNombres = ["jaime", "alberto", "juan", "antonio", "pepe"] letra = input("Introduzca la letra a buscar: ") listaNombresLetra = [] for nombre in listaNombres: if nombre[0] == letra: listaNombresLetra.append(nombre) print(f"Los nombres que empiezan con la laetra {letra} son: {listaNombresLetra}")
8525fd79981a84bfb2a3d36b5e38a77ac8bc6e44
Notechus/ExtPython
/src/lista1/zad1.py
816
3.65625
4
from random import randrange import sys def roll_dice(): return randrange(1, 6, 1) def roll_for_player(n): res = 0 for i in range(n): res += roll_dice() return res def game(n): i = 0 res_a = 0 res_b = 0 draw = 0 while i < n or (i >= n and res_a == res_b): a = ro...
9f6a8c0b8bae5e8082899259703400c6af4de166
codejayanth/code-life
/Birthday_Func.py
7,786
3.953125
4
""" Created on Wed Dec 7 21:46:08 2022 @author: U410558 """ import pandas as pd import numpy as np import matplotlib.pyplot as plt import datetime class Birthday: def __init__(self, Availability_start, Availability_end, Budget, Template_Select, N): self.Availability_start = Availability_sta...
57851c856682c866f14b21d0a536bc80e3bdca96
ExcelsiorCJH/algorithm_solving
/07-Graph/bkjn_2178.py
767
3.609375
4
""" 2178. 미로탐색 https://www.acmicpc.net/problem/2178 힌트: BFS 탐색 + 응용 """ from collections import deque def bfs(x, y): queue = deque([(x, y)]) while queue: i, j = queue.popleft() for h, w in [(1, 0), (-1, 0), (0, 1), (0, -1)]: h, w = h + i, w + j if 0 <= h < N and 0 <=...
954dc9bfdc4b9977600b818a16f8d1ab7994a5c5
ExcelsiorCJH/algorithm_solving
/02-String/leet_819.py
800
3.65625
4
""" 819 - Most Common Word """ import re from collections import Counter class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: paragraph = paragraph.lower() paragraph = re.sub("[^a-z0-9]", " ", paragraph) paragraph = paragraph.split() w_dict = Counter...
b4b109c86f7937814a73704a4bb8496fb39ff96e
ExcelsiorCJH/algorithm_solving
/03-Stack/leet_739.py
520
3.71875
4
""" 739. Daily Temperatures """ from typing import List class Solution: def dailyTemperatures(self, T: List[int]) -> List[int]: answer = [0] * len(T) stack = [] for i in range(len(T)): while stack and T[stack[-1]] < T[i]: last = stack.pop() answ...
1ca27a5eea93f00e768cdd35858c1f9f4dcfa303
ExcelsiorCJH/algorithm_solving
/02-String/leet_5.py
1,232
3.6875
4
""" 5 - Longest Palindrome Substring """ class Solution: def longestPalindrome(self, s: str) -> str: def expand(left: int, right: int) -> str: while left >= 0 and right <= len(s) and s[left] == s[right - 1]: left -= 1 right += 1 return s[left + 1 : r...
ae97176aa5e383b22f8061891839804ca52ee630
Pyas/Data-Structures
/Data Structures/LinkedList/LinkList.py
1,885
3.890625
4
from LinkedList.Node import Node; class LinkList(object): def __init__(self): self.head=None def insertFirst(self,data): newNode=Node(data) if not self.head: self.head=newNode else: newNode.nextNode=self.head self.head=newNode def insertLas...
740f1b0cbe954110aac1a37bd3f16fbc4b1db9f4
pairashmi/Scientific-Calculator
/calculator.py
2,734
3.90625
4
from tkinter import Tk,StringVar,Entry,Button from math import degrees,radians,exp,asin,acos,atan,floor,pi,e,sin,cos,tan,log,log10,ceil class calculator: def __init__(self): window=Tk() window.title('Scientific Calculator') window.configure(background="white") self.string=StringVar(...
081b4a8bb3255e05de8bdc83bb1acf7aae3dface
deesaw/PythonD-04
/File I-O/Zipping/zip.py
283
3.8125
4
import zipfile # Create zip file f = zipfile.ZipFile('test.zip', 'w') # add some files f.write('file1.txt') # add file as a new name f.write('file2.txt', 'file-two.txt') # add content from program (string) f.writestr('file3.txt', 'Hello how are you') # flush and close f.close()
d79a995408cfd550002bad13feae36eb27a79666
deesaw/PythonD-04
/RegEx/1.py
199
3.78125
4
import re # Regular expression to replace pin value to * where ever it is located mob="My mobile number is 9888080808, 8900 and my pin is 7890" nn=re.sub(r"\b\d{4}\b","****",mob) print("Pin: ",nn)
8d20eedc41ed70717daf953c86e4de24d095e8bb
deesaw/PythonD-04
/Exception Handling/48_except4.py
291
3.6875
4
#prints the exception name try: a=10/0 except Exception as ex: raise Exception("Invalid Level") print("prints the exception name:",type(ex).__name__) print("Prints the arguments",e) def func(level): if level < 1: raise Exception("Invalid level") func(0)
a02bafa111abed277ae887a290165d6d4173a05a
deesaw/PythonD-04
/Web Programming/bottle/bottle_sqlite/bottlesqlite.py
500
3.5
4
import sqlite3 db = sqlite3.connect('picnic.db') db.execute("CREATE TABLE picnic (id INTEGER PRIMARY KEY, item CHAR(100) NOT NULL, quant INTEGER NOT NULL)") db.execute("INSERT INTO picnic (item,quant) VALUES ('bread', 4)") db.execute("INSERT INTO picnic (item,quant) VALUES ('cheese', 2)") db.execute("INSERT INTO picnic...