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
12284512b8af388e4ed161a00fea411dfead3100
sakura-fly/learnpyqt
/src/布局/绝对定位.py
1,054
4.21875
4
""" 程序指定了组件的位置并且每个组件的大小用像素作为单位来丈量。当你使用了绝对定位,我们需要知道下面的几点限制: 如果我们改变了窗口大小,组件的位置和大小并不会发生改变。 在不同平台上,应用的外观可能不同 改变我们应用中的字体的话可能会把应用弄得一团糟。 如果我们决定改变我们的布局,我们必须完全重写我们的布局,这样非常乏味和浪费时间。 """ import sys from PyQt5.QtWidgets import QWidget, QLabel, QApplication class Example(QWidget): def __init__(self): super().__init_...
81f91a2469b17797ef6dea07455970b80f854cb5
rebecamacedo80/Pascal-compiler
/lexico.py
9,588
3.578125
4
from token import Token import sys class Lexico: def __init__(self): self.palavras_chaves = ['program', 'var', 'integer', 'real', 'boolean', 'procedure', 'begin', 'end', 'if', 'then', 'else', 'while', 'do', 'not'] self.delimitadores = ['.', ',', ';', ':', '(', ')'] self.aditivos = ['+', '-'...
ae0822d07e8d28e0dbfc5b5f2d9526985f34e1c7
solsword/enfreakment-study
/data/ethnicities.py
1,234
3.78125
4
#!/usr/bin/env python3 """ multiethnic.py Processes ethnicities list to determine distribution of multiple ethnicities. """ import sys multi = 0 single = 0 semi_equal = { "White": [ "American", "European" ], "Hispanic": [ "Latinx" ] } counts = {} multi_counts = {} for line in sys.stdin.readlines(): bits = li...
144e54ba2157096c8d6e9076129d00022ad1bd93
Dgustavino/Taller_01-Python
/python_1.py
1,103
4.59375
5
""" EJERCIO 1: EJERCIO 2: """ lista_nombres = [ 'nombre1', # this is list 'nombre2' ] lista_apellidos = ('apell1', 'apell2') # this is tuplet # imprimo los ejemplos de la parte superior print(lista_nombres) print(lista_apellidos) # ejemplos de la estructurada de datos set() set1 = {12345...
1b7126539ba4033b51bcf4993fc06b9e7b6b097b
TateStaples/AdvCompSciNotes
/Supervised/Tree.py
7,784
3.9375
4
import numpy as np class Tree: # https://machinelearningmastery.com/implement-decision-tree-algorithm-scratch-python/ def __init__(self, data, max_depth, metric="gini"): """ A decision regression tree implementation :param data: a 2-d list how data with the results at the end of each r...
8d38243308431625dc13861f95deba2c70b11c58
mustafaonal/python-converter
/2016510082.py
20,420
3.734375
4
# -*- coding: utf-8 -*- from lxml import etree #for xml validation from io import StringIO import xml.etree.ElementTree as ET #for convert xml to other file types import sys #for command line arguments import json #json file oparation import codecs #for utf-8 file read import xml.dom.minidom #only for prity print xml f...
b28ac175fdd5019bf9221dc3a82353604e01a3ad
IssacAX123/Matrices-Calculator
/home.py
2,145
3.5
4
from tkinter import * import main_classes class HomeLayout(main_classes.App): def __init__(self, windows): super().__init__(windows) self._window = windows self.__button_option_matrices_arithmetic = Button(self._windows, text='Matri...
af3b4f33a657953d9c201b8c99dcd852f4192156
bradpowles/PycharmProjects
/ALevel/Electioneering/electioneering.py
29,607
3.71875
4
import random import random_name import datetime class Region(list): # Region is a list filled with Voter def __init__(self): super(Region, self).__init__() self.name = random_name.region() # Region's name self.candidates = [] # List of all of the candidates that will ...
e7b3b13f3c0df1ba244bdadd79cb68fb31319c99
metamorph0s/python_L1
/l1q4.py
227
3.859375
4
num = int(input("введите целое положительное число ")) b = 0 if num > 0: while num != 0: a = num % 10 num = (num - a) / 10 if b < a: b = a print(b)
12cf1d355d35ebc17f49e41aebac25bfed7ea28f
surfascope/surfascope-docker
/notebooks/surfascope/gaussian/__init__.py
9,394
3.625
4
from math import ceil import numpy as np def chunkstring(string, length): string = string.rstrip('\n') return (string[0+i:length+i] for i in range(0, len(string), length)) def build_symmetric_matrix(values, dims): # assert len(values) == dims * (dims + 1) // 2 hessian = np.zeros((dims, dims)) l...
e2195d5b87593292b655fa6ee4395b5976948091
tanzim721/Python
/7 pattern matching.py
1,586
3.875
4
""" Name : Tanzimul Islam Roll : 180636 Session : 2017-18 E-mail : tanzimulislam799@gmail.com Blog : https://tanzim36.blogspot.com/ Dept.of ICE, Pabna University of Science and Technology """ #Problem-7: Write a program to find a given pattern from text using the first pattern matching algorithm ###### KMP Alg...
0823b6486c60bccbed17ff96778b88ec46a3d113
ScoltBr/PythonProjetos
/escopo_de_variaveis.py
990
4.40625
4
""" Escopo de variavel Dois casos de escopo: 1 - Variáveis globais: - Variáveis globais são reconhecidas, ou seja, seu escopos compreendem, todo a o programa. 2 - Variáveis locais: - Variáveis locais ~soa reconhecidas apenas no bloco onde foram declarades, ou seja, seu escopo esta limitado ao seu bloco on...
8034b3dcc454c0570bbf301ed92a7d9ee3100260
ScoltBr/PythonProjetos
/tipo_float.py
726
4.125
4
"""" Tipo float Tipo real, dicimal Casas decimais OBS: o separados de casas de cimais na programação é o ponto e não a virgula. [1.5F,0.9F,1.123F] """ # Errado do ponto de vista do Float, mas gera uma tupla from builtins import int valor = 1, 44 ...
e8e4be7c09c390665d09573dd3bb432e98ac113d
liziniu/CVAE
/pypr/preprocessing/lag_matrix.py
3,204
3.640625
4
import numpy as np def create_lag_matrix(F, lags): """ Create a matrix of sequences lagged 1 step. Parameters ---------- F : NxD np array A sequence (or time series) of data length N with D dimensions. lags : int Number of lags to create """ if isinstance(F, list) or F...
5ca7503d4cca1480f5e0ca972bd0521be6c98e2a
schoonhovenrichard/WISB256-Eindopdracht
/ElliptischeKrommen.py
3,575
3.890625
4
import math import fractions frac = fractions.Fraction class ElliptischeKromme(object): """ De Elliptischekromme class definieert een elliptische krommen en controleert of de meegegeven waarden kloppen. """ def __init__(self, a, b): self.a = a self.b = b self.check = -16 *...
4fef0fe6073ed1434cac428189387f8619c144fd
rakeshnetsil/Tcs_Codevita_coding_Problem_Question_with_Answer_Tech_Siddhar
/Chakravyuha.py
3,291
3.78125
4
""" Chakravyuha During the battle of Mahabharat, when Arjuna was far away in the battlefield, Guru Drona made a Chakravyuha formation of the Kaurava army to capture Yudhisthir Maharaj. Abhimanyu, young son of Arjuna was the only one amongst the remaining Pandava army who knew how to crack the Chakravyuha. He took it u...
704c4e45b509417a55f4de29b83bf7b696e38fd0
rakeshnetsil/Tcs_Codevita_coding_Problem_Question_with_Answer_Tech_Siddhar
/Securing_Financial_Transactions.py
3,631
4.21875
4
''' Problem : Securing Financial Transactions Statement: ABC Corporation's finance team wants to deal with each of their supplier's invoicing details in a more secured way. Between ABC's and their suppliers' finance systems, ABC wants to build its own encryption/decryption logic. ABC has a unique identifier for each ...
3f5ffcf5ef4ebdd7d82f9eea2dd876c0dfebf3d5
ksy9926/Daily-Leetcode
/Easy/Valid Parentheses/solution.py
1,058
3.796875
4
class Solution: def isValid(self, s: str) -> bool: stack = [] dic = {'}':'{', ']':'[', ')':'('} dicOpen = {'{', '[', '('} for a in s: if a in dicOpen: stack.append(a) else: if len(stack) != 0 and stack[-1] == dic[a]: ...
4b99df368f3bf0a024139f335697d4c5ce8d6ade
ksy9926/Daily-Leetcode
/Easy/Climbing Stairs/solution.py
554
3.59375
4
class Solution: def __init__(self): self.memo = {} def climbStairs(self, n: int) -> int: if n == 1: return 1 elif n == 2: return 2 if n in self.memo: return self.memo[n] self.memo[n] = self.climbStairs(n-1) + self.clim...
d8fb565e7a39ebb7a200514407b2ffb49e07b19d
adharmad/project-euler
/python/commonutils.py
2,794
4.34375
4
import functools from math import sqrt @functools.lru_cache(maxsize=128, typed=False) def isPrime(n): """ Checks if the number is prime """ # Return false if numbers are less than 2 if n < 2: return False # 2 is smallest prime if n == 2: return True # All even numbers ...
a1ce09d7ae4116208daab0908140f5d83d7391f6
ttiyemba/Python_Challenges
/ListofMultiples/list.py
171
4.125
4
def list_of_multiples(num,length): list = [] for i in range(1,length+1): list.append(num * i) return list print(list_of_multiples(12,10))
bf67f3fdf787652df32a6f9cc3cc4b9b02b81377
yssdnj/Python4DataAnalysis
/Assignment_2/Test/argparse_test.py
1,128
3.578125
4
import argparse import requests import twitter import json # from twitter import OAuth # from requests.auth import HTTPBasicAuth CONSUMER_KEY = 'Gfi9Gt4imoHDKNuhTqH0RvkJD' CONSUMER_SECRET = 'YU4ukWbn8ROr1JXph9HtiXCBWh96rY0LpedN5ny8t35pLvHcgd' ACCESS_TOKEN = '2865250744-BJcNzHyOeGcAyD8ImHyHItNPZS6Md4wXLMKyN4M' ACCESS_SE...
89e14c6ddca6695f0741bee1d68aa711ac901cbe
polyatcc/MathPython
/fibonacci.py
1,359
3.640625
4
import math fibConstFirst = (1.0 + math.sqrt(5)) / 2 fibConstSecond = (1.0 - math.sqrt(5)) / 2 def NthNumberFib(n): return int((math.pow(fibConstFirst, n) - math.pow(fibConstSecond, n)) / math.sqrt(5)) def fibonacci(f, a, b, eps): count = 0 v = 0 list = [] while (b - a) >= (eps ...
7c7cf5fb011bccb088c7b9b299b9124e15f19bed
zhannd/demo1
/helloworld/dict.py
532
3.515625
4
array1 = { "username": "pyuser1@exhr-14201dom.extest.microsoft.com", "receive_address": "user1@exhr-14201dom.extest.microsoft.com", "cc_address": "test1@exhr-14201dom.extest.microsoft.com", "subject": "111", "password": "T%nt0wn", "receive_password": "T%nt0wn", ...
215e2949bdbd4b3559688b288362ad52a20238a4
andy-shaw/sudoku_solver
/sudoku.py
6,760
3.765625
4
''' Author: Andy Shaw Date: 12/5/2013 This class represents a sudoku. The internal state will be a 2-dimensional array. 0's (zeros) are unresolved numbers. ''' emptyCharacters = [' ', 0, '-', '_'] class Block: '''Block of each sudoku element''' def __init__(self, number=None): self.number = number...
97fee167a426b404694914d45e69b493b6f07a72
patrebert/pynet_cert
/class9/ex8/mytest/world.py
885
4.15625
4
#!/bin/env python def func3(): print "world.py func3" class MyClass: def __init__(self,arg1, arg2, arg3): self.arg1 = arg1 self.arg2 = arg2 self.arg3 = arg3 def hello(self): print "hello" print " %s %s %s" %(self.arg1, self.arg2, self.arg3) def not_hello(self...
80401e52a7fdef7ae970c29514b3919f7c819f95
itm-dsc-tap-2020-1/practica-1-interfaz-grafica-con-tkinter-alondra-zarco
/examen.py
2,679
3.65625
4
import tkinter as Tk from tkinter import ttk from tkinter import Menu from tkinter import scrolledtext from tkinter import messagebox as mBox ventana=Tk.Tk() ventana.title("EXAMEN DE ETICA") #textos ttk.Label(ventana,text="1.¿Que es la etica?: \n").grid(column=0,row=0) ttk.Label(ventana,text="2.¿Quien es el denomin...
76d6dcca546b7d115bbb6d8d2ddfb263b48da8dd
jba91/machinelearning
/IrisPractice.py
1,709
4
4
import numpy as np from sklearn import neighbors from sklearn import datasets #Load Data #The class of each Iris observation is stored in the .target attribute iris = datasets.load_iris() allData = iris.data allTarget = iris.target # Data Division for each class of Iris # Concatenate - Join a sequence of a...
70532bf157d1dbf6fa9915bfb3093ce21cf40fc3
chenwuxing/Python
/context_manager.py
1,099
3.90625
4
""" 一个对象只要实现了__enter__()和__exit__()方法,那么它就是一个 上下文管理器,上下文管理器可以使用with关键字 """ class File(): def __init__(self,filename,mode): self.filename = filename self.mode = mode def __enter__(self): print("entering") self.f = open(self.filename,self.mode) return self.f def ...
c03b7f8cb750d3c56aa319058b268bb5cd1a59d8
chenwuxing/Python
/iteration.py
919
3.59375
4
class C_Range: def __init__(self,start,end,step): self.start = start self.end = end self.step = step def __iter__(self): return C_Range_Iteration(self.start,self.end,self.step,self.flag) class C_Range_Iteration: def __init__(self,start,end,step): self.start...
63df9154e3084da81d8dcd3077c1b6b96c59ce93
luisren64/Cs2302
/Lab3bst.py
4,667
3.984375
4
class BST(object): # Constructor def __init__(self, item, left=None, right=None): self.item = item self.left = left self.right = right def Insert(T,newItem): if T == None: T = BST(newItem) elif T.item > newItem: T.left = Insert(T....
d01aa9fe43df9438828ef0e35470db8484bda036
dojorio/dojo_niteroi
/2010/20100706_python_campo_minado/campo_minado.py
921
3.53125
4
class CampoMinado(object): def __init__(self, minas): linhas = minas.splitlines() campo = [] for linha in linhas: linha = linha.strip() if linha: linha = linha.replace('-', '0') lista_de_campo = [] for caracter in linha...
4f28c22df25b9c11e7a9ef92a9d890a47015bf29
dojorio/dojo_niteroi
/2011/20110915_python_conta_segundos/conta_segundos.py
2,989
3.65625
4
import unittest2 from datetime import datetime minutos_para_segundos = lambda x: x * 60 horas_para_segundos = lambda x: x * 3600 class DataTempo(datetime): def segundos_desde_1990(self): tempo = self.second tempo += minutos_para_segundos(self.minute) tempo += horas_para_segundos(self.hou...
c64fc01ff4cfaef177601ec4019767bee9d5eed4
dojorio/dojo_niteroi
/2010/20100929_python_unipli_fizzbuzz/fizzbuzz.py
435
3.640625
4
def diz_fizzbuzz(numero): retorno = '' if numero_e_divisivel_por_3(numero): retorno = 'fizz' if numero_e_divisivel_por_5(numero): retorno += 'buzz' if retorno_e_vazio(retorno): return numero return retorno def retorno_e_vazio(retorno): return not retorno def numero_e_div...
fdbd8fa5d1be522e8e99aa84ab10216be3fb248d
KavinduZoysa/artificial-intelligence
/samples/multi_processing1.py
1,401
3.671875
4
# import multiprocessing from multiprocessing import Pool from multiprocessing import Process import time import os # def square(x): # # calculate the square of the value of x # return x * x # # # if __name__ == '__main__': # # Define the dataset # dataset = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...
a6616d655928827da7494f19fa0b86f180bf25a0
victorsibanda/prime_numbers
/prime_number_exercise.py
759
4.0625
4
num = int(input ('what is the range you want to check')) # # if num > 1 : # for i in range(2,num+1): # if num % i != 0: # print (f'this is a prime Number {i}') # else: # print(f'This is not a prime number{i}') # # if num > 1: # # for i in range(2, num): # if (num...
af585b32390972bda748d9677bd24917b104221a
skanev/playground
/other/clrs/13/problems/03.py
2,935
3.640625
4
from collections import deque class Node: def __init__(self, key, height=-1, left=None, right=None): self.key = key self.height = height self.left = left self.right = right def __str__(self): def dump(node): if not node: return "NIL" ...
03e87351e441a3813ca61e4286f56c2d0f3c05ad
skanev/playground
/other/clrs/06/problems/01.py
1,893
3.71875
4
############################################################################## # DATA STRUCTURES ############################################################################## class heap: def __init__(self, items, size = None): self.items = items self.heap_size = size or len(items) def __getit...
641e3403d371db8872d1c4ea9aedd2d2fa781398
skanev/playground
/other/clrs/14/misc/order_statistic_tree.py
958
3.515625
4
from augmentable_tree import AugmentableTree def node_size(node): return node.size if node else 0 def select_node(node, i): while node: rank = node_size(node.left) + 1 if i == rank: return node elif i < rank: node = node.left else: i -= rank ...
3e12a14e07b03fd9443651c749f851ab8055d618
skanev/playground
/other/clrs/14/misc/augmentable_tree_test.py
7,973
3.640625
4
import unittest from augmentable_tree import AugmentableTree, Color import random class Interval: def __init__(self, low, high): assert low <= high self.low = low self.high = high def __eq__(self, other): return isinstance(other, Interval) and self.low == other.low and \ ...
e1c105bd09ce338aa885e1bb7c727fe092555e22
skanev/playground
/other/clrs/09/03/08.py
341
3.640625
4
def two_array_median(a, b): if len(a) == 1: return min(a[0], b[0]) m = median_index(len(a)) i = m + 1 if a[m] < b[m]: return two_array_median(a[-i:], b[:i]) else: return two_array_median(a[:i], b[-i:]) def median_index(n): if n % 2: return n // 2 else: ...
9685c28ad67b8de4ca711b0ff8498aa07c0423ff
fulv1o/Python-Basics
/Tipos de Dados/exemplo28.py
336
3.828125
4
""" Fúlvio Taroni Monteforte Aluno de engenharia de computação do CEFET-MG. """ """ Exercícios retirados da geek university Faça uma leitura de 3 valores e apresente o resultado como a soma do quadrado dos três valores lidos """ print("Informe 3 valores: ") a = float(input()) b = float(input()) c = float(input()) x...
c91b8e48ecbad7ba00b37bb95e73a846449f1872
fulv1o/Python-Basics
/Tipos de Dados/exemplo31.py
240
3.53125
4
""" Fúlvio Taroni Monteforte Aluno de engenharia de computação do CEFET-MG. """ """ Leia um número inteiro e imprima seu sucessor e seu antecessor """ i = int(input("Informe um número inteiro: ")) print(f'Sucessor: {i+1}') print(f'Antecessor: {i-1}')
a7dd3c9f9e3f5f22f860ad832a1d4f49d2c80d06
fulv1o/Python-Basics
/Tipos de Dados/exemplo11.py
259
3.96875
4
""" Fúlvio Taroni Monteforte Aluno de engenharia de computação do CEFET-MG. """ """ Exercícios retirados da geek university Leia uma velocidade em m/s e apresente-a convertida em km/h. """ v = float(input("Informe a velocidade em m/s: ")) v = v*3.6 print(f'{v:.2f}km/h')
72c5efc5591f46217303033a728e53da8286c6d1
fulv1o/Python-Basics
/Tipos de Dados/exemplo4.py
260
3.546875
4
""" Fúlvio Taroni Monteforte Aluno de engenharia de computação do CEFET-MG. """ """ Exercícios retirados da geek university Leia um número real e imprima o quadrado desse número """ x = float(input("Insira um número real: ")) print(f"O quadrado do número é: {x**2}")
88e02acbee4d81a81dc09735c293e01dbb1fe9c3
fulv1o/Python-Basics
/Tipos de Dados/exemplo10.py
259
3.828125
4
""" Fúlvio Taroni Monteforte Aluno de engenharia de computação do CEFET-MG. """ """ Exercícios retirados da geek university Leia uma velocidade em km/h e apresente-a convertida em m/s. """ v = float(input("Informe a velocidade em km/h: ")) v = v/3.6 print(f'{v:.2f}m/s')
90f9a7b5ee687bd03e814b76ecca8b04e54b5209
AlejandroL12/ej-base
/assignments/00HelloWorld/src/act-14 - EJ3.py
378
3.78125
4
def main(): #escribe tu código abajo de esta línea n=int(input('Total de datos a capturar: ')) lista =[] for i in range(n): dato = int(input('>>>')) lista.append(dato) print(lista) listacuadrados=[] for i in range(n): listacuadrados.append(lista[i]**2) print...
88dbefee7711f1c2c4c47447b3613348abdda510
Metamess/AdventOfCode
/2020/days/day9.py
2,206
3.984375
4
def part1(): """ XMAS starts by transmitting a preamble of 25 numbers. After that, each number you receive should be the sum of any two of the 25 immediately previous numbers. The two numbers will have different values, and there might be more than one such pair. Find the first number in the list (...
3a712380f44e0f4367daeb74bdc9820f437c54f6
Metamess/AdventOfCode
/2022/days/day12.py
3,860
4.09375
4
def part1(): """ A heightmap of the surrounding area is your puzzle input. Each square of the grid is given by a single lowercase letter, where a is the lowest elevation, b is the next-lowest, and so on up to the highest elevation, z. On the heightmap are marks for your current position (S) and the...
34452d1f3a05312e7adcc9a63ca583a8d32a673d
Metamess/AdventOfCode
/2019/days/day6.py
1,230
4.0625
4
def part1(): """ Except for the universal Center of Mass (COM), every object in space is in orbit around exactly one other object. In the map data, this orbital relationship is written AAA)BBB, which means "BBB is in orbit around AAA". What is the total number of direct and indirect orbits in your map data? """ ...
a3d9152af68a02561e8b678a5ed769495d0abf8d
Metamess/AdventOfCode
/2018/days/day10.py
2,372
3.5625
4
def part1(): """ Each line represents one point. What message will eventually appear in the sky? """ # Assumption: Points are aligned when point cloud area is smallest point_cloud = PointCloud() point_cloud.read_input() min_area = point_cloud.get_area() + 1 while True: new_area = point_cloud.get_area() if...
a8f4b7e86f5248e108bbf555bd7d85435140cf21
Metamess/AdventOfCode
/2020/days/day3.py
1,660
3.796875
4
from functools import reduce def part1(): """ Trees in this area only grow on exact integer coordinates in a grid. You make a map (your puzzle input) of the open squares (.) and trees (#) you can see. The same pattern repeats to the right Starting at the top-left corner of your map and following a...
8c3e4907e9d5dccd15ca5c1222ef335bb126a5ed
Metamess/AdventOfCode
/2018/days/day12.py
2,011
3.796875
4
def part1(): """ Your puzzle input contains a list of pots from 0 to the right, and whether they do (#) or do not (.) currently contain a plant, the initial state. For each generation of plants, a given pot has or does not have a plant based on whether that pot (and the two pots on either side of it) had a plant ...
253d3523ac283be24bdc7e91c3dc0411194baf35
Diego91RA/school_2020_examples
/test.py
380
3.6875
4
l = [1, 2, 3, 4, 5] print(l[1]) print(l[-1]) print(l[1:]) print(l[1:3]) print(l[1:4:2]) s = '1234567890' print(s[1]) print(s[2:]) print(s[-1]) print(s[2:8:3]) sl = list(s) print(sl) for i in s: print(i, end='') l.append(3) print(l) s = 'wertwe werwerwwe dfgdfgf dfghdhgfd' spl = s.split(' ') print(spl) ...
99f3bb24fd0cd97e101dd70883673da0952e93ad
jhelland/spring2017_activesubspaces-nnet
/theano/nnet_classes.py
17,914
3.546875
4
""" Theano integrated neural network layer classes for defining multi-layer perceptron models. """ ######################### # LIBRARIES ######################### from __future__ import print_function import numpy as np import theano import theano.tensor as T ######################### # CLASSES ###################...
0794b9807b557328433db9d54b2bf54f930831ee
RJL22/rosalind-bioinformatics
/src/prot.py
535
3.71875
4
# Translates a RNA sequence into a chain of amino acids #Read in data for rna codon table lines = [] with open("../res/rna-codon-table.txt") as f: lines = f.readlines() codon_table = {} for l in lines: line = l.rstrip('\n') codon_table[line[0:3]] = line[4:] #Get RNA sequence input sequence = "" with open("/PATH...
a62e4d8c7dac0fe1ef9b2a8c2d79cbb41acb7c2d
RicardoScofileld/MyCode
/tools/set.py
806
3.609375
4
import sys def combinations(iterable, r): '''从长度为n的列表中,获取长度为m的集合.python内置函数combinations,用来排列组合,抽样不放回''' pool = tuple(iterable) n = len(pool) if r > n: return '长度越界' indices = list(range(r)) yield tuple(pool[i] for i in indices) while True: for i in reversed(range(r)): ...
49cd394fcbcf46b98c3ccfb3ce150bb1d9108847
kirbysebastian/TicTacToe
/tic_tac_toe/tic_tac_toe.py
1,939
3.734375
4
from tic_tac_toe.board import Board from utils.utilities import clear, is_winner class TicTacToe: def __init__(self, player1, player2): self.game_over = False self.player_one = player1 self.player_two = player2 self.board = Board() def start(self): self.player_one.make_turn...
3c8252741b1c671257420f0c04fa4617f01603fb
kirbysebastian/TicTacToe
/play.py
2,171
3.59375
4
#!/usr/bin/python3 import sys from tic_tac_toe.player import Player, AI from tic_tac_toe.tic_tac_toe import TicTacToe from utils.utilities import clear def get_validated_inputs(): areValidInputs = False is_p1_valid = False is_p2_valid = False while not areValidInputs: if not is_p1_valid: ...
7b5c452adcf134dde99e2acbe49bd78d0aef5cfb
devlanguage/Python
/pythonhello/logical/ifelse.py
829
3.703125
4
''' Created on Feb 9, 2018 @author: gongyo ''' pass print 'test if-elif-else' a = 1 if(a < 0): print "Negative" elif (a == 0): print "zero" else: print "Positive" print 'while-for' a = 0 while a < 3: a += 1 print ("a=" + str(a)); # TypeError: cannot concatenate 'str' and 'int' objects for ...
ea44b12e1aeed172f3e4584a702d0987256ca0c6
Benaca/Python
/ledRGBarduino.py
1,824
3.625
4
""" Lee información de Arduino mediante USB En un circuito con 3 potenciómetros R:A0 G:A1 B:A2, lee los valores analógicos de las entradas y los almacena en el diccionario "colores" Luego usa estos valores para controlar un led RGB conectado a los GPIO R:18 G:23 B:24 """ #!usr/bin/env/ python # -*- cod...
f334448bc5a0d99aaae55f3a8e2b0445fa0df4f9
CCOMJHC/control_by_web_x4xx_interface
/refs/test_parse_relays.py
4,323
3.515625
4
#!/usr/bin/env python import math def make_test_dataset(): relays = dict() analogInputs = dict() relays['posmvRelay'] = False relays['em2040Relay'] = True relays['stormRelay'] = False relays['jet2PwrButtonRelay'] = True relays['aisRelay'] = False analogInputs['posmvAmps'] = 1.1 ...
ff289ebb78de5b82e79a7752846a90d8b9af0c5c
RunningShoes/python_lianxice
/5/5.py
213
3.78125
4
filepath='5.txt' letter=[] str='' with open(filepath) as file: f=file.readline() for line in f: str+=line print(str) letter=str.split(' ') for word in letter: print(word) print(len(letter))
e8030538ed47172940dc27aaf582f3dc5304b9e4
rahulraikwar00/DSA
/Python/CSPFiltering.py
7,399
3.546875
4
from random import shuffle import time from itertools import permutations # Defining vetex class of graph class Vertex: def __init__(self, key): self.id = key self.connection = {} def __str__(self): return str(self.id) + ' connected to: ' + str([x for x in self.connection]) # defining Graph for the problme...
5c4d20dce361949b799f45090bf82ed56896c9f7
JRice15/relativism
/src/path.py
1,754
3.890625
4
""" path object for handling paths """ import re def join_path(*args, is_dir=False, ext=None): """ join *args strings into a path """ path = "/".join(args) if is_dir: assert ext is None path += "/" if ext is not None: path += "." + ext path = re.sub(r"//", "/", p...
5a018140482884591fdf907988ec76c65f2b0936
OscarSierra24/Exercises
/Strings/delete_dups.py
1,486
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 3 23:37:03 2019 @author: oscar """ class Node: def __init__(self, value): self.value = value self.next = None class ll: def __init__(self): self.head = None self.tail = None def insert(self, value):...
d2df58a23ff97cfd39cce62d734d9c45198f1f21
OscarSierra24/Exercises
/Strings/URLify.py
689
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 7 13:59:18 2019 @author: oscar """ def urlify(string, last_char_index): string = list(string) new_char_pos = len(string) - 1 last_char_index-=1 for i in range(last_char_index, -1, -1): if string[i] == " ": ...
8774b4bcb13514d84b8f803be523a4b84a6d9b62
OscarSierra24/Exercises
/Miscelaneous/reverse.py
272
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 10 12:35:36 2018 @author: oscar """ "reverses a string ej. Oscar Sierra becomes arreiS racsO" def reverse(string): if len(string) == 0: return "" return string[-1] + reverse(string[0:len(string)-1])
68485eefd39cbb8ac95a3d39dec868f55c4f3c33
OscarSierra24/Exercises
/Miscelaneous/anagram.py
601
3.765625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 10 10:14:13 2018 @author: oscar """ #Checks if a string is anagram of another def anagram(string_a, string_b): dict = {} for el in string_a.lower(): if el in dict: dict[el] += 1 else: dict[el] = 1 fo...
247420f7215c1a370b8492c92df7bf4830a06b8c
mmiakashs/CSSD-Workshop
/src/day_one/euler_task_14.py
657
3.65625
4
cache_result={} def cal_chain_length(n): if(n==1): return 1 elif(n in cache_result): return cache_result[n] if n%2==0: cache_result[n] = cal_chain_length(n//2)+1 else: cache_result[n] = cal_chain_length(3*n+1) + 1 return cache_result[n] num=int(1e6) max_chain_lengt...
96de7caab2ee2c486df92f38a6b207376173bc01
jackyxugz/myshop
/coupons/tests.py
814
4.28125
4
class Cat: """定义一个猫类""" def __init__(self, new_name, new_age): """在创建完对象之后 会自动调用, 它完成对象的初始化的功能""" self.name = new_name self.age = new_age # 它是一个对象中的属性,在对象中存储,即只要这个对象还存在,那么这个变量就可以使用 def __str__(self): """返回一个对象的描述信息""" return "名字是:%s , 年龄是:%d" % (self.name, self.age...
e1bf47c489290d370447510efeca42966064d034
abhay-rana/python-tutorials.
/DATA STRUCTURE AND ALGORITHMS/LINEAR_SEARCH.py
404
3.84375
4
#LINEAR SEARS JUST SIMPLY A SEARCH OF PARTICULAR ELEMT IN A SORTED OR A UNSORTED LIST pos=-1 def linear_search(arr,x): for e in range(len(arr)): if arr[e]==x: globals()["pos"]=e+1 return True else: return False arr=[5,62,7,12,36,582,1] x=7 result=linear_search(arr,x) i...
34b4d136592ac3d414a64de49fdc9bf26c34918a
abhay-rana/python-tutorials.
/DATA STRUCTURE AND ALGORITHMS/RECURRSION AND BACKTRACKING/RAT IN A MAZE NO. OF WAYS.py
811
3.890625
4
def move(maze,n,x,y,sol): if x>=n or y>=n or y<0 or x<0 : #when i have not incuded myself return False if x==n-1 and y==n-1: #base case for the recurrsion sol[x][y]=1 #cahnging the goal/destination to 1 for e in sol: print(e) print() return True ...
6406b4de6b9cb989191bd5572c4f183394d3a935
abhay-rana/python-tutorials.
/hackerrank-competetive questions/STRING Q AND A 1.py
344
3.984375
4
#ACCEPT two int values from the user and return there products . if th eproduct is greater than 1000 #then return there sum.. def add(x,y): return x+y def products(x,y): if x*y>1000: return add(x,y) else: return x*y a=int(input("enter the first value")) b=int(input("enter the second value"...
d95f953d4922215b7c3496c99ca1186333e71719
abhay-rana/python-tutorials.
/python tutorials/FACTORIAL_OF _A _NUMBER.py
311
3.96875
4
#factorial of a number using recurrsion def facto(n): if n==1: return 1 else: return n*facto(n-1) x=int(input("")) print(facto(x)) ## factorial of a number without recurrsion n=int(input("enter")) fact=1 while(n>0): #till the condition is true fact=fact*n n=n-1 print(fact)
4e046d1824d1afdf08b05e4925c8ce29f44fa2e8
abhay-rana/python-tutorials.
/hackerrank-competetive questions/FACTORIAL_SOLUITON.py
598
3.515625
4
from math import * n=int(input("enter the test cases")) l=[int(x) for x in input().split()] print(l) l1=[] for e in l: l1.append(factorial(e)) print(l1) l2=list(map(str,l1)) print(l2) l3=[] for e in l2: x=len(e) s=0 for i in range(x): s=s+int(e[i]) l3.append(s) print(l3) # # from math impo...
779d06833f0b30281c71242196a77f9ff08ce094
abhay-rana/python-tutorials.
/DATA STRUCTURE AND ALGORITHMS/INSERRTION_ SORT.py
397
4.15625
4
#INSERTION SORT IS SIMILAR TO E WE PLAYING CARDS # THE WAY WE SORT THE CARDS def insertion_sort(arr): for e in range(1,len(arr)): temp=arr[e] j=e-1 while j>=0 and temp<arr[j]: arr[j+1]=arr[j] # we are forwarding the elements j=j-1 else: arr[j...
9dbe4d07300a19cc83c37433810a5471fdd54071
abhay-rana/python-tutorials.
/DATA STRUCTURE AND ALGORITHMS/RECURRSION AND BACKTRACKING/N QUEEN;S PROBLEM.py
1,467
3.84375
4
# N QUEEN P4ROBLEM N IS ENTER BY THE USER global n n=4 def printsolution(board): for i in range(n): for e in range(n): print(board[i][e],end=" ") print() # A utility function(issafe) to check if a queen can # be placed on board[row][col]. Note that this # function is called when "col" q...
22fb7a49d135de70385c096411bc055aa2d6fea3
shreyadalmia/lab1
/task2.py
128
3.921875
4
name = input("what is your name ? ") age = input("what is your age ?") year = input("birth year") x = 100 + int(year) print(x)
81a5287af3ec7e30896bb87b5d603fedd9c3aa2b
mnhan32/productionUtils
/WIP/exportEveryOtherFrameList.py
1,412
3.578125
4
import tkFileDialog from Tkinter import * import os def browse_button(): # Allow user to select a directory and store it in global var # called folder_path global folder_path filename = tkFileDialog.askdirectory() folder_path.set(filename) print(filename) def writeF(e1, e2): global folder_...
6cc03c6e49891cacfa4ff2824caf9718994e1811
Avinint/Python_musicfiles
/timeitchallenge.py
1,006
4.375
4
# In the section on Functions, we looked at 2 different ways to calculate the factorial # of a number. We used an iterative approach, and also used a recursive function. # # This challenge is to use the timeit module to see which performs better. # # The two functions appear below. # # Hint: change the number of itera...
2595115c144e69d5c0066fcf68ab00455cb0d1ee
syntaxaire/CheckiO
/Home/median.py
1,014
4.0625
4
""" A median is a numerical value separating the upper half of a sorted array of numbers from the lower half. In a list where there are an odd number of entities, the median is the number found in the middle of the array. If the array contains an even number of entities, then there is no single middle value, instead t...
f348334cc86f5d86e66be05fa2aaaab5da2460c6
cyrus-raitava/SOFTENG_364
/ASSIGNMENT_2/SOLUTIONS/checksum.py
1,406
4.125
4
# -*- coding: utf-8 -*- def hextet_complement(num): ''' Internet Checksum of a bytes array. Further reading: 1. https://tools.ietf.org/html/rfc1071 2. http://www.netfor2.com/checksum.html ''' # Create bitmask to help calculate one's complement mask = 0xffff # Use th...
89541a3beb74b1ebf0daf800f5c461bffa000453
pjot/calendar
/config.py
1,271
3.984375
4
''' Module that simplifies storing and reading values from a config file ''' import os import pickle class Config(object): ''' Class that simplifies storing and reading values from a config file ''' def __init__(self, config_path): ''' Create a new Config object using the supplied path...
b44f41cacafcd1f58438638191a274721f33aa5e
kujirahand/book-mlearn-gyomu
/src/ch5/recog/cifar10-cnn.py
2,096
3.515625
4
import matplotlib.pyplot as plt import keras from keras.datasets import cifar10 from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Conv2D, MaxPooling2D num_classes = 10 im_rows = 32 im_cols = 32 in_shape = (im_rows, im_cols, 3) # データを読み込む --- (*1)...
de8a5d5c0f8b47deba04fb0d5f579a81ff92d00f
LiliBag/prime_checker_PYTHON
/main.py
358
4.09375
4
#written by Lili Bagramyan def prime_checker(number): prime=True for i in range(2,number): if number%i==0: prime=False if prime: return (print("Prime number!")) else: return (print("NOT a prime number!")) numToCheck = int(input("I will check for you if number is prime or not. Please enter the...
b956d18eccc66908b1ff7fd7aa292009c6de8ec5
Loganbart/SLIOTGEAN.github.io
/triinsertion.py
496
3.78125
4
import time import random maxVal =10 nVal = 5 listeNombres = random.choices(range(maxVal),k=nVal) def triSelection(L: list)-> list: """ A compléter """ return # A compléter def triInsertion(L: list)-> list: t1 = time.time() compteur = 0 print(L) n = len(L) for i in range(1,n): ...
cfd0d212f68d0be4b2caca1cf3df6c5a7ce645c5
toasterbob/review
/Object_Oriented/polymorphism.py
1,195
4.1875
4
# Polymorphism class Animal: name = "" location = "" def __init__(self, name, location): self.name = name self.location = location def talk(self): pass def move(self): pass def breathe(self): pass class Bird(Animal): def talk(self): print...
3d3081b530ee0c4770f456fbcda2707e8d647b35
h-bekker/Kurs3
/Kurs 3/python3/TrianglesCmp.py
807
3.734375
4
class Triangle: def __init__(self, k1, k2, k3): self.k1 = k1 self.k2 = k2 self.k3 = k3 def __repr__(self): return "{:.1f}:{:.1f}:{:.1f}".format(self.k1, self.k2, self.k3) def __ge__(self, other): if abs(self) >= abs(other): return True; else: return False; def __gt__(self, other): if abs(self) >...
0ded4e989991f80d5100cf8fb3ad1baaa26358f7
h-bekker/Kurs3
/Kurs 3/python3/andor.py
183
3.765625
4
... a = eval(input()) b = eval(input()) if a: print(a) elif b: print(b) else: print("NO") ... a = eval(input()) b = eval(input()) if (a or b) : print(a or b) else : print("NO")
0a43e2d9fd454a07d02bb6733a9bf2470413c49a
GamesCrafters/GamesmanWeb
/PythonPuzzles/Rubik.py
12,625
3.8125
4
from Puzzle import * import string # 11022480 #Level 0 : 1 | #Level 1 : 9 | 9 #Level 2 : 54 | 6 #Level 3 : 321 | 5.94 #Level 4 : 1847 | 5.75 #Level 5 : 9992 | 5.41 #Level 6 : 50135 | 5.01 #Level 7 : 227510 | 4.53 #Level 8 : 869715 | 3.82 #Level 9 : 1885639 | 2.16 class Rubik(Puzzle): ...
b99d163b6479e46eba3f71d840f4521093bbc211
GamesCrafters/GamesmanWeb
/PythonPuzzles/sym/LOSym.py
5,225
3.75
4
from Puzzle import * from math import sqrt import copy import string class LO(Puzzle): """This is the Lights Out puzzle class""" def __init__(self, board): #size = side length 1, 2, 3, etc... len = board.__len__() size = sqrt(board.__len__()) ...
88054a2efeb96207a077270aafc9aa59fd3a66f9
SHyoJun/Python_practice_5
/test5.py
955
3.5
4
# Q1 class Calculator: def __init__(self): self.value = 0 def add(self, val): self.value += val class UpgradeCalculator(Calculator): def minus(self,val): self.value -= val cal = UpgradeCalculator() cal.add(10) cal.minus(7) print(cal.value) # Q2 class MaxLimitCalculator(Calculator)...
72351a935a6f1d76c6cad057777189a79b9b526e
AndreiKorzhun/Stepik
/Программирование на Python/1/matrix._elem.py
886
3.78125
4
# create a matrix matrix = [] # start the loop until the user enters the word 'end' while True: # asks the user for the values of the matrix row = input().split() if row == ['end']: break # add the entered values to the matrix and return integers matrix.append(list(map(int, row))) # matrix...
00fe9e58faba71157d8d35599ee4315dc82ed454
AndreiKorzhun/Stepik
/Программирование на Python/7/spelling.py
441
3.84375
4
# number of known words d = int(input()) # put known words in the list lst_d = [i.lower() for _ in range(d) for i in input().split()] # the number of lines of text to check w = int(input()) # lines of text lst_l = [i.lower() for _ in range(w) for i in input().split()] # set of wrong words mist = set() # chech lines o...
6532f4059f84ce064099c049ad5fe0ece187f8fa
sriladda/practice
/python/arrays/triplet_sum.py
766
3.984375
4
#http://www.geeksforgeeks.org/find-a-triplet-that-sum-to-a-given-value/ #!/usr/bin/python def tripletSum(x, a): for first_element in range(0, len(a) - 2): left = first_element + 1 right = len(a) -1 while( left < right): if ( (a[first_element] + a[left] + a[right]) == ...
ae21c061854b509f7e92bce6821b2eb09951df5d
LucasWarner/ISC4U_CULM
/Main/MonthlySchedule.py
4,557
3.828125
4
# ------------------------------------------------------------------------------- # Name: MonthlySchedule.py # Purpose: File to create and display the monthly schedule # Author: Warner.Lucas, McKeen.Kaden # # Created: 13/04/2018 # ---------------------------------------------------...
82b50126fd52145f1d863a61ca57c592bf13b297
carlosflrslpfi/CS2-A
/class-08/scope.py
1,521
4.21875
4
# Global and local scope # The place where the binding of a variable is valid. # Global variable that can be seen and used everywhere in your program # Local variable that is only seen/used locally. # Local analogous to within a function. # we define a global variable x x = 5 def some_function(): x = 10 # local v...
06ff4726e12ca391f97d27f966edfe8eb7ded0d6
carlosflrslpfi/CS2-A
/class-09/quiz3.py
847
3.984375
4
# Fill out the functions below so that they behave as expected def example(x): """ >>> example('hello') 'HELLO' """ print(x.upper()) def one(objects, word): """ >>> fruits = ['oranges', 'apples', 'pineapples'] >>> one(fruits, 'like') I like oranges I like apples I like pine...
caaff2f169ba68f157eaccfc6869ce96165a58d0
bmenrigh/gofirstdice
/kryger_perm_counting/kryger_perm_counting.py
6,400
3.65625
4
#!/usr/bin/env python3 # Kryger Permutation Counting # # Algorithm developed by Landon Kryger, May 2012 dice = 'abcdeecdabdbaececdabbecdadbcaeacbdeecdabbeacdeabdcdacebbacdedcaebacbdeabcdeedcbaedbcabeacdedcabbecadcdbaedcaebbadceedbcaeacbdadcebbadceceabdbadceedcba' perms = {'': 1} # A dictionary tracking the counts fo...