blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f258d3be7157102100bc3d285a9465c4814bb969
erobic/neural_networks
/src/simple_network.py
2,875
4.15625
4
import numpy as np ''' A simple neural network with single hidden layer ''' # Even no. of 1s = 1 training_data = np.array([ [[0, 0, 1], 0], [[0, 1, 1], 1], [[1, 0, 1], 1], [[1, 1, 1], 0] ]) def sigmoid(z): return 1.0/(1.0+np.exp(-z)) def sigmoid_deriv(z): return z*(1-z) def feedforwa...
true
2044dc4a1fd7d4d5481887b73813340e3913b1f8
sabinbhattaraii/python_assignment_2
/q12.py
379
4.28125
4
''' Create a function, is_palindrome, to determine if a supplied word is the same if the letters are reversed ''' def is_palindrome(string): string = string.lower() if list(string) == list(reversed(string)): return 'The word is palindrome' else: return 'The word is not palindrome' string ...
true
3131eb96e58ff19f85cdd910f3006dc398258192
sabinbhattaraii/python_assignment_2
/q15.py
831
4.28125
4
''' Imagine you are designing a banking application. What would a customer look like? What attributes would she have? What methods would she have? ''' class Bank(): def __init__(self): self.amount = int(input('Enter the amount of money you have')) def deposite_money(self,money): self.amount = ...
true
e4fded88028d58bc84e851f7f7beb73bf77a1c16
George-Went/Gwent-Library-Python
/Basic_Programs/Lists.py
360
4.40625
4
myList = [] myList.append(1) myList.append(2) myList.append(3) print(myList[0]) print(myList[1]) print(myList[2]) for x in myList: print(x) numbers = [1 ,2, 3] strings = ["Hello", "World"] names = ["John", "Eric", "Jessica"] third_name = names[2] print(numbers) print(strings[0] + " " + strings[1]) print("the th...
true
29aa9354e288bc5a8fda963839123c01f0164083
Ge0dude/AlgorithmsCoursera
/Course1/week5/coinChanging.py
912
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 19 17:41:48 2017 @author: brendontucker using this as an example to better understand dynamic programming lets do some debugging with print statements """ coinValueList = [1, 5, 21, 25] change = 63 minCoins = [0 for x in range(change + 1)] for ce...
true
b9c5a6d08e004c566ca2e69051c4a9a8b39dd6df
fionacahill/greenpepper
/PBJ.py
993
4.125
4
bread = 7 jelly = 4 pb = 4 if bread>=2 and jelly>=1 and pb>=1: print "You can have lunch today" else: print "No sandwich for you" if bread>=2 and jelly>=1 and pb>=1: sandwich=bread/2 if pb<sandwich: sandwich = pb if jelly<sandwich: sandwich = jelly print sandwich print "I can make {0} sandwiches".for...
true
f63945f0d5bd465b57d4c5c40329d43adcf558b5
tacolim/Python_Algorithms
/palindrome.py
1,547
4.28125
4
""" Return true if the given string is a palindrome. Otherwise, return false. A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Note You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everyth...
true
adafb62d7438f44a424023a65aad35dba4462934
KanchanRana/Information_Security
/IS_A_1_Additive_cipher.py
2,452
4.625
5
'''Ques 1. Write a program that can encrypt and decrypt using the Additive Cipher.''' #index of character is its value alpha_list=['A','B','C','D','E','F','G','H', 'I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X','Y','Z'] ''' encrypt_the_plain_text() is a fun...
true
08d70a6c3d6f164d0302e90742b33317a69110cf
attapun-an/topscore-project
/simple.py
1,026
4.40625
4
""" OpenTopScore(fileName) This function creates a new, empty, top score text file if it doesn't exist, otherwise it opens the text file filename (string) and returns a list of the contents AddScore(name, score, filename) This procedure takes 3 parameters, the name (string), score (integer) and the top score filen...
true
bb3fb7bf84f11dcb698b7928c1cc3536c65b879a
skyswordLi/Python-Core-Program
/Chapter2/sumAndAverage.py
904
4.28125
4
print "This script computes some values' summary and average." print "------------------------------------------" print "-------------Give your choice-------------" print "---------1 means compute summary----------" print "---------2 means compute average----------" print "--------------X means quit---------------...
true
73499d8e0ded33f336ac4d610a15e367c08013ea
skyswordLi/Python-Core-Program
/Chapter5/score.py
441
4.1875
4
def grade(score): assert 0 <= score <= 100, 'Wrong input score!' if 90 <= score <= 100: return 'A' elif 80 <= score < 90: return 'B' elif 70 <= score < 80: return 'C' elif 60 <= score < 70: return 'D' elif 0 <= score < 60: return 'F' print "Please input y...
true
d51a73e4e33d8fbd6e07e79fff740e03f26f2146
Automedon/Codewars
/8-kyu/Return Two Highest Values in List.py
621
4.34375
4
""" Description: In this kata, your job is to return the two highest values in a list, this doesn't include duplicates. When given an empty list, you should also return an empty list, no strings will be passed into the list. The return should also be ordered from highest to lowest. If the argument passed isn't a lis...
true
9faf9f52ef81370438c9192d23813b51c709659f
Tanja75/Python-tasks-solution
/String_reverse.py
224
4.40625
4
#Function that reverses the string: def string_reverse(str1): rstr1="" index=len(str1) while index>0: rstr1 += str1[index -1] index=index-1 return rstr1 print(string_reverse("python"))
true
0519a64e3938b4f567b674acfc766372e0ef4e1f
Hank02/CodeEval
/easy/penultimate_word.py
724
4.25
4
# print next-to-last word of each input string # each string has more than one word import sys # open file with comma-separated list of integers def file_open(): # get inout file name as command line argument in_file = sys.argv[1] # open input file test_cases = open(in_file, "r") return test_cases...
true
0bd64fedc0c0b0bf4e0e9f4c85ebb9f1539a1c4a
Hank02/CodeEval
/easy/longest_word.py
698
4.375
4
# print the longest word in a sentence # if more than one, print the left-most one import sys def file_open(): # get inout file name as command line argument in_file = sys.argv[1] # open input file test_cases = open(in_file, "r") return test_cases # funtion to print in title case def longest_word...
true
911c96d588df562ed190c1cf7b786441f5a78d62
AnupreetMishra/creating-static-variable-oops-
/main.py
675
4.21875
4
class Student: dept='BCA' #define class def __init__(self,name,age): self.name=name #instance variable self.age=age #instance variable #define the object of student class stud1=Student('ANU', '22') stud2=Student('ANKIT' , '19') print(stud1.dept) print(stud2.dept) print(stud1.name) pr...
true
225e5540b6996e40ab5ee461b26aa46d7635975a
AreRex14/ppdtmr-python-training
/script-10.py
1,927
4.125
4
# Classes and Objects # basic class class ClassName(object): """docstring for ClassName""" def __init__(self, arg): super(ClassName, self).__init__() self.arg = arg class MyClass(): variable = "hello" def function(self): print("This is a message inside a class.") myobjectx = MyClass() # ...
true
1de9de90abb9edd40590ce6d6e3e32d98b5871bd
AlexMan2000/ICS
/Lectures/Lecture 6/quicksort_student.py
750
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 6 20:05:43 2019 @author: xg7 """ def quicksort(seq): if len(seq) <= 1: return seq low, pivot, high = partition(seq) return quicksort(low) + [pivot] + quicksort(high) def partition(seq): """complete the function""" pivo...
true
ca9e6a0b79162a852a99c1b50db3e4586a1a35f1
mohnoor94/CorePythonCourse
/28 - Lecture 19/module_01/math_helpers.py
377
4.3125
4
def multiply(num1, num2, *numbers): """ Multiply all values and return the result. """ result = num1 * num2 if len(numbers): for num in numbers: result *= num return result def avg(*numbers): """ Return the average of all numbers. """ ...
true
1950a6f8072e37f8cee0639e6119704b6830f663
hyunmin0317/PythonProgramming
/Final/실습 11-1.py
462
4.125
4
def longest(str1, str2, str3): longest = str1 if (len(longest) < len(str2)): longest = str2 if (len(longest) < len(str3)): longest = str3 return longest def shortest(str1, str2, str3): shortest = str1 if (len(shortest) > len(str2)): shortest = str2 if (len(shortest) ...
true
fcb2b22c4d9d98f431e0273c6f3d7c9ede287d61
allenjcochran/google-python-class
/donuts.py
594
4.15625
4
#!/usr/bin/python -tt # Copyright 2010 Google Inc. import sys # Define a main() function that prints a little greeting. def main(): # Get the name from the command line, using 'World' as a fallback. if len(sys.argv) <= 9: name = sys.argv[1] print 'The number of donuts', sys.argv[1] if len(sys.argv) >= 9...
true
f845cdbfd7747be7760e489db65ec03763b61571
z-cntrl/Code
/math_quiz.py
1,311
4.21875
4
############################################################################### # Author: Chloe Weber # Date: 3/9/21 # Description A program that returns two series of numbers on separate lines #and asks the user to give the correct answer, if they pass it says one thing if they don't it says wrong ####################...
true
67172b7331ecbb92581019cd38ce9f93a2932bd0
geekcomputers/Python
/Python Program to Count the Number of Each Vowel.py
399
4.21875
4
# Program to count the number of each vowels # string of vowels vowels = 'aeiou' ip_str = 'Hello, have you tried our tutorial section yet?' # make it suitable for caseless comparisions ip_str = ip_str.casefold() # make a dictionary with each vowel a key and value 0 count = {}.fromkeys(vowels,0) # count the vowels ...
true
b7875cc58eb8fa78a9f54ba2e33ea8a7b15ba235
geekcomputers/Python
/convert_time.py
783
4.21875
4
from __future__ import print_function # Created by sarathkaul on 12/11/19 def convert_time(input_str): # Checking if last two elements of time # is AM and first two elements are 12 if input_str[-2:] == "AM" and input_str[:2] == "12": return "00" + input_str[2:-2] # remove the AM elif inp...
true
c3073018d8e1ebc33a00651fb49b5d7578083621
geekcomputers/Python
/dice_rolling_simulator.py
2,305
4.28125
4
# Made on May 27th, 2017 # Made by SlimxShadyx # Editted by CaptMcTavish, June 17th, 2017 # Comments edits by SlimxShadyx, August 11th, 2017 # Dice Rolling Simulator import random try: input = raw_input except NameError: pass global user_exit_checker user_exit_checker = "exit" # Our start function (What t...
true
3db22ee66217267ff7aee5ab7533be78f8feba46
geekcomputers/Python
/Sorting Algorithms/Bubble_sort.py
597
4.46875
4
def bubble_sort(Lists): for i in range(len(Lists)): for j in range(len(Lists) - 1): # We check whether the adjecent number is greater or not if Lists[j] > Lists[j + 1]: Lists[j], Lists[j + 1] = Lists[j + 1], Lists[j] # Lets the user enter values of an array and veri...
true
4e622d0815174abd5e264e06b46e1036394d0feb
geekcomputers/Python
/equations.py
1,165
4.21875
4
### ##### ####### by @JymPatel ##### ### ### ##### edited by ... (editors can put their name and thanks for suggestion) :) ### # what we are going to do print("We can solve the below equations") print("1 Quadratic Equation") # ask what they want to solve sinput = input("What you would like to solve?") # for Qdc E...
true
febd3ff6a2c454f07e650c9d374c1c7350e110dd
geekcomputers/Python
/Sorting Algorithms/Bubble_Sorting_Prog.py
376
4.125
4
def bubblesort(list): # Swap the elements to arrange in order for iter_num in range(len(list) - 1, 0, -1): for idx in range(iter_num): if list[idx] > list[idx + 1]: temp = list[idx] list[idx] = list[idx + 1] list[idx + 1] = temp list = [19, ...
true
e1cc51f13d221a6a8dd45a829557b7622f701a84
geekcomputers/Python
/stack.py
1,268
4.40625
4
# Python program to reverse a string using stack # Function to create an empty stack. # It initializes size of stack as 0 def createStack(): stack = [] return stack # Function to determine the size of the stack def size(stack): return len(stack) # Stack is empty if the size is 0 def isEmpty(stack): ...
true
21060130b122055b47d8982a938143da7af62cbb
geekcomputers/Python
/Strings.py
579
4.125
4
String1 = "Welcome to Malya's World" print("String with the use of Single Quotes: ") print(String1) # Creating a String # with double Quotes String1 = "I'm a TechGeek" print("\nString with the use of Double Quotes: ") print(String1) # Creating a String # with triple Quotes String1 = '''I'm Malya and I live in a world...
true
e7cb918f27de0433e10887a708fd1de5728f0669
geekcomputers/Python
/Sorting Algorithms/Counting Sort.py
868
4.1875
4
# Python program for counting sort def countingSort(array): size = len(array) output = [0] * size # Initialize count array count = [0] * 10 # Store the count of each elements in count array for i in range(0, size): count[array[i]] += 1 # Store the cummulative count for i in ...
true
4e3f5987f04b4635b06c4a759e95d2eaae9ec93b
geekcomputers/Python
/Python Program to Remove Punctuations from a String.py
371
4.46875
4
# define punctuation punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' my_str = "Hello!!!, he said ---and went." # To take input from the user # my_str = input("Enter a string: ") # remove punctuation from the string no_punct = "" for char in my_str: if char not in punctuations: no_punct = no_punct + char ...
true
00777b77f62961eafe2cf703e7a58698081c6cfa
geekcomputers/Python
/FIND FACTORIAL OF A NUMBER.py
543
4.375
4
# Python program to find the factorial of a number provided by the user. def factorial(n): if n < 0: # factorial of number less than 0 is not possible return "Oops!Factorial Not Possible" elif n == 0: # 0! = 1; when n=0 it returns 1 to the function which is calling it previously. return 1 else: re...
true
8629524dde42cd04e96e48c7c4adf29635697383
geekcomputers/Python
/Sorting Algorithms/bubblesortpgm.py
1,698
4.21875
4
"""Bubble Sort Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. Example: First Pass: ( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1. ( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4 ...
true
8e471f54b14459a37642a4212a0ec7882ab6178d
geekcomputers/Python
/tic_tak_toe.py
2,633
4.34375
4
# Tic-Tac-Toe Program using # random number in Python # importing all necessary libraries import numpy as np import random from time import sleep # Creates an empty board def create_board(): return np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) # Check for empty places on board def possibilities(board): l = []...
true
769fa0fd8f58aebc0240d119bb4d9fa33494a2b1
geekcomputers/Python
/area_of_square.py
231
4.46875
4
# Returns the area of the square with given sides n = input("Enter the side of the square: ") # Side length should be given in input side = float(n) area = side * side # calculate area print("Area of the given square is ", area)
true
1c6f8e5af875995ac1032c02ed834183fcc729b2
oknashar/interview-preparation
/googlePY/OA/Minimum-Domino-Rotations-For-Equal-Row.py
1,492
4.21875
4
''' n a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A are the...
true
a402180485c6cc4ed6a2c90dd13d3e557fb40c42
CataHax/lab2-py
/ex6.py
561
4.1875
4
# input a phone number x = int(input("Enter a phone number:")) # Take the string consisting of the first three characters and surround it with "(" and ") ". This is the area code. # Concatenate the area code, the string consisting of the next three characters, a hyphen, and the string consisting # of the last four c...
true
7eb422927724b81ba278b2e3de74ae812675b64f
angjerden/oiler
/svpino/problem3.py
533
4.1875
4
__author__ = 'anders' # Problem 3 # # Write a function that computes the list of the first # 100 Fibonacci numbers. By definition, the first two # numbers in the Fibonacci sequence are 0 and 1, # and each subsequent number is the sum of the # previous two. As an example, here are the first # 10 Fibonnaci numbers: 0, 1...
true
d229f9c08525e14b2d117026b2db0965287087e2
Ace5584/Machine-Learning-Notes
/other-libraries/learning-numpy/Part 1/main.py
895
4.53125
5
#------------------------------------------# # This part of np is about inizilizing and # # understanding and seeing types of data # # sets and sizes # #------------------------------------------# import numpy as np #init with dtype specifies the data type # dtype='int16' # dtype='int32' ...
true
729277f45c38b9dfb4fd5def1302e29db7601b1f
Ace5584/Machine-Learning-Notes
/other-libraries/learn-pandas/part 2/main.py
1,229
4.21875
4
#-----------------------------# # Reading data, getting rows, # # columns, cells, headers, # # etc... And sorting # # /discribing data. And High # # Level description on data # #-----------------------------# import pandas as pd df = pd.read_csv('C:/src/learn-pandas/pandas code/pokemon_data.csv') # Rea...
true
2b88ed10b16d103e1154e3c4e812c09743b8b02c
AsoUrum/python_Assignment_1
/question-3.py
1,115
4.21875
4
""" Given a string of odd length 7, return the middle char of the word """ word = input("Please Enter an odd number word with characters greater that 7: ") wordlenght= int(len(word)) odd = wordlenght%2 while ( not(wordlenght >=7 and odd == 1)): print("invalid word length, or not an odd nunber characters. Try ag...
true
44429416c832ab713f336bbc3c0f6fd48b4aacd9
anantvir/Leetcode-Problems
/Array_Manipulations/Search_2D_Matrix_II.py
1,016
4.25
4
"""Approach --> For each row of matrix, run a binary search through that row return True if element is found else False Complexity --> O(r*log(c)) where r = rows and c = columns""" """Better can be done by going through diagnols and searching the row and column chunks. Refer to https://leetcode.com/problems/search-a...
true
06121543c410017a1403e8d454056a149375f64d
anantvir/Leetcode-Problems
/Practice_2/Reshape_the_Matrix.py
1,935
4.125
4
""" MAIN IDEA --> Approach 1: Use a queue. Traverse the original matrxi and put every element in the queue. Then traverse the new matrix and on th fly dequeue each element and assign it to the new matrix. Approach 2 : 2D matrix can be represented in memory as 1D array. Convert given matrix to 1 D array(temp) where eac...
true
051f74548b371e7319a050f7df841f3a667a420b
Arjuna1513/Python_Practice_Programs
/AllAboutLists/ListComprehensionOfTuples.py
493
4.15625
4
"""for row in elements: for col in row: print(col, end='\t') print('\n') print(elements[0][0]) # u cannot try to view the tuple present in list if u try it will throw # "TypeError: 'generator' object is not subscriptable" error. tuple1=((1, 2), (3, 4)) print(tuple1[0][0])""" elements = [x for x in ...
true
84f30546eab00b0932211886af2593954316b5f4
Arjuna1513/Python_Practice_Programs
/SwitchStatementInPython/SwitchEx1.py
760
4.46875
4
def intToMonth(argument): dict1 = { 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9...
true
9eb43f96d7ab6cf5c7696a60e24ce170bfc65a62
BROjohnny/Python-A-Z-and-BasicPrograms-
/05 For Loop/For Loop.py
363
4.25
4
print("this is normal for loop") for i in range(1,11): print(i) print("\nin this for loop print 1 to 10 numbers passing 3 by 3") for i in range(1,11 ,3): print(i) print("\nthis is how to print values of 2 list as nexted loop") adj = ["red", "big", "tasty"] fruits = ["apple", "banana", "cherry"] for x in adj[...
true
8e699ea99af07d3c2c1dd445a0e62ce45b653526
azharul/misc_problems
/iterator.py
674
4.28125
4
#!/usr/bin/python #Write Interleaving Iterator class which takes a list of Iterators as input and iterates one element at a time from each iterator until they are all empty # interleaving iterators are also called Round Robin iterator from itertools import islice, cycle def roundrobin(*iterables): "roundrobin('...
true
a20b85284bbac100bcc5498c0cdadc069b7ab08e
azharul/misc_problems
/running_avg.py
387
4.15625
4
#!/usr/bin/python #Implement a class that can calculate the running average of a stream of input numbers up to a maximum of N numbers def running_avg(): temp=0 avg=0 C=1 n=int(raw_input("Enter maximum number of entries: ")) while C<=n: temp=int(raw_input("Enter number: ") avg = (avg*(C-1)+temp)/C C +=1 p...
true
7652554adf1cf618049bc9c65a87d98d9f1265e2
olieysteinn/T-111-PROG_Assignment-5
/5+/stdev.py
1,085
4.1875
4
# You might need this to calculate a square root using math.sqrt import math num = int(input("Enter a number (-1 to exit) ")) num_sum, count, current_average, standard_deviation = 0, 0, 0, 0 # Loop until the user types in -1 while num != -1: num_sum += num count += 1 previous_average = current_average ...
true
7ca8718e57774256ab93fba3fb712a7814702885
BrichtaICS3U/assignment-2-logo-and-action-abblurs
/action.py
2,516
4.34375
4
# ICS3U # Assignment 2: Action # Abbey Jayne # adapted from http://www.101computing.net/getting-started-with-pygame/ # Import the pygame library and initialise the game engine # Don't forget to import your class import pygame import random #to randomize rain fall #Import Rain class from rain import Rain from rain imp...
true
02d0f89834c36261a54f69ac9642aecde1820686
ODCenteno/python_100days
/day_5/adding_even.py
544
4.375
4
""" ## Adding Evens # Instructions You are going to write a program that calculates the sum of all the even numbers from 1 to 100. Thus, the first even number would be 2 and the last one is 100: i.e. 2 + 4 + 6 + 8 +10 ... + 98 + 100 Important, there should only be 1 print statement in your console output. It should...
true
dc47e2438926ed734cfe8bfc875f98c54b93931f
ODCenteno/python_100days
/day_3/odd-even.py
445
4.125
4
""" Creat a program that evaluates if a nuber is odd or even """ def main(): number = int(input('Enter a number: ')) check_number(number) def check_number(number): if number % 2 == 0: print('It is even') else: print('It is odd') def get_number(): try: number = input('Ent...
true
0823c6903b13d15050468e5f575b3f5454b4482f
ODCenteno/python_100days
/day_3/leap_year.py
946
4.34375
4
""" Write a program that works out whether if a given year is a leap year. A normal year has 365 days, leap years have 366, with an extra day in February. The reason why we have leap years is really fascinating, this video does it more justice: https://www.youtube.com/watch?v=xX96xng7sAE This is how you work out wheth...
true
8cc9eebb49164e47a43a9794cfa2f7e7b343ccc5
kumarnalinaksh21/Python-Practice
/Arrays/Anagram problem.py
886
4.4375
4
################ Question ###################################### # Construct an algorithm to check whether two words (or phrases) # are anagrams or not! # "An anagram is a word or phrase formed by rearranging the letters # of a different word or phrase, typically using all the original # letters exactly once" # For e...
true
e5ec47a5039806badaadec40915b0b6f35891ca1
Gerry84/Python-for-everybody
/3.2.py
323
4.125
4
#3.2 hours = input('Enter number of hours: ') rate = input('Enter rate: ') try: if int(hours)<40: pay = int(hours) * int(rate) print('Pay: ',pay) else: pay = 40 * int(rate) + (int(hours)-40) * 1.5 * int(rate) print('Pay: ',pay) except: print('Error, please enter numeric input...
true
b987e3dddbc09e5dd024519f65aef99e86c4982c
jinlygenius/basics
/algorithm/sortings/bubble_sort.py
789
4.40625
4
''' The algorithm works by comparing each item in the list with the item next to it, and swapping them if required. In other words, the largest element has bubbled to the top of the array. The algorithm repeats this process until it makes a pass all the way through the list without swapping any items. O(n2) algorithms ...
true
33914f9635d83148c350deb7113785c0310fa5b8
Samundar9525/datastructure-codes
/basic data structure using python/merge sory.py
1,031
4.21875
4
def mergesort(a,lb,ub): if(lb<ub): mid=int((ub+lb)/2) mergesort(a,lb,mid) mergesort(a,mid+1,ub) merge(a, lb, mid, ub) def merge(a,lb,mid,ub): i=lb j=mid+1 k=lb while(i<=mid and j<=ub): if(a[i]<=a[j]): b[k]=a[i] i=i+1 ...
true
07c862160943278a5de8323013e59f0fdb21c401
MarwanBit/Tri-1-Procedural-Programming-2019-2020
/notes_and_lectures/september_17_notes.py
291
4.21875
4
from sys import argv #To print anything from the command line type python file_name things_to_print #argv is everything in a list which contains all the arguments typed into the command line print('My name is {} and I have just run.'.format(argv[1])) print(argv) for i in argv: print(i)
true
58bdf06ff88233bba8882492f79797c52673fc48
bholanathyadav/PythonPractice
/ArmstrongNum.py
326
4.375
4
# A program to find if a number is an Armstrong number dt. 12th Feb 2019 num = int(input("Enter a number of your choice: ")) a = str(num) b = len(a) arm = 0 for i in a: c = int(i) arm += c**b if num == arm: print("Yes, it is an Armstrong number") else: print("No, it is not an Armstrong numb...
true
1905da90cdac22726e72508af744585c3e209bcb
HanchengZhao/Leetcode-exercise
/348. Design Tic-Tac-Toe/TicTacToe.py
2,024
4.3125
4
class TicTacToe(object): ''' The key observation is that in order to win Tic-Tac-Toe you must have the entire row or column. Thus, we don't need to keep track of an entire n^2 board. We only need to keep a count for each row and column. If at any time a row or column matches the size of the board then ...
true
aa2252d4f9c95e56e5ddc17cf92a43da198d9edb
HanchengZhao/Leetcode-exercise
/332. Reconstruct Itinerary/findItinerary.py
1,711
4.1875
4
from collections import defaultdict class Solution: def findItinerary(self, tickets: List[List[str]]) -> List[str]: self.trips = defaultdict(list) self.path = ["JFK"] for t in sorted(tickets): self.trips[t[0]].append(t[1]) # backtrack to see if the city would be the go...
true
823288aa85bfdf950884bbcca1bc99a0b1e4582c
darylhjd/ctci
/trees_and_graphs/validate_bst.py
601
4.15625
4
from tree import * def validate_bst(root: BTNode, mi, ma): """Validate whether a binary tree is a binary search tree.""" # Solution: O(n) time for going through each node, O(logn) for recursive calling. # Base case. If the root is None, return True. if root is None: return True # We chec...
true
762be873f4c493a6197c3e5dc253a2318abba79f
darylhjd/ctci
/arrays_and_strings/palindrome_permutation.py
1,048
4.1875
4
from collections import defaultdict def palindrome_permutation(string: str): """Check if the given string is a permutation of a palindrome.""" # Solution: O(n) time for creating the counter, and O(n) auxiliary space (worst case each letter is different), # where n is the length of the string. # We us...
true
f6ef3687038017c3294e205b513dceb469a31061
darylhjd/ctci
/trees_and_graphs/route_between_nodes.py
1,206
4.34375
4
def route_between_nodes(n1, n2): """Find out whether there is a route between n1 and n2.""" # Solution: O(k^(b/2)) time and space, k is the average number of neighbour nodes for each node, # b is the breadth of the search. # Use a queue to do BFS through n1's and n2's neighbours. n1_search = set() ...
true
53e18ee0f709e16c46c02f6abce1b276a1532715
BinXu-UW/basic-pythoncode
/Xu_pa2/sphere.py
432
4.25
4
# Programmer: Bin Xu # Class: Cpts 111 Section 01 # Programming Assignment: Project 02 # Filename: sphere.py # Date Created: 02/01/01 # Description: A program that calculates the volume and surface area of a sphere from its radius import math def main(): r= input ("Enter the radius: ") V = (4.0/3.0...
true
046fa4c3c7c35156ad8f3a7bce5d45ed67180384
johntiger1/LinkedList
/python_approaches/hackerrank.py
758
4.25
4
""" Reverse a linked list head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method. """ def Reverse(head): # base...
true
d9d1dea3c9e6ac436cda29f42bf73f3a4b2c6180
J0NATHANsimmons/Lab9
/lab9-70pt.py
641
4.28125
4
############################################ # # # 70pt # # # ############################################ # Create a celcius to fahrenheit calculator. # Multiply by 9, then divide by 5, then add 32 t...
true
f3a7a06249cd77f91b8a7f99298713530f3c65de
tamirverthim/programmers-introduction-to-mathematics
/secret-sharing/interpolate.py
959
4.1875
4
from polynomial import Polynomial from polynomial import ZERO def single_term(points, i): """Return one term of an interpolated polynomial. Arguments: - points: a list of (float, float) - i: an integer indexing a specific point """ theTerm = Polynomial([1.]) xi, yi = points[i] fo...
true
e9d0e0e4fb445c4909ed9eaa5586e7c710972136
woody-connell/dc-classwork
/week01/2-Tuesday/preLectureNotes/strings.py
1,277
4.1875
4
###################### Strings ###################### print("I am a string.") print('I am a string too.') print('I\'m a string and I have to escape my single quote.') print("I'm a string and I have a single quote.") print(""" I am a string and I can span multiple lines! """) ####################### Concatenta...
true
6fe44847e3a913e8ae5738987ad1b2caa7a876f0
Novandev/interview_prep_python
/algorithms/dynamic_programming/fibonnacci_dynamic.py
977
4.25
4
""" Dynamic programming and Memoization """ def fibonacci_dynamic(n): ''' This function displayes the proper use of memoization ''' pass def fibonacci_recursion(n): ''' SO recursion is usually a place to start with this kinda stuff The problem is that it builds a tree so ...
true
d12c833768b687418f8584ec406678bf820b75a3
yuehu9/Deep-Learning-From-Scratch
/5_DL_regularization/data_utils.py
2,632
4.59375
5
import numpy as np import matplotlib.pyplot as plt import sklearn.datasets def plot_decision_boundary(model, X, y): '''The function for plotting the decision function takes as arguments an anonymous function used to generate the predicted labels, and applies the function to the training data. plot_decisi...
true
38cc6bb0b6716e277aa148a6f30801d8c61f1fbd
meharrahim/python-small-projects-for-beginners
/Dice-Rolling-Simulator.py
547
4.34375
4
from random import randint # set min and max values of die min=1 max=6 # set a variable roll-again to repeat rolling roll_again = 'yes' # set a number of dice number_dice = 1 while roll_again == "yes": # integer input to number_dice number_dice = int(input("Input the number of dice you want to roll")) ...
true
243d207ae4003988a9903e96d000fd14c4517de2
UjuAyoku/Pycharm-Projects
/Fizz Buzz.py
665
4.25
4
# Exercise 2 """ Write a function called fizz_buzz that takes a number. If the number is divisible by 3, it should return “Fizz”. If it is divisible by 5, it should return “Buzz”. If it is divisible by both 3 and 5, it should return “FizzBuzz”. Otherwise, it should return the same number. """ def fizz_buzz...
true
ea92c718d609bdd40848ae003152a491c426e464
migzpogi/gitgud
/lessons/lambdas.py
539
4.15625
4
# Lambdas # https://www.w3schools.com/python/python_lambda.asp # Date: Sep 20, 2018 # Lambda is a small anonymous function # Can take any number of arguments, but can only have 1 expression # Syntax: lambda arguments : expression x = lambda a : a + 10 print(x(10)) y = lambda a, b, c : print('Your arguments are: {},...
true
b385a60bb675f46e9958466e9889f949e6105746
skrishna1978/CodingChallenge-February-2019-
/2.26.2019 | stringShortener.py
2,144
4.28125
4
#2.26.2019 - shashi #program that take a sentence to shortens it to a given length. def stringShorten(sentence, maxLength, connector): #function starts here if not sentence or maxLength<=0: #error check return "Invalid" if maxLength >= len(sentence): #if sente...
true
2f039c4e309858e33c3ea424a3bf1dd924ea55d5
abhishekRamesh8/BestEnlist-Python-Internship-Repo
/Day 9/task5.py
205
4.15625
4
# Write a Python program to count the even numbers in a given list of integers lst = list(range(1, int(input('Enter the length of list: ')) + 1)) print(list(map(lambda x: (x % 2 == 0), lst)).count(True))
true
65baf64dac7679aa5a58ba8b8208c83dd6d0af42
aneels3/Algorithm
/rightrotate.py
771
4.4375
4
# Python program to right rotate a list by n def rightRotate(lists, num): output_list = [] # Will add values from n to the new list for item in range(len(lists) - num, len(lists)): output_list.append(lists[item]) # Will add the values before # n to the end of new list for ite...
true
62b860e2af43f957f954a2fd6150e4110f35df65
JPCLima/DataCamp-Python-2020
/Data Scientist with Python- Track/Data Manipulation with pandas/3. Slicing and indexing/1_explicit_index.py
1,350
4.40625
4
# Setting & removing indexes # Look at temperatures print(temperatures) # Index temperatures by city temperatures_ind = temperatures.set_index("city") # Look at temperatures_ind print(temperatures_ind) # Reset the index, keeping its contents print(temperatures_ind.reset_index()) # Reset the index, dropping its cont...
true
2ef08c80e252f319589b657f2047ad243c142e7d
Jadoon83/PythonMVA
/21_FUnctionInPython.py
1,630
4.21875
4
# in Python, we have to define a function before we can use it. # def keyword is used to define a function followed by th neme of the function # and then the parameters # The main() function is called at the bottom def main(): fileName = "CountryList.csv" myList = ["C", "Python", "Java", "C++", "NodeJS", "Jav...
true
266152f584f608a390fef38aa0e919069ddade50
Jadoon83/PythonMVA
/13_MoreOnForLoop.py
321
4.3125
4
for numbers in range (5): print (numbers) # More on range print() for numbers in range (1, 6): print (numbers) # Another kid of loop, more like foreach loop print() for nums in [1, 2, 3, 4, 5]: print(nums) # Few more exampples print() for num in [22, "Ashok", "Python", 22.4, 12, "C"]: print (num...
true
ea85cbb1fa92b0680049a57083d42ac72e4b4ad0
ajauhri/playground
/coin_change.py
1,104
4.375
4
#! /usr/bin/env python """ Usage: coin_change [options] Prints the minimum number of change using the input denominations. Options: -d, --provide a list of denominations. For example: coin_change 1 2 3 """ from sys import argv, exit def main(): if not len(argv[1:]) > 1 and not argv[1] == "-d": print ("P...
true
356973f79a45356f24c1621bc90fbc78ef447dd3
ShahzainAhmed/InvertedStar
/InvertedStar.py
236
4.53125
5
# Program to create Inverted Star pattern. # Taking input from the user. n=int(input("Enter number of rows: ")) # Using for loop with range. for i in range (n,0,-1): # Using print statement. print((n-i) * ' ' + i * '*')
true
08bba9009b19e7e99c2842843f0ac21c772c2cc3
maxmyth01/unit4
/stringUnion.py
422
4.21875
4
#Max Low #10-20-17 #stringUnion.py takes two words and then prints out all the apering letter each letter only once def stringUnion(word1, word2): letters = '' for ch in word1: if ch not in letters: letters = letters + ch for ch in word2: if ch not in letters: lette...
true
89e11189a2ebf3072cfa0936b72421b20d555fad
stambla/google_prep
/anagram.py~
418
4.3125
4
#! usr/bin/env python """ 1.4 Write method which to decide if two strings are anagram or not. """ str_1 = input("Please input first word:") str_2 = input("Please input second word:") def check_anagram(str_1, str_2): temp = str_1[::-1] if temp == str_2: print "%s is angaram of %s" % (str_1, str_2) e...
true
25a5fb2ae9f7f82dbbd3cb65b5cbe53a8c815ce3
humanoiddess13/be-fullstack-TDD
/find_min.py
1,780
4.25
4
def get_min(a, b): """ Return minimal number among a and b. """ return a if a < b else b def get_min_without_arguments(): """ Raise TypeError exception with message. """ raise TypeError('You must have at least 1 argument.') def get_min_with_one_argument(x): """ ...
true
01193520f4ca41afc35c5bd4e34b2f1ccaf42527
VireshDoshi/pd_test
/PerspectumDiagnostics.py
2,721
4.5
4
#!/usr/bin/env python import itertools def strings_appear_in_multiple_lists(list_in): """ This method will print out the list of Strings appearing in multiple Lists. Input: List of Lists ( 1..n) Output: String """ # establish the size of the list list_in_len = len(list_in) # set the...
true
9402dc7956bd81a9f115c27f35dc1bb17e3d8363
RiyazShaikAuxo/datascience_store
/1.python/Datastrutures_in_Python/tupple.py
508
4.28125
4
# tupples once craeted can not be modified at all #Similar to lists tuple=(30,'Riyaz',5.8) print(tuple[0]) tuple1=("Banglore",29.3343,34) print(tuple1) #assigning new variable tuple2=tuple1 print(tuple2) #tupple not allow item assignment will throw error #tuple2(1)="Riyaz" retrieve1=tuple2[:-1] print(retrieve1...
true
fd73446ae26bc74f87d35ce6c29b156da1130201
mskyberg/Module7
/fun_with_collections/sort_and_search_array.py
2,712
4.59375
5
""" Program: sort_and_search_array.py Author: Michael Skyberg, mskyberg@dmacc.edu Last date modified: June 2020 Purpose: Demonstrates the use of a basic array sorting and searching """ import array as arr LIST_MAX = 3 def get_input(): """ Description: Gets user input :returns: returns a string of user ...
true
8421badfb54ed5238572c619a67f828dff41de39
henry199101/6.00.1x_Files
/Midterm_Exam/Quiz/Problem_5/laceStringsFinished.py
823
4.25
4
def laceStrings(s1, s2): """ s1 and s2 are strings. Returns a new str with elements of s1 and s2 interlaced, beginning with s1. If strings are not of same length, then the extra elements should appear at the end. """ # Your Code Here if len(s1) > len(s2): (s1, remainder) = (s1[...
true
229463b206f7594e56f94825645a236bcb48160b
PrabuddhaBanerjee/Python
/Chapter3/Ch3P9.py
269
4.15625
4
import math def main(): print("This program calculates area of a triangle") a, b, c = eval(input("Please enter 3 sides of triangle a, b, c:")) s = (a + b + c)/2 area = math.sqrt(s * (s - a) * (s - b) * (s - c)) print("Area of the triangle is ", area) main()
true
dca253cfa9ab3a66679770ec8879ca841c8cc616
PrabuddhaBanerjee/Python
/Chapter3/Ch3P6.py
289
4.125
4
def main(): print("This program calculates slope between two points") x1, y1 = eval(input("Please enter x, y coordinates for point 1:")) x2, y2 = eval(input("Please enter x, y coordinates for point 2:")) slope = (y2 - y1)/ (x2 - x1) print("Slope of the line is ", slope) main()
true
ef61b8338e2e3f0678e0b3174068bbeef8301723
PrabuddhaBanerjee/Python
/Chapter3/Ch3P1.py
320
4.28125
4
import math def main(): print("This program is to calculate the volume and surface area of a sphere") radius = int(input("Please enter the radius for sphere:")) vol = (4 / 3)* math.pi * (radius ** 3) area = 4 * math.pi * (radius ** 2) print("The area of the sphere is",area," and the volume is ",vol) main()
true
fbdc4501fd424d15c0d478286655ce417924b01f
FaatimahM/Analyse-predict
/analysepredict/word_split.py
505
4.28125
4
def word_splitter(df): """ Splits the sentences in a dataframe's column into a list of the separate words. The created lists should be placed in a column named 'Split Tweets' in the original dataframe. parameters ---------- df: Dataframe It should take a pandas dataframe as an input. ...
true
89a0dad041bb636a7119e958f881d7c95d017346
atena-data/Python-Bootcamp-Codes
/Day 1 - Band Name Generator/main.py
435
4.375
4
#1. Create a greeting for the program. print("Hello there! Welcome to the band name generator :) \n") #2. Ask the user for their favorite color and pet name. favorite_color = input("What is your favorite color?\n") pet_name = input("What is the name of your pet?\n") #4. Combine the names to suggest a band name. print("...
true
28085fc4229c92fcaf5f8ba852a8db66389ca5f5
atena-data/Python-Bootcamp-Codes
/Day 12 - Guess a Number Game/main.py
1,131
4.15625
4
from art import logo import random #Function to compare user's guess to the number def compare(user_guess, number): """Compares user's guess to the number and will return result""" if user_guess > number: global attempts attempts -= 1 return "Too high." elif user_guess < number: attempts -= 1 ...
true
1c4a20def81fddff2c3df963a8cf84cc2487a615
kwhit2/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
740
4.53125
5
#!/usr/bin/python3 """ This module contains a function that prints a square with #s """ def print_square(size): """ print_square method Args: size - int (length of a side of the square) Raises: TypeError: if size is not an int, if size is a float and less than 0 ValueError: if siz...
true
42a554b961de6ca003d11b0a2e7cbb00837486ae
kwhit2/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/9-print_last_digit.py
229
4.375
4
#!/usr/bin/python3 def print_last_digit(number): number = abs(number) # abs value needed for negative numbers print((number % 10), end="") # print the last digit with no \n return (number % 10) # return last digit
true
ad0e1c52f13e80b96eeea36d41f4c3d2d3aaab52
ArthurZheng/python_hard_way
/month_list.py
573
4.1875
4
def choose_month(): months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December'] month_input = int(raw_input("Enter a number for the month (1-12)")) print "The month you pick is ", month_input, " month name: ", months[month_input-1] def main(): ...
true
ce558dd7444d0bf453e7d055db8d869bf912fd27
gasamoma/cracking-code
/Strings/1.3.py
2,226
4.5
4
# URLify: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" length of the string. (Note: If implementing in Java, please use a character array so that you can perform this opera...
true