blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
90cf8e58771153b9d8da3aa4f7524c02f44eed9c
CoderTitan/PythonDemo
/PythonStudy/10-读取文件和自动化办公/1-读取csv文件/1-读csv文件.py
402
3.53125
4
import csv def readCsv(path): infoList = [] with open(path, "r") as f: allFileInfo = csv.reader(f) print(allFileInfo) for row in allFileInfo: infoList.append(row) return infoList path = r"/Users/quanjunt/Documents/Quanjun/GitHub/PythonDemo/PythonStudy/10-读取文件和自...
b63bd6967251eab4fffb8d5428a0ae5a46bafd12
xdejavu/BilsemDersPython
/Ders8/uygulama.py
242
4.03125
4
#Listede tanımlanan değerlerden çift olanlarını ekrana yazdırınız. liste = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in liste: if i % 2 == 0: print(i) #sayi%5==1 #bu şu demek sayının 5 e bölümünden kalan 1 dir
a55738bbe9bfbb83a3b1cf3c7279621e1502f645
ejgm99/SnackLauncher
/ThreadingExample.py
1,430
4.0625
4
from threading import Thread import time global cycle cycle = 0.0 class Hello5Program: def __init__(self): self._running = True def terminate(self): self._running = False def run(self): global cycle while self._running: time.sleep(5) #Five second delay ...
1444a71c5aa53badaf599d85605d118ac4311e50
samuroi/SamuROI
/samuroi/masks/mask.py
1,348
3.71875
4
from abc import abstractmethod class Mask(object): """If a mask is mutable, it needs to provide a changed signal, which is supposed to be triggered upon modification.""" # count created objects, useful for creating suffixes __count = {} def __init__(self, name=None): if name is None: ...
81f19a2e56197d8a66314768d1168f50ec035ee9
manbalboy/python-another-level
/python-basic-syntax/Chapter04/03.입력과 자료형 변환.py
534
3.78125
4
x = input("첫번째 숫자를 입력하세요 >>> ") y = input("두번째 숫자를 입력하세요 >>> ") # 자료형 확인하기 : type(x) print(type(x), type(y), sep=", ") print("두개의 숫자를 더한 숫자는 : ", int(x) + int(y)) z = input("태어난 년도를 입력하세요 >>> ") age = int(2021) - int(z) + 1 print("나이는 " + str(age) + "입니다") # 정리 # 1. 사용자로 부터 입력받기 # input("입력할 시 출력할 메세지") # 2. 자료형...
adb7319054b28f4b8f292ea57c168e22029a2f42
anuragmb/Python
/TicTacToe.py
1,772
3.890625
4
board={'9':' ','8':' ','7':' ', '4':' ','5':' ','6':' ', '1':' ','2':' ','3':' '} #Game Board For Player 1 def print_board1(ch): board[ch]='*' print(board['7'] + '|' + board['8'] + '|' +board['9']) print("______") print(board['4'] + '|' + board['5'] + '|' +board['6']) print("______") print(board['1'] + '|' + bo...
5612b634f94e0d1d382087c6ccae412a6dea4ce3
Peixinho20/Fundamentos-da-Computacao
/ex005l1.py
486
3.75
4
''' Crie um algoritmo que imprima o peso total que será carregado por um caminhão. Sabe-se que este caminhão carrega 25 caixas. O peso de cada caixa deve ser informado pelo usuário. ''' pt = 0 caixa = 0 peso = 0 peso = float(input('Digite o peso de uma caixa em kg: ')) while caixa <= 25: caixa = caixa + 1 pt =...
6c0e0469ab94a46eb2493f58f325abbc907e1cbd
Peixinho20/Fundamentos-da-Computacao
/python2/minuscula.py
177
4
4
#Faça um programa que leia uma string e crie uma outra string igual, mas com todos os caracteres em minúsculo. frase = raw_input("Digite uma frase: ").lower() print frase
e0d3b5e35f278c886e694dc6245cbcabd2808557
Peixinho20/Fundamentos-da-Computacao
/python2/nota-cem-alunos.py
418
3.90625
4
#Faça um programa em pascal para ler as notas de 100 alunos e imprimir quantos alunos tiraram nota abaixo da media da turma e quantos tiraram acima ou igual a media. soma = 0 cont = 0 notas = [0.0]*100 for i in range(0,100): nota = float(input("nota: ")) notas[i] = nota soma += notas[i] media = soma/100 print "medi...
3c415b144afaea764fe93fd7c2f991b1b1418920
Peixinho20/Fundamentos-da-Computacao
/python2/salario-comissao.py
411
3.671875
4
''' Um funcionário recebe um salário fixo mais 4% de comissão sobre as suas vendas. Faça um algoritmo que receba o valor do salário fixo do funcionário, o valor das suas vendas e que calcule e mostre o salário final do funcionário. ''' salario = input("Entre com seu salario: ") vendas = input("Entre com a quantidade de...
03396c1955a224c6f2ff19be78443181a0f39d76
Peixinho20/Fundamentos-da-Computacao
/ex006l1.py
543
3.71875
4
# Crie um algoritmo que leia a quantidade e o preço de 50 produtos comprados # por uma empresa. Ao final deve ser escrito o total gasto pela empresa. quantidade = 0 vpreco = [0.0]*2 preco = 0.0 soma_preco = 0.0 while quantidade < 2: for i in range(0,2): preco = float(input('Digite o preço do produto: ')) ...
19f9dc7c05db3373a6908c5b13e7ce378168df70
Peixinho20/Fundamentos-da-Computacao
/python2/conversao-tempo.py
286
3.71875
4
''' Faça um algoritmo que leia os valores em hora, minuto e segundo e imprima tudo em segundo. ''' hora = input("Quantas horas: ") minuto = input("Quantos minutos: ") segundo = input("Quantos segundos: ") total = hora*3600 + minuto*60 + segundo print "Tempo total em segundos: ",total
23f7842edca89d24626d252e1996fdf7c19b9a92
bwopez/japanese_helper
/character_sets/fill_scriptv2.py
631
3.8125
4
import json, pyperclip def Convert(a): it = iter(a) res_dct = dict(zip(it, it)) return res_dct def printing(file_name): fo = open(file_name, "r", encoding="utf8").read() pyperclip.copy(fo) pasted = pyperclip.paste() my_arr = pasted.replace("\r", "").split("\n") dictiona...
4824e8b0042e6f1297376d54ee8281e2b4c34762
anilpolineni/Django-Training-Program-Batch-7
/Day-2(06-10-2020)/SdcDjango/SingleInheritance.py
243
3.5625
4
class ClassA: a=20 b=30 def display(): return "I am from ClassA" def add(x,y): return x+y class ClassB(ClassA): d=20 f=30 def show(): return "i am from ClassB" obj=ClassB print(obj.show())
90db55f25f15380b9251a72d2341ed742c775c86
ahmad-elkhawaldeh/ICS3U-unit3-07-python
/age.py
518
3.828125
4
#!/usr/bin/env python3 # Created by: Ahmad El-khawaldeh # Created on: Dec 2020 # This program uses a compound boolean statement def main(): # input age = print("Enter your age ") age_string = input("Enter Here plz : ") # process & output try: age = int(age_string) if age >= 25 a...
9f4484263a07de99d0e1c02fd29ead34a0b9fd1f
emehbak/python
/p1.10.max_age_and_second_max.py
267
3.96875
4
#to find out the maximum age and second maximum age age1=0 age2=0 input_age=int(input()) while input_age!=-1: if input_age>age1: age2=age1 age1=input_age elif input_age>age2: age2=input_age input_age=int(input()) print(age1,age2)
0c8ce4349793bf179688bbd5a6968871a871ace0
emehbak/python
/p3.6.py
224
4.3125
4
#if reverse of the word is same as the word , print palindrome vorodi=input() vorodi=vorodi.lower() reverse='' for i in vorodi: reverse=i+reverse if vorodi==reverse: print('palindrome') else: print('not palindrome')
01039264f2c2376ed606701d5e3b0aac67b3cafe
emehbak/python
/p3.2_2.py
283
3.5
4
adad=input() yek=adad.count('1') doo=adad.count('2') seh=adad.count('3') yek_1='' doo_1='' seh_1='' for i in range(1,yek+1): yek_1='1'+'+'+yek_1 for i in range(1,doo+1): doo_1='2'+'+'+doo_1 for i in range(1,seh+1): seh_1='3'+'+'+seh_1 x=yek_1+doo_1+seh_1 print(x[:-1])
49a68bcea1ab65d98a93ff7aa15c8e7b16833fc2
EliVaudrin/etgg1801-lab01-eli_vaudrin
/EliVaudrinLab01.py
666
3.90625
4
#ETGG 1801 #Eli Vaudrin #Lab 1-Hello World #Date:9/2/2020 f = "Eli" l = "Vaudrin" x = 42.68 y = 28 print("Lab01 created by: Eli Vaudrin") print("Eli", end= ' ') print("Vaudrin", end='\n') import math print("The hypotenuse lenghth is", math.hypot(x, y),"if the other sides are", (x),"and", (y)) input("Press ...
92039c4bad63df6123697a07e4ec74662b7e3df5
HongLeiNW/project
/day01/xiaojiayu/recursion_2.py
437
3.859375
4
#斐波那契数列的迭代实现--n1+n2=n3 #相应速度快 def fab(n): n1 = 1 n2 = 1 n3 = 1 #不能输入0或负数 if n < 1: print('输入错误!') return -1 while (n - 2) > 0: n3 = n2 + n1 n1 = n2 n2 = n3 n -= 1 return n3 result = int(input('Input one number: ')) fab_number = fab(result) i...
3ba2d0c797a472ffa1c088c7eeffe87b5a08db17
RTalha/CONCURRENT-AND-DISTRIBUTED-SYSTEM
/cds_assighnent2/server2.py
1,320
3.828125
4
def fun(string): a=string.split("/") left = float(a[0]) right = float(a[1]) check=int(a[2]) if(check==0): return add(left,right) elif(check==1): return sub(left,right) elif(check==2): return mul(left,right) else: return 0 def add(a,b): return a+b de...
5699c9d6944f9a4c6b74cf6723cf64f9e712ebe2
Tai13492/Operation-Research
/Week1_Homework/hw24.py
759
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 20 22:29:22 2019 @author: TaiT_ """ print "integers from 1 to 50 divisible by 11:", for i in range(1,51): if(i%11 == 0): print i, print("") print "integers from 1 to 30 divisible by 5 or 7:", for i in range(1,31): if(i%5 == 0 or i%7==0): print i,...
ef37d0c0120c2daf8b3a3483c4efc79fbcf362dd
CesarJrFontalvo/ejercicios-python
/ventana3.py
991
3.90625
4
#Posicionamiento de elementos en la ventana from tkinter import * """ Funcion para que la ventana se centre en la pantalla """ def centrar_ventana(toplevel): toplevel.update_idletasks() w = toplevel.winfo_screenwidth() h = toplevel.winfo_screenheight() size = tuple(int(_) for _ in t...
102b151517dae9f3fbc389167ab3a242bf202742
kiruh/python-interview
/quick_sort.py
862
3.828125
4
def partition(array, start, end): pivot = array[start] left = start + 1 right = end while left <= right: while left <= right and array[right] >= pivot: right = right - 1 while left <= right and array[left] <= pivot: left = left + 1 if left <= right: ...
a6cdf990031f6cebe1569b7108f066d5dc4ff04c
igelfiend/Python.Structures.Stack
/reverse_polish_notation.py
1,958
4
4
#!/usr/bin/env python # coding=utf8 from copy import deepcopy """ Important: Class was copy-pasted in cause of using it in study. Normal use case suppose to import that class """ class Stack: def __init__(self): self.stack = [] def size(self): return len(self.stack) def pop(self): ...
8f2380276ec8c2fbc909f4fb3c72e6f0e5ca2c45
marccasian/KaryML-Framework
/C_FeatureExtraction/utils.py
4,059
3.90625
4
from math import sqrt import math class Point: def __init__(self, x, y): self.x = x self.y = y def __eq__(self, other): return self.x == other.x and self.y == other.y class Segment: def __init__(self, point1, point2, line=None, intersection_point=None): self.a = point1 ...
f106b57e9ac7554d13dd6d0e0ed05c0448cdb1a6
himanshuKp/python-practice
/challenges/odd_indices.py
473
4.3125
4
# Create a function named odd_indices() that has one parameter named lst. # The function should create a new empty list and add every element # from lst that has an odd index. The function should then return this new list. # For example, odd_indices([4, 3, 7, 10, 11, -2]) should return the list [3, 10, -2]. def odd_...
09488cb8d14baae899fd6bb5850cb8138290f584
himanshuKp/python-practice
/basics/nodes.py
819
3.78125
4
#Create a node class below class Node: def __init__(self, value, link_node='None'): self.value = value self.link_node = link_node def get_value(self): return self.value def get_link_node(self): return self.link_node def set_link_node(self, link_node): ...
ed435e0de210cb2aa2588375708e586c986a2603
himanshuKp/python-practice
/challenges/appendSum.py
530
4.40625
4
# Write a function named append_sum that has one parameter named lst. # The function should add the last two elements of lst together and append the result to lst. # It should do this process three times and then return lst. # For example, if lst started as [1, 1, 2], the final result should be [1, 1, 2, 3, 5, 8]. ...
eb295b4294efa4dae47b7c502eec7b4707f5a42d
Ngulefac/Python_for_everyone
/Introduction to python programming/Checking_if_an_element_is_in_an_an_array.py
187
3.625
4
list = 0,2,1,1,2,4,3,9,6 # This is an altenate way of declaring an array print(1 in list) print(7 in list) print(9-4 in list) print(9-4 not in list) print([list[2]] + [list[1]]) # done
8cfd9cd4c3dea8a5e7fc5b8b921085c7190346ed
kyosek/name-classifier
/src/modules/transform/preprocess.py
1,540
3.859375
4
def cleanNames(text, word_length=1): """Clean the text feature to be consumable for the model training Args: text (str): the text feature word_length (int): the minimal length of a word Process: 1. Remove all numbers 2. Remove punctuation: `?` `!` `'` `"` `#` `:` 3. Rep...
a8b33e2d5630c3ddf5e2d44bcf15a2b7f42d63fd
link0127/learning
/Sort.py
2,505
3.71875
4
""" You have a database. Please sort the devices by name in the sites! At the end write out the db with the pprint. In [ ]: # Beginner python - Lesson 4 - homework 2 # Sort inventory # level: medium # Hint: use dict and list functions and loop from pprint import pprint """ from pprint import pprint db={ "HU": {...
738f4f91bd40a96848cbb60a1ae00389180bf356
link0127/learning
/zoo.py
2,894
4.46875
4
""" In the first task, please create a base class Animal with class attribute 'species', instance attribute 'name', 'age' and method 'speak'. Constructor should set initial values of these attributes. Then please create some animal classes with overrides class attributes and inherits behaviour from Animal class. Some i...
cc93542960aba9a97d2e21fcfc7bd58dd70d5402
Jungho-Cheon/algorithm-python
/programmers/brute-force2.py
729
3.8125
4
res = 0 v = list() seq = set() ck = [False] * 8 def isPrime(num): if num == 1 or num == 0: return False for i in range(2, num): if (num % i == 0): return False return True def countPrime(cnt, numbers): s = "" for i in v: s += i if len(s): if isPrim...
b7659dab498d90247f1ec286ed4715dacb39b973
Jungho-Cheon/algorithm-python
/Solutions/Kst_Num_11004.py
790
3.6875
4
def Merge_Sort(data): if len(data) <= 1: return data mid = len(data) // 2 left = Merge_Sort(data[:mid]) right = Merge_Sort(data[mid:]) i, j, k = 0, 0, 0 while i < len(left) and j < len(right): if left[i] < right[j]: data[k] = left[i] i += 1 else...
6c1c63d4295daeb2a6356af24fd4120f7e1c6953
Jungho-Cheon/algorithm-python
/Solutions/Sort/1427.py
132
3.5
4
data = ' '.join(input()) array = list(map(int, data.split())) array.sort(reverse=True) for i in array: print(i, end='') print()
17c6ae052eafbf6a266fa699b0e8f7a9d6f1429c
kamran1231/CMS-USING-DICTIONARY
/CMSusingDICT.py
1,985
3.9375
4
cus_dict = {} def add_cust(id,name,age,salary): cus_dict.update({id:[name,age,salary]}) return def search_cust(id): cus = cus_dict[id] return cus def delete_cus(id): cus_del = cus_dict.pop(id) return cus_del def updateCustomer(id,name,age,salary): cus_dict[id][0]= na...
edaeefc7f05a9bcfbafaa7086f83c6b8a41c3619
nikorose87/DJS-analysis
/curvature.py
9,230
3.5625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Apr 26 15:08:34 2018 From Jaime of Stackoverflow Script to smooth the data and for detecting the highest curvature @author: nikorose """ # ============================================================================= # If your curve is smooth enough, you...
745c38ded8e57a2b19bd76cd571fb664ae08995e
nandiniananthan/Python
/Data Structures/Array/252. Meeting Rooms.py
406
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 25 11:56:41 2020 @author: nandini.ananthan """ intervals = [[6,10],[13,14],[12,14]] #OP : false def canAttendMeetings(intervals): intervals = sorted(intervals) for i in range(len(intervals)-1): if intervals[i][1] > intervals[i+1][0]: ...
09aee83642e9c7daa5adbc437bcadb451dc7fa9f
nandiniananthan/Python
/Data Structures/Array/4. palindromePermutation.py
556
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 2 16:24:54 2021 @author: nandini.ananthan """ str1 = "Tact Cpoa" OP = True def palper(str1): str1 = str1.lower() str1 = str1.replace(" ","") dict1 = {} for i in range(len(str1)): if str1[i] not in dict1: dict1[s...
d4a78bfcc45733934fe35af7d5fd02437569d83f
nandiniananthan/Python
/Data Structures/Array/CS 33 logestDigitPrefix.py
510
3.875
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 24 10:13:38 2021 @author: nandini.ananthan """ import re inputString = "123aa123" OP = "123" def longestDigitsPrefix(inputString): return re.findall('$\d+',inputString) print(longestDigitsPrefix(inputString)) def longestDigitsPrefix...
a31e434893072c73d4d31fe77a274dce2e32ceca
nandiniananthan/Python
/Data Structures/Array/496. Next Greater Element I.py
871
3.65625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 23 09:37:57 2021 @author: nandini.ananthan """ nums1 = [4,1,2] nums2 = [1,3,4,2] Output = [-1,3,-1] class Solution: def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]: stack = [] result = [] stack.a...
e2778935baa14a3c5debd037e1dc14a8a3791650
nandiniananthan/Python
/Data Structures/Array/953. Verifying an Alien Dictionary.py
895
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 9 10:37:40 2020 @author: nandini.ananthan """ ''' words = ["word","world","row"] order = "worldabcefghijkmnpqstuvxyz" ''' words = ["hello","leetcode"] order = "hlabcdefgijkmnopqrstuvwxyz" ''' words = ["apple","app"] order = "abcdefghijklmnopqrstuvwxyz" ...
341273b299b9864e1de0f3912940c2cac9306dba
nandiniananthan/Python
/Data Structures/Array/24. Swap Nodes in Pairs.py
648
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 18 00:31:55 2021 @author: nandini.ananthan """ head = [1,2,3,4] Output = [2,1,4,3] class Solution: def swapPairs(self, head: ListNode) -> ListNode: curr = ListNode(-1) curr.next = head prev_node = curr ...
395cc2bd6023a52537ee5003cb0a3d1524476221
nandiniananthan/Python
/Data Structures/Array/217. Contains Duplicate.py
267
3.9375
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 7 10:51:41 2020 @author: nandini.ananthan """ nums = [1,1,1,3,3,4,3,2,4,2] nums.sort() OP = True def containsDuplicate(nums): return len(nums) != len(set(nums)) print(containsDuplicate(nums))
1e02d6dcb67c90c8c3e034afeaf4cc2fadf3f146
nandiniananthan/Python
/Data Structures/Array/5. Longest Palindromic Substring.py
1,122
3.609375
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 31 14:30:38 2020 @author: nandini.ananthan """ s = "babad" class Solution: def longestPalindrome(self,s): largestPalindrome = "" for i in range(len(s)): palOdd = self.largestPalindromeIndex(s,i,i) palEv...
cf8089a09301350d21df5fd056742a03f4c891ef
nandiniananthan/Python
/Data Structures/Array/1047. Remove All Adjacent Duplicates In String.py
435
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 21 11:19:21 2021 @author: nandini.ananthan """ Input: "abbaca" Output: "ca" class Solution: def removeDuplicates(self, S: str) -> str: stack = [] for char in S: if stack and char == stack[-1]: stack.pop() ...
6666538608c9dc87364f751d9b040e6962c2d5dc
nandiniananthan/Python
/Data Structures/Array/10. LL_removeDups.py
1,802
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 13 01:22:35 2021 @author: nandini.ananthan """ class Node(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): def __init__(self, head = None): self.head = head ...
82fd474836470feed2507d9f5eb1dea64fdd93ad
nandiniananthan/Python
/Data Structures/Array/CS 38 buildPalindrome.py
410
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 2 00:22:20 2021 @author: nandini.ananthan """ st = "abcdc" OP = "abcdcba" def buildPalindrome(st): for i in range(len(st)): subS = st[i:] if isPalindrome(subS): nonPal = st[0:i] return st + nonPal[::-1] def ...
ce6b20359e900a88f98a27cbb42de3facfe57abb
nandiniananthan/Python
/Data Structures/Array/54. Spiral Matrix.py
1,276
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 2 23:09:18 2020 @author: nandini.ananthan """ matrix = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,3,6,9,8,7,4,5] def spiralOrder(matrix): ans = [] if matrix == []: return matrix top, left = 0,0 bot...
fa95338776bcb6de8f53c761c2bdf265128d11d6
nandiniananthan/Python
/Data Structures/Array/844. Backspace String Compare.py
492
3.625
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 13 20:51:30 2021 @author: nandini.ananthan """ S = "ab#c" T = "ad#c" class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def build(s): ans = [] for c in reversed(s): if c == '#': ...
a4a15290b9a20d75eaf9c7078ec4adb55fc6f26b
nandiniananthan/Python
/Data Structures/Array/414. Third Maximum Number.py
435
4.25
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 25 01:24:15 2020 @author: nandini.ananthan """ nums = [3,2,1] op = 1 def thirdMax(nums): nums=set(nums) if len(nums) < 3: return max(nums) else: max_val = max(nums) nums.remove(max_val) max_val = m...
34cf209482b051c656a1e7d5eaf7064a6a34ff75
betsybaileyy/practice_problems
/linked_list.py
2,323
4.4375
4
""" Reverse the order of a singly-linked list by modifying the nodes links. """ class Node(object): def __init__(self, data): """Initialize this node with the given data.""" self.data = data self.next = None class LinkedList(object): def __init__(self): """Initialize this li...
754858ff4d0825d43f71ead980a51bb3411bfcfb
betsybaileyy/practice_problems
/breakout/class_breakout.py
229
3.875
4
def find_dupe(): new_list = [] num_list = [ 1, 2, 3, 4, 4, 5 ] for number in num_list: if number not in new_list: new_list.append(number) else: return number print(number)
948d7fa56fd48382c232da01533a6c19ee468b40
ChiangDavid/Outside-Class-Learning
/LeetCodePractice/arrayOfProducts.py
377
3.703125
4
#Time: O(n^2), space: O(n) def arrayOfProducts(array): # Write your code here. current = 0 result = [] while current < len(array): product = 1 for i in range(len(array)): if array[i] != array[current] or current != i: product *= array[i] result.append(...
31b2546fc4c0490ea3914e81420eed40a7f837c7
allansdefreitas/python
/built-in_modules.py
431
3.8125
4
import random def megasena(): lista = [] while len(lista) < 6: num = random.randint(1,60) # Não podem ser números repetidos if num in lista: continue else: lista.append(num) print(sorted(lista)) #megasena() alunos = ['Cassio', 'Etinho', 'M...
488aeb90c1dbf24f4cda6e430badaf796df378d0
allansdefreitas/python
/imc/bmi_exercise.py
1,272
3.78125
4
import imc as i bmi = 0.0 result = '' validate = False # Validate Gender while validate == False: gender = input('Gender (M | F): ') try: gender = gender.upper() if gender == 'M' or gender == 'F': validate = True else: print('Gender have to be M or F') ...
179841b0c61e29393f03e50250c18ff4a89c6ebc
saurabh0vipin/overview
/Day3/CabBook/CabBooking.py
1,582
4.125
4
vehicles = { "Swift ": 45, "Maruti": 30, "Vagnor": 30, "innova": 40, "safari": 45 } class bookCab(): def __init__(self): ## name and speed assignment print("vehicle name\t\tspeed") print("________________________________") count=1; for x in vehicles: pr...
8c33020853a83248a7235c984092570618af65d6
YongshengCui-Lab/Python
/tese3.py
478
3.875
4
import math def abs_value1(): a = float(input('1.请输入一个数字:')) if a >= 0: a = a else: a = -a print('绝对值为:%f' % a) def abs_value2(): a = float(input('2.请输入一个数字:')) a = abs(a) print('绝对值为:%f' % a) def abs_value3(): a = float(input('3.请输入一个数字:')) a = ma...
550bd3dbb27010a852b584f373d693a33f08c166
kliegeois/progs
/apps/filemgr/filemgr.py
397
3.515625
4
#! /usr/bin/env python # -*- coding: latin-1 -*- import sys def findfiles(patterns): for file_or_dir in glob.glob(patterns): if os.path.isdir(file_or_dir): for path, subdirs, files in os.walk(dir): print 'entering "%s"...' % path for file in files: ...
a25e9e320b9dd225167269a092870511465d8631
AlekefromKz/Python-Game-TruthOrFalse
/client.py
689
3.640625
4
from truth_or_false.game import Game from truth_or_false.game_status import GameStatus print('Welcome to my gameY you will be asking questions one by one. In case you will not make more mistakes than you ' 'allowed to make, you will win. Otherwise you will loose!\n\n') game = Game() game.get_data() while game....
912c8856eaa9c60856020dca787abe554a94d305
caitaozhan/LeetCode
/divide-and-conquer/95.unique-binary-search-trees-ii.py
1,271
3.84375
4
# # @lc app=leetcode id=95 lang=python3 # # [95] Unique Binary Search Trees II # # @lc code=start # Definition for a binary tree node. from typing import List, Optional class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right cl...
5033807ededc1a5b8b6763af9cbe5c3f16536334
caitaozhan/LeetCode
/tree/2096.step-by-step-directions-from-a-binary-tree-node-to-another.py
2,870
3.96875
4
''' You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t. Find the shortest path starting from ...
ce1d06c20023c843d64a19ca18c3180a52b55bb9
caitaozhan/LeetCode
/tree/669.trim-a-binary-search-tree.py
2,188
3.734375
4
# # @lc app=leetcode id=669 lang=python3 # # [669] Trim a Binary Search Tree # # @lc code=start # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def trimBST(self, ...
9f106dd0366add927a01e2dc39eb67ca51a27a65
caitaozhan/LeetCode
/linked-list/61.rotate-list.py
906
3.78125
4
# # @lc app=leetcode id=61 lang=python3 # # [61] Rotate List # # @lc code=start # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[ListNo...
090ad6f9f150c87dd4b90ccf891a9cfba238ce5a
caitaozhan/LeetCode
/divide-and-conquer/148.sort-list.py
1,426
3.8125
4
# # @lc app=leetcode id=148 lang=python3 # # [148] Sort List # # @lc code=start # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def find_mid(self, head): slow = head fast = head.next ...
a7908066a7f0641837c8622db9984bb48ff66119
caitaozhan/LeetCode
/greedy/376.wiggle-subsequence.py
4,044
3.703125
4
# # @lc app=leetcode id=376 lang=python3 # # [376] Wiggle Subsequence # # https://leetcode.com/problems/wiggle-subsequence/description/ # # algorithms # Medium (39.31%) # Likes: 919 # Dislikes: 59 # Total Accepted: 66.3K # Total Submissions: 168.5K # Testcase Example: '[1,7,4,9,2,5]' # # A sequence of numbers is...
91cc726a3fc3c09f24ad05ca6686f5a90e3b0e7d
caitaozhan/LeetCode
/dp/322.coin-change.py
1,687
3.875
4
# # @lc app=leetcode id=322 lang=python3 # # [322] Coin Change # # https://leetcode.com/problems/coin-change/description/ # # algorithms # Medium (34.79%) # Likes: 4025 # Dislikes: 135 # Total Accepted: 399.7K # Total Submissions: 1.1M # Testcase Example: '[1,2,5]\n11' # # You are given coins of different denomi...
5a016fff8800373403d608617aebf41dedf7a4b9
caitaozhan/LeetCode
/binary-search/34.find-first-and-last-position-of-element-in-sorted-array.py
1,747
3.625
4
# # @lc app=leetcode id=34 lang=python3 # # [34] Find First and Last Position of Element in Sorted Array # from typing import List from bisect import bisect_left, bisect_right # @lc code=start class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: def binary_search_left...
8d2a1638bd4b702aa7690bd574bf939dda38365b
caitaozhan/LeetCode
/array/59.spiral-matrix-ii.py
815
3.5625
4
# # @lc app=leetcode id=59 lang=python3 # # [59] Spiral Matrix II # # @lc code=start class Solution: def generateMatrix(self, n: int) -> List[List[int]]: directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] grid = [[0 for _ in range(n)] for _ in range(n)] total = n**2 counter = 0 ...
31021b9d415ec960718a5f6c19408917381b75c3
caitaozhan/LeetCode
/array/229.majority-element-ii.py
1,670
3.8125
4
# # @lc app=leetcode id=229 lang=python3 # # [229] Majority Element II # # https://leetcode.com/problems/majority-element-ii/description/ # # algorithms # Medium (35.11%) # Likes: 1965 # Dislikes: 183 # Total Accepted: 163.5K # Total Submissions: 443.2K # Testcase Example: '[3,2,3]' # # Given an integer array of...
86047666cca2730a967d034b657b2f035ce99c38
caitaozhan/LeetCode
/array/624.maximum-distance-in-arrays.py
1,551
4.4375
4
''' Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|. Your task is to find the maximum distance. Example 1...
efddd1fa76098697c3f173fe4cc3d429c1353b47
caitaozhan/LeetCode
/string/767.reorganize-string.py
2,619
3.703125
4
# # @lc app=leetcode id=767 lang=python3 # # [767] Reorganize String # # https://leetcode.com/problems/reorganize-string/description/ # # algorithms # Medium (47.98%) # Likes: 1887 # Dislikes: 83 # Total Accepted: 94.6K # Total Submissions: 193.1K # Testcase Example: '"aab"' # # Given a string S, check if the le...
28f297f8597942a32f83af7ad2376fe3e9900313
caitaozhan/LeetCode
/queue/239.sliding-window-maximum.py
2,396
3.8125
4
# # @lc app=leetcode id=239 lang=python3 # # [239] Sliding Window Maximum # # https://leetcode.com/problems/sliding-window-maximum/description/ # # algorithms # Hard (40.09%) # Likes: 2361 # Dislikes: 139 # Total Accepted: 206.8K # Total Submissions: 514.6K # Testcase Example: '[1,3,-1,-3,5,3,6,7]\n3' # # Given ...
ec56f678354b1a05d0c6ac6ea35fbd107f8c1ca5
caitaozhan/LeetCode
/greedy/406.queue-reconstruction-by-height.py
1,937
3.546875
4
# # @lc app=leetcode id=406 lang=python3 # # [406] Queue Reconstruction by Height # from collections import defaultdict from typing import List # @lc code=start class Solution: '''O(n^2), insert one at a time sort by (ascending k, ascending height) with the same k value, put shorter people first ...
02cbab5a771a127c05d6ff3ea6ff949017d7ca37
caitaozhan/LeetCode
/array/57.insert-interval.py
3,393
3.8125
4
# # @lc app=leetcode id=57 lang=python3 # # [57] Insert Interval # # https://leetcode.com/problems/insert-interval/description/ # # algorithms # Hard (33.18%) # Likes: 1902 # Dislikes: 194 # Total Accepted: 272.2K # Total Submissions: 803.1K # Testcase Example: '[[1,3],[6,9]]\n[2,5]' # # Given a set of non-overl...
4cbfc25b622cab605ccecb1e409defcfb8c5548c
caitaozhan/LeetCode
/linked-list/19.remove-nth-node-from-end-of-list.py
3,267
3.8125
4
# # @lc app=leetcode id=19 lang=python3 # # [19] Remove Nth Node From End of List # # https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/ # # algorithms # Medium (34.49%) # Likes: 2267 # Dislikes: 169 # Total Accepted: 473.7K # Total Submissions: 1.4M # Testcase Example: '[1,2,3,4,5]\n2' ...
4cf476af49c59c6ca337d6905c58a93821b18f74
caitaozhan/LeetCode
/tree/105.construct-binary-tree-from-preorder-and-inorder-traversal.py
3,945
4
4
# # @lc app=leetcode id=105 lang=python3 # # [105] Construct Binary Tree from Preorder and Inorder Traversal # # https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/description/ # # algorithms # Medium (55.21%) # Likes: 6654 # Dislikes: 162 # Total Accepted: 587.3K # Total Subm...
3e9529947eb495d458ef57bad2a18eea28e4fc8c
caitaozhan/LeetCode
/others/1583.count-unhappy-friends.py
3,380
3.5625
4
""" You are given a list of preferences for n friends, where n is always even. For each person i, preferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers fr...
bbf081f50661704e8ff25200a17ef1bed42cb0fb
caitaozhan/LeetCode
/backtracking/51.n-queens.py
3,744
3.90625
4
# # @lc app=leetcode id=51 lang=python3 # # [51] N-Queens # # https://leetcode.com/problems/n-queens/description/ # # algorithms # Hard (40.62%) # Likes: 1267 # Dislikes: 58 # Total Accepted: 166.9K # Total Submissions: 394K # Testcase Example: '4' # # The n-queens puzzle is the problem of placing n queens on an...
79d2dbf39fbe6d0d6e8c44fde34b0b3c4c85d714
caitaozhan/LeetCode
/linked-list/86.partition-list.py
937
3.625
4
# # @lc app=leetcode id=86 lang=python3 # # [86] Partition List # # @lc code=start # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def partition(self, head: Optional[ListNode], x: int) -> Optional[ListNo...
dad1411198dbeda13dd2860748786f6763e47b58
caitaozhan/LeetCode
/divide-and-conquer/1569.number-of-ways-to-reorder-array-to-get-same-bst.py
2,455
3.90625
4
""" Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the ...
f4ea5cc05e7d245a37f35165ce5c61282b9f08a6
caitaozhan/LeetCode
/dp/152.maximum-product-subarray.py
3,009
3.59375
4
# # @lc app=leetcode id=152 lang=python3 # # [152] Maximum Product Subarray # # https://leetcode.com/problems/maximum-product-subarray/description/ # # algorithms # Medium (30.42%) # Likes: 2833 # Dislikes: 121 # Total Accepted: 265.2K # Total Submissions: 870.6K # Testcase Example: '[2,3,-2,4]' # # Given an int...
6b8a0f11f9cdc5fd1e0895b6e5ee69c0dcb4f3c5
caitaozhan/LeetCode
/tree/145.binary-tree-postorder-traversal.py
1,454
3.8125
4
# # @lc app=leetcode id=145 lang=python3 # # [145] Binary Tree Postorder Traversal # # @lc code=start # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: ''' divide and...
ce9cd0491fb427760d8b41f0b576328d5013969f
caitaozhan/LeetCode
/stack/946.validate-stack-sequences.py
922
3.5
4
# # @lc app=leetcode id=946 lang=python3 # # [946] Validate Stack Sequences # # @lc code=start class Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: stack = [] i = 0 # for pushed j = 0 # for popped while i < len(pushed): st...
c5024d265c843fedb94e3e253e432baff7368e78
caitaozhan/LeetCode
/tree/538.convert-bst-to-greater-tree.py
1,915
3.625
4
# # @lc app=leetcode id=538 lang=python3 # # [538] Convert BST to Greater Tree # # @lc code=start # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def convertBST(se...
c0c1050f406aa5005d8f723e33f6d3dcc85bf947
caitaozhan/LeetCode
/math/2.add-two-numbers.py
2,297
3.859375
4
# # @lc app=leetcode id=2 lang=python3 # # [2] Add Two Numbers # # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def print(self): cur = self while cur is not None: print(cur.val, end=' ') cur = cu...
0402968e852eca69b2be8e128414a6a76dd4a1d7
caitaozhan/LeetCode
/dp/1641.count-sorted-vowel-strings.py
2,435
3.53125
4
# # @lc app=leetcode id=1641 lang=python3 # # [1641] Count Sorted Vowel Strings # # @lc code=start class Solution: '''backtrack ''' def __init__(self): self.ans = 0 def countVowelStrings(self, n: int) -> int: def backtrack(num, index): if index == n: ...
3933983a7e2d113fe863e69fc904f0adbcee41bf
Nadunnissanka/Day-16-object-oriented-programing
/example_shapes.py
598
4
4
from turtle import Turtle, Screen turtle = Turtle() colors = ["red", "orange", "blue", "green", "purple", "coral", "goldenrod", "lime", "black", "crimson"] def draw_shapes(): turtle_color_index = 0 sides = 3 angel = 120 draw = False while not draw: for _ in range(sides): turt...
f769b2b3f08d63a44d1ac48b89995c6b7fbd1db2
dfm/tinygp
/src/tinygp/kernels/distance.py
2,056
3.828125
4
# -*- coding: utf-8 -*- """ This submodule defines a set of distance metrics that can be used when working with multivariate data. By default, all :class:`tinygp.kernels.stationary.Stationary` kernels will use either an :class:`L1Distance` or :class:`L2Distance`, when applied in multiple dimensions, but it is possible ...
9e07967e02f727025336f76b184dac4165cca8d0
Zohrab039/PragmatechFoundationProject
/Works/Python/run.py
4,512
3.8125
4
""" adlar=[] soyadlar=[] yaslar=[] emailler=[] hamisi=[adlar, soyadlar, yaslar, emailler] while True: emr=input('Yeni istifadəçi əlavə etmək üçün "1" düyməsinə basın:') if emr=='1': ad=input('İstifadəçi adını daxil edin: ') adlar.append(ad) break while True: emr=input('Yeni s...
44981f2c9e0e62d52acf0a3b0938e093e52d3fae
zhoushuaiandrew981112/cpe_202_proj1
/my_test.py
548
3.640625
4
from recursion import* def test_div(): for x in range(-900, 900): for y in range(-900, 900): if y == 0: #print(x, "Value Error") continue elif div(x, y) != (x//y): print(x, "div ", y, "=", div(x, y)) print(x, " // ", y,...
d25c1958c0410b18d76199aad433d39e4ac94699
pberzins/tips_and_tricks
/knn.py
1,069
3.796875
4
import numpy as np from sklearn import datasets class KNearestNeighbors: def __init__(self, k, distance): """Inputs self, k and type of distance """ self.k = k self.distance = distance def fit(self, X, y): """ X is the feature matrix as a 2d numpy Arrays y is t...
3314444de4a6af2096fb5312e29d4ec0e48a5dd2
cryogenic-dreams/PythonFunFolder
/Basic/sieve.py
986
3.9375
4
""" This program is inspired by the Eratostenes' sieve. """ def sieve (number): """ @type number: integer @param number: number > 0 @rtype: list @return: list of the primes until number. """ i = 2 cont = 0 primes = [] while i <= number: while cont < len(primes) and i % pr...
9b15d0c9a1524975a02e8894c1a55b160f75ef25
santoshikalaskar/Basic_Advance_python_program
/Python-dataStructure/dataStructure/stackUsingLL.py
633
3.78125
4
from node import * class StackUsingLinkedList: def __init__(self): self.head = None def push(self,data): new_node = Node(data) if self.head == None: self.head = new_node else : new_node.next = self.head self.head = new_node def po...
709a42f78c55aaaf2921cac9331cdaf730ddce26
santoshikalaskar/Basic_Advance_python_program
/Python-algorithm/algorithm/insertionSort.py
196
3.796875
4
from algorithm import * class InsertionSort: ins = AlgorithmMethods() ar = [7,2,9,5,9,1,7,6,4] print('Before sorting : ',ar) ins.insertion_sort(ar) print('After sorting : ',ar)
79c2059b563dfdaf77b7d5d9ea657643ba345c07
santoshikalaskar/Basic_Advance_python_program
/Python-algorithm/algorithm/anagram.py
264
4.0625
4
from algorithm import * class AnagramDetection: al = AlgorithmMethods() string1 = input('Enter 1st line : ') string2 = input('Enter 2nd line : ') if al.is_anagram(string1,string2): print('Anagram') else: print('Not an anagrams')
40ddd2943d504f908027ef976c6a24fe0da4af93
santoshikalaskar/Basic_Advance_python_program
/Python-oops/OOP/queueUsingLL.py
1,116
3.828125
4
from node import * class QueueUsingLinkedList: def __init__(self): self.head = None def enque(self,data): new_node = Node(data) if self.head == None: self.head = new_node else: new_node.next = self.head self.head = new_node def de...
f2982436d22eabf3e9bfb83f1b2fc80161cc25de
santoshikalaskar/Basic_Advance_python_program
/Python-algorithm/algorithm/bubbleSort.py
190
3.640625
4
from algorithm import * class BubbleSort: ins = AlgorithmMethods() ar = [7,2,9,5,9,1,7,6,4] print('Before sorting : ',ar) ins.bubble_sort(ar) print('After sorting : ',ar)
460160a4d45c467e0a1d2227975546ab7b83d9a2
santoshikalaskar/Basic_Advance_python_program
/EmployeeWageCompute/employee_wage/EmployeeWageInfo.py
1,926
4.3125
4
class EmployeeWageInfo: """ Initialising private attributes of a company """ __name = None __wage_per_hour = None __maximum_working_hours = None __maximum_working_days = None def __init__(self, name, wage_per_hour, maximum_working_hours, maximum_working_days): """ Con...