blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7f5b4896c3c47f834ff7dbb4aa5b65e2dba2437c
dj5353/Data-Structures-using-python
/CodeChef/Binary-search.py
738
4.15625
4
def binarySearch(a,n,searchValue): first = 0 last = n-1 while(first<last): mid = (first + last)//2 if(searchValue<a[mid]): last = mid-1 elif(searchValue>a[mid]): first = mid+1 else: return mid return -1 n = int(input("Enter ...
true
258d837ce4d5bfd7c4e4a7cbdc5517aec582d9e1
abusamrah2005/Saudi-Developer-Organization
/Week4/secondLesson.py
1,268
4.3125
4
# set of names , we have four names. setOfNames = {'waseem', 'ahmed', 'ali', 'dayili'} # by using len() function to calculate the number of items seted in the set print('we have ' + str(len(setOfNames)) +' names are there.') # there are two function to remove elemen in set 'remove() & discard()' print('Names: ' + st...
true
5066c5fccfc4e132798a0d04d59fb1de6e0f68da
AntonioRice/python_practice
/strings.py
752
4.1875
4
num = 3; print(type(num)); print(5 + 2); print(5 / 2); print(5 - 2); # exponents print(5 ** 2); # modulus print(5 % 2); print(4 % 2); # OOP print(3 * 2 + 4); print(3 * (2 + 4)); num = 1; num += 1; print(num); # absolute value print(abs(-3)); # round print(round(5.8901)); # how many digits id like to round to print(r...
true
d3b2a74ce570df798dc7da790b6bdfcdb20448d1
JiangRIVERS/data_structure
/LinkedBag/linked_structure.py
743
4.375
4
#定义一个单链表节点类 class Node: """Represents a singly linked node""" def __init__(self,data,next=None): """Instantiates a Node with a default next of None""" self.data=data self.next=next class TwoWayNode(Node): """Represents a doubly linked node""" def __init__(self,data,previous=Non...
true
1a51c8997f8090c61af75592596f44571005001f
JiangRIVERS/data_structure
/Calculate_arithmetic_expressions/calculate_function.py
543
4.375
4
""" Filename:calculate_function Convert string operator to real operator """ def calculate_function(string,operand1,operand2): """Raises KeyError if the string operator not in string list""" string_list=['+','-','*','/'] if string not in string_list: raise KeyError('We can\'t deal with this operator...
true
00b3c3106f95ccb9059c195315d28812ec71f1f6
RMolleda/Analytics_course
/delivery/basic_functions.py
540
4.15625
4
def append_item(item, where): """ U must set the object u want to append as the value of "object" and "where" should be the list where u want to append it """ where.append(item) def remove_item_list(item, where): """ pop the input from a list it will loop arround all the list, and if ...
true
d4c588d0811d01742dcfd25915554ea1fd06fe69
Anonymous-indigo/PYTHON
/shapes/heptagon.py
231
4.15625
4
#To draw a heptagon, you will need to have seven sides and have a 51.42 degree angle on each side. The lenth of each side will not affect the angle needed. import turtle t=turtle for n in range(7): t.forward(100) t.right(51.42)
true
6abf212d5cbd88ec6c3802cee3a9da7c4b740bcc
RuidongZ/LeetCode
/code/290.py
1,373
4.125
4
# -*- Encoding:UTF-8 -*- # 290. Word Pattern # Given a pattern and a string str, find if str follows the same pattern. # # Here follow means a full match, such that there is a bijection # between a letter in pattern and a non-empty word in str. # # Examples: # pattern = "abba", str = "dog cat cat dog" should return t...
true
e0fa225b4ed69b3234517176b2c8c3a519b93c39
RuidongZ/LeetCode
/code/451.py
1,130
4.125
4
# -*- Encoding:UTF-8 -*- # 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" # # Explanation: # 'e' appears twice while 'r' and 't' both appear once. # So 'e' must appear before both 'r' and 't'. Theref...
true
3651948d047f7ab76cba9e74c98e2b9d53a62504
RuidongZ/LeetCode
/code/537.py
1,011
4.15625
4
# -*- Encoding:UTF-8 -*- # 537. Complex Number Multiplication # Given two strings representing two complex numbers. # You need to return a string representing their multiplication. Note i2 = -1 according to the definition. # Example 1: # Input: "1+1i", "1+1i" # Output: "0+2i" # Explanation: (1 + i) * (1 + i) = 1 + i2...
true
050bb7bbddb8040a778bfae81d54776c95f375c9
Dillon1john/Python
/finalreview4finishit.py
203
4.1875
4
temp=70 humid=45 if(temp<60) or (temp>90) or (humid>50): print("Stay inside") else: if (humid==100): print("It is raining outside") else: print("Do you want to take a walk?")
true
a28854b23700b3af588a06aa525c53ad503a5ad5
Dillon1john/Python
/classworkstudynov7.py
575
4.125
4
#example of input list name=[ ] ssn=[ ] age= [ ] while True: Last_name=input("Enter your last name: ") if Last_name in name: print("Your name already in the list") else: name.append(Last_name) print("I just got your registered") Social= input("Enter your SSN: ") if So...
true
450a60088fd4913f56d817ef4681a9550ef12198
btgong/Cmpe131Homework-Python
/calculator.py
1,215
4.4375
4
def calculator(number1, number2, operator): ''' Returns the calculation of two decimal numbers with the given operator Parameters: number1 (float): A decimal integer number2 (float): Another decimal integer) operator (string): Math operation operator Returns: Calculation of number1 and number2 with ...
true
119c4153fe8a13d13ad8f522aa008623362a4218
skinisbizapps/learning-python
/ch02/loops.py
906
4.15625
4
def main(): print('welcome to loops') x = 0 # define a while loop while x < 5: print(x) x = x + 1 # define a for loop for x in range(5, 10): print(x) # use a for loop over a collection days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'] for day in day...
true
825d001f7eba45a6d8a663321370a608a7a6cbca
egalleye/katas
/two_smallest.py
659
4.1875
4
def sum_two_smallest_numbers(numbers): smallest = -1 secondSmallest = -1 for num in numbers: if ( smallest < 0 ): smallest = num else: if ( num < smallest ): secondSmallest = smallest smallest = num elif ( num < secondSmal...
true
bc69b59ed4ac02f07ca0b48a4581787feb7e6416
csouto/samplecode
/CS50x/pset6/caesar.py
1,067
4.15625
4
import sys import cs50 # Allow two arguments only, program will exit otherwise if len(sys.argv) != 2: # change error message print("Please provide one argument only") exit(1) # Use the the second argument as key k = int(sys.argv[1]) # Print instructions on screen, ask for input and calculate the length o...
true
04fb3910612a6d0bd6167dcfa7a4e7d22333522d
Wolverinepb007/Python_Assignments
/Python/prime.py
348
4.125
4
num=int(input("Enter a number: ")) i=0 n=2 while(n<num): if(num%n==0): i+=1 break n+=1 if(i==0 and num !=1 and num !=0): print(num," is a prime number.") elif(num ==1 or num ==0): print(num," is neither prime nor a composite number.") else: print(num," is not a prime ...
true
f604a334cda7df8ebcc58e105deeb911dc62a7f8
PrashantThirumal/Python
/Basics/RandomGenEclipse.py
371
4.125
4
''' Created on May 30, 2019 @author: Prashant ''' import random #Randomly generate numbers 0 to 50 com = random.randint(0,50) user = 51 while(user != com): user = int(input("Enter your guess")) if(user > com): print("My number is smaller") elif(com > user): print("My num...
true
98d5f200a0168bb4dda7ff62f14e1e4e73c016c7
golbeckm/Programming
/Python/the self-taught programmer/Chapter 14 More Object Oriented Programming/chapter_14_challenge_1.py
369
4.15625
4
# Add a square_list class variable to a class called # Square so that every time you create a new Square # object, the new object gets added to the list. class Square(): square_list = [] def __init__(self, s): self.side = s self.square_list.append((self.side)) s1 = Square(5) s2 = Square...
true
35d1c727021ecfc6c40dac30832cce0df861fb6b
golbeckm/Programming
/Python/the self-taught programmer/Chapter 3 Intro to Programming/chapter_3_challenge_5.py
323
4.25
4
# create a program that takes two varibales, # divides them, and prints the quotient. print("Give me two numbers to divide by.") variable_1 = int(input("Enter the first number: ")) variable_2 = int(input("Enter the second number: ")) print("The quotient of ", variable_1,"/", variable_2, "is", variable_1 // variable_...
true
1f694b39cee317c3c32ea34a773a98b326d87677
golbeckm/Programming
/Python/the self-taught programmer/Chapter 3 Intro to Programming/chapter_3_challenge_2.py
303
4.28125
4
# write a program that prints a message if a variable is less than 10, # and different message if the variable is less than or equal to 10. variable = int(input("Enter a number: ")) if variable < 10: print(variable, "is less than 10") elif variable > 10: print(variable, "is greater than 10")
true
ce4905f64e2981632c19df7e2e5b0c64d0dfabaf
marianpg12/pcep-tests
/block3_flow_control/test2.py
411
4.15625
4
# What is the output of the following code snippet when the : milk_left = "None" if milk_left: print("Groceries trip pending!") else: print("Let's enjoy a bowl of cereals") # Answer: Groceries trip pending! # Explanation: If the value of a variable is non-zero or non-empty, # bool(non_empty_variable) will be be T...
true
cc580e2311da3d5358d3710f044ba6b63df035f6
marianpg12/pcep-tests
/block4_data_collections/test1.py
298
4.15625
4
# What do you expect when the following code snippet is run: weekdays = ("Monday", "Tuesday", "Wednesday", "Thursday") weekdays.append("Friday") print(weekdays) # Answer: AttributeError: 'tuple' object has no attribute 'append' # Explanation: Tuples are immutable and can't be amended once created
true
d34a70c3d5ba30d5fe02f360e8946b9a3a1dbdb4
marianpg12/pcep-tests
/block5_functions/test7.py
442
4.34375
4
# What is the output of the following code def fun(a = 3, b = 2): return b ** a print(fun(2)) # Answer: 4 # Explanation: The function expects two values, but if not provided, # they can be defaulted to 3 and 2 respectively for a and b. # Note that he function calculates and returns b to the power of a. # When yo...
true
bb45e2ba337d201916858aebe6f6433cce8d14d9
Pandaradox/LC101-WeeklyAssigns
/python/ch9weekly.py
1,333
4.15625
4
# ##################################################Chapter 9 Weekly Assignment # Function to scan a string for 'e' and return a percentage of the string that's 'e' import string def analyze_text(text): es = 0 count = 0 for char in text: if char in string.ascii_letters: count += 1 ...
true
2cb987fd5d1852847c30f7cd000ed8a1f61e0a8a
akashbhanu009/Functions
/Lambda_Function.py
667
4.34375
4
'''->Sometimes we can declare a function without any name,such type of nameless functions are called anonymous functions or lambda functions. The main purpose of anonymous function is just for instant use(i.e for one time usage)''' #normally we can use 'def' keyword def square(a): print(a*a) square(10) #no...
true
0fe91c1d26853ba69130e2925e6935d5eee882f6
Adenife/Python_first-days
/Game.py
1,571
4.125
4
import random my_dict = { "Base-2 number system" : "binary", "Number system that uses the characters 0-F" : "hexidecimal", "7-bit text encoding standard" : "ascii", "16-bit text encoding standard" : "unicode", "A number that is bigger than...
true
051364e41d439c7402c6e2a7e57a5583c2bfad26
djtongol/python
/OOP/OOP.py
2,718
4.15625
4
#Basic OOP class Beach: #location= 'Cape Cod' def __init__(self, location, water, temperature): self.location= location #instance variable self.water= water self.temperature= temperature self.heat = 'hot' if temperature >80 else 'cool' self.parts= ['water'...
true
6c010e3b0462d6ea40a5966839571ed6ab0a0355
asmitapoudel/Python_Basics-2
/qs_7.py
672
4.125
4
""" Create a list of tuples of first name, last name, and age for your friends and colleagues. If you don't know the age, put in None. Calculate the average age, skipping over any None values. Print out each name, followed by old or young if they are above or below the average age. """ lioftuples=[('Shruti','Poudel',2...
true
66470c73af52ffecfa327eddf1cb32c790854aa6
mctraore/Data-Structures-and-Algorithms
/Linked Lists/linked_list.py
1,850
4.125
4
class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): def __init__(self, head=None): self.head = head def append(self, new_element): current = self.head if self.head: while current...
true
77373257b4daaa97c0703f6f92d9f7744bc5c711
drakezhu/algorithms
/random_selection/randSelect.py
1,900
4.15625
4
########################################################################## # # Tufts University, Comp 160 randSelect coding assignment # randSelect.py # randomized selection # # includes functions provided and function students need to implement # ##########################################################...
true
0e4b3a8cc3b6cb693b030e663a1f15611669233c
dineshbalachandran/mypython
/src/gaylelaakmann/1_6.py
592
4.21875
4
def compress(txt): if len(txt) < 3: return txt out = [] currchar = txt[0] count = 0 for char in txt: if char != currchar: out.append(currchar) out.append(str(count)) currchar = char count = 1 else: count += 1 ...
true
919e93118fc21b5f45a947257bee54a667752573
dakshtrehan/Python-practice
/Strings/Alternate_capitalize.py
297
4.1875
4
#Write a program that reads a string and print a string that capitalizes every other letter in the string #e.g. passion becomes pAsSiOn x=input("Enter the string: ") str1= "" for i in range(0, len(x)): if i%2==0: str1+=x[i] else: str1+=x[i].upper() print(str1)
true
1e438dd75672e236927476f9e7cfc964aba9b7f3
Minyi-Zhang/intro-to-python
/classwork/week-2/groceries.py
1,567
4.375
4
#!/usr/bin/env python3 # Built-in data type: Sequence Types # list (mutable) # groceries = list( # "apples", # "oranges", # ) groceries = [ "apples", "oranges", "pears", "kiwis", "oranges", "pears", "pears", ] # print(groceries[3:6]) # example: groceries.count(x) # Return the nu...
true
9a40697a33b75f341c3c4aeb502f4bb3051618db
RdotSilva/Harvard-CS50
/PSET6/caesar/caesar.py
1,022
4.125
4
from sys import argv from cs50 import get_string def main(): # Check command line arguments to make sure they are valid. if len(argv) == 2: k = int(argv[1]) if k > 0: print(k) else: print("NO") else: print("Invalid Input") exit(1) # Prom...
true
946c278ccc0a1e0a26c8c87b1b10f3dd201701ec
rohanaurora/daily-coding-challenges
/Problems/target_array.py
1,098
4.34375
4
# Create Target Array in the Given Order # Given two arrays of integers nums and index. Your task is to create target array under the following rules: # # Initially target array is empty. # From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array. # Repeat the previous st...
true
acbc16d28d1eecdf125d26a44572ee035857fb15
lungen/Project_Euler
/p30-digit-fifth-powers-0101.py
1,381
4.1875
4
<<<<<<< HEAD """ Digit fifth powers Problem 30 Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 84 + 24 + 04 + 84 9474 = 94 + 44 + 74 + 44 As 1 = 14 is not a sum it is not included. The sum of these numbers i...
true
323921991a78e974ed30a01d14b01ec1b2f5ffb0
lungen/Project_Euler
/_training_/codes/001.001_recursive_memoization_fibonacci.py
885
4.34375
4
""" Published on 31 Aug 2016 Let’s explore recursion by writing a function to generate the terms of the Fibonacci sequence. We will use a technique called “memoization” to make the function fast. We’ll first implement our own caching, but then we will use Python’s builtin memoization tool: the lru_cache decorator. To ...
true
749c0846784ae81b34c06c09115e6102b42d63d1
mikaelbeat/The_Python_Mega_Course
/The_Python_Mega_Course/Basics/Check_date_type.py
570
4.15625
4
data1 = 5 data2 = "Text" data3 = 3 print("\n***** Data is int *****\n") print(type(data1)) print("\n***** Data is str *****\n") print(type(data2)) print("\n***** Check data type *****\n") if isinstance(data3, str): print("Data is string") elif isinstance(data3, int): print("Data is interg...
true
63b5273dd2d85b4b412522e61266430592ba4b30
RajeshNutalapati/PyCodes
/OOPs/Inheritence/super() or function overriding/super with single level inheritance_python3.py
1,115
4.25
4
''' Python | super() function with multilevel inheritance super() function in Python: Python super function provides us the facility to refer to the parent class explicitly. It is basically useful where we have to call superclass functions. It returns the proxy object that allows us to refer parent class by 'super'. T...
true
48626c838ebc03ddbf36ea98d78c7186359a332e
RajeshNutalapati/PyCodes
/OOPs/Inheritence/super() or function overriding/super with multilevel inheritence_python3.py
1,727
4.40625
4
''' Python super() function with multilevel inheritance. As we have studied that the Python super() function allows us to refer the superclass implicitly. But in multi-level inheritances, the question arises that there are so many classes so which class did the super() function will refer? Well, the super() function h...
true
a22d680571411459964d7db525fe155ab2fe09b6
RajeshNutalapati/PyCodes
/DataAlgorithms/LinkedLists/single linked list.py
701
4.25
4
# make node class #creating singly linked list class Node: def __init__(self,data): self.data = data self.next = None #initializing next to null class LinkedList: def __init__(self): self.head = None #This will print the contents of the linked list #starting from head def ...
true
534d5357b9157fd8f63b8576226e003b4f132806
lare-cay/CSCI-12700
/10-16-19.py
1,217
4.25
4
#Name: Clare Lee #Email: Clare.Lee94@myhunter.cuny.edu #Date: October 16, 2019 #This program modifies a map according to given amount of blue crating a new image import numpy as np import matplotlib.pyplot as plt blue = input("How blue is the ocean: ") file_name = input("What is the output file: ") #Read ...
true
151dcc61aadad894cfffbd9f28deb772f130d578
clush7113/code-change-test
/linearSearch.py
357
4.1875
4
testString = "" searchChar = "" newChar= "" while testString == "" and len(searchChar) != 1 and newChar=="": testString = input("Please enter some text to search : ") searchChar = input("Enter a character to search for : ") newChar = input("What would you like to replace the character with? : ") print(tes...
true
cddc867538535903d69e4795aaf554bb3260c602
puntara/Python-
/Module3/m1_m2_concat_dict.py
445
4.4375
4
#1) Write a Python script to concatenate following dictionaries to create a new one. dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} result1={**dic1, **dic2, **dic3} print(result1) #2) Write a Python script to generate and print a dictionary that contains a number # (between 1 and n) in the form (x, x*x). nu...
true
465bae6eadd928fbd7fd9cf3c80fc8de3dbbb0b7
UjjwalSaini07/Tkinter_Course_1
/Tkinter_13.py
983
4.46875
4
# https://www.codewithharry.com/videos/python-gui-tkinter-hindi-19 # todo : Sliders In Tkinter Using Scale() from tkinter import * import tkinter.messagebox as tmsg root = Tk() root.geometry("455x233") root.title("Slider tutorial") # get(): This method returns the current value of the scale. # set(value):...
true
e23c1a608d0172466d94f7619215a3df61b0bd84
RandyKline/Self_Paced-Online
/students/ian_letourneau/Lesson03/slicing_lab.py
2,973
4.25
4
## Ian Letourneau ## 4/26/2018 ## A script with various sequencing functions def exchange_first_last(seq): """A function to exchange the first and last entries in a sequence""" middle = list(seq) middle[0] = seq[-1] middle[-1] = seq[0] if type(seq) is str: return "".join(middle) elif t...
true
14537d1a3dfbd4423de9ae80124510d697435069
leelu62/PythonPractice
/BirthdayDictionary.py
336
4.53125
5
#store family and friend's birthdays in a dictionary #write a program that looks up the birthday of the person inputted by the user birthdays_dict = {"Amon":"10/03/2016","Christopher":"12/18/1983","Jenna":"6/2/1985"} person = input("Whose birthday would you like to look up? ") print(person + "'s birthday is",birthdays_...
true
f0a1e316b9c2c0f0d740326ab98c0a6040460f6b
leelu62/PythonPractice
/StringLists.py
374
4.5
4
# ask user to input a word, then tell user whether or not the word is a palindrome word = input("Please enter a word for palindrome testing: ") letters_list = [] for letter in word: letters_list.append(letter) reverse = letters_list[::-1] if letters_list == reverse: print("Your word is a palindrome!") else: ...
true
99b3f30eff84ec601734b54f2bdf596fda25fc37
Stevella/Early-days
/regexSearch.py
1,092
4.3125
4
# python 3 #regexSearch.py opens all .txt files in a folder and searches for any # line that matches a user-supplied regular expression. results are printed to the screen import os,re,glob,sys #print(sys.argv[1]) if len(sys.argv) < 3: #ask for directory and regexpattern if commandline arguments is insufficien...
true
eae604c50b0450db7ee01da3b9600149bdca2ac2
mark-kohrman/python_practice
/python_practice.py
1,626
4.25
4
# 1. Write a while loop to print the numbers 1 through 10. i = 1 while i <= 10: print i i = i + 1 # # # 2. Write a while loop that prints the word "hello" 5 times. i = 1 while i <= 5: print "hello" i += 1 # 3. Write a while loop that asks the user to enter a word and will run forever until the user enters th...
true
6afdce799ca7121e1ce5cf1274660407706cf732
diketj0753/CTI110
/P2_PayRate_DiketJohn.py
472
4.25
4
Hours=float(input('How many hours did you work last week? ')) # Creates a variable named PRate with user generated information. GrossPay=float(input('How much did you make over this time? ')) # Multiplies the two variables together to determine Gross Pay and rounds to # two decimal places. PRate=float(GrossPay...
true
7d8f996b50024904bdabed331ba996578ab1dd44
planets09/HB_Final-Project
/ToDoList.py
1,459
4.15625
4
#NOTE: Final project Rena_to_do = {"Shopping":"Groceries", "Pay_Bills":"Rent", "Pay_Utilities":"Water, Heat and Electric", "Repair": "Car", "Pet_Care": "Dog grooming"} print "Welcome to Rena's TO DO List!" while(True): instructions = "Type A to see list., Type B to see Shopping, Type C to see Pay_Bills, Type D...
true
fe33f96dae69f5469d83f9c69f7df77d4862557d
Irlet/Python_SelfTraining
/Find_multiply.py
750
4.625
5
""" In this simple exercise, you will build a program that takes a value, integer, and returns a list of its multiples up to another value, limit. If limit is a multiple of integer, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limit will...
true
d40b3893bef288d7a47b2ddb1537df43e3a6c85b
Irlet/Python_SelfTraining
/Text_analyser_1st_lvl.py
1,107
4.1875
4
# Ask over text and check: no. of characters, find vowels, every second char., no. of letters in words, # find indicated character and element my_text = input("Enter text: ") number_of_text_char = len(my_text) my_text_splitted = my_text.split() vowels = "AaEeIiOoUuYy" vowels_in_text = [] every_second_char = [] print(...
true
a272c7266131e411c60eefaa5c2474dd466b780a
abanuelo/Code-Interview-Practice
/LeetCode/Google Interview/Interview Process/lisence-key-formatting.py
2,189
4.15625
4
''' You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the first group which could be sho...
true
20fa547df238d952da01752d372a0e7118214c89
dcantor/python-fun1
/dictionaries/dictionary1.py
526
4.53125
5
# Dictionary sample (key value pair) food = {'chocolate' : 101, 'cheese' : 102, 'soup' : 103} print "Food dictionary is: " print food print # what is the value for key chocolate print food['chocolate'] print # for loop test print "iterate over the food dictionary" for x in food: print food[x] # add new key/val...
true
b7d768961b7dfa886096d40d0c808e04a9fc03f1
vtu4869/Hangman
/hangmen.py
2,664
4.28125
4
#author: Vincent Tu #modules to use for the game import time import random #Asked for the username name = input("Input your player name: ") choice = False #Different difficulties choice of words for the user to choose ListOfDifficulties = [" ", "easy", "medium", "hard"] EasyWords = ["listen", "phones", "games", "smil...
true
0ea1e3024677c97325c93bf4d7984b11521d64b6
CereliaZhang/leetcode
/217_Contains_Duplicate.py
745
4.125
4
''' Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,2,3,4] Output: false Example 3: Input:...
true
a41aef1333c2dbfef42e99ef46b288dd2cfeffc7
yousuf550/Basic_Python_Projects
/Grocery_Cashier.py
1,452
4.21875
4
#Grocery Store ''' The program evaluates the total bill price and the discount price of the bill according to the membership grade. The product price and buying list are both presented in dictionary format. Then we create two functions that read the dictionaries to get the bill price and the discount price. ''' ...
true
fd0035ec10de79eb8fe60970267e7780238b7a11
Sumedh3113/Python-codes
/pangram.py
796
4.21875
4
""" Write a Python function to check whether a string is pangram or not. Note : Pangrams are words or sentences containing every letter of the alphabet at least once. For example : "The quick brown fox jumps over the lazy dog" """ import string def ispangram(str1, alphabet=string.ascii_lowercase): str1.lower() ...
true
7e047589467b22af0f793518d32f31b4c583da4a
yenandrew/CIS3260
/Assignment 1/Chapter 3/Assignment 3.9.py
1,102
4.3125
4
#Write a program that reads the following information and prints a payroll statement: #Employee’s name (e.g., Smith) #Number of hours worked in a week (e.g., 10) #Hourly pay rate (e.g., 9.75) #Federal tax withholding rate (e.g., 20%) #State tax withholding rate (e.g., 9%) name=input("Enter employee's name: ") ...
true
be34debf56b4f2435eda7501f8b78cdb6d6b3f9c
yenandrew/CIS3260
/Assignment 1/Chapter 4/Assignment 4.8.py
370
4.3125
4
# (Sort three integers) Write a program that prompts the user to enter three integers # and displays them in increasing order. n1, n2, n3 = eval(input("Enter 3 integers separated by commas no spaces")) if n1 > n2: n1, n2 = n2, n1 if n2 > n3: n2, n3 = n3, n2 if n1 > n2: n1, n2 = n2, n1 print("So...
true
f08d2357990b536e5dd686f565d4c9973b99eccc
tecnoedm/PyChat
/PyChat/client/gui/helper/stack.py
1,328
4.1875
4
#!/usr/bin/env python2 ## # PyChat # https://github.com/leosartaj/PyChat.git # # Copyright (c) 2014 Sartaj Singh # Licensed under the MIT license. ## """ Upper key and lower key functionality when pressed gives last written text """ class stack: """ Makes a stack that can be cycled up and down "...
true
5859033462563e5a8977e2dd568bbb75f78807f8
Martijnde/Jupyter_Portfolio
/Python basics/Regular expressions.py
1,457
4.28125
4
#A regular expression is a sequence of characters that describes a search pattern. #In practice, we say that certain strings match a regular expression if the pattern can be found anywhere within those strings (as a substring). #The simplest example of regular expressions is an ordinary sequence of characters. Any st...
true
8b1385f2e1e7646d18c29b309c2d78cdb6661d8a
georich/python_bootcamp
/rock_paper_scissors/rps_ai.py
1,386
4.375
4
from random import choice player_wins = 0 computer_wins = 0 to_win = 3 print("Time to play rock paper scissors, first to three wins!") while player_wins < to_win and computer_wins < to_win: player = input("Enter your choice: ").lower() computer = choice(["rock", "paper", "scissors"]) print(f"The computer ...
true
030d63e2bb296078a7306d414dcd5e5a0212d540
georich/python_bootcamp
/lambdas_and_builtin/filter.py
676
4.15625
4
# returns only values which return true to the lambda l = [1, 2, 3, 4] evens = list(filter(lambda x: x % 2 == 0, l)) print(evens) # combining filter and map names = ["Lassie", "Colt", "Rusty"] #return a list with the string "Your instructor is " # + each value in array, only if less than 5 characters # sends filte...
true
8346b24ee1c6abb2484391b16940152612a48af4
gadtab/tutorials
/Python/ex01_ConvertKM2Miles.py
218
4.15625
4
print("This program converts kilometers to miles") number = float(input("Please enter a number in kilometers: ")) print("You have entered", number, "km") print("which is", round(number / 1.609344, 4), "miles")
true
79ebe029b626361c6a180e10949585183bafcbc3
niuniu6niuniu/Leetcode
/IV-Perm&Comb.py
562
4.25
4
# # # Combination # # # # Example # For several given letters, print out all the combination of it's letters # Input: 1 2 3 # Output: 1 2 3 # 1 3 2 # 2 1 3 # 2 3 1 # 3 1 2 # 3 2 1 from itertools import permutations,combinations def comb(n,*args): _list = [] ...
true
abb6d702f4d52de7239e13a6d601a6578444243b
niuniu6niuniu/Leetcode
/LC-Robot_Moves.py
1,521
4.1875
4
# # # Robot Return to Origin # # # # There is a robot starting at position (0, 0), the origin, on a 2D plane. # Given a sequence of its moves, judge if this robot ends up at (0, 0) # after it completes its moves. # The move sequence is represented by a string, and the character moves[i] # represents its ith ...
true
37d300cd616de4bde0c9d60c6c0cbcf722c6805e
niuniu6niuniu/Leetcode
/Sort_Heap.py
1,037
4.15625
4
# Heap Sort # Best case & Worst case: O(nlogn) # Average case: O(nlogn) # Idea: Build max heap & Remove # Heapify # Set root at index i, n is the size of heap def heapify(arr, n, i): largest = i # Initialize largets as root l = 2 * i + 1 # Left child r = 2 * i + 2 # Right child ...
true
1cbe3db493217a7e138404e710b221e9d2424532
periyandavart/ty.py
/leap.py
285
4.125
4
print("Enter the year") year=input() if ((year%4==0)and(year%100!=0)): print("The year is a leap year") elif((year%100==0)and(year%400==0)): print("The year is a leap year") elif(year%400==0): print("The year is a leap year") else: print("The year is not a leap year")
true
d78dfa16dff3d735f5ec17d5b757ee279741d52b
changwang/Union-Find
/src/datastructure.py
1,550
4.25
4
''' Created on Nov 8, 2009 @author: changwang Define some data structures that could be used by other data structure. ''' class Node: ''' The node class represents the node in the disjoint set and union-find tree. ''' def __init__(self, value): ''' construct function. ''' # The ...
true
3a7b06004f0d3f2079c7adcb3c808b85c666de9e
pawwahn/python_practice
/searches/bisect_algorithm.py
833
4.21875
4
# Python code to demonstrate the working of # bisect(), bisect_left() and bisect_right() # importing "bisect" for bisection operations import bisect # initializing list li = [1, 3, 4, 4, 4, 6, 7] # using bisect() to find index to insert new element # returns 5 ( right most possible index ) print ("The rightmost inde...
true
0f2637e48a465145b7aaedd032287a493d250998
pawwahn/python_practice
/dateutil/no_of_days_since_a_date.py
382
4.46875
4
# Python3 program to find number of days # between two given dates from datetime import date def numOfDays(date1, date2): return (date2 - date1).days cur_date = date.today() #print(cur_date) yy,mm,dd = cur_date.year, cur_date.month, cur_date.day #print(yy,mm,dd) # Driver program date1 = date(1947, 12, 13) date...
true
081a411eaa519f60eb34c97f5653f6ba1a0e4f54
pawwahn/python_practice
/oops_python/create_class_and_object_in_python.py
426
4.21875
4
class Parrot: # class attribute species = 'bird' #instance attribute def __init__(self,name,age): self.name = name self.age = age #instantiating the class blu = Parrot("blu",5) #prints the class object print(blu) # 1st way of retriving class attribute print(Parrot.species) #2nd way ...
true
bf135b43e94f7e7863b621876f4e5e415e431911
pawwahn/python_practice
/mnc_int_questions/data_abstraction.py
1,157
4.28125
4
class Employee: __count = 10 def __init__(self): Employee.__count = Employee.__count+1 def display(self): print("The number of employees",Employee.__count) def __secured(self): print("Inside secured function..") def get_count(self): print("Employee count is :",Emp...
true
c9cbfafce0956bb999662e6ad30ff458c2bf7ea4
pawwahn/python_practice
/exceptions/except2.py
356
4.15625
4
lists = ['white','pink','Blue','Red'] clr = input('Enter the color you wish to find ??') print(clr) try: if clr in lists: print ("{} color found".format(clr)) else: print("Color not found ") except Exception as e: print (e) print ("IOException: Color not found") finally: print("There...
true
036925d524f9407f11d1fc957881ef8c565d03b4
pawwahn/python_practice
/numpy concepts/numpy1.py
657
4.53125
5
import numpy as np a = np.array([1,2,3]) print("The numpy array created is {}".format(a)) print("The numpy array type is {}".format(type(a))) print("The length of numpy array is {}".format(len(a))) print("The rank of numpy array is {}".format(np.ndim(a))) print("*************") b = np.array([(1,2,3),(4,5,6,7)]) print...
true
c6b80e32d305b9007a2a2f38cc2ae25b1d3c5afc
Viveknegi5832/Python-
/Practicals.1.py
1,155
4.59375
5
''' Ques.1 Write a function that takes the lengths of three sides : side1, side2 and side3 of the triangle as the in put from the user using input function and return the area and perimeter of the triangle as a tuple. Also , assert that sum of the length of any two sides is greater than the third side ''...
true
855ff19d45c7bde65a07fc84a27cc10bc848919f
Viveknegi5832/Python-
/Practicals.7.py
2,282
4.34375
4
''' Ques.7 Write a menu driven program to perform the following on strings : a) Find the length of string. b) Return maximum of three strings. c) Accept a string and replace all vowels with “#” d) Find number of words in the given string. e) Check whether the string is a palindrome or not. ''' def len_st...
true
deb484aa1ad4612c916100e222b7629065824a6b
asadmshah/cs61a
/week2/hw.py
1,689
4.15625
4
""" CS61A Homework 2 Asad Shah """ from operator import add from operator import mul def square(x): """ Return square of x. >>> square(4) 16 """ return x * x # Question 1 def summation(n, term): """ Return the sum of the first n terms in a sequence. >>> summation(4, square) 30 """ t, i = 0, 1 while i...
true
a48bf0b58650a53816aaa76dafee51b5bc369ae5
marcmanley/mosh
/python_full/HelloWorld/test.py
972
4.28125
4
# How to print multiple non-consecutive values from a list with Python from operator import itemgetter animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'dog', 'cat', 'cardinal'] print(itemgetter(0, 3, 4, 1, 5)(animals)) print(animals) print(type(animals)) # Slicing indexes course_name = "Pytho...
true
5b05967d412a28c2085b2de504eec80831b6f67b
maskalja/WD1-12_Functions
/12.3_Geography Quiz/main.py
429
4.15625
4
import random count = 0 capitals = {"Slovenia": "Ljubljana", "Austria": "Vienna", "Hungary": "Budapest", "USA": "Washington"} countries = ["Slovenia", "Austria", "Hungary", "USA"] for country in countries: count += 1 r = random.randint(0, count-1) answer = input(f"What is the capital of {countries[r]}? ") if an...
true
37f5758d6dd77e5a90ccb4a4fd11e8f8b8649041
kevinjyee/PythonExcercises
/Excercise02_21.py
480
4.4375
4
'''Write a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month. Here is a sample run of the program: ''' def main(): interest = .05; total = 0; savings = int(input("Enter the monthly saving amount: ")); for i in range(0,6): savi...
true
bad718105eadf1f0206a4335278b0f74415f457b
kevinjyee/PythonExcercises
/Excercise04_19.py
510
4.3125
4
'''(Compute the perimeter of a triangle) Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of every pair of two edges is greater than the remaining edge. Here is a sample run''' def main()...
true
5e47ac70f312466460693882b93afc8746a3017b
Barret-ma/leetcode
/63. Unique Paths II.py
1,807
4.28125
4
# A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). # The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). # Now consider if some obstacles are added to...
true
f6b4a44ec75285d1d43e9767e3c0ed3a6cde25ca
Barret-ma/leetcode
/543. Diameter of Binary Tree.py
1,407
4.375
4
# Given a binary tree, you need to compute the length of the # diameter of the tree. The diameter of a binary tree is the # length of the longest path between any two nodes in a tree. # This path may or may not pass through the root. # Example: # Given a binary tree # 1 # / \ # 2 3 # ...
true
4b8d187a174a15db189f2095ccd00d689b4b991a
Barret-ma/leetcode
/112. Path Sum.py
1,507
4.125
4
# Given a binary tree and a sum, determine if the tree has # a root-to-leaf path such that adding up all the values along # the path equals the given sum. # Note: A leaf is a node with no children. # Example: # Given the below binary tree and sum = 22, # 5 # / \ # 4 8 # / / \ # 11 13 4 # ...
true
aea69a498caab1fe218aa0df397d93e9e5a937d7
alexanch/Data-Structures-implementation-in-Python
/BST.py
2,038
4.28125
4
""" Binary Search Tree Implementation: search, insert, print methods. """ class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None class BST(object): def __init__(self, root): self.root = Node(root) def insert(self, new_val): ...
true
3ef383f3fa3969f09a16c32ae03a47a039b42737
Ibbukanch/Python-programs
/pythonprograms/Algorithm/sqrtnewton.py
255
4.46875
4
# program to find the sqrt of number using newton method # Take input from user n=float(input("Enter the Number")) t = n # calculates the sqrt of a Number while abs(t- n/t) > 1e-15 * t: t = (n/t + t) / 2 # Print the sqrt of a number print(round(t,2))
true
b701916d7032b3449af2d316638b828cfcbe4267
ajaybhatia/python-practical-2020
/27-practical.py
1,289
4.125
4
''' Practical 27 Perform following operations on dictionary 1) Insert 2) delete 3) change ''' book = { 1: "Compute sum, subtraction, multiplication, division and exponent of given variables input by the user.", 2: "Compute area of following shapes: circle, rectangle, triangle, square, trapezoid and parallel...
true
056eec7bf4c59ea34c4248341d289d168cff0771
imshile/Python_Regex_Engine
/Python_Regex_Search_Vs_Match.py
2,149
4.375
4
# Python Regex # re Regular expression operations. # This module provides regular expression matching operations similar to those found in Perl. # Both patterns and strings to be searched can be Unicode strings (str) as well as 8-bit strings (bytes). # However, Unicode strings and 8-bit strings cannot be mixed: th...
true
6a62677db52869b3aeb03c3c1ee041a98623ab91
imshile/Python_Regex_Engine
/Python_Regular_Expressions_Named_Group.py
2,785
4.3125
4
# Python Regular Expressions # Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python # and made available through the re module. Using this little language, you specify the rules for the set of possible strings that you w...
true
aa61fb4c0ea2ae4e8d0b3c89c1e3c690d056a993
PabloNunes/AceleraDev
/2_Segundo_Modulo/main.py
2,437
4.3125
4
from abc import ABC, abstractclassmethod class Department: # Department class: Stores department name and code def __init__(self, name, code): self.name = name self.code = code class Employee(ABC): # Employee class: A abstract class for inheritance # Constants for our Employees ...
true
cf428b248dd28892aba4affa59ddb983211cc495
andrefisch/EvanProjects
/text/emailsToSpreadsheet/splitNames.py
1,054
4.21875
4
# Extract first, last, and middle name from a name with more than 3 parts # determine_names(listy) def determine_names(listy): dicty = {} lasty = [] middley = [] # first spot is always first name at this point dicty['first_name'] = listy[0] dicty['middle_name'] = "" dicty['last_name'] ...
true
be6d059dbd1b40680f329f5f38330c506e32f85e
ontasedu/eric-courses
/python_advanced_course/Ericsson Python Adv Solutions/q1_nested_if.py
783
4.1875
4
''' Get the user to input a list of numbers. Then output a menu for the user to select either the sum/average/max/min. Then execute the selected function :- - using nested ifs - using a dict ''' from __future__ import division def average(numbers): return sum(numbers) / len(numbers) 'get user to ...
true
307264ac158f25b11562a3f745eaec1d71c4e8ef
jonyachen/TestingPython
/bubblesort3.py
735
4.28125
4
#Bubble sort that's a combo of 1 and 2. while and for loop geared towards FPGA version myList = [5, 2, 1, 4, 3] def bubblesort(list): max = len(list) - 1 sorted = False i = 0 j = i + 1 while not sorted: sorted = True for j in range(0 , max): # or (0, length) a = lis...
true
c7c79c54d109229c76ebf8c4ad5b6a309958385c
AlexandreBalataSouto/Python-Games
/PYTHON BASICS/basic_05.py
363
4.28125
4
#List names = ["Alo","Marco","Lucia"] print(len(names)) print(names) names.append("Eustaquio") print(names) print(names[1]) print(names[0:3]) print("------------------Loop 01--------------------------") for name in names: print(name) print("------------------Loop 02--------------------------") for index in r...
true
41f389f0a9213dc6aada4ae8ffc136e7133a9145
dinglight/corpus_tools
/scripts/char_frequency.py
1,071
4.375
4
"""count the every char in the input file Usage: python char_frequency.py input_file.txt """ import sys import codecs def char_frequency(file_path): """count very char in the input file. Args: file_path: input file return: a dictionary of char and count """ char_count_dict = dict()...
true