blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
24265804cef2ae8dfdf0bf6e0eff534bf9f56c1b
estraviz/codewars
/7_kyu/String prefix and suffix/solve.py
193
3.5625
4
""" String prefix and suffix """ def solve(st): ind = len(st) // 2 while ind > 0: if st[:ind] == st[-ind:]: return ind ind -= 1 else: return 0
84b1b5c1b1972fb6ca7352e808396a9cbf2be6b5
estraviz/codewars
/5_kyu/Number of trailing zeros of N!/python/solution.py
145
3.859375
4
"""Number of trailing zeros of N!""" def zeros(n): count = 0 while n / 5 >= 1: count += n // 5 n /= 5 return count
2bb861abc5672a2e777bf635976260b60e81807d
estraviz/codewars
/8_kyu/Simple calculator/calculator.py
183
3.84375
4
""" Simple calculator """ def calculator(x, y, op): if op in ['+', '-', '*', '/'] and type(x) == type(y) == int: return eval(f'{x} {op} {y}') return "unknown value"
0240e766566f2c722138b8e105f82520bb84ea0a
estraviz/codewars
/8_kyu/Calculate BMI/bmi.py
258
3.953125
4
"""Calculate BMI """ def bmi(weight, height): coef = weight/height**2 if coef <= 18.5: return "Underweight" elif coef <= 25.0: return "Normal" elif coef <= 30.0: return "Overweight" else: return "Obese"
8b7ff86dea0813a506118025d023d36b919d5df1
estraviz/codewars
/7_kyu/Birthday I - Cake/python/solution.py
306
3.703125
4
# Birthday I - Cake from string import ascii_lowercase def cake(candles, debris): if not candles: return "That was close!" score = sum(ord(c) if i % 2 == 0 else ascii_lowercase.index(c) + 1 for i, c in enumerate(debris)) return "Fire!" if score > 0.7 * candles else "That was close!"
1d76593795cc8d8422f7a5a361818952a5a44fac
estraviz/codewars
/6_kyu/IQ Test/iq_test.py
158
3.546875
4
"""IQ Test """ def iq_test(numbers): evenness = [int(num) % 2 for num in numbers.split()] return evenness.index(1 if sum(evenness) == 1 else 0) + 1
d042b790e7331c77ee79169c889adb7f72ac1744
estraviz/codewars
/7_kyu/Nice Array/is_nice.py
194
3.546875
4
""" Nice Array """ def is_nice(arr): if not arr: return False for elem in arr: if elem - 1 not in arr and elem + 1 not in arr: return False return True
7ac1a13df6e0691cc3a846e86bb13eec4adcaf49
estraviz/codewars
/5_kyu/RGB To Hex Conversion/rgb.py
358
3.71875
4
""" RGB To Hex Conversion """ def rgb(r, g, b): (r, g, b) = truncate([r, g, b]) return ''.join( n.zfill(2) for n in [hex(r)[2:], hex(g)[2:], hex(b)[2:]]).upper() def truncate(n): output = [] for k in n: if k < 0: k = 0 if k > 255: k = 255 ...
4c27f7196ca9497f11727b982184da62689c8d3d
estraviz/codewars
/8_kyu/Palindrome Strings/is_palindrome.py
99
3.796875
4
"""Palindrome Strings """ def is_palindrome(string): return str(string) == str(string)[::-1]
c829f926ebf5cd7366b4d53434df96f4c37a4015
estraviz/codewars
/8_kyu/Regex count lowercase letters/test_lowercase_count.py
419
3.859375
4
from lowercase_count import lowercase_count def test_lowercase_count_basic_examples(): assert lowercase_count("abc") == 3 assert lowercase_count("abcABC123") == 3 assert lowercase_count("abcABC123!@#$%^&*()_-+=}{[]|\':;?/>.<,~") == 3 assert lowercase_count("") == 0 assert lowercase_count("ABC123!@...
cc9938f4ca9c945493dd6ea8125f934dc2766666
estraviz/codewars
/8_kyu/Did she say hallo?/python/solution.py
313
4.03125
4
"""Did she say hallo?""" import re def validate_hello(greetings): hello_list = ["hello", "ciao", "salut", "hallo", "hola", "ahoj", "czesc"] regex = re.compile('[^a-zA-Z]') for word in greetings.split(): if regex.sub('', word.lower()) in hello_list: return True return False
1c10638d909170c7da1ef3f53c47361e8e949210
estraviz/codewars
/7_kyu/Max-min arrays/python/solution.py
250
3.671875
4
""" Max-min arrays """ def solve(arr): arr_sorted = sorted(arr, reverse=True) output = [] while arr_sorted: output.append(arr_sorted.pop(0)) if arr_sorted: output.append(arr_sorted.pop(-1)) return output
5d09d78c19030072e225c06b2bc69a82d16bfc68
estraviz/codewars
/8_kyu/Count of positives_sum of negatives/count_positives_sum_negatives.py
202
3.875
4
''' Count of positives / sum of negatives ''' def count_positives_sum_negatives(arr): return arr if arr == [] else \ [sum(1 for num in arr if num > 0), sum(num for num in arr if num < 0)]
c88d4bc5798faa7b4f21ee82ee0c5a091743cabd
estraviz/codewars
/6_kyu/Reverse every other word in the string/reverse_alternate.py
188
4.1875
4
""" Reverse every other word in the string """ def reverse_alternate(string): return ' '.join([ word[::-1] if i % 2 else word for i, word in enumerate(string.split()) ])
c08afff26bc8e8a957d76cd392a388db2ec03333
estraviz/codewars
/7_kyu/Palindrome chain length/palindrome.py
176
3.859375
4
""" Palindrome chain length """ def palindrome_chain_length(n): if str(n) == str(n)[::-1]: return 0 return 1 + palindrome_chain_length(n + int(str(n)[::-1]))
755bea66a190d5d6ef61b909a41bc8edf7486d7b
estraviz/codewars
/7_kyu/Make a function that does arithmetic/arithmetic.py
216
3.578125
4
""" Make a function that does arithmetic! """ def arithmetic(a, b, operator): return { "add": a + b, "subtract": a - b, "multiply": a * b, "divide": a / b }.get(operator, 0)
143f6279b435020ea201e81311ed96068bde1b11
estraviz/codewars
/7_kyu/Power of two/test_power_of_two.py
517
3.703125
4
from power_of_two import power_of_two def test_number_is_negative(): assert power_of_two(-1) is False def test_number_is_zero(): assert power_of_two(0) is False def test_number_is_positive(): assert power_of_two(1) is True assert power_of_two(2) is True assert power_of_two(5) is False asse...
4c0781f9a374c788c1aba1448e385894040fa3d7
DamianBocanegra/FalloutHackingMiniGame
/falloutHackingMiniGame.py
1,499
3.78125
4
#Fallout Password Crack #Recreate Fallout password cracking mini-game import random def addPassword(list, password): list.append(password) def checkAnswer(correctPassword, guess): index = 0 correctLetters = 0 for letter in correctPassword: if guess[index] != letter: index += 1 ...
982e7c541f8ba254fa461466e9ba78b8ba7ae043
SrCarlangas1/Practica4
/Exercici_09.py
343
4
4
print "dame la altura del rectangulo" a=input() print "dame la anchura del rectangulo" b=input() for i in range (a): for j in range (b): if i==0 or i==a-1: print "*", else: if j==0 or j==b-1: print"*", else: print" ", ...
e64b6d1b38d1904a37069e64b561955c39b3a140
vaibhav748/my_first_repo
/python_practice.py
6,913
4.1875
4
# my_dict = {"name": "vaibhav", # "surname": "mathur", # "age": 21} # print(my_dict) # print(my_dict["age"]) # print(len(my_dict)) # print(type(my_dict)) # # x = my_dict.get("name") # # print(x) # y = my_dict.keys() # print(y) # my_dict["company"] = "ThoughtWin IT Solutions Pvt. Ltd" # pri...
918ad1bb31e46fd4dc8301c14504bd4b69a36763
komalsorte/LeetCode
/Amazon/Trees and Graphs/236_LowestCommonAncesterofABinarySearchTree.py
1,987
3.953125
4
__author__ = "Komal Atul Sorte" """ Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow ...
c33d83a77c657e38367470f958cfd379fb5e4545
komalsorte/LeetCode
/Oracle/BinarySearchTree.py
4,563
3.921875
4
""" """ class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def __init__(self): self.isPValue = False def isValidBST(self, root): """ 98. Validate Binary Search Tree ...
2e8a74c5c5c49849e9ce94eb14c83643f38218d8
komalsorte/LeetCode
/Oracle/113_PathSumII.py
1,790
3.734375
4
""" LeetCode - Medium """ """ Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 Return: [ ...
cff55c73deea005d2138c5e66581cbe99d80db8c
komalsorte/LeetCode
/BinaryTree/104_MaximumDepthOfBinaryTree.py
1,324
4.09375
4
__author__ = "Komal Atul Sorte" """ Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 /...
0226b9fcba8e0792d079257b25774e7bd9a9be9e
komalsorte/LeetCode
/BinaryTree/112_PathSum.py
1,695
3.96875
4
__author__ = "Komal Atul Sorte" """ Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ ...
8e7d1637747eb54f850e061a28b143833afda88a
komalsorte/LeetCode
/Amazon/Array and String/937_RorderLogFiles.py
2,091
3.734375
4
__author__ = "Komal Atul Sorte" """ You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier. Then, either: Each word after the identifier will consist only of lowercase letters, or; Each word after the identifier will consist o...
5340e4ef042f67e12d3f30f6f78075a396d384f0
komalsorte/LeetCode
/HashTables/HashMap/599_MinimumIndexSumofTwoLists.py
2,542
3.796875
4
""" LeetCode - Easy """ """ Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no o...
62189c29eeff0f3d11c3f2b68d89964f655524df
komalsorte/LeetCode
/BinarySearchTree/701_InsertIntoABST.py
2,005
4.28125
4
__author__ = "Komal Atul Sorte" """ Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. Note that there may exist multiple ...
97a277d44d310186eaac5eafab821f76b167857c
komalsorte/LeetCode
/NAryTree/590_NAryTreePostorderTraversal.py
1,814
3.734375
4
""" LeetCode - Easy """ """ Given an n-ary tree, return the postorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). Follow up: Recursive solution is trivial, could you do it iterati...
d372fd0c5882aae7695c4f0f36b5215518ca8e69
komalsorte/LeetCode
/StackAndQueues/20_ValidParantheses.py
1,500
3.78125
4
""" LeetCode - Easy """ """ Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Example 1: Input: s = "()"...
d3fee9175d557e9266651a5ed4faf5b0d7acb55b
komalsorte/LeetCode
/HashTables/705_DesignHashSet.py
4,723
3.859375
4
""" LeetCode - Easy """ """ Design a HashSet without using any built-in hash table libraries. To be specific, your design should include these functions: add(value): Insert a value into the HashSet. contains(value) : Return whether the value exists in the HashSet or not. remove(value): Remove a value in the HashSet...
356e21a157da1a067c7d8fbd997055ac030c23ee
komalsorte/LeetCode
/Oracle/692_TopKFrequentWords.py
2,021
4.03125
4
""" LeetCode - Medium """ import collections """ Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first. Example 1: Input: ["i", "love", "...
9e22b05ad03b0058c50e330b212672988ff9dffb
komalsorte/LeetCode
/DynamicProgramming/1025_DivisorGame.py
1,148
3.78125
4
""" LeetCode - Easy """ """ Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of: Choosing any x with 0 < x < N and N % x == 0. Replacing the number N on the chalkboard with N - x. Also, if ...
1939eedbb5639bc8a7b3c76bef2adfbcfd5886c3
komalsorte/LeetCode
/Amazon/Linked Lists/138_CopyListWithRandomPointer.py
2,682
4.15625
4
__author__ = "Komal Atul Sorte" """ A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, r...
8e21bac51e0765a758ad6f686889b3458542c9a2
komalsorte/LeetCode
/BinarySearchTree/703_KthLargestElementInAStream.py
2,218
3.78125
4
""" LeetCode - Easy """ """ Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums. int a...
2c150e17e55c9b4d92790601fde97a9a6972dce9
komalsorte/LeetCode
/Amazon/Array and String/268_MissingNumber.py
489
3.75
4
__author__ = 'Komal Atul Sorte' """ Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. """ # Complexity - O(nlogn) # n - for loop # log n - sort class Solution: def missingNumber(self, nums): nums.sort() for num in range(len(nums))...
3634226793ce12561cac92fcfc00a41eae73d7fb
aLoi3/comp260-server
/MUD/Dungeon.py
2,693
3.921875
4
from Room import Room class Dungeon: def __init__(self): self.currentRoom = 0 self.room = {} def Init(self): print("You've decided to go on an adventure. \n " "Luckily, first dungeon was nearby, which wasn't looking as dangerous as others were talking about. \n " ...
eaec2dd706cd73f4e328519123290944590d3a76
karimould/til-1
/python/tutorial/code/ch02/embedded.py
195
3.65625
4
import math # 10進数の2進数表記を得る関数 def get_binary_number(n): result = '' while n != 0: n, r = divmod(n, 2) result = str(r) + result return result
15b265aa5dc15e1d5373b6707a4a0b781bb74fda
Utsav-Raut/python_tutorials
/intrvw_topics/codewars/disemvowel.py
189
4.125
4
#REMOVE THE VOWELS OF A STRING def disemvowel(s): return "".join(c for c in s if c.lower() not in 'aeiou') str = "This website is for fools, LOL!" reply = disemvowel(str) print(reply)
452b216c2a8ca88c693a6178964a0369d6b03ce8
Utsav-Raut/python_tutorials
/intrvw_topics/hackerrank/set_symmetric_diff.py
999
4.28125
4
# Given 2 sets of integers, M and N, print their symmetric difference in ascending order. # The term symmetric difference indicates those values that exist in either M or N but do not exist in both. # Input Format # The first line of input contains an integer, M. # The second line contains M space-separated integers...
38bf75a3fddffd0173f65a5e7bf3f581a605e96a
Utsav-Raut/python_tutorials
/python_oop/oop_constructor.py
639
4.34375
4
class Mobile: def __init__(self, brand, price): print("Inside constructor") self.brand = brand self.price = price def __del__(self): #This is a special method which gets invoked automatically when an object is removed from memory print("deleting object") mob1 = Mobile("Apple",...
d1c88b2e8688fb56eecbc9db2b5d505e61810e97
Utsav-Raut/python_tutorials
/dsa_basics/tuples/tuple_basics2.py
1,190
4.40625
4
# TUPLE FUNCTIONS # LENGTH coral = ('blue coral', 'staghorn coral', 'pillar coral', 'elkhorn coral') kelp = ('wakame', 'alaria', 'depp-sea tangle', 'macrocystis') numbers = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) print("the length of the tuple 'coral' is: ",len(coral)) print("the length of the tuple 'numbers' is: ...
902a52b11f883526e35a6c647bab723cad8733c1
Utsav-Raut/python_tutorials
/dsa_basics/lists/list_basics4.py
4,110
4.875
5
# LIST METHODS # Unlike strings, which are immutable, whenever we apply any method on a list we affect the list itself and not a copy of it. # ###################################################### # LIST APPEND # The method list.append(x) will add an item (x) to the end of a list. print('Before Append...') fish = ...
10136f903472aa5aa5c3d677b39d0662b837bb2e
Utsav-Raut/python_tutorials
/python_basics/numTypes-3.py
665
4.40625
4
num = 3 # print(type(num)) #ARITHMETIC OPERATORS: # ADDITION: 3 + 2 # SUBTRACTION: 3 - 2 # MULTIPLICATION: 3 * 2 # DIVISION: 3 / 2 # Floor DIVISION: 3 // 2 # Exponent: 3 ** 2 # Modulus: 3 % 2 # print(3/2) # This gives 1.5 # print(3//2) #This gives 1 # num *= 10 # print(num) # print(abs(...
6d8b5d9ab902ddedcde1aeb169b316d8799d2ea2
Utsav-Raut/python_tutorials
/intrvw_topics/basics/6_check_prime.py
299
4.21875
4
# Program to check if a number is prime or not num = int(input('Enter the number to be checked for prime ')) flag = 0 for i in range(2, (num // 2) + 1): if num > 1: if num % i == 0: flag = 1 break if flag == 0: print('Prime') else: print('Not a prime')
da06bdd74c29b3eade4ac13eaa10159addb6c486
Utsav-Raut/python_tutorials
/python-sdet/reg_exp.py
2,099
3.96875
4
import re if(re.search(r"A..l","Aopline")!=None): # each . represents a single character print("Dot Pattern found") else: print("Dot Pattern not found") if(re.search(r"A\dl","A2line")!=None): #Digit after A print("Digit Pattern found") else: print("Digit Pattern not found") if(re.search(r"A\d*","A223...
6e2c782e79547e686b4cdbe918eccd6ec76aa7e1
Utsav-Raut/python_tutorials
/python-sdet/oops/basic_oops/oops4.py
331
3.640625
4
class Mobile: def __init__(self): print("Inside constructor") def purchase (self): print("Purchasing a mobile") mob1=Mobile() mob1.purchase() #Inbound method invocation, We need not pass the value for self. Mobile.purchase(mob1) #Outbound method invocation, We have to pass the object as the valu...
bf34e4bf6ad197fea6b16954faeee92f4461c747
Utsav-Raut/python_tutorials
/2022_python_learnings/user_input.py
514
4.15625
4
# Taking numbers as input beautiful_number = input("Enter a beautiful number:") print(beautiful_number) print(type(beautiful_number)) second_beautiful_number = float(input("Enter another beautiful number:")) print(second_beautiful_number) print(type(second_beautiful_number)) print("Big", 99, 1.2) print("Big", 99, 1.2...
43b9ded978e19b0227783f3b39a097f4d165b1c5
Utsav-Raut/python_tutorials
/intrvw_topics/dsa/python_lists.py
1,455
4.6875
5
# Demonstrating Lists in Python # Lists are dynamically sized arrays. They are fairly general and can contain any linear sequence of Python objects: functions, strings, integers, floats, objects and also, other lists. It is not necessary that all objects in the list need to be of the same type. You can have a list wit...
7bb0a2ecd984bc02a7ae55acf57ed4b03d6fd417
Utsav-Raut/python_tutorials
/intrvw_topics/basics/sum_of_divisors.py
856
4.15625
4
# Given a natural number N, the task is to find the sum of the divisors of all the divisors of N. # Example 1: # Input: # N = 54 # Output: # 232 # Explanation: # Divisors of 54 = 1, 2, 3, 6, 9, 18, 27, 54. # Sum of divisors of 1, 2, 3, 6, 9, 18, 27, 54 # are 1, 3, 4, 12, 13, 39, 40, 120 respectively. # Sum of diviso...
a46a29049206a7fc1a33ad3842a33d423bbd728f
Utsav-Raut/python_tutorials
/python_oop/multiple_inheritance.py
660
3.796875
4
# Parent class 1 class TeamMember(object): def __init__(self, name, uid): self.name = name self.uid = uid # Parent class 2 class Worker(object): def __init__(self, pay, jobtitle): self.pay = pay self.jobtitle = jobtitle # Deriving a child class from the two parent classes class...
7b88434d713546f8b4f5309333f01ecc4d17250d
Utsav-Raut/python_tutorials
/python-sdet/oops/inheritance/method_overriding.py
484
3.75
4
class Phone: def __init__(self, price, brand, camera): print ("Inside phone constructor") self.__price = price self.brand = brand self.camera = camera def buy(self): print ("Buying a phone") def return_phone(self): print ("Returning a phone") class FeaturePhon...
9e1d2fd55e799df754b3da4c1946562106e88ebf
Utsav-Raut/python_tutorials
/intrvw_topics/codewars/parenthesis_count.py
735
4.40625
4
# Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if it's invalid. # Examples # "()" => true # ")(()))" => false # "(" => false # "(())((()())())" => ...
4be179b44c0eb1ecf5cda22aee36d48d2ccddb52
Vador05/iec_codeclub
/day2/simpleif.py
475
4.125
4
#print() will show on the terminal the variable or text that has inside #input() will expect some input from the terminal #int() makes python to convert what is inside the parenthesis to number a = int(input("Introduce a number \n")) if(a<10):#if the condition that is betweeen the parenthesis is fulfilled then the co...
315e6c914b73691215e0739979ae1daf782bd73e
vrodolfo/python_nov_2017
/Rodolfo_Valdivieso/PythonFundamentals/assignment11PythonCoins.py
642
4.0625
4
# Assignment 11 Python - Coin Tosses #function that simulates tossing a coin 5,000 times. #function should print how many times the head/tail appears. import random def coinTosses(a): tail=0 head=0 for i in range(1,a+1): x_rounded = round(random.random()) if (x_rounded == 1): tail = tail + 1 print "Attemp...
ea8a78364cafed9a8a191113ad9554a9c3182d10
vrodolfo/python_nov_2017
/Rodolfo_Valdivieso/PythonFundamentals/assignment3PythonMultiples.py
576
4.375
4
#Assignment 3 Python. #Multiples - Part 1. Printing Odd Numbers from 1 to 1000 for i in range(1,1001): if i % 2 != 0: print i #Multiples - Part 2. Printing Numbers Multiples of 5 from 5 to 1.000.000 for i in range(1,1000001): if i % 5 == 0: print i #Sum List. Program that sum every item in a list and prints the...
df96e27b764cec312acbd4f4a3de8a9d791ed17a
vrodolfo/python_nov_2017
/Rodolfo_Valdivieso/PythonOOP/assignment4Animal.py
1,089
3.953125
4
#Assignment 4 Python OOP - Animal class animal(object): def __init__(self, name, health): self.name = name self.health = health def walk(self): self.health -= 1 return self def run(self): self.health -= 5 return self def display_health(self): print "Health: " , self.health return self print "An...
fe0b9c03fd05d25af9672e1a7f55c5382f947b67
dominicpaul17/pythonintern
/day 3.py
683
4.15625
4
dict1 = {"apple":2 , "orange":3, "banana" :4 } dict2 = {"cashew" : 2, "almond": 3 } dict1.update(dict2) print ("merging two python dictionaries") print(dict1) print ("remove a key from dictionaries") del dict1["apple"] print(dict1) keys = ['tata','maruti','aud...
3ce399525f96da18e3b5a63a1f76636f420a29e7
WJChoong/Exercise-Python
/Exercise/arithmetic.py
1,173
4.15625
4
import math #Both inputs a = input("Please enter the first input: ") b = input("Please enter the second input: ") #validate inputs while a.isdigit() !=True or b.isdigit() != True: if a.isdigit() != True and b.isdigit() != True: print("Both input are invalid! Please enter again.") a = inp...
4ad4994d9962d53efdf8ba623f42bd56facee007
WJChoong/Exercise-Python
/Exercise/Decimal and Binary Converter.py
2,057
4.25
4
def menu(): print("1: Binary To Decimal and Octal"); print("2: Decimal To Binary and Octal"); print("Enter 'x' for exit."); menu(); choice = input("Your Choice: "); while choice != 'x': #chooses 1 if choice == "1": binary = input("Enter any number in Binary Format: "); ...
ceca3165ced59353a0f86f4a526516b0d63ce46a
nceglia/Hebbian
/Network.py
7,530
3.875
4
from math import exp import math from boolean import BOOLEAN from Neuron import Neuron class Network(object): """Network class""" def __init__(self, rate, sigmoid, hidden, examples, variables, layers, rule, dropout): """ Feed-Forward Hebbian network for learning boolean functions with t...
ee75b9ffed87c147173850f041bc87d7a935044c
dorbarker/standard-measurements
/scripts/python/N50.py
984
3.59375
4
#!/usr/bin/env python3 # Author: Lee Katz <gzu2@cdc.gov> import sys from Bio import SeqIO import argparse # Find the N50: the contig size at half the expected genome # size def N50(fasta, expectedGenomeSize): lengths=[] with open(fasta, "r") as handle: for record in SeqIO.parse(handle, "fasta"): lengths...
02bcdb0428d9e36d2c803d8234ae0bc35cb7c1f9
bryanbcheng/MT124
/translate.py
1,874
3.6875
4
def readFile(filename): f = open(filename) lines = f.readlines() f.close() for line in lines: if line == "\n": # print "**line deleted**" del line # else: # print line return lines def readDict(filename): dictionary = {} f = open(filename) lines = f.readlines() f.close() for line in lines: ger...
67f50b1323a05e8dad1c864042a55a72c55bb54a
kayvera/python_practice
/misc/findmaxnum.py
235
3.671875
4
def findBiggestNumber(sampleArray): biggestNumber = sampleArray[0] for index in range(1, len(sampleArray)): if sampleArray[index] > biggestNumber: biggestNumber = sampleArray[index] print(biggestNumber)
188ff4f5fb28f27bdacfbc11e492c0384bd849b5
kayvera/python_practice
/array/removeDuplicates.py
2,159
3.9375
4
class Node(): """Single node of singly linked list""" def __init__(self, data): self.data = data self.nextNode = None def __str__(self): return str(self.data) class LinkedList(): """Create singly linked list by passing the list to the constructor""" def __init__(self, link...
a08ac99bdf92b1f96f8d0e0b98a309c3be6cf94e
kayvera/python_practice
/lists/listoperations.py
381
3.75
4
a = [0, 1, 2, 3] b = [4, 5, 6] c = a + b print(c) d = [0, 1] d = d * 4 print(d) print(len(c)) print(max(c)) print(min(c)) print(sum(c)) print(sum(c)/len(c)) my_list = list() while (True): inp = input('Enter a number: ') if inp == 'done': break value = float(inp) my_list.append(value) aver...
2da3d2b723e03d95760dcc2ae2146ac1518142f3
kayvera/python_practice
/recursion/findMax.py
323
3.78125
4
def findMaxNum(arr, n): # M(n) if n == 1: # O(1) return arr[0] # O(1) return max(arr[n-1], findMaxNum(arr, n-1)) # M(n-1) # big-O of recursive algorithm? # recursive is assumed to take M(n) # equation above equals M(n)=O(1)+M(n-1) # equals O(n) # recursive function that makes multiple calls is O(2^...
885fc1143fb2a26b988271b58c71b2c6f8426b81
mollenayla/assignmentOrganizer
/assignmentOrganizer.py
1,527
4.28125
4
''' Created on Feb 10, 2019 @author: ITAUser Algorithm: 1. Make a .json txt file that will store the assignments 2. Import .json file into code 3. create user input for finding assignments 4. find the user's assignment in data - If the user's input is in our data - the user's input isn't in our data ''' impor...
c301be2dbfd33fd1271306146d5bb821eab6ceee
JuniorLlancari/Quantum-python
/Sesion_01/Ejercicio_Clase/Ejercicio_01.py
234
3.84375
4
#float() edad=input("Escribe tu edad ") nombre=input("Escribe tu nombre") if int(edad) >18: print("La edad de "+ str(nombre) +" es" +str(edad)+"- Adulto") else: print("La edad de "+ str(nombre) +" es"+ str(edad)+"- Menor")
bd2171241a9e654abb33fe0fe0493ffd8c032166
JuniorLlancari/Quantum-python
/Sesion_02/Ejercicio_Clase/Ejercicio-01.py
154
3.625
4
def saludar(nombre): print(f'Hola {nombre.capitalize()}') # print(f'Hola {nombre.upper()}') nombre=input('Ingresa tu nombre : ') saludar(nombre)
1c1cdaae4be575d9b32a9e3969c99d71726931d0
JuniorLlancari/Quantum-python
/Práctica I/Ejercicio-04.py
557
3.984375
4
def lectura(): valor=input("Ingrese el numero de mes :") valor=int(valor) if(valor<=12 and valor>=1): if(valor<=3 and valor>=1): print("Es parte del Primer Trimestre ") if(valor<=6 and valor>=4): print("Es parte del Segundo Trimestre ") if(valor<=9 and valor>...
0cad07d8655c4b9832c38e52352b3ab127076923
DEVILcong/PythonTest
/Test1/Q3.py
510
3.6875
4
#! /usr/bin/env python3 #coding:utf8 def shopping(itemList): item = 0 num = 0 check = 0 print('请输入商品名及购买数量,以逗号分开,输入为空结束') while True: middle = input() if middle == '': break item,num = middle.split(',') num = int(num) if not item in itemLi...
fc1fe5667f6e9fdf7c99dccffe554329e3dbad37
Yaxin1996Z/LeetCode-py-cpp
/LeetCode-py/78_subsets.py
402
3.703125
4
class Solution: def subsets(self, nums): result = [] path = [] def backtrack(start, path): result.append(path) for i in range(start, len(nums)): backtrack(i+1, path+[nums[i]]) backtrack(0, path) return result if __name__ == '__main__':...
68ac6164ce32eeb3cd1eb54614a3d155ea8938de
gajubadge11/code-with-harry
/absolute-beginners/004-tut.py
1,334
4.4375
4
# Lists and Lists Functions. laptop = ["ram", "battery", "hdd", "led", "wifi", "mouse", 227] print(laptop[5]) numbers = [2, 8, 9, 11, 67, 7] # print(numbers[4]) # numbers.sort() # Sort and reverse may change the original list parameter. Here we are using numbers name list. # numbers.reverse() print(numbers[1:4]) ...
1d876bb80545c4f4facb4cb09dd86ff52ea416c6
gajubadge11/code-with-harry
/absolute-beginners/006-tut.py
936
3.984375
4
# set function. # In brief examples on set. >> print set() set([]) >>> print set('HackerRank') set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R']) >>> print set([1,2,1,2,3,4,5,6,0,9,12,22,3]) set([0, 1, 2, 3, 4, 5, 6, 9, 12, 22]) >>> print set((1,2,3,4,5,5)) set([1, 2, 3, 4, 5]) >>> print set(set(['H','a','c','k','e','...
683e407817a1af7b8bb952a9b41a357b0bb4df3d
Amenti90/IS211_Assignment2
/assignment2.py
3,385
3.78125
4
from __future__ import print_function import urllib2 import csv import argparse import logging import datetime TEST_URL = "https://s3.amazonaws.com/cuny-is211-spring2015/birthdays100.csv" LOG_FILENAME = 'errors.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.ERROR) logger = logging.getLogger("assignme...
8673268867bb57d36aa7b2ab265f811866c34c9c
thierved/learning_python
/test.py
262
3.8125
4
def product(x): def add(y): return x * y return add multiply_by = product(3) quadriples = product(4) print(multiply_by(3)) print(multiply_by(4)) print(multiply_by(10)) print() print(quadriples(2)) print(quadriples(4)) print(quadriples(10))
a5ba187821fece00cef0d2d34ced4bf222bbc205
FinnBerkhout/the_island
/advanced_map_logic_t1.py
2,820
3.796875
4
from tkinter import * from random import * window = Tk() width = window.winfo_screenwidth() height = window.winfo_screenheight() window.geometry('%sx%s' % (width, height)) placeDES = StringVar() y = 4 x = 4 starter = 1 destype = randint(0, 3) placeDES.set("""you decide to head out on a journey. there...
a8a20033b5df26603988be268a8c251bfe62396c
sachin0010/faulty-calculator
/faulty-calculator.py
776
4.15625
4
opt=input("Enetr operator {+ , - , * , / , }: ") f_no=int(input("Enetr First Number: ")) s_no=int(input("Enter Second Number: ")) if opt=='+': if (f_no==55 and s_no==9) or (f_no==9 and s_no==55): print("Your ans is 40") else: print("Your ans is ", f_no+s_no) elif opt=="-": if (f_n...
8831313fd64910e981f434e2ac6e04a021eb8b5b
alonitac/BlokusAI
/blokus_problems.py
16,756
3.859375
4
from board import Board from search import SearchProblem, Node, a_star_search import util import numpy as np class BlokusFillProblem(SearchProblem): """ A one-player Blokus game as a search problem. This problem is implemented for you. You should NOT change it! """ def __init__(self, ...
d6d1624df8ae975b1e3d1bede1461d8aebcb3e15
Ajd100/Secure-Number-Game
/number_game.py
3,657
3.96875
4
#This is importing the rand module import random import logging #Setting up the debugging environment fh = logging.FileHandler("debuggingLog.log") sh = logging.StreamHandler() fh.setLevel(logging.WARNING) sh.setLevel(logging.DEBUG) logger = logging.getLogger() logger.setLevel(logging.DEBUG) logger.addHandler(fh) l...
9976a9cb9ddbda8b086fb9a9a235c9b98469ea9d
Munanna/MITx-6.00.1x
/Week1_Problem1.py
241
3.8125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 6 11:54:17 2017 @author: OMNISLO """ counter = 0 for x in s: if x=='a' or x=='e' or x=='i' or x=='o' or x=='u': counter += 1 print ("Number of vowels: ", str(counter))
95e8dc5c83d148496ed9893aed7b00b38691daf7
shch92/Project__Topic_Modelling
/function__preprocess_tweet__dataframe.py
1,298
4
4
# Defining function to preprocess tweets by lemmatization and removing stopwords and convert it into a corpus def preprocess_tweet(df): """ The function accepts a dataframe. The column in the dataframe which contains the text data to preprocess should be called 'text' otherwise the function will not w...
7f64268ecc6d675d50ca9a1595b2a6615ad35a54
mtkane6/Python_Leetcode
/ReverseLinkedList.py
1,036
4.03125
4
''' Runtime: 24 ms, faster than 60.80% of Python online submissions for Reverse Linked List. Memory Usage: 15.4 MB, less than 23.15% of Python online submissions for Reverse Linked List. Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL ''' # Definition for singly-li...
49c753ae6d6ba1c90c107c91af5d4b90318901f5
alpaca0629/python_hardway3
/ex_19.py
823
3.875
4
import math def cheese_and_crackers(cheese_count, boxes_of_crackers): print("You have {} cheeses!".format(cheese_count)) print("you have {} boxes of crackers!".format(boxes_of_crackers)) print("Man that's enough for a party!") print("Get a blanket.\n") cheese_and_crackers(input("The number of chesses:"...
cc5c3124b27229d8e732f8b363530c440466e699
GBoshnakov/SoftUni-Advanced
/Multidimensional Lists/Snake Moves.py
515
3.546875
4
from collections import deque rows, cols = [int(n) for n in input().split()] matrix = deque() snake = input() index = 0 for row in range(rows): matrix.append(deque()) for col in range(cols): for i in range(index, index + 1): if row % 2 == 0: matrix[row].append(snake[i]) ...
bb3e64563ad4870b4710f623218a10ea751a66dc
GBoshnakov/SoftUni-Advanced
/Multidimensional Lists/Symbol in Matrix.py
387
4
4
rows = int(input()) matrix = [] for row in range(rows): matrix.append([n for n in list(input())]) position = None searched_symbol = input() for row in range(rows): for col in range(rows): if matrix[row][col] == searched_symbol: position = (row, col) print(position) ...
2263ae36b7a848a4e4eab7bc154d14e4725786e4
GBoshnakov/SoftUni-Advanced
/Stacks and Queues/Truck Tour.py
1,006
3.53125
4
from collections import deque number_of_pumps = int(input()) circle = deque() for _ in range(number_of_pumps): data = [int(n) for n in input().split()] circle.append(data) current_smallest = int() index = 0 #print(circle) for i in range(len(circle)): fuel_in_tank = 0 is_enough_fuel = True ...
4c25eae9888c421b606e4fe6ab56ba9569bfe802
GBoshnakov/SoftUni-Advanced
/Comprehensions/No Vowels.py
102
4.09375
4
vowels = ['a', 'o', 'u', 'e', 'i'] print("".join([el for el in input() if el.lower() not in vowels]))
fb0c4392996c4af2518105bdd07d708aae67be50
GBoshnakov/SoftUni-Advanced
/Stacks and Queues/Fast Food.py
321
3.75
4
from collections import deque food = int(input()) queue = deque(int(n) for n in input().split()) print(max(queue)) while queue: if food < queue[0]: break food -= queue[0] queue.popleft() if not queue: print("Orders complete") else: print(f"Orders left: {' '.join(list(map(str, queue)))}"...
4d3ce2e530c7fda6e26ffe704c6913443cf42006
GBoshnakov/SoftUni-Advanced
/Functions Advanced/Even or Odd.py
372
3.9375
4
def even_odd(*args): args = list(args) operator = args.pop() filtered = [] if operator == "even": filtered = filter(lambda x:x % 2 == 0, args) elif operator == "odd": filtered = filter(lambda x:x % 2 == 1, args) return list(filtered) print(even_odd(1, 2, 3, 4, 5, 6, "even")) p...
6ecdfe411c5f0b0d7f0370cd9ca29c2870b6f518
GBoshnakov/SoftUni-Advanced
/Comprehensions/Bunker.py
607
3.8125
4
items = {category: {} for category in input().split(", ")} count = 0 avg_quality = 0 for _ in range(int(input())): line = input().split(" - ") category = line[0] name = line[1] part1, part2 = line[2].split(";") quantity = int(part1.split(":")[1]) quality = int(part2.split(":")[1]) items[cate...
2214f47ad564206f1d812c2bbd04a0af0c993b07
GBoshnakov/SoftUni-Advanced
/Exams/27 June 2020/01.Bombs.py
1,218
3.671875
4
from collections import deque bomb_effect = deque([int(el) for el in input().split(", ")]) bomb_casing = [int(el) for el in input().split(", ")] is_fulfill = False bombs = { "Datura Bombs": 0, "Cherry Bombs": 0, "Smoke Decoy Bombs": 0 } checker = { 40: "Datura Bombs", 60: "Cherry Bombs", 120...
405d19c75deb3c3c82c30d42293a43d2a617f3cc
GBoshnakov/SoftUni-Advanced
/Exams/16 Dec 2020/01.py
1,254
3.609375
4
from collections import deque def check_value(number): if number <= 0: return True return False def check_if_divisible(number): if number % 25 == 0: return True return False males = [int(el) for el in input().split()] females = deque([int(el) for el in input().split()]) matches = 0...
f0a0d8006387f29ca09087025cad2409a9f68401
GBoshnakov/SoftUni-Advanced
/Exams/19 Aug 2020/01.Taxi Express.py
616
3.71875
4
from collections import deque customers = deque([int(el) for el in input().split(", ")]) taxis = [int(el) for el in input().split(", ")] total_time_driven = 0 while taxis and customers: if customers[0] > taxis[-1]: taxis.pop() continue else: total_time_driven += customers.popleft() ...
2c2acc4c427284559d1cf5a62749d81136b87248
TylerBromley/MovieTrailerWebsite
/media.py
591
3.515625
4
import webbrowser class Movie(): """This class provides a way to store movie related information.""" # constructor def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube): # types of related information: self.title = movie_title self.sto...
a02810e0a3e69fd84f0d41187f01be60a13ad52a
ZafarHamidov/Python
/LESSON 5/LESSON 5 B.py
78
3.78125
4
n = int(input()) for i in range(n): x = i * 3 + 3 print(x, end=' ')
f1fbb9ee0a54c1d004f94e567c02a016fb44a30c
Lasya2026/p98
/swappingFile.py
653
3.75
4
def SwapFileData(): swap1 = input("Enter 1st file name to Swap:- ") swap2 = input("Enter 2nd file name to Swap:- ") with open(swap1, 'r') as a: read_a = a.read() with open(swap2, 'r') as b: read_b = b.read() with open(sw...
f8edf3b176798d21359c26d9d7366fc987d02f12
ceorourke/head-first-python
/hfpy_ch5_data/process.py
1,051
3.546875
4
def sanitize(time_string): """Make all strings be in the same format""" if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return(time_string) (mins, secs) = time_string.split(splitter) return(mins + '.' + secs) def process_file(filenam...
8cd3494c2802624f677d208b54c799b7941b575b
rutiglianom/Face-class
/as17.py
9,590
3.703125
4
# Matthew Rutigliano # ECEGR 3910 # November 22nd, 2019 # AS.17: Graphics Class # Description: Demonstration of face class, showing the move function, blink animation, and spinning animation from graphics import * class Face: def __init__(self, xloc, yloc, height, skinColor, eyeColor, window): s...