blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
35bb652c0f240421bfa70a6199e254096aebbefa
robgoyal/CodingChallenges
/Exercism/python/reverse-string/reverse_string.py
236
4.375
4
def reverse(text): """ str -> str Reverse a string. Examples: >>> reverse("") "" >>> reverse("hello") "olleh" >>> reverse("What's your name?") "?eman ruoy s'tahW" """ return text[::-1]
true
9663daead070165822cbb191d30fbd4eaa73be25
robgoyal/CodingChallenges
/CodeFights/Arcade/Intro/darkWilderness/knapsackLight.py
574
4.125
4
# Name: knapsackLight.py # Author: Robin Goyal # Last-Modified: July 21, 2017 # Purpose: Check the total weight your knapsack can hold from # the weight of two different items # Note: Forced solution def knapsackLight(value1, weight1, value2, weight2, maxW): if (weight1 + weight2) <= maxW: retur...
true
0cef65ad00a794aee620f23d9c13faaf878bb46c
robgoyal/CodingChallenges
/FireCode/Level_1/missingNumberFrom1To10.py
474
4.375
4
# Name: missingNumberFrom1To10.py # Author: Robin Goyal # Last-Modified: August 7, 2017 # Purpose: Find the number missing in the order of 1 to 10 # Note: Found other solutions where the sum of 1 to 10 minus the sum of the list # returned the missing number def find_missing_number(list_numbers): # Check if ...
true
8e40c15622ed0abbf7e635e3941f2d05b93dec83
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/11-to-20/betweenTwoSets.py
1,186
4.15625
4
# Name: betweenTwoSets.py # Author: Robin Goyal # Last-Modified: November 12, 2017 # Purpose: Count the number of times a value is a multiple of all elements # in list A and a factor of all elements in list B def main(): n, m = list(map(int, input().strip().split(' '))) a = list(map(int, input().str...
true
14977d9de6c198fd7492ed70decde4d6c4f9144c
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/21-to-30/electronicsShop.py
1,516
4.21875
4
# Name: electronicsShop.py # Author: Robin Goyal # Last-Modified: November 21, 2017 # Purpose: Calculate the amount of money spent at an electronics shop def getMoneySpent(keyboards, drives, s): ''' The maximum amount of money that can be spent on a single keyboard and drive without exceeding her budget ...
true
0d8df21193abb042e99156135f5896754e8c4f86
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/41-to-50/flatlandSpaceStations.py
1,027
4.4375
4
# Name: flatlandSpaceStations.py # Author: Robin Goyal # Last-Modified: January 31, 2018 # Purpose: Determine the maximum distance an astronaut will # have to travel to a space station def flatlandSpaceStations(n, c): ''' (int, list: int) -> int n is the number of cities and c is the indices at ...
true
c9a8f2a748fa632dc1a2a1feeb275b1968f5e3c5
robgoyal/CodingChallenges
/CodeWars/8/multiply.py
326
4.3125
4
# Name: multiply.py # Author: Robin Goyal # Last-Modified: March 3, 2018 # Purpose: Implement multiply def multiply(a, b): """ (int, int) -> int Return the multiplication of a and b Examples: >>> multiply(2, 5) 10 >>> multiply(-1, 3) -3 >>> multiply(-3, -4) 12 """ re...
false
51cae524f60d055e449dca4873941206325d4d5d
robgoyal/CodingChallenges
/CodeWars/7/numberPeopleInBus.py
557
4.40625
4
# Name: numberPeopleInBus.py # Author: Robin Goyal # Last-Modified: June 7, 2018 # Purpose: Calculate the remaining number of people # on the bus after the last stop def number(bus_stops): """bus_stops Return the remaining number of people on the bus after the last stop. Examples: >>> n...
true
1e189ea6efb35bf1d8f0ab74b3f558a83fc5ab98
robgoyal/CodingChallenges
/CodeFights/Arcade/Intro/throughTheFog/circleOfNumbers.py
269
4.25
4
# Name: circleOfNumbers.py # Author: Robin Goyal # Last-Modified: July 13, 2017 # Purpose: Given a circular radius n and an input number, # find the number which is opposite the input number def circleOfNumbers(n, firstNumber): return (firstNumber + n / 2) % n
true
806b3371f326efcbfa503d157529e9431dadef74
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/41-to-50/sherlocksAndSquares.py
775
4.375
4
# Name: sherlocksAndSquares.py # Author: Robin Goyal # Last-Modified: December 14, 2017 # Purpose: Calculate the number of squares in between a range import math def sherlocksAndSquares(A, B): ''' A -> int: start of range B -> int: end of range return -> int: number of squares in between [A, B] ...
true
722582520522b4fa825ad4ecb6b21c860aa2f7f3
robgoyal/CodingChallenges
/CodeWars/6/sortTheOdd.py
663
4.4375
4
# Name: sortTheOdd.py # Author: Robin Goyal # Last-Modified: March 17, 2018 # Purpose: Implement solution to Sort the Odd def sort_array(arr): """ (list: int) -> list: int Return an array of the odd numbers in sorted order while the even numbers remain in place. Examples: >>> sort_array([5, ...
true
d25f598c24122cf9cf1544bfc27c383d8dfe4aba
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/41-to-50/encryption.py
1,234
4.40625
4
# Name: encryption.py # Author: Robin Goyal # Last-Modified: February 16, 2018 # Purpose: Encrypt a string import math def encryption(s): """ (str) -> str Return a string by encrypting a string s using the following encryption scheme. Split s into rows (floor(sqrt(s)) and cols (ceil(sqrt(s))). ...
true
81b86a6268ff3d043cfe3fe95bbbbe419c1b6307
robgoyal/CodingChallenges
/CodeWars/7/sumNNumbers.py
422
4.375
4
# Name: sumNNumbers.py # Author: Robin Goyal # Last-Modified: March 13, 2018 # Purpose: Return the sum of the first n numbers def f(n): """ (int) -> int or None Return None if n is a positive integer, else return the sum of the first n numbers. Examples: >>> f(100) 5050 >>> f(-5) ...
true
dcf235636f58ccff76d4f24b22417e6d9a796e2c
robgoyal/CodingChallenges
/Exercism/python/bob/bob.py
775
4.125
4
def hey(phrase): """ str -> str Return responses depending on what is said to Bob. >>> hey("Tom-ay-to, tom-aaaah-to.") "Whatever." >>> hey("WATCH OUT!") "Whoa, chill out!" >>> hey("You are, what, like 15?") "Sure." >>> hey("WHAT THE HELL WERE YOU THINKING?") "Calm down, I k...
false
d4ce245927f33fc5f58140997a35c756a86d0800
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/11-to-20/catsAndMouse.py
858
4.15625
4
# Name: catsAndMouse.py # Author: Robin Goyal # Last-Modified: November 17, 2017 # Purpose: Determine which cat will reach the mouse first def catAndMouse(a, b, c): ''' a: position of cat A b: position of cat B c: position of mouse C result: "Cat A" if cat A reaches mouse first "Cat B...
true
7d4b342b0188b0d97bfeb8510edf6c63afd96a23
CPrimbee/scripts_python
/scriptBasico.py
1,461
4.125
4
#!/usr/bin/python #coding: utf-8 print "O cabeçalho em script é: #!/usr/bin/env python ou #!/usr/bin/python" print "Para não aparecer o erro (SyntaxErro: Non-ASCII character), use essa linha logo abaixo do cabeçalho: #coding :utf-8" print "Os comentários começam com: #" print "Para imprimir na tela, ex.: print Olá...
false
606e46df077d834a86a684b4bb6bc0bf9542cdac
kranz912/Algorithms
/Problems/5-CheckPangram.py
606
4.3125
4
''' Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet. Examples : "The quick brown fox jumps over the lazy dog" is a Pangram [Contains all the characters from 'a' to 'z'] "The quick brown fox jumps over the dog" is not a Pangram [Doesn't contains all...
true
527ffee1162fb0545368a799e3763483ccb6d093
krsnvijay/prime
/prime_consecutive_check.py
2,155
4.25
4
import sys from functools import cache import primesieve @cache def sum_digits(number): """ Sums all the digits of a number recursively to a single digit number eg: 192 = 1 + 9 + 2 = 12 => 12 = 1 + 2 = 3 so 192 will turn to 3 """ result = sum(int(digit) for digit in str(number)) #...
true
379af50325a45d8a599fd3d89f6a9268f02fcd95
dhillonfarms/core-python-scripts
/NumericalProjects/fibonacci.py
1,764
4.15625
4
""" Discussing various approaches for generating fibonacci sequences Using Python timeit module to find most efficient approach """ __author__ = 'https://github.com/dhillonfarms' import timeit # Using classic loop approach to get fibonacci series def get_fibonacci_classic(num): a = 1 b = 1 output = [] ...
true
d51c5108c8a63b7220134bdd5889bc1d0ec1576b
gokerguner/Playground
/Python/goker_miletos/pythons/isprime.py
657
4.125
4
#Goker Guner import math num=int(input("Bir sayi girin:")) def isprime(num): count=0 if num<0: print("{} sayısı negatiftir".format(num)) return 0 elif num == 1: print("1 sayısı asal veya değildir denemez.") return 0 for i in range(2,math.floor(math.sqrt(num))+1): ...
false
d942c3cd31a0c0f76a79f437cca969e85ec8d5d5
tianxingqian/study-py
/knowlage/004_functional_programming/001_Higher-order function/001_map_reduce.py
865
4.4375
4
# map/reduce ''' Python内建了map()和reduce()函数。 我们先看map。map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回。 举例说明,比如我们有一个函数f(x)=x2,要把这个函数作用在一个list [1, 2, 3, 4, 5, 6, 7, 8, 9]上,就可以用map()实现如下: ''' def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) print(list(r)) ''' map()传入的第一个参数是f,...
false
9001e276ee0c12d82c392afaea05438824a6b6de
onahirniak/algorithms
/app/main/lists/linked_list.py
2,335
4.15625
4
from app.main.base.node import Node class LinkedListNode(Node): def __init__(self, val): Node.__init__(self, val) self.next = None class LinkedList: def __init__(self): self.root = None def push(self, val): node = LinkedListNode(val) node.next = self...
true
4066bbd2c27a2c2b5fa65d35e55e6eb6104e8279
modcomlearning/pythonOnline
/Lesson4.py
637
4.65625
5
# Today , we do while loop # While Loop repeats a task n-times # With while a loop you can do an infinite loop(loops forever) # There are three steps you need to do: # 1. Create a variable to start your loop i.e x = 0 # 2. Set a condition, loop will run only if this condition is true # The loop will not run if ...
true
c825f98e03cecae1489ff35b61f8f868677efca5
jorjilour/python_files
/queues.py
2,395
4.5
4
from queue import Queue import sys # Initializing a queue q = Queue(maxsize=3) # qsize() give the maxsize # of the Queue print(q.qsize()) # Adding of element to queue q.put('a') q.put('b') q.put('c') # Return Boolean for Full # Queue print("\nFull: ", q.full()) # Removing element from queue ...
true
e69fc704dceb397e33194a91bf85b96f2607913a
idaks/explanation-visualization
/prime-or-composite/prime-or-composite.py
2,120
4.28125
4
#!/usr/bin/env python3 import sys print("### Running", *sys.argv, "###") # a bit of logging N = int(sys.argv[1]) # number N > 2 to test assert N > 2 d = 2 # trial divisor d = 2,3, ... c = 0 # count 'composite...
true
4f8bebc809322aa2d144bcc9b1837934939076ce
SunnyVikasMalviya/Python
/Sockets/Sockets_Intro.py
2,321
4.34375
4
import socket #Sockets aid in communication between 2 entities #For example, a client and a server are 2 entities and the client requests a \ #url. Servers have their ports open that they use to serve different kinds of \ #requests. So the client generates a socket that plugs into the port of the \ #server and h...
true
347c04e45398da2ca4ea23a7ce9e544afa970696
SunnyVikasMalviya/Python
/HackerRank-Solutions/Count-SubString.py
453
4.40625
4
def count_substring(string, sub_string): ''' Function to count number of times a substring occurs in a string. ''' n = len(string)-len(sub_string)+1 cnt = 0 for _ in range(n): if string[_:_+len(sub_string)] == sub_string: cnt = cnt+1 return cnt if __name__ == '__main__':...
true
b873309e52739c7f8f3b79c73d6dd3ebf2d0259a
SunnyVikasMalviya/Python
/Intermediate Python/Generators.py
2,416
4.25
4
''' Generators ''' #Generators don't return things, they yield it. #We will create our own simple generator def gen_func(): """ Simple example of our own generator. """ yield 'Corona Corona' yield 'Corona Corona' yield 'Corona Corona' yield 'Me hun ek Corona' def normal_func...
true
9c42e5d7f60f1e531877044fc08f7344a06b766e
SunnyVikasMalviya/Python
/Prime_In_List.py
510
4.15625
4
from Prime_Check import is_prime def prime_in_list(list_): """ The prime_in_list function takes a list argument, iterates through all the elements in the list, and returns a list of all the prime numbers in the list. """ lst = [] for x in list_: if is_prime(x): ...
true
807628db2cf3320fb368c29a8297cd4bd81012e0
SunnyVikasMalviya/Python
/Mersenne_Prime.py
710
4.375
4
from Prime_Check import is_prime def Mersenne_prime(n): """ In mathematics, a Mersenne Prime is a prime number that is one less than a power of 2 i.e. M(n) = 2^n - 1 should be prime for some n. The Mersenne_prime function takes a integer argument which is n in M(n) and returns a list of Mer...
true
d66f9d41acb3608bfe1ab2735c1649254bbc33e5
SunnyVikasMalviya/Python
/Intermediate Python/Multiprocessing.py
2,138
4.375
4
import multiprocessing """ CPUs have different number of processors i.e.the number of cores in your CPU. All the programs not using multiprocessing will be allocated only a single core to work with. So at a time you will only be using a fraction of what your whole CPU is capable of. Say, you have a quad core proce...
true
623e6e566cdc9fb40d5e6da93b1600cf2d9bb366
SunnyVikasMalviya/Python
/Radius_From_Chord_Parts.py
1,059
4.15625
4
""" Program for finding chord lengths or radius when two intersecting chords are given with their lengths. formula : 4r^2 = x^2 + y^2 + z^2 + w^2 where r = radius x = 1st part of chord one y = 2nd part of chord one z = 1st part of chord two w = 2nd part of chord two """ def finding_fourth_part(x, y, z): ...
false
493334dae982fa4307c233234bc1ad00e9b3d5a4
Muzashii/Exercicios_curso_python
/exercicios seção 6/ex 16.py
270
4.1875
4
""" numeros naturais ate o numeor escolhido decrecente par """ numero = int(input(f'Digite um numero: ')) if(numero%2) == 0: numero -= 1 for num in range(numero, -1, -2): print(num) else: for num in range(numero, -1, -2): print(num)
false
773f7f6dafb220d32fb023cae1363e1eba50b742
jeetpatel242/turtlebot3_astar
/scripts/utils.py
1,964
4.15625
4
#!/usr/bin/env python3 import numpy as np import math # Function to check if the given point lies outside the final map or in the obstacle space def check_node(node, clearance): # Checking if point inside map offset = 5.1 if node[0] + clearance >= 10.1 - offset or node[0] - clearance <= 0.1 - offset or n...
true
3a7778a7a96577c76dde47bed0dc1c41bc649d4f
sarahdactyl71/lpthr
/exercises/ex33.py
402
4.28125
4
def while_loop(times, increment): i = 0 numbers = [] while i < times: print(f"At the top i is {i}") numbers.append(i) i += increment print("Numbers now: ", numbers) print(f"At the bottom i is {i}") print("The numbers: ") for num in numbers: print...
true
91178a5ee27fa127d03c2b8f6db73673f6735c37
ancylq/leetcode
/detect_capital.py
840
4.46875
4
# coding:utf-8 ''' Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". ...
true
cf7d3496fa7bd37aecdd0268bfd6628f5e5f7034
florin-postelnicu/PythonFlorin01
/IfElseElif/Multiplication4.py
1,244
4.21875
4
import random yesno = True correct = 0 incorrect = 0 while(yesno): print(" This program helps you to learn the multiplication table!") a = random.randint(1, 10) b = random.randint(1, 10) print("Find the product of the numbers :", a , " * ", b) product = a*b print("Please Enter you...
true
1915944dbe1b4a252697b765a26087e65c8102b9
michaelbenninghoven-sparks/PythonPrograms
/3a) Map+ReverseMap.py
1,264
4.4375
4
import time #Asking for first name name1=input("Enter a name.\n") name1=name1.rstrip() #Asking for first number number1=input("Enter their phone number.\n") number1=number1.rstrip() #Asking for second name name2=input("Enter a name.\n") name2=name2.rstrip() #Asking for second number number2=input("Ente...
true
ee0a8c14349e16c6ed4f4dd3cc710c53f009eb29
SACHSTech/ics2o1-livehack2-practice-StephanieHCTam
/problem2.py
720
4.21875
4
""" ------------------------------------------------------------------------------- Name: problem2.py Purpose: This program determines if a triangle is a right angle triangle. Author: Tam.S Created: 12/02/2021 ------------------------------------------------------------------------------ """ print(" ****** S...
true
7331f3222ce90576e93745e90e3755b82d095266
tjhobbs1/python
/Module7/fun_with_lists/search_sort_list.py
1,300
4.625
5
""" Program: search_sort_list.py Author: Ty Hobbs Last Day Modified: 10/08/2019 The purpose of the program is to create a list of numbers and return it to the user. It will be used for testing Basic List Exceptions """ def make_list(): # This function will run a for loop calling the get_input function to get t...
true
67a015f1f98a9724eec728c7cfe5442bc3bda742
tjhobbs1/python
/Module11/override_test.py
1,095
4.125
4
class Shape: """Shape class""" colors = ['BLUE', 'GREEN', 'ORANGE', 'PURPLE', 'RED', 'YELLOW'] def __init__(self, color='BLUE'): self._color = color def change_color(self, new_color): if new_color not in self.colors: raise InvalidColorError self._color = new_color ...
true
5d46e5cd5da5caa8cad966d40f214d32cc537e0f
tjhobbs1/python
/Module6/payroll_calc.py
1,769
4.40625
4
""" Program: payroll_calc.py Author: Ty Hobbs Last date modified: 09/30/2019 The purpose of this program is to take an employees name, the number of hours they work and their rate of pay. It will then return the total amount of pay that employee will receive. """ def hourly_employee_input(): # This function wil...
true
cdbb311a8c65ef52b6a37a35e182b636a7ba3c43
nitin2149kumar/INFYTQ-Modules
/Data Structure/Day-4/Ex_11.py
1,384
4.25
4
#DSA-Exercise-11 import random def find_it(num,element_list): #Remove pass and write the logic to search num in element_list using linear search algorithm #Return the total number of guesses made guesses=0 for i in element_list: guesses+=1 print(guesses) if num==i: ...
true
65b1767df2e775cdf12f28362e0a552647793684
nitin2149kumar/INFYTQ-Modules
/Data Structure/Day-5/Ex_19.py
902
4.125
4
#DSA-Exer-19 def swap(num_list, first_index, second_index): #Remove pass and copy the code written earlier for this function num_list[first_index],num_list[second_index]=num_list[second_index],num_list[first_index] def find_next_min(num_list,start_index): #Remove pass and copy the code written earlier fo...
true
5d57618679bb7c706274e5b5fe0f24f7b8b8a489
ekarademir/algorithms_cormen_book
/ch2/insertion_sort.py
473
4.125
4
#!/usr/bin/python3 # -*- coding: utf8 -*- from pprint import pprint import random def insertion_sort(arr): for i in range(1, len(arr)): pivot = arr[i] j = i - 1 while j > -1 and arr[j] > pivot: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = pivot return arr ...
false
e1aa509aec8569119b0eb5d467b4598677959751
bagreve/MCOC-Proyecto-0
/loss-of-significance.py
2,429
4.25
4
# -*- coding: utf-8 -*- """ @author: """ # una perdida de significancia ocurre con el cambio de numeros flotantes a binarios debido a que tienen un sesgo de # aproximacion al tener que sumar 127 al sector de exponentes no siendo exacto. # un caso donde se puede ver es en la funcion de aproximacion, si se aproxima a ...
false
49dd1f1a4ac77bb1c3a8c6c0d3e9500514fd2cca
rchicoli/ispycode-python
/Data-Types/Numbers/Booleans.py
383
4.15625
4
# True behaves like 1 print( int(True) ) # False behaves like 0 print( int(False) ) # non zero numbers evaluates to True print( bool(99) ) # 0 evaluates to False print( bool(0) ) # boolean expressions using the logical operators print "not True :" , not True print "not False :" , not False print "True and False :...
true
c0805de1cd404c8258fb5e91a7408de33db58f81
Carter0/learningPython
/vector.py
1,150
4.375
4
#!/usr/local/bin/python3 from math import hypot # Also another example from the book. This time about vectors. class Vector: # What is interesting to note here is that... # We have created 6 special methods and most are not called by the user. Most are called by the python interpreter. def __init__(self...
true
4383772d34f8f68671a65e594e6775143f8337c0
kuldeeparyadotcom/coding_interview
/sum_target/SumTarget.py
2,941
4.1875
4
#!/usr/bin/env python # vim: tabstop=8 expandtab widthsize=4 softtabstop=4 """ Problem - A list of numbers is given. A target number (integer) is given. Write a function that returns a boolean value if any two numbers in list sum up the given target number. Input - List of integers target integer Output - True if a...
true
11a092e1eea851c85df75938bc0f2df28fce8f71
kuldeeparyadotcom/coding_interview
/q004/prime_classification.py
1,157
4.125
4
#!/usr/bin/env python # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 def classify_list(l): """ Purpose - function classifies prime numbers vs non-prime numbers Input - a list of positive integers Ouput - For each number in list, program confirms whether it is prime or not """ ...
true
42fda741883c2092888795118c130777edaf9448
abi-oluwade/engineering-48-Mr-Miyagi-Game
/mr_miyagi_sensei_edition.py
1,501
4.28125
4
print ("Hello young grasshopper,") # The 'while True' here means that the whole loop will run on forever/infinitely it will always be a true condition , # but can be broken with the use of the 'break' keyword after a condition has been met and will print the statement # at the end outside the loop. while True: user...
true
ea36fe328a8653132ddf456d18745196bea80a84
SMinTexas/phone_book_console_app
/phonebook.py
2,049
4.59375
5
# You will write a command line program to manage a phone book. # When you start the phonebook.py program, it will print out a menu # and ask the user to enter a choice: # $ python3 phonebook.py # Electronic Phone Book # ===================== # 1. Look up an entry # 2. Set an entry # 3. Delete an entry # 4. Li...
true
d7b2c4dd0a7b106730e4731819dbbe31b4dc18db
Arun-07/python_100_exercises
/Question_2.py
395
4.34375
4
# Question 2 # Write a program which can compute the factorial of a given numbers. # The results should be printed in a comma-separated sequence on a single line. # Suppose the following input is supplied to the program: 8 Then, the output should be:40320 n = int(input('Enter a number: ')) result = 1 for i in range(1,...
true
44a5e5d629980e316a750c26037d41be1ae1a74b
Arun-07/python_100_exercises
/Question_12.py
435
4.1875
4
# Write a program, which will find all such numbers between 1000 and 3000 (both included) # such that each digit of the number is an even number. # The numbers obtained should be printed in a comma-separated sequence on a single line. import re odd_pattern = re.compile(r"['1', '3', '5', '7', '9' ]") for num in rang...
true
cfaf8e864df4eb7d0a30e03466184abd33f3c2d3
Arun-07/python_100_exercises
/Question_35.py
315
4.3125
4
# Define a function which can generate a list where # the values are square of numbers between 1 and 20 (both included). # Then the function needs to print the last 5 elements in the list. def sqrd_list(): num_list = [i**2 for i in range(1, 21)] for j in num_list[:-6:-1]: print(j) sqrd_list()
true
15d687c7ae68b28c20e713ae165c59576cb1690c
schase15/cs-module-project-hash-tables
/applications/word_count/word_count.py
2,328
4.3125
4
# Already did this with the histo.py example # Only works on 3 out of 5 test with the special characters if statement # I think the test is wrong, based on the Readme. It says if no special characters are # removed it should return a blank dictionary. # In the second one, "Hello hello", there are no...
true
496109a8720fd12f0aaf8065423224ce46097081
SR-Sunny-Raj/Hacktoberfest2021-DSA
/33. Python Programs/binconversion.py
204
4.1875
4
'''Problem Statement : Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number. ''' n=int(input("Enter Number : ")) print(bin(n)[2:])
true
0cd1dd82c16e2fc272087e3c55578aa107a3b44c
SR-Sunny-Raj/Hacktoberfest2021-DSA
/05. Searching/BinarySearch.py
1,266
4.3125
4
# Binary Search: Search a sorted array by repeatedly dividing the search interval in half. # Begin with an interval covering the whole array. # If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. # Otherwise, narrow it to the upper half. Repeated...
true
2f836eba2f03aa2af3d26029f16f760624e144bd
SR-Sunny-Raj/Hacktoberfest2021-DSA
/33. Python Programs/create_sublist.py
2,113
4.1875
4
Python3 program to find a list in second list class Node: def __init__(self, value = 0): self.value = value self.next = None # Returns true if first list is # present in second list def findList(first, second): # If both linked lists are empty/None, # return True if not first and not second: return True ...
true
3b4d75e13e90c3f80307badb1fe07be84aaee4f5
SR-Sunny-Raj/Hacktoberfest2021-DSA
/20. Dynamic Programming/rod_cutting.py
1,423
4.34375
4
""" Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. Example: If length of the rod is 8 and the values of different pieces are given as following, then the maximum obta...
true
6d3a0183b835bed116980eab41cd43df8bd54c46
Hanu-Homework/SS1
/week02/hw_ex05_vowels_and_consonants.py
796
4.28125
4
def count_vowels_and_consonants(string: str) -> tuple: # A constant tuple holding all of the vowels all_vowels = ('a', 'e', 'i', 'o', 'u') vowels_count = 0 consonants_count = 0 # Convert all the characters of the string to lowercase string = string.lower() # Iterate through each character...
true
e2ff807c46dafdfe5ca57a85cba6c52f3fdab478
Hanu-Homework/SS1
/week02/tut_ex01_digits_sum.py
647
4.3125
4
# Get the input number from the user num = int(input("Enter a number: ")) def calculate_digits_sum(number: int) -> int: """ Return the sum of all digits in a number Args: number (int): the input number Returns: (int): the sum of all digits of the input number """ # Return val...
true
c86a4161ca43e6fad5387ba5c8aa795480549a08
dbrgn/projecteuler
/python/0009/9.py
769
4.28125
4
""" Problem 9 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ import sys def triplet(m, n): """Euclid's formula. Generate...
true
f6152c426e22d59b0b2ea333f0873ec3bc3591db
betts888/my-first-blog
/python_intro.py
1,101
4.3125
4
if 3 > 2: print('it works!') if 5>2: print('5 is indeed greater than 2') else: print('5 is not greater than 2') name = 'Sonja' if name == 'Ola': print('Hey Ola!') elif name == 'Sonja': print('Hey Sonja!') else: print('Hey awesome') volume = 57 if volume < 20: print("its kinda quiet") elif 20...
false
8b2094f561c9088f0da99fe268820fd59f4fd93e
thomasren681/MIT_6.0001
/ps4/ps4a.py
2,481
4.3125
4
# Problem Set 4A # Name: Thomas Ren # Collaborators: None # Time Spent: x: About a quarter to an hours def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST u...
true
a2650327ea1d4d9e989e94bf082e0801899cd5ba
Katarzyna-Bak/Coding-exercises
/Triangle area.py
766
4.21875
4
""" Task. Calculate area of given triangle. Create a function t_area that will take a string which will represent triangle, find area of the triangle, one space will be equal to one length unit. The smallest triangle will have one length unit. Hints Ignore dots. Example: . . . . . . -...
true
aeb77a185e0947f5eb2e7d95884cdf6b11697dc9
Katarzyna-Bak/Coding-exercises
/Right to Left.py
1,761
4.46875
4
""" "For centuries, left-handers have suffered unfair discrimination in a world designed for right-handers." Santrock, John W. (2008). Motor, Sensory, and Perceptual Development. "Most humans (say 70 percent to 95 percent) are right-handed, a minority (say 5 percent to 30 percent) are left-handed, and an indetermi...
true
bae89e5416fca377bce925552209a6c3eb97bf23
Katarzyna-Bak/Coding-exercises
/Filling an array (part 1).py
468
4.15625
4
""" We want an array, but not just any old array, an array with contents! Write a function that produces an array with the numbers 0 to N-1 in it. For example, the following code will result in an array containing the numbers 0 to 4: arr(5) // => [0,1,2,3,4] Note: The parameter is optional. So you have to...
true
8d02064e8feb688e01ece44ce2921f23b79b758c
Katarzyna-Bak/Coding-exercises
/Double Char.py
502
4.125
4
""" Given a string, you have to return a string in which each character (case-sensitive) is repeated once. double_char("String") ==> "SSttrriinngg" double_char("Hello World") ==> "HHeelllloo WWoorrlldd" double_char("1234!_ ") ==> "11223344!!__ " Good Luck! """ def double_char(s): output = '' f...
true
657a70dba9da3ec8793d9a4116f0d737775643eb
Katarzyna-Bak/Coding-exercises
/BASIC Making Six Toast.py
857
4.6875
5
""" Story: You are going to make toast fast, you think that you should make multiple pieces of toasts and once. So, you try to make 6 pieces of toast. Problem: You forgot to count the number of toast you put into there, you don't know if you put exactly six pieces of toast into the toasters. Define a funct...
true
d7317c89f49fdd717c8a251bab1576bdc9954716
Katarzyna-Bak/Coding-exercises
/Multiplication table for number.py
802
4.46875
4
""" Your goal is to return multiplication table for number that is always an integer from 1 to 10. For example, a multiplication table (string) for number == 5 looks like below: 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45 10 * 5 = 50 P. S. You can...
true
4cd58172be2558a2bf3e20e38817d39f0c7551f2
Katarzyna-Bak/Coding-exercises
/Majority.py
780
4.5625
5
""" We have a List of booleans. Let's check if the majority of elements are true. Some cases worth mentioning: 1) an empty list should return false; 2) if trues and falses have an equal amount, function should return false. Input: A List of booleans. Output: A Boolean. Example: is_majority([True, True, ...
true
66df0d705d7c17cd804e3ca813e8764dd1fa1461
Katarzyna-Bak/Coding-exercises
/Grasshopper - Terminal game move function.py
491
4.15625
4
""" Terminal game move function In this game, the hero moves from left to right. The player rolls the die and moves the number of spaces indicated by the die two times. Create a function for the terminal game that takes the current position of the hero and the roll (1-6) and return the new position. Example...
true
30e788b6aa05a95b1e2ff60316c673f40a87c915
Katarzyna-Bak/Coding-exercises
/L1 Set Alarm.py
761
4.28125
4
""" Write a function named setAlarm which receives two parameters. The first parameter, employed, is true whenever you are employed and the second parameter, vacation is true whenever you are on vacation. The function should return true if you are employed and not on vacation (because these are the circumstance...
true
62e4fc0551e05077fa9973fb9f1b3e6084e2bc0f
Katarzyna-Bak/Coding-exercises
/Count of positives sum of negatives.py
952
4.125
4
""" Given an array of integers. Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. If the input array is empty or null, return an empty array. Example For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should r...
true
9e783f91b7cb733caab0c177293b3da8b7a41c76
Katarzyna-Bak/Coding-exercises
/Days in the year.py
1,198
4.40625
4
""" A variation of determining leap years, assuming only integers are used and years can be negative and positive. Write a function which will return the days in the year and the year entered in a string. For example 2000, entered as an integer, will return as a string 2000 has 366 days There are a few assum...
true
f921bbe245fbf3cfe15671f2aeca902f5e82903c
Katarzyna-Bak/Coding-exercises
/First Word II.py
1,037
4.46875
4
""" You are given a string where you have to find its first word. When solving a task pay attention to the following points: There can be dots and commas in a string. A string can start with a letter or, for example, a dot or space. A word can contain an apostrophe and it's a part of a word. The whole text ca...
true
e7ac5307c1db801bcb856f70346cef9b5c1a1c60
Katarzyna-Bak/Coding-exercises
/Triple Trouble.py
767
4.21875
4
""" Triple Trouble Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the first letter of all of the inputs and grouping them next to each other. Do this for every letter, see example below! E.g. Input: "aa", "bb" , "cc" => Output: "abcab...
true
d80789651f5243b5db2f13859c49021ae7f9f1a1
Katarzyna-Bak/Coding-exercises
/Is n divisible by x and y.py
639
4.3125
4
""" Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits. Examples: 1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3 2) n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6 3) n = 100, x = 5, y = 3 => fals...
true
121ff2983e49ba7f50cee2366dee25a2052e2691
Katarzyna-Bak/Coding-exercises
/Is Even.py
514
4.46875
4
""" Check if the given number is even or not. Your function should return True if the number is even, and False if the number is odd. Input: An int. Output: A bool. Example: is_even(2) == True is_even(5) == False is_even(0) == True How it’s used: (math is used everywhere) Precondition: both given int...
true
7a63aa0ea780d23783a3b2941577a461c62d60e8
Katarzyna-Bak/Coding-exercises
/Find numbers which are divisible by given number.py
598
4.40625
4
""" Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor. Example divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6] """ def divisible_by(numbers, divisor): return [n for n in ...
true
0c1b756b5c1992a1156f2ea12277680771dc1455
Katarzyna-Bak/Coding-exercises
/Beginner - Reduce but Grow.py
343
4.25
4
""" Given a non-empty array of integers, return the result of multiplying the values together in order. Example: [1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24 """ def grow(arr): b = 1 for a in arr: b = b*a return b print("Tests:") print(grow([1, 2, 3])) print(grow([4, 1, 1, 1, 4])) print(gr...
true
c5582c5662069dfdbb87b8cd5957b45786427e3c
Katarzyna-Bak/Coding-exercises
/Keep Hydrated!.py
596
4.21875
4
""" Nathan loves cycling. Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value. For example: time = 3 ----> litres = 1 time = 6.7-...
true
3227c95714004341e4b61d6dd84453d3233957c1
luislauriano/python-data-structures-and-algorithms
/src/data_structures/arrays/left_rotation.py
497
4.59375
5
""" A left rotation operation on an array of size 'n' shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2]. Given an array of n integers and a number, 'd', perform 'd' left rotations on the array. T...
true
d0ef60a4b7a858f15afbc1fc0212af098818682b
andrewonyango/bioinformatics
/1-finding-hidden-messages-in-dna/week1/pattern_count.py
485
4.3125
4
def pattern_count(string, pattern): """ returns the number of occurences of *pattern* in *string* string: the string to search on pattern: the substring to look for in *string* """ count = 0 text_length = len(string) pattern_length = len(pattern) # compare only up to the last possi...
true
83de70501c82f7fbbb843e5e4b05e9451a5b841d
ferminhg/training-python
/patterns/behavioral-design-patterns/template.py
1,010
4.125
4
# Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. # Template Method lets subclasses redefine certain steps of an algorithm without changing # the algorithm's structure. # Use when you have to define steps of the algorithm once and let subclasses # to implement its behaviour....
true
ebc925161eaa9b1804c9bde35c56d90c01901489
patonelli/numericoPython
/gauss2.py
1,602
4.15625
4
# gauss elimination as seen in the classroom import numpy as np # A is type array from numpy # remember: A[0.0] is the first element # Elementary row operations: def troca_linha(A,i,j): '''Troca as linhas i e j da matriz A''' buffer = A[i].copy() A[i] = A[j] A[j] = buffer return A def mult_linh...
false
3bb124cac40c17cf765168b0d654b8663dd38eae
MarielenaDominguez/PC2TALLER
/ejercicio2.py
1,085
4.25
4
#historia de usuario #la historia de usuario es como un pequeño resumen de una actividad que se quiere realizar #historia: demora al comprar un producto en una tienda #como: implementar una página web, para poder comprar en línea #quiero_lograr: un fácil acceso a las personas, para poder comprar n = input("ingrese su...
false
ced048c3be05466bfe8e9aef6c310446ecb498ff
apontejaj/Python-Bootcamp
/for loop.py
624
4.3125
4
l = [] for num in range(0,10): l.append(num) for num in l: print (num) print ("-- We can also put a third parameter which is a step") l = [] for num in range(0,10,2): l.append(num) for num in l: print (num) print ("how to iterate over dictionaries") dict = {"k1":0, "k2":1, "k3":2} print dict fo...
false
c5cf7830c0a8ea665795a9cf738eadb4e72fd8c2
prasannagiri2072/python-practice
/spreedsheet work3/Untitled-6.py
741
4.21875
4
# String characters balance Test # We’ll say that a String s1 and s2 is balanced if all the chars in the string1 are there in s2. characters position doesn’t matter. # For Example: # stringBalanceCheck(yn, Pynative) = True def flag_statment(s1,s2): flag = True for char in s1: if char in s2: ...
true
5c286e31b47eef1bae59a1dc311ca8e03b5219d1
enterpriseih/easyTest
/SRC/demo/imooc/imooc_requests/part2_2urllib_demo.py
1,304
4.21875
4
''' urllib介绍 1.urllib和urllib2是相互独立的模块 2.requests库使用了urllib3(多场请求重复使用一个socket) ''' # # bytes object # b = b"example" # # # str object # s = "example" # # # str to bytes # bytes(s, encoding = "utf8") # # # bytes to str # str(b, encoding = "utf-8") # # # an alternative method # # str to bytes # str.encode(s) # # # bytes...
false
82d7ca65232a511f08307d0405768db40c1f0440
enterpriseih/easyTest
/SRC/demo/基础实例/part7.py
223
4.21875
4
# 题目:将一个列表的数据复制到另一个列表中。 # 程序分析:使用列表[:]。 numbers=[x for x in range(10)] n2=numbers[:] n3=numbers numbers[2]='abc' del numbers print(n2) print(n3) print(numbers)
false
6414e75ab4378fe13a0e4f9d242466db693c20f6
langigo/algorithm_python
/MergeSort.py
1,437
4.25
4
# -*- coding: utf-8 -*- """ Idea of merge sort: _Recursively split unsorted list into 2 sub-list, split until each sub-lists has only 1 memeber _For each 2 sub-lists, join them together by comparing 2 first members of 2 sub-lists, and append to the result-list of the join """ #implementation: acceptance parameter i...
true
bf3612377e123c1bf3e6584f81737584de1feaf4
dsrizvi/algo-interview-prep
/old/general/findPivotPoint.py
518
4.125
4
def findPivot(array, left, right): if left > right: return -1 if left == right: return left mid = (left+right)/2 if array[mid-1] > array[mid]: return array[mid] if array[mid+1] < array[mid]: return array[mid+1] if array[mid] > array[right]: return findPivot(array, mid+1, right) else: return findP...
true
ec2e68215caa750e057ac6732c4eed87f400acf8
dsrizvi/algo-interview-prep
/hacker-rank/warmup/solved/staircase.py
386
4.1875
4
# https://www.hackerrank.com/challenges/staircase import sys def build_staircase(total_steps): curr_step = 1 while curr_step <= total_steps: spaces = ' ' * (total_steps - curr_step) hashtags = '#' * curr_step print(spaces + hashtags) curr_step += 1 return def main(): total_steps = int(input().strip()) ...
false
ecaadd0b6312df92027978094a7f8013659ceb54
dsrizvi/algo-interview-prep
/old/general/sort/mergeRemove.py
712
4.125
4
def mergeSort(array): if len(array) < 2: return array mid = len(array)/2 left = array[:mid] right = array[mid:] left = mergeSort(left) right = mergeSort(right) return merge(left, right) def merge(left, right): merged = [] i = 0 j = 0 while i < len(left) and j < len(right): if left[i] < right[j]: ...
false
a7cd2b08a7cc82d65424b5e8f74d75dc22ad69f0
Taraslut/Python_circle
/5_list/list_1.py
417
4.1875
4
weekdays = [] print(weekdays) weekdays = ['Monday', "Tuesday", 'Weednesday'] print(weekdays) # first item in the list print(weekdays[0]) #slice print(weekdays[0:2]) another_list = list() print(another_list) # iterate by string ll1 = list('cat') print(ll1) ll2 = ['cat'] print(ll2) ll3 = ['cat', 'dog'] print(ll3) # ...
false
796ac8e33482626e4c5e72b0ff52e71864f79ba6
abolfazl-sadeghian/text_to_morse_code
/main.py
812
4.1875
4
from morse_code_table import CODE from art import logo from playsound import playsound # A text-based Python program to convert Strings into Morse Code. print(logo) text = input("Please enter a text to turn into morse code : \n").upper().split(' ') morse_code = [] def word_to_morse_code(word: str): for char i...
true
b35aec7bf7a170c1893b162d4f90e9210b40cc66
DevonLetendre/Distributions
/distribution.py
2,297
4.1875
4
from random import randrange ''' The Distribution class models a distribution and provides methods which allow a user to interact with the distribution. ''' class Distribution: def __init__(self): self.dict = {} self.eventspace = 0 self._L = [] self.flag = None self.leftoff_at = 1 self.slider_begin = ...
true
b4bbbd4c520eb8f8e1b598dea851ab75b6dfb2cf
FelipeLinares04/LaboratorioRepeticionRemoto
/mayor.py
253
4.1875
4
print("Bienvenido a el espacio donde sabras cuando un numero entero es mayor a cero") for i in range(1,11): x=int(input("ingrese el numero ")) if x>0: print("es un numero es postivo") else: print ("es un numero negativo")
false