blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
78d1084a4dcf796b06973f9f66fc737a51737b20
tahabroachwala/hangman
/ExternalGuessingGame.py
1,109
4.28125
4
# The Guess Game # secret number between 1 and 100 import random randomNumber = random.randrange(1, 100) # changed from 10 to 100 #print randomNumber #check if it's working # rules print('Hello and welcome to the guess game !') print('The number is between 1 and 100') guesses = set() # your set of guesses gues...
true
179b10a76d7f45d72b940df327b3130df69c6aac
mrmufo/learning-python
/dates-and-datetime/challenge.py
2,824
4.1875
4
# Create a program that allows a user to choose one of # up to 9 time zones from a menu. You can choose any # zones you want from the all_timezones list. # # The program will then display the time in that timezone, as # well as local time and UTC time. # # Entering 0 as the choice will quit the program. # # Display the...
true
6f998d7918322d4c8934e7a690cbf10e8e59eb7e
imranmohamed1986/cs50-pset01
/pset6/caesar/caesar.py
1,469
4.125
4
from cs50 import get_string from sys import argv def main(): key = get_key() plaintext = get_plaintext("plaintext: ") print("ciphertext:", encipher_text(plaintext, key)) # Get key def get_key(): # Check if program was executed with an argument and only one # If yes, produce an int from it if...
true
bbecc9c3de6b21ecc7981e6da0d1c37a7937b792
Topazoo/Machine_Learning
/collab_filter/euclid_dist/euclid_dist.py
1,964
4.34375
4
from math import sqrt import recommendations '''Code for calculating Euclidean Distance scores. Two preferences are mapped on axes to determine similarities''' def distance(y1, y2, x1, x2): '''Calculating Distance: 1. Take the difference in each axis 2. Square them 3. Add them ...
true
0e16302bcec94857f4f3bae43d638df597f8b191
Haridhakshini/Python
/selectionsort.py
674
4.28125
4
#Program for Selection Sort #Array Input array_num = list() num = raw_input("Enter how many elements in the array:") print "Enter elements in the array: " for i in range(int(num)): n = raw_input("num :") array_num.append(int(n)) #Selection Sort function def selectionsort(array_num): for slot in range...
true
1c66c415554e0d1d60effecd3ecd42ce7165551e
amanewgirl/set09103
/Python_Tutorials_Continued/exercise16.py
638
4.25
4
#Exercise 16 from Learn Python the Hard way- Reading and writing from sys import argv script, filename = argv print "Opening the file: " target = open(filename, 'w') print "Now I'm going to ask you for three lines." line1 = raw_input("line 1: ") line2 = raw_input("line 2: ") line3 = raw_input("line 3: ") print "I'...
true
0c53d752d09b426a810792bbc244d653a775e55f
Tarun-coder/Data-science-
/table14.py
597
4.15625
4
# Print multiplication table of 14 from a list in which multiplication table of 12 is stored. number=int(input("Enter the number to Find Table of: ")) table=[] for i in range(1,11,1): numb=number*i table.append(numb) print("Table of Number",number,"is",table) print("---------------table of 2-------------------...
true
889d67897848f4b7ec25397bfb6825378fbc7cc5
Tarun-coder/Data-science-
/evenno.py
509
4.21875
4
# Write a Python function to print the even numbers from a given list. a =int(input("Enter the size of the list : " )) li=[] for i in range(a): number=int(input("Enter the Number to add into list: ")) li.append(number) print("The value of the list",li) print("The Final list is :",li) print("--------------...
true
97dbe152ca65123ee746e5ec222aec6f51cc0cd8
Tarun-coder/Data-science-
/Roman2.py
461
4.3125
4
# Write a Python script to check if a given key already exists in a dictionary. new={1:"one",2:"two",3:"Three",4:"Four",5:"Five",6:"Six",7:"Seven",8:"Eight",9:"Nine",10:"Ten"} keys=[1,2,3,4,5,6,7,8,9,10] values=["one","two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"] number=int(input("Enter the Key : "))...
true
b526c782ab5c09113d16827fcf81e8eb7d8da8eb
Tarun-coder/Data-science-
/function7.py
358
4.25
4
# Write a function to calculate area and perimeter of a rectangle. lenth=int(input("Enter the Lenth of Rectangle:")) width=int(input("Enter the Breadth of the Rectangle:")) def rectangle(lenth,width): print("The Permiter of the Rectangle is:",2*lenth+2*width,"cm") print("The Area of the Rectangle is:",lenth*wid...
true
76dbfeb357c5f237f3c1c803ed110fca8807b5cf
Tarun-coder/Data-science-
/tempcon.py
762
4.53125
5
# If we want to Print the value from farenheit to celsius Converter=input("Enter the Converter Name: ") print("The Converter Selected is : ",Converter) if Converter=="cels to far": celscius=int(input("Enter the Temperature in celscius : ")) farenheit=(celscius*9/5)+32 print("The Value in Farenheit is {}F:...
true
5231ad5e30fdb1102c98f309ab30c80a37f257e0
Tarun-coder/Data-science-
/functionq 5.py
465
4.15625
4
a=int(input("Enter the Number a: ")) b=int(input("Enter the Number b: ")) c=int(input("Enter the Number c: ")) def findmax(a,b,c): if a==b==c: print("All are Equal") exit() if a>b: if a>c: print("a is Greater than all") else: print("c is Greater than all...
true
8f2994a49203bc8dcae758fad8fd848dc212c7b9
NikaZamani/ICS3U-Unit3-03-Python-Number_Guessing_Game
/Number_Guessing_Game.py
808
4.28125
4
#!/usr/bin/env python3 # Created by: Nika Zamani # Created on: April 2021 # This program will generate a random number between 0 and 9 # and then checks if it matches the right number. import random def main(): # this function generates a random number between 0 and 9 random_number = random.randint(0, 9) ...
true
3950ced96153a601310a17980f9031013b82d59d
shafirpl/InterView_Prep
/Basics/Colt_Data_structure/Queue/Queue.py
1,196
4.125
4
class Node: def __init__(self, val): self.val = val self.next = None # in java, use a LinkedList class, use add method (compared to push method which # adds item at the front/head) to enqueue/add item to the end, and pop to remove item from head/front/begining class Queue: def __init__(self)...
true
e370ad016d1c193084a224df6a3f8f347b4ac595
weak-head/leetcode
/leetcode/p0023_merge_k_sorted_lists.py
1,743
4.125
4
from queue import PriorityQueue from typing import List class ListNode: def __init__(self, x): self.val = x self.next = None def mergeKLists(lists: List[ListNode]) -> ListNode: """ Divide And Conquer Time: O(n * log(k)) n - total number of nodes k - total number of l...
true
fde9c44a1de285bb11bb2d24b3e07c5c74747022
weak-head/leetcode
/leetcode/p0212_word_search_ii.py
2,581
4.125
4
from typing import List def findWords_optimized(board: List[List[str]], words: List[str]) -> List[str]: """ Backtracking with trie and multiple optimizations to prune branching Time: O(r * c * (3 ** l)) Space: O(l) r - number of rows c - number of cols l - max length of th...
true
d743e7c63ddee5169e99773c615f3a2cb63613bf
weak-head/leetcode
/leetcode/p0609_find_duplicate_file_in_system.py
2,447
4.15625
4
from typing import List from collections import defaultdict def findDuplicate(paths: List[str]) -> List[List[str]]: """ * 1. Imagine you are given a real file system, how will you search files? DFS or BFS? BFS explores neighbors first. This means that files which are located close to each other are al...
true
b88e80385800a44af25da1f0ab75ccfbca9387d8
candyer/learn-python-the-hard-way
/airport-board.py
1,741
4.15625
4
def next_letter(letter): return chr(ord(letter) + 1) def initialize_array(city): """ create a list of "a" the same length as city """ list_city = [] while len(list_city) < len(city): list_city.append('a') return list_city def list_to_string(list_city): """ take a list, make what's inside to a string. """ ...
true
03abde311519c576eed418644098b09848945806
deepakag5/Data-Structure-Algorithm-Analysis
/Sorting/InsertionSort.py
477
4.21875
4
def insertion_sort(arr): for i in range(1,len(arr)): # create a temp variable to store current value temp = arr[i] position = i # keep swapping the elements until the previous element is greater than the element at position while position > 0 and temp < arr[position - 1]: ...
true
eb3f98069aa33aeabac448c00c91085d54de9576
deepakag5/Data-Structure-Algorithm-Analysis
/leetcode/array_merge_intervals_two_lists.py
1,226
4.1875
4
# Time Complexity: Best case : O(m+n) # Space Complexity - O(m+n) for holding the results def merge(list1, list2): # base case if not list1: return list2 if not list2: return list1 # first we need to merge both lists in sorted order (on basis of first element) so that we can then merg...
true
eb104e1a0f8d6a13ef93c7b3e46385dd32480d97
dackour/python
/Chapter_23/01_Module_Usage.py
1,675
4.125
4
# The import statement import module1 # Get module as a whole (one or more) module1.printer('Hello world!') # Qualify to get names # The from Statement from module1 import printer # Copy out a variable (one or more) printer('Hello world!') # No need to qualify name # The from * Statement from module1 import * ...
true
8b763a0c00f8caa70c566c3ea5c7cb3d66c24164
mavamfihlo/Mava059
/calculatorSprint4.py
1,627
4.1875
4
# -*- coding: utf-8 -*- """ @author: Mava Mfihlo """ # below we are importing all of the functions that were created in the CalculatorFunctions.py file from CalculatorFunctions import* #this function import sys from os which will allow exit or quit the program from os import sys # while loop will remain...
true
6385a5bed6596c002b1363c69c4320bd88a32957
akash95khandare/Functional-Algorithm-Object-Oriented-program-in-python
/Month1/OOPS/StockReport.py
1,986
4.15625
4
""" Overview : Stock Report purpose : writing new json data into json file class name : StockReport author : Akash Khandare date : 05/03/2019 """ import json class StockReport: def __init__(self): self.list = [] with open("Json_Files/Stock.json", 'r') as data: try: data...
true
28e79fcbf38289d6608ccc1aff49a1b949ba558c
UltraChris64/Learn-Python-the-Hard-Way
/labs/ex6.py
886
4.5625
5
types_of_people = 10 # lines 3 and 7 format (the beginning f) inside the variable to replace any # variable used in the curly brackets when that variable is used x = f"There are {types_of_people} types of people." binary = "binary" do_not = "don't" y = f"Those who know {binary} and those who {do_not}." print(x) print...
true
ad76f9a4e39a8cfb270db88be5c54bbe5633f2ec
Hroque1987/Exercices_Python
/Functions_examples/string.format.py
1,036
4.1875
4
#str.format() #animal ='cow' #item = 'moon' #print('The '+animal+' jumped over '+item) #print('The {} jumped over the {}'.format(animal, item)) #print('The {1} jumped over the {0}'.format(animal, item)) #positional argument #print('The {animal} jumped over the {item}'.format(animal='cow', item='moon')) # keyword ...
true
ec0bf97fb5cbf2fea670da8b29442993345fc565
fredericyiding/algorithms
/numsIslands.py
2,454
4.21875
4
from Queue import Queue class Solution: """This is to calculate the number of Islands based on binary list of lists. Attributes: """ def numsIslands(self, grid, method='bfs'): """This function calculates the number of Islands. Both BFS and DFS implementations were presented. ...
true
990578d0a0ed269d519392e7a4b58177fe0ebb59
wojtas2000/codewars
/number_expanded_form.py
873
4.375
4
# Write Number in Expanded Form # You will be given a number and you will need to return it as a string in Expanded Form. For example: # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # NOTE: All numbers will be whole numb...
true
fba00850481a6a5df77e86977cc07d11d60c05ec
Zmontague/PythonSchoolWork
/asciiArt.py
1,896
4.40625
4
""" Author: Zachary Montague Date: 4/19/2021 Description: Program which prompts user for file name, reads the file name in, line by line iterates through the file and then decrypts the text, finally displaying the art and asking the user if they wish to read more files, until blank line is entered """ # CONSTANT DECLA...
true
082cae899e0314834cbbc83c9f3043a4ae13d9c0
codrWu/py-codewars
/get_the_mid_char.py
900
4.3125
4
# -*- coding: utf-8 -*- """ You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters. 获取字符串中间的字符,字符串长度为奇数返回中间一个字符,长度为偶数返回中间两个字符 Created on 2018/7/4 @author: codrwu """...
true
dd174d1a4f71b9583c1280b55bd1132511338c1b
amari-at4/Duplicate-File-Handler
/Topics/Loop control statements/Prime number/main.py
233
4.1875
4
number = int(input()) times_divisible = 0 for _i in range(1, number + 1): if number % _i == 0: times_divisible += 1 if times_divisible == 2: print("This number is prime") else: print("This number is not prime")
true
021e2c922e635be0cadc325bbbc78f738f024e69
sam-kumar-sah/Leetcode-100-
/451s.sort_character_by_frequency_in_string.py
663
4.1875
4
//451. Sort Characters By Frequency ''' Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Example 2: Input: "cccaaa" Output: "cccaaa" Example 3: Input: "Aabb" Output: "bbAa" ''' //code: class Solution(object): def fs(self,s): ...
true
b7bab5235de87b65aa8fe8c7c8bdb26debdf3e35
marcowchan/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,417
4.28125
4
#!/usr/bin/python3 """Defines matrix_divided""" def matrix_divided(matrix, div): """Divides all elements of a matrix. Args: matrix: A list of lists of integers or floats. div: The divisor to divide the elements of the matrix by. Raises: TypeError: If the matrix is not a list of li...
true
5747ce73e516a8a66c6668f7ca3d9ea389fac79f
gerpsh/backtoschool
/imgEditor/editor/processing/bw.py
1,748
4.3125
4
def applyFilter(pixels): # This is an array where we'll store pixels for the new image. In the beginning, it's empty. newPixels = [] # Let's go through the entire image, one pixel at a time for pixel in pixels: # Let's get the Red, Green and Blue values for the current pixel inputRed ...
true
34d222f0a98b6d90711a37661c30bddb450b09db
randm989/Euler-Problems
/python/p14.py
891
4.15625
4
#!/usr/bin/python #The following iterative sequence is defined for the set of positive integers: # #n n/2 (n is even) #n 3n + 1 (n is odd) # #Using the rule above and starting with 13, we generate the following sequence: # #13 40 20 10 5 16 8 4 2 1 #It can be seen that this sequence (starting at 13 and fini...
true
9b6c8d5b353f452cfd2809c57d3a521fa0aa553c
mattcucuzza/pyLinearAlgebra
/main.py
2,060
4.125
4
# Matthew Cucuzza # 2/18/17 # Python program doing various operations with vectors from linear algebra import math # Find the sum of two vectors combined def addVectors(x1, y1, x2, y2): x = x1+x2 y = y1+y2 return x,y # Find the length of two vectors combined def lengthOfVector(x,y): x = x**2 y =...
true
4cf83df6618978bd041bfa78af67e33a73818663
atriadhiakri2000/Algorithm
/Tree/Merge two BST 's.py
2,677
4.375
4
# Data structure to store a BST node class Node: # Constructor def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # Helper function to print a doubly linked list def printDoublyList(head): while head: print(head.data, end=" -> ") head = he...
true
0137bccec4aecafec20f89a64077fee732221da4
priyanka090700/hacktoberfest2021
/multiply.py
367
4.375
4
#Taking input from the user. num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) #Defining a function to calculate multiplication of the two numbers. def multiply(a,b): result = a * b print("Product of two given numbers is: ", result) #Calling the function to ...
true
f00c9f561c037c9bbc0fbbb8c12b6339719c1116
zeeshanhanif/ssuet-python
/9April2017/DemoList/StudentTerminal.py
1,256
4.28125
4
studentslist = ["zeeshan","saad","osama"] print("Welcome to student portal") print("Please enter 1 to list student names") print("Please enter 2 to add student names") print("Please enter 3 to search student names") print("Please enter 4 to delete particular student names") print("Please enter 5 to sort student name...
true
835476ef90f3f6c91c00eaccc427af5cfaec0e89
susbiswas/DSAlgo
/MaxHeap.py
2,141
4.1875
4
# The following code implements a **max** Heap # # Strictly speaking, the following functions will take O(n) time # in Python, because changing an input array within the body of a function # causes the language to copy the entire array. We will soon see how to do this # better, using Python classes # function for in...
true
05ca6f981f767455a9dfb99592821976c09c6f4b
MyHackInfo/Python-3-on-geeksforgeeks
/035- Mouse and keyboard automation using Python.py
1,409
4.125
4
''' #### Mouse and keyboard automation using Python #### -The pyautogui is a module that help us control mouse and keyboard with code. ## Some Functions 1-size(): This function is used to get Screen resolution. 2-moveTo(): use this function move the mouse in pyautogui module. 3-moveRel() functi...
true
32eda3cbc67f060040a8eed5ba02e29dde62b512
MyHackInfo/Python-3-on-geeksforgeeks
/048-enum in Python.py
930
4.46875
4
''' #### Enum in Python #### -Enumerations in Python are implemented by using the module named “enum“. -Enumerations are created using classes. Enums have names and values associated with them. ## Properties of enum: 1. Enums can be displayed as string or repr. 2. Enum can be checked fo...
true
8bb072d3d1a21338fd3b206de442f13e94badb01
MyHackInfo/Python-3-on-geeksforgeeks
/020-Generators in Python.py
1,170
4.625
5
''' #### Generators in Python #### 1-Generator-Function: A generator-function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return. If the body of a def contains yield, the f...
true
f37ada6908329b162e40f9486a0228be999983b0
MyHackInfo/Python-3-on-geeksforgeeks
/017-Using Iterations in Python.py
878
4.75
5
# Accessing items using for-in loop cars = ["Aston", "Audi", "McLaren"] for x in cars: print (x) # Indexing using Range function for i in range(len(cars)): print (cars[i]) # Enumerate is built-in python function that takes input as iterator for q, x in enumerate(cars): print (x) for x in enumerate(cars...
true
b2c38cdbf324a30dff7fef4116d3b620d3691dd0
MyHackInfo/Python-3-on-geeksforgeeks
/057-Python tkinter Button and Canvas.py
1,469
4.3125
4
''' ## 1- Button:->> To add a button in your application, this widget is used. ## format of the Buttons:> 1->activebackground:-> to set the background color when button is under the cursor. 2->activeforeground:-> to set the foreground color when button is under the cursor. 3->bg:-> to s...
true
7f2e1c54a6c5df0f7d1ebc56667e465831d875cd
MyHackInfo/Python-3-on-geeksforgeeks
/014-Inplace vs Standard Operators in Python.py
1,503
4.625
5
''' # Inplace vs Standard Operators in Python -Normal operators do the simple assigning job. On other hand, Inplace operators behave -similar to normal operators except that they act in a different manner in case of -mutable and Immutable targets. Immutable=> such as numbers, strings and tuples. >>Updation But...
true
f65250794c2b2f3fa49927b3e37786978215dfce
MyHackInfo/Python-3-on-geeksforgeeks
/036-Object Oriented Programming in Python.py
1,823
4.40625
4
''' #### Object Oriented Programming in Python #### # Class, Object and Members # * The __init__ method:>> The __init__ method is similar to constructors in C++ and Java. It is run as soon as an object of a class is instantiated. The method is useful to do any initialization you wan...
true
7d95dc42bae43085f729ee5d037b9cc144c51d5e
MyHackInfo/Python-3-on-geeksforgeeks
/047-Heap queue (or heapq) in Python.py
2,260
4.1875
4
''' ### Heap Queue in python ### -Heap data structure is mainly used to represent a priority queue. -In Python, it is available using “heapq” module. The property of this -data structure in python is that each time the smallest of heap element is popped(min heap). -Whenever elements are pushed or po...
true
7052094ebf233f0fa595080757162a7882589e55
CSmel/pythonProjects
/average_rainfall2/average_rainfall2.py
1,062
4.5
4
# Ask user for how many years of rainfall to be used in calculations. num_years = int(input('How many years? ')) # Determine how many years. print() for years in range(num_years): total = 0 # Initialize an accumulator for number of inches of rainfall. print('---------------') ...
true
02e8b105d9395302f5a9452f81aa0c5ede756db0
CSmel/pythonProjects
/feet_to_inches/feet_to_inches.py
458
4.25
4
# Constant for thenumber of inches per foot INCHES_PER_FOOT = 12 # Main functions. def main(): # Get the number of feet from the user feet = int(input('How many feet? ')) # Display and convert feet to inches print(feet,'feet converted to inches is:',feet_to_inches(feet),'inches.') # Th...
true
139f211d82629d5c2946b2b9a514bcc1b50f6934
pmkiedrowicz/python_beginning_scripts
/random_string.py
370
4.21875
4
''' Generate random String of length 5. String must be the combination of the UPPER case and lower case letters only. No numbers and a special symbol. ''' import random import string def generate_string(length): base_chars = string.ascii_letters return ''.join(random.choice(base_chars) for i in range(length...
true
e4c272f006a7210ca82b2d331cd8198ceb47deed
pmkiedrowicz/python_beginning_scripts
/select_multiple_columns_csv.py
394
4.1875
4
''' Find each company’s Higesht price car ''' import pandas # Read .csv file pd = pandas.read_csv("Automobile_data.csv") # Create multidimension list grouped by company companies = pd.groupby('company') # Use below script for debugging # for i in companies: # print(i) # Select from each group row with max price ...
true
15ea8695f41f7a946ad704915e69947be30a0c89
gicici/python
/lists.py
853
4.1875
4
my_list=[1,2,3] print(my_list) #Lists can hold different types of numbers, strings or even floating point numbers my_list= ['string',1,0.3,67, 'o'] print(my_list) #len stands foor length print(len(my_list)) my_list = ['one','two', 'three', 4,5] #grabs elements on the index and that is 1 print(my_list[0]) l = [1,4,5] l...
true
40c8dfe529c86ddbcdb60cf52e31600c9e64b669
gicici/python
/ex2.py
2,697
4.21875
4
print("I could have code like this") #and the comment after #You can also use a comment to "disable" or comment out #print("This wont run") l = [1,2,3] print(l.append(4)) #objects are things on the real world print(l.count(3))#this is used to check the type while count()is used to 'count ' the number of times something...
true
0747db47499bee241d6c2685bb29641204bd3576
joydip10/Python-Helping-Codes
/errorsandexceptions2.py
633
4.125
4
class Animal: def __init__(self,name): self.name=name def sound(self): raise NotImplementedError("You haven't implemented this method in this particular subclass") #abstract method class Dog(Animal): def __init__(self,name,breed): super().__init__(name) se...
true
04005a5d88f72a3afa481f52fbd5478a3fb87316
joydip10/Python-Helping-Codes
/args.py
1,253
4.125
4
def total(*nums): total=0 print("Type of *nums: "+str(type(nums))) print("Packed as tuple: ") print(nums) #packed print("Unpacked: ") print(*nums) #unpacked for i in nums: total+=i return total print(total(1,2,3,4,5,6,7,8,9,10)) print("\n\n\n\n\n") l=[i for i in range(1,11)] t=...
true
258a1180264a716ab49e134082c6e03c1e191ff8
pkopy/python_tests
/csv/csv_reader.py
336
4.125
4
import csv def csv_reader(file_object): ''' Read a CSV file using csv.DictReader ''' reader = csv.DictReader(file_object, delimiter=',') for line in reader: print(line["first_name"]), print(line["last_name"]) if __name__ == "__main__": with open("data.csv") as f_obj: c...
true
e6eec83a6b8c5cc929fc6d02d274ea88d2ff5553
whoissahil/python_tutorials
/advancedListProject.py
948
4.40625
4
# We're back at it again with the shoes list. I have provided you with the shoes list from the last exercise. # In this exercise, I want you to make a function called addtofront, which will take in two parameters, a list and a value to add to the beginning of that list. # Once you have made your function, add this li...
true
5824b0576b6bd3977296ab653a51cdc1f483c839
Wall-Lai/COMP9021
/final sample/10_27_gai_gai_not_one_line/sample_3.py
2,908
4.125
4
''' Given a word w, a good subsequence of w is defined as a word w' such that - all letters in w' are different; - w' is obtained from w by deleting some letters in w. Returns the list of all good subsequences, without duplicates, in lexicographic order (recall that the sorted() function sorts strings in lexicographic...
true
1f6b22d7f7903e1c207096966e2bdfcd1a1ba55d
Timothy-Myers/Automate-The-Boring-Stuff-Projects
/Projects/collatz.py
919
4.5625
5
#this program shows how the Collatz sequence works by having a user enter a number and using the sequence to get the number down to 1 #definition where the number is analyzed def collatz(number): #continues until number is 1 while number != 1: #examines if number is even if number % 2 ==...
true
189da249379adfb2f49a05d8dc55df795958ef4e
takuhartley/Python_Practice
/Dictionaries/dictionaries.py
717
4.15625
4
cars = { "brand": "Tesla", "model": "Model X", "year": 2019 } people = { "name": "Robert", "age": 22, "gender": "Male" } print(cars) x = cars["model"] print(x) x = cars.get("model") print(x) people["age"] = 1995 print(people) for x in people: print(x) for x in people: print(people[x]) for x in pe...
true
a5381669b79f9d6dab81037a9a02070097328348
NickCampbell91/CSE212FinalProject
/Final/Python/stack_2.py
1,152
4.21875
4
""" Python3 code to delete middle of a stack without using additional data structure. Write the deleteMid function where st is the call to the Stack class, n is the size of the stack, and curr is the current item number. """ class Stack: def __init__(self): self.items = [] def isEmpty...
true
fcd000e9f9879c7ef9455eb7c7d94db2f343c398
terranigmark/code-wars-python
/6th-kyu/replace_with_alphabet_position.py
643
4.40625
4
""" Welcome. In this kata you are required to, given a string, replace every letter with its position in the alphabet. If anything in the text isn't a letter, ignore it and don't return it. "a" = 1, "b" = 2, etc. Example alphabet_position("The sunset sets at twelve o' clock.") """ import string def alphabet_posit...
true
2d8292045564876ab2c3caa27664982daf0c2965
fwchj/cursoABMPythonPublic
/EjemplosCodigo/20_Hierarchy2_herencia.py
1,100
4.1875
4
# OOP with inheritance # Defining the class class Individual: # Constructor def __init__(self,salary,name,age,tenure,female): self.salary = salary self.name = name self.age = age self.tenure = tenure self.female = female # Method printing some basic information ...
true
5dbbf8d13447181eb29b7730c7881e3a28de0bbb
AntonyRajeev/Python-codes
/positivelist.py
299
4.25
4
#to find and print all positive numbers in a range list=[] n=int(input("enter the no of elements and the respective elements in the list ")) for i in range(0,n): i=int(input()) list.append(i) print("The positive integers are -") for k in list: if k>=0: print(k)
true
dabd439f38d4e1ffbff4e5f40c4b2f72240e932c
roytalyan/Python_self_learning
/Leetcode/String/Valid Palindrome.py
746
4.3125
4
# -*- coding: utf-8 -*- """ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car...
true
a85bb8418f65b352eb78a56db24be3a9b3f28212
clarkkarenl/codingdojoonline
/python_track/filter-by-type.py
1,876
4.25
4
# Assignment: Filter by Type # Karen Clark # 2018-06-02 # Assignment: Filter by Type # Write a program that, given some value, tests that value for its type. Here's what you should do for each type: # Integer # If the integer is greater than or equal to 100, print "That's a big number!" If the integer is less than 100...
true
a999e0ce0226ee0082a3228d9df34f98fac04d5c
RapheaSiddiqui/AI-Assignment-1
/q2(checking sign of a given number).py
233
4.1875
4
print ("\t\t\t***CHECKING NATURE OF A NUMBER***") num = float(input("Enter any number: ")) if (num == 0): print("It's a Zero!") if (num < 0): print("It's a Negative number!") if (num > 0): print("It's a Positive number!")
true
f019103d9d581f8f77b246cb553d964410d5300c
tnmas/python-exercises
/unit-6-assignment.py
839
4.125
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ # first we need to define the function and ask for to arguments def compare(a,b): #case 1 when the first number is greater than the second number if a > b : return 1 # case 0 when the twon numbers are equals elif a == b: retu...
true
98cdd8dadc1c159f49ee1a880d3326640e1a25e2
Success2014/Leetcode
/stringtoInteger.py
2,225
4.21875
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 02 09:46:34 2015 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be speci...
true
ef4941567063ba507df1933c92f2ada872766ceb
Success2014/Leetcode
/spiralMatrix.py
1,863
4.125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 02 13:32:07 2015 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. @author: Neo """ cl...
true
e2851deac5f5546d0c421f4edfa8b1251820531c
rahulsrivastava30/python
/Calculator.py
615
4.125
4
def calculator(first_num,second_num,operation): if(operation=='add'): return first_num+second_num elif(operation=='subtract'): return first_num-second_num else: return "error" first=(int)(input("Enter first num: ")) second=(int)(input("Enter second num: ")) symbol=input("Ent...
true
ea2b8dd0a42bbbc763c14b8510031d2eb5df1530
iri02000/rau-webappprogramming1
/seminar5/intro_612.py
404
4.1875
4
n = input("Please enter a number: ") print(type(n), n) n = int(n) print(type(n), n) n = float(n) print(type(n), n) s = "This is a string" parts = s.split(" ") print(parts) parts = s.split("is") print(parts) a = 13 % 2 # find out modul print(a) # line comment # other line comment """ This is a block of comments....
true
6b8812204a60737efe13a509304f24f92a695919
sprakaha/Python-CyberSecurity101
/Modules/Ciphers/DataConversions/convtask1.py
548
4.15625
4
## TODO: Get the user to input a number ## Return the number in binary, WITHOUT using the bin() function ## Only has to work for positive numbers ## Conver the number to binary, return as an int # DO NOT CHANGE FUNCTION NAME OR RETURN TYPE def toBinary(digit): ## Your Code Here pass ## Print out the ...
true
9e5669f5534a0b67417f3fcfebad14ece9791935
sprakaha/Python-CyberSecurity101
/Modules/Ciphers/CipherReviews/cipherintro.py
2,323
4.3125
4
## Strings Review # strings are a list of characters # "hello" -> 'h', 'e', 'l', 'l', 'o' greeting = "Hello! How are you?" # Get first character of a string # print(greeting[0]) # Get last character of a string # print(greeting[len(greeting) - 1]) # print(greeting[len(greeting)]) # this will give an error - IndexE...
true
b453b5d57be9bbdc53d67e3cd6b9b72cc1a3ae5b
octopus84/w3spython
/lambdas.py
1,111
4.5625
5
#Lambda # A lambda function is a small anonymous function. # A lambda function can take any number of arguments, # but can only have one expression. # Syntax # lambda arguments : expression x = lambda a : a + 10 print(x(4)) x = lambda a, b : a * b print(x(5,5)) x = 5#int(input("Ingresa 3 números: ")) y = 3#int(...
true
f020dd09c72558fcd5361e11b888357320142c5a
Lance117/Etudes
/leetcode/greedy/435_non_overlapping_intervals.py
775
4.1875
4
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals are non-overlapping. Greedy algorithm: 1. Select interval with the ear...
true
d4837b1ae7b35db2030dc2b7606a6d550b382483
Lance117/Etudes
/leetcode/tree/144_binary_tree_preorder_traversal.py
942
4.125
4
""" Given a binary tree, return the preorder traversal of its nodes' values. """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def preorder_traversal_rec(root): """ Time complexity: O(n) Space complexity: O(h) since size of call stack de...
true
dda83eb38db783203e4b9d73b21f8de326f857b6
Arthanadftz/Codeacademy_ex
/BankAccount.py
1,703
4.15625
4
class BankAccount(object): balance = 0 def __init__(self, name): self.name = name def __repr__(self): return '%s\'s acoount has balance: $%.2f' %(self.name, self.balance) def show_balance(self): print('Balance: $%.2f' %(self.balance)) def deposit(self, amount): if amount <= 0: print('You...
true
675c46c9b05e7fa7f74a9113a2b15f50d6bbdf21
mastermind2001/Problem-Solving-Python-
/snail's_journey.py
1,349
4.3125
4
# Date : 23-06-2018 # A Snail's Journey # Each day snail climbs up A meters on a tree with H meters in height. # At night it goes down B meters. # Program which takes 3 inputs: H, A, B, and calculates how many days it will take # for the snail to get to the top of the tree. # Input format : # 15 # For H # 1 # F...
true
9003b3a8093b7aeb22e8bbb03fe54c294f50082f
mastermind2001/Problem-Solving-Python-
/tower_of_hanoi.py
1,993
4.15625
4
# Date : 7-05-2018 # Write a program to find solution for # Tower of Hanoi Problem """ This code uses the recursion to find the solution for tower of Hanoi Problem. """ # Handle the user input try: # No. of disks (a positive integer # value greater than zero) disk = int(input("")) # Error h...
true
132764e4ca174a49d6f2d24fa51334f72bec0771
running-on-sunshine/python-exercises
/Python Exercises-102/hello.py
688
4.25
4
# ======================================================================= # # Exercises - Python 102 # # ======================================================================= # # Begin here: # ======================================================================...
true
65a3483498b5b0cedc45e141c9f57a8c2e3db83a
gophers-latam/pytago
/examples/contains.py
867
4.125
4
def main(): # Iterables should compare the index of the element to -1 a = [1, 2, 3] print(1 in a) print(4 in a) print(5 not in a) # Strings should either use strings.Compare or use strings.Index with a comparison to -1 # While the former is more straight forward, I think the latter will be ...
true
e85d2015fd1c22f8479bcb5e68487fa6b6e0696a
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/learn-python/src/control_flow/test_try.py
2,117
4.53125
5
"""TRY statement @see: https://www.w3schools.com/python/python_try_except.asp "try" statement is used for exception handling. When an error occurs, or exception as we call it, Python will normally stop and generate an error message. These exceptions can be handled using the try statement. The "try" block lets you te...
true
b28ca804bf8a7ddd093b5aac170a3f3a8b7596c9
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/02-pyth/python-ds-master/data_structures/graphs/check_if_graph_is_tree.py
1,245
4.125
4
""" A graph is a tree if - 1. It does not contain cycles 2. The graph is connected Do DFS and see if every vertex can be visited from a source vertex and check for cycle """ from collections import defaultdict class Graph: def __init__(self, vertices): self.vertices = vertices self.graph = defau...
true
4a2d64f6ae9f0e76d0278e807c0669dd8ce6ff5d
bgoonz/UsefulResourceRepo2.0
/_PYTHON/DATA_STRUC_PYTHON_NOTES/course-work/cs-guided-project-binary-search-trees/src/demonstration_2.py
1,131
4.34375
4
""" You are given a binary tree. You need to write a function that can determin if it is a valid binary search tree. The rules for a valid binary search tree are: - The node's left subtree only contains nodes with values less than the node's value. - The node's right subtree only contains nodes with values greater th...
true
d640ce7c735a28d7a21522a4ba324a81ea7f400d
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/leetcode/Sort_an_Array.py
1,079
4.25
4
# Given an array of integers nums, sort the array in ascending order. # # Example 1: # # Input: nums = [5,2,3,1] # Output: [1,2,3,5] # Example 2: # # Input: nums = [5,1,1,2,0,0] # Output: [0,0,1,1,2,5] def sortArray(nums): def helper(nums, start, end): if start >= end: return pivot =...
true
6f3983b4248adcadbd968a9cd95fdc01bfb3789f
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/DATA_STRUC_PYTHON_NOTES/course-work/cs-guided-project-hash-tables-i/src/guided.py
2,080
4.25
4
# d = { # 'banana': 'is a fruit', # 'apple' : 'is also a fruit', # 'pickle': 'vegetable', # } # a hash fucntion # -must take a string # -return a number # -must always return the same output for the same input # -should be fast storage = [None] * 8 # has a size of 8/ static array def hash_func(string, ...
true
10e97a74c79d2a0710d60765fd974f9e01866c46
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/learn-python/src/control_flow/test_break.py
798
4.21875
4
"""BREAK statement @see: https://docs.python.org/3/tutorial/controlflow.html The break statement, like in C, breaks out of the innermost enclosing "for" or "while" loop. """ def test_break_statement(): """BREAK statement""" # Let's terminate the loop in case if we've found the number we need in a range fro...
true
fbb262b3510cc4bce1df1e37005b59c96c6ad556
bgoonz/UsefulResourceRepo2.0
/_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/leetcode/Symmetric_Tree.py
1,352
4.25
4
# Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # # For example, this binary tree [1,2,2,3,4,4,3] is symmetric: # # 1 # / \ # 2 2 # / \ / \ # 3 4 4 3 class TreeNode: def __init__(self, x): self.val = x self.left = None self.rig...
true
8c3570abe515e660d278df1a404825b3d8a6f9fd
bgoonz/UsefulResourceRepo2.0
/GIT-USERS/TOM-Lambda/CS35_DataStructures_GP/problems/smallest.py
2,205
4.25
4
def smallest_missing(arr, left, right): """ run a binary search on our sorted list because we know that the input should already be sorted and this would give us a O(log n) time complexity over doing a linear search that would yield a time complexity of O(n) """ # check if...
true
5e867b0d715586f32ea76ce11d893c5979852f68
bgoonz/UsefulResourceRepo2.0
/_MY_ORGS/Web-Dev-Collaborative/blog-research/Data-Structures/1-Python/sort/bogo_sort.py
740
4.15625
4
import random def bogo_sort(arr, simulation=False): """Bogo Sort Best Case Complexity: O(n) Worst Case Complexity: O(∞) Average Case Complexity: O(n(n-1)!) """ iteration = 0 if simulation: print("iteration",iteration,":",*arr) def is_sorted(arr): #c...
true
9e8a845992e85e0c5c4b3b0d7b64232969850061
bgoonz/UsefulResourceRepo2.0
/_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/learn-python/src/functions/test_function_default_arguments.py
925
4.71875
5
"""Default Argument Values @see: https://docs.python.org/3/tutorial/controlflow.html#default-argument-values The most useful form is to specify a default value for one or more arguments. This creates a function that can be called with fewer arguments than it is defined to allow. """ def power_of(number, power=2): ...
true
f456218d7e16eec46de4f5f1259fe046207246a3
bgoonz/UsefulResourceRepo2.0
/_REPO/MICROSOFT/c9-python-getting-started/python-for-beginners/10_-_Complex_conditon_checks/code_challenge_solution.py
1,347
4.34375
4
# When you join a hockey team you get your name on the back of the jersey # but the jersey may not be big enough to hold all the letters # Ask the user for their first name first_name = input("Please enter your first name: ") # Ask the user for their last name last_name = input("Please enter your last name: ") # if fi...
true
bdfb941afe94f555350eef11bdd5549dde16bad1
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/web-dev-notes-resource-site/2-content/Python/pcc_2e-master/chapter_09/dog.py
714
4.1875
4
class Dog: """A simple attempt to model a dog.""" def __init__(self, name, age): """Initialize name and age attributes.""" self.name = name self.age = age def sit(self): """Simulate a dog sitting in response to a command.""" print(f"{self.name} is now sitting.") ...
true
8fb3d4d97fc3decf83bf2953b66dd4311fa580ff
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/02-pyth/algorithms-master/algorithms/maths/pythagoras.py
674
4.4375
4
""" input two of the three side in right angled triangle and return the third. use "?" to indicate the unknown side. """ def pythagoras(opposite, adjacent, hypotenuse): try: if opposite == str("?"): return "Opposite = " + str(((hypotenuse ** 2) - (adjacent ** 2)) ** 0.5) elif adjacent...
true
02ed1b0abb9e3d1d05e95fdf17eec352182ba901
bgoonz/UsefulResourceRepo2.0
/_MY_ORGS/Web-Dev-Collaborative/blog-research/Data-Structures/1-Python/arrays/longest_non_repeat.py
2,614
4.375
4
""" Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1. Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring,...
true
fb292ced4358a81ef561965389cda19bcb7ff34d
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/PYTHON_PRAC/leetcode/Maximize_Distance_to_Closest_Person.py
1,219
4.15625
4
# In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. # # There is at least one empty seat, and at least one person sitting. # # Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized. # # Return that maximum distan...
true
2cb7a4362a8cf521043affd8e6918a425f4b320e
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Recursion/First Index/first_index_of_array.py
601
4.125
4
# To find first index of an element in an array. def firstIndex(arr, si, x): l = len(arr) # length of array. if l == 0: # base case return -1 if ( arr[si] == x ): # if element is found at start index of an array then return that index. return si return firstIndex(arr, si +...
true
f253ed9ff0e143d23edaf116b2f0a76878bdeccb
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/Lambda-Resource-Static-Assets/2-resources/BLOG/Data-Structures/1-Python/arrays/top_1.py
947
4.28125
4
""" This algorithm receives an array and returns most_frequent_value Also, sometimes it is possible to have multiple 'most_frequent_value's, so this function returns a list. This result can be used to find a representative value in an array. This algorithm gets an array, makes a dictionary of it, finds the most freq...
true
8b8eb1e64a7760cc3eb480d2f2ec608fb8728951
bgoonz/UsefulResourceRepo2.0
/GIT-USERS/TOM-Lambda/CSEUFLEX_Data_Structures_GP/stack.py
1,626
4.3125
4
""" A stack is a data structure whose primary purpose is to store and return elements in Last In First Out order. 1. Implement the Stack class using an array as the underlying storage structure. Make sure the Stack tests pass. 2. Re-implement the Stack class, this time using the linked list implementation as the...
true