blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ed5388f3c390d596cd6a2927960cf28e0065d8d2
ceeblet/OST_PythonCertificationTrack
/Python1/python1Homework/caserFirst.py
1,284
4.34375
4
#!/usr/local/bin/python3 """ caser.py """ import sys def capitalize(mystr): """ capitalize(str) - takes a string and returns the string with first letters capitalized. """ print(mystr.capitalize()) def title(mystr): """ title(str) - takes a string and returns the string in title form. ...
true
4c490de53e3bed60e94a60e4229cffb4181d7ed8
dotnest/pynotes
/Exercises/swapping_elements.py
284
4.21875
4
# Swapping list elements def swap_elements(in_list): """ Return the list after swapping the biggest integer in the list with the one at the last position. >>> swap_elements([3, 4, 2, 2, 43, 7]) >>> [3, 4, 2, 2, 7, 43] """ # your code here
true
d859287b31a1883963543dea6c9f335ade0c0755
Jokekiller/Theory-Programmes
/Program converting ASCII to text and other way.py
956
4.125
4
#Harry Robinson #30-09-2014 #Program converting ASCII to text and other way print("Do you want to convert an ASCII code ? (y/n)") response = input() if response == "y": ASCIINumber = int(input("Give an ASCII number")) ASCIINumberConverted = chr(ASCIINumber) print("The ASCII number is {0} in text c...
true
0f4085b0b240aab78424953c0a66eeb09e6b019e
krouvy/Useless-Python-Programms.-
/18 - Checking the list for parity/pop_break.py
707
4.21875
4
""" This program checks the list items for odd parity. If all elements are even, then the list will be empty. Because the "pop ()" method cuts out the last item from the list. """ List = list(map(int, input("Enter your digit values ").split())) # Entering list items separated by a space while len(List) > 0: # Execut...
true
4e93aec8e1cf56a3fc4610ac438fb50d77a856b8
yding57/CSCI-UA-002
/Lecture 3.py
2,238
4.15625
4
#Data types # "=" is an assignment operator # x=7+"1.0" this is ERROR answer = input("Enter a value: ") print(answer,type(answer)) n1 = input("Number 1: ") n2 = input('Number 2: ') #convert this into an integer n1_int = int(n1) n2_int = int(n2) print(n1_int + n2_int) #different from: print(n1 + n2) #简便convert的方法:ne...
true
607b6d533f1ac9a6ca74f04edcb43f50ad164b4d
AMRobert/Word_Counter
/WordCounter_2ndMethod.py
268
4.1875
4
#WORD COUNTER USING PYTHON #Read the text file file = open(r"file path") Words = [] for i in file: Words.extend(i.split(" ")) print(Words) #Count the Number of Words Word_Count=0 for x in range(len(Words)): Word_Count = Word_Count + 1 print(Word_Count)
true
b4ad1c25c8d0ecee08a1a48787fb7c116bcba965
igotboredand/python-examples
/loops/basic_for_loop.py
514
4.59375
5
#!/usr/bin/python3 # # Python program to demonstrate for loops. # # The for loop goes through a list, like foreach in # some other languages. A useful construct. for x in ['Steve', 'Alice', 'Joe', 'Sue' ]: print(x, 'is awesome.') # Powers of 2 (for no obvious reason) power = 1 for y in range(0,25): print("...
true
00587653e7706bed6683f00538a9e22f00590cdc
FengdiLi/ComputationalLinguistic
/update automation/menu_update.py
2,857
4.15625
4
#!/usr/bin/env python import argparse import re def main(old_menu, new_menu, category_key, update_key): """This main function will read and create two dictionaries representing the category keys and update keys, then check and update the price according to its multiplier if the item is associated wit...
true
6172e61f25108eec6aee06c155264e74441ee10c
bacizone/python
/ch5-bubble-report.py
2,046
4.3125
4
#Pseudocode for Ch5 2040 excercise #First we have a list with solutions and their scores. We are writing a loop where it iterates until all solution -score pair are output to the screen. #Second: using the len function we display the total number of bubble tests, that is the number of elements in the list. #Then we nee...
true
b3f3acc08c5777696db004a6ccabcb09c1dd3c36
kirankumarcs02/daily-coding
/problems/exe_1.py
581
4.125
4
''' This problem was recently asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this in one pass? ''' def checkSumPair(input, k): givenNumbers = set(...
true
bc4126d785715c1aebf52f99fbafea90fc21f6fe
kirankumarcs02/daily-coding
/problems/exe_40.py
704
4.1875
4
# This problem was asked by Google. # # Given an array of integers where every integer occurs three # times except for one integer, which only occurs once, # find and return the non-duplicated integer. # # For example, given [6, 1, 3, 3, 3, 6, 6], # return 1. Given [13, 19, 13, 13], return 19. def get_non_duplicate(a...
true
63c881db45cfac236675707f637c29c74f86d257
bhanuxhrma/learn-python-the-hard-way
/ex16.py
882
4.1875
4
from sys import argv script, filename = argv #some important file operations #open - open the file #close - close the file like file -> save ... #readline - read just one line of the text #truncate - Empties the file watch out if you care about file #write('stuff') - write "stuff" to the file print("we are going to er...
true
fd25c5909d3329a11e7eed49c14d08dfbf81ec95
deepakmarathe/whirlwindtourofpython
/string_regex/regex_syntax.py
1,772
4.21875
4
# Basics of regular expression syntax import re # Simple strings are matched directly regex = re.compile('ion') print regex.findall('great expectations') # characters with special meanings # . ^ $ * + ? { } [ ] \ | ( ) # Escaping special characters regex = re.compile('\$') print regex.findall(r"the cost is $100") ...
true
380cccfd40ee68bf5ffa1a99d145cffcd1fa6d4b
TETSUOOOO/usercheck
/passwordDetect.py
1,058
4.4375
4
#! python3 # passwordDetect.py - Ensures that password is 8 characters in length, at least one lowercase and one uppercase letter, # and at least one digit # saves accepted passwords into a json file import json, re filename = 'passwords.json' def passwordDetector(text): """Uses a regex to parse the user input c...
true
c23b9c26d90994d5aac03bdeb8cf2c038762336c
davekunjan99/PyPractice
/Py6.py
218
4.28125
4
string = str(input("Enter a string: ")) revString = string[::-1] if(string == revString): print("Your string " + string + " is palindrome.") else: print("Your string " + string + " is not palindrome.")
true
659de313db36bb521842ba837228b6fd87d66b52
davekunjan99/PyPractice
/Py11.py
455
4.375
4
num = int(input("Please enter a number: ")) def checkPrime(num): isPrime = "" if num == 1 or num == 2: isPrime = "This number is prime." else: for i in range(2, num): if num % i == 0: isPrime = "This number is not prime." break else: ...
true
f5686d3db18f0f77a679085954f752e648f8e5f4
mjixd/helloworld-sva-2018
/week2/mjstory.py
1,551
4.5
4
# let the user know what's going on print ("Welcome to MJ World!") print ("Answer the questions below to play.") print ("-----------------------------------") # variables containing all of your story info adjective1 = raw_input("Enter an adjective: ") food1 = raw_input("What is your favorite food?: ") location1 = raw...
true
e90ff02843379fd3ff97a9ff61ab7fc351039e03
binthafra/Python
/2-Python Basics 2/6-iterable.py
422
4.1875
4
#iterable -list ,dict,tuple,set,string # iterable ->ono by one check each item in the collection user = { 'name': "afra", 'age': 20, 'can_swim': False } # print only keys for item in user: print(item) for item in user.keys(): print(item) # print key and value for item in user.items(): print(ite...
true
6cc518e1a3e69721374315bcced5aed005cb4d75
jwodder/euler
/digits/euler0055.py
1,808
4.125
4
#!/usr/bin/python """Lychrel numbers If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. ...
true
3ade90c1e0cac84869460cd0aa453552002528d5
jwodder/euler
/euler0173.py
1,745
4.15625
4
#!/usr/bin/python """Using up to one million tiles how many different "hollow" square laminae can be formed? We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can f...
true
d81f15a0dd213f3f16396fbe09213fa0b90a3273
paulknepper/john
/guess_your_number.py
2,836
4.4375
4
#!/usr/local/bin/python3 # guess_your_number.py """ Guess Your Number rules: I, the computer, will attempt to guess your number. This is the exact opposite of the proposition made in guess_my_number.py. You must pick a number between one and ten. I will make a guess. If I am incorrect, tell me if I ...
true
4258ab9b79c0d20997c84a2d6d4414bc29d953e1
Nathan-Zenga/210CT-Coursework-tasks
/cw q9 - binary search 2 - adapted.py
1,448
4.15625
4
number1 = int(input("1st number: ")) number2 = int(input("2nd number: ")) List = [4, 19, 23, 36, 40, 43, 61, 64, 78, 95] def binarySearch(num1, num2, array): '''performs binary search to identify if there is a number in the List within a given interval''' mid = len(array)//2 try: if...
true
06e6078bb3b5585e95aa3f0f11bb011e6f2723c8
shalu169/lets-be-smart-with-python
/Flatten_Dictionary.py
540
4.15625
4
""" This problem was asked by Stripe. Write a function to flatten a nested dictionary. Namespace the keys with a period. For example, given the following dictionary: { "key": 3, "foo": { "a": 5, "bar": { "baz": 8 }}} it should become: { "key": 3, "foo.a": 5, "foo.bar.baz": 8 } You can assume keys do not contain dots...
true
f8e2832fa04459261dd5d89ec41dbc329f41cee9
shalu169/lets-be-smart-with-python
/object_to_iter.py
2,675
4.40625
4
#The __iter__() function returns an iterator for the given object (array, set, tuple etc. or custom objects). #It creates an object that can be accessed one element at a time using __next__() function, #which generally comes in handy when dealing with loops. #iter(object) #iter(callable, sentinel) # Python code demonst...
true
01240ebbeac9cd0dd912097c8249ca7c6654b73f
janedallaway/ThinkStats
/Chapter2/pumpkin.py
1,975
4.25
4
import thinkstats import math '''ThinkStats chapter 2 exercise 1 http://greenteapress.com/thinkstats/html/thinkstats003.html This is a bit of an overkill solution for the exercise, but as I'm using it as an opportunity to learn python it seemed to make sense''' class Pumpkin(): def __init__ (self, ty...
true
254057aa4f45292225fea68a65458c4fb8098bba
gusmendez99/ai-hoppers
/game/state.py
700
4.15625
4
from copy import deepcopy class GameState: """ Class to represent the state of the game. - board = stores board information in a certain state - current_player = stores current_player information in a specified state - opponent = stores opponent information in specified state """ def __in...
true
1dfda62b11b9721499dff52d38617d547647198a
DinakarBijili/Python-Preparation
/Data Structures and Algorithms/Algorithms/Sorting_Algorithms/2.Bubble.sort.py
1,042
4.375
4
# Bubble sort is a Simple Sorting algorithm that repeatedly steps through the array, compare adjecent and swaps them if they are in the wrong order. # pass through the array is repeated until the array is sorted #Best O(n^2); Average O(n^2); Worst O(n^2) """ Approach Starting with the first element(index = 0), compare...
true
e88b39744da6626bb46d84c211c9475a0c45ec93
DinakarBijili/Python-Preparation
/Problem Solving/Loops/Remove_Duplication_from_string.py
330
4.125
4
"""Remove Duplication from a String """ def remove_duplication(your_str): result = "" for char in your_str: if char not in result: result += char return result user_input = input("Enter Characters : ") no_duplication = remove_duplication(user_input) print("With out Duplication = ",no_dupl...
true
224fc51576ce0320b8b78210fde376cf4aba4b37
S411m4/very_simple_python_database
/very_simple_python_database.py
1,386
4.21875
4
class School: def __init__(self, firstName, lastName, email, money, job): self.firstName = firstName self.lastName = lastName self.email = email self.money = money self.job = job def __str__(self): data = [self.firstName, self.lastName, self.email, sel...
true
9492b53ff84e6463ca659d5ade4c4b6be287501a
michalmaj90/basic_python_exercises
/ex1.py
346
4.21875
4
'''Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.''' name = input("What's your name?? ") age = input("What's your age?? ") year = str((100 - int(age)) + 2018) print("Hello " + name + "! You'll be 1...
true
dc7a57d761082468346561bfa10083e4e5b80e56
mohammedjasam/Coding-Interview-Practice
/LeetCode/LongestSubstring.py
850
4.125
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
0e8f5383d8e33592ec5f1b0ebb18c7f9bfe9f7dc
Shashankhs17/Hackereath-problems_python
/Basic/palindrome_string.py
461
4.15625
4
''' You have been given a String S. You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes). ''' string = input("Enter the string:") lenght = len(string) flag = 0 i = 0 while i<lenght/2: if string[i] == string[lenght - 1]: ...
true
247bf8d334045c2af71b90ee7dd9be4a67dc1941
mmore500/hstrat
/hstrat/_auxiliary_lib/_capitalize_n.py
454
4.1875
4
def capitalize_n(string: str, n: int) -> str: """Create a copy of `string` with the first `n` characers capitalized. If `n` is negative, the last `n` characters will be capitalized. Examples -------- >>> capitalize_n('hello world', 2) 'HEllo world' >>> capitalize_n('goodbye', 4) 'GOODb...
true
4adec0efa3c15a3ab80eb6ec7706f4dfc51cb015
mmore500/hstrat
/hstrat/_auxiliary_lib/_render_to_numeral_system.py
1,278
4.21875
4
# adapted from https://cs.stackexchange.com/a/65744 def render_to_numeral_system(n: int, alphabet: str) -> str: """Convert an integer to its digit representation in a custom base. Parameters ---------- n : int The non-negative integer to be converted to a custom base representation. ...
true
02901ed5551932dcd71f9c33e75361f815bc963c
Isaac12x/codeexamples
/split_list.py
1,858
4.40625
4
def sub_split_list_by_reminder(list, splitter): """ Function to create a nested list with length equal to the reminder of division This function splites the list into an amount of nested lists equally sized to the second parameter. It also spreads the contents of the first list in nested lists equal...
true
787d8c98b29972ac759a8e13175dccb84f1dd69a
paulopimenta6/ph_codes
/python/edx_loop_for_3.py
263
4.34375
4
#Using a for loop, write a program which asks the user to type an integer, n, and then prints the sum of all numbers from 1 to n (including both 1 and n). number = int(input("write a number: ")) sum=0 for i in range(1,number+1): sum = sum + (i**2) print(sum)
true
90b9a6ed8f46b120764be142824d76cac1f88a2f
sssandesh9918/Python-Basics
/Functions/11.py
291
4.28125
4
'''Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result.''' add= lambda a: a+15 mul =lambda x,y: x*y r=add(10) s=mul(15,10) print(r) print(s)
true
ff1908e083e96ca7f60b802cf1ff4549a789fde2
sssandesh9918/Python-Basics
/Data Types/7.py
373
4.21875
4
'''Write a Python function that takes a list of words and returns the length of the longest one.''' def func(a): b=[] for i in range(a): words=list(input("Enter words")) b.append(words) print(b) c=[] for j in range(len(b)): c.append(len(b[j])) print(max(c)) a=int(input("E...
true
a8434f61ab39cdab8ba3622b7b0f0456bcd424de
sssandesh9918/Python-Basics
/Functions/1.py
254
4.28125
4
'''Write a Python function to find the Max of three numbers.''' def highest(x,y,z): return(max(x,y,z)) a=input("Enter first number") b=input("Enter second number") c=input("Enter third number") m=highest(a,b,c) print("The max of three numbers is ",m)
true
9d3fdd56d2421bbaf118afaa03bbba63f2c39382
ArthurMelo9/100daysofCode
/examples.py
955
4.15625
4
#A rollercoaster ride #print("Welcome to Rollercoaster!") #height= int(input("Enter your height in cm: ")) #if height > 120: # print("You can ride the rollercoaster!") #else: # print("Sorry, you have to grow taller before you can ride.") print("Welcome to rollercoaster!") height=int(input("What is your height...
true
0c7efc52a64526e2c9fb5c3dbc7495bb479908b7
omvikram/python-advance
/decorators.py
661
4.125
4
#Return a function def myfunc1(name=""): print("This is myfunc1()") def welcome(): print("\t This is welcome()") def greet(): print("\t This is greet()") if(name == "Om"): return welcome else: return greet f = myfunc1() f() f= myfunc1("Om") f() #Pass a function a...
true
8436a1dc91a3328e45aba2a4b8e9c8192561aef8
mingyuea/pythonScriptingProblems
/routeCircle.py
821
4.125
4
class Solution: def judgeCircle(self, moves): """ Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. The move sequence is represented by a string. And each move is represent by a character. The ...
true
1234197b9ea59d5b5004b2cd424e6e9b38417df0
cskamil/PcExParser
/python/py_trees_insert_binarytree/insert_binarytree.py
2,602
4.3125
4
''' @goalDescription(In a BinaryTree, adding new nodes to the tree is an important capability to have.\nConstruct a simple implementation of a BinaryTree consisting of an __init__ method and an insertLeft method, which adds new nodes to the tree to the left of the root. ) @name(Inserting binary tree) ''' # Define a...
true
502ce16f0984b5d247561afe4fe2ef29f9a4bd72
paulatumwine/andelabs
/Day 2/OOP/oop_concepts.py
1,944
4.625
5
from abc import ABCMeta class Product(object): """ An abstract class """ __metaclass__ = ABCMeta unit_price = 0 def __init__(self, name, maker): self.__name = name self.__maker = maker self._quantity = 0 self._total_stock_price = 0 def add_stock(self, qu...
true
39c5f391e9016907762f2465f47b5251316bfd8c
Emile-Dadou-EPSI/EulerProject
/problem1.py
501
4.15625
4
## Euler Project problem 1 : ## If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. ## The sum of these multiples is 23. ## Find the sum of all the multiples of 3 and 5 below 1000. def findMultiples(nbMax): res = 0 for x in range(nbMax): if x % 3 == 0 or x % ...
true
7d3a72a7c767addcf1320b785bedd3b5e61f95ea
padmini06/pythonExamples
/example.py
486
4.1875
4
#!/usr/bin/python3 print("hello") x="" x=input("enter your name \n") print("Hello",x) x=input("enter number 1 \n") y=input("enter number 2 \n ") if x>y: print("x is greater than y"); print("anscscdsafasf") else: print("y is greater than x"); def MaxNumber(a,b,c): "This function will return th...
true
deb17862f7715aca87c07a2b0a74571da13bbfc7
padmini06/pythonExamples
/Example5.py
970
4.21875
4
#!/usr/bin/python3 """ Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your progra...
true
a8170f6055aac917f096ce057feba9015c713bed
padmini06/pythonExamples
/example1.py
396
4.375
4
""" Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.""" _name= input("Enter your name\n") _age = int(input("Enter you age \n")) if _age > 100 : print("your age is greater than 100") el...
true
0e12c929ff4cbb6a9b263a4bbe074edeea8546f1
rogerwoods99/UCDLessons
/UCDLessons/DataCampDictionary.py
2,374
4.4375
4
# find the capital based on index of the country, a slow method # Definition of countries and capital countries = ['spain', 'france', 'germany', 'norway'] capitals = ['madrid', 'paris', 'berlin', 'oslo'] # Get index of 'germany': ind_ger ind_ger=countries.index("germany") # Use ind_ger to print out capital of Germany...
true
444283f159d5fc198a4bb0a990968fd321c18e87
planktonlex55/ajs
/basics/rough_works/2_iterators.py
841
4.8125
5
#for can be used to iterate over many data structures in python. #ex. 1 list1 = [10, 20, 30] for x in list1: print x string1 = "python" for x in string1: print x dict1 = {"key1": "value1", "key2": "value2", "key3": 10} print dict1 #order of printing seems to be from last to first for x in di...
true
c9a7d17b5534f997709ab430eb851262b4e06a5d
Shivani-Y/assignment-3-prime-factors-Shivani-Y
/prime.py
785
4.28125
4
""" prime.py -- Write the application code here """ def generate_prime_factors(number): """ Code to generate prime factors """ prime_list = [] i = 2 if not isinstance(number, int): #raises an error of function called for any type but integer raise ValueError("Only integers can be used in the fun...
true
9511d38e439478be9b7166629091ba87f9652836
YoungWenMing/gifmaze
/examples/example4.py
1,793
4.375
4
# -*- coding: utf-8 -*- """ This script shows how to run an animation on a maze. """ import gifmaze as gm from gifmaze.algorithms import prim # size of the image. width, height = 605, 405 # 1. define a surface to draw on. surface = gm.GIFSurface(width, height, bg_color=0) # define the colors of the walls and tree. ...
true
5f4c8a6d164228395c8aaecd4893ee887de0034b
Lingrui/Learn-Python
/Beginner/tuple.py
390
4.21875
4
#!/usr/bin/python #define an empty tuple tuple = () #a comma is required for a tuple with one item tuple = (3,) personInfo = ("Diana",32,"New York") #data access print(personInfo[0]) print(personInfo[1]) #assign multiple variables at once name,age,country,career = ('Diana',32,'Canada','CompSci') print(country) #...
true
b9a63cdacea35210a3952f4ca597399e1fc2cb87
Lingrui/Learn-Python
/Beginner/objects_classes.py
1,078
4.5
4
#!/usr/bin/python ###class###### ## The __init__() method is called the constructor and is always called when creating an object. class User: name = "" def __init__(self,name): self.name = name def sayHello(self): print "Hello, my name is " + self.name #creat virtual objects james = User("James") david = Us...
true
88073a7b852e94d8fcbf21de3b0c9b1ac0447563
ChiDrummer/CodingDojoPythonStack
/PythonFundamentals/math.py
504
4.53125
5
"""Multiples Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise. Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.""" for number in range(1,101,2): print number for number in range(5,100): if num...
true
54afcc3930bfaf9e2c5afa953cbcdd0438dd1e35
smahs/euler-py
/20.py
767
4.15625
4
#!/usr/bin/python2 """ Statement: n! means n x (n - 1) x ... x 3 x 2 x 1 For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! """ from unittest import TestCase, main class Problem20(obj...
true
a7b980f2e78b2720dbb60ca9ba2ef8c242a8e38b
jakubowskaD/Rock_Papper_Scissors-TEAM_ONE
/Rock_paper_scissors_game.py
1,947
4.15625
4
import random scoretable = [0,0] def computer_choice(): choices = ['rock', 'paper', 'scissors'] return random.choice(choices) def player_choice(player): if player == "1": player_choice = "rock" elif player == "2": player_choice = "paper" else: player_choice =...
true
df08c1c86d29e0187566b66bd0e0cb8a8d7813a5
RakhshandaMujib/The-test-game
/Test_game.py
1,992
4.1875
4
import math def single_digits_only (list_is): ''' This method checks a list of number for any number that has more than 2 digits. If there is any, it splits the digits of the same. Argument: list_is - List. The list of numbers to check. Returns: list_is - Revised list. ''' index = 0 while...
true
2b2989045ce3fbf972faf3653e8ea9f65ac45e71
CadetPD/Kodilla_4_2
/zad_4-2_palindrom_.py
391
4.1875
4
def palindrome(word): """ Palindrome(word) checks if a word is palindrome or not Parameter: word Argument: 'word' Sollution: compare lists for argument ([normal] vs [reversed]) Func result: returns after func execution """ if list(word.lower()) == list(reversed(word.lower())): ...
true
2b7329ca49a053e7bb0392d43233c360a8344de3
caitinggui/leetcode
/zigzag_conversion.py
2,099
4.28125
4
#!usr/bin/python # coding:utf-8 ''' The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the co...
true
566fa1ae85da1c75006ff57a27e582a1290b1047
caitinggui/leetcode
/189_rotate_array.py
1,410
4.34375
4
# coding: utf-8 ''' Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. [show hint] Hint: Could you do it in-pl...
true
d8c7134b884879119809e2d4d9073df88fd472fe
romperstomper/petshop
/arrayflatten.py
705
4.25
4
"""Flatten an array of arbitrarily nested arrays. Array elements will be integers and nested arrays. Result in a flat array. E.g. [[1,2,[3]],4] -> [1,2,3,4].""" def flatten(target_list): """Flattens a nested list. Args: target_list: (int|list|tuple) Yields: (int) Raises: TypeError: Error if t...
true
f435655c8e051070c5672f122d0d6af36d29f28e
Anoopsmohan/Project-Euler-solutions-in-Python
/project_euler/pjt_euler_pbm_9.py
406
4.1875
4
'''A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' def pythagorean(): for a in xrange(1, 501): for b in xrange(a+1, 501): c ...
true
acb00c5ece15950069d9a074de30b7b5e8e634d9
onyinyealadiume/Count-Primes
/main.py
523
4.15625
4
# Determine if the input number is prime def isPrime(n): for current_number in range(2,n): # if the input number is evenly divisible by the current number? if n % current_number == 0: return False return True # Determine how many prime numbers are UNDER the input number def countPrimes(n)...
true
fe2db7b0d45f4bb358389c68557d21680f618b31
sxdegithub/myPythonStudy
/Study/ds_str_methods.py
497
4.375
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # Author: sx # 这是一个字符串对象 name = 'Swaroop' if name.startswith('Swar'): print('Yes,the string starts with Swar') if name.startswith(('a', 's')): print("yes there is a 'S'") if 'a' in name: print("Yes ,the string contains character 'a'") if name.find('war') != -1...
true
f1e8831044ec44f2cae9076789715eb5682934f5
prossellob/CodeWars
/duplicate_encoder.py
721
4.15625
4
''' The goal of this exercise is to convert a string to a new string where each character in the new string is '(' if that character appears only once in the original string, or ')' if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. Ex...
true
b36649f74f78e09023d0a9db48c12cbd2a4f769a
anoopch/PythonExperiments
/print_test.py
832
4.28125
4
# Pass it as a tuple: name = "Anoop CH" score = 9.0 print("Total score for %s is %s" % (name, score)) # Pass it as a dictionary: print("Total score for %(n)s is %(s)s" % {'n': name, 's': score}) # There's also new-style string formatting, which might be a little easier to read: # Use new-style string formatting: pri...
true
b74d7bd074117eac432209dd90ec6117e890b53d
anoopch/PythonExperiments
/Lab_Ex_23_Factorial_Of_Number_while.py
509
4.4375
4
# Program to Factorial of a number number = int(input('Enter an Integer number : ')) if number < 0: print("Sorry, factorial does not exist for negative numbers") elif number == 0 or number == 1: print("The factorial of {0} is {1}".format(number, number)) else: i = 1 factorial = 1 while i < number + ...
true
5ca09128a7e6200bc5df8a766fa1f86f739c8db4
anoopch/PythonExperiments
/Lab_Ex_16_celcius_to_farenheit.py
223
4.40625
4
# Convert celcius to farenheit celcius=float(input('Enter the temperature in Celcius : ')) farenheit=(celcius*(9/5)) + 32 print('The temperature equivalent of {} Celcius is {} Farenheit'.format(celcius, farenheit))
true
d1f09f88680f085e6666fefee0f6304430579d42
MeghaGajare/Algorithms
/String/reverse a string.py
247
4.3125
4
#reverse a string string = input() a = string[::-1] print('reverse string: ',a) # or b = '' for i in string: b=i+b print(b) #check palindrome string if(a == string): print("It is a palindrome.") else: print("It is not palindrome.")
true
ac34b15de951625480c670d0ce60bd3586b77931
ddh/leetcode
/python/perform_string_shifts.py
1,958
4.1875
4
""" You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left shift) or 1 (for right shift). amount is the amount by which string s is to be shifted. A left shift by 1 means remove the first character of s and append it to the ...
true
d72c8326f3567ad955f46f848e232247bf1b573a
ddh/leetcode
/python/shortest_word_distance.py
1,834
4.125
4
""" Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. Example: Assume that words = ["practice", "makes", "perfect", "coding", "makes"]. Input: word1 = “coding”, word2 = “practice” Output: 3 Input: word1 = "makes", word2 = "coding" Output: 1 Note: Yo...
true
a0157e9d059f448f30af6ddb873b9eef438ec171
CalebKnight10/CS_260_4
/factorial_recursive.py
276
4.34375
4
# A factorial is multiplying our num by the numbers before it # Ex, 5 would be 5x4x3x2x1 def factorial(num): if num <= 1: return num else: return factorial(num - 1) * num def main(): print(factorial(9)) if __name__ == '__main__': main()
true
010fb27996b2a30bffb70755ba9c86266215f4b2
Tradd-Schmidt/CSC236-Data-Structures
/T/T12/count_evens.py
2,009
4.34375
4
# ------------------------------------------------------------------------------- # Name: count_evens.py # Purpose: This program is designed to use recursion to count the number of # even numbers are read from a file. This sequence is stored in a # linked list. # # Created: 08/10/2...
true
e8e7d5b2eac6d3937b518a55d0219d2951b2a784
Tradd-Schmidt/CSC236-Data-Structures
/A/A08/LinkedLIst_smdriver.py
2,037
4.125
4
# ------------------------------------------------------------------------------- # Name: LinkedList_smdriver.py # Purpose: Rudimentary driver for the LinkedList class. # # Edited by: Tradd Schmidt on 9/21/17 # ------------------------------------------------------------------------------- from LList impor...
true
92fb30404522bc211979ebf91b8c33d55c91be96
gayatri-p/python-stuff
/challenge/games/guess.py
541
4.21875
4
import random start = 0 end = 100 n = random.randint(start, end) tries = 1 print('-----Guessing Game-----') print(f'The computer has guessed an integer between {start} and {end}.') guess = int(input('Guess the number: ')) while guess != n: tries += 1 if n > guess: print('The number is larger than you...
true
8fcc321aa45145737d6343a0387637a586a20d01
ramiro-arias/HeadPython
/HeadPython/Chapter02/p56.py
732
4.15625
4
# Source: Chapter01/The Basics/p56.py # Book: Head First Python (2nd Edition) - Paul Barry # Name in the book: Working with lists # Eclipse project: HeadFirstPython ''' Created on May 2, 2019 @author: ramiro ''' # We will use the shell to first define a list called vowels, then check to see if # each letter in a wor...
true
6e3542bf51343ab56329a32dfc76cbe504f55bf0
dhking1/PHY494
/03_python/heavisidefunc.py
414
4.1875
4
# Heaviside step function def heaviside(x): """Heaviside step function Arguments --------- x = float input value Returns --------- Theta : float value of heaviside """ theta = None if x < 0: theta = 0. elif x == 0: theta = 0.5 else: theta = 1. r...
true
e1a778777bd164df6a46519e74ee6f35d84fc22b
missingcharacter/janky-stuff
/python/rename_trim_multiple_spaces.py
515
4.21875
4
#!/usr/bin/env python3 # Python3 code to rename multiple # files in a directory or folder # importing os module import os import re # Function to rename multiple files def main(): for filename in os.listdir("./"): src = filename dst = re.sub(' +', ' ', filename) # rename() function will ...
true
1fc26b0beb9013585a58985916541dcc1b95f3e1
Tanges/assignment5_1-python
/sequence.py
746
4.25
4
n = int(input("Enter the length of the sequence: ")) # Do not change this line #The sequence for the algorythm is 1, 2, 3, 6, 11, 20, 37, ___, ___, ___, … #Idea: i + 2 power of i #Algorithm adds up last 3 inputs and returns the sum of it #Make a list with first 3 inputs which are already determined #Print out the first...
true
a37ffbff5331c3c7e1741073bec9c177ec4ac244
Sean-Stretch/CP1404_Pracs
/Prac_01/shop_calculator.py
876
4.34375
4
""" The program allows the user to enter the number of items and the price of each different item. Then the program computes and displays the total price of those items. If the total price is over $100, then a 10% discount is applied to that total before the amount is displayed on the screen. """ total_cost = 0 valid...
true
327197a5ee25edcae773ad77af22eca04e35495b
nikhilbagde/Grokking-The-Coding-Interview
/topological-sort/examples/tasks-scheduling/python/MainApp/app/mainApp.py
2,454
4.125
4
from collections import defaultdict class MainApp: def __init__(self): pass ''' There are ‘N’ tasks, labeled from ‘0’ to ‘N-1’. Each task can have some prerequisite tasks which need to be completed before it can be scheduled. Given the number of tasks and a list of prerequisite pairs, f...
true
ca140ef57f7b1a6616faf90660071bf1e276fa9a
nikhilbagde/Grokking-The-Coding-Interview
/sliding-window/examples/no_repeat_substring/python/MainApp/app/mainApp.py
1,272
4.15625
4
import sys class MainApp: def __init__(self): pass ''' Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb...
true
aac73ba75af9ca633c06abf6d78725b838e55bfc
nikhilbagde/Grokking-The-Coding-Interview
/two-pointers/examples/subarrays-with-products-less-than-k/python/MainApp/app/mainApp.py
1,235
4.125
4
class MainApp: def __init__(self): pass ''' Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 ...
true
c957a225ec65cf3aad4a51a334f7d241f51c866d
nikhilbagde/Grokking-The-Coding-Interview
/tree-bfs/examples/reverse-level-order-traversal/python/MainApp/app/mainApp.py
1,853
4.1875
4
from queue import Queue class FifoDataStructure: def __init__(self): self.stack = list() def push(self, e): self.stack.insert(0, e) def get(self): if len(self.stack) == 0: return None self.stack.pop(0) def get_stack(self): return self.stack clas...
true
957472acc148e3088ae2dc0a453c783065ff0dd4
nikhilbagde/Grokking-The-Coding-Interview
/fast-and-slow-pointers/examples/middle-of-linked-list/python/MainApp/app/mainApp.py
1,085
4.125
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class MainApp: def __init__(self): pass ''' Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the secon...
true
82e2a58a20f4e9896cc97e34af2074e55baf6ccb
imtiazraqib/Tutor-CompSci-UAlberta
/CMPUT-174-Fa19/guess-the-word/Guess_The_Word_V1.py
1,410
4.28125
4
#WordPuzzle V1 #This version plans to implement the ability for the program to select a word from a limited word list #The program will then remove the first letter and replace it with an _ and the player can make a guess #if correct, the program congratulates. if not then condolensces are sent #Functions such as multi...
true
15a6ed0d48f867c9163defbe6f25428091c0e2cd
Nandi22/hardway3
/ex18.py
697
4.3125
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 2 18:45:33 2019 @author: ferna """ # this one is like your scripts with argv def print_two(*args):# defines what function does arg1, arg2 = args # asks for arguments print (f"arg1: {arg1}, arg2: {arg2}") # ok, that *args is actually pointless, ...
true
dac7d2d70f4736f453f5b446453120568896df33
jitendrabhamare/Problems-vs-Algorithms
/Sort_012.py
1,364
4.25
4
# Dutch National Flag Problem # Author: Jitendra Bhamare def sort_012(list_012): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: list_012(list): List to be sorted """ next_pos_0 = 0 next_pos_2 = len(list_012) - 1 front_index = 0 whi...
true
10e5e22683d76cd7f02845a05047643950bfa2d2
Vivekagent47/data_structure
/Python/doubly_linked_list.py
2,923
4.3125
4
''' In this program wi impliment the Doubly LinkedList here we can do 4 differnt operations: 1- Insert Node at Beginning 2- Insert Node at End 3- Delete the node you want 4- Print List ''' class Node: def __init__(self, data, next = None, previous = None): self.data = data self.nex...
true
6da9eac046121212d554fa6500eb2da6cd2be4b0
Rhornberger/Python
/python_folder/roll_dice.py
1,235
4.125
4
''' Rolling dice with gui interface using tkinter written by Rhornberger last updated nov 12 2019 ''' # import library from tkinter import * # create the window size and welcome text window = Tk() window.title('Welcome to the D20 roller!') lbl = Label(window, text = 'Welcome!', font =('arial', 20)) lbl.grid(column = ...
true
02e0f413935a045783423ee27aa57c71acb3551c
JaredBigelow/Python-Projects
/Nesting, Div, and Mod/Star.py
2,516
4.1875
4
#Author: Jared Bigelow #Date: February 27 2015 #Purpose: To create star patterns based on inputted type and size #Input: Type, size #Output: Star Pattern #Star Patterns ################################################################################ import math repeat = "Y" while repeat == "Y" or repeat == "y": ...
true
ff9baf913c50c07d3b7805702505cbf78d01bde7
chelseavalentine/Courses
/Intro-Programming/[10]AnotherSortOfSort.py
647
4.1875
4
""" Assignment Name: Another Sort of Sort Student Name: Chelsea Valentine (cv851) """ import random #ask for input & keep the user in a loop until they type 'done' while True: n = int(input("Enter an integer to create a random list, or type 'done' to finish: ")) #check whether user entered 'done' & define th...
true
4602412de2c9a2a876149e9ed2fb249a789b3413
ShazamZX/Data-Structure-and-Algorithm
/Array Questions/PalinMerge.py
1,084
4.3125
4
""" Given an array of positive integers. We need to make the given array a ‘Palindrome’. The only allowed operation is”merging” (of two adjacent elements). Merging two adjacent elements means replacing them with their sum. The task is to find the minimum number of merge operations required to make the given array a ‘Pa...
true
8cc89bb11638aa49abdcfd1c52b5e8b983bd0131
ShazamZX/Data-Structure-and-Algorithm
/Array Questions/ZeroSumSubA.py
609
4.125
4
#check if an array has a any subarray whose sum is zero (Prefix sum method) #the idea is that we calculate prefix sum at every index, if two prefix sum are same then the subarray between those two index have sum as zero def subSum(arr): prefix_sum = set() prefix_sum_till_i = 0 for i in range(len(arr)): ...
true
9cfd7b4f89b93e5af2765e5c60e3eb0fb58db748
Mehedi-Bin-Hafiz/Python-OOP
/classes/creating_a_class.py
2,156
4.8125
5
# Making an object from a class is called instantiation, and you work with # instances of a class. #### when we write function in a class then it called method # ((Methods are associated with the objects of the class they belong to. # Functions are not associated with any object. We can invoke a function just by its n...
true
0f4d4cb8f7f45575b5ba4d04757db25a09d0c79e
DrFeederino/python_scripts
/password_randomizer.py
2,820
4.28125
4
""" This module to randomize passwords for your own or user's usages. Supports for custom or default (8-16) lengths of passwords. Can be used both as a standalone program or imported to your project. Example: For default length: $ python3 password_randomizer.py For a variable length: $ python3 pass...
true
8a4dcdb0d69d1c5ef779637dab859e3c68bde45f
Ameliarate16/python-programming
/unit-2/homework/highest.py
220
4.28125
4
#Given a list of numbers, find the largest number in the list num_list = [1, 2, 3, 17, 5, 9, 13, 12, 11, 4] highest = num_list[0] for number in num_list: if number > highest: highest = number print(highest)
true
180727f1c1ed8730bcf31e95b5b36409fe7da25d
Ameliarate16/python-programming
/unit-2/functions.py
905
4.15625
4
''' def add_two(): result = 5 + 5 print(result) #passing arguments def add_two(a, b): result = a + b print(result) #returning the value def add_two(a, b): result = a + b return result print(add_two(3, 10)) ''' #write a function that returns the sum of the integers in a list def sum_list(a_li...
true
bd947bf7410ca64c210a42e5a278aada8b949131
HEroKuma/leetcode
/1005-univalued-binary-tree/univalued-binary-tree.py
1,029
4.21875
4
# A binary tree is univalued if every node in the tree has the same value. # # Return true if and only if the given tree is univalued. # #   # # Example 1: # # # Input: [1,1,1,1,1,null,1] # Output: true # # # # Example 2: # # # Input: [2,2,2,5,2] # Output: false # # # #   # # Note: # # # The number of nodes...
true