blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f746de4262b1c9f975a55ee02581b7a873ce1146
tglaza/Automate-the-Boring-Stuff-with-Python
/while_break_yourName_input.py
514
4.28125
4
#this is similar the first yourName program, except it uses a break to end the program #break statements are useful if you have several different places in a while loop that would allow you to leave from that point name = '' while True: #this would never be False so it's an infinite loop because it's always True ...
true
3caa06220975d573f9400da144c54c853555addc
robbailiff/database-operations
/sqlite_functions.py
1,920
4.84375
5
""" Here is some practice code for using the sqlite3 module with Python. Here I was experimenting with applying functions in SQLite statements. I have included comments throughout explaining the code for my own benefit, but hopefully they'll help someone else too. Hope you like the code. Any tips, comments or genera...
true
43d180dea65f2b5d65ec2da20c6524b0e42047c5
mareaokim/hello-world
/03_8번Gregorian.py
456
4.1875
4
def main(): print("Gregorian epact value of year.") print() year = int(input("Enter the year (e.g. 2020) : ")) c = year // 100 epact = (8+(c//4) - c + ((8*c+13)//25) + 11 * (year % 19)) % 30 print() print("The epact value is" , epact, "days.") main() >>>>>>>>>>>>>>> ...
true
d0a504f3603a3c9471c2826dd00cada6044f1a21
mareaokim/hello-world
/03_3번weight.py
700
4.28125
4
def main(): print("This program calculates the molecular weight of a hydrocarbon.") print() h = int(input("Enter the number of hydrogen atoms : ")) c = int(input("Enter the number of carbon atoms : ")) ox = int(input("Enter the number of oxygen atoms : ")) weight = 1.00794 * h + 12.01...
true
e18412d42429782751836ec1759665325a172b4f
mareaokim/hello-world
/03_12번number2.py
975
4.375
4
def main(): print("This program finds the sum of the cubes of the first n natural numbers.") print() n = int(input("Please enter a value for n : ")) sum = 0 for i in range(1,n+1): sum = sum + i**3 print() print("The sum of cubes of 1 through through", n, "is : ",s...
true
2decab40de10c88aa8102ab675e9fa1f3a46c8b0
riteshsahu16/python-programming
/2 loop/ex1.10_check_ifprime.py
270
4.125
4
#Q10. Write a program to check whether a number is prime or not. n = int(input()) i = 2 is_prime = True while(i <= n//2): if n%i==0: is_prime = False break i += 1 if is_prime: print("The no. is prime") else: print("The no. is NOT prime")
true
a0a1fbc6a48d45ccb858529ca0f5718390adeb00
MOIPA/MyPython
/practice/basic/text_encode.py
473
4.21875
4
# in RAM all text would be translated to Unicode # while in Disk there are UTF-8 str = u'编码' # Unicode now str = str.encode('utf-8') # UTF-8 print(str) str = str.decode('utf-8') print(str) # riverse a = u'\u5916' print(a) a = a.encode('utf-8') print(a) # -*- coding: utf-8 -*- # the above line means read the code fi...
true
6e0e2c9518732023f4416e5971029e73947d5ea3
MOIPA/MyPython
/practice/basic/list_tuple.py
372
4.15625
4
list_num = [1, 2, 3, 4, 5] print(list_num[-1]) # 3 # delete list_num.pop() # delete the end one list_num.pop(2) # delete the third one print(list_num) # add list_num.append(6) list_num.insert(0, -1) # update list_num[0] = 0 # tow dimensional array one = [2.1, 2.2, 2.3] array = [1, one, 2, 3] print(array[1][0]) ...
true
d47af399c0c701882f4c78b20395df6808d2c503
Douglass-Jeffrey/Unit-5-06-Python
/rounder.py
1,330
4.375
4
#!/usr/bin/env python3 # Created by: Douglass Jeffrey # Created on: Nov 2019 # This program turns inputs into a proper address format def rounding(number, rounder): # This function rounds the user's number # Process rounded_number = (number[0]*(10**rounder)) rounded_number = rounded_number + 0.5 ...
true
74ae9c1c92272b3cd54e2a76269ddf32994c5822
brentholmes317/Project_Euler_Problems_1-10
/Project_Euler/13_adjacent.py
1,086
4.34375
4
from sys import argv, exit from check_integer import check_input_integer """ This reads a file and finds the largest product that can be had by multiplying 13 adjancent numbers. The program needs the final line in the text to be blank. """ script, filename = argv txt = open(filename) reading = 1 #keeps track of if...
true
b942302e280c289fceac406b562b7fb05b7cab36
36rahu/codewar_works
/22-4-2015/product_of_diagonal.py
341
4.3125
4
''' Description: Given a list of rows of a square matrix, find the product of the main diagonal. Examples: main_diagonal_product([[1,0],[0,1]]) => 1 main_diagonal_product([[1,2,3],[4,5,6],[7,8,9]]) => 45 ''' def main_diagonal_product(mat): result = 1 for i in range(len(mat[0])): result *= mat[i][...
true
153705a0ea3ff05d7e59fcd5bee4f28ac60ce413
muhammeta7/CodeAcademyPython
/strings_cons_output.py
1,542
4.375
4
# Create a string by surrounding it with quotes string = "Hello there " # For words with apostrophe's us a backslash \ print "There isn\'t flying, this is falling with style!" # Accesing by index print fifth_letter = "MONTY"[4] # Will return Y # String methods parrot = "Parrot" print len(parrot) # will return numb...
true
598768ac97d73068511606617b003142fcbcc7c1
anbarasanv/PythonWB
/Merge Sort Recursive.py
890
4.21875
4
#Time complexity O(n log n) def merge(left,right): '''This Function will merge 2 array or list''' result = [] i,j = 0,0 #Comparing two list for smallest element while i < len(left) and j < len(right): if left[i] <= right[j]: result.append(left[i]) i +=1 else: ...
true
3000f9b65ad6926b0274a5d94ea41a7e2608781f
bimri/programming_python
/chapter_1/person_start.py
1,107
4.125
4
"Step 3: Stepping Up to OOP" 'Using Classes' class Person: def __init__(self, name, age, pay=0, job=None): self.name = name self.age = age self.pay = pay self.job = job if __name__ == '__main__': bob = Person('Bob Smith', 42, 30000, 'software') sue = Person('Sue Jone...
true
9ae6c269b41521b7ededa35ccae246557185174f
bimri/programming_python
/chapter_7/gui2.py
492
4.28125
4
"Adding Buttons and Callbacks" import sys from tkinter import * widget = Button(None, text='Hello GUI world!', command=sys.exit) widget.pack() widget.mainloop() ''' Here, instead of making a label, we create an instance of the tkinter Button class. For buttons, the command option is the place where we specify a ca...
true
f46676e4e06c7657a92b10f6ac48f8a13f199d02
bimri/programming_python
/chapter_1/tkinter102.py
964
4.15625
4
"Step 5: Adding a GUI" 'Using OOP for GUIs' ''' In larger programs, it is often more useful to code a GUI as a subclass of the tkinter Frame widget—a container for other widgets. ''' from tkinter import * from tkinter.messagebox import showinfo class MyGui(Frame): def __init__(self, parent=None): Frame._...
true
73e6e2712fc736f21f7818bef2c63815de570750
hymhanraj/lockdown_coding
/range.py
266
4.40625
4
''' Given start and end of a range, write a Python program to print all negative numbers in given range. Example: Input: start = -4, end = 5 Output: -4, -3, -2, -1 Input: start = -3, end = 4 Output: -3, -2, -1 ''' for num in range(-3,4): if num<0: print(num)
true
040cdf085336c553e8b0951a59a25028577999f7
helper-uttam/Hacktober2020-5
/Python/calc.py
1,011
4.1875
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") while True: num1 = int(input("Enter first number: ")) num2 = int(...
true
20e5713218979589bc452c464c4e9d52216d2b2b
mishra28soumya/Hackerrank
/Python/Basic_Data_Types/second_largest.py
673
4.125
4
#Find the Runner-Up Score! # Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. # You are given n scores. Store them in a list and find the score of the runner-up. # Input Format # The first line contains N. The second line contains an array A[] of N in...
true
8763f32cd9ae69553a4554c0223283a51c5522be
crypto4808/PythonTutorial_CoreySchafer-master1
/intro.py
1,731
4.3125
4
#import as a smaller name so you don't have to type 'my_modules' each time # import my_modules # #from my_module import find_index # courses = ['history', 'math' , 'physics' , 'compsci' ] # index = my_modules.find_index(courses,'math')# # print(index) #Use shorthand for my_modules so you don't have to type it out al...
true
b9b1a64e80fe8d1a4e9038e36d98f84b56f75ba8
Cassie-bot/Module-3
/Area.py
340
4.40625
4
#Casandra Villagran #1/30/2020 #This is a program that computes the area of a circle using the radius and it prints a message to the user with the answer. radius = int(input ("What is the radius of the circle? ")) Area= 3.14 * radius ** 2 print ("I loved helping you find the area of this circle, here i...
true
13091fa05d4d93a37a34f95520e6de8746a93763
avijitkumar2011/My-Python-programs
/middle_letter.py
213
4.1875
4
#To find middle letter in a string def middle(strg): if len(strg) % 2 == 1: n = len(strg)//2 print('Middle letter in string is:', strg[n]) else: print('enter string of length odd number') middle('kuma')
true
dcd1d7304fd1d7dbf55602f6f95150d98d92ea66
Ma11ock/cs362-asgn4
/avg_list.py
226
4.125
4
#!/usr/bin/env python # Calculate the average of elements in a list. def findAvg(lst): if(len(lst) == 0): raise ValueError("List is empty") avg = 0 for i in lst: avg += i return avg / len(lst)
true
af211c4fb797589561c443a8593c3cc3bf122d47
purnimagupta17/python-excel-func
/string_indexing_slicing_usingpython.py
967
4.65625
5
print('Hello World') #to shift the 'World' to next line, we can use \n in the symtax as follows: print('Hello \nWorld') #to count the number of characters in a string, we use len function as follows: str1="Hello" print(len(str1)) #to assign the index number to a string, for example: ss="Hello World" print(ss[0]) pri...
true
7a71cc280ae6302fc83eebd003a4693c17f8bc2a
krallnyx/NATO_Alphabet_Translation
/main.py
527
4.1875
4
import pandas data = pandas.read_csv("nato_phonetic_alphabet.csv") alphabet = {row.letter: row.code for (index, row) in data.iterrows()} def generate_phonetic(): to_translate = input("Please enter the word you want to translate into NATO Alphabet.\n").upper() try: output = [alphabet[letter] for lette...
true
efb19779c940b3f7d1f8999d089c2b2849764f1c
rckc/CoderDojo
/Python-TurtleGraphics/PythonIntro2-1Sequences.py
1,435
4.5625
5
# Author: Robert Cheung # Date: 29 March 2014 # License: CC BY-SA # For CoderDojo WA # Python Intro Turtle Graphics # Python has a rich "library" of functions. # We are going to use "turtle" to do some simple graphics. import turtle # see https://docs.python.org/2/library/turtle.html#filling if __name__ ...
true
786073c2e842f81fd71fc391628f6161546b5a9e
yyuuliang/codingchallenges
/hackerrank/Reverse-a-doubly-linked-list.py
2,556
4.15625
4
''' File: Reverse-a-doubly-linked-list.py Source: hackerrank Author: yyuuliang@github ----- File Created: Thursday, 12th March 2020 4:21:54 pm Last Modified: Thursday, 12th March 2020 4:21:58 pm ----- Copyright: MIT ''' # Reverse a doubly linked list # https://www.hackerrank.com/challenges/reverse-a-doubly-linked-lis...
true
7b04023a27193cf35c7c4db27c72cbb265193ddf
manusoler/code-challenges
/projecteuler/pe_1_multiples_3_and_5.py
364
4.3125
4
""" 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 or 5 below 1000. """ def multiples_of(*nums, max=1000): return [i for i in range(max) if any([i % n == 0 for n in nums])] if __name__ == "_...
true
74b4f4975aff361161aaa469e959a1652b22a77d
manusoler/code-challenges
/projecteuler/pe_9_special_pythagorean_triplet.py
723
4.3125
4
import functools from math import sqrt from utils.decorators import timer """ A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a**2+b**2=c**2 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 ab...
true
d3c3a3cf50793588756306288b30433842460b60
littlejoe1216/Chapter-6-Exercies
/Python Chapter 6 Exercises/Chp 6 Excercise 4.py
596
4.21875
4
#Exercise 4: #There is a string method called count that is similar to the function in the previous exercise. #Read the documentation of this method at https://docs.python.org/3.5/library/stdtypes.html#string-methods #and write an invocation that counts the number of times the letter a occurs in "banana". word ...
true
e3ddbeb215a0d6419b2ae83f2a0933ffc6fcb459
mmengote/CentralParkZoo
/sketch_181013b/sketch_181013b.pyde
971
4.34375
4
#this library converts the random into integers from random import randint #lists of animals included in the simulation #divided into two types, the zoo animals will have a starting state position of zoolocation. #local animals will have a starting position of something else. zoo_animals = ["Penguins", "Zebra...
true
4f03b52ca0f1f596bfe78b065f44ee8eb0f3b10c
markcharyk/data-structures
/tests/insert_sort_tests.py
1,085
4.125
4
import unittest from data_structures.insert_sort import insertion_sort class TestInsertSort(unittest.TestCase): def setUp(self): """Set up some lists to be sorted""" self.empty = [] self.single = [5] self.sorted = [1, 2, 3, 10] self.unsorted = [8, 1, 94, 43, 33] def te...
true
9689a252589118db6d6623abb196aff8c3efa9ab
vielma24/playground
/bank.py
1,337
4.40625
4
#!/usr/bin/python '''Program will intake customer information and account information. Account management will also be added.''' from datetime import date #******************************************************************************* class person: """ Returns a ```Person``` object with the given name, DO...
true
9d625b9f273e27a48db58a2694b0b8e1eb537063
dolapobj/interviews
/Data Structures/Array/MaximumProductSubarray.py
1,155
4.3125
4
#Maximum Product Subarray #LC 152 """ Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. Example 2: Input: [-2,0,-1] Output: 0 Explanation: The ...
true
4076f61a183fac23c05fbf162dde7289caff5a74
sndp2510/PythonSelenium
/basic/_04Geometry.py
432
4.28125
4
sideCount=int(input("Enter Number of side: ")) if(sideCount==1): print("Its square") side=int(input("Enter length of side : ")) print("Area of the square is : " , (side*side)) elif(sideCount==2): print("Its Rectangle") length = int(input("Enter length of side : ")) breadth =int(input("Enter len...
true
d60ccaf31fe2c293d566effaf936c5c17e6064e3
ksu-is/Commute-Traffic-Twitter-Bot
/Practice/user_funct.py
1,027
4.28125
4
## will create text file for new users with info on each line. (not able to do OOP yet reliably so this is the best I've got) # do you have an account? user_ask = input("Before we start, lets specify what user this is for\nHave you used this program before?\nType 'y' or 'n' only: ") if user_ask.lower() == "n": ...
true
1e3cc57af263476e1346cccf480a6ed62e7c891d
jenshurley/python-practice
/python_early_examples.py
1,836
4.125
4
# Initial variable to track game play user_play = "y" # While we are still playing... while user_play == "y": # Ask the user how many numbers to loop through user_number = input("How many numbers? ") # Loop through the numbers. (Be sure to cast the string into an integer.) for x in range(int(user_num...
true
0be835d18fae63f8b63fbae296f65250f8b38ac4
koaning/scikit-fairness
/skfair/common.py
1,752
4.4375
4
import collections def as_list(val): """ Helper function, always returns a list of the input value. :param val: the input value. :returns: the input value as a list. :Example: >>> as_list('test') ['test'] >>> as_list(['test1', 'test2']) ['test1', 'test2'] """ treat_sing...
true
7a5d6f9bdd12a2aa3d4d1ce7c50723742a23cd46
Azoad/Coursera_py4e
/chapter7/ex_07_01.py
220
4.375
4
"""Take a file as input and display it at uppercase""" fname = input('Enter the file name: ') try: file = open(fname) except: print('Error in file!') quit() for line in file: print(line.strip().upper())
true
6dafc193f5e2f1731df5462295131e2cee3236b8
victorrayoflight/Foudil
/Examen 2019-02-18/6.py
582
4.15625
4
x = True y = False z = False # False OR True == True # True OR False == True # True OR True == True # False OR False == False # True AND True = True # True AND False = False # False AND True = False # False AND False = False # False XOR True == True # True XOR False == True # True XOR True == False # False XOR False...
true
9d848849b6d688b2872bd9923a86319e3ad73807
Anchals24/InterviewBit-Practice
/Topic - String/Longest Common Prefix.py
1,216
4.25
4
#Longest Common Prefix. #Arr = ["aa" , "aab" , "aabvde"] """ Problem Description >> Given the array of strings A, you need to find the longest string S which is the prefix of ALL the strings in the array. Longest common prefix for a pair of strings S1 and S2 is the longest string S which is the prefix of both S1...
true
ac81f1e984700b6b3993e1b60e29812dc82e69c4
emlemmon/emlemmon.github.io
/python/Week6/check06b.py
1,121
4.4375
4
class Phone: """Parent class that has 3 member variables and 2 methods""" def __init__(self): self.area_code = 0 self.prefix = 0 self.suffix = 0 def prompt_number(self): self.area_code = input("Area Code: ") self.prefix = input("Prefix: ") self.suffix = inpu...
true
41f61ba806ae6942a62b114ae624ab00ce0d6b7d
kobecow/algo
/NoAdjacentRepeatingCharacters/problem.py
543
4.15625
4
""" Given a string, rearrange the string so that no character next to each other are the same. If no such arrangement is possible, then return None. Example: Input: abbccc Output: cbcbca """ def rearrangeString(s: str) -> str or None: pass print(rearrangeString("gahoeaddddggrea")) # no order required # ahg...
true
c47370697303df60b4e50e91092a5564b047a718
stephenforsythe/crypt
/shift.py
1,172
4.125
4
""" This is essentially a substitution cypher designed to avoid fequency analysis. The idea is to shift the char to the right by an increasing number, until n = 25, at which time the loop will start again. Spaces are treated as a character at the end of the alphabet. """ import string FULL_ALPHABET = string.lowercas...
true
dfed06b4bbf51b8d57511753a08f09e26e3605d0
MuhammetEser/Class4-PythonModule-Week4
/4- Mis Calculator.py
2,631
4.28125
4
# As a user, I want to use a program which can calculate basic mathematical operations. So that I can add, subtract, multiply or divide my inputs. # Acceptance Criteria: # The calculator must support the Addition, Subtraction, Multiplication and Division operations. # Define four functions in four files ...
true
5cae2691b29e74917c55007405b67e7fcf1a60de
KennethNielsen/presentations
/python_and_beer_lesser_known_gems/ex6_namedtuple.py
2,143
4.21875
4
"""namedtuple example""" from __future__ import print_function from collections import namedtuple def arange(start, end, step): """Arange dummy function""" print('arange', start, end, step) def get_data_from_db(data_id): """Get data from db dummy function""" print('get_data_from_db', data_id) def ...
true
de31bc761ac04f9c15ac4a74328d74b907fbd822
oliviamillard/CS141
/coinAdder.py
1,690
4.28125
4
#Olivia Millard - Lab 3a #This program will add up a user's coins based off of their input. #Short welcome message. print("Hello. This program will add up all of your change!\nCool! Let's get started.\n") """ This function, first, take input from the user asking how many coins they have. Next, it takes input for what...
true
173ecefb3bd3070bff1b3cd83e91dab2dd2eb4bd
renan-suetsugu/WorkshopPythonOnAWS
/Labs/Loops/lab_6_step_1_Simple_Loops.py
545
4.125
4
#fruit = ['apples','oranges','bananas'] #for item in fruit: # print(f'The best fruit now is {item}') #numbers = [0,1,2,3,4,5,6,7,8,9,10] #for number in numbers: # print(f'The next number is {number}') #for number in range(10): # print(f'The next number is{number}') #for number in range(10): #...
true
2a4dd3b8574142a991f73761bd43d6e2688c83a0
blackicetee/Python
/python_games/simple_games/MyValidator.py
451
4.125
4
"""This self written python module will handle different kinds of user input and validate it""" # This is a module for regular expressions see python documentation "Regular expression operations" import re class MyValidator: @staticmethod def is_valid_from_zero_to_three(user_input): regex_pattern = r...
true
8190dd1f19c1c918cd16997aae5a2c0b77c60607
CoitThomas/Milestone_7
/7.1/test_string.py
480
4.3125
4
"""Verify the correct returned string value of a list of chars given to the funtion string(). """ from reverse_string import string def test_string(): """Assert the correct returned string values for various lists of chars given to the string() function. """ # Anticipated input. assert string(['H',...
true
bc58fb8b971f9a907786caac451b8d603a7ec1c0
llduyll10/backup
/Backup/BigOGreen/classPython.py
1,960
4.34375
4
#Create Class class MyClass: x=5 print(MyClass) #Create object p1 = MyClass() print(p1.x) #__innit__() function class Person: def __init__(self,name,age): self.name = name self.age = age p1 = Person("DuyNND",22) print(p1.name) print(p1.age) #Object METHOD #Object can also cotain method clas...
true
950af6a1c4cd4ffe12ff99061bb44cfd0104fec6
regismagnus/challenge_python
/is_list_palindrome.py
1,390
4.15625
4
''' Note: Try to solve this task in O(n) time using O(1) additional space, where n is the number of elements in l, since this is what you'll be asked to do during an interview. Given a singly linked list of integers, determine whether or not it's a palindrome. Note: in examples below and tests preview linked lists a...
true
0f9ba273804db8997bd5ec73e7c233c11d58eac5
regismagnus/challenge_python
/longest_word.py
611
4.34375
4
''' Define a word as a sequence of consecutive English letters. Find the longest word from the given string. Example For text = "Ready, steady, go!", the output should be longestWord(text) = "steady". best solution by dnl-blkv: return max(re.split('[^a-zA-Z]', text), key=len) ''' def longestWord(text): rex='[\[...
true
bee95c39ec36fa669a574732be32e6a85d024117
bvishny/basic-algos
/mergesort_inversions.py
2,008
4.25
4
# Basic Merge Sort Implementation # Components # 1. split_array(array) array array - takes an array and splits it at the midpoint into two other arrays # 2. merge(array, array) array - takes two split arrays and merges them together sorted # 3. mergesort(array) array - takes an array and sorts it using mergesort def s...
true
b98c45e58694e05b7fadee7721ce57a4e625c603
shubhamPrakashJha/selfLearnPython
/6.FunctionalProgramming/6.Recursion.py
328
4.1875
4
def factorial(x): if x == 1: return 1 else: return x*factorial(x-1) print(factorial(int(input("enter the number: ")))) def is_even(x): if x == 0: return True else: return is_odd(x-1) def is_odd(x): return not is_even(x) print(is_even(23)) print(is_odd(1)) print(is...
true
f9a34ec2cd69deb1bc020afd803e3abd5f3ac877
juechen-zzz/LeetCode
/python/0207.Course Schedule.py
2,706
4.125
4
""" There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for yo...
true
837c95fb0a7b12b26dd16d0c3c693ac16ed1bfd1
juechen-zzz/LeetCode
/python/0075.Sort Colors.py
1,075
4.21875
4
''' Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note: You are not suppose to use the l...
true
c22a3a2358c43fa2010303fa125199b77168d3b5
colemai/coding-challenges
/leetcode_challenges/L267-PalindromeP2.py
2,627
4.28125
4
#!/usr/bin/env python3 """ Author: Ian Coleman Input: Output: Challenge: Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. For example: Given s = "aabb", return ["abba", "baab"]. Given s = "abc", return []. """ from...
true
0c0e23c15708325ec523a31bd9b7bea1044ad2e4
prameya21/python_leetcode
/Valid_Palindrome.py
800
4.25
4
''' 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" Output: false ''' class...
true
92cc8732044e9fc0a64a3d7de55ec4393b6b4beb
kangwonlee/16pfa_kangwonlee
/ex29_if/ex29.py
714
4.1875
4
# -*-coding:utf8 # http://learnpythonthehardway.org/book/ people = 10 cats = 30 dogs = 15 if people < cats: print("Too many cats! The world is doomed!") if people > cats: print("No many cats! The world is saved!") if people < dogs: print("The world is drooled on!") if people > dogs: print("The worl...
true
24dad66dd22395fc2a92f2a403de09dcb82fbfe4
Maschenka77/100_Day_Python
/day_2_tip_project_calculator.py
625
4.21875
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 #Tip: You might need to do some research in Google to figure out how to do this. print("Welcome to the tip calculator!") total_bill = float(input("What is t...
true
9d0dec604ab6ca5aefcec6aca0a3766082e1419d
Aravind-39679/tri.py
/triangle.py
658
4.125
4
t=True while(t): A=int(input('Enter first side of the triangle:')) B=int(input('Enter second side of the triangle:')) C=int(input('Enter third side of the triangle:')) if(A+B>C and B+C>A and A+C>B): print("It is a triangle") if(A==B==C): print('It is an equailateral t...
true
cae0951dcb0aaed9aa287c1e924211365b6bcf80
Lynch08/pands-problem-sheet
/squareroot.py
1,061
4.3125
4
#Programme that uses a function so when you input a number it will return the square root #Author Enda Lynch #REF https://medium.com/@sddkal/newton-square-root-method-in-python-270853e9185d #REF https://www.youtube.com/watch?v=WsQQvHm4lSw - Understand Calculas #REF https://www.homeschoolmath.net/teaching/square-root-al...
true
53b9d3683feff9adfa34c88be6c856db960072ad
sheelabhadra/LeetCode-Python
/1033_Moving_Stones_Until_Consecutive.py
2,232
4.21875
4
"""PROBLEM: Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, z with x < y < z. Y...
true
22e6457a4791af6292a17bbb294566aefdb9834e
sheelabhadra/LeetCode-Python
/728_Self_Dividing_Numbers.py
1,425
4.125
4
#A self-dividing number is a number that is divisible by every digit it contains. # For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. # Also, a self-dividing number is not allowed to contain the digit zero. # Given a lower and upper number bound, output a list of every ...
true
8f977472fd05fb250e180589c6545a545805a2ac
zahraaassaad/holbertonschool-machine_learning
/math/0x06-multivariate_prob/0-mean_cov.py
854
4.28125
4
#!/usr/bin/env python3 """ calculates the mean and covariance of a data set """ import numpy as np def mean_cov(X): """ X is a numpy.ndarray of shape (n, d) containing the data set: n is the number of data points d is the number of dimensions in each data point Returns: mean, cov: mean num...
true
e4a322de533519abc12a1819ef9bcea84113c488
kwierman/Cards
/Source/Shuffle.py
1,032
4.125
4
""" @package Shuffle Performs shuffling operations on decks """ import Deck ## splits the deck into two decks # @param deck The deck to be split # @param split_point how many cards from the top of the deck to split it def split_deck(deck, split_point=26): deck_1 = Deck.Deck() deck_2 = Deck.Deck() for x, card in ...
true
5fd87282bd2429a43a83feb00c542b07da1a4259
simiyub/python
/interview/practice/code/arrays/SortedSquareFromSortedArray.py
642
4.28125
4
""" Given an array of sorted integers, this function returns a sorted array of the square of the numbers """ def sorted_square_array(array): result = [0 for _ in array] smaller_value_index = 0 larger_value_index = len(array) - 1 for index in reversed(range(len(array))): smaller_value = array[...
true
6e713b61bedbe73121c1326b8d17ae7cd5d1ef06
simiyub/python
/interview/practice/code/recursion/Permutations.py
1,724
4.15625
4
""" Requirement:This function will receive an array of integers and create an array of unique permutations or ordering of integers that can be created from the integers in the array. Implementation: We build all permutations for the array within the array in place using pointers. We select the first element in the arra...
true
61066f828ffa00dd2652b07ea8e546e255682cf8
simiyub/python
/interview/practice/code/linked_lists/ReverseLinkedList.py
1,248
4.15625
4
""" Requirement: Given a linked list where each node points to the next node, this function will return the linked list in reverse order Implementation: Conceptually, a node is reversed when the next pointer points to the previous node. However, as this is a singly linked list, we do not have a pointer to the previous ...
true
fe1c5e5cea9e34e329b658982acd5bd7fd8f23af
shorya97/AddSkill
/DS & Algo/Week 2/Stack/Implement Stack using Queues.py
1,420
4.15625
4
from queue import Queue class MyStack: def __init__(self): """ Initialize your data structure here. """ self.q1 = Queue() #inbuilt queues self.q2 = Queue() self.cur_size = 0 #contains number of elements def push(self, x: int) -> None...
true
be1b56dc341fc45d7c0d017bc979c4d1426f7afa
prabhu30/Python
/Strings/Set - 1/maketrans_translate.py
743
4.5625
5
""" maketrans() :- It is used to map the contents of string 1 with string 2 with respective indices to be translated later using translate(). translate() :- This is used to swap the string elements mapped with the help of maketrans(). """ # Python code to demonstrate working of # maketrans() and translate() from ...
true
bdbfdd41268b98866a0eb26d1d335267b1a4f0b9
prabhu30/Python
/Lists/Set - 1/indexing_negative.py
666
4.375
4
""" Negative indexing :- In Python, negative sequence indexes represent positions from the end of the array. Instead of having to compute the offset as in List[len(List)-3], it is enough to just write List[-3]. Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second-last it...
true
df60640085e6f84ebd72aee33d3dd29dfc4d950e
TrevorSpitzley/PersonalRepo
/PythonProjects/listCheck.py
920
4.25
4
#!/usr/bin/env python # This file is used for comparing two lists. # If there is an element in the input_list, # and it is not in the black_list, then it # will be added to the out_list and printed def list_check(input_list, black_list): out_list = [] for element in input_list: if element not in blac...
true
62615472dad8b7cbd47655acab1ee1dcafcfc4f3
cbolson13/Pyautogui_CO
/Personality_Survey_C.py
1,876
4.21875
4
print("What's your name?") name = input().title() if name == "Connor": print("Same here!") else: print(name + " is a pretty cool name.") print("What's your favorite sport") sport = input().title() if sport == "Soccer": print("Cool, what's your favorite team!") soccertea...
true
e120d6a0b5708af15a2a50b654ef68837a12c03e
Abhiaish/GUVI
/ZEN class/day 1/fare.py
236
4.15625
4
distance=int(input("enter the distance")) peaktime=int(input("enter the peaktime")) if(distance>5): distance=distance-5 else: print("fare is 100") fare=int(distance*8+100) if(peaktime==1): fare=fare+0.25*fare print(fare)
true
bbdb68232f6a2d04d342d4cc274faa2d3d083aeb
renzhiliang/python_work
/chapter4/4-10.py
293
4.34375
4
#numbers=range(3,31,3) numbers=[number**3 for number in range(1,11)] print(numbers) print("The first three items in the list are:") print(numbers[0:3]) print("Three items from the middle of the list are:") print(numbers[5:8]) print("The last three items in the list are:") print(numbers[-3:])
true
cabc815a05896d9d72e0f904eac1aede308438e7
thu4nvd/project_euler
/prob014.py
1,184
4.15625
4
#!/usr/bin/env python3 ''' Longest Collatz sequence Problem 14 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 ...
true
12abd510bd551ccafd2101bb6392c35357bdbe47
mtmccarthy/langlearn
/bottomupcs/Types.py
1,530
4.71875
5
from typing import NewType, Dict """ In Chapter 1, we learned that 'Everything is a File!'. Here we've created a new type, 'FileType' which models a file as its path in the filesystem. """ FileType = NewType('FileType', str) """ In Chapter 1, we learned about FileDescriptors, which are essentially integer indexes int...
true
6bb5fbe258c60e039c2380dcbbf50dc6b8e5d803
mtmccarthy/langlearn
/dailyredditor/easy/imgurlinks_352.py
1,574
4.25
4
from common import * from typing import Union """ Finds the greatest exponent of n that is less than or equal to another number m Example: if n = 2 and m = 17 return 4 """ def get_base62_character(index: int) -> Union[str, None]: capital_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' lower_case = 'abcdefghijklmnopqr...
true
17ce6e5c354abe914abb538356201ed5cfc55a25
lamyai-norn/algorithsm-week11
/week11/thursday1.py
279
4.15625
4
def sumFromTo(start,end): result=0 if start>end: return 0 else: for index in range(start,end+1): result=result+index return result startValue=int(input("Start value : ")) endValue=int(input("End value : ")) print(sumFromTo(startValue,endValue))
true
3ce463b0b5860ae48129db242597bb45d7620ecc
NikolasSchildberg/guesser
/guesser_simple.py
1,218
4.21875
4
""" Welcome to the number guesser in python! The logic is to use the bissection method to find a number chosen by the user, only providing guesses and asking to try a bigger or smaller one next time. """ # Initial message print("Welcome to the number guesser!\nThink of a number between 1 and 1000 (including them).I'll...
true
826f03f9f1dc41fe4aca2c70b505d7381ba091bf
EagleRock1313/Python
/circle.py
523
4.40625
4
# Load the Math Library (giving us access to math.pi and other values) import math # Ask for the radius of a circle that will be entered as a decimal number radius = eval(input(("Enter the radius of the circle: "))) # Computer circumference and area of this circle circumference = 2 * math.pi * radius area = math.pi ...
true
fdeecfeec4bbea1b1c5bd1738bbadf905dcb3772
Kapilmundra/Complete-Python-for-Lerner
/4 set.py
691
4.21875
4
#Create set print("Create set") s={"teena","meena","reena"} print(s) # it can print in unorder way #pop the element from the set print("\npop the element from the set") s.pop() # it can pop the element in unorder way print(s) #Add element in the set print("\nAdd element in the set") s.add("priya") # i...
true
d86d7fdc1e4fb8c3e6c328b2d4141f5b2e078f66
das-jishu/data-structures-basics-leetcode
/Leetcode/hard/regular-expression-matching.py
2,506
4.28125
4
""" # REGULAR EXPRESSION MATCHING Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Exampl...
true
59d4865c48cf12bac99b751cec480b1aa52b59c5
das-jishu/data-structures-basics-leetcode
/Leetcode/medium/simplify-path.py
2,163
4.5
4
""" # SIMPLIFY PATH Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a period '.' refers to the current directory. Furthermore, a double period '..' moves the directory up a level. Note that the returned canonical path mus...
true
7028074d72039afc722149007fbae5fda2bba392
SPARSHAGGARWAL17/DSA
/Linked List/linked_ques_4.py
1,325
4.28125
4
# reverse of a linked list class Node(): def __init__(self,data): self.data = data self.nextNode = None class LinkedList(): def __init__(self): self.head = None self.size = 0 def insertAtStart(self,data): self.size += 1 node = Node(data) ...
true
50dfd4b377425832e0a75179c16433e00d68ffda
Unknown-Flyin-Wayfarer/pycodes
/7/test_if4.py
658
4.25
4
a = int(input("enter first number")) b = int(input("Enter second number")) if a > b: print("a is larger") if a > 100: print("a is also greater than 100") if a > 1000: print ("a is greater than 1000 also") print("a is only greater than and not 1000") p...
true
e0622163402f580a65518211eb3378994a15bec2
rajeshpillai/learnpythonhardway
/ex9.py
717
4.1875
4
# Exercise 9: Printing, Printing, Printing # By now you should realize the pattern for this book is to use more than one # exercise to teach you something new. I start with code that you might not # understand, then more exercises explain the concept. If you don't understand something now, # you will later as you co...
true
e4288c0c6d4b3d2decad9a22a96a79fe8b9502b7
rajeshpillai/learnpythonhardway
/ex31.py
2,038
4.59375
5
# Exercise 32: Loops and Lists # You should now be able to do some programs that are much more interesting. If you have been keeping up, you should realize that now you can combine all the other things you have learned with if-statements and boolean expressions to make your programs do smart things. # However, program...
true
b6350d9fb8134ecb5fa0d840315140af1c905978
mauriceLC92/LeetCode-solutions
/Arrays/Selection-sort.py
607
4.125
4
def find_smallest(arr): smallestIndex = 0 smallestValue = arr[smallestIndex] index = 1 while index < len(arr): if arr[index] < smallestValue: smallestValue = arr[index] smallestIndex = index index += 1 return smallestIndex def selection_sort(arr): so...
true
c6fb497553306801c5ee4c71ef33e19a832dd6f0
has-g/HR
/fb_1_TestQuestions.py
1,551
4.1875
4
''' In order to win the prize for most cookies sold, my friend Alice and I are going to merge our Girl Scout Cookies orders and enter as one unit. Each order is represented by an "order id" (an integer). We have our lists of orders sorted numerically already, in lists. Write a function to merge our lists of orders into...
true
77d6e6cd9187f8c0b5dc63059a37a717873f3717
OSUrobotics/me499
/plotting/basic.py
1,617
4.5
4
#!/usr/bin/env python3 # Import the basic plotting package # plt has all of the plotting commands - all of your plotting will begin with ply.[blah] # To have this behave more like MatLab, do # import matplotlib.pyplot # in which case the plt scoping isn't needed import matplotlib.pyplot as plt # Get some thin...
true
744b7479288431296863e7d8d2254c0cd58c1ea4
OSUrobotics/me499
/files/basics.py
760
4.40625
4
#!/usr/bin/env python3 if __name__ == '__main__': # Open a file. The second argument means we're opening the file to write to it. f = open('example_file', 'w') # Write something to the file. You have to explicitly add the end of lines. f.write('This is a string\n') f.write('So is this\n') ...
true
84eb498c2dc5b63eb5942e3bd057b1d2602c0348
OSUrobotics/me499
/control/while_loops.py
613
4.3125
4
#!/usr/bin/env python3 if __name__ == '__main__': # This is the basic form a while statement. This particular example is better suited to a for loop, though, since # you know how many times round the loop you're going to go. n = 0 while n < 5: print(n) n += 1 # This is a better e...
true
23b5df5c6836f5759b1b820eb7d57fc51d9d70ff
OSUrobotics/me499
/containers/list_comprehensions.py
870
4.3125
4
#!/usr/bin/env python3 from random import random if __name__ == '__main__': # Instead of enumerating all of the items in a list, you can use a for loop to build one. Start with an empty # list. a = [] # This will build a list of the first 10 even numbers. for i in range(10): a.append(i...
true
7730f652b4b1bb37f4e2b33533317aca526af6c0
Mksourav/Python-Data-Structures
/stringlibraryfunction.py
819
4.15625
4
greet=input("Enter the string on which you want to perform the operation::") # zap=greet.lower() # print("lower case of the inputted value:",zap) # # search=input("Enter the substring you want the find:") # pos=greet.find(search) # if pos=='-1': # print("substring not found!") # else: # print("substring spotted...
true
78345b42e8ff3dc48545a9d4d3bd1aeac5b74eef
HighPriestJonko/Anger-Bird
/Task1.py
1,366
4.15625
4
import math v = int(input('Enter a velocity in m/s:')) # With which bird was flung a = int(input('Enter an angle in degrees:')) # With respect to the horizontal d = int(input('Enter distance to structure in m:')) h = int(input('Enter a height in m:')) # Height of structure g = -9.8 # m/s^2 degC = math.pi / 180 ar = a...
true
8b11e8566191510812c33c50c77a9c4610904130
ajakaiye33/pythonic_daily_capsules
/apythonicworkout_book/pig_latin.py
1,814
4.21875
4
def pig_latin(): """ The program should asks the user to enter an english word. your program should then print the word, translated into Pig Latin. If the word begins with a vowel(a,e,i,o,u), then add way to the end of the word e.g so "air" becomes "airway" eat becomes "eatway" if the word begi...
true
25223ab1874f7cf1e492040faba073faba3881a4
ajakaiye33/pythonic_daily_capsules
/make_car_drive.py
469
4.125
4
class Car(object): """ make a car that drive """ def __init__(self, electric): """ receives a madatory argument: electric """ self. electric = electric def drive(self): if not self.electric: return "VROOOOM" else: return "WH...
true