blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7cfa1c977434c386eb3738bb15c0510c2a587563
adityaapi444/beginner_game
/chocwrap.py
1,004
4.1875
4
#chocolate wrapper puzzle game # price of one chocolate=2 #you will get 1 chocolate by exchanging 3 wrapper #write a program to count how many chocolates can you eat in 'n' money # n is input value for money #ex. #input: money=20 #output: chocolate=14 wrapper remains: 2 money=int(input("ente your mone...
true
681b785e3f09a24c8ab87c58aa759a588ce30e51
esterwalf/python-basics
/rosette or polygon.py
1,005
4.5625
5
>>> import turtle >>> t = turtle.Pen() >>> number = int(turtle.numinput("Number of sides or circles", "How many sides or circles in your shape?", 6)) >>> shape = turtle.textinput("which shape do you want?", "Enter 'p' for polygon or 'r' for rosette:") >>> for x in range(number): if shape == 'r': ...
true
989eeaea35c3342c9476735031a4ea1ae496c878
elaguerta/Xiangqi
/ElephantPiece.py
1,777
4.21875
4
from Piece import Piece class ElephantPiece(Piece): """Creates ElephantPieces elephant_positions is a class variable, a dictionary of initial positions keyed by player color Two ElephantPieces are created by a call to Player.__init__().""" elephant_positions = { 'red': [...
true
fef6a53d7ac9e0a73aaf7f8a6168c6b2761c2e90
rambabu519/AlgorithmsNSolutions
/Valid_paranthesis.py
1,533
4.125
4
''' 20. Valid Parentheses Given a string 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. Note that an empty string is also ...
true
4c775b35a1f0a0b9ff4484564abcdfadc8273e01
kemar1997/Python_Tutorials
/range_and_while.py
1,213
4.5
4
# creates a for loop that iterates through nine times starting with 0 # the range function is equivalent to creating a list but within the for loop only # Remember: Computers always start counting from 0 # the range function also accepts a range of numbers so the iteration doesn't necessarily, # have to start from exac...
true
20781199bff842884181faa97ec7af6d40b239dd
kemar1997/Python_Tutorials
/keyword_arguments.py
991
4.4375
4
# name, action, and item are keywords that hold values either strings or numbers # these keywords can have a default value which can be set in the parentheses below def dumb_sentence(name='Kemar', action='ate', item='tuna.'): print(name, action, item) dumb_sentence() # keyword arguments are taken in the function ...
true
076c7e2aa32dcc8aef746adb9c52fd64a742106d
halamsk/checkio
/checkio_solutions/O'Reilly/cipher_crossword.py
2,329
4.3125
4
#!/usr/bin/env checkio --domain=py run cipher-crossword # Everyone has tried solving a crossword puzzle at some point in their lives. We're going to mix things up by adding a cipher to the classic puzzle. A cipher crossword replaces the clues for each entry with clues for each white cell of the grid. These ...
true
70573b9422a6e9b4122522882bf71f6dc902d9a8
No-Life-King/school_stuff
/CSC 131 - Intro to CS/philip_smith.py
1,280
4.21875
4
def mult_tables_one(num): """ Prints a row of the multiplication table of the number 'num' from num*1 to num*10. """ print(num, end="\t") for x in range(1, 11): print(x*num, end='\t') print('\n') def mult_tables_two(start, end): """ Prints the rows of the multiplicatio...
true
259f11820d403abfd022a319693f15bf0e17156f
nandhinipandurangan11/CIS40_Chapter3_Assignment
/CIS40_Nandhini_Pandurangan_P3_3.py
1,478
4.1875
4
# CIS40: Chapter 3 Assignment: P3.3: Nandhini Pandurangan # This program uses a function to solve problem 3.3 # P3.3: Write a program that reads an integer and prints how many digits # the number has, by checking whether the number >= 10, >= 100 and so on. # (Assume that all integers are less than 10 billion) >> 10 bi...
true
c6f2dd94451ab8a2877335b133e1a4b8b0e5c838
betyonfire/gwcexamples
/python/scramble.py
475
4.21875
4
import random print "Welcome to Word Scramble!\n\n" print "Try unscrambling these letters to make an english word.\n" words = ["apple", "banana", "peach", "apricot"] while True: word = random.choice(words) letters = list(word) random.shuffle(letters) scramble = ''.join(letters) print "Scrambled: %s" % s...
true
f5be1bc6340012b3b3052e8f6a45df116a1c2d5c
Zahidsqldba07/CodeSignal-solutions-2
/Arcade/Intro/growingPlant.py
1,072
4.53125
5
def growingPlant(upSpeed, downSpeed, desiredHeight): import itertools for i in itertools.count(): if upSpeed >= desiredHeight: return 1 elif i*upSpeed - (i-1)*downSpeed >= desiredHeight: return i '''Caring for a plant can be hard work, but since you tend to i...
true
a288cdf0c28d593175e59f2e8fdff0a2c26cd98f
OmkarD7/Python-Basics
/22_assignment.py
766
4.28125
4
from functools import reduce #find the sum of squares of all numbers less than 10 numbers = [5, 6, 11, 12] sum = reduce(lambda a,b:a+b, map(lambda a:a*a, filter(lambda n: n <= 10, numbers))) print("sum of squares of all numbers which are less than 10: ",sum) #other way without using lambda def fun1(a, b): return a...
true
709a63ba721c447fad84ff309e45adc0774d29f5
egosk/codewars
/ML - Iris flower - Scikit/Iris flower - ML - basic exercises.py
1,849
4.125
4
# ML exercises from https://www.w3resource.com/machine-learning/scikit-learn/iris/index.php import pandas as pd import matplotlib.pyplot as plt import numpy as np from scipy import sparse # 1. Write a Python program to load the iris data from a given csv file into a dataframe and print the shape of the # data, type o...
true
da877bb35d8f3728d2bf91305c8b30e46819b30c
egosk/codewars
/print directory contents.py
606
4.15625
4
""" This function takes the name of a directory and prints out the paths files within that directory as well as any files contained in contained directories. This function is similar to os.walk. Please don't use os.walk in your answer. We are interested in your ability to work with nested structures. """ import os d...
true
088f07aec3fa090ff61b70376bf6e2f169f2241a
Bhumi248/finding_Squareroot_in_python
/squareroot.py
351
4.1875
4
#importing pakage import math print "enter the number u want to squreroot" a=int(input("a:")) #for finding square root there is defuslt function sqrt() which can be accessible by math module print" square_root=",math.sqrt(a) #finding square root without use of math module like:x**.5 print "squareroot usin...
true
ebdd28443a4eb602e246e5284e300344ce5cd9bf
nihagopala/PythonAssignments
/day3/MaxInThreeNos.py
700
4.5
4
#-----------------------------------------------------------# #Define a function max_of_three() that takes three numbers as # arguments and returns the largest of them. #-----------------------------------------------------------# def Max_Three(a,y,z): max_3 = 0 if a > y: if a > z: m...
true
6bcc913eed3ed4d99c607fb12c0400017b247a9e
nihagopala/PythonAssignments
/day1/15. SetOfOperations.py
545
4.53125
5
#----------------------------------------------------------# #Program to print the result of different set of operations #----------------------------------------------------------# set1 = {0, 2, 4, 6, 8}; set2 = {1, 2, 3, 4, 5}; # set union print("Union of set1 and set2 is",set1 | set2) # set intersection...
true
8ba142c74997a10c79bf39bcfca62307c8f3eb89
bs4/LearnPythontheHardWay
/ex32drill.py
2,263
4.625
5
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # this first kind of for-loop goes through a list for number in the_count: print "This is count %d" % number # same as above for fruit in fruits: print "A fruit of type %s" % ...
true
5958d7e44c80a44c98a28c64c9451631525f27c5
bs4/LearnPythontheHardWay
/ex06drill.py
2,124
4.125
4
# The below line gives a value for variable x, the value is a string that has a formatter in it x = "There are %d types of people." % 10 # The below line gives a value for the variable "binary", I think doing this is a joke of sorts binary = "binary" # The below line gives a value for the variable "do_not", the value i...
true
ada0873f48aba1239e05d845c2bb457cda744af4
bs4/LearnPythontheHardWay
/ex18drill.py
1,643
4.5
4
# this one is like your scripts with argv. The below line has a *, it tells python to take all arguments to the function and put them in args as a list def print_two(*args): arg1, arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2) # ok, that *args is actually pointless, we can just do this def print_tw...
true
f30c80da1a3ca8b3c3b34359cc1f7ecb6f0004bc
alinabalgradean/algos
/insertion_sort.py
413
4.25
4
def InsertionSort(lst): """Basic Insertion sort. Args: lst [list]: The list to be sorted. Returns: lst [list]: Sorted list. """ for index in range(1, len(lst)): position = index temp_value = array[lst] while position > 0 and lst[position - 1] > temp_value: lst[position]...
true
8dd255cbd492106fcfde67c9221698df5a85045f
andrewlidong/PythonSyntax
/Top18Questions/11_determineValidNum.py
2,176
4.125
4
''' 11. Determine if the number is valid Given an input string, determine if it makes a valid number or not. For simplicity, assume that white spaces are not present in the input. 4.325 is a valid number. 1.1.1 is NOT a valid number. 222 is a valid number. is NOT a valid number. 0.1 is a valid number. 22.22. is N...
true
fd8ea6ece01e686a8beef54bc5af3b8dfab593bf
andrewlidong/PythonSyntax
/Top18Questions/3_sumOfTwoValues.py
1,277
4.21875
4
''' 3. Sum of two values Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value. Return true if the sum exists and return false if it does not. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return...
true
e93d0ce781eb3ff8e8ed1515c3ccc49fb0c47dd9
drewAdorno/Algos
/Python Algos.py
2,200
4.125
4
import math '''Sara is looking to hire an awesome web developer and has received applications from various sources. Her assistant alphabetized them but noticed some duplicates. Given a sorted array, remove duplicate values. Because array elements are already in order, all duplicate values will be grouped together. As w...
true
3bb64b4540bed752e3f748ce0af80e2657d373e4
carcagi/hpython
/part1/P2_looping.py
1,393
4.25
4
# while loops # Not i++ avaiable i = 0 while i <= 5: # print(i) i += 1 # break and continue i = 0 while i <= 5: i += 1 if i == 2: continue print(i) if i == 4: break # else i = 0 while i <= 5: i += 1 print(i) else: print('Is more than 5') # if you break before else ...
true
575617625d8ba29a27eebc80b953330d8e20fb9f
famd92/python
/FizzBuzz.py
565
4.3125
4
###Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz" #### def fizzbuzz(number): if (number%3 ==0 and number%5 ==0): output ...
true
b4ed82079b3ad9ae8e9e2628c7570668215044b3
hamdi3/Python-Practice
/Formatting.py
783
4.53125
5
#Formatting in python str="string" print("this will type a %s" %(str)) # in %() whatever you write will be changed to a string print("this will type a %s , %s" %("hello" ,3)) # you can use %s 2 times and more but you use one %() with a comma for diffrient ones print("this will type a float %1.2f" %(13.4454)) # %1.2f me...
true
1ecebff7cf8703717fc8bc5d19a795161869c53a
iamSurjya/dailycoding
/Day 12_numpy_advance_indexing.py
421
4.1875
4
import numpy as np x = np.array([[1, 2], [3, 4], [5, 6]]) print('Array') print(x) y = x[[0,1,2], [0,1,0]] print('\nFrom each row, a specific element should be selected') #fetching [1 4 5] print(y) print('\nFrom a 4x3 array the corner elements should be selected using advanced indexing') x = np.array( [[ 0, 1, 2], [...
true
f38d4534d6a5fdb6565f9124eefc8e7cf00e04e5
satyamachani/python-experiments
/guess game.py
896
4.21875
4
import random print("you are going to play guess game with computer") print("rules are as follows") print("computer guess and you too") print("if ur guess equals computer guess") print("you wins") print("maximum guess allowed are 3") print("we are strating game......") print("ready to play with satya's computer...
true
503eb1fb3f378307e6ff0d9a9ccbd191e592d9b3
hugolribeiro/Python3_curso_em_video
/World3/exercise081.py
811
4.21875
4
# Exercise 081: Extracting data from a lista # Make a program that reads several numbers and put them into a list. After that, show: # A) How many numbers were inputted # B) The numbers list, in descending order # C) If the value 5 is in the list numbers_list = [] want_continue = 'Y' while want_continue != 'N': nu...
true
edaa06ad2bdc494c8011777a3aacf69f5ba2764a
hugolribeiro/Python3_curso_em_video
/World3/exercise096.py
467
4.40625
4
# Objective: Make a program that have a function called Area(). # Receive the dimensions of a rectangular land (width and length) and show its area. # Programmer: Hugo Leça Ribeiro def area(width, length): amount_area = width * length print(f'The area of this land is equal than: {amount_area}m²') width = fl...
true
1f25f848fb152d60b5af77405534750d4c83694c
hugolribeiro/Python3_curso_em_video
/World2/exercise060.py
408
4.3125
4
# Exercise 060: Factorial calculation # Make a program that read any number and show its factorial # Example: 5! = 5 X 4 X 3 X 2 X 1 = 120 number = int(input('Input here a number: ')) factorial = 1 print(f'{number}! = ', end='') for multiply in range(number, 0, -1): factorial = multiply * factorial print(f'{mu...
true
45a18da87d6d6a4b6d6dc201dbce51a6b44dab87
hugolribeiro/Python3_curso_em_video
/World2/exercise071.py
857
4.21875
4
# Exercise 071: ATM simulator # Make a program that simulates the operation of an ATM. # At the begin, ask to the user what value will be withdraw (an integer number) # and the program will informs how many banknotes of each value will be give. # Observation: Consider that the banking box has these banknotes: R$ 50, R$...
true
63f0901cc32517c7090232184e6179db607d1f87
hugolribeiro/Python3_curso_em_video
/World1/exercise013.py
265
4.125
4
# Exercise 013: Income readjustment # Build an algorithm that read the employee's income and show his new income, with 15% increase. income = float(input(f"Input here the employee's income: ")) new_income = income * 1.15 print(f'The new income is: {new_income}')
true
3127270d8291d1794b18cc66b47a0d547ba9b353
hugolribeiro/Python3_curso_em_video
/World2/exercise052.py
572
4.125
4
# Exercise 052: Prime numbers # Make a program that read an integer number and tell if it is or not a prime number. def verify_prime(num): if num < 2 or (num % 2 == 0 and num != 2): return False else: square_root = int(num ** 0.5) for divisor in range(square_root, 2, -1): if...
true
8fb71045715791f1d73d8394de33b5af4400a102
hugolribeiro/Python3_curso_em_video
/World2/exercise043.py
740
4.625
5
# Exercise 043: body mass index (BMI) # Make a program that read the weight and the height of a person. # Calculate his BMI and show your status, according with the table below: # - Up to 18.5 (not include): Under weight # - Between 18.5 and 25: Ideal weight # - Between 25 and 30: Overweight # - Between 30 and 40: Obes...
true
c99de9678d8cc3cd067ab93f3480a5c75f850bee
hugolribeiro/Python3_curso_em_video
/World3/exercise086.py
510
4.4375
4
# Exercise 086: Matrix in Python # Make a program that create a 3x3 matrix and fill it with inputted values. # At the end, show the matrix with the correct format matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for line in range(0, 3): for column in range(0, 3): matrix[line][column] = int(i...
true
5cad30469285efa036089dd993eaa595bb0ecdf4
as3379/Python_programming
/String_manipulation/reverse_alternate_words.py
629
4.3125
4
def reverseWordSentence(Sentence): # Splitting the Sentence into list of words. words = Sentence.split(" ") # Reversing each word and creating # a new list of words # List Comprehension Technique n = len(words) for i in range (0, n): if i%2 !=0: words[i] = words[i][::...
true
8e37ac3431bffcc74f9c66f16938409ef2277561
as3379/Python_programming
/String_manipulation/middle_char.py
377
4.25
4
"""Print middle character of a string. If middle value has even then print 2 characters Eg: Amazon -->print az """ def middle_char(S): S = S.replace(" ", "") # mid = "" n = len(S) if n%2 ==0: mid = S[n//2 -1]+ S[n//2] else: mid = S[n//2 -1] print(mid) middle_char("Amazon"...
true
0d8d1c23ee883c8ecb465b1ea25b9b2bf60bf01f
blueicy/Python-achieve
/00 pylec/01 StartPython/hw_5_2.py
358
4.1875
4
numscore = -1 score = input("Score:") try: numscore = float(score) except : "Input is not a number" if numscore > 1.0 : print("Score is out of range") elif numscore >= 0.9: print("A") elif numscore >= 0.8: print("B") elif numscore >= 0.7: print("C") elif numscore >= 0.6: print("D") elif numscore >= 0.0: pr...
true
489259c1f202adff5817dbedde48efeff65f2258
scienceiscool/Permutations
/permutation.py
2,248
4.15625
4
# CS223P - Python Programming # Author Name: Kathy Saad # Project Title: Assignment 6 - Generators and Iterators - Permutations # Project Status: Working # External Resources: # Class notes # https://www.python.org/ class PermutationIterator: def __init__(self, L): self.counter = 0 self.length_for_co...
true
420505fb8d7e2230e8554772d8e60c2efbb83017
kunalprompt/numpy
/numpyArray.py
735
4.4375
4
''' Hello World! http://kunalprompt.github.io Introduction to NumPy Objects ''' print __doc__ from numpy import * lst = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print "This a Python List of Lists - \n", lst print "Converting this to NumPy Object..." # creating a numpy object (ie. a multidimensional array) num_obj = array...
true
49694169a4ab556bcd9072ff168c8dd894008455
ffnbh777/Udacity-Adventure-Game
/udacity_game.py
2,680
4.125
4
import time import random import sys def print_pause(message_to_print): print(message_to_print) time.sleep(2) def intro(): print_pause("You find yourself in a dark dungeon.") print_pause("In front of you are two passageways.") print_pause("Which way do you want to go right or left?") def pla...
true
fc25cd3651f146956a075bc5c258b6181adbcee8
judebattista/CS355_Homework
/hw02/reverseComplement.py
1,980
4.4375
4
# function to find the reverse complement of a DNA strand # pattern: A string representation of DNA consisting of the chars 'A', 'C, 'G', and 'T' # complements: a dictionary translating a nucleotide to its complement # revComp: The pattern's complement, complete with 5' to 3' reversal # We may need to store complement ...
true
b78d2fe914cdf429651d076b7627d2daad9269f7
Timeverse/stanCode-Projects
/SC101_Assignment5/largest_digit.py
1,176
4.59375
5
""" File: largest_digit.py Name: ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 print(find_larg...
true
7efcb0b3f5aa5622e90423c07dd92952fc3f5c07
TryHarder01/SantaBot
/code/draft_bot_chatting.py
2,639
4.15625
4
""" The conversation logic to get the information from users """ username = 'NAME_GOES_HERE' introduction = "Hello {}, before we start let me check if we've done this before...".format(username) new= """Ok let's do this. I'm going to ask you for three things you like and three things you don't like. Once everyone has...
true
c8518987eda51e8866d77f42c7913e2f64bb9d37
tarakaramaraogottapu/CSD-Excercise01
/01_prefix_words.py
1,029
4.34375
4
import unittest question_01 = """ Given a query string s and a list of all possible words, return all words that have s as a prefix. Example 1: Input: s = “de” words = [“dog”, “deal”, “deer”] Output: [“deal”, “deer”] Explanation: Only deal and deer begin with de. Example 2: Input: s = “b” words = [“banana”, “bin...
true
1dcba14f0fb6b1e4ec92993a0ad8980fb1588bdf
Puneeth1996/programiz.com
/Python Introduction/Additon with single statement.py
639
4.34375
4
""" # This program adds two numbers num1 = 1.5 num2 = 6.3 # Add two numbers sum = float(num1) + float(num2) # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) # Store input numbers num1 = input('Enter first number: ') num2 = input('Enter second number: ') # Add two numbers sum = f...
true
332aaf6ab6405d2fdeef7ba789b4736437531b8c
mateo42/Project-Euler
/problem005.py
587
4.15625
4
# smallest positive number that is evenly divisible by all of the numbers from 1 to 20 def multiplesOf20(): '''Yield increasing multiples of 20''' i = 20 while True: yield i i += 20 def divisibleByAll( number ): ''' Checks that arguments is divisible by 3 - 19 ''' # Skip 1, 2, 20 for i in range(3,20): if ...
true
50d9761e41347ae4992d85276f54ba0a00662c08
Jazaltron10/Python
/Time_Till_Deadline/Time_Till_Deadline.py
556
4.28125
4
from datetime import datetime user_input = input("enter your goal with a deadline separated by colon\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] deadline_date = datetime.strptime(deadline,"%d/%m/%Y") # calculate how many days from now till deadline today_date = datetime.toda...
true
ddee8e59a44e8f76b83f63ebcc1054c8e6e1d128
EdgarUstian/CSE116-Python
/src/tests/UnitTesting.py
721
4.1875
4
import unittest from lecture import FirstObject class UnitTesting(unittest.TestCase): def test_shipping_cost(self): small_weights = [15.0, 10.0, 20.0, 25.0, 10.0] large_weights = [45.0, 30.1, 30.0, 55.0] def compute_shipping_cost(weight): if weight < 30: return 5.0 else: return 5.0 + (weigh...
true
0768f554f6d4780360f4cf27f7fdc3f4734a1f4b
rishav-karanjit/Udemy-Python-Basic
/6. Project 1 - Basic Calculator/1. Getting the data.py
465
4.4375
4
# input() -> Takes user input in the form of string a = int(input("Enter a integer:")) #We have changed string to integer because operations like addition cannot be performed in string b = int(input("Enter a integer:")) sign = input("Enter \n + for addition \n - for substraction \n * for multiplication \n / for divis...
true
504e771762dc1227fab5e0d4572629c1e7a5cbcd
MattSokol79/Python_Control_Flow
/loops.py
824
4.375
4
# Loops for loop and while loop # for loop is used to iterate through the data 1 by 1 for example # Syntax for variable name in name_of_data collection_variable shopping_list = ['eggs', 'milk', 'supermalt'] print(shopping_list) for item in shopping_list: if item == 'milk': print(item) sparta_user_details...
true
2365ccf635085dfa2e38e28d80aa7a1811eb0279
Ch-sriram/python-advanced-concepts
/functional-programming/exercise_2.py
405
4.1875
4
# Small exercises on lambda expressions # Square each element in the list using lambda expression my_list = [5, 4, 3] print(list(map(lambda item: item ** 2, my_list))) # Sort the following list on the basis of the 2nd element in the tuple my_list = [(0, 2), (4, 3), (9, 9), (10, -1)] print(sorted(my_list, key=lambda t...
true
0dda899681dd50663c3aa5a81c3ef00a1df6f090
Ch-sriram/python-advanced-concepts
/functional-programming/reduce.py
1,061
4.125
4
''' The reduce() function isn't provided by python directly. reduce() function is present inside the functools package, from which we import the reduce() function. In the functools library, we have functional tools that we can use to work with functions and callable objects. ''' from functools import reduce # synta...
true
795e15a99a91d2857fbdfab497ecaccd1789c0e8
ilarysz/python_course_projects
/data_structures/3_stack/linkedstack.py
920
4.28125
4
from linkedlist import LinkedList class LinkedStack: """ This class is a stack wrapper around a LinkedList. """ def __init__(self): self.__linked_list = LinkedList() def push(self, node): """ Add a node to the start of the linked list property. :param node: The No...
true
60ce10d064bf776b47d4e35da055b4a88d2a88aa
likhi-23/DSA-Algorithms
/Data Structures/linked_queue.py
1,828
4.1875
4
#Linked Queue class Node: def __init__(self, data): self.data = data self.next = None class Queue: def __init__(self): self.head = None self.tail=None def enqueue(self, data): if self.tail is None: self.head =Node(data) self.tail =self.head else: self.tail.next = No...
true
91c9488189f2895212594e1834cb54f5de713b8e
lpjacob/RPN-Calculator
/operand_queue.py
1,025
4.15625
4
""" Program to perform demonstrate a static queue in Python by ljacob1@canterbury.kent.sch.uk Purpose: to demonstrate queue operation, Limitations: WIP - not currently fully tested """ """global variables""" queue = [] maxSize = 5 #constant to set max queue size tailPointer = 0 def queueSize(): global queue ...
true
91bf3c7be3b61637fa8b66c891a5c3d26fb713f8
zhangqunshi/common-utils
/python/file/remove_duplicate_line.py
607
4.1875
4
# coding: utf8 # # Remove the duplicate line of a file # import sys def remove_duplicate_line(filename): exist_lines = list() with open(filename) as f: for line in f.readlines(): line = line.strip() if not line: continue if line not in exist_lines:...
true
78123433f18d7959d1f7f264e85c4afd964cb878
coala/workshops
/2016_07_03_doctesting_in_python_lasse/sum.py
320
4.3125
4
def sum(*args): """ Sums up all the arguments: >>> sum(1, 2.5, 3) 6.5 If you don’t provide any arguments, it’ll return 0: >>> sum() 0 :param args: Any numbers to sum up. :return: The sum of all the given """ return args[0] + sum(*args[1:]) if len(args) > 0 else 0
true
15b5608a5d690e4fbc40285ea65c94a81195f624
dhruvilthakkar/Dhruv_Algorithm_and_Games
/check_prime.py
267
4.15625
4
#!/usr/bin/env python from __future__ import print_function def check_prime(num): for i in range(2,num): if num % i == 0: print('Number is not prime') break print('Number is prime') num = input('Enter number to check for: ') check_prime(num)
true
29b21b246bd6eadf38f3e71b23d61a5f4590c05f
Alireza-Helali/Design-Patterns
/ProtoType_p2.py
1,500
4.125
4
from copy import deepcopy """ ProtoType: prototype is creational design pattern that lets you copy existing objects without making your code dependant on your classes """ class Address: def __init__(self, street, building, city): self.street = street self.building = buildi...
true
5acdaf70d6cb94d97a315d255ca6a1db1e027c44
Alireza-Helali/Design-Patterns
/Interface_Segregation_principle.py
2,207
4.3125
4
# Interface Segregation Principle """ The idea of interface segregation principle is that you dont really want to stick too many elements or too many methods in to an interface. """ from abc import ABC, abstractmethod class Machine(ABC): @abstractmethod def printer(self, document): pass @abstr...
true
e49b2f20b098d8119943430968da3d841376642c
sarwar1227/Stone-Paper-Scissors-E-Game
/stone_paper_scissors E-Game.py
2,659
4.15625
4
'''Stone Paper Scissors E-Game by SARWAR ALI(github.com/sarwar1227) using Python Technologies Required To Run this Code : Pyhton(32/64 bit) version 2/3+ INSTRUCTIONS TO PLAY THIS GAME : 1.Computer Randomly chose between ston/paper/scissors 2.You are asked to chose your option 3.Based on some camparisons...
true
d23a81e251ccfb2000f3de8ac0e93db194e08bee
shasha9/30-days-of-code-hackerrank
/Day_04_ClassVSInstance.py
1,345
4.21875
4
#Task # Write a person class with an instance variable age and a constructor that takes an integer initialAge as a parameter. #The constructor must assign initialAge to age after confirming the argument past as initialAge is not negative; #if a negative argument is passed past as initilAge, the constructor should set ...
true
7373b562b5e59201e6ffdcdde140e33dba3ce468
thiteixeira/Python
/Sum_Avg_Variance_StdDeviation.py
898
4.21875
4
#!/usr/bin/env python ''' Compute the Sum, Average, Variance, Std Deviation of a list ''' grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(grades): sum_of_grades = grades...
true
caeb99fe34437b5d5adc1c31cad03bbc30e31e35
ASHOK6266/fita-python
/w3resource/python3/List/exercise.py
1,614
4.34375
4
''' 1. Write a Python program to sum all the items in a list. list_values = [2,4,5,6] index = 0 while index < len(list_values): print(list_values[index]) index += 1 ---------------------------------------------------------------------------------------------------------------------------------------------...
true
7b8cbe2a5228cc3153d40bfeaf976cd1f8857f42
PatrickPitts/Brainworms
/lab2/SeasonsAndDays.py
1,526
4.40625
4
# Author : John Patrick Pitts # Date : June 21, 2021 # File : SeasonsAndDays.py # imports essential libraries import sys # gets data input from the user day_num = eval(input("Enter a number between 1 and 7: ")) season = input("Enter a season: ") day = "" month = "" # lists to check against for type of season spr...
true
fac443035144eb723c6df6a82fa4405079c49b10
Ewa-Gruba/Building_AI
/Scripts/C3E15_Nearest_Neighbor.py
947
4.15625
4
import math import random import numpy as np import io from io import StringIO import numpy as np x_train = np.random.rand(10, 3) # generate 10 random vectors of dimension 3 x_test = np.random.rand(3) # generate one more random vector of the same dimension def dist(a, b): sum = 0 for ai...
true
8044c59728a243d5ba9e974e0a8c62c3dd9cf750
ingehol/RomanNumerals
/main.py
2,205
4.21875
4
# Function for turning integers into roman numerals. # Creating lists with integers and the corresponding roman numerals. integers = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000] romans = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"] def int_to_roman(val): i = 12 roman_from_nu...
true
10cc4bf9eb93419251371f45e589c194f7cdd2f4
SeanIvy/Learning-Python
/ex6 (2).py
2,000
4.25
4
# --------------------------------- # Header # --------------------------------- # LPTHW - Exercise 6 # Sean Ivy - 050912 # Exercise 6 - Strings and Text # --------------------------------- # Start Code # --------------------------------- # Setting up Variables # --------------------------------- x = "There are %d ...
true
770edf3dc3dbde450b0c82e276193f413a633732
aidenyan12/LPTHW
/EX36/ex36.py
2,848
4.15625
4
from sys import exit def cave(): print "You're in a cave, a dragon is living inside to safeguard the magic sword" print "You need to take the sword as a weapon to kill the evil king to safe the country" print "You can choose 'sing' to make the dragon fall alseep or 'fight' with the dragon" action = raw_input("> "...
true
07265f21311c4a90056ddf0f4c7458cfdae4e880
DokiStar/my-lpthw-lib
/ex11.py
719
4.21875
4
print("How old are you?", end=' ') # input默认返回字符串类型 age = input() print("How tall are you?", end=' ') height = input() print("How much do you weight?", end=' ') weight = input() print(f"So, you're {age} old, {height} tall and {weight} heavy.") # 更多输入 str = input("Input some text here: ") str2 = input("more things her...
true
7032001cac6b18552bb161bb3c07f55961cc8230
greenfox-zerda-lasers/matheb
/week-03/day-2/36.py
243
4.25
4
numbers = [3, 4, 5, 6, 7] # write a function that reverses a list def rev(numbers): newlist = [] for i in range(len(numbers)-1, -1, -1): print(numbers[i]) newlist.append(numbers[i]) print(newlist) rev(numbers)
true
cf934c557b66a540408af48e1c5ebb3dcc0ea7e1
andyyu/coding-problems
/maximum_product_of_three.py
1,811
4.125
4
# Andy Yu ''' Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Input: [1,2,3,4] Output: 24 Note: The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000]. Multiplication of an...
true
c47c78d8b585483eac06ee47a9c55b02b22bb741
andyyu/coding-problems
/is_palindrome.py
686
4.21875
4
# Andy Yu ''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ask during an ...
true
99cbb8dac0fe03bad60919a4ebfcf3be8e5e434a
andyyu/coding-problems
/string_permutation.py
315
4.15625
4
# Andy Yu ''' Print all permutations of a string. Difficulty: Easy Solution notes: O(n*n!) time O(1) space ''' def permutate(string, prefix = ''): if (len(string) == 0): print prefix else: for char in string: permutate(string[:string.index(char)] + string[string.index(char)+1:], prefix + char)
true
b648720e20cae1330c7a094599027bcf991b58ed
andyyu/coding-problems
/is_anagram.py
701
4.125
4
# Andy Yu ''' Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. Note: You may assume the string contains only lowercase alphabets. Follow up: What if the inputs contain unicode characters? How ...
true
830c75cf9be01d0b3dbdf8ccf275d5f5aab9a000
andyyu/coding-problems
/invert_binary_tree.py
1,293
4.21875
4
# Andy Yu ''' Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None Difficul...
true
b79af958a03cd31deaf3d794f18fb4eea8f8dafa
andyyu/coding-problems
/last_word_length.py
1,001
4.15625
4
# Andy Yu ''' Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined as a character sequence consists of non-space characters only. For example, Given s = "Hello World",...
true
9bef8335c8629608d0982148e814acfed3bab9f0
BelfastTechTraining/python
/examples/mymodule.py
865
4.15625
4
def sum_numeric_list(nums): """ Accepts a list of numeric values. Returns the sum of the elements. """ sum = 0 for item in nums: sum += item return sum def prune_dict(dict, keys_to_remove): """ Accepts a dict to priune and a list of keys to remove. Matching keys are del...
true
b36f2f7a5bc5cc1dd1bc500bfe4c45d1f34f547f
pdaplyn/adventOfCode2018
/solutions/day1.py
1,326
4.1875
4
""" >>> test = ["+1", "+1", "+1"] >>> calc_frequency(test) [0, 1, 2, 3] >>> test = ["+1", "+1", "-2"] >>> calc_frequency(test) [0, 1, 2, 0] >>> test = ["-1", "-2", "-3"] >>> calc_frequency(test) [0, -1, -3, -6] >>> test = ["+1", "-2", "+3", "+1"] >>> calc_frequency(test) [0, 1, -1, 2, 3] >>> find_first_repeated( test )...
true
b9ce5e24adecc9b4795c536dc833a0cfd8699d1a
BaggyKimono/pythonfoundationswow
/02 Printpractice.py
956
4.5625
5
""" title: Printpractice author: Ally date: 11/26/18 10:36 AM """ print("hello world") #new line print("hello world\nhell is other people") #end a print statement with a thingy print("newline", end = "-") #tabbed characters print("Testing, testing\t1\t2\t3...") print("Testing, testing\n\t1\n\t\t2\n\t\t\t3...")...
true
4ba9bb1961d7dfd94f6019cda03c0fa31c0a0a96
ysr20/comp110-fa20-lab02
/draw_polygon.py
601
4.6875
5
""" Module: draw_polygon Program to draw a regular polygon based on user's input. """ import turtle # create a turtle and set the pen color duzzy = turtle.Turtle() duzzy.pencolor("red") # asks user for the length of the pentagon go_forward=int(input("Enter a length for the pentagon: ")) #asks user for number of side...
true
0d6fbc8b255a676dbc6b6da8608eee3367615187
Portfolio-Projects42/UsefulResourceRepo2.0
/GIT-USERS/TOM2/WEBEU3-PY1/guessing.py
1,080
4.3125
4
## guessing game where user thinks of a number between 1 and 100 ## and the program tries to guess it ## print the rules of the game print("Think of a number between 1 and 100, and I will guess it.") print("You have to tell me if my guess is less than, greater than or equal to your number.") # set a sentinal value t...
true
da2734b97e7b3b1449ed1688e1406e4c62e2e726
Portfolio-Projects42/UsefulResourceRepo2.0
/GIT-USERS/TOM2/WEBEU3-PY1/day1.py
1,819
4.15625
4
# This is a comment # lets print a string print("Hello, World!") # variables name = "Tom" age = 40 print("Hello, " + name) # f strings name = "Bob" print(f"Hello, {name}") # collections # create an empty list? lst1 = [] # lst1 = list() # create a list with numbers 1, 2, 3, 4, 5 lst2 = [1, 2, 3, 4, 5] # add an ...
true
665e20a76c940043340a84f48abec890420458e0
App-Dev-League/intro-python-course-jul-2020
/Session7/NestedLoops/main.py
279
4.1875
4
#Nested Loops for i in range(5): for j in range(5): print(f"The value of i is {i} and the value of j is {j}") #Nested lists and loops table = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] print(table) for row in table: print(row) for col in row: print(col)
true
30238131f2827d86fe4f530b1c7b39600c2dbdc4
App-Dev-League/intro-python-course-jul-2020
/Session2/DataTypes/strings.py
473
4.1875
4
#Strings name = "Krish" print(name) print(type(name)) #Indexing and Slicing print(name[0]) print(name[4]) print(name[2:4]) #get characters from 2 to 4 (not included) print(name[-1]) #gets last index print(name[-2]) #gets second to last index print(name[:]) #gets whole string #Length print(len(name)) #Common String...
true
7aa74118c759dff5f3ac767deaf623dfcae7b411
Yesidh/holbertonschool-web_back_end
/0x00-python_variable_annotations/5-sum_list.py
516
4.28125
4
#!/usr/bin/env python3 """ =============================================================================== a type-annotated function sum_list which takes a list input_list of floats as argument and returns their sum as a float. =============================================================================== """ from t...
true
d0c5db82d901898df3259ef51bcfc03de773eeee
PatrickJCorbett/MSDS-Bootcamp-Module-5
/module5_python.py
2,777
4.34375
4
#first just a test, print "hello world" print("hello world") ##Exercise 1: print the time #import the datetime function from the datetime package from datetime import datetime #put the current time into a variable now = datetime.now() #print the current time print(now) ##Exercise 2: simple stopwatch #Create the sto...
true
da4610110e6e7e580e52700b9fbe42c6f6fa0a19
Nirvighan/Python-C100-Project-
/ATM.py
1,231
4.125
4
# CREATE THE CLASS class ATM(object): #CREATE __INIT__ FUNCTION #IT IS SAME LIKE CONSTRUCTO IN JAVA def __init__(self,name,age,cardNumber,PIN,TotalAmount): #USE SELF #IT IS SAME LIKE THIS IN JAVA self.name = name self.age = age self.cardNumber = cardNumber ...
true
057ed18abae64e416e94891e2c1bdb530ff20db9
jigsaw2212/Understanding-Regular-Expressions
/RedEx_findall.py
971
4.6875
5
#findall() function for regular expressions finds all the matches of the desrired pattern in a string, and returns them as a list of strings #findall automatically does the iteration import re #Suppose we have a list with many email addresses str = 'purple alice-b@google.com, blah monkey bob@abc.com blah dishwasher' ...
true
893b3c73e03bb2d07fd0d2b6fa1da8cf1b8dd6ef
vanigupta20024/Programming-Challenges
/CaesarCipher.py
1,468
4.40625
4
''' Caesar cipher: Encryption technique also called the shift cipher. Each letter is shifted with respect to a key value entered. ''' print("Enter 0 for encryption and 1 for decryption:") n = int(input()) enc_text = "" print("Enter the input string: ", end = "") text = input() print("Enter key: ", end = "") key = int(i...
true
05bed03f2a6c548af9c820ec4872c7ec36c168e8
vanigupta20024/Programming-Challenges
/FindHighestAltitude.py
684
4.125
4
''' There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i and i + 1 for all (0 <= i < n). Return the hig...
true
de4d4235835ca1b871af439494367b2119c909d9
vanigupta20024/Programming-Challenges
/ReshapeTheMatrix.py
1,279
4.34375
4
''' You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively. The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they wer...
true
a64ffa6636d8f087557f9acb8ebe9c08c98226d6
vanigupta20024/Programming-Challenges
/RevVowelsOfString.py
625
4.15625
4
''' Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Input: s = "hello" Output: "holle" ''' class Solution: def reverseVowels(self, s: str) -> str: vowels = ['a', 'e', 'i', 'o', 'u', 'A', '...
true
fa1a26561714f20ce09c29bc00ab14fb1e2837a9
SelimOzel/ProjectEuler
/Problem003.py
629
4.21875
4
def FindLargestPrime(Number): primeList = [] currentPrime = 2 primeList.append(currentPrime) currentPrime = 3 primeList.append(currentPrime) while(currentPrime < Number/2): isPrime = True # Only check odd numbers currentPrime += 2 for prime in primeList: # Current prime is not prime if(currentPrim...
true
9dbecf5b08709386a86862878123c2c174d50328
SamuelFolledo/CS1.3-Core-Data-Structures-And-Algorithms
/classwork/class_activity/day8.py
377
4.3125
4
#Day 8: Hash Map # Stack coding challenge # Write a function that will reverse a string using a stack def reverse_string(text): my_stack = [] for letter in text: my_stack.append(letter) reversed_string = "" while len(my_stack) != 0: reversed_string += my_stack.pop(-1) #pop last ...
true
2a9fc322901e7bb2a32d5a8a75b53cd813f3c00b
FluffyFu/UCSD_Algorithms_Course_1
/week4_divide_and_conquer/3_improving_quicksort/sorting.py
2,005
4.21875
4
# Uses python3 import sys import random def partition3(a, l, r): """ Partition the given array into three parts with respect to the first element. i.e. x < pivot, x == pivot and x > pivot Args: a (list) l (int): the left index of the array. r (int): the right index of the a...
true
c219e62a3d037e0a82ee047c929ca271dd575082
FluffyFu/UCSD_Algorithms_Course_1
/week3_greedy_algorithms/2_maximum_value_of_the_loot/fractional_knapsack.py
1,061
4.1875
4
# Uses python3 import sys def get_optimal_value(capacity, weights, values): """ Find the optimal value that can be stored in the knapsack. Args: capacity (int): the capacity of the knapsack. weights (list): a list of item weights. values (list): a list of item values. The order ...
true