blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
68ea1674faba247ed68e8bc974ce43ad338cbea9
om-100/assignment2
/4.py
413
4.09375
4
# question number 4 """ Create a list. Append the names of your colleagues and friends to it. Has the id of the list changed? Sort the list. What is the first item on the list? What is the second item on the list? """ om = ('om', 'sapkota', 24) ram_b = ('ram', 'bahadur', 35) ram = ('Ram', 'Prasad', 26) people = [] pe...
7d16b1a4caca082162ed41edb8d679beec2d3389
LeonGuerreroM/Codigos-Python
/Binary_Power.py
2,641
4.15625
4
def binary_method(base, exponent, module): '''Funcion que realiza la potenciación modular con el método binario Entradas base => base de la potencia exponent => exponente de la potencia module => módulo de la potenciación modular Salidas C => resultado de la potenciación modu...
438b1ec6d0f5328716e708e6bf4b20d8b7c0dc1d
rlongo/ictf-gradings-paperwork
/ictf_pipeline/parsers/helpers.py
285
3.625
4
import os def verify_file(f): '''Check if a file exists''' return os.path.exists(f) def create_file_dirs(f): '''Creates parent directories for a given input file''' directory = os.path.dirname(f) if not os.path.exists(directory): os.makedirs(directory)
fe7941cd7c38737b68baf8cc698553b7b4b85216
pranjalc1/USACO-Python-Practice
/USACO Training/Section 1.3/1.3 Palindromic Squares.py
986
3.515625
4
''' ID: pranjal16 LANG: PYTHON3 TASK: palsquare ''' filein = open('palsquare.in','r') fileout = open('palsquare.out','w') B = int(filein.readlines()[0].strip()) filein.close() def numinbase(B,N): '''finds N in base B''' largest = 0 while B**largest <= N: largest += 1 i = largest-1 numin...
f9cfc61f7b8a99522ea80c330aac21ef01394e57
pranjalc1/USACO-Python-Practice
/USACO Training/Section 1.6/1.6 Prime Palindromes.py
1,580
3.671875
4
""" ID: pranjal16 LANG: PYTHON3 TASK: pprime """ filein = open('pprime.in','r') fileout = open('pprime.out','w') text = filein.readlines() a,b = text[0].split() a,b = int(a),int(b) filein.close() # check if prime def isprime(num): '''checks if the number is prime''' for i in range(3,int(num**0.5)+1,2): ...
0ec738fd86767ffe2821a29d72bccb8c2a1e3093
ManuelCoronel/python_scripts
/strings2.py
153
4
4
a = input("Ingrese la cadena #1 \n") b = input("Ingrese la cadena #2 \n") if a < b : print("A es menor que b") else : print("b es menor que a")
822425619e9887ec4a8eecc22e380643d86f4b5d
LidiaKrawczyk/git_tests
/gittie.py
412
3.78125
4
print('Hello!') print('Hello gittie! I am trying to learn GIT!') greetings = (input('Hello! What is your name?')) print('Hello {}!'.format(greetings)) index = 0 while index < 4: print("donkey") index += 1 answer = input('Do you want to hear a joke?') if answer == 'y': print('przychodzi baba do lekarza a ...
48d017956174921972e46796f3e553afb674fc85
fangxi1998/UniversityCode
/python/4-19_函数5/C.py
159
3.890625
4
def fib(n): sum=0 a,b=1,1 while a<=n: if a%2==0: sum+=a a,b=b,a+b return sum n=int(input()) print(fib(n))
3caca03495aac25be4a8136d74d0939c973fef09
fangxi1998/UniversityCode
/python/3-7_序列2/Dlist.py
694
3.640625
4
alist=list(map(int,input().split())) blist=list(map(int,input().split())) alist.extend(blist) blist=list(set(alist)) blist.sort() print(*blist,sep=',') ''' бalistblistҪбеÿԪضΪҲ10 ϲalistblistظԪȥһµбclist ʹʵбalist룺 alist=list(map(int,input().split())) ͬʱΪ֤һ£뽫Ԫ֮ УÿһжбеԪֵԿո һУϲб֮öŷָ'''
0d5d3358bcae060245b7ac6a3d92f4a970539ba4
fangxi1998/UniversityCode
/python/4-19_函数5/E.py
135
3.890625
4
def su(n): if n==1 or n==2 or n==3: return 1 else: return su(n-1)+su(n-3) n=int(input()) print(su(n))
91888f62dd6fd245306c0a766309c4758b8d9180
jart2222/pythoncorreo
/funcionescorreo.py
825
3.84375
4
class correos(): def __init__(self): self.a=input("Introduce tu correo por favor: ") def inicio(self): micorreo.limpiezaydescomposicion() micorreo.ciclo() print("correo valido. muchas gracias") def limpiezaydescomposicion(self): self.a=self.a.lstrip() self.a=self.a.rstrip() self.c=int(self.a.count("@...
7fa1ea43011c7928d272cb913da926a492369bef
Andyandpandy/codewars
/Completed_Kata/Sum_Of_A_Sequence.py
382
3.6875
4
def sequence_sum(begin_number, end_number, step): x = 0 for i in range(begin_number, end_number+1, step): x += i return x def sequence_sum_oneliner(begin, end, step): return sum(range(begin,end+1,step)) print(sequence_sum(2, 6, 2), 12) print(sequence_sum(1, 5, 1), 15) print(sequence_sum_oneli...
d2a194d424d857d72c449458138448d6af14d566
juliocesar2195/Python
/Clase2/Ejemplos/ejemplo1_1.py
1,062
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 02 16:46:31 2017 @author: labotec """ #%%Propiedades de las listas num = input("Ingrese numero : ") salida=[]#genero variable tipo lista for i in range(1,num+1): salida.append(i**2) print salida #%%Contar texto=["hola"] texto=texto*6 print texto...
f06e2de81f6aaea3b8ebf2616da3687276d61bcb
BrendanCase/cs364-FinalProject
/evaluator.py
1,022
3.59375
4
import nltk class Evaluator: def __init__(self, metrics, user): self.metrics = metrics #metric is the list of functions which the Evaluator evaluates the strings on self.minusThresh = -10 self.plusThresh = 25 self.user = user def evaluate(self, post): v = ...
3bba6f7020d16f657db3661c41b71a545c9b0cd5
aandreev0/threadEscape
/games/lab_escape/Door.py
1,521
3.671875
4
from Object import Object class Door(Object): def __init__(self, name, desc, key): Object.__init__(self,name,desc) self.init_description = desc self.locked = True self.key = key self.closed = True def lock(self, who): if self.key in who.inventory: if ...
88ccd4d5ff04e19902600a2466ef7893f2042d09
rafaelmarviila/thinkbi
/ex.py
236
3.921875
4
numero_multiplicado = input("Por favor digite o número que deseje a ser multiplicado: ") resultado_multiplicacao = int(float(numero_multiplicado) * 2) result = print("O valor de sua multiplicação é: ", resultado_multiplicacao)
bde5879c753c18e61f681a833fdade609a0badb1
Searsb/AdventOfCode
/2020/Day3.py
1,860
3.890625
4
##Author: Bryan Sears ##Date: 12/01/2020 ##Problem: ##read input in my_file = open("2020/Day3InputTesting.txt", "r") testlist = my_file.read().splitlines() my_file.close() ##read input in my_file = open("2020/Day3Input.txt", "r") lists = my_file.read().splitlines() my_file.close() ##Part 1 print('-'*25) print('...
c81d576469dc0ec9334253e729bf1c8341f58276
liambrock99/CAB431-Assignment-2
/Processor.py
1,293
3.53125
4
import re import string import xml.etree.ElementTree as ET from stemming.porter2 import stem from BowDoc import BowDoc stopwords = [] with open('stopwords.txt') as file: stopwords = file.read().split(',') """ Static methods for processing XML documents """ class Processor: def preprocess(text): "...
c46fa7649d77a884bd2a3dd1e808a00d640a1741
Gustavo-OF/BCR_exercicios_python
/1096/1096.py
121
3.515625
4
i = 1 j = 7 while i < 10: for c in range(0,3): print(f"I={i}", end=" ") print(f"J={j-c}") i += 2
13d759a3accaba9725d3b70f6a261fe9d9eca1a9
owaisali8/Python-Bootcamp-DSC-DSU
/week_1/2.py
924
4.125
4
def average(x): return sum(x)/len(x) user_records = int(input("How many student records do you want to save: ")) student_list = {} student_marks = [] for i in range(user_records): roll_number = input("Enter roll number:") name = input("Enter name: ") age = input("Enter age: ") marks = int(input("E...
9f770da2c9c45afc96c5390ee74fd8e256c1b27e
TZdybel/python-hangman
/hangman.py
3,977
3.625
4
import random import sys def writeToArray(words): a = 0 # zmienna pomocnicza, potrzebna do zakonczenie przeszukania pliku filepath = "slowa.txt" # wprowadzam nazwe/sciezke do pliku numOfWords = 0 try: file = open(filepath) file.seek(0, 2) # przesuwam wskaznik na ko...
f7ccdb31cc184e3603f2f465c1d68f5c694ef9d7
Ollisteka/Chipher_Breaker
/logic/encryptor.py
2,968
4.3125
4
#!/usr/bin/env python3 # coding=utf-8 import json import sys import tempfile from copy import copy from random import shuffle def read_json_file(filename, encoding): """ Read data, written in a json format from a file, and return it :param encoding: :param filename: :return: """ with open(...
1da79a8b67af7f2ae3c50aa55bc05af4694c6672
kyluca/aoc
/2018/1/1b.py
778
3.859375
4
from itertools import accumulate, cycle from collections import Counter INPUT_FILE = "./input.txt" def gen_change(): for line in open(INPUT_FILE, mode="rt"): yield int(line.strip()) def main(): frequency = 0 results = Counter({0: 0}) i = 0 changes = gen_change() while results.most...
d8f389b09a97f8d81678a298b198ab7f1d678aa1
anroots/teensy-moonica
/python/examples/memory.py
3,300
3.578125
4
#!/usr/bin/env python # A simple memory game example. # The Octo plays a sequence of notes and you have to repeat them. # The legs act as a keyboard. import os, sys from random import randint import time # Hack to import from a parent dir # http://stackoverflow.com/a/11158224/401554 parentdir = os.path.dirname(os.p...
b6d9ad9c90df27c7a65f8c933b68045de6053047
sophialuo/CrackingTheCodingInterview_4thEdition
/chapter2/2.5.py
2,133
4.03125
4
class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next_node = next_node class LinkedList(object): def __init__(self, head=None): self.head = head def size(self): current = self.head count = 0 whi...
0ca4115fe8d747cbdbdf8c19bce9613b6140642a
sophialuo/CrackingTheCodingInterview_4thEdition
/chapter8/8.4.py
360
3.8125
4
#8.4 #Write a method to compute all permutations of a string def perm(string): if len(string) <= 1: return [string] first_char = string[0] perms = perm(string[1:]) ans = [] for p in perms: for i in range(len(p)+1): ans.append(p[:i]+first_char+p[i:]) #insert the ...
65473b131108f7c9acf737753107a60dbfa2be41
sophialuo/CrackingTheCodingInterview_4thEdition
/chapter1/1.8.py
764
4.09375
4
''' 1.8 Assume you have a method isSubstring which checks if one word is a substring of another. given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring ''' def is_substring(orig_string, try_string): try: orig_string.index(try_string) ...
909f28e3de50e5b1b096fe162e5aaba387c273f1
sophialuo/CrackingTheCodingInterview_4thEdition
/chapter8/8.1.py
379
4.1875
4
#8.1 #Write a method to generate nth Fibonacci number def fib_recursion(n): if n <= 1: return 1 return fib_recursion(n-1) + fib_recursion(n-2) #a more space and time efficient way def fib_efficient(n): first = 0 second = 1 for i in range(n): temp = second s...
9c0d7ac946d082f5ccadef38f9de9c83c3a2534a
sophialuo/CrackingTheCodingInterview_4thEdition
/chapter1/1.7.py
727
3.78125
4
''' 1.7 Write an algorithm such that if an element in an MXN matrix is 0, its entire row and column is set to 0 ''' def zeroes(matrix, M, N): rows_with_zeros = [False for i in range(M)] cols_with_zeros =[False for i in range(N)] for row in range(M): for col in range(N): if m...
a35bfc3e54ec9c85770c70fc0ab222ef9b0062ab
FlyingSparrow/Python3_Learning
/Python3.4_Project/com/base/section23/object_oriented.py
3,281
4.03125
4
#!/usr/bin/python3 print("================类示例====================") class MyClass: """一个简单的类实例""" i = 12345 def __init__(self): self.data = [] def f(self): return 'hello world' x = MyClass() print("MyClass 类的属性 i 为:", x.i) print("MyClass 类的方法 f 输出为:", x.f()) print("===================...
110ebd73e127064f6265c7407a486412eeb4218d
FlyingSparrow/Python3_Learning
/Python3.4_Project/com/base/section8/string.py
603
3.65625
4
#!/usr/bin/python3 var1 = 'Hello World!' var2 = 'Runoob' print("var1[0]: ", var1[0]) print("var2[1:5]: ", var2[1:5]) print("已更新字符串:", var1[:6] + 'Runoob!') a = "Hello" b = "Python" print("a + b 输出结果:", a + b) print("a * 2 输出结果:", a*2) print("a[1] 输出结果:", a[1]) print("a[1:4] 输出结果:", a[1:4]) if("H" in a): print(...
7fa691f1d9f48d3818935d431a98c855b71dbf46
FlyingSparrow/Python3_Learning
/Python3.4_Project/com/base/section10/tuple.py
322
3.75
4
#!/usr/bin/python3 tup1 = () tup1 = (50) print(type(tup1)) tup1 = (50,) print(type(tup1)) tup1 = ('Google', 'Runoob', 1997, 2000) tup2 = (1, 2, 3, 4, 5, 6, 7) print("tup1[0]: ", tup1[0]) print("tup2[1:5]", tup2[1:5]) tup1 = (12, 34.56) tup2 = ('abc', 'xyz') # 创建一个新的元组 tup3 = tup1 + tup2; print(tup3)
d453fea7cdea71dc9ca2cf967350e9d9bfb836e3
FlyingSparrow/Python3_Learning
/Python3.4_Project/com/base/section3/basic_datatype.py
1,517
4.15625
4
#!/usr/bin/python3 print("==============变量示例=================") counter = 100 miles = 1000.0 name = "runoob" print(counter) print(miles) print(name) print("==============字符串示例=================") str = 'Runoob' print(str) print(str[0:-1]) print(str[0]) print(str[2:5]) print(str[2:]) print(str*2) print(str+"TEST") p...
15065a683fa733faa071b3f9e145100ca355951c
FlyingSparrow/Python3_Learning
/Python3.4_Project/com/base/section25/sample_23.py
930
4.15625
4
#!/usr/bin/python3 print("{0}简单计算器实现{1}".format('=' * 10, '=' * 10)) def add(x, y): return x + y def substract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: print('divisor can not be zero') return else: return x / y print('选择运算:'...
b26fdb79541ab9b8a3e88f77752526c6efeca6b5
glifed/Flashbacks_1-5_sem
/2 sem/Python/2 sem/Zaschita_TK.py
1,998
3.5625
4
#Защита from math import * from tkinter import * place = Tk() size = 500 h = size // 2 canv = Canvas(place, width = size, height = size, bg = "lightblue") def main(): x_d = [] y_d = [] dots = int(input("Введите количество точек: ")) for i in range(dots): s = input("Введите координаты точки: "...
deaff24fd27a14cf7e00ef1e01e4f731426a6bd8
glifed/Flashbacks_1-5_sem
/1 sem/Python/YaD_funcs.py
1,547
4.0625
4
#Янова Даниэлла ИУ7-13 #Вычислить Y(x) по заданной функции для вводимого Х. try: x=float(input('Введите значние Х: ')) except ValueError: print('Ошибка при записи числа') x=float(input('Введите значние Х: ')) if -1<=x<1: #Находим с помощью if then else, без использования булевых операций Y1=abs...
c714d34733a15642c9e4681f6dc53e3a31ca32d6
glifed/Flashbacks_1-5_sem
/2 sem/Python/2 sem/pygame/Тесты движения.py
989
3.71875
4
import pygame from pygame import * from math import * # Иницилиализируем pygame pygame.init() # Создаем окно DISPLAY = (1000, 700) screen = pygame.display.set_mode(DISPLAY) pygame.display.set_caption('Window for drawing') # -------- Цикл главной программы ----------- # Начальная позиция прямоугольника x = 0 done ...
929dc281420943046efdf23217babe5f6cb900bf
glifed/Flashbacks_1-5_sem
/2 sem/Python/2 sem/pygame/Z pygame.py
3,515
3.65625
4
import pygame from pygame import * from math import pi, cos, sin, sqrt SCREEN_WIDTH = 1200 SCREEN_HEIGHT = 400 DISPLAY = (SCREEN_WIDTH,SCREEN_HEIGHT) # задаем размеры окна pygame.init() # иницилиализируем pygame screen = pygame.display.set_mode(DISPLAY) # создаем окно pygame.display.set_caption('Kvadrat'...
de163b28d7e21d5ae9c4b55923c5596feb59be37
glifed/Flashbacks_1-5_sem
/2 sem/Python/2 sem/Zashita_okr.py
2,305
3.625
4
#Янова Даниэлла ИУ7-23 from math import sqrt from tkinter import * N=0 N=int(input('Введите количество окружностей: ')) while N<=2: print('Окружностей должно быть не менее двух!') N=int(input('Введите количество окружностей: ')) x=[0]*N y=[0]*N rad=[0]*N for i in range(N): xi,yi=map(float,input('Введ...
8c9562639096d9e809da97a5b6e692d9e79c9fc8
jrimyak/NLTKPractice
/NLTK/wordStemming.py
477
3.96875
4
#Word stemming means removing affixes form words and return the root word #"Working" becomes "work" #Use the NLTK implemention of the Porter stemming algorithm #There are different algorithms for stemming words such as the Lancaster algorithms where some words will be different from nltk.stem import PorterStemmer #Cre...
79487180ea1de38c385619abc2bc68e09c21818b
Noscuro52/Stage-2021
/CrowBox/Code Jetson/sample button.py
1,002
3.515625
4
import Jetson.GPIO as GPIO import time # Pin Definitions but_pin = 'DAP4_SCLK' # BOARD pin 12, BCM pin 18 def main(): # Pin Setup: # Board pin-numbering scheme GPIO.setmode(GPIO.TEGRA_SOC) # set pin as an output pin with optional initial state of HIGH # GPIO.setup(output_pin, GPIO.IN) GPIO.set...
9dd7c5ec0ac2a8510e408bb2b54c2e4a47ca95d2
Leliny/ciphertools
/ciphertools/skip.py
1,184
3.828125
4
import english_words DICT_WORDS = english_words.get_words() def skip(plain, dist, offset=0): """ Skip cipher the string plain by an amount dist starting at offset """ idx = offset % len(plain) result = [] while len(result) < len(plain): result.append(plain[idx]) idx = (idx + dist) % len(plain) retu...
57343f7efe5f3b8a4049323a4a156bf36d0f4ce5
Leliny/ciphertools
/ciphertools/vigenere.py
971
3.796875
4
from itertools import cycle import string def vigenere_encrypt(plain, key): """ Vigenere encrypts plaintext with key. """ plain = plain.lower() key = key.lower() alphabet = string.ascii_lowercase def enc_char(p, k): if p not in alphabet: return p c = alphabet.find(p) + alphabet.find(k) re...
2629c37b964891a70d07734fd0afd8a428c42ee5
kaderfoysal/Code-camp-Basic-problem
/2.py
138
3.953125
4
number1 = int(input("input first number : ")) number2 = int(input("input second number: ")) sum = number1 + number2 print("sum = ", sum)
1a481a8741d7f9b59c3bd85f81dfe31a31cf0888
kaderfoysal/Code-camp-Basic-problem
/8.py
159
3.96875
4
c = int (input(" Enter temperature in Celsius: ")) celsius = (c) fahrenheit = (celsius * 9 / 5) + 32. print("Temperature in Fahrenheit = ", fahrenheit, "F")
641a5569e5ef6a0fcdd1dfbf3daaad5f9e8bafe9
PDMacDonald/CIS_Python_Projects
/CIS_3680_Final_PDM/CSV_Utilities.py
1,008
3.984375
4
#!/usr/bin/env python3 """ Read_CSV_Utilities.py: Code responsible for reading a CSV file into a dictionary for processing in python. CIS3680-101 Final Exam Program Date created: 05/03/2019 """ __author__ = "Preston MacDonald" __copyright__ = "Copyright 2019, Preston MacDonald" __credits__ = [""] ...
261220afc50418fc68c4a5e70c3562970253392a
SeiteAlexMH/pyhton-stuff
/code_war.py
243
3.59375
4
def next_happy_year(year): n = 0 year_found = True while n <10.0: m = str(year).count(str(n)) if m <= 1: pass else: year_found = False n+=1 return year_found if next_happy_year(2013): print('success') else: print('fail')
10d15b40dc30395f840677a1174278f48bf74c90
chanwooDev/Algorithm
/Programmers-Python/Programmers - 크레인인형뽑기게임_ver2.py
764
3.828125
4
def solution(board, moves): answer = 0 crane = [] for move in moves: move -= 1 for i in range(len(board)): if board[i][move]: if not crane : crane.append(board[i][move]) else: craneData = crane.pop() ...
888506a7aea37d1bd08fc08e37155b3efb0105b5
chanwooDev/Algorithm
/Programmers-Python/Programmers - 자물쇠와열쇠.py
1,427
3.578125
4
# 90도 회전 def rotate_a_matrix_by_90_degree(a): n = len(a) m = len(a[0]) result = [[0] * m for _ in range(n)] for i in range(n): for j in range(m): result[j][n-i-1] = a[i][j] return result # 자물쇠 중간 부분이 모두 1인지 확인 def check(new_lock): length = len(new_lock) // 3 for i i...
b103e9b14ab4268d227398cc62633142e50fe9ca
chanwooDev/Algorithm
/Programmers-Python/Programmers - 오픈채팅방.py
800
3.6875
4
def solution(record): userDic = dict() # 유저아이디, 닉네임 chat = [] answer = [] for dataList in record : # data[0] : Enter ,Leave , Change /[1] : uid1234 , uid4567 /[2] : Muzi, Prodo data = dataList.split() if data[0] == "Enter": userDic[data[1]] = data[2] chat.a...
488643fa30fa3349e488c623c294545550ba3adc
biopherret/128AL-Muon-Group-3
/vectorized_group_one_electron_density.py
907
4.03125
4
# -*- coding: utf-8 -*- """ Created on Tue May 4 15:40:02 2021 @author: marti """ import numpy as np import matplotlib.pyplot as plt # takes an input of height in meters and returns the electron density of the atmosphere # at that height in number of electrons per cubic meter def density_of_atmosphere(hei...
5e82537c0ffdc3e1f3bc104740043709a0571418
krishnapvs/Cracking-Trees
/BalancedTree.py
1,989
3.765625
4
import random class BTree(object): def __init__(self, data): self.key=data self.left=None self.right=None # -1 means the value is not yet set self.depth=-1 def __str__(self): return "( " + str(self.key) + " ( " + str(self.left) + " | " + str(self.right) + "))" ...
510fc8b92cc08297c72a50dbd1eee16bb1227d0a
rahulsharma511/sign-language-translator
/scrollable_class.py
7,225
3.765625
4
import cv2 import numpy as np class PanZoomWindow(object): """ Controls an OpenCV window. Registers a mouse listener so that: 1. right-dragging up/down zooms in/out 2. right-clicking re-centers 3. trackbars scroll vertically and horizontally You can open multiple windows at once if you...
08fe1b8568d76d80a4ff9bee65f02d9ed80ddd80
skhani/google-traffic-screen
/location.py
1,227
3.546875
4
#!/usr/bin/env python import math import logging class Location(object): def __init__(self, name, address): self.reset() self.name = name self.address = address self.distance = "..." self.eta = 0 self.level = 0 self.speed = 0 def reset(self): self.distance = "..." self.eta =...
ff99f3d8ca40994f3281518c74f65cd4d8fb6b12
ldher/adventofcode2020
/day6/main.py
816
3.578125
4
from pathlib import Path from collections import Counter def count_answers(group): answers = group.replace("\n", "") return len(set(answers)) def count_all_yes(group): counter = Counter(group) group_size = (counter.get("\n") or 0) + 1 return len({answer for answer, count in counter.items() if co...
cb856459cc38ebf302bee5d9a0fedf1fc1183c14
Jcgo3003/Funtions-Python
/Tiempo/ti.py
702
3.53125
4
import time from datetime import datetime, timedelta import datetime as dt d = int(round(349.75)) print("Redondeo", d) # d = timedelta(microseconds=1) # print(d) # d = timedelta(minutes=1.5) # (d.days, d.seconds, d.microseconds) # print(d) t3 = timedelta(seconds = d) print("Tiempo 3", t3) t2 = (time.strftime('%H:...
d2efeb84e05786b029007cb778346e17f5fd2d6a
Jcgo3003/Funtions-Python
/listasmix.py
192
3.65625
4
pro_a = [] a = 1 + 2 pro_a.append(a) pro_a.append(1+1) pro_b = [1, 2, 5] print("a", pro_a) print("b", pro_b) # haciendo 2 listas una sola pro_final = pro_a + pro_b print("Final", pro_final)
64b324b0e4a199c6883af63ed80973c4e8648bb5
brianchiang-tw/Python_Toolbox
/CSV Reader/stat_country.py
667
3.6875
4
import csv # open CSV file with open('test.csv', encoding='utf-8') as csvfile: country = ['美國','法國','日本'] country_occ = dict().fromkeys(country, 0) # read csv as python dictionary rows = csv.DictReader(csvfile) fields = rows.fieldnames # print fieldname of csv file #print("fieldnames of ...
1f64fdf12e6b80e818f2479bf722d97e42e599ee
MonkeyPengc/Order-Pizza
/client/pizza.py
4,297
3.515625
4
from .meats import Meats, MeatsMenu from .veggies import Veggies, VeggiesMenu class PizzaSize: Personal = 0 Medium = 1 Large = 2 class CheeseAmount: Zero = 0 Regular = 1 Extra = 2 class IngredientAmount: Zero = 0 Regular = 1 Extra = 2 class Pizza: def __init__(self, siz...
7f01c5d8ceb30d69ea27ad5878189abfcc5b2a08
MonkeyPengc/Order-Pizza
/database/admin_database.py
2,092
3.890625
4
import sqlite3 import random import hashlib try: from string import ascii_letters as letters ## python 3 except ImportError: from string import letters ## python 2 class adminDB: """ Database that stores account records of users having access to the sales database. """ def __init__(...
f9794155ecb56aea3a814958c88e424f7a874e29
Borna5356/chess
/moves.py
13,586
4.125
4
""" This module is responsible for creating the different possible moves for the pieces """ import pieces import board def move_piece(piece, board): """ This function is for moving knights """ if (piece.get_name() == "knight"): moves = [(2, 1), (-2, 1), (2, -1), (-2, -1), (1, 2), (1, -2), (-...
1be8e78a10d13b31487d147a1a4b9f714745397f
benjamintmc/Practice_Password_checking
/practice_password.py
546
4.0625
4
# #password = 'a123456' #time = 3 #pw = input('Enter your password: ') #while pw != password: # if time > 0: # print('Try again') # time = time - 1 # print('You have', time, 'time left') # pw = input('Enter your password: ') # elif time == 0: # print('No more chance!') # break #print('Good job!') password = 'a1...
1610ed3b8b0226299e1d57bc0e4c77ba77fbc025
43061b4a/phone_number_to_words
/number_converter.py
2,576
3.578125
4
import time from functools import lru_cache from trie import PrefixTree class NumberConverter(object): def __init__(self): self.trie = PrefixTree() with open('words_en.txt') as file: lines = [line.rstrip('\n') for line in file] for line in lines: self.trie...
6fd09cc3bf00dffae2698792516819026e6ab1fd
Shreyadontha/python_14_july
/python 2.py
377
3.875
4
name="shreya" print(name) rollno='77' print(rollno) a=int(input("enter the english marks:")) b=int(input("enter the telugu marks:")) c=int(input("enter the computer marks:")) d=int(input("enter the maths marks:")) e=int(input("enter the science marks:")) total=(a+b+c+d+e) print(total) percentage=(total/500)*...
c4be3b698430a4c18e6511dc7b8dbac0bd432e6a
asgg4321/python_lib
/python_test/name_saying.py
207
3.5625
4
# -*- coding: utf-8 -*- name = "\t\nalbert einstein\n" saying = "\"A person who never made a mistake never tried anything new.\"" print(name) print("delete space") print(name.title().strip() + " once said, " + saying)
dd57cf9eb7b9182ab8ce957b534a9d3eee8750b9
J1ng06/4dn4_Advanced_Internet_Communications
/Lab 2/4DN4_LAB2_JC_WZ/4DN4_LAB2_JC_WZ/Client_Code/FTPClient.py
4,447
3.59375
4
import socket import sys import os import time # Create a TCP/IP socket sock = None # Connect the socket to the port where the server is listening server_address = '' amount_received = 0 file_found = False # client always running unless break while True: message = raw_input('Enter your command.\n') if(...
2b15b322662d81bfaf2c650314620c5b5ea677b1
ethanjoyce14/RPG-Classes
/rpg_classes_map.py
5,199
3.78125
4
# Ethan Joyce # Ms Cotcher # 2020/01/15 # CS30 # RPG Classes import rpg_classes_inventory # List of available pickups in room 4 pickups_rm4 = ['key'] class Room: """ A class for all room descriptions """ def __init__(self, desc): self.desc = desc # All rooms and their...
c35b42168c1043a7a47b064f14c9812838178e16
qujinliang/mytest
/moocseven/nine/c1.py
1,030
3.90625
4
# 面向对象 # 有意义的面向对象代码 # 类 = 面向对象 # 类、对象 # 类和对象 from moocseven.nine.c2 import Human class Student(Human): def __init__(self, school, name, age): self.school = school super(Student, self).__init__(name, age) self.score = 0 def do_homework(self): print('english homework') # de...
23a3b2898099d252e45fddf39da8aebc810de56c
qujinliang/mytest
/pyMysql/Demo_Select.py
1,022
3.546875
4
""" Created by qujl on 2018-05-10 """ __author__ = 'qujl' ''' fetchone():该方法获取一下个查询结果集,结果集是一个对象 fetchall():接受全部的返回结果 rowcount():这是一个只读属性,并返回执行execute()方法最后影像的行数。 ''' # 实例:查询 EMPLOYEE表中的salary(工资) 字段大于1000的所有数据: import pymysql # 打开数据库连接 db = pymysql.connect("localhost","testuser","test123","TESTDB") curs...
1bfe6b4782c218a22ea1054bb46bf4f8291ecdbe
qujinliang/mytest
/algorithm/quick_sort2.py
546
3.796875
4
""" Created by qujl on 2018-05-10 """ __author__ = 'qujl' from random import randint # quick_sort L = [randint(0,5) for i in range(5)] print(L) def quick_sort(L, left, right): i = left j = right if i >= j: return key = L[i] while i < j: while i < j and L[j] >= key: j =...
b3a8a0a2c4413efbc54aeb4f1609670ce865147b
vortex-exoplanet/VIP
/vip_hci/config/mem.py
1,938
3.8125
4
#! /usr/bin/env python """ System memory related functions """ __author__ = 'Carlos Alberto Gomez Gonzalez' __all__ = ['check_enough_memory', 'get_available_memory'] from psutil import virtual_memory def get_available_memory(verbose=True): """ Get the available memory in bytes. Parameters ...
f0708a0ede8922bb981c09571cefff7315bbca84
ralphplumley/coursera
/algo-toolbox/week3_greedy_algorithms/1_money_change/my_change.py
349
3.8125
4
# Uses python3 import sys def get_change(m): #write your code here output = (m // 10) + ( (m % 10) // 5 + (m % 5) ) # print('Dimes: ', m//10) # print('Nickels', (m%10)//5) # print('Pennies', m%5) return output if __name__ == '__main__': # m = int(sys.stdin.read()) input = int(input()) ...
d5734684623b3ec1bf75fdef8ef6abd4d2e2c6fa
UN-FISICA/taller-2-2018-2-Julietta1
/Ejercicio3.py
711
3.65625
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 7 20:35:27 2018 @author: salvi """ import math as m from turtle import * N=int(input("Digite el número de lados del polígono: ")) n=int(input("Digite el numero de lados del polígono de alineación: ")) title("Ejercicio 3") screensize(4000,4000) speed("fast...
316fb3c877c7009ab06ea152347916ff1a72477d
Mantom112/Phase3Project1
/TommyKylePhase3.py
3,061
4.53125
5
import sqlite3 from sqlite3 import Error def create_Conection(db_file): """ this will connect to the db file that is specified later on in the code :param_db is the db we want to connect to :return the connection to the db""" conn = None try: conn = sqlite3.connect(db_file) print("Connected to the Database")...
a80c4b8a51218956a7a38e2a42487083487e815d
LarsAstrom/Notebook
/code/gcdbezout.py
630
3.75
4
''' Returns gcd for two numbers, or for all numbers in a list. Also returns Bezout's identity. Time Complexity: O(N) (if b == 1), O(logN) for random numbers, N = a+b. Space Complexity: O(1) TODO: Do it iteratively. ''' def gcd(a,b): if a < b: return gcd(b,a) if b == 0: return a return gcd(b...
0e6f103fe7413d6a3628705ae583fd9416974591
LarsAstrom/Notebook
/code/crt.py
867
3.515625
4
''' Implementation of the chineese remainder theorem. The equation is x = a_i mod b_i for a_i in a, b_i in b. Time Complexity: O(n^2), n = len(a)=len(b). Space complexity: O(n) ''' def gcd(a,b): if a < b: return gcd(b,a) if b == 0: return a return gcd(b,a%b) #Returns (u,v) such that au+bv = gcd(a,b) def...
2aad8bd52539af5121ea27d1d76bb3b2213fb088
LarsAstrom/Notebook
/code/monotonequeue.py
791
3.96875
4
''' Keeps a monotone queue (always increasing or decreasing). This is good for solving "What is the smallest (largest) element in the window of size L in an array. This is done by in each step calling add and remove on the monotone queue and also looking at the smallest (largest) element which is at position 0. Time-...
f84cf15c04be752423408f06737cc5100c7f0cf4
af94080/bitesofpy
/9/palindrome.py
1,406
4.3125
4
"""A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward""" import os import urllib.request DICTIONARY = os.path.join('/tmp', 'dictionary_m_words.txt') urllib.request.urlretrieve('http://bit.ly/2Cbj6zn', DICTIONARY) def load_dictionary(): """Lo...
8d1edce6de9e45d6bd5f0d033b0f3d265f85b388
Multivalence/Algorithms
/sorting/insertionSort.py
1,546
3.859375
4
from manipulate import Manipulate import time ''' # Time quadruples every time elements are doubled INSERTION SORT 5000: ~1.4 seconds 10000: ~5.6 seconds 20000: ~22.4 seconds 40000: ~89.6 seconds 80000: ~358.4 seconds 160000: ~1433.6 seconds # Time triples every time elements are doubled TIMSORT (BUILT-IN) 500...
03a71c05e501f2fce0cb9207e6be8ca77a3ba877
brightskylee/python_practice
/practice/num_of_python.py
478
3.59375
4
import os def num_of_python(root_dir): number_of_python = 0 for path, sub_dirs, files in os.walk(root_dir): for file in files: if file.endswith(".py"): print(os.path.join(path, file)) number_of_python += 1 for sub_dir in sub_dirs: number_of_pytho...
64ae5cbc52fc329b66c7339ffa1e42742e96047e
chaerim-kim/Data-Structures-and-Algorithms
/Common Intv Algo/mergesort.py
946
3.90625
4
# 반복적으로 한개가 남을때까지 n/2로 나눈다 - conquer # 그후, 나뉜 두 리스트의 앞부분 부터 비교하며 반복적으로 merge한 def mergesort(arr): # if the list has more than 1 element (not sorted) if len(arr)<= 1: return arr mid = len(arr) // 2 # split the array L = mergesort(arr[:mid]) R = mergesort(arr[mid:]) return merge(L,R) de...
31c322cb2e3b8c927a9ab439741a732d60bbbc06
chaerim-kim/Data-Structures-and-Algorithms
/2.Dictionaries and Hashmaps/2.2TwoStrings.py
822
3.859375
4
import math import os import random import re import sys # if two strings s1,s2 share a common string def twoStrings(s1, s2): ans="YES" # split the word into a single character and aggregate it into a set to remove duplicates splitted_s1 =set(list(s1)) splitted_s2 =set(list(s2)) # if there exists...
09255fb110646e21ab2cc2aceb6da013fe62b3eb
chaerim-kim/Data-Structures-and-Algorithms
/Stack/20. Valid Parentheses.py
347
3.765625
4
class Solution: def isValid(self, s: str) -> bool: stack = [] dic = {'(':')', '{':'}', '[':']' } for char in s: if char in dic.keys(): stack.append(char) elif stack == [] or char != dic[stack.pop()] : return Fals...
bd10144291c59cf46b942e738a6fb43c7b124863
jgrynczewski/testowanie_waw
/test_funkcje_unit.py
755
3.78125
4
import math import unittest import funkcje class TestCircleArea(unittest.TestCase): def test_area(self): """Test area when radius >=0""" self.assertAlmostEqual(funkcje.circle_area(1), math.pi) # zgodność 7 miejsc po przecinku self.assertEqual(funkcje.circle_area(0), 0) self.assert...
019e669d17c7b67ab92e4e7e22331b7c34dc9f0c
fmoralesc/python-keychainbinder
/keychainbinder.py
1,575
3.5
4
#!/usr/bin/env python """some functions to bind globally available key sequences to callable objects.""" import gobject import keybinder def bind_keychain(chain, callback, timeout=400): """Bind a callable object to a globally available key sequence. Arguments: chain -- a string describing the key sequence. cal...
11b2130a0c61504054f8d1fc5b2dae655b554bbe
davidozhang/spycodes
/Scripts/sort_dedup.py
520
3.796875
4
#/usr/bin/python from __future__ import print_function # Output is directly copy-able to SCWordBank.swift def print_sorted_deduped_list(collection): print('[', end='') s = sorted(list(set(collection))) l = len(s) for e, word in enumerate(s): print('"{}"'.format(word), end='') if e == l ...
2342465bcbe36147e43003e19f00b7ac618faf8f
guainlin/convenient-code
/reorder by repeated numbers.py
544
3.828125
4
'reorder by repeated numbers' def reorder( li_repeat_num , li_repeat ): li_reorder = [] first=0 last =0 for i in li_repeat_num : last = first + i li_reorder.append( li_repeat[first:last:1] ) first = last return( li_reorder ) '''...
793ed57ec24969417448e976158625ea752871db
wangxuyongkang/chengxuyuanhh
/Code/爬虫/07day/线程复习.py
2,513
4.0625
4
#使用线程 import threading import time sum = 0 def work_one(num): global sum print(num) lockA.acquire() #枷锁 time.sleep(1) lockB.acquire() for i in range(0,num): # time.sleep(0.05) #threading.currentThread().name获取线程的名称 # print(threading.currentThread().name,i) sum +...
7dbc5add2711275e1237d56aa3751d0cc8de81ec
BritoO97/NJCU_Linux_Class
/Week10/MarkDecello/Problem1/getCoordinates.py
79
3.625
4
#!/bin/python3 x = 0 while(x <= 10): print(f"{x:.4f}") x = x + 0.0001
d6d6bd5f5fe4bbacb66fb4f3be1f2345f7745fdc
alexander-lloyd/interpreter
/proglang/scanner.py
2,302
3.6875
4
from typing import List, Optional from proglang.token import Token, TokenType def is_digit(c: str) -> bool: return '0' <= c <= '9' class Scanner: def __init__(self, source: str): self.source = source self.start = 0 self.current = 0 def scan_tokens(self) -> List[Token]: ...
e946c2ebe53cdd0d63871575ba8c54cf817a6ac7
arminAnderson/CodingChallenges
/ProjectEuler/Python/TruncatablePrimes.py
584
3.953125
4
def IsPrime(num): if (num % 2 == 0 and num > 2) or num == 1: return 0 i = 3 while i * i <= num: if num % i == 0: return False i += 2 return True iter = 11 remaining = 11 result = 0 while remaining > 0: i = iter j = 0 t = 1 fail = False while i > 0...
77526f4046dcaed3dc5669ec9c2a470c9e9a1f17
arminAnderson/CodingChallenges
/Facebook/TravelRestrictions.py
821
3.515625
4
cases = int(input()) for i in range(cases): length = int(input()) arrA = input() #can enter arrB = input() #can leave ret = [] for j in range(0, length): k = j charArr = [] for pos in range(length): charArr.append("N") ret.append(charArr) ...
e49003e82eab96207467ccb0f5dc0c231c2f4f1c
arminAnderson/CodingChallenges
/ProjectEuler/Python/SubStringDiv.py
1,231
3.515625
4
from math import factorial def ReverseSectionOfArr(arr, start): swapAmount = (len(arr) - start)//2 k = len(arr) - 1 for i in range(swapAmount): i += start temp = arr[i] arr[i] = arr[k] arr[k] = temp k -= 1 return arr def GetLexi(arr): for i in range(factoria...
1bfd6865e9f465aedb60c8327bb74bccb2d3361d
arminAnderson/CodingChallenges
/Facebook/MrX.py
339
3.65625
4
def Study(s): cases = int(input()) for i in range(cases): sequence = input() if len(sequence) == 1: try: int(sequence) print("Case #{}: {}".format(i + 1, "0")) except ValueError: print("Case #{}: {}".format(i + 1, "1")) else: St...
3adb56113fb0b76404dd8882ff3c64c4de788ceb
arminAnderson/CodingChallenges
/ProjectEuler/Python/PandigitalMultiples.py
606
3.59375
4
import math def GetDigitCount(num): return int(math.log10(num))+1 panSet = set() def IsPandigital(arr): panSet.clear() panSet.add('0') for t in arr: if t in panSet: return False else: panSet.add(t) return len(panSet) == 10 temp = "" for i in range(1, 10...
d05e221a115f40573e30c9be2c2348e4ffb2684a
nareshdb/codechefSolutions
/CHEFING/answer.py
543
3.5625
4
noOfTestCases = input() for i in range(0, noOfTestCases): noOfDishes = input() charCount = {} for j in range(0, noOfDishes): ingredients = raw_input() presentChars = {} for k in range(0, len(ingredients)): presentChars[ingredients[k]] = True for ingredient, value in presentChars.items(): if ingredie...
bb5416e4d56ddf64d44591c5bed4ed18f57aa1a1
nareshdb/codechefSolutions
/COOK102B_ADAMTR/answer.py
1,171
3.5
4
import math noOfTestCases = input() def compareMatrix(matrix, comparisonMatrix, matSize): for j in range(0, int(math.ceil(float(matSize)/2.0))): noInJthCircleInitialMatrix = {} for l in range(j, matSize-j): noInJthCircleInitialMatrix[matrix[j][l]] = True noInJthCircleInitialMatrix[matrix[l][j]] = True...
003e11479d5d001e6bb01c71be889f0bc922de69
shaowei2019/shiyanlou
/listtest.py
204
3.65625
4
#!/usr/bin/env python3 import sys big = [] small = [] for arg in sys.argv[1:]: if len(arg) > 3: big.append(arg) else: small.append(arg) print(' '.join(small)) print(' '.join(big))
2a52be36b84f897e082efc5f41c86552fa07eb3c
chinmaygiri007/Machine-Learning-Repository
/Part 1 - Data Preprocessing/Using_Imputer.py
642
4.03125
4
#Imputer is use to Fill the Missing Values in dataset Using Various Strategies like: # 1.Mean 2.Median 3.Most Frequent #Import required libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt #Reading the data data = pd.read_csv("Data.csv") X = data[["Country","Age","Salary"]].values Y = dat...
2a482264dc15fc4c17fc27e08d9247351e47815a
chinmaygiri007/Machine-Learning-Repository
/Part 2 - Regression/Section 6 - Polynomial Regression/Polynomial_Regression_Demo.py
1,317
4.25
4
#Creating the model using Polynomial Regression and fit the data and Visualize the data. #Check out the difference between Linear and Polynomial Regression #Import required libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #Reading the data data = pd.read_csv("Position_Salaries.csv") ...