blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7b95a8588f581ec38cc1b50875b9b2c88c4691d7
SIMELLI25/esercizi_python
/es34.py
1,679
4.15625
4
input("ES 34") #Le prenotazioni per la partecipazione a un convegno sono memorizzate secondo l'ordine di arrivo. Scrivi un programma che comprenda due funzionalità #- L'operazione per registrare i dati dei partecipanti; #- L'operazione per visualizzare i nomi dei partecipanti a cui si deve inviare una lettera di confer...
false
381b57be748331cf095cef78336c4f31b780da43
Talleyman/Test-list-generator
/TestListGeneratorV1-1.py
1,344
4.25
4
#!/usr/bin/python #Stephen Talley #Date: July 11, 2014 #Program for generating random ranked lists import random import csv import doctest #This declaration creates a two-dimensional list i.e. a list of lists (the number of lists varies up to 100) Listoflists=[[] for _ in range(random.randrange(100))] #ListCreator f...
true
e12892267cb47dfa68507b4caec7008743e39231
Alb4tr02/holbertonschool-machine_learning
/math/0x00-linear_algebra/2-size_me_please.py
365
4.125
4
#!/usr/bin/env python3 """function def matrix_shape(matrix): returns the shape of a matrix:""" def matrix_shape(matrix=None): """INPUT: a matrix OUTPUT: the shape of the given matrix """ shape = [] aux = matrix while matrix is not None and type(aux) == type(matrix): shape.append(len...
true
76e79bf0976170c8a9087ab269fe47df156476f2
DeeMATT/PythonExercises
/park_ride.py
1,770
4.40625
4
""" A program for park users of all ages to select a ride of choice """ available_rides = {'1': "Scenic River Cruise", '2': "Carnival Carousel", '3': "Jungle Adventure Water Splash", '4': "Downhill Mountain R...
true
5a3f793f5db44a632508b7ef9b8b4448d65c0944
jcclarke/learnpythonthehardwayJC
/python2/exercise15/ex15.py
506
4.4375
4
#!/usr/bin/env python2 from sys import argv script, filename = argv txt = open(filename) print "Here's your file %r:" % filename print txt.read() print "Type the file name again:" file_again = raw_input("> ") txt_again = open(file_again) print txt_again.read() # NOTE # You can run "python 2.7" in the te...
true
3d3e594708c6121e03611aa3a011bb580dc2f59e
jcclarke/learnpythonthehardwayJC
/python3/exercise15/ex15.py
508
4.46875
4
#!/usr/bin/env python3 from sys import argv script, filename = argv txt = open(filename) print (f"Here's your file {filename}") print (txt.read()) print ("Type the file name again:") file_again = input("> ") txt_again = open(file_again) print (txt_again.read()) # NOTE # You can run "python 3.6" in the t...
true
c27554e7a83f20a5ab5b1dc729e110640e16254f
cvhs-cs-2017/practice-exam-LeoCWang
/Loops.py
310
4.1875
4
"""Use a loop to make a turtle draw a shape that is has at least 100 sides and that shows symmetry. The entire shape must fit inside the screen""" import turtle sven = turtle.Turtle() def hectagon(): sven.speed(0) for i in range(100): sven.fd(10) sven.left(3.6) input() hectagon()
true
60d6c96bd3f2d9223c7905bb3932820be07a857d
younkyounghwan/python_class
/lab5_8.py
412
4.21875
4
""" 쳅터: day 5 주제: 함수 문제: 작성자: 윤경환 작성일: 18 10 04 """ #매대변수의 수정 여부 확인을 위한 하수 정의 #call-by-value 방식으로 매개변수 값을 전달 #매개변수 값을 복사(copy)하여 전달 def modify(s): s+=" to you" return s msg = "Happy Birthday" print("호출 전 msg =",msg) re=modify(msg) print("호출 후 msg =",msg) print("re=",re)
false
16014b857535a0016ab74b31beb8f333a16bbbaf
alexlouden/tetris-ai
/fileops.py
1,262
4.15625
4
#------------------------------------------------------------------------- # Name: Tetris File Operations # Purpose: Functions to read and write to disk # # Version: Python 2.7 # # Author: Alex Louden # # Created: 28/04/2013 # Copyright: (c) Alex Louden 2013 # Licence: MIT #---------------...
true
65d525337644b19c4eac0260d06f40205390865c
swap9047/Machine-Learning-by-Andrew-Ng-Coursera
/exercise_2/ex2.py
2,978
4.125
4
""" Machine Learning Online Class - Exercise 2: Logistic Regression """ ## Initialization import pandas as pd import numpy as np from scipy.optimize import minimize from ex2_utils import * ## Load Data # The first two columns contains the exam scores and the third column # contains the label. data = pd.read_csv('...
true
b9be744e56c2b91c70b1da3ceda69023022ba57d
mahajany/Python
/05_for_loop_1.py
422
4.5625
5
# Example 'for' loop # First, create a list to loop through: newList = [45, 'eat me', 90210, "The day has come, the walrus said, \ to speak of many things", -67] print ("newList[]", newList) # create the loop: # Goes through newList, and seqentially puts each bit of information # into the variable value, and r...
true
b2955d88653469995e6e438ef683425e4d783e5a
moshix/mvs
/hanukkah.py
922
4.34375
4
from datetime import datetime from calendar import monthrange def hanukkah_dates(year): # Calculate the date of Hanukkah for the given year # Hanukkah always falls on the 25th day of the Jewish month of Kislev # and the Jewish calendar is based on lunar cycles a = (year * 12 + 17) % 19 b = (year - 1) // 100 ...
false
0a7c5b48c2556bd0bbd7cdd8bbc9eb960cfd0c63
Mgrdich/algorithms_data_structures
/util/Lib.py
598
4.1875
4
import math class Lib: """ Checks a number whether it is prime or not """ @staticmethod def isPrime(n: int) -> bool: if n == 1 or n == 0 or n % 2 == 0: return False limit = math.ceil(math.sqrt(n)) for i in range(3, limit, 2): if n % i == 0: ...
true
ca711f0bd15c40cca23664045ac3974474af2ec1
sujith1919/TCS-Python
/classroom examples/strings7.py
666
4.375
4
#string indexing #string slicing a = "Good Morning" print(a[0]) #prints the first character print(a[1]) #prints the second character print(a[-1]) #prints the last character print(a[-3]) #prints the third last character #slicing print(a[5:8]) #prints from index 5 to 7 print(a[:8]) #prints from index 0...
true
13ef039681bb8fd37e1a48ea757ae81b98a3fe56
sujith1919/TCS-Python
/classroom examples/lists2.py
629
4.21875
4
#working with lists #lists are like C arrays #but a lot more flexible b = [3,6,8,4,5,6,7] #append to a list print(b) b.append(9) print(b) #insert into a list print(b) b.insert(1,200) print(b) #remove from a list print(b) b.remove(200) print(b) #pop from a list print(b) c = b.pop() print(c) ...
true
02c5be09f721a6986d414c8366a58bb791d75eb4
shashanka2a/LeetCode
/addDigits.py
428
4.15625
4
""" Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. """ def addDigits(self, num): while num>9: num=sum(int(c) fo...
true
b6ddfd1034f68fcb04d7dd7367c60d64d74c567f
xujinshan361/python_study_code
/01_Python基础/05_高级数据类型/study_17_字符串的查找和替换.py
666
4.59375
5
hello_str = "hello word" # 1.判断是否以指定字符串开始 print(hello_str.startswith("he")) # 2.判断是否以指定字符串结束 print(hello_str.endswith("word")) # 3.查找指定字符串 # index同样可以查找指定的字符串在大字符串中的索引 print(hello_str.find("lo")) # index 如果指定的字符串不存在,会报错 # find如果指定的字符串不存在,会返回-1 # print(hello_str.index("abc")) print(hello_str.find("abc")) # 4.替换字符串 #...
false
c4cf6fa16df4a73d079865b40c23c2a7a721179c
wntbrian/python-course1
/task2/function_2_while.py
788
4.15625
4
### ### Задание 2, Вариант 2, Функции №2 ### ''' Дано действительное положительное число a и целоe число n. Вычислите a в степени n. Решение оформите в виде функции power(a, n). Стандартной функцией возведения в степень пользоваться нельзя. ''' def power(a,n): pw, ls=1 if n<0: ls=n n=-n whil...
false
b609cdd515877e36fe6b0550783c0dcb7195f44e
birdming22/python_examples
/strategy/strategy_class.py
1,298
4.21875
4
"""strategy Example ref. https://sourcemaking.com/design_patterns/strategy/python/1 """ class StrategyExample(object): """Strategy Example class""" def __init__(self): self.op1 = 0 self.op2 = 0 self.result = 0 self.operation = "" def operate(self, op1, op2): """ope...
false
4c205e21356cf91cde27a0c8e474bab67c202961
eduohe/PythonCodeSnippets
/05-conditional/conditional.py
250
4.1875
4
#!/usr/bin/python3 def main(): x, y = 2,2 if x < y: print("x < y") elif x == y: print("x = y") else: print("x > y") result = "<=" if x <= y else ">=" print(result) if __name__ == "__main__" : main()
false
bf4ced295b6e35c862ddb594a3ff2ee65123d688
jacquewhitaker/jacquewhitaker.github.io
/my_website/whitsshipsv1.py
2,345
4.3125
4
''' import statements ''' from random import randint ''' declare global variables ''' # constants BOARD_LENGTH = 8 # set row cell length TURN_COUNT = 5 # number of guesses a user gets # parameter names board = [] # 1D array ship_row = 0 # default size ship_col = 0 # default size ''' initializ...
true
87906c497e3967e58098bcb2686a7b0a72b8ec1c
devilist/FirstProject
/数据类型.py
2,571
4.125
4
#! /usr/bin/env python3 counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 print(counter) print(miles) print(name) a, b, c, d = 20, 5.5, True, 4 + 3j print(type(a), type(b), type(c), type(d)) print(8 / 3) print(8 // 3) str = 'Runoob' print(str) # 输出字符串 print(str[0:-1]) # 输出第一个个到倒数第二个的所有字符 print(s...
false
1e409c70a2dbeedd726e6f22c409f8ea4e2cf1e8
pkr26/Machine-Learning
/Home Works/HW2/HomeWork(2)-Question 02.py
2,611
4.1875
4
# <h3> Implementing Perceptron Algorithm # <h5> Assumption in Perceptron Algorithms:<br> # <br><br> # <b>The Data should be Linearly Separable<br><br><br> # <b> The hyperplane or the line should pass through the origin<br> import numpy as np import pandas as pd import os #checking the path directory print("Previo...
true
0dd2757122f6f48a2a5f93398c69fe7885f779b7
sln-dns/lesson1
/dictionary.py
352
4.25
4
weather = { "city" : "Москва", "temperature" : "20" } print(weather["city"]) decrease = int(input('Введите уменьшение температуры ')) weather["temperature"] = int(weather["temperature"]) - decrease print(weather) print(weather.get("contry", "Россия")) weather["date"] = "27.05.2019" print(len(weather))
false
9ad8538c59667f174c2b664e7bec9b66571b8d71
achalesh27022003/sortlinkedlist
/sortlinkedlist.py
2,719
4.34375
4
# Represent a node of the singly linked list class Node: def __init__(self,data): self.data = data self.next = None class SortList: # Represent the head and tail of the singly linked list def __init__(self): self.head = None self.tail = No...
true
da01108bec94e563d5915681a1835b310fe83908
Miheel/PY_lab
/Lab1/sten_sax_påse/kai_bai_bo.py
1,925
4.1875
4
""" kai bai bo """ import random def rand(): """' Simple randomizer """ rng = random.randint(1, 3) return rng def main(): """ main funktion """ moves = ["Rock", "Paper", "Scissor"] player_points = 0 pc_points = 0 play_loop = True print("Welcome to the Game ROCK-PA...
false
813edeb4b243842e4bfbb4a1d0a20e705300fea8
dundunmao/lint_leet
/mycode/lintcode/Array/two sum/625 partition-array-ii.py
1,222
4.125
4
# -*- encoding: utf-8 -*- # Partition an unsorted integer array into three parts: # The front part < low # The middle part >= low & <= high # The tail part > high # Return any of the possible solutions. # # 注意事项:low <= high in all testcases. # 样例 # Given [4,3,4,1,2,3,1,2], and low = 2 and high = 3. # # Change to [1,1,...
true
3967db398f71847ed2cb8424a207c154bb3cea64
dundunmao/lint_leet
/mycode/leetcode_old/1 array(12)/hard/42. Trapping Rain Water.py
1,214
4.15625
4
# -*- encoding: utf-8 -*- # 3级 # 内容:能积多少水.Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. # For example, # Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. # ^ # 3| ■ □: water # 2| ■ □ □ □ ■ ■ □...
false
d713e35608ec089ee02f2f307c9860dacb53cb30
dundunmao/lint_leet
/mycode/lintcode/DFS template.py
1,003
4.125
4
# -*- encoding: utf-8 -*- # bfs的模板 class Node: def __init__(self, val): self.val = val self.left, self.right = None, None # 1: traverse def traverse(root): if root is None: return None traverse(root.left) traverse(root.right) # 2: divid & conquer def traversal(root): if root...
false
458a1517122fe9f0b347d3064bdf5284f5244742
dundunmao/lint_leet
/mycode/leetcode2017/Hash/350. Intersection of Two Arrays II.py
1,850
4.125
4
# Given two arrays, write a function to compute their intersection. # # Example: # Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. # # Note: # Each element in the result should appear as many times as it shows in both arrays. # The result can be in any order. # Follow up: # What if the given array is already...
true
5810283138b8e106e5ed704d29342c33b7ff4fa8
dundunmao/lint_leet
/mycode/leetcode2017/String/451. Sort Characters By Frequency.py
918
4.375
4
# -*- encoding: utf-8 -*- # 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'. Therefore "eetr" is also a valid an...
true
833b8754318f239d9cc34385fe2bca9640d8fc07
dundunmao/lint_leet
/mycode/leetcode_old/2 string(9)/125. Valid Palindrome.py
1,012
4.1875
4
# -*- encoding: utf-8 -*- # 2级 # 题目:回文正反都能读 # 例如:"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a palindrome. # 思路:str.isalnum()判断是否为非数字字母的str。两个指针,分别从前和后往前遍历。记住这段code class Solution: # @param s, a string # @return a boolean def isPalindrome(self, s): if not s: ret...
false
3e43d498d3ed43cec67f25ed8d59623f8cf13f59
Aaqib925/Assignment
/assignment 5.py
2,883
4.25
4
# Question 1 # Write a Python function to calculate the factorial of a number (a non-negative # integer). The function accepts the number as an argument. def fact(num): """ functions which finds a factorial value of the number """ factorial = 1 if num < 0: return "The factorial of the negative num...
true
b9afcbbeb6631087b2352ca2423406ff4fb850c9
maxitaxi03/Python_stuff
/conditions.py
268
4.28125
4
#num= input("Enter number: ")this generates an error because the input function assumes it's a string type num = int(input("Enter number: ")) if num > 0: print(f"{num} is positive.") elif num < 0: print(f"{num} is negative.") else: print(f"{num} is zero.")
true
6931ae5dafc4d5d0d8b29b879e53098c28edfde7
acepele/PRG105
/retirement_savings_calculator.py
1,049
4.15625
4
age = int(input("How old are you currently?")) retire_age = int(input("At what age do you want to retire?")) income = float(input("What is your yearly income?")) percentage = float(input("What percent of your income do you save?")) savings = float(input("How much money do you currently have in your savings?")) p...
true
0e9382996e3c3ac4abbec2697973755b74af3451
DongmeeKim/Python-Study
/dictionary set/set.py
1,307
4.15625
4
# 집합 (Sets) ss = set(['a','b','c']) print(ss) ss = set([1,2,3]) print(ss) ss = set("Good Morning") print(ss) # 집합을 인덱싱하기 -> list 사용 ss1 = set([1,2,3]) li = list(ss1) print(li[2]) # 교집합, 합집합, 차집합 s1 = set([1,2,3,4,5,6,7]) s2 = set([3,5,6,8,9]) # 교집합 : & print(s1 & s2) # 합집합 :| or .union() print(s1 | s2) print...
false
c2b339938731d8d089f33f03fe5bbde22a5719e5
OdessaRadio/Complete_Python_Developer_in_2020-Zero-to-Mastery
/Python_Basics_3/formatted_strings.py
996
4.375
4
# formatted strings # name = "Johnny" # age = 55 # # print('Hi '+ name + '. You are ' + str(age)) # print(f'Hi, {name}. You are {age} yers old') # f tells Python that this is formatted string # print('Hi, {}. You are {} yers old'.format('Johnny', '55')) # print('Hi, {}. You are {} yers old'.format(name, age)) # pr...
false
c107ab318900e779ad761d01eae972b8e4ffccbf
OdessaRadio/Complete_Python_Developer_in_2020-Zero-to-Mastery
/Python_Basics_3/built_in_functions_methids.py
335
4.125
4
print(len('0123456789')) # len -> lenght ofthe string greet = '0123456789' print(greet[1:]) print(greet[0:len(greet)]) quote = "to be or not to be" print(quote.upper()) print(quote.capitalize()) print(quote.find('be')) print(quote.replace('be','me')) print(quote) # strings are immutable. So it will print "to be ...
true
dd3c00d69811963353e85a59072c510846c7a4dd
ananddasani/Python_Practice_Course
/Quick_Basic/9.practice_List_and_tuples.py
782
4.4375
4
# Take DOB from user as a format DD-MM-YYYY and print the name of month the user is born in months = ["january", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] # taking input as a string DOB = input("Enter your DOB in DD-MM-YYYY formate :: ") ...
true
c3b32a9a5281c3c2b56d9125376718f943199953
ananddasani/Python_Practice_Course
/Quick_Basic/20.functions.py
698
4.40625
4
# program to demonstrate the functions in python # function without args def say_hello(): print("Hello python :)") say_hello() # function with args def say_hello_args(arg1, arg2): print("Hello " + arg1 + " how are you doing ? " + arg2 + " is waiting for you :)") say_hello_args("anand", "om") ...
false
ebcbeabb3bb8a028da820c2ad96e33eefa3b7982
xukangjune/Leetcode
/solved/23. 合并K个排序链表.py
1,952
4.15625
4
""" 这道题有好多解法。首先我写的是将所有链表的第一个节点值(如果有的话)放在一个临时的数组中,然后再这个数组中找到最小的值,将这个 最小值当作返回链表的下一个节点,然后找出这个数在临时数组的下标,只是临时数组和链表数组一一对应的,就可以映射到链表数组中,接着 判断对应的链表下一个节点是否为空,如果为空则是一番操作,不是另一番操作。 其实,这道题用暴力法是最简单的,也是最快的。直接将所有链表的所有节点值加入一个数组,然后直接排序。 还有一个就是将所有的链表两两合并,然后将新的链表与下一个链表合并,直到结束。 """ # Definition for singly-linked list. class ListNode: d...
false
f460de727a2021b774bdb3a4d1f3b870dcfa6f5b
xukangjune/Leetcode
/solved/334. 递增的三元子序列.py
1,540
4.15625
4
""" 有时候能想到好想法,却在一些细节方面没有做到优化。这一题由于只要三个数递增就好了,所以先设置两个数为无穷大,当有数 大于第二个数时说明有三个数递增。假如大于第一个数而小于第二个数,那么就第二个的数替换成num。因为大于second的一定会 大于num,这样就扩大了查找的范围。假如num小于第一个数,那么将first换成num,因为不影响second的取值范围,这样如果 后面的数小于second而大于现在的num,那就将second替换,这样原来的first和second就换成了更小的两个数,这样扩大了查 找的范围。 """ class Solution: def increasingTriplet(self, nu...
false
1133aecb5df8171f339f47e4c997bc86771c36a2
leandrolimasp/python-apps
/calculator.py
926
4.1875
4
class Calculator: def __init__(self): pass def calculate(f): while True: print('\n===== CALCULATOR =====\n') print(' 1 -- Addition') print(' 2 -- Subtraction') print(' 3 -- Multiplication') print(' 4 -- Division') print(' 5 -- Percentage') print(' 6 -- Exponentiation') print(' 7 -...
false
7bd95ca78d13d09d3c902766e58f37d251ad9d7d
jc2c2/pygameTIII2020
/Introduccion a Python/ejemplo2.py
1,048
4.25
4
# Estructuras de Control """ Operadores Relacionales == igual != no es igual < menor > mayor <= menor igual >= mayor igual Operadores Logicos and -> y logico -> && or -> o logico -> || not -> negacion -> ! Operadores de identidad is -> pertence a is not -> no pertenece Operadores de membresia in -> apare...
false
2dbf8950e0e0401f7d63d8050560c09e5f16e210
jboe10/python_practice
/Sorting_Algorithms/Insertion_Sorts/insert.py
280
4.15625
4
def insertion_sort(array): for i in range(1,len(array)): key = array[i] follow = i -1 while follow >= 0 and key < array[follow]: array[follow+1] = array[follow] follow -= 1 array[follow+1] = key array= [1,3,411,23,142,33,21,9] insertion_sort(array) print(array)
true
71b0a1c14c7ce3d51fc7fbb8efcac58303efa61f
jboe10/python_practice
/Trees/Max_heap/max_heap2.py
1,609
4.3125
4
class node: def __init__(self, value = None, color = "black"): self.value = value self.left = None self.right = None self.color = color class red_black: def __init__(self): self.root = None #this makes it so we dont have to worry about root/parent being empty def insert(self, value): if self.root...
true
d8558d872368bce9acbce46503b5fc0f0e23d1d9
gmcapra/Python-Data-Structures
/Array Sequences/dynamic_array_example.py
2,089
4.28125
4
""" -------------------------------------------------------------------------------- Dynamic Array Exercise Project -------------------------------------------------------------------------------- Gianluca Capraro Created: July 2019 -------------------------------------------------------------------------------- The pu...
true
6564c454e3c628e6ac4d72af5a0d29bc5da62368
emanmacario/dsa
/ctci-solutions/ch-08-recursion-and-dynamic-programming/01-triple-step.py
2,071
4.53125
5
# Triple Step: A child is running up a staircase with n steps and can hop either # 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many # possible ways the child can run up the stairs. # Hints: #152, #178, #217, #237, #262, #359 # -- Solution # Here is a general solution for climbing n steps ...
true
0fcd282fe6957aeff00209bc387b709feb439706
emanmacario/dsa
/ctci-solutions/ch-01-arrays-and-strings/01-is-unique.py
449
4.15625
4
# Implement an algorithm to determine if a string has all unique characters. What if you # cannot use additional data structures? # Hints: #44, #117, #732 def is_unique(string): seen = set() for char in string: if char in seen: return False seen.add(char) return True def mai...
true
8c40a3d75548b9ad23854b29281296897b64d6ea
emanmacario/dsa
/ctci-solutions/ch-01-arrays-and-strings/09-string-rotations.py
912
4.59375
5
# String Rotation: Assume you have a method isSubstring which checks if one word is a substring # of another. Given two strings, sl and s2, write code to check if s2 is a rotation of s1 using only one # call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat"). # Hints: #34, #88, #104 def is_substring(s...
true
c371018c53ce4f396ac65f2ed3738a0c4088866e
emanmacario/dsa
/epi-solutions/ch-11-searching/06-search-2d-sorted-array.py
1,829
4.3125
4
# Call a 2D array sorted if its rows and its columns are nondecreasing. # For example: # -1 2 4 4 6 # 1 5 5 9 21 # 3 6 6 9 22 # 3 6 8 10 24 # 6 8 9 12 25 # 8 10 12 13 40 # Design an algorithm that takes a 2D sorted array and a number and checks # whether that number appears in the arra...
true
3f0b3b2ee8f5a58f4f1fc25114c095461bce3a37
emanmacario/dsa
/ctci-solutions/ch-04-trees-and-graphs/03-list-of-depths.py
1,825
4.28125
4
# List of Depths: Given a binary tree, design an algorithm which creates a # linked list of all the nodes at each depth (e.g., if you have a tree with # depth D, you'll have D linked lists). # Hints: #107, #123, #135 # -- Auxiliary data structures # Definition for singly-linked list class ListNode: def __init_...
true
72d54cbbf3fac238508d8d9ef2770035577768ce
emanmacario/dsa
/ctci-solutions/ch-02-linked-lists/04-partition.py
1,831
4.3125
4
# Partition: Write code to partition a linked list around a value x, such that all nodes less than x come # before all nodes greater than or equal to x. If x is contained within the list, the values of x only need # to be after the elements less than x (see below). The partition element x can appear anywhere in the # "...
true
6c53d466477ed42be9fd961c9d748cc004e08fd2
pierre-ecarlat/algorithms_experiments
/leetcode_mess/q3.py
1,130
4.28125
4
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ------------------------------ Find All Duplicates in an Array ------------------------------ Given an array of integers, 1 &le; a[i] &le; n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear t...
true
0e22de1ec890cf31a9ee06053a8e9e7e06e235d5
projectPythonator/portfolio
/ProjectEuler/Python/p4.py
1,139
4.125
4
def is_palindrome(num): return (str(num) == str(num)[::-1]) def sol2(limit): largest = 0 a = 999 lim = 100 while lim <= a: b = 999 while a <= b: ab = a*b if ab < largest: break if is_palindrome(ab): largest = ab ...
true
78e7ebb88d26be732ccf0d5cdf68d1ace21449fa
JJWren/Python_UniversityStudyGroup_ConsoleApps
/pythonGraphicPrograms/drawObjectsTest.py
941
4.125
4
import graphics from graphics import * def main(): print("\n***** Graphics Test *****\n") print("This program generates a window\nwith some shapes drawn in.\n") # Open a graphics window win = graphics.GraphWin('Shapes') # Draw a red circle centered at point (100, 100) with radius 30 center = ...
true
4fa3c4eef05f5c4bd508b40bcde7c34aab5c7f0f
gurhanPro/Interview_questions_python
/array_manipulation.py
1,669
4.3125
4
""" Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in your array. For example, the length of your array of zeros . Your list of queries...
true
0bb193c09a34cbee9919ab598d8bcd91842bccad
Simiopolis/exercises
/reddit_dailyprogrammer/challenge_1_difficult.py
862
4.125
4
# Objective: # we all know the classic "guessing game" with higher or lower prompts. # lets do a role reversal; you create a program that will guess numbers # between 1-100, and respond appropriately based on whether users say that # the number is too high or too low. Try to make a program that can guess # your num...
true
0e6734de8f1b69456245db2093565f394b336064
ShivaGanapathy/PascalsTriangleGenerator
/PascalsTriangle.py
2,247
4.375
4
''' create a program that will result in an output of n rows of Pascal's Triangle ex. if n is 3 the out put should look like this: 1 1 1 1 2 1 ''' def get_input(): """ This Function handles the user input process, ensuring that the user enters an positive integer. The Function has no arguments and returns an in...
true
ab04240722c919c0951f3619a7743ec7e51ad9b8
Abulero/Sorting-Algorithms
/SelectionSort.py
422
4.1875
4
def selection_sort(numbers): for i in range(len(numbers)): for index in range(len(numbers) - i): if numbers[index + i] < numbers[i]: swap(numbers, index + i, i) def swap(numbers, a, b): numbers[a], numbers[b] = numbers[b], numbers[a] if __name__ == '__main__': numbers ...
true
63408a0a5e0bb8a9532957f0bacea05370a46753
anuragpatil94/Python-Practice
/cracking-the-coding-interview/StacksAndQueues/3.3_StackOfPlates.py
2,654
4.15625
4
""" Stack of Plates: Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be comp...
true
e08f6a2482e6bf944979357d204e771a706a4e26
anuragpatil94/Python-Practice
/cracking-the-coding-interview/ArraysAndStrings/CTCI_01_IsUnique.py
738
4.1875
4
""" Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? My Solution With additional data structure - using set to check if a duplicate character exists """ class Solution: def isUnique(string): """ ...
true
8d5c88069762040ae079b394dd8edb7be0b4d51e
anuragpatil94/Python-Practice
/cracking-the-coding-interview/LinkedList/2.5_SumLists.py
2,976
4.3125
4
import sys sys.path.insert(0, "../../") from conceptual.linked_list import LinkedList """ 2.5 Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write...
true
9db68315acd436a621caa8bf8ccf8f2dd1ddfaeb
anuragpatil94/Python-Practice
/cracking-the-coding-interview/LinkedList/2.6_Palindrome.py
1,656
4.375
4
import sys sys.path.insert(0, "../../") from conceptual.linked_list import LinkedList """ Important 2.6: Palindrome Implement a function to check if the linked list is the palindrome Solution: - Get the Middle Element in Recursion - using the (length - 2) in the recussion which will ...
true
f31269622691bb450c41d584b36b206670658d56
anuragpatil94/Python-Practice
/OnlineAssessmentQuestions/N16_FindPairWithGivenSum.py
1,166
4.15625
4
""" Given a list of positive integers nums and an int target, return indices of the two numbers such that they add up to a target - 30. Conditions: You will pick exactly 2 numbers. You cannot pick the same element twice. If you have muliple pairs, select the pair with the largest number. Example: Given nums = [...
true
4123ec6a578d0e18c1a1a983334dd43c89dab311
anuragpatil94/Python-Practice
/interview-questions/find_nth_smallest_in_the_set.py
2,569
4.125
4
""" Find the Nth Order Statistic for a given array of numbers Steps : Find the Smallest Number - this is straightforward O(n), Find 2nd Smallest Number - Brute Force - Find Minimum - swap with 1st element - then again loop the remainder to find 2nd shortest - O(n**2) Best Possible - Have two index - 1st...
true
34678fcd907333314101b255a796553ea1c33ff9
nileshsharma-cloud/PythonProjects
/pythonExamples/loopExamples.py
345
4.34375
4
names = ['Nilesh', 'Ashesh', 'Ashwani'] month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] for i in names: invite = "Hi " + i + "! Please come to my party." print(invite) for i in month: month_names = "Hi!!! This month is : "...
false
83f85fdf1c3bc565f34406e38bb459000e27d864
Luke-Callaghan23/Synonyms
/find_synonyms/scripts/clean_word.py
554
4.15625
4
from functools import reduce def clean_word (word): word = word.strip().lower() # step 1: remove excess spaces and turn to lower case word = reduce ( # step 2: split the word on all spaces and only keep the longest one lambda acc, word: ( # (sometimes the api will return words lik...
true
2521f29cf2a56ef7ceab46a579f918ad465a50ec
xieqing181/Pythonwork-Chapter9
/Admin.py
1,818
4.28125
4
class User(): '''save the user's first name, last name, and middle name, also some other info, like height, weight, and username.''' def __init__(self, first, last, height, weight, username, middle=''): self.first = first self.last = last self.height = height self.weight = weight self.username = username...
true
df436d40ab69118a77486626781563eb5d2fa844
PythPeri2017/PyProgFall2017
/pitonozavr/l11/racing.py
1,341
4.3125
4
# Описываем участников - скорость, нитро, бак, расход топлива, пройденный путь, # имя. # На выбор: обычная скорость, нитро - расход топлива 3x - каждый ход # Побеждает тот, кто приехал первый, либо тот, у кого позже закончилось # топливо. def eezzzee(car): car["distance"] += car["speed"] car["fuel"] -= car["expen"] ...
false
d4c47fd2f50219fab61b8e311875e3988de33575
toralero/PyRes
/5/errorhandling.py
337
4.25
4
while True: try: age = int(input("What is your age?: ")) except ValueError: print("Age has to be an integer.") print("Please answer the question again.") print() continue else: break if age < 18: print("You are still not an adult.") else: print("You a...
true
bf64c7fd11d3fe7626b2498e708bad6d9a30741a
toralero/PyRes
/3/listinlist.py
881
4.5
4
# A class of students class_a = ["Edward", "Sally", "Oscar", "Ana"] class_b = ["Steve", "Julius", "Jenny", "Stacey"] class_c = ["Aubrey", "Kyle", "Bob", "Velma"] # A year with multiple classes year_3 = [class_a, class_b, class_c] # A year directly year_3 = [["Edward", "Sally", "Oscar", "Ana"], ["Steve", "Ju...
false
b261320bc145ee14419755e8cc3c316e779a7248
alhanoufN97/Python
/W5L30.py
371
4.21875
4
print("Range #1 : ") for x in range(9) : print(x) print("Range #2 : ") for x in range(3,9) : print(x) print("Range #3 : ") for x in range(3,20 , 15) : print(x) print("Range #4 : ") for x in range(3) : print(x) else : print("Final loop ") Digital = ["A","B","C" , "D"] Num = [1,2,3,4,5] for x ...
false
80599480442c344e02401dc5991c1cb2862e7460
Despaquitoe/Guisa_story
/2.py
302
4.25
4
# Write a program that will ask the user what their age is and then # determine if they are old enough to vote or not and respond appropriately ask=input("How old are you?") elif ask >= int(18): print=("What a little youngster") if (18-100): print=("Would you like to vote?") int()
true
c2449b9d45fecd27e6872e9a05e1ea7381998c8e
PriraRoja/python_training
/day1/matrix.py
365
4.1875
4
row = int(input("Enter the no of rows:")) col = int(input("Enter the no of columns:")) mat = [] print("Enter the numbers:") for i in range(row): a =[] for j in range(col): a.append(int(input())) m.append(a) for i in range(row): for j in range(col): ...
false
6936bac435aad77d243c975a2295281ab90e65f4
rosemary-c/codingDojo
/python/printListType.py
1,169
4.28125
4
''' Assignment: Type List Write a program that takes a list and prints a message for each element in the list, based on that element's data type. Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, ad...
true
a934712e523a820f64e266beb891d660feeb367b
sunnychemist/pylearn
/python_tutor/07_lists/rank.py
1,119
4.34375
4
def rank_position(list_u, x): """ Source https://pythontutor.ru/lessons/lists/problems/lineup/ Condition Petya moved to another school. In a physical education lesson, he needed to determine his place in the ranks. Help him do this. The program receives a non-increasing sequence of natural...
true
0b6698b58ff23e2f5cc88d36ad2e7f26cd67b847
IvanDanyliv/python
/lab7_4.py
220
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def encryption(expression: str) -> str: lst = list(map(lambda x: chr(ord(x) + 1), expression)) return ''.join(lst) print(encryption(input("Input your string: ")))
false
dfdca5d2079d4ef7bf0b00f2638511769a5c0cda
qiubite31/Leetcode
/Tree/leetcode-872.py
1,507
4.28125
4
""" 872. Leaf-Similar Trees Difficulty: Easy Related Topic: Tree, Recursive Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8). Two binary trees are considered leaf...
true
cbcc8e3955cecdbf3d5bdacb6a8b4cbae8b6ba6b
qiubite31/Leetcode
/Hash/leetcode-500.py
1,268
4.125
4
""" 500. Keyboard Row Difficulty: Easy Related Topic: Hash Table Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. American keyboard Example 1: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"...
true
d4e3e9bbe62976988977347d81510912dd0b767f
aratik711/100-python3-programs
/92.py
602
4.1875
4
""" Manage a game player's High Score list. Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the thr...
true
76c486ecc32a8632f9d39a8fc6c375dd933ae707
aratik711/100-python3-programs
/48.py
316
4.34375
4
""" Define a class named Circle which can be constructed by a radius. The Circle class has a method which can compute the area. """ class Circle(object): def __init__(self, radius = 0): self.radius = radius def area(self): return self.radius**2*3.14 circle = Circle(5) print(circle.area())
true
24477e86ca72c6bbd3285942d61766633f0fc845
aratik711/100-python3-programs
/94.py
1,065
4.3125
4
""" Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! When cells divide, their DNA replicates too. Sometimes during this p...
true
752c24c84d3e8b266dcbb5fcd71ff0fb184f83db
keishi25/work-codes
/class/classmethod.py
1,199
4.21875
4
""" classmethod使用方法 メリット:クラスから直接メソッドを呼べる(クラスをインスタンス化する必要なし) 使われるケース:メソッドの処理とそれに基づいて変更されたインスタンス変数にアクセスできる """ # classmethodを使用しないケース class Item1: def __init__(self, id, name): self.id = id self.name = name def retrieve_item(id): data = {"name":"taka"} return Item1(id, data["name"]) # c...
false
660bac6a3ee2b739922073a0ea59f5fdf0086371
romulogm/EstudosPython
/cursoUSP/ordenacao.py
327
4.15625
4
def main(): num1 = float(input("Insira um número: ")) num2 = float(input("Insira um número: ")) num3 = float(input("Insira um número: ")) if (num1) < (num2) and (num2) < (num3) or num1 < 0 and num1 > num2 > num3: print ("crescente") else: print ("não está em ordem crescente") main(...
false
87346f0af31de16e7e808a7379cbc73bdd42c5d6
JunDang/MIT-Python
/CreditCard1.py
994
4.125
4
''' Monthly interest rate= (Annual interest rate) / 12.0 Minimum monthly payment = (Minimum monthly payment rate) x (Previous balance) Monthly unpaid balance = (Previous balance) - (Minimum monthly payment) Updated balance each month = (Monthly unpaid balance) + (Monthly interest rate x Monthly unpaid balance) ''' def...
true
9d813ebf826f742a7c2027836a2cb0d64a7118b9
markwang922/markwang922
/Python/Test/copylist.py
295
4.15625
4
# 题目:将一个列表的数据复制到另一个列表中。 # -*- coding: utf-8 -*- def copy_list(arg): list_in = [] for i in arg: list_in.append(i) return list_in if __name__ == '__main__': list1 = [1, 2, 4, 5, 3] list2 = copy_list(list1) print(list2)
false
5c1dccfbf85eb8a5f44bee2c55affd997ccec8ba
dileepachuthan/Python-Exercise
/Exercise_9.py
1,140
4.21875
4
Pretend that you have just opened a new savings account that earns 4 percent interest per year. The interest that you earn is paid at the end of the year, and is added to the balance of the savings account. Write a program that begins by reading the amount of money deposited into the account from the user. Then your pr...
true
f6276c8a2b723d2c37dbf1a3e21592a4b4d8492a
Divyansh-03/PythoN_WorK
/Denomination.py
521
4.125
4
''' A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer. ''' amount = int(input(" Enter the Total Amount in Hundreds ")) notes_...
true
3173330493eb58230febd9caeee826a2cd2dff52
Divyansh-03/PythoN_WorK
/distance.py
456
4.40625
4
''' The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters. ''' dist_km = float(input("Enter distance in kilometres" )) print(" The distance in meters is " + str(dist_km*1000.0) + " The distance in feet is "+ st...
true
d0f94f29be1cc7a4f9d2708d6fbcf4870c768522
Divyansh-03/PythoN_WorK
/Largest3.py
1,089
4.375
4
''' Input any three number and display which one is largest according to given situation and result; n1 n2 n3 Output 5 5 5 All Three Are Equal 5 5 2 First and Second Number are Largest 5 2 5 First and Third Number are Largest 2 5 5 Second and Third Number are Largest 5 1 2 First Number is Largest 5 11 2 Second Number ...
false
f6060dbd91f4a1e6871a97fb2db1f46be5bb56a0
Divyansh-03/PythoN_WorK
/4company.py
935
4.21875
4
''' In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to ...
true
a22c2139f716074a184fac5f560fd2e98914cf72
Divyansh-03/PythoN_WorK
/youngest.py
920
4.15625
4
''' If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three. ''' n1 = int(input(" Enter Ram's age ")) n2 = int(input(" Enter Shyam's age ")) n3 = int(input(" Enter Ajay's age ")) if n1==n2 and n2==n3 : print(" All Three are of equal ages. ") else : i...
false
2ca40ae8cb5255db3205a56d75f9da920f2d500a
brandonnorsworthy/ProjectEuler
/python/p004.py
619
4.125
4
#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. foundnumber = 0 for x in reversed(range(900,1000)): for y in reversed(range(900,1000)): number = ...
true
7fab1cd207ab3b2afc933d6e226c5c7ab9e78f01
Vibhushit07/Python
/Case Studies/cs7.py
611
4.40625
4
''' You are given a string that was encoded by a Caesar cipher with an unknown distance value. The text can contain any of the printable ASCII characters. Suggest an algorithm for cracking this code. - Input Plain Text & its Cipher Text - Output distance value d. ''' def findDistance(cipherText, ...
true
fd9f2e759e086f928e09ae35c1e089bdf8104c50
Vibhushit07/Python
/Case Studies/cs5.py
753
4.375
4
''' Write the encrypted text of each of the following words using a Caesar cipher with a distance value of 3: a. python b. hacker c. wow And then decrypt it also. Write different scripts for encryption & decryption. ''' def encrypt(string): enc = "" for i in string: if ord(i) <...
true
3cfb8695374c6784e4d386f865f513d545814903
David-Guri/python
/to-do-list.py
1,254
4.125
4
print(' ') print('Hi, David!') print('Welcome back to your to-do list') thislist = ['Learn the basics of python', 'Learn the basics of vim', 'Play with PS4', 'Take a sh*t'] print('Number of items in your list: ' + str(len(thislist))) print('Curren...
true
eb93a34f3046548ebdff20a0817e6658b9bf52f3
agiratech/yelp-review-text-analysis
/scripts/data_pre_processing.py
790
4.15625
4
import nltk,re # strip the suffix # stemming def stem(word): regexp = r'^(.*?)(ing|ly|ed|ious|ies|ive|s|es|ment)?$' stem, suffix = re.findall(regexp, word)[0] return stem raw = "There's a lot going on in this pipeline. To understand it properly, it helps to be clear about the type of each variable that it menti...
false
38e4c254c0030c1771664c1e55c9dec2bc1d7fda
konstantinskorin/python_tasks
/Scripts/task_1.py
556
4.125
4
#!/usr/bin/env python def my_dict(key,value): while len(key)>len(value): value.append('None') #добавляем значение 'None', если список key больше return dict(zip(key, value)) #zip создает объект-итератор, из которого извлекается кортеж, состоящий из двух элементов - первый из списка key, второй из списка value...
false
95b555a7283f61d41194d216f2d807dabcc055dc
SumanSudhir/Automatic-Speech-Recognition-CS753
/Assignment1/search.py
1,067
4.3125
4
''' The function of this code is to search for given word when it is searched in FST ''' import argparse ap = argparse.ArgumentParser() #ap.add_argument("--l_fst", type=str) ap.add_argument("--words", type=str) args = ap.parse_args() input_txt = open("input.txt", 'r') word_fst = open('word.fst', 'w') word_fst.wri...
false