blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6ab11c76f2488a2a142935a6c768b1365bab6ddc
jadermcs/networkinglab
/exemplo_programa_container/app.py
42
3.671875
4
x = input("Digite um numero\n") print(x*x)
94ac2481ac122a499146a4a2e4492f087f32f400
mountains-high/Genetic-Algorithm
/model/population.py
18,636
3.578125
4
''' Created on Oct 17, 2014 @author: bjw ''' import random, copy, math from montecarlo import MonteCarlo class Population: def __init__(self, genes=[], fitness=[]): """ Initializes a new instance of a Population. """ self.genes = genes # The genes of the popul...
0420f686f85f8e005212448f46c126f2d941134a
mountains-high/Genetic-Algorithm
/model/montecarlo.py
1,547
3.578125
4
''' Created on Oct 10, 2014 @author: bjw ''' import random class MonteCarlo: def __init__(self, inputs, probabilities): if len(inputs) != len(probabilities): print inputs print probabilities raise Exception("Error: You must provide probabilities for each input type") ...
ee27bbc6272c0c2ee811a6c1066a38fc38bc10fa
sumithrasenthil/Hackerank-problemsolving
/Plus Minus
547
3.5625
4
#!/bin/python3 import math import os import random import re import sys # Complete the plusMinus function below. def plusMinus(arr): po_count=0 ne_count =0 zero_count=0 for i in range (len(arr)): if(arr[i]>0): po_count+=1 elif(arr[i]<0): ne_count+=1 else: zer...
6302c9af1d863de3488b7299a8a8c24bcfb3524c
afbarnard/glowing-broccoli
/src/heap.py
4,498
3.890625
4
# Heaps and priority queues from . import tests class Heap: def __init__(self): self._n_items = 0 self._items = [] def __len__(self): return self._n_items def __contains__(self, item): return item in self._items[:self._n_items] def _parent_idx(self, idx): #...
62bd7cb8d9c74ba00a51ee7866b44aa7aa7c8b11
afbarnard/glowing-broccoli
/lc/linked.py
1,945
3.75
4
# Classes for programming practice with linked lists import unittest class Node: def __init__(self, item, next=None): self.item = item self.next = next @property def val(self): return self.item @val.setter def val(self, value): self.item = value def __repr...
412e08540b6e8e9826e5d54b528adbf0c42fe7eb
zhangmy163/unittest_work
/calculator.py
213
3.5
4
class Calculator(): def add(self,a=0,b=0): return a + b def sub(self,a=0,b=0): return a - b if __name__ == '__main__': c = Calculator() r_add = c.add(3,8) print(r_add) r_sub = c.sub(7,5) print(r_sub)
1ac82af73a3b77cca23d933bda23ce453a00d02c
Mandeep5138/Study
/PYTHON CODES/Karatsuba algo.py
506
3.796875
4
X=int(input("Enter number 1 : ")) Y=int(input("Enter number 2 : ")) #Divide and conquer def karatsuba(X,Y): #Base case if X<10 or Y<10: return X*Y m=max(len(str(X)),len(str(Y))) if m%2!=0: m-=1 a,b=divmod(X,10**int(m/2)) c,d=divmod(Y,10**int(m/2)) ac...
24d8a3712a6bb4fddcfa05564e8c411bab920db0
Yeshwanth115/Python
/positive or negative.py
92
3.828125
4
n=int(input()) if(n>0): print('%d is positive' %n) else: print('%d is negative' %n)
974fe857981d3ff082fafaf6b3573766f3ac31ea
Yeshwanth115/Python
/radius of circle.py
60
3.65625
4
from math import * r=float(input()) area=pi*r*r print(area)
d5428a8765ceb27c40ef44db610f6efe7afaf3e6
Yeshwanth115/Python
/check a num is greater than elements of list.py
142
3.53125
4
a=[int(x) for x in input().split() [:4]] b=int(input()) c=min(a) if(c>b): print("all are greater") else: print("all are not greater")
487fdc0ea885b36bd49ae1547221617177e3a4bf
sinvalfelisberto/python_cod4r
/05_functions/packing.py
656
3.9375
4
def soma_2(a, b): return a + b def soma_3(a, b, c): return a + b + c def soma_n(*numeros): soma = 0 for n in numeros: soma += n return soma if __name__ == '__main__': print(soma_2(10, 15)) print(soma_3(10, 15, 20)) # packing = empacotando os parรขmetros em uma tupla prin...
14113e253430dae4d98e66b12bceb7d553231da6
sinvalfelisberto/python_cod4r
/00_fundamentos/estruturas_controle/for_05.py
376
3.546875
4
# for i in range(1, 11): # if i == 6: # break # print(i) # else: # print('Fim!') from random import randint def sortear_dado(): return randint(1, 6) for face in range(1, 7): if face % 2 == 1: continue elif face == sortear_dado(): print(f'Acertou! --> face = {face}') ...
7a41e11f22e5d5b9559d6ee4547117f073ef71c1
KubaWasik/python-game
/wall.py
1,600
3.5
4
from platforms import Platform class Wall(Platform): """ Klasa ล›ciany (pionowa platforma) """ def draw(self, surface, image_list_wall, image_list_wall_corner): for row in range(0, self.height, 70): if row == 0: surface.blit(image_list_wall_corner[0], self.rect) ...
cfcfb45f43d7dab216ccb417e917d1b6383c842e
janghyeonan/File_control
/File_control.py
2,262
3.53125
4
import os #๋ฉ”์ธ์ด ๋˜๋Š” ํด๋”๋ฅผ ์ง€์ •ํ•œ๋‹ค. #์ƒ์„ฑํ•  ํด๋”๋ช…๊นŒ์ง€ ๋„ฃ๊ธฐ main_path = 'C:\\Users\\nugu\\mulra\\envs\\name\\src\\pd\\' #๋ฉ”์ธ ํด๋” ์ƒ์„ฑํด๋”์ƒ์„ฑ os.makedirs(main_path[:-1]) #ํด๋”๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. (ํด๋” ์ˆ˜, ํด๋”๋ช…) - ํด๋”๋ช…0, ํด๋”๋ช…1 ์ด๋Ÿฐ์‹์œผ๋กœ ์ฆ๊ฐ€ํ•œ๋‹ค. def createFolder(x, directory): global main_path if x == "0": ft_directory = main_path + directory ...
f400b3592fa6fbc5bc54c0213eac9b9d72961e97
LukasWarna/programmerings-kurs
/Paddan/sixsten.py
350
3.59375
4
open = True import turtle sixsten = turtle.Turtle() sixsten.speed(50) sixsten.penup() while open: planX = input("Var vill du ha pricken pรฅ plan X?") planY = input("Var vill du ha pricken pรฅ plan Y?") sixsten.goto(int(planX), int(planY)) sixsten.pendown() sixsten.dot() si...
66cfd2faa0de96f2aba7779594988239f6847f8f
Razuimlh/poker
/.idea/shisanshui.py
863
3.703125
4
import random class Card(): def _init_(self, suit, rank, value): self.suit = suit #่Šฑ่‰ฒ self.rank = rank #็‰Œๅท self.value = value #็‰Œๅ€ผ def InitCard(self): self.cards = [] for suit in ["$","&","*","#"]: for rank in ["2","3","4","5","6","7","8","9","10","J","...
7287f8af76b5d6c10d72216e711c01749bebfcf9
nandyaaditya/basic_python4
/Tugas-1/Soal-[1].py
317
3.921875
4
name = input("Enter name : ") umur = int(input("Enter age : ")) tinggi = float(input("Enter heigt : ")) txtnama = "Nama saya {} , ". format(name) txtumur = "umur saya {} tahun ". format(umur) txttinggi = "dan tinggi saya {} cm". format(tinggi) txtgabung = txtnama + txtumur + txttinggi print(txtgabung)
254d09bf7933b172ffb76683ad1d16644d5b786d
huogerac/acpy
/calculadora_oo.py
2,002
3.703125
4
# coding: utf-8 """ Calculadora >>> calc = Calculadora() >>> calc.aceitar(10) >>> calc.visor() 10 >>> calc.pilha() [10] >>> calc.aceitar(20) >>> calc.visor() 20 >>> calc.pilha() [10, 20] >>> calc.aceitar('+') >>> calc.visor() 30 >>> calc.pilha() ...
7cfb76778004e72a8456282e73075d03604fa2fa
chinmayk03/Sample-Python-Projects
/Singh_Keskar_CA.py
7,216
4.3125
4
#Chinmay Keskar , Harmehar Singh #November 29th, 2019 #Hangman - Automobile Variation #How to build a hangman game with a car theme? import random #importing random module #Chinmay #Defining a function called startmenu that gives allows the user to help, start or quit def startmenu(): helpmenu = input...
d123ea905354b5ad30efc0456d640e1abde24e04
leooliveira135/machine_learning_python
/manipulacaoArquivo_v2.py
964
3.796875
4
print('Iniciando escrita de arquivo') texto = """ Aprendendo python machine learning python รฉ muito legal """ run = str(input('Escolha a forma de execuรงรฃo (w, a) ')) if run == 'w': with open('testes_arquivos/arquivo.txt',run) as f: f.write('-----------Escrevendo com o modo write-----------') f.writ...
35a935854a22fd158351b2aaf72dd64fa3f9666a
ystop/algorithms
/sword/ๆŒ‰ไน‹ๅญ—ๅฝข้กบๅบๆ‰“ๅฐไบŒๅ‰ๆ ‘.py
1,250
3.8125
4
# -*- coding:utf-8 -*- # ่ฏทๅฎž็Žฐไธ€ไธชๅ‡ฝๆ•ฐๆŒ‰็…งไน‹ๅญ—ๅฝขๆ‰“ๅฐไบŒๅ‰ๆ ‘๏ผŒๅณ็ฌฌไธ€่กŒๆŒ‰็…งไปŽๅทฆๅˆฐๅณ็š„้กบๅบๆ‰“ๅฐ๏ผŒ็ฌฌไบŒๅฑ‚ๆŒ‰็…งไปŽๅณ่‡ณๅทฆ็š„้กบๅบๆ‰“ๅฐ๏ผŒ็ฌฌไธ‰่กŒๆŒ‰็…งไปŽๅทฆๅˆฐๅณ็š„้กบๅบๆ‰“ๅฐ๏ผŒๅ…ถไป–่กŒไปฅๆญค็ฑปๆŽจใ€‚ # ๆ€่ทฏ: ๅฑ‚ๅบ้ๅކ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def Print(self, pRoot): # write code here if not pRoot: ...
00a2eee74c4586dfddcc1834f0938404be64335c
ystop/algorithms
/sword/ๅˆๅนถไธคไธชๆŽ’ๅบ็š„้“พ่กจ.py
1,079
3.984375
4
# -*- coding:utf-8 -*- # ่พ“ๅ…ฅไธคไธชๅ•่ฐƒ้€’ๅขž็š„้“พ่กจ๏ผŒ่พ“ๅ‡บไธคไธช้“พ่กจๅˆๆˆๅŽ็š„้“พ่กจ๏ผŒๅฝ“็„ถๆˆ‘ไปฌ้œ€่ฆๅˆๆˆๅŽ็š„้“พ่กจๆปก่ถณๅ•่ฐƒไธๅ‡่ง„ๅˆ™ใ€‚ # ๆ€่ทฏ: ็ฑปไผผ2ไธชๆ•ฐ็ป„ๅฝ’ๅนถ็š„่ฟ‡็จ‹ class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # ่ฟ”ๅ›žๅˆๅนถๅŽๅˆ—่กจ def Merge(self, pHead1, pHead2): # write code here cur = ListNode('None') bak = cu...
98486824bd77529e33d0315784ed5e5f722a2b47
ystop/algorithms
/leetcode/80. Remove Duplicates from Sorted Array II.py
1,042
3.640625
4
# -*- coding:utf-8 -*- # ๆ€่ทฏ: ๆœ‰ๅบๆ•ฐ็ป„๏ผŒc่ฎฐๅฝ•ๅ‡ ๆฌก๏ผŒๅฆ‚ๆžœไธ็›ธ็ญ‰๏ผŒไบคๆข๏ผŒๅนถ้‡็ฝฎc๏ผ›ๅฆ‚ๆžœ็›ธ็ญ‰๏ผŒไธ”cๆฌกๆ•ฐ็”จๅฎŒ๏ผŒfast็ปง็ปญ๏ผ›ๅฆ‚ๆžœ็›ธ็ญ‰๏ผŒไฝ†ๆ˜ฏcๆœ‰ๆฌกๆ•ฐ๏ผŒslowๅพ€ๅ‰็ปง็ปญ่ตฐ๏ผŒc-1 class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 slow = 0 fast = 1 ...
6a3ed2f8778d451342f3fb8ebc97ca30bf50d1b2
ystop/algorithms
/sword/ๆ—‹่ฝฌๆ•ฐ็ป„็š„ๆœ€ๅฐๆ•ฐๅญ—.py
1,123
3.65625
4
# -*- coding:utf-8 -*- # ๆŠŠไธ€ไธชๆ•ฐ็ป„ๆœ€ๅผ€ๅง‹็š„่‹ฅๅนฒไธชๅ…ƒ็ด ๆฌๅˆฐๆ•ฐ็ป„็š„ๆœซๅฐพ๏ผŒๆˆ‘ไปฌ็งฐไน‹ไธบๆ•ฐ็ป„็š„ๆ—‹่ฝฌใ€‚ ่พ“ๅ…ฅไธ€ไธช้žๅ‡ๆŽ’ๅบ็š„ๆ•ฐ็ป„็š„ไธ€ไธชๆ—‹่ฝฌ๏ผŒ่พ“ๅ‡บๆ—‹่ฝฌๆ•ฐ็ป„็š„ๆœ€ๅฐๅ…ƒ็ด ใ€‚ # ไพ‹ๅฆ‚ๆ•ฐ็ป„{3,4,5,1,2}ไธบ{1,2,3,4,5}็š„ไธ€ไธชๆ—‹่ฝฌ๏ผŒ่ฏฅๆ•ฐ็ป„็š„ๆœ€ๅฐๅ€ผไธบ1ใ€‚ NOTE๏ผš็ป™ๅ‡บ็š„ๆ‰€ๆœ‰ๅ…ƒ็ด ้ƒฝๅคงไบŽ0๏ผŒ่‹ฅๆ•ฐ็ป„ๅคงๅฐไธบ0๏ผŒ่ฏท่ฟ”ๅ›ž0ใ€‚ # ๆ€่ทฏ: ๅฝ“ๅทฆๅณๅทฎ1็š„ๆ—ถๅ€™๏ผŒๅณ่พนๅฐฑๆ˜ฏๆœ€ๅฐๅ€ผใ€‚ ไธไธบ1็š„ๆ—ถๅ€™๏ผŒไธ€็›ดๆ‰พใ€‚ๅฆ‚ๆžœไธญ้—ดๅ€ผๆฏ”ๆœ€ๅทฆ่พน่ฆๅคงๆˆ–่€…็›ธ็ญ‰๏ผŒ่ฏดๆ˜Žๅœจๅณ่พน๏ผ›ๅฆๅˆ™๏ผŒไธญ้—ดๅ€ผๆฏ”ๆœ€ๅทฆ่พนๅฐ๏ผŒ่ฏดๆ˜Žๅœจๅทฆ่พน class Solution: def minNumberInRotateArray(self, rotateArray): # ...
5fb7c68b7c5b199371aeb4a232bd07aada53d308
ystop/algorithms
/sword/ไบŒ่ฟ›ๅˆถไธญ1็š„ไธชๆ•ฐ.py
477
3.59375
4
# -*- coding:utf-8 -*- # ่พ“ๅ…ฅไธ€ไธชๆ•ดๆ•ฐ๏ผŒ่พ“ๅ‡บ่ฏฅๆ•ฐไบŒ่ฟ›ๅˆถ่กจ็คบไธญ1็š„ไธชๆ•ฐใ€‚ๅ…ถไธญ่ดŸๆ•ฐ็”จ่กฅ็ ่กจ็คบใ€‚ # ๆ€่ทฏ: 1. ไธ€ไฝไธ€ไฝๆฏ”๏ผŒไผšๆญปๅพช็Žฏ๏ผŒๅฏไปฅ่งฃๅ†ณ๏ผˆไฝ†ๆ˜ฏไป้œ€่ฆnๆฌก๏ผ‰ # 2. n & (n - 1) ไผšๆŠŠๆœ€ๅŽไธ€ไธช1ๅŽปๆމ๏ผŒ็›ดๅˆฐไธบ0 class Solution: def NumberOf1(self, n): # write code here c = 0 while n & 0xffffffff: n = n & (n - 1) c = c + 1 return c s = Solution()...
1fe8ae7810953014521cc125b50886a87164fe83
ystop/algorithms
/sword/ๆŠŠๆ•ฐ็ป„ๆŽ’ๆˆๆœ€ๅฐ็š„ๆ•ฐ.py
1,568
3.796875
4
# -*- coding:utf-8 -*- # ่พ“ๅ…ฅไธ€ไธชๆญฃๆ•ดๆ•ฐๆ•ฐ็ป„๏ผŒๆŠŠๆ•ฐ็ป„้‡Œๆ‰€ๆœ‰ๆ•ฐๅญ—ๆ‹ผๆŽฅ่ตทๆฅๆŽ’ๆˆไธ€ไธชๆ•ฐ๏ผŒๆ‰“ๅฐ่ƒฝๆ‹ผๆŽฅๅ‡บ็š„ๆ‰€ๆœ‰ๆ•ฐๅญ—ไธญๆœ€ๅฐ็š„ไธ€ไธชใ€‚ไพ‹ๅฆ‚่พ“ๅ…ฅๆ•ฐ็ป„{3๏ผŒ32๏ผŒ321}๏ผŒๅˆ™ๆ‰“ๅฐๅ‡บ่ฟ™ไธ‰ไธชๆ•ฐๅญ—่ƒฝๆŽ’ๆˆ็š„ๆœ€ๅฐๆ•ฐๅญ—ไธบ321323ใ€‚ # ๆ€่ทฏ1๏ผš ๅ…จๆŽ’ๅบ # 2. ๅ…ˆๅฐ†ๆ•ฐๅญ—ๅˆ—่กจ่ฝฌๅŒ–ๆˆๅญ—็ฌฆไธฒ้“พ่กจ๏ผŒ่ฟ™ๆ ทไพฟไบŽๅœจไธ€ไธชๅญ—็ฌฆไธฒๅŽ้ข็›ดๆŽฅๅŠ ไธŠๅฆๅค–ไธ€ไธชๅญ—็ฌฆไธฒใ€‚ไนŸๅฐฑๆ˜ฏ "3"+"321"="3321" ใ€‚ # โ€ƒโ€ƒ๏ผˆ2๏ผ‰ๆž„้€ ไธ€ไธชๆฏ”่พƒๅ‡ฝๆ•ฐ๏ผŒๅฝ“ str1+str2>str2+str1 ๆ—ถๆˆ‘ไปฌ่ฎคไธบๅญ—็ฌฆไธฒ str1>str2 ใ€‚ # โ€ƒโ€ƒ๏ผˆ3๏ผ‰ๅฐ†ๅญ—็ฌฆไธฒๅˆ—่กจๆŒ‰็…งๆฏ”่พƒๅ‡ฝๆ•ฐ็š„่ง„ๅฎš่ฟ›่กŒๅ†’ๆณกๆŽ’ๅบ๏ผˆๆˆ–ๅ…ถๅฎƒๆ–นๆณ•ๆŽ’ๅบ๏ผ‰๏ผŒๅฐ†ๅฎšไน‰ไธบโ€ๅคงโ€็š„ๅญ—็ฌฆไธฒๆ”พๅˆฐๆœ€ๅŽใ€‚่€Œโ€ๅฐโ€็š„ๅญ—็ฌฆไธฒๆ”พๅœจ...
b6ed7b073b0a8914f831d01b689a5601c62146a8
ystop/algorithms
/sword/ไบŒๅ‰ๆ ‘็š„ๆทฑๅบฆ.py
683
3.796875
4
# -*- coding:utf-8 -*- # ่พ“ๅ…ฅไธ€ๆฃตไบŒๅ‰ๆ ‘๏ผŒๆฑ‚่ฏฅๆ ‘็š„ๆทฑๅบฆใ€‚ไปŽๆ น็ป“็‚นๅˆฐๅถ็ป“็‚นไพๆฌก็ป่ฟ‡็š„็ป“็‚น๏ผˆๅซๆ นใ€ๅถ็ป“็‚น๏ผ‰ๅฝขๆˆๆ ‘็š„ไธ€ๆก่ทฏๅพ„๏ผŒๆœ€้•ฟ่ทฏๅพ„็š„้•ฟๅบฆไธบๆ ‘็š„ๆทฑๅบฆใ€‚ # ๆ€่ทฏ๏ผš ้€’ๅฝ’็ฎ—้•ฟๅบฆๅฐฑๅฏไปฅไบ†ใ€‚ใ€‚ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def TreeDepth(self, pRoot): # write code here if pRoot is None: ...
46b5a93a52e60e1b2abb5f130e92f08a00d45c96
ystop/algorithms
/leetcode/146. LRU Cache.py
1,065
3.703125
4
class LRUCache(object): def __init__(self, capacity): """ :type capacity: int """ self.capacity = capacity self.cache = {} self.list = [] def get(self, key): """ :type key: int :rtype: int """ if key in self.cache: ...
f72902ba397fbbe54e2356b8edeccf05abe0af09
ystop/algorithms
/leetcode/104. Maximum Depth of Binary Tree.py
927
3.96875
4
# -*- coding:utf-8 -*- # ๆ€่ทฏ๏ผš้€’ๅฝ’่ฎก็ฎ—ๅ‡บๆ‰€ๆœ‰็š„ๆทฑๅบฆ๏ผŒๅ–ๆœ€ๅคงๅณๅฏใ€‚๏ผˆๆˆ–่€…ไธ€็›ดๆปšๅŠจ็ปดๆŠคไธ€ไธชๆœ€ๅคง) # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def maxDepth(self, root): """ :type root: TreeNode ...
51223dc3e40cc263e343e2c207a2e4be337b090b
ystop/algorithms
/leetcode/47. Permutations II.py
970
3.578125
4
# -*- coding:utf-8 -*- # ๆ€่ทฏ: ๅ…จ้ƒจ้ๅކ๏ผŒๆฏไธชไฝ็ฝฎ้ƒฝๆœ‰ๅฏ่ƒฝๆœ‰ๆ˜ฏไปปไฝ•ไธ€ไธชๆ•ฐๆฎใ€‚ ๆณจๆ„๏ผŒๅฆ‚ๆžœๅœจpath้‡Œๆœ‰ไบ†๏ผŒๅฐฑไธ่ฆๅŠ ๅ…ฅไบ†ใ€‚ๆŽ’ๅบ้—ฎ้ข˜๏ผŒ(123)(321)้ƒฝๆ˜ฏ # ่ฟ™ไธช้ข˜็›ฎๆณจๆ„ไธ€ไธ‹๏ผŒ่ฆ่ฎฐๅฝ•index๏ผŒๆฏไธชindexๅฏไปฅ็”จไธ€ๆฌก๏ผŒ ๆ•ฐๆฎๅฏไปฅ้‡ๅค class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ path = [] ret = [] ...
abb49a5f4cf16e44edab126ede18625bc7ee9adf
ystop/algorithms
/sword/ๆ•ฐ็ป„ไธญๅ‡บ็Žฐๆฌกๆ•ฐ่ถ…่ฟ‡ไธ€ๅŠ็š„ๆ•ฐๅญ—.py
2,128
3.640625
4
# -*- coding:utf-8 -*- # ๆ•ฐ็ป„ไธญๆœ‰ไธ€ไธชๆ•ฐๅญ—ๅ‡บ็Žฐ็š„ๆฌกๆ•ฐ่ถ…่ฟ‡ๆ•ฐ็ป„้•ฟๅบฆ็š„ไธ€ๅŠ๏ผŒ่ฏทๆ‰พๅ‡บ่ฟ™ไธชๆ•ฐๅญ—ใ€‚ไพ‹ๅฆ‚่พ“ๅ…ฅไธ€ไธช้•ฟๅบฆไธบ9็š„ๆ•ฐ็ป„{1,2,3,2,2,2,5,4,2}ใ€‚็”ฑไบŽๆ•ฐๅญ—2ๅœจๆ•ฐ็ป„ไธญๅ‡บ็Žฐไบ†5ๆฌก๏ผŒ่ถ…่ฟ‡ๆ•ฐ็ป„้•ฟๅบฆ็š„ไธ€ๅŠ๏ผŒๅ› ๆญค่พ“ๅ‡บ2ใ€‚ๅฆ‚ๆžœไธๅญ˜ๅœจๅˆ™่พ“ๅ‡บ0ใ€‚ # ๆ€่ทฏ: 1 ๆŽ’ๅบ 2 ไธ€ไธชไปฃ่กจ่ฏฅๆ•ฐ็ป„ไธญ็š„ๆŸไธชๆ•ฐ๏ผˆresult๏ผ‰๏ผŒไธ€ไธชไปฃ่กจๆฌกๆ•ฐ๏ผˆtimes๏ผ‰๏ผŒๅฝ“้ๅކ่ฏฅๆ•ฐ็ป„ๆ—ถๅฏนๅ…ถ่ฟ›่กŒไธ€ไธ‹ๅ‡ ็งๆƒ…ๅ†ต็š„ๅค„็†๏ผš # ๏ผˆ1๏ผ‰ๅฝ“ไธ‹ไธ€ไธชๆ•ฐๅ’Œๆˆ‘ไปฌไฟๅญ˜็š„result็š„ๆ•ฐๅญ—็›ธๅŒๆ—ถ๏ผŒtimesๅŠ 1๏ผ› # ๏ผˆ2๏ผ‰ๅฝ“ไธ‹ไธ€ไธชๆ•ฐๅ’Œๆˆ‘ไปฌไฟๅญ˜็š„result็š„ๆ•ฐๅญ—ไธๅŒๆ—ถ๏ผŒtimesๅ‡1๏ผ› # ๏ผˆ3๏ผ‰ๅฝ“timesๅ‡ๅˆฐ0ๆ—ถ๏ผŒๆˆ‘ไปฌๆ ‡่ฎฐไธ‹ไธ€ไธชๆ•ฐไธบresult๏ผŒๅนถไธ”็ฝฎtimesไธบ1...
35460e5a2439f7c4f78ee24c9ea705e83a75842e
ystop/algorithms
/leetcode/460. LFU Cache.py
2,875
3.515625
4
# -*- coding:utf-8 -*- # ๆ€่ทฏ: ๆƒณ็”จ1ไธชhtๅ’Œ1ไธชlistๅ‘็Žฐlistๅฟ…้กป้ๅކ๏ผŒๅณไพฟ็”จๅ †(logn)ใ€‚้‚ฃไนˆๅฐฑๆ‹†list,ๆ นๆฎ้ข‘็އๆ‹†ๆˆnไธชlist,้ข‘็އไน‹้—ด็”จlistๆˆ–่€…htๅ†็ปดๆŠคไธ‹ใ€‚ # 3ไธชๆ•ฐๆฎ็ป“ๆž„+1ไธชๆœ€ๅฐ้ข‘็އ็š„็ปดๆŠค: 1. cache็”จๆฅ็ปดๆŠคๅŸบ็ก€ๆ•ฐๆฎ 2.keyCounts ๅ“ˆๅธŒ่กจ๏ผŒ็”จๆฅ็ปดๆŠคๆฏไธชkey็š„้ข‘็އ # 3.countKeyMapList็”จๆฅ็ปดๆŠคๆฏไธชcountไธ‹้ข็š„ๅ…ƒ็ด ใ€‚ class LFUCache(object): def __init__(self, capacity): """ :type capacity: int """ ...
95848039dd85c63ed9a4421fc20c63f46f55bdea
karthikrk1/leetcode-solutions
/misc/longest_palindromic_substring.py
1,088
3.96875
4
""" Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Input: "cbbd" Output: "bb" """ class Solution: def lps(self, s): if not s or len(s) < 1: return "" s...
f6c99a569a353dafd14f7f725fa02afacf434685
karthikrk1/leetcode-solutions
/misc/valid_parantheses.py
1,006
4
4
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. """ ...
ecb319feb192f9b48697a0517a46a02433ffb4e1
luisjeremias/python-guess-number
/Guess_a_number.py
756
3.75
4
import random import re from time import sleep class Guess: def __init__(self): self.minimum = 0 self.maximum = 100 self.guess = random.randint(self.minimum,self.maximum) def start(self): self.guess_number() def guess_number(self): try: the_guess = int(input('Chute um numero de 0 รก 100...
1157e881d999f4fba463fb3f2550397fb8e70fb2
denysdenys77/pygame
/arkanoid_game/ball.py
2,625
3.796875
4
import random class Ball: def __init__(self): self.ball_x = 200 self.ball_y = 300 self.ball_radius = 5 self.ball_speed = 5 self.color = (255, 255, 255) self.ball_direction = random.choice(['move_up_and_left', 'move_down_and_right', ...
8efecba54212dbc008261bb117ad875f7c400cdd
MaximGasilin/homework_1
/PythonAlgorithms_lesson-8/les_8_task_2.py
3,627
3.765625
4
''' ะšัƒั€ั "ะะปะณะพั€ะธั‚ะผั‹ ะธ ัั‚ั€ัƒะบั‚ัƒั€ั‹ ะดะฐะฝะฝั‹ั… ะฝะฐ Python." ะฃั€ะพะบ # 8. ะ—ะฐะดะฐะฝะธะต # 2. ะ”ะพั€ะฐะฑะพั‚ะฐั‚ัŒ ะฐะปะณะพั€ะธั‚ะผ ะ”ะตะนะบัั‚ั€ั‹ (ั€ะฐััะผะฐั‚ั€ะธะฒะฐะปัั ะฝะฐ ัƒั€ะพะบะต), ั‡ั‚ะพะฑั‹ ะพะฝ ะดะพะฟะพะปะฝะธั‚ะตะปัŒะฝะพ ะฒะพะทะฒั€ะฐั‰ะฐะป ัะฟะธัะพะบ ะฒะตั€ัˆะธะฝ, ะบะพั‚ะพั€ั‹ะต ะฝะตะพะฑั…ะพะดะธะผะพ ะพะฑะพะนั‚ะธ. ะะตะผะฝะพะณะพ ัั‚ั€ะฐะฝะฝะฐั ะทะฐะดะฐั‡ะฐ. ะข.ะบ. ะฟะพ ัะฒะพะตะน ััƒั‚ะธ ะผะฐััะธะฒ parent ัƒะถะต ัะพะดะตั€ะถะธั‚ ะฒััŽ ะฝะตะพะฑั…ะพะดะธะผัƒัŽ ะธะฝั„ะพั€ะผะฐั†ะธัŽ, ะฝะพ ะฒ ั...
2f3ac75354e44967bb492155db0587fdda8b9020
MaximGasilin/homework_1
/PythonAlgorithms_lesson-2/les_2_task_3.py
619
4.125
4
''' ะšัƒั€ั "ะะปะณะพั€ะธั‚ะผั‹ ะธ ัั‚ั€ัƒะบั‚ัƒั€ั‹ ะดะฐะฝะฝั‹ั… ะฝะฐ Python." ะฃั€ะพะบ # 2. ะ—ะฐะดะฐะฝะธะต # 3. ะกั„ะพั€ะผะธั€ะพะฒะฐั‚ัŒ ะธะท ะฒะฒะตะดะตะฝะฝะพะณะพ ั‡ะธัะปะฐ ะพะฑั€ะฐั‚ะฝะพะต ะฟะพ ะฟะพั€ัะดะบัƒ ะฒั…ะพะดัั‰ะธั… ะฒ ะฝะตะณะพ ั†ะธั„ั€ ะธ ะฒั‹ะฒะตัั‚ะธ ะฝะฐ ัะบั€ะฐะฝ. ะะฐะฟั€ะธะผะตั€, ะตัะปะธ ะฒะฒะตะดะตะฝะพ ั‡ะธัะปะพ 3486, ะฝะฐะดะพ ะฒั‹ะฒะตัั‚ะธ 6843. ''' n = int(input('ะ’ะฒะตะดะธั‚ะต ะฝะฐั‚ัƒั€ะฐะปัŒะฝะพะต ั‡ะธัะปะพ: ')) new_n = 0 while True: new_n ...
1c236fe04c9c0a79ad355b22fb84bb138f594637
pamolloy/interview
/sum-depth-nested-list/solution.py
1,133
4.1875
4
#!/usr/bin/env python # # sum-depth-nested-list/solution.py # # Examples consisting of the list and output examples = [ ([[1, 1], 2, [1, 1]], 10), ([1, [4, [6]]], 27) ] def sum_depth(nested_list, depth=0): """A recursive solution that sums the product of multiplying each element by its depth""" ...
c55f434eff636cbee2482721c3a06310fc870b54
vprotsan/pythonFunctions
/uniqueValues.py
539
3.78125
4
def uniqueValues(aDict): ''' aDict: a dictionary ''' uniqVal = [] for key,val in aDict.items(): allVal = list(aDict.values()) if allVal.count(val) == 1: uniqVal.append(key) print(sorted(uniqVal)) return sorted(uniqVal) #uniqueValues({1: 1, 2: 2, 3: 3}) #[1...
8abf70359a1d18db526cc25d5f6173f79c8212cc
Vayne-Lover/Effective
/Python/Web Scraping with Python/easy scripts/table9x9.py
344
3.796875
4
# -*- coding: utf-8 -*- __author__ = "Vayne Lover" class PrintTable(object): def __init__(self): print("Start to print!") self.print99() def print99(self): for i in range(1,10): for j in range(1,i+1): print("{0} X {1} = {2:2d}".format(j,i,i*j),end=" ") print(u'\n') if __name__=="...
b5183d35e62976189741ae6d3b867e0898da8235
Vayne-Lover/Effective
/Python/Effective Python/item17.py
496
3.625
4
# -*- coding: utf-8 -*- def normalize(numbers): total=sum(numbers) result=[] for v in numbers: percent=100*v/total result.append(percent) return result def normalize_copy(numbers): num=list(numbers) total=sum(num) result=[] for v in num: percent=100*v/total result.append(percent) ret...
186693a80c92ec4e63aa89fcd303b16f77a2002a
Vayne-Lover/Effective
/Python/Learn Python The Hard Way/ex6.py
385
4
4
# -*- coding: utf-8 -*- x="There are %d types of people." %10 binary="binary" do_not="don't" y="Those who know %s and those who %s." %(binary,do_not) print(x) print(y) print("I said: %r." %x) print("I also said: '{}'".format(y)) h= False joke="Isn't that joke so funny?{}" print(joke.format(h)) w="This is th...
8fac731ef977528ca3310984c44ce11f05a61a89
Vayne-Lover/Effective
/Python/Learn Python The Hard Way/ex36.py
172
4.28125
4
# -*- coding: utf-8 -*- a = 1 b = 3 if a > b : print("{0} > {1} !".format(a,b)) elif a == b: print("{0} = {1} !".format(a,b)) else: print("{0} < {1} !".format(a,b))
c3de31bab2bd1730c77be9ed8007db6787523a7b
Vayne-Lover/Effective
/Python/Effective Python/item10.py
124
3.625
4
#!/usr/local/bin/python favor_list=['a','b','c','d','e'] for i,favor in enumerate(favor_list,1): print '%d: %s'%(i,favor)
40c9ba18e98a2cdba5c0dbe663ab12a73865eb75
Vayne-Lover/Effective
/Python/Learn Python The Hard Way/ex30.py
184
4
4
# -*- coding: utf-8 -*- a = 30 b = 40 c = 15 if a > b : print("{0} > {1} !".format(a,b)) elif a < b: print("{0} < {1} !".format(a,b)) else : print("{0} = {1} !".format(a,b))
b03dd55f400065138c23f3fafd2068214130ef82
Vayne-Lover/Effective
/Python/Learn Python The Hard Way/ex20.py
456
3.84375
4
# -*- coding: utf-8 -*- from sys import argv script,file=argv def print_all(f): print f.read() def rewind(f): f.seek(0) def print_line(count,f): print count,f.readline() currentFile=open(file) print("Print the whole file!") print_all(currentFile) print("Back to start!") rewind(currentFile) print("Print...
b8f2dea9495d0f40372154a029b0eac2bf227666
Vayne-Lover/Effective
/Python/Learn Python The Hard Way/ex11.py
509
4.25
4
# -*- coding: utf-8 -*- # #print("Please input your name :",end=" ") # #name=input() # #print("Please input your age :",end=" ") # #age=input() # #print("Please input your height :",end=" ") # #height=input() # #print("I'm {0},{1} years old,{2} cm tall.".format(name,age,height)) print "How old are you?", age = raw_in...
7ede6a6193f6fd7771be504dd52c9c39eb91b6df
davidruffner/computational-physics-nyu-2009
/assignments/assign03/advect_dbr250.py
3,272
3.953125
4
#!/usr/bin/env python """ Author: David Ruffner, NYU Date: 9/26/09 This program integrates the advection equation using the Lax-Friedrichs Method. """ import pylab import math #The advection equation can be written as Ut + a*Ux = 0, where a is the rate of # advection, Ut is the derivative of U wrt time and Ux is...
4ed76f34faaaf1698c034635104797e6210b8c99
davidruffner/computational-physics-nyu-2009
/pythonExamples/pythonLect9_28_09/class.py
155
3.609375
4
class MyClass: i = 3 def __init__(self): self.i = 0 def double(self): self.i = self.i*2 Thingy = MyClass() Thingy.double()
7cc585f3cddcbcb386e9dcb67263edafb47d558a
sdkcouto/exercises-coronapython
/chapter_8_8_2.py
397
3.765625
4
#Favorite Book: Write a function called favorite_book() that accepts one parameter, title. The function should print a message, such as One of my favorite books is Alice in Wonderland. Call the function, making sure to include a book title as an argument in the function call. def favorite_book(book): print('One of...
ecb83e7e01953dc0230fbc2c9ffe0265e84bcd23
sdkcouto/exercises-coronapython
/chapter_6_6_5.py
657
4.90625
5
#6-5. Rivers: Make a dictionary containing three major rivers and the country each river runs through. One key-value pair might be 'nile': 'egypt'. rivers = {'amazon' : 'brazil', 'nile' : 'egypt', 'hudson' : 'usa' } #โ€ข Use a loop to print a sentence about each river, such as The Nile runs through Egypt. ...
93092e9360ef9224ddc8435de8a040212b71f7b1
sdkcouto/exercises-coronapython
/city_functions.py
285
3.78125
4
def city_name(city,country,population = ""): if population: city_country = city + ", " + country + " - population " + str(population) else: city_country = city + ", " + country + "- population " return city_country.title() city_name('santiago','chile')
6512adea31b5490919e46c131a3e3b0ce5bce6f0
sdkcouto/exercises-coronapython
/chapter_10_10_12.py
601
4.15625
4
# Favorite Number Remembered: Combine the two programs from Exercise 10-11 into one file. If the number is already stored, report the favorite number to the user. If not, prompt for the userโ€™s favorite number and store it in a file. Run the program twice to see that it works. import json favorite_number = input("what...
33640d12c11102ba62e4db888aa21978aeb0c5fe
sdkcouto/exercises-coronapython
/chapter_9_9_5.py
1,494
4
4
#Login Attempts: Add an attribute called login_attempts to your User class from Exercise 9-3 (page 166). Write a method called increment_login_attempts() that increments the value of login_attempts by 1. Write another method called reset_login_attempts() that resets the value of login_attempts to 0. #Make an instance ...
2b2a5f7d89e070b18008e7f315f1b8ce82a9d6cf
sdkcouto/exercises-coronapython
/chapter_2_2_3.py
276
3.765625
4
# 2-3. Personal Message: Store a personโ€™s name in a variable, and print a message to that person. Your message should be simple, such as, โ€œHello Eric, would you like to learn some Python today?โ€ name = "Elsa" var = "oi" + name + " vc quer brincar na neve? " print(var)
11dbd9274d2a6a21cca3d80a3f5d0cc1010801d0
sdkcouto/exercises-coronapython
/chapter_4_4_11.py
877
4.6875
5
# 4-11. My Pizzas, Your Pizzas: Start with your program from Exercise 4-1 (page 60). Make a copy of the list of pizzas, and call it friend_pizzas. Then, do the following: pizza = ["Tuna", "Pepperoni", "Brazilian"] friend_pizzas = ["Pepperoni","Margherita","Four cheese"] # # โ€ข Add a new pizza to the original list. pizza...
80514de5d13749ef7a9dc1a707785fc1ba973c71
sdkcouto/exercises-coronapython
/chapter_7_7_1.py
266
4.25
4
#Rental Car: Write a program that asks the user what kind of rental car they would like. Print a message about that car, such as โ€œLet me see if I can find you a Subaru.โ€ car = input('which car are you looking for?') print('Let me see if I can find you a ' + car)
99859a36b5ef7274fda091d1fd886972e7f89a51
sdkcouto/exercises-coronapython
/chapter_8_8_5.py
528
4.53125
5
#Cities: Write a function called describe_city() that accepts the name of a city and its country. The function should print a simple sentence, such as Reykjavik is in Iceland. Give the parameter for the country a default value. Call your function for three different cities, at least one of which is not in the default c...
583f9e57780cd80509293af59db3ed708d7638d0
tfssweb/tfss-python
/pymsql/pymsql.py
731
3.640625
4
import pymysql.cursors # ่ฟžๆŽฅMySQLๆ•ฐๆฎๅบ“ใ€‚ connection = pymysql.connect(host='172.18.18.203', port=23306, user='root', password='root', db='guest', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) # ้€š่ฟ‡cursorๅˆ›ๅปบๆธธๆ ‡ cursor = connection.cursor() # ๆ‰ง่กŒๆ•ฐๆฎๆŸฅ่ฏข sql = "SELECT `id`, `password` FROM `users` WHERE `email`='hu...
e1c05ed022b68183e46bd6061d326ee732797ff6
kkomarocker/learn_python
/str.py
1,935
4.4375
4
"""learning str in python""" # len(str) gives the length of string passed as an argument. len("hello") # 5 # concatenate "hello " + "my name is" + " Jay" # "hello my name is Jay" # string augmentation s = "Hello " s += "my name is " s += "Jay" s == "Hello my name is Jay" # True # join / split color...
04bd0f4e4040d8016cea177fe5adee2e2dc10c0b
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/2. Beginner_Coder/๋„ํ˜•๋งŒ๋“ค๊ธฐ1/1304_์ˆซ์ž์‚ฌ๊ฐํ˜•3.py
312
3.84375
4
def fill(): num = 1 for i in range(n): for j in range(n): arr[j][i] = num num += 1 def printAll(): for i in range(n): for j in range(n): print(arr[i][j],end=" ") print() n = int(input()) arr = [[0] * n for _ in range(n)] fill() printAll()
d1071473c5815ccb349d38c4115eb71ff3e82e0e
Gyeong-Yeon/TIL
/Algorithm/SW Expert Academy/2056_์—ฐ์›”์ผ ๋‹ฌ๋ ฅ.py
1,572
3.640625
4
T = int(input()) for t in range(1,T+1): # calender = list(map(str,input())) # joinํ•จ์ˆ˜๋กœ ์›์†Œ๋“ค์„ ์ถ”์ถœํ•˜๊ธฐ ์œ„ํ•ด ์ž…๋ ฅ๊ฐ’์„ strํ˜•ํƒœ๋กœ list์— ๋„ฃ๋Š”๋‹ค. # YYYY = ''.join(calender[:4]) # ๋…„ # MM = ''.join(calender[4:6]) # ์›” # DD = ''.join(calender[6:8]) # ์ผ # # if MM == '01' or MM == '03' or MM == '05' or MM == '07' or MM == '...
5d64a9a79dfc706f04d448c4f90f40eb45c6e154
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/1. Language_Coder/๋ฐ˜๋ณต์ œ์–ด๋ฌธ1/538_๋ฐ˜๋ณต์ œ์–ด๋ฌธ1_์ž๊ฐ€์ง„๋‹จ3.py
186
4.0625
4
while True: print(f'number? ', end="") N = int(input()) if N > 0: print("positive integer") elif N < 0: print("negative number") else: break
1cbb3d4ef71522fb167b07f47994f2a9e6274163
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/1. Language_Coder/๋ฐ˜๋ณต์ œ์–ด๋ฌธ2/132_๋ฐ˜๋ณต์ œ์–ด๋ฌธ2_ํ˜•์„ฑํ‰๊ฐ€3.py
101
3.703125
4
N = int(input()) i = 1 sum = 0 for i in range(N+1): if i % 5 == 0: sum += i print(sum)
dea1801cad9fbe15b35da970956d8fdda87a2e5d
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/1. Language_Coder/๋ฐ˜๋ณต์ œ์–ด๋ฌธ3/145_๋ฐ˜๋ณต์ œ์–ด๋ฌธ3_ํ˜•์„ฑํ‰๊ฐ€6.py
172
3.703125
4
n = int(input()) l = 2*n - 1 for i in range(1,n+1): empty = ' ' * (l-2*i+1) print(empty, end="") for j in range(1, i+1): print(j, end=" ") print()
f54f6cac867f73c004bbaf2efc70e0352e0c3b30
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/2. Beginner_Coder/๋„ํ˜•๋งŒ๋“ค๊ธฐ1/1307_๋ฌธ์ž์‚ฌ๊ฐํ˜•1.py
426
3.828125
4
def fill(): num = ord('A') # 65 for i in range(n-1, -1, -1): # ํ–‰ for j in range(n-1, -1, -1): # ์—ด arr[j][i] = chr(num) num += 1 if chr(num) > 'Z': num = ord('A') def printAll(): for i in range(n): for j in range(n): print(arr[i...
e22170734ef10b1ca2f17f66ccdab7dfdeed4d4a
Gyeong-Yeon/TIL
/Algorithm/JUNGOL/1. Language_Coder/๋ฐ˜๋ณต์ œ์–ด๋ฌธ1/633_๋ฐ˜๋ณต์ œ์–ด๋ฌธ1_์ž๊ฐ€์ง„๋‹จ6.py
257
3.6875
4
print(f'1. Korea') print(f'2. USA') print(f'3. Japan') print(f'4. China') print(f'number?', end=" ") N = int(input()) print() capital = [' ', 'Seoul', 'Washington', 'Tokyo', 'Beijing'] if 0 < N < len(capital): print(capital[N]) else: print('none')
991ffe6309c00d2e11ed1e3f54384596a9ca68f0
nusnlp/neuralreord-aaai2017
/tools/DependencyReordering/nnAdapt/models/dropout_mlp.py
6,100
3.734375
4
""" This code is adapted from Deep Learning tutorial introducing multilayer perceptron using Theano. Added Dropout from https://github.com/mdenil/dropout/blob/master/mlp.py """ __docformat__ = 'restructedtext en' import os import sys import timeit import numpy import theano import theano.tensor as T from logisti...
4def358c407563a12dc6ffc3baeee790eaaf88d9
d-jskim/202003_platform
/๊น€์ง€์ˆ˜/pre_python_20.py
810
3.8125
4
"""20. 1๋ถ€ํ„ฐ 100๊นŒ์ง€ 369 ๊ฒŒ์ž„์„ ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. 3,6,9๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ๋ถ€๋ถ„์—๋Š” '์ง' ์„ ์ถœ๋ ฅํ•˜๊ณ , 5์˜ ๋ฐฐ์ˆ˜์—๋Š” '์•„์ž' ๋ฅผ ์ถœ๋ ฅ, ๊ทธ์™ธ์—๋Š” ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“œ์‹œ์˜ค.""" def game369(): gameList = [] numList = [] for i in range(100): number = i + 1 numStr = str(number) numList = list(numStr) if number %...
f165a5eb60dfb3b1386127de0053a5b067a9822e
d-jskim/202003_platform
/๊น€์ง€์ˆ˜/pre_python_08.py
367
3.78125
4
"""8. ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ์ง์ˆ˜์ธ์ง€ ํ™€์ˆ˜์ธ์ง€ ํ•€๋ณ„ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค""" def oddAndEven(no): if no % 2 == 0: print("{}์€(๋Š”) {}์ž…๋‹ˆ๋‹ค.".format(no, "์ง์ˆ˜")) else: print("{}์€(๋Š”) {}์ž…๋‹ˆ๋‹ค.".format(no, "ํ™€์ˆ˜")) inputNo = int(input("์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ")) oddAndEven(inputNo)
784098e278ecfdde7d752bc2f926cec0b68f63fe
roarkemc/StatTools
/stattools/utils/validation.py
9,422
4.21875
4
"""Functions for input validation.""" import functools import numbers import numpy as np def validate_bool(x, name) -> bool: """Validate boolean function parameters. Parameters ---------- x : object Object to validate as a bool. name : dtr Name of the function parameter. Re...
3825045f70720e42bd7618bdbb06cc4b34c1e9c2
roarkemc/StatTools
/stattools/visualization/classification.py
2,008
3.734375
4
"""Visualizations of classification results.""" import itertools import matplotlib.pyplot as plt import numpy as np from ..preprocessing import PCA def pca_label_plot(x, y_true, y_pred, ax=None, pca=None, marker_dict=None): """Reduce data to 2 dimensions and plot predicted labels colored according to wheth...
4e740956bea6be667b6d1d61dc7b3d39c2185636
TechforgoodCAST/beehive-data-etl
/beehivedata/assets/name_parse.py
2,191
3.53125
4
import re import titlecase def title_exceptions(word, **kwargs): word_test = word.strip("(){}<>.") # lowercase words if word_test.lower() in ['a', 'an', 'of', 'the', 'is', 'or']: return word.lower() # uppercase words if word_test.upper() in ['UK', 'FM', 'YMCA', 'PTA', 'PTFA', ...
c5e262d0df628a6a2badbd9a68b2550edcf1c88b
AhmadMWaddah/AMW_Functions
/AMW SLR Package.py
4,342
3.640625
4
class MeanSquaredError: def __init__(self, actual_data, predicted_data): self. # Mean Squared Error. def mean_square_error(self): """ Function Takes 2 Parameters lists of data, making counter and add to it and zipping lists. :param actual_data: :param predicted_data: :return: Mean Square...
ff0087ffb5f0916e6753f56ccda45bbfa11ebdd3
tomhudddson/PySnake
/menu.py
14,985
3.53125
4
import graphics as g import york_graphics as yg class Text(object): def __init__(self, string, x, y, size, colour): """ param string: the text to be displayed. param x: the x position of the string at the center. param y: the y position of the string at the center. par...
f941e9d41c10259c458fdec17995000d27fc0361
DerevenetsArtyom/pure-python
/algorithms/Problem_Solving_Algorithms_Data Structures/sorting_and_search/hash_table.py
2,575
3.578125
4
class HashTable: def __init__(self): self.size = 79 # Static for now, better to be a prime number self.slots = [None] * self.size # Contains list of keys self.data = [None] * self.size # Contains list of values @property def len_slots(self): return len(self.slots) de...
39c7d938326a6932678b96edfeb15ce135457c4f
DerevenetsArtyom/pure-python
/algorithms/Problem_Solving_Algorithms_Data Structures/binary_search/search_recursive.py
1,442
3.90625
4
# Recursive solution # Function takes only four arguments that I don't really like def binary_search_recursive(arr, item, low=0, high=-1): if not arr: # handling empty list return -1 if high == -1: # handling first iteration high = len(arr) - 1 if low >= high: # handle where we've got ...
5fb8b03e2a9bd734f04438f61c52b92477056d20
DerevenetsArtyom/pure-python
/algorithms/Problem_Solving_Algorithms_Data Structures/data_strutures/custom_stack.py
589
3.84375
4
class Stack: def __init__(self): self.lst = [] def push(self, item): self.lst.append(item) def pop(self): return self.lst.pop() def peek(self): return self.lst[-1] def isEmpty(self): # return self.items == [] return not bool(self.lst) def size...
8fee7f97dbc0e991dd0a3a9c0ea76270434da025
DerevenetsArtyom/pure-python
/generators/excess.org/rock_paper_scissors_game_2.py
2,274
3.875
4
from convenient_decorator import advanced_generator_once # This is a Rock-Paper-Scissors game where each player's play # is passed in separately, and once both players have played the result of # the game is yielded. Players can change their mind choose a different play # if the other player hasn't chosen yet. Games w...
06a5ebe2081b0fe4d5fe781f20e6d9a4aa827662
DerevenetsArtyom/pure-python
/algorithms/Problem_Solving_Algorithms_Data Structures/data_strutures/custom_queue.py
553
3.8125
4
class Queue: def __init__(self): self.items = [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): return self.items.pop() def isEmpty(self): # return self.items == [] return not bool(self.items) def size(self): return len(self...
9862233f3288dd7bddb10c5eb5e63a85bd227bcb
DerevenetsArtyom/pure-python
/decorators/func_decor_with_args.py
387
3.65625
4
def decorator(arg1, arg2): def inner_function(function): def wrapper(*args, **kwargs): print('Arguments passed to decorator {} and {}'.format(arg1, arg2)) function(*args, **kwargs) return wrapper return inner_function @decorator('foo', 'bar') def print_args(*args): ...
693d67255b9315e0017d5aeba2dfa70e94354e6e
Anik-Patel/Virus_Simulation
/Dot.py
2,015
3.640625
4
import pygame import math GREEN = (20, 255, 140) GREY = (210, 210 ,210) WHITE = (255, 255, 255) RED = (255, 0, 0) PURPLE = (255, 0, 255) BLUE = (0, 0, 255) BLACK = (0, 0, 0) class Dot(pygame.sprite.Sprite): # This class represents a car. It derives from the "Sprite" class in Pygame. def __init__(self, color...
6590b3032e86cc75414780f7da3aaabb639e4e19
asabnis7/python-basics
/ex33.py
419
3.890625
4
numbers = [] def looper(limit, incre): i = 0 while i < limit: print "At the top i is %d" % i numbers.append(i) i += incre print "Numbers now: ", numbers print "At the bottom i is %d" % i print "What limit?" limit = int(raw_input("> ")) print "What increment?" increment = int(raw_in...
5468e7eecbc019a53080e9af317ceb253f436165
asabnis7/python-basics
/ex21.py
785
4.0625
4
def add(a,b): print "Adding %d + %d" % (a, b) return a + b def subtract(a,b): print "Subtracting %d - %d" % (a, b) return a - b def multiply(a,b): print "Multiplying %d * %d" % (a, b) return a * b def divide(a,b): print "Dividing %d / %d" % (a, b) return a /b def inverse(a): print "Inv...
00f9ad42e47a67a73bf71cc9a3939d9bc2a36b9d
antonboychenko/contagion_network
/bases.py
4,215
3.78125
4
from datetime import datetime def main(): pass class base(object): """A class to store data on PUBG matches and cheaters""" def __init__(self): """Creates an empty base""" self.objects = {} def add_obj(self, obj): """Adds an object (cheater or match) to a base if it i...
13dea0bf6a088c1e76eb33189750af6c60d743f2
thisissagnik/Sorting-Algorithms-Visualisation-with-Python
/InsertionSort/__init__.py
877
3.5625
4
import time colorArray=[] def insertion_sort(data,drawdata,timetick): global colorArray for i in range(1,len(data)): CurrNumber=data[i] j = i-1 while j >=0 and CurrNumber < data[j] : data[j+1] = data[j] drawdata(data,GetColorArray(data,j)) ...
5e9092efdd27041b2c3a1cb92f10405fc01b6abf
erickvs/evs_lib
/AMPMtoMilitaryTimeConverter.py
694
4.28125
4
''' Given a time in -hour AM/PM format, convert it to military (-hour) time. Note: Midnight is on a -hour clock, and on a -hour clock. Noon is on a -hour clock, and on a -hour clock. Input Format A single string containing a time in -hour clock format (i.e.: or ), where and . Output Format Convert and print ...
9d8033e3ae5150bb8783bb9f1ee68917fec53207
kukayatan/OOP_python
/app_file.py
825
4.15625
4
# app that ask user for inputs to calculate either bmi or whr indexes from body_index import * while True: try: print("Welcome in body index calculator \nInput number 1 for BMI index \nInput number2 for WHR index") choice = int(input("Input what index you want to measure:")) if ch...
56c1ae0d88336af847b7da6c735d30b61b99ea29
leakydata/useful_python
/pandas.py
3,817
3.703125
4
# Remove Column Heading Formatting In Excel Export #pd.io.formats.excel.ExcelFormatter.header_style = None from pandas.io.formats import excel excel.ExcelFormatter.header_style = None # Pandas Nans to None df = df.replace([np.nan], [None]) df = df.where(pd.notnull(df), None) #Remove new line (\n) characters from the ...
4a469b6bea4c8a7c2dc3f15963307092f358a8fe
mcroydon/opencv_playground
/manipulators/goodfeatures.py
663
3.625
4
import cv def good_features(image): # Get the size of the image size = cv.GetSize(image) # Convert to gray gray_image = cv.CreateImage(size, 8, 1) cv.CvtColor(image, gray_image, cv.CV_RGB2GRAY) # Create temporary images for processing eig_image = cv.CreateImage(size, 32, 1) temp_imag...
ca98dc651fb784b61f1124a8c57b91656103f5d9
SongJin-Carleton/Python-Self-Learning
/04/14_functionPractice.py
442
4.1875
4
def get_3_paramaters(a,b,c): result = a + b + c print("Sum of three numbres is %d" %result) return result def average_3_numbers(num1,num2,num3): average = get_3_paramaters(num1,num2,num3) / 3 print("Average is %d" %average) num1 = int(input("Please input the first number :")) num2 = int(input("...
bf8bcc3d98c180e3e090c6be6b5dd14bc6b2ded4
SongJin-Carleton/Python-Self-Learning
/06/06-more.py
426
4.03125
4
#a = 200 a = [100] def test(num): num += num # in python num+=num is not equal with num = num+num, # just for int value they are same # num = num + num ===> [100]+[100] = [100,100], now num points to # new list [100,100],in the global original value won't change. ...
476db51076fc7baaae5533bda2a7c8a9bcb3c41c
SongJin-Carleton/Python-Self-Learning
/02/if&else.py
373
4.125
4
#age = input("Please input your age:") #age = int(age) a = 5 b = 2 # if age > 18: # print("You can drink alcholo") # else: # print("You cannot drink!") # print(a//b) # print(a/b) # print(a%b) # print(" Hello " * 10) you = input("Will you go?") yourWife = input("Will your wife go with you?") if you == "yes"...
bc8e85214e86f6ba13ddb38b18dbc92459a205d9
SongJin-Carleton/Python-Self-Learning
/03/15_For_else.py
429
3.953125
4
# nums = [11,22,33,44] # for item in nums: # print(item) # break # else: # print("=" * 10) cards_info = [{"name":"aaa","Tel":111,"age":11}, {"name":"bbb","Tel":222,"age":22}, {"name":"ccc","Tel":333,"age":33}] find_name = input("Please input a name: ") for item in cards_info:...
d59e0d394d75eb008ef96a60942bbe579526e256
pootle/YASS
/sudoku5.py
10,342
3.984375
4
#!/usr/bin/env python3 """ Core routines to solve sudoku """ def findEmpty(grid): """find the first unknown value position""" for r, row in enumerate(grid): for c, v in enumerate(row): if v is None: return r,c return None def testValid(grid, row, col, val): """ r...
1eec44f73e75ed8fa9b28f674c51c3c0e9658dac
ashish1500616/ITARM
/impdata.py
4,117
3.5625
4
import csv import sys import itertools #open the csv file containg the data with open('MOCK_DATA.csv') as csvfile: data=list(csv.reader(csvfile,delimiter=' ')) # print(data[0][0].split(',')[1]) # sys.exit() tempList=[] supportVariabe=50 indexCount=1 supportList=[] supindex=0 result=[] # sys.ex...
53fbb17d6314500ca19c40b626e1b5359660bd0a
joseVFernandez/adventOfCode2015
/day04/main.py
419
3.625
4
''' Created on Dec 4, 2015 @author: jose.fernandez ''' import hashlib import itertools def find_minimum_number_for_md5(input_string, number_of_zeroes): result_string = "0" * number_of_zeroes for i in itertools.count(): test_string = "".join([input_string, str(i)]) if (result_string == ...
f366d01f49da8536290119e17bfdae96b0c0e1d6
siphera/python-conditionals
/test.py
377
4
4
mark = int(input("Enter mark: ")) if not isinstance(mark, int): print("wrong input") elif 80 <= mark <= 100: print("grade A") elif 70 <= mark <= 79: print("Grade B") elif 50 <= mark <= 69: print("Grade C") elif 40 <= mark <= 49: print("Grade D") elif 0 <= mark <= 39: print("Grade E") else...