blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1dad48d9a7c43456a7aa4852163d0dde586329b8
arashalaei/NLP_filter_toxic_comment
/pre_processing/remove_punctutaions.py
358
4.5
4
from string import punctuation def remove_punct(text): """ take string input and clean string without punctuations. use regex to remove the punctuations. """ return ''.join(c for c in text if c not in punctuation) def main(): text = "Hello! how are you doing?" print(remove_punct(text)) ...
true
4cac9106ea4333f70926b139ba38bcb2b6c7a756
agreen2413/GitDemo
/Loops.py
1,146
4.21875
4
# In Python there is no {} open and close brackets unlike C# and Java. It is ":" instead on If statement. #Example of If/else statement code below language = "Python" a = 4 if a > 2: print("condition match") else: print("condition do not match") print("This code is valid") #This will always print cause i...
true
97bb391812d0670d5682b4b8c323e6841ee05927
biki234/PythonNotes
/list_dict_tuple/list.py
2,154
4.375
4
""" Sequential Data Types: Lists, Tuples List in Python is an ordered group of items or elements, may contain various elements of different types. -Mutable, Extendable -accessible by index, slicing etc ex: myList = [] """ emptyList = [] mixedList = [1,2,3,4,56.7,34.6] mixedList_0 = [1,2,3,4,56.7,34.6,"the",'python'] ...
true
e70f60b731e3308141c629c97c12acde5048e48c
biki234/PythonNotes
/loops/while.py
623
4.1875
4
""" while Loop """ number=0 while number <= 10: #performs the Loop until given condition is satisfied print("Number : ",number) if number%2==0: print("\tNumber ",number," is Even") else: print("\tNumber ",number," is ODD") number+=1 #Infinite Loop with while print("\n Enter 'quit' to ...
true
48a46a3de83abfafae8f55da6dbf55bb008d5ce4
JanisLibeks/PythonExercises
/palindrome/__init__.py
368
4.15625
4
inputText = input("Enter string you want to check: ") def reverse(reverse_string): return reverse_string[::-1] def ispalindrome(reverse_string): rev = reverse(reverse_string) if reverse_string == rev: return True return False reverseString = inputText ans = ispalindrome(reverseString) if ...
true
585d7387e564f739c8594576ac52a4f51d0466e2
olyatko/Stepic-Python
/working with files in Python.py
1,020
4.25
4
f = open('input.txt', 'r') f.readline() f.readlines() f.readlines()[2] # returns the third line of the file object f (don't forget that Python utilizes 0-based numbering!) for line in f: print(line) # Using this loop, you can do anything you need with every line in the file 'Simple is\nbetter than\ncomplex.\n'...
true
6ed4b33ea0845410fd9a6b6957a117dbf2cbc9f6
javiCuara/Google-Python-IT-automation
/Course-2/Regex/Search/RepetitionQualifiers.py
736
4.53125
5
#!/bin/env python3 import re ''' This functions checks if the text passed includes the letter 'a' upper or lower at least twice! ''' def repeating_letter_a(text): result = re.search(r"(.*[aA]){2}", text) return result != None ''' BREAKDOWN: () : make scope for matching any text that inxludes consecutive ...
true
00203d559ed09cf62df51cb684f5e80af456ed2b
ibrakadabra70/SudokuSolver
/main.py
2,971
4.34375
4
# Initialize puzzle puzzle = [ [5, 8, 6, 4, 0, 0, 0, 0, 3], [0, 0, 0, 0, 8, 0, 0, 0, 4], [0, 0, 0, 9, 0, 0, 0, 0, 7], [0, 0, 0, 0, 0, 0, 0, 4, 0], [0, 0, 0, 0, 0, 9, 7, 2, 0], [0, 4, 0, 0, 5, 0, 0, 0, 1], [7, 0, 0, 0, 0, 0, 0, 6, 0], [0, 5, 0, 0, 3, 2, 0, 0, 0], [2, 0, 0, 0, 6, 0, 0,...
true
daa488fc103a2b3ceb4ce6f020c8202df1abc9a4
Moira-Rinn/Bootcamp-Functions_Basic_2
/Functions_Basic_2.py
1,732
4.21875
4
# 1. Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). def countDown(num): lst = [num] for x in range(num): num -= 1 lst.append(num) return lst print(countDown(5...
true
6b27c70e4ea0538917032811f9a3a4411abcda15
touilleWoman/learn_python
/Boot_camp_Python/Day00/ex03/count.py
875
4.3125
4
import string import sys def count(str): upper = 0 space = 0 lower = 0 punc = 0 for x in str: if x.isupper(): upper += 1 elif x.islower(): lower += 1 elif x == ' ': space += 1 elif x in string.punctuation: punc += 1 ...
true
ab9ffdc872a0d237271c3088dabef1a77e9b2ddf
philomathtanya/Basic-Python-Program
/circle_in_out_on.py
386
4.3125
4
print("Enter the center points of circle:") x1=int(input()) y1=int(input()) radius=int(input("Enter the radius of circle")) print("Enter the co_ordinate of point:") x2=int(input()) y2=int(input()) dis=((x2-x1)**2+(y2-y1)**2)**0.5 if dis==radius: print("point is on the circle") elif dis<radius: print("point is i...
true
47d21df3bce23c51524b9bf9d0ee55003a285236
seanchoi/algorithms
/CyclicRotation/cyclicRotation.py
1,030
4.3125
4
""" An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is mov...
true
154b48a93203f7be84595a75afcad73913635ebd
PurnimaS18/Open-Source-Software-Lab-Assignments
/lab3/wrap.py
612
4.125
4
#Write a program wrap.py that takes filename and number of characters per line (width)as arguments. The program must wrap the lines of the file longer than entered width. import textwrap value = """This function wraps the input paragraph such that each line in the paragraph is at most width characters long. The ...
true
9dd6c22ac27aab1adc406bdf729c64fa4899c204
PurnimaS18/Open-Source-Software-Lab-Assignments
/lab4/q1.py
431
4.40625
4
# Using numpy, WAP that takes an input from the user in the form of a list and calculate the # frequency of occurrence of each character/integer in that list (count the number of # characters). import numpy as np print("Enter elements of the list: ") ls = np.array(input().split()) unique, frequency = np.uni...
true
4fc47ab1522a41d3f7c521aacddc5ead9b977e8f
nourafull/Classifiers
/Logistic Regression Classifier/Logistic Regression Classifier.py
2,270
4.1875
4
# coding: utf-8 # In[8]: """ This is an example of using Logistic Regression to build a binary classifier. First we created some smaple data using the gen_data function, and plotted the data. Then we use Scikit Learn to create the Logistic Regression model. Last, we generate points from [-5,-5] to [5,5] and plot th...
true
ee72ff1e9249d06df8b7f9c868f37881344a8f11
DanielaG0627/election-analysis
/Python_Practice.py
776
4.3125
4
## temperature = int(input("What is the temperature outside?")) ## if temperature > 80: ## print("Turn on the AC") ## else: ## print("Open the windows") #What is the score? #score = int(input("What is your test score? ")) # Determine the grade. #if score >= 90: # print('Your grade is an A.') #elif score >= ...
true
9cc878b222d42ef852c315bd80f172127a807c46
CrazyJ36/python
/str_rstrip.py
910
4.78125
5
#!/usr/bin/env python3 # clear space for program text, prints 1 new line. # print("\n") would be two lines(print function itself) print() # this shows how to use python3's string function # str.rstrip() # str.rstrip() only removes ending, or 'trailing' # whitespace(spaces). if str.rstrip('ing') has A parameter, # it...
true
b6122a138a5a682eaba19f44ca5c73e613a735f9
CrazyJ36/python
/slicing_range_lists_dict_tuple.py
792
4.5
4
#!/usr/bin/env python3 # reuse a list, 'sliced' as: [start:end] mlist = ["bill", "james", "becky", "chris", "thomas", "megan"] print("my list, defined like ['','','']:") print(mlist) print("[0:2] slicing from index 0 to 2, not including 2:") print(mlist[0:2]) # if start: or :end part is left out, start or end # of...
true
50b5fd78d080367798875f28541c59d9e8c25bcd
CrazyJ36/python
/dictionary_usage.py
1,614
4.5625
5
#!/usr/bin/env python3 # Dictionaries are data structures(blueprint for big data, definition template) # used to map key:value pairs. # As if lists were dictionaries with integer keys at range. # Dictionaries can be indexed in the same way as lists, using [] containing keys. # {key:value} can be: {"String":int} {"Stri...
true
1df8b0947fb80d4ed991a14af57dfff86e47d4ad
CrazyJ36/python
/str_check_fun.py
257
4.125
4
#!/usr/bin/env python3.7 instruct = "Enter x, y, or something else: " str1 = input(instruct) def checkStr(str1): if (str1 is 'x'): print("typed x") elif (str1 is 'y'): print("typed y") else: print("typed neither x or y") checkStr(str1)
true
b21cfbb5a3b29a08c3fb498fde1310bc4bdbf9cd
CrazyJ36/python
/operator_add_to_and_equal.py
347
4.34375
4
#!/usr/bin/env python3 # '+=' for variables, this operator adds a value to, # then sets variable name to new value. # this formula shortcut can be used with any # mathmatical operator. # string example y = 'one' y += 'two' # adding to and equaling print(y) # int example x = 1 # x has value of one x += 2 # same as x...
true
208b16bfbcb3aab6444143a07f1233c336ae5458
CrazyJ36/python
/string_string_and_int.py
401
4.21875
4
#!/usr/bin/env python3 # As printing A string and A number type like: # $ print("text" + 3) # errors as 'cannot concetanate str and int', # or simply 'cannot add words and numbers', # we should use the string funtion itself to make # the number type A string: print("text " + str(1)) print("text", str(1)) # you can use...
true
5c44834d92dc161c3e4c00a01895ff7edcdada1b
Sidarth-debug/Project-97
/guessingGame.py
428
4.15625
4
import random random_number = random.randint(1,9) chances = 0 while chances<5: guessed_number = int(input("Guess the number ")) if guessed_number<random_number: print("You have to guess higher.") elif guessed_number>random_number: print("You have to guess lower.") else : print(...
true
1c0afc4f0e52b07743bb2b0f147f1dbd4f40d95d
wenyuwong1/biosys-analytics
/assignments/09-bottles/bottles.py
2,001
4.125
4
#!/usr/bin/env python3 """ Author : wwong3 Date : 2019-MAR-14 Purpose: Bottles of beer song """ import argparse import sys # -------------------------------------------------- def get_args(): """get command-line arguments""" parser = argparse.ArgumentParser( description='Bottles of beer song', ...
true
51b4d23f292d895746ecf0df1bfbf647db24fce7
hkommineni/Week2
/vernam.py
1,741
4.1875
4
import itertools import binascii """This program is to encrypt the following text using a key 'ICE' Text to be encrypted: “We didn't start the fire, It was always burning, Since the world's been turning, We didn't start the fire, No we didn't light it, But we tried to fight it” Author : Harish Kommineni Date ...
true
ea608b1b96f783f7e0d1fceae6fc33816844c572
ry362/Light-py-Calculator
/Basic Calculatorv1.3.1.py
2,940
4.25
4
againBreak = "again" while againBreak in ("again", "go", "restart"): print('type m for multiplication, d for division with decimals, s for subtraction,') op = input(' a for addition, sq for squares or adv for advanced calculations:').lower() if (op == 'adv'): print('type ex for exponents, dr fo...
true
b87fba98f82dcaff702a96bddbaa8406dbbaf01f
krnets/codewars-practice
/7kyu/Unlimited Sum/index.py
603
4.125
4
# 7kyu - Unlimited Sum """ Write a function sum that accepts an unlimited number of integer arguments, and adds all of them together. The function should reject any arguments that are not integers, and sum the remaining integers. sum(1, 2, 3) ==> 6 sum(1, "2", 3) ==> 4 """ # from functools import reduce # de...
true
4cf9694b335e8c91a69030a767ec1e7bd2ce57b4
krnets/codewars-practice
/7kyu/Find the Middle of the Product/index.py
1,734
4.125
4
""" 7kyu - Find the Middle of the Product Given a string of characters, I want the function find_middle() to return the middle number in the product of each digit in the string. Example: 's7d8jd9' -> 7, 8, 9 -> 7*8*9=504, thus 0 should be returned as an integer. Not all strings will contain digits. In this case and...
true
9cbe1a029aaec85918da58c014f9c708def0ed1a
krnets/codewars-practice
/beta/Rotated string/index.py
622
4.21875
4
# Beta - Rotated string """ Write to function that takes as argument two strings and returns True if one string is a rotation of the other or else it returns False. # ohell is left rotation of hello is_rotation('hello','ohell') => True # elloh is right rotation of hello is_rotation('hello','elloh') => True """ # ...
true
d5f6af3d42ca576a4e5f2e526b0bbced41fc9542
krnets/codewars-practice
/7kyu/Even odd disparity/index.py
1,234
4.21875
4
# 7kyu - Even odd disparity """ Given an array, return the difference between the count of even numbers and the count of odd numbers. 0 will be considered an even number. For example: solve([0,1,2,3]) = 0 because there are two even numbers and two odd numbers. Even - Odd = 2 - 2 = 0. Let's now add two letters t...
true
adf45dcc21948ea7cecdb06054a7d7e2cd8079ea
krnets/codewars-practice
/7kyu/Number Pairs/index.py
743
4.1875
4
# 7kyu - Number Pairs """ In this Kata the aim is to compare each pair of integers from 2 arrays, and return a new array of large numbers. Both arrays have the same dimensions. arr1 = [13, 64, 15, 17, 88] arr2 = [23, 14, 53, 17, 80] get_larger_numbers(arr1, arr2) == [23, 64, 53, 17, 88] """ # def get_larger_numbers...
true
8289f966df7d5a2d916aec44cac1fc1e5d9650d3
krnets/codewars-practice
/6kyu/Who won the election/index.py
2,968
4.1875
4
""" 6kyu - Who won the election? In democracy we have a lot of elections. For example, we have to vote for a class representative in school, for a new parliament or a new government. Usually, we vote for a candidate, i.e. a set of eligible candidates is given. This is done by casting a ballot into a ballot-box. Aft...
true
48e866c896695a997f23f933878cb2d1066c3414
krnets/codewars-practice
/7kyu/Case-sensitive/index.py
605
4.28125
4
""" 7kyu - Case-sensitive! Given an input string s, case_sensitive(s), check whether all letters are lowercase or not. Return True/False and a list of all the entries that are not lowercase in order of their appearance in s. For example, case_sensitive('codewars') returns [True, []], but case_sensitive('codeWaRs') ...
true
a4d6f5ae71cbbfec83d565353d38bcff290bb0f5
krnets/codewars-practice
/6kyu/Multiplication Tables/index.py
848
4.46875
4
# 6kyu - Multiplication Tables """ Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT strings. multiplication_table(3,...
true
44658fbd5f3d8a6304dc5128be6f2aaf5749892b
krnets/codewars-practice
/7kyu/Caeser Encryption/index.py
1,028
4.21875
4
""" 7kyu - Caeser Encryption You have invented a time-machine which has taken you back to ancient Rome. Caeser is impressed with your programming skills and has appointed you to be the new information security officer. Caeser has ordered you to write a Caeser cipher to prevent Asterix and Obelix from reading his ema...
true
c0b732dad47f5666944d2a39b8a75f2c175369d2
krnets/codewars-practice
/8kyu/Return Negative/index.py
738
4.375
4
# 8kyu - Return Negative """ In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative? Example: make_negative(1); # return -1 make_negative(-5); # return -5 make_negative(0); # return 0 Notes: The number can be negative already, in which case no ...
true
571a41eba19311968a0574bb7c5de1e6a62256ff
krnets/codewars-practice
/6kyu/Checking Groups/index.py
1,338
4.5
4
# 6kyu - Checking Groups """ In English and programming, groups can be made using symbols such as () and {} that change meaning. However, these groups must be closed in the correct order to maintain correct syntax. Your job in this kata will be to make a program that checks a string for correct grouping. For instan...
true
ba2956f7a648d0109b14f4cbdfb5bf51e0cb1f72
krnets/codewars-practice
/7kyu/More than Zero/index.py
639
4.15625
4
# 7kyu - More than Zero? """ Correct this code so that it takes one argument, x, and returns "x is more than zero" if x is positive (and nonzero), and otherwise, returns "x is equal to or less than zero." In both cases, replace x with the actual value of x. """ def corrections(x): return '{} is {} than zero.'...
true
e4628d332005c833db13eb27240fc109c97959e7
krnets/codewars-practice
/7kyu/Decoding a message/index.py
911
4.125
4
""" 7kyu - Decoding a message You have managed to intercept an important message and you are trying to read it. You realise that the message has been encoded and can be decoded by switching each letter with a corresponding letter. You also notice that each letter is paired with the letter that it coincides with when t...
true
25e87fb068140dc7ad0daea8e424e89354a1c009
krnets/codewars-practice
/5kyu/flatten/index.py
2,518
4.34375
4
# 5kyu - flatten() """ For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as t...
true
1e1f92461c3dc6054e61ec451a079d5b68171f40
krnets/codewars-practice
/7kyu/The Coupon Code/index.py
1,870
4.1875
4
# 7kyu - The Coupon Code """ Your online store likes to give out coupons for special occasions. Some customers try to cheat the system by entering invalid codes or using expired coupons. Write a function called checkCoupon which verifies that a coupon code is valid and not expired. A coupon is no more valid on the ...
true
38170a2f5dbbdbf800ef13c1873e72f7f8b7f0e1
krnets/codewars-practice
/6kyu/From..To..Series 7 - from sentence to camelCase/index.py
2,127
4.46875
4
# 6kyu - From..To..Series #7: from sentence to camelCase. Can you convert it? """ Give you a sentence s. It contains some words and separated by spaces. Another arguments is n, its a number(1,2 or 3). You should convert s to camelCase n. There are three kinds of camelCase: camelCase 1: The first letter of each wor...
true
abcb9480fb05184ad358b9412d018719957bbd68
krnets/codewars-practice
/7kyu/Find missing numbers/index.py
811
4.25
4
# 7kyu - Find missing numbers """ You will get an array of numbers. Every preceding number is smaller than the one following it. Some numbers will be missing, for instance: [-3,-2,1,5] //missing numbers are: -1,0,2,3,4 Your task is to return an array of those missing numbers: [-1,0,2,3,4] """ # def find_missing...
true
b1b3d62e98ef55ebedce34aa79a392a89d3d00fd
krnets/codewars-practice
/7kyu/Monotone travel/index.py
1,475
4.4375
4
# 7kyu - Monotone travel """Peter lives on a hill, and he always moans about the way to his home. "It's always just up. I never get a rest". But you're pretty sure that at least at one point Peter's altitude doesn't rise, but fall. To get him, you use a nefarious plan: you attach an altimeter to his backpack and yo...
true
877b6b5d48013e930827eaf5c7c90adbf05bb679
krnets/codewars-practice
/7kyu/Capitals first/index.py
975
4.375
4
# 7kyu - Capitals first! """ Create a function that takes an input String and returns a String, where all the uppercase words of the input String are in front and all the lowercase words at the end. The order of the uppercase and lowercase words should be the order in which they occur. If a word starts with a numbe...
true
d1ad880eaf074d0fc0dd58ca68fb0730d283c6af
krnets/codewars-practice
/7kyu/Nth Smallest Element (Array Series 4)/kata.py
1,372
4.3125
4
# 7kyu - Nth Smallest Element (Array Series #4) """ Given an array/list [] of integers, find the Nth smallest element in this array of integers Array/list size is at least 3. Array/list's numbers could be a mixture of positives , negatives and zeros . Repetition in array/list's numbers could occur , so do...
true
25dd64714253171c490966cb3b4cc1b22f5adb90
krnets/codewars-practice
/7kyu/Xmas Tree/index.py
1,913
4.5625
5
# 7kyu - Xmas Tree """ Create a function xMasTree(height) that returns a christmas tree of the correct height. The height is passed through to the function and the function should return a list containing each line of the tree. xMasTree(5) should return : ['____#____', '___###___', '__#####__', '_#######_', '#######...
true
f1d913ba5850b53f4ed49a2e351d6690314520fb
krnets/codewars-practice
/6kyu/Count the divisible numbers/index.py
657
4.21875
4
# 6kyu - Count the divisible numbers """ Complete the function that takes 3 numbers x, y and k (where x ≤ y), and returns the number of integers within the range [x..y] (both ends included) that are divisible by k. More scientifically: { i : x ≤ i ≤ y, i mod k = 0 } Given x = 6, y = 11, k = 2 the function should re...
true
7db61cded7c68ac16a8353dd93a4f826e0c67431
krnets/codewars-practice
/8kyu/My head is at the wrong end/index.py
1,052
4.125
4
# 8kyu - My head is at the wrong end! """ You're at the zoo... all the meerkats look weird. Something has gone terribly wrong - someone has gone and switched their heads and tails around! Save the animals by switching them back. You will be given an array which will have three values (tail, body, head). It is your...
true
abd6a409bbdc6116735722c1db824a5c4a2e008f
krnets/codewars-practice
/beta/Generating Permutations/index.py
1,521
4.25
4
# Beta - Generating Permutations """ Write a generator function named permutations that returns all permutations of the supplied list. This function cannot modify the list that is passed in, or modify the lists that it returns inbetween iterations. In Python a generator function is a function that uses the yield key...
true
6c96b20244105171e0fd7c59b60ceb21316902d6
krnets/codewars-practice
/7kyu/Find Count of Most Frequent Item in an Array/index.py
816
4.34375
4
# 7kyu - Find Count of Most Frequent Item in an Array """ Complete the function to find the count of the most frequent item of an array. You can assume that input is an array of integers. For an empty array return 0 input array: [3, -1, -1, -1, 2, 3, -1, 3, -1, 2, 4, 9, 3] ouptut: 5 The most frequent number in the...
true
5294256eaaeb541bbd6a24f004aeb696352bc12f
krnets/codewars-practice
/6kyu/Alpha to Numeric and Numeric to Alpha/index.py
1,478
4.5625
5
# 6kyu - Alpha to Numeric and Numeric to Alpha """ In this Kata, you will create a function that converts a string with letters and numbers to the inverse of that string (with regards to Alpha and Numeric characters). So, e.g. the letter a will become 1 and number 1 will become a; z will become 26 and 26 will become...
true
5fcdcfb6efe9aff0b5bfb3a702891b3b45c86ae4
krnets/codewars-practice
/7kyu/Map function issue/index.py
2,226
4.3125
4
""" 7kyu - Map function issue In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and ass...
true
f66c2e0e5085d86a2c21f48b2400b927d7e91cfe
krnets/codewars-practice
/8kyu/To square(root) or not to square(root)/index.py
1,058
4.40625
4
# 8kyu - To square(root) or not to square(root) """ Write a method, that will get an integer array as parameter and will process every number from this array. Return a new array with processing every number of the input-array like this: If the number has an integer square root, take this, otherwise square the number....
true
c294c8d19ba783f2b701bb8cd332eed57142f7f8
krnets/codewars-practice
/7kyu/Make a function that does arithmetic/index.py
1,153
4.25
4
# 7kyu - Make a function that does arithmetic! """ Given two numbers and an arithmetic operator (the name of it, as a string), return the result of the two numbers having that operator used on them. a and b will both be positive integers, and a will always be the first number in the operation, and b always the sec...
true
568fcc260f37d42450285baf5d51590686db0a07
krnets/codewars-practice
/6kyu/Basic subclasses - Adam and Eve/index.py
1,244
4.5
4
# 6kyu - Basic subclasses - Adam and Eve """ According to the creation myths of the Abrahamic religions, Adam and Eve were the first Humans to wander the Earth. You have to do God's job. The creation method must return an array of length 2 containing objects (representing Adam and Eve). The first object in the arr...
true
e1432bb3227ebd706cc2ad4d10cfeadcf69af23f
krnets/codewars-practice
/6kyu/Run-length encoding/index.py
1,961
4.3125
4
""" 6kyu - Run-length encoding Run-length encoding (RLE) is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. Your task is to write such...
true
f3f6f706514a296937daa2f851529a3eb0fb7db3
krnets/codewars-practice
/6kyu/Parity bit - Error detecting code/index.py
1,983
4.15625
4
# 6kyu - Parity bit - Error detecting code """ In telecomunications we use information coding to detect and prevent errors while sending data. A parity bit is a bit added to a string of binary code that indicates whether the number of 1-bits in the string is even or odd. Parity bits are used as the simplest form of ...
true
9bf2d05411897f300dda8c9bddef7c1c89d4ad33
krnets/codewars-practice
/7kyu/Sum of Odd Cubed Numbers/index.py
504
4.53125
5
# 7kyu - Sum of Odd Cubed Numbers """ Find the sum of the odd numbers within an array, after cubing the initial integers. The function should return None if any of the values aren't numbers. Note: Booleans should not be considered as numbers. """ def cube_odd(arr): if all(type(x) == int for x in arr): ...
true
ce219cb0e2ca86803465c3079147cfd04176724e
krnets/codewars-practice
/7kyu/Maximum Multiple/index.py
1,239
4.1875
4
# 7kyu - Maximum Multiple """ Given a Divisor and a Bound , Find the largest integer N , Such That , N is divisible by divisor N is less than or equal to bound N is greater than 0. The parameters (divisor, bound) passed to the function are only positve values . It's guaranteed that a divisor is F...
true
05e757ed9e6616b5be4e38f4ea461d04af976ee1
krnets/codewars-practice
/6kyu/Split Strings/index.py
747
4.15625
4
# 6kyu - Split Strings """ Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). solution('abc') # should return ['ab', 'c_'] solution('abcdef')...
true
ce56dfc225804556d51ead6c73fb6218d779dbc3
kassarl/Random
/SleepHoursCalc.py
580
4.1875
4
#Sleep Calculator #This is super basic I did this in 3 minutes. import time import math start =int(input("Input your sleep time in HHMM format (military time):")) alarm =int(input("Input the time you want to wake up in HHMM format (military time): ")) timeAwake = start - alarm timeAsleep = 2400 - timeAwake print("Yo...
true
42915da848c862bc8759ffb01aba9eead58c8030
SHERMANOUKO/randompythoncodes
/generators.py
709
4.25
4
#function returning square of numbers in a list def squared(numbers): """without generators""" result = [] for number in numbers: result.append(number*number) return result def squared_with_generator(numbers): """with generators""" for number in numbers: yield number*number sq...
true
ee84800ea4848d62365f9fd1b4d120fb8d846c01
erestor/evade
/src/P_input_funcs_1.py
2,490
4.25
4
# all function asking user for input from keybord # The file is called by init_game and play_game from P_debug import DEBUG_MODE def ask_type_of_player(): #to choose a type of player, human or computer while True: player_type = input("Select a type of player: for Computer player press 'C', for Human p...
true
4ce55293f12c153ac99382a86c411e8626b3f1d4
sancheslz/basic_tdd
/lesson_29.py
835
4.375
4
"""LESSON 29 Goal: Create a function "bubble_sort" to order a list of values """ def bubble_sort(values_list, *, reverse=False): current = 0 final = [] for _ in range(len(values_list)): for item in values_list: if item > current: current = item final.insert(0, c...
true
98739db706a7fc40e169b4afb513cfb72cb58051
sancheslz/basic_tdd
/lesson_11.py
419
4.40625
4
"""LESSON 11 Goal: Discover if the value is positive or negative """ def is_positive(value: int) -> bool: if value < 0: return False return True if __name__ == "__main__": assert callable(is_positive), "Function not defined" assert is_positive(3), "Error with positive numbers" assert not...
true
e407b68d240aaa677a8b1bff134f4aa7b2ed94b7
sancheslz/basic_tdd
/lesson_26.py
410
4.21875
4
"""LESSON 26 Goal: Create a class that calc the simple interest """ class Financial: def simple(self, amount, tax, months): return amount * tax * months if __name__ == "__main__": assert callable(Financial), "Class <Financial> not defined" assert callable(Financial.simple), "Function <n_previou...
true
84f595a3bacd501f975fbb2d297a2fa53a580179
golfoclock/encryptPractice
/encrypt.py
688
4.21875
4
result = '' message = '' choice = '' while choice != 0: choice = input("\nWould you like to encrypt or decrypt the message?\nEnter 1 to encrypt, or 2 to decrypt. Enter 0 to exit program.") if choice == '1': message = input("\nEnter message for encryption: ") for i in range(0, len(message)): result = result +...
true
a1d0a8fcde7e8bb118595c22475a10943659b465
tmh327/learning_python
/w1/Chapter3.py
1,934
4.15625
4
#!/usr/bin/python3 '''exercise 3''' def right_justify(s): print(' '*(70-len(s)),s,sep='') return right_justify('allen') ''' 1. Type this example into a script and test it. 2. Modify do_twice so that it takes two arguments, a function object and a value, and calls the function twice, passing the value as an a...
true
455570d9dd71d9f7880a576dd14ed22d95a0e263
tmh327/learning_python
/w4/Ch8e6.py
258
4.125
4
#!/usr/bin/env python3 def count(string,letter,start): c = 0 while start < len(string): if string[start] == letter: c += 1 else: c = c start += 1 return print(c) count('hubbub','b',3)
true
f57bc197acec5ba806482aa220388e0fe70546e2
A8IK/Python-2
/abstract class.py
902
4.34375
4
##ABC = Abstract Base Class from abc import ABC, abstractmethod class Computer(ABC): @abstractmethod def process(self): pass #class Laptop(Computer): ##It's got an error because Laptop class is sub class of Computer class and Computer class is in @abstractmethod #pass class Lapto...
true
4088088c319e0222729948924d63a030e66c8292
chrislane134/PythonTasks
/stringmethods.py
534
4.34375
4
course = "Python for Beginners" print(len(course)) # counts number of characters. General purpose function. print(course.upper()) # makes all characters uppercase print(course.lower()) # makes all characters lowercase # will return the index of that character. Case sensitive. can parse sequence of characters eg:'for...
true
38d0cdf58d4be3e23f1a2a4ee9f7f3abcb96580a
TreyHusko/LeapYear
/ErrorLeapYear.py
884
4.15625
4
# series of if/else statements to determine if input year is leap year def isLeapYear(year): if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print(str(year) + " is a leap year") else: print (str(year) + " is not a leap year") ...
true
39830461d7bdaca42a3586da5b1ab7bf220fedf5
jyeoniii/algorithm
/20201130/implement_trie.py
1,897
4.15625
4
# https://leetcode.com/problems/implement-trie-prefix-tree/ class Node: def __init__(self, value: str): self.value = value self.left = None self.right = None class Trie: def __init__(self): self.root = None def insert(self, word: str) -> None: """ Inserts...
true
022c717715d8f92f32a50dba39898d3d61d7c9fc
anipshah/geeksforgeeks_problems
/RouteBetweenNodes.py
1,019
4.40625
4
# Find if there is a path between two vertices in a directed graph def is_route(graph,start,end): """ Find if there is a path between two vertices in a directed graph using bfs :param graph: graph :param start: start point :param end: end point :return: if there is a route between two points th...
true
16ae518d0783008f3b31e6f2954633d77957d4bb
anjanpandey/python_work
/loop_list/pizzas.py
2,090
4.59375
5
pizzas = ['Chicken Ranchero', 'Chicken Pineapple', 'Italian Bread'] print(pizzas[1:3]) #prints the elements from index 1 and 2, 3 is not included for pizza in pizzas: print("I like "+pizza+" pizza.\n") print("I like pizza. The combination of bread, meat, and vegetable is just amazing.") animals = ['Dog', 'Cat',...
true
33739c6a18423433327a6cfa8bdb7b26c23b8233
haiderijlal/DataStructure-Algorithms
/dataStructure-Python/queueOnList.py
1,169
4.5
4
''' This is implementation of Queue using a python list. For dequeue and enqueue operations of Queue, python list methods is used. Idea of this implementation is to show the basic functionality of Queue with fewer lines of code''' ''' Test cases are given below to give a better insight of the code.''' class Queue: ...
true
217e51f73489f43bf7f838b1ef1a783a54c5c41c
Svens1234/lambda
/main.py
1,689
4.21875
4
#Map, filter and lambda expressions #map #def sum_of_two_numbers(x): #return x+x #number_list = [1, 2, 3, 4, 5, 6, 7] #result = map(sum_of_two_numbers, number_list) #print(result) #for item in result: #print(item) #for item in map(sum_of_two_numbers, number_list): #print(item) #print(list(map(sum_of_t...
true
fd8d0702f375f818ddbf2239711b232529c527a4
Nnigmat/Homeworks
/Assignment1/task3.py
1,033
4.375
4
import random def randomize_in_place(arr): """ 'randomize_in_place' method randomly swaps the element of income array It use numpy library for generation random integer :param arr: :return: """ # Goes for each element in array for i in range(len(arr)): # Gets random integer i...
true
b64e8da8bd7837a4a1452a12eadc1bbfe240e741
cornell-cup/cs-reminibot
/basestation/util/helper_functions.py
1,983
4.1875
4
import math def distance(x1, y1, x2, y2): return math.sqrt((x2-x1)**2 + (y2-y1)**2) # Python3 program to implement # the above approach # Utility function to find cross product # of two vectors def CrossProduct(A): # Stores coefficient of X # direction of vector A[1]A[0] X1 = (A[1][0] - A[0][0...
true
4731f71111fc0b989e0d200ca511465294c33532
sankeerth/Algorithms
/Array/python/leetcode/set_matrix_zeros.py
1,842
4.375
4
""" 73. Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0], [...
true
ccced91d307a6a4b2bd56b8a130f841c4849803d
sankeerth/Algorithms
/Array/python/leetcode/find_first_and_last_position_of_element_in_sorted_array.py
2,204
4.15625
4
""" 34. Find First and Last Position of Element in Sorted Array Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. Example 1...
true
eff816f0a67205cf7cea884498cded8feca2d25a
sankeerth/Algorithms
/Math/python/leetcode/robot_bounded_in_circle.py
2,238
4.28125
4
""" 1041. Robot Bounded In Circle On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 degrees to the right. The robot performs the instructions given in order, and repeats the...
true
d962c612c9166e6703831b8923a1ddfe10eabdc5
sankeerth/Algorithms
/Graph/python/leetcode/pacific_atlantic_water_flow.py
2,787
4.28125
4
""" Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges. Water can only flow in four directions (up, down, left, or right) from a cell to a...
true
c5758958f7d2388e9311ea8ef651f5942da92836
sankeerth/Algorithms
/String/python/leetcode/partition_labels.py
2,679
4.125
4
""" 763. Partition Labels A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts. Example 1: Input: S = "ababcbacadefegdehijhklij" Output: [9,7,8] Exp...
true
8ba9dda971381f59f4eb905d89e124397de89131
sankeerth/Algorithms
/DynamicProgramming/python/leetcode/number_of_longest_increasing_subsequence.py
2,160
4.125
4
""" 673. Number of Longest Increasing Subsequence Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, ...
true
dd22165aca136bc981605cb9866348d323b878f0
sankeerth/Algorithms
/DynamicProgramming/python/leetcode/edit_distance.py
2,474
4.125
4
""" 72. Edit Distance Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: h...
true
aaa552cc2cd9e1065d367c90b12cdecf5fbf249d
pratikmehkarkar/Hackerrank_Practices-
/30 Days of Code/day7.py
687
4.15625
4
# Day-7 (Pratik Mehkarkar) # Objective # Today, we will learn about the Array data structure. Check out the Tutorial tab for learning materials and an instructional video. # Task # Given an array,A , of N integers, print A's elements in reverse order as a single line of space-separated numbers. # Example # A = [1,2,3,4...
true
392be13bffc2697d05ba04398a10fa5fb4c986c4
SaranTrKS/DS_Algo_Scaler_Academy
/Arrays/leadersInAnArray.py
1,482
4.28125
4
''' Leaders in an array Problem Description Given an integer array A containing N distinct integers, you have to find all the leaders in the array A. An element is leader if it is strictly greater than all the elements to its right side. NOTE:The rightmost element is always a leader. Problem Constraints 1 <= N <...
true
405c612357839e74317c8dfb54c791d1dd004d43
Daemo00/MyFirstPythonRepository
/exercises/practice-python/02.py
872
4.375
4
"""Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? Extras: If the number is a multiple of 4, print out a different message. Ask the user for two numbers: one number to chec...
true
6fb2c5806aae94b559fe2e70ceaec1b43de359fb
emiliog-c/me
/week3/exercise3.py
2,175
4.40625
4
"""Week 3, Exercise 3. Steps on the way to making your own guessing game. """ import random def advancedGuessingGame(): """Play a guessing game with a user. The exercise here is to rewrite the exampleGuessingGame() function from exercise 3, but to allow for: * a lower bound to be entered, e.g. gues...
true
fe69d16955a92454693411e0eb397672fa72bef4
faykris/holbertonschool-higher_level_programming
/0x0A-python-inheritance/3-is_kind_of_class.py
537
4.125
4
#!/usr/bin/python3 """ 3. Same class or inherit from Write a function that returns True if the object is an instance of, or if the object is an instance of a class that inherited from, the specified class ; otherwise False. """ def is_kind_of_class(obj, a_class): """is_kind_of_class function Args:...
true
677761a5e88b81e16f141523f706887e95c76ad1
faykris/holbertonschool-higher_level_programming
/0x08-python-more_classes/7-rectangle.py
2,597
4.46875
4
#!/usr/bin/python3 """7. Change representation classes of module: Rectangle: print a rectangle """ class Rectangle: """Class Rectangle objects of this class who print a rectangle """ number_of_instances = 0 print_symbol = "#" def __init__(self, width=0, height=0): """I...
true
50016d759e30eb18a09b4c56d71357a58059ed7b
alieldinramadan/lab-code-simplicity-efficiency
/your-code/challenge-1.py
786
4.125
4
def plus(x, y): print(f"Your answer is: {x+y}") def minus(x, y): print(f"Your answer is: {x-y}") print('Welcome to this calculator!') print('It can add and subtract whole numbers from zero to five') a = input('Please choose your first number (zero to five): ') b = input('What do you want to do? plus or minus: ...
true
fbcd9aafa83bfeb0f5a69714c85d319bf97f0c48
rlsharpton/crash
/word_counter.py
1,609
4.40625
4
def count_words(filename): """Count the approximate number of words in a file.""" try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError: msg = "Sorry, the file " + filename + " was not found." print(msg) else: # Count approximate ...
true
6d32629c2cdf8d4b98b65507a5484c16e4fc1367
hrmendez/Python-Challenge
/PyBank/main.py
2,210
4.375
4
import os import csv # In this challenge, you are tasked with creating a Python script for analyzing the financial records of your company. # You will give a set of financial data called budget_data.csv # The dataset is composed of two columns: `Date` and `Profit/Losses` # The total number of months included in the dat...
true
2b337e907e7eaca1e01d2739070bf4c5fef0c999
sankethalake/django_practice
/learnPython/day7/0_.py
702
4.15625
4
# what will be output: method1 class Test: def __init__(self): print("this is init method1") def _init_(self): print("this is init method2") def init(self): print("this is init method3") t1 = Test() # ####################################################### #...
true
c69fd5e5d2c0bec5a01729aab7ab6e8f24ffb1fa
sankethalake/django_practice
/learnPython/day6/0_set.py
2,455
4.375
4
# sets : # contain unique values # sets don't have indexing i.e unordered # mutable setEmpty = set() print(setEmpty) print(type(setEmpty)) setEmpty.add(1) print(setEmpty) print(type(setEmpty)) set1 = {} # this gives type as dict and not set print(set1) print(type(set1)) set2 = {1, 2, 3, 4...
true
3181ae2bba4e4b421ee8d2cc5334dee5f500d7b1
Oprea00/LFTC-2020
/Lab2 - Symbol Table/tables/HashTable.py
1,888
4.25
4
class HashTable: """ A hash table is used to store data in Symbol/Constants table """ def __init__(self): self.__content = {} def add(self, value): """ Adds a new identifier/constant into the hash table. :param value: string :return: """ # Ha...
true
31ee1ba7566b80cc1d3c2876c3a34f0b363a01c3
meghanamurthysn/D08
/mimsmind0.py
1,583
4.25
4
#!/usr/bin/env python3 ############################################################################################################################## # Imports import random import sys # Body # Generate a random integer of the specified length or default = 1 def get_randint(length): n = random.randint(10**(length - ...
true