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
e31b7e03f72fbcd099fcd6965a73a90b2b6528ea
mironmiron3/SoftuniPythonFundamentals
/TypesandVariableswithTextProcessing/CharsToString.py
194
3.984375
4
result = "" first_character = input() result += first_character second_character = input() result += second_character third_character = input() result += third_character print(result)
ce4ce5203f0ba2e38879cf40ef181162bbf422e0
mironmiron3/SoftuniPythonFundamentals
/TypesandVariableswithTextProcessing/EmoticonFinder.py
122
3.828125
4
text = input() for index in range(len(text)): if text[index] == ":": print(f"{text[index]}{text[index+1]}")
d14fc45b9cbfd6fc6e95073b5d3079493295bbd4
mironmiron3/SoftuniPythonFundamentals
/SoftUniExamResults.py
1,061
3.71875
4
data = input() contestants = {} submissions = {} while not data == "exam finished": data = data.split("-") if data[1] not in submissions and data[1] != "banned": submissions[data[1]] = 0 if data[1] != "banned": submissions[data[1]] += 1 if data[0] not in contestants: co...
563fcba0b41b18cdf85b43019048bd2961674dc8
mironmiron3/SoftuniPythonFundamentals
/FunctionsBasics/PerfectNumber.py
313
3.6875
4
def check_if_perfect_number(num): sum = 0 for i in range(1, num): if num % i == 0: sum += i if sum == num: return "We have a perfect number!" else: return "It's not so perfect." a = int(input()) outcome = check_if_perfect_number(a) print(outcome)
607a1b260c5e355ff9afd116bc46c019760bb819
mironmiron3/SoftuniPythonFundamentals
/TypesandVariableswithTextProcessing/WaterOverflow.py
250
3.609375
4
n = int(input()) liters_in_tank = 0 for i in range (n): pour = int(input()) if pour > (255 - liters_in_tank): print("Insufficient capacity!") continue liters_in_tank += pour print(f"{liters_in_tank:.0f}")
342ddaaefc25ae2d2aa4d8ee9b4eb59cfd26a7fb
liangtrevor/Daily-Report-Automation
/main.py
1,307
3.625
4
# main file # version 2.6.2 of OpenPyXL # to install: >>> pip install openpyxl==2.6.2 import openpyxl from datetime import date def passthrough(pos_report, report, precip, temphigh, passnumber, date): print("\nStarting pass " + str(passnumber) + " ... ") # pos report sheet is active by default (just for test...
aea8035a7060b884c50a236ac5bc53a7f1b85c4b
giovannyortegon/TheSecuritySentinel
/SEM1/fraud_detection
1,107
3.59375
4
#!/usr/bin/env python3 import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score, confusion_matrix # Read in the data from the CSV file df = pd.read_csv('payment_fraud.csv') print(df.sample(3)) # Convert ca...
a3de1bbed0bd9ec054b0c4b9de327b8b2ff58c64
mjeedelamen/PythonExamples
/pythonics/zip_example.py
858
3.90625
4
# ZIP lst1 = [1, 2, 3, 4, 5, 6] lst2 = [6, 5, 4, 3, 2, 1] # build lst3: lst3[i] = lst1[i] + lst2[i] # Old way lst3 = [] for i in range(len(lst1)): lst3.append(lst1[i] + lst2[i]) print(lst3) # Using ZIP lst3 = [] for i, j in zip(lst1, lst2): lst3.append(i + j) print(lst3) # Not the same length lst1 = [1, 2, 3...
1bd8342305b3ed213d1bbc55fee658b54ed7d959
mjeedelamen/PythonExamples
/pythonics/map_example.py
470
4.03125
4
# MAP lst1 = [1, 2, 3, 4, 5, 6] # + 1 lst2 = [] for i in lst1: lst2.append(i + 1) print(lst2) # Using map def add_1(x): return x + 1 lst2 = [] for i in lst1: lst2.append(add_1(i)) print(lst2) lst3 = list(map(add_1, lst1)) print(lst3) # Power example def power(x): return x*x lst4 = list(map(power,...
c6eed1ed72ea86f52a059656ef0e0db6bee0fce6
mjeedelamen/PythonExamples
/pythonics/json/json_example.py
427
3.515625
4
import json # Reading json file file_path = "example.json" fd = open(file_path) content = json.load(fd) fd.close() print(content) # Writing json file data = {"Name": "Saeed", "Family": "Isa", "Job desc": "SW Eng", "Grades": [100, 88, 98], "Address": {"Street": "Ebn roshd", ...
a63e80091e661ee6592c2bb2fdc9565acd45009b
Chubek/CodingChallenges
/InsertionSort/Program.py
419
4.0625
4
def SwapList(myList, element1, element2): temp = myList[element1]; myList[element1] = myList[element2]; myList[element2] = temp; def InsertionSort(): myList = [3, 42, 235, 223, 221, 11, 123, 21, 1]; for i in range(1, len(myList)): j = i; while (j > 0 and (myList[j] < myList[j-1])):...
5f31027bfac53495b1493c3cd09a95473b7490c5
Chubek/CodingChallenges
/CeasarsCipher/Program.py
432
3.65625
4
def cipher(direction, shift, text): text_split = list(text) text_split = [ord(i) for i in text_split] text_shift = [str(i+(direction*shift)) for i in text_split] return str.join(',', text_shift) def decipher(direction, shift, text): text_split = str.split(text, ',') print(text_split) ...
a0a3248e7323344bc6e88fdc5e37846116c718bd
ntamurejocolorado/LearningPython
/QT5/QMessageBoxPython.py
1,540
3.703125
4
print("Show message box in qt") import sys from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox from PyQt5.QtGui import QIcon from PyQt5.QtCore import pyqtSlot class Aplication(QWidget): def __init__(self): super().__init__() self.title = 'PyQt5 messageBox' self.lef...
4476da4e6ddf335e315d84e7a1acf83e09313575
tfnribeiro/RomanNumeralConverter
/RomanConverter.py
4,133
3.75
4
import sys from random import randint import time import pickle import os.path from os import path def convertToRoman(num): roman_num = { 1 : "I", 5 : "V", 10 : "X", 50 : "L", 100 : "C", 500 : "D", 1000 : "M", } # The system can be looked at...
4eb969bc61a04c973cc2a73636f2dce3a55209d3
RaspberryCheesecake/airport-novel-name-generator
/airport_novel_titles_generator.py
1,085
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 04 12:37:19 2016 @author: CAMHW5 """ import random def read_from_file_to_list(filename): words_list = [] file_to_open = open(filename) for line in file_to_open: word = line.strip() words_list.append(word) return words_list def airport...
e48680fc8740e24358dba1fb11ba772450d9f0bb
NewAlice/python-code
/exceptions/raiseException2.py
421
3.96875
4
def main(): try: #fh = open('file1.txt') for line in readfile('filex.doc'): print(line.strip()) except IOError as e: print('cannot read file: ', e) except ValueError as e: print('wrong file extension: ', e) def readfile(filename): if filename.endswith('.txt'): fh = open(filename...
0e1f9cc810712147cf7f4a7086b764bd58615d49
DenysKaliuzhnyi/CppUnivLabs
/ACS-Lab-2/acs.py
3,508
3.5625
4
""" Denis Kaliuzhnui K-23, var 3.7.17 """ """ IMPORTANT: press "enter" on a keyboard to go to the next tact, each command has 2 tacts """ register_size = 24 byte_size = 8 Memory = { 'IR': ' ', # string of current command 'R1': 0, # registers... 'R2': 0, 'R3'...
d00d88ddcc4c6e2e9c7821c947a377bce3410b58
salarsf/SFsubtitleFixer
/SubtitleFixer.py
721
3.734375
4
import os def fix_encode(file_path:str): """ This function gets the subtitle file path, check if the file format is supported, and then opens the file in windows-1256 encoding and then creates a new file with utf-8 format """ name, ext = os.path.splitext(file_path) if ext != ".srt": raise Typ...
6ffc7f167844c394632e906658ec47a6bffcbbad
Siddiqui-code/Lab-Assignment-9
/Problem1Infinite.py
391
4.09375
4
# Nousheen Siddiqui # 03/11/2021 # An infinite loop that prints “Infinite”. An infinite loop never ends. The condition is always true. #for x in "Infinite": #print("Infinite") #x = 0 #while x < 5: #x += 1 #print(x) ##This while loop will run 5 times, as eventually x + 1 will equal to 5 and the ...
878c02d7e4d66d94fccc17f36525eb204fc5301b
TonyPeng2003/chapter3
/w7/h/dinner_guests.py
2,125
3.921875
4
name=['Tommy','Livia','Lisa','Peter'] print(len(name)) print("You are my best friend, would you like to have dinner with me, "+name[0]+" ?") print("You are my best friend, would you like to have dinner with me, "+name[1]+" ?") print("You are my best friend, would you like to have dinner with me, "+name[2]+" ?") print(...
d91c2649a3e614860af0db91befc21ef2b4511e9
TonyPeng2003/chapter3
/homework/numbers.py
526
4
4
for number in range(1,20): print(number) for number in range(1,10000): print(number) numbers= [] for number in range(1,10000): numbers.append(number) print(str(min(numbers))+" and " +str(max(numbers))) print(str(sum(numbers))) for number in range(1,20,2): print(number) numbers= [] for number in ...
cd80e67db583e02c80878c8dab5f3d8993548290
ppalex/projet_3_aidez_mac_gyver
/Model/board.py
367
3.75
4
class Cell(): WIDTH_PX = 30 HEIGHT_PX = 30 def __init__(self, x, y): """Constructor of class Cell. Arguments: x {int} -- Abscissa coordinate of the cell. y {int} -- Ordinate coordinate of the cell. """ self.width_px, self.height_px = self.WIDTH_PX...
6fe552cf022f9b89b130a2453c63bb3a79a89962
gurnit1/Python_Projects
/Daily Programmer/Maybe_Numeric.py
394
3.90625
4
# Subreddit Daily Programmer Challenge 262: # https://www.reddit.com/r/dailyprogrammer/comments/4eaeff/20160411_challenge_262_easy_maybenumeric/ def numeric_or_string(val): try: num = float(val) numeric = isinstance(num, float) if numeric: print "number" except Exception: ...
f271a09536e44020e4e771ea900e08d0ffbb752f
mkmad/ctci
/ctci/trees_graphs/build_order.py
1,463
3.6875
4
''' So, store the dependency list like this (a, d), (f, b), (b, d), (f, a), (d, c) project -> depends on a -> f b -> f c -> d d -> a, b e -> f -> ''' projects = ['a', 'b', 'c', 'd', 'e', 'f'] deps = [('a', 'd'), ('f', 'b'), ('b', 'd'), ('f', 'a'), ('d', 'c')] class build(object): def __init__(self): ...
36852494e85192b2a74e93c7ac805c5cf7734959
mkmad/ctci
/ctci/math/powerset.py
647
3.53125
4
# There are four subsets of the set {a1,a2} : {}, {a1},{a2),{a1, a2} # Note : {a1, a2} is the same as {a2, a1} import copy inp = (4, 5, 6) def power_set(input): if input: temp = copy.deepcopy(input) for val in inp: for sub_val in input: if val not in sub_val: ...
15aa99fe17ff8d1084436987787c127886e01d25
urstkj/Python
/decorator/simpledecorator_new.py
1,246
3.6875
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- from random import randrange def show_call_and_return_details(f): def execute_augmented(x, y): call_string = "{}({}, {})".format(f.__name__, x, y) print(">>> Calling " + call_string) result = f(x, y) print("<<< Returning {} from ".form...
67324962750acf3afd6ed1fee6f1d4f4afeaef17
urstkj/Python
/app/findfactors.py
393
3.84375
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import os n = 1 if len(os.sys.argv) <= 1: print("usage: findfactors <num>") exit() MAX = int(os.sys.argv[1]) print "Find all factors of number from 1 to ", MAX while n <= MAX: factor = 1 print str(n) + ": ", while factor <= n: if n % factor =...
b94372da460ed16903985e36cbeee5ae52ec6be9
urstkj/Python
/math/factors.py
886
4.03125
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- def factors(n): results = [] for k in range(1, n + 1): if n % k == 0: results.append(k) return results def factors_generator(n): for k in range(1, n + 1): if n % k == 0: yield k def factors_improved(n): k = 1 ...
566a0c80b8c9c75367cacb2b654f24746672436c
urstkj/Python
/data_structure/funs.py
1,143
3.765625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import math from io import StringIO def isSorted(data): for i in range(1, len(data)): if data[i - 1] > data[i]: return False return True def isHeap(data, index): l = index * 2 + 1 r = l + 1 if l < len(data): if data[index] < data[l]: ...
fc8f710a881f74f7bf2cfc65a6c00ecccd939dfe
urstkj/Python
/thread/thread.py
1,484
4.125
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import _thread import threading import time # Define a function for the thread def print_time(threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print("%s: %s" % (threadName, time.ctime(time.time()))) # Create two...
ec206cabbed38e21c3f7735de961ecb25201e25f
urstkj/Python
/data_structure/graph.py
3,906
3.515625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- class graph: def __init__(self, gdict=None): if gdict is None: gdict = [] self.gdict = gdict # Get the keys of the dictionary def getVertices(self): return list(self.gdict.keys()) # Create the dictionary with graph elements g...
c09d5b979322dc5048316f78cf219c62f2c4026c
urstkj/Python
/data_type/set.py
1,218
3.828125
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import random as random Days = set(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]) Months = {"Jan", "Feb", "Mar"} Dates = {21, 22, 17} print(Days) print(Months) print(Dates) Days = set(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]) for d in Days: print(d) D...
cb42297069ea0f56adf016b621def4a6fc303455
urstkj/Python
/function/scope.py
618
3.8125
4
#!/usr/local/bin/python print "demo..." x = 1 def f(): global x x += 1 print x f() print "demo1..." def t(l = []): print "fun: l: %s" % l l.append('hi') return l print t() print t() print "demo2..." def fun(l = None): print "fun: l: %s" % l if l == None: l = [] l.app...
d399448811cfb85d4f53cdbf874dd38eb79ba0a3
urstkj/Python
/oop/property.py
638
3.5625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- class Student(object): @property def birth(self): return self._birth @birth.setter def birth(self, value): self._birth = value @property def age(self): return 2015 - self._birth class Screen(object): @property d...
6612037547152a3a8954a9639dbb0eb2eac7e5a4
urstkj/Python
/math/fabonacci.py
878
3.828125
4
#!/usr/local/bin/python3 #-*- coding: utf-8 -*- def fab(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a + b n += 1 def fab2(max): n, a, b = 0, 0, 1 l = [] while n < max: l.append(b) a, b = b, a + b n += 1 return l class Fab: def ...
146be61dd823fe1e8c1f4be10bd7d6a79c679b44
urstkj/Python
/operator/operator_methods.py
557
3.734375
4
#!/usr/local/bin/python class A: def __init__(self, index, num): self.data = [0 for _ in range(10)] self.data[index] = num def __str__(self): return "%s" % self.data def __len__(self): return len(self.data) def __getitem__(self, index): return self.data[index] def __setitem__(self, index, value): ...
c8bca636dbc0fd5a7d7febe93a6e83ff814a379b
urstkj/Python
/algorithm/array_stack.py
1,042
3.859375
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- class ArrayStack: def __init__(self): self._data = [] def __len__(self): return len(self._data) def is_empty(self): return len(self._data) == 0 def push(self, e): self._data.append(e) def top(self): if self....
663a1bd6d66f8369f9a2aec460433bc020c5cb80
urstkj/Python
/database/mysql.py
2,825
3.890625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import MySQLdb # Open database connection db = MySQLdb.connect("localhost", "root", "", "test") # prepare a cursor object using cursor() method cursor = db.cursor() # execute SQL query using execute() method. cursor.execute("SELECT VERSION()") # Fetch a single row usi...
69f58529113b1a6bad610b65c6dea8fafaf72a03
anabeatrizzz/exercicios-pa-python
/exercicios_palgoritmo/exercicio_palgoritmo_02.py
349
4.0625
4
"""Elaborar um algoritmo que leia um número. Se positivo armazene-o em uma variável chamada "A", se for negativo, em uma variável chamada "B". No final mostrar o resultado das duas variáveis.""" A = B = 0 num = int(input("Digite um numero: " )) if num > 0: A = num if num < 0: B = num print(f"A variavel A vale: {A}\...
b2f3a9bce9b1b9864004371d5762d9d4380948a7
anabeatrizzz/exercicios-pa-python
/exemplos_Aula_2/Aula_2_13.py
144
3.96875
4
while True: A = int(input("Digite um numero: ")) if A != 0: print(f"O dobro de {A} é {A * 2}") else: print("Programa encerrado") break
0236e95fdffd9e769366713f402c0833f2023599
anabeatrizzz/exercicios-pa-python
/exercicios_5/exercicios_5_01.py
2,466
4.25
4
"""Escreva um programa que peça para o usuário digitar uma data contendo dia, mês e ano e o programa deverá informar se é uma data válida ou não.""" class Data(): def __init__(self): self.dia = 0 self.mes = 0 self.ano = 0 def VerificaDia(dia, mes, resultado): if (mes == 1 or 3 or 5 or 7 or 8 or 10 or 12) and ...
6eff63e0b9409caaa59773416df3adb8128c880e
anabeatrizzz/exercicios-pa-python
/exemplos_Aula_4/Aula_4_07.py
306
4.28125
4
matriz = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] print("Entre com o valor em cada posição da matriz: ") for a in range(0, 3): for b in range(0, 3): matriz[a][b] = int(input(f"mat[{a}][{b}] = ")) print("\nExibindo os dados da matriz: ") for a in range(0, 3): for b in range(0, 3): print(matriz[a][b])
dc8b6496247dbcd6c0e1af69d9f44880a4567dde
anabeatrizzz/exercicios-pa-python
/exercicios_do_caderno/exercicio01_do_caderno.py
477
4.28125
4
"""Elabore um algoritmo que receba dois números e mostre na tela o resultado da soma, subtração, multiplicação e divisão desses números""" num1 = float(input("Digite um numero: ")) num2 = float(input("Digite outro numero: ")) print(f'A soma desses dois numeros é: {num1 + num2}') print(f'A subtração desses dois numeros...
7c5ce778fe8d215102fd05915c7d370faec8044b
anabeatrizzz/exercicios-pa-python
/exercicios_4/exercicios_4_03.py
1,132
4.34375
4
"""Escreva um programa que leia uma matriz (3x5 ou 5x3) de 15 números inteiros e exiba ao final a soma dos valores de cada linha que estão armazenados nesta matriz.""" matriz = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] valores = 0 for l in range(0, 3): for c in range(0, 5): matriz[l][c] = int(input(f'Linh...
029a34313409456def0bed3d3ec322043044d73f
anabeatrizzz/exercicios-pa-python
/exercicios_do_caderno/exercicio10_do_caderno.py
214
4.03125
4
"""Desenvolva um programa que receba 10 numeros e mostre na tela a media aritmetica.""" s = 0 for c in range(1, 10+1): v = float(input("Digite um numero: ")) s += v m = s // 10 print(f"A media é {m}")
d6db9c17ae072ce17aa56a5812ca0fff4d03138a
anabeatrizzz/exercicios-pa-python
/exemplos_Aula_1/Aula_1_02.py
177
3.8125
4
a = 20 b = 10 print(f'{a} + {b} = {a + b}') total = a - b print(f'{a} - {b} = {total}') print(f'{a} * {b} = {a * b}') print(f'{a} / {b} = {a / b}') print(f'{a} % {b} = {a % b}')
f82decda3595053e71926ab45945b9f5f6d0392c
anabeatrizzz/exercicios-pa-python
/exercicios_palgoritmo/exercicio_palgoritmo_03.py
530
3.859375
4
"""Tendo como dados de entrada a altura e o sexo de uma pessoa, construa um algoritmo que calcule peso ideal, utilizando as seguintes fórmulas: Para homens: (72.7 * h) - 58 Para mulheres: (62.1*h) – 44.7 Onde h equivale a altura da pessoa.""" h = float(input("Digite a sua altura: ")) g = str(input("Digite o seu genero...
69431ac15eb0345f604905fc66f547198e872f35
anabeatrizzz/exercicios-pa-python
/exemplos_Aula_3/Aula_3_02.py
154
3.515625
4
def Digite(): print("Digite uma palavra: ") def Tamanho(p): return len(p) Digite() p = str(input()) t = Tamanho(p) print(f"{p} possui {t} caracteres")
dd8c229c8db6673df6cafedd9f95de0f63d319b4
anabeatrizzz/exercicios-pa-python
/exemplos_Aula_5/Aula_5_06.py
625
4
4
class Livros(): def __init__(self): self.titulo = [] self.ano = [] self.preco = [] def cadastrar(): livro = Livros() print("Cadastrando um livro...") for c in range(0, 3): livro.titulo.append(str(input("Titulo do livro: "))) livro.ano.append(int(input("Ano de lançamento: "))) livro.preco.append(float(i...
98af71260debdb1435845afefa1dc166ea4301d3
anabeatrizzz/exercicios-pa-python
/exercicios_1/exercicios_1_10.py
484
4.125
4
# Escreva um programa que calcule a expressão lógica, sendo que o usuário deverá informar os valores (números inteiros) # para as variáveis. # ((X >= Y) AND (Z <=X)) OR ((X == W) AND (Y == Z)) OR (NOT(X != W)) X = int(input("Informe um valor para X: ")) Y = int(input("Informe um valor para Y: ")) Z = int(input("Inform...
5a15c335db5b1d6cff4ead8bf5d1f6951ea1b7ab
Jump1556/automatetheboringstuff
/chapter7.regex/tasks/spaces_exclamation_marks.py
591
3.796875
4
#! /usr/bin/env python3. # spaces_exclamation_marks.py - Find multiple spaces between words, accidentally repeated words, # or multiple exclamation marks. import re, pyperclip pyperclip.copy('ometimes you you may need to use the!! matched text text itself as part of!!! the substitution') text = str(pyperclip.past...
0034a3442023cbae28e4cdd84f9389cda61b9730
KedraMichal/python-lab
/lab5/shape_classes.py
3,173
3.8125
4
def is_number(number): try: float(number) return True except: return False class Vector_2D: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector_2D(self.x + other.x, self.y + other.y) def __iadd__(self, other): ...
093b26ef3a9cfb148bb0395f793c46dda1172946
KedraMichal/python-lab
/lab3/n_grams.py
1,767
3.640625
4
def get_words(file_txt): with open(file_txt, "r", encoding="utf-8") as f: for word in f.read().replace(".", "").replace(",", "").replace("-", "").replace("!", "").replace("?", "").split(): yield word def count_n_grams(words_list, n): n_grams = {} saved = [] i = 0 for word in w...
d497e9e2134225b5dd7835a98395c1cd5910dc30
Learning-and-Intelligent-Systems/stacking
/learning/models/ensemble.py
3,088
3.53125
4
import torch import torch.nn as nn from learning.models.mlp_dropout import MLP class Ensemble(nn.Module): """ A helper class to represent a collection of models. Intended usage: This class is designed to be used for active learning. It only needs to be initialized once outside of the active loop. Ev...
d4977267f1392849d4638c2f2cde3db140569de8
brew/satchless
/satchless/item/__init__.py
2,472
3.65625
4
from prices import PriceRange __all__ = ('Item', 'ItemLine', 'ItemRange', 'ItemSet') class ItemRange(object): """ Represents a group of products like a product with multiple variants """ def __iter__(self): raise NotImplementedError() # pragma: no cover def get_price_per_item(self, item...
c8751e965ace416a4b608de22eb9d625b7da2b46
0523431/Python
/20200110/function_ex01.py
735
3.609375
4
''' Created on 2020. 1. 10. @author: GDJ19 <function : 함수사용하기> ''' # 함수 선언하기 # 예약어 def로 시작하고 앞에 시작하는 공백으로 구분할 수 있음 def coffee_machine(button): print() print("#1 뜨거운 물 준비") print("#2 개인 머그컵 준비") if button ==1 : print("#3 보통 커피를 탄다") elif button ==2 : print("#3 설탕...
accd3426b82b0b4df2117813716e6866538ae3cb
0523431/Python
/20200120/regular_ex03.py
1,065
3.640625
4
''' Created on 2020. 1. 20. @author: GDJ19 <정규식 예제> ''' import re string ="The quick brown fox jumps over the lazy dog." string_list = string.split() pattern = re.compile("The") count =0 for word in string_list : # word 중에 pattern이 있니? if pattern.search(word) : count +=1 print(...
a7194956218e4c731edc6340fe16675f2d3a1b21
0523431/Python
/20200109/operator_ex01.py
1,157
3.53125
4
''' Created on 2020. 1. 9. @author: GDJ19 <연산자 연습> ''' num1 = int(input('첫번째 점수 입력 : ')) num2 = int(input('두번째 점수 입력 : ')) print(num1,"+",num2,"=",(num1+num2)) print(num1,"-",num2,"=",(num1-num2)) print(num1,"*",num2,"=",(num1*num2)) print(num1,"/",num2,"=",(num1/num2)) # java : 정수 몫 / python : 몫 전체...
24f193f83ec5827214825e130c0d074b6d96fd55
0523431/Python
/20200117/class_ex05.py
667
3.515625
4
''' Created on 2020. 1. 17. @author: GDJ19 <추상클래스와 메서드> ''' class SuperClass : # 추상메서드 def method(self) : # 반드시 오버라이딩 해야함 raise NotImplementedError class SubClass1(SuperClass) : def method(self) : print("SubClass1에서 method()를 오버라이딩 함") class SubClass...
72ded1088cf83e19824d18a0f40553b9aa0730ab
0523431/Python
/20200115/lotto.py
591
3.765625
4
''' Created on 2020. 1. 15. @author: GDJ19 <lotto 로또 번호 생성기> ''' import random def getNumber() : return random.randrange(1, 46) # 자료형 dictionary lotto = {} print(type(lotto)) # lotto[]를 쓴 식은 dict인 경우에만 가능함 for num in range (1, 7) : lotto[num] = getNumber() # set으로 만들어주려면 lotto = s...
dc382fe23771b95281c7bf999c96f4a7755b71a2
0523431/Python
/20200109/while_ex01.py
279
3.78125
4
''' Created on 2020. 1. 9. @author: GDJ19 <while구문 연습> ''' print("while구문") num =0 while num <5 : print(num, end=",") num +=1 print("\nfor구문") for i in range(1,11) : # 1부터 11전까지 (1,2,3,4,5,6,7,8,9,10,) print(i, end=",")
2148caa9891d0908914a7eae7d50c7c20eebc6da
sarveshbhatnagar/space-raider
/enemy.py
1,424
3.515625
4
import position # As of now there is only one enemy, can be updated # to have multiple enemies with different properties. # all the enemy classes will be stored in enemy.py # TODO remove enemyimage from class as it should be fixed per class. class MoonVader(position.Position): """ MoonVader type enemy class...
18bd55a617f55c21bb4aef6b44ae3547c54530ee
yingziyu-llt/OI
/python/myMath/pow.py
111
3.71875
4
def pow(x,n): """x是底数,n是指数,n是正整数""" while(n > 0): x *= x n = n - 1 return x
cd1d1d98cd5bac3ec171efbe4263a4726bc181b5
EPCJC-LP10/09
/M9/exemploProf/teste datas.py
380
3.65625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 21 13:10:44 2013 @author: i12201 """ from datetime import date from datetime import datetime from datetime import timedelta data_inicio = raw_input("Data de inicio: ") data_fim = raw_input("Data de fim: ") a = datetime.strptime(data_inicio,'%d-%m-%Y') b = datetime.st...
1d39b9e59c64f255bed4f93633721fe3fffc76e7
SHAILESHSHIVA/internship
/prctice/assiPart1.py
1,686
3.53125
4
import urllib from collections import Counter #OPEN FILE THROUGH URLLIB MODULE AND STORING IN HTMLSrc variable # content= urllib.urlopen('https://docs.python.org/2/index.html') # htmlSrc = content.read() # # # # file1 = open('ext.txt','w') # file1.write(htmlSrc) # file1.close() #+++++++++++++++++++++++++++++Star...
3cf7bc92cc769cf13263daa14733695cee5267a0
abdulhaq-e/projectEuler
/P1.py
1,098
3.796875
4
def factors(n1, n2, m): '''n is the number, m is the range''' f = [x for x in xrange(1,m) if (x%n1 == 0) or (x%n2 == 0)] return f def sumOfFactors(n1,n2,m): f = factors(n1, n2, m) #print f1 ans = sum(f) return ans ''' that was my solution, the first solution in the pdf gives the same...
38aa843a83904894f86e1c447fcdb138b281a370
luckeyme74/tuples
/tuples_practice.py
2,274
4.40625
4
# 12.1 # Create a tuple filled with 5 numbers assign it to the variable n n = ('2', '4', '6', '8', '10') # the ( ) are optional # Create a tuple named tup using the tuple function tup = tuple() # Create a tuple named first and pass it your first name first = tuple('Jenny',) # print the first lette...
b7f74e2099d41dc5247a5cebe533b7e957bd473a
wy4313/github_exercise
/loop.py
459
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def HelloMsg(): classmates = ['hello', 'world', 'python'] for x in classmates: print('Hello %s' % x) def calcsum(max): sumnumber = 0 for i in range(max): sumnumber += i print(sumnumber) if __name__ == '__main__': HelloMsg() ...
6ac3812a821c44633538de9f98d50fe153864946
matthewwardrop/python-qubricks
/qubricks/wall/systems.py
2,595
3.5625
4
from ..system import QuantumSystem class SimpleQuantumSystem(QuantumSystem): ''' `SimpleQuantumSystem` is a subclass of `QuantumSystem` that enables you to initialise a `QuantumSystem` instance in one line, by passing keyword arguments to the constructor. Otherwise, it is indistinguishable. ...
59caac01308555665d8b437a44f1bdaab4084b0e
ishween/Bill-Reimbursement
/src/decorators.py
864
3.609375
4
""" decorators to wrap functions with other functionality without modifying existing function function is passed in the argument In this if someone tries to directly reach to add dept/manager/employee/bill type without login we prevent the user to access it by redirecting it back to login page. One can directly reach ...
ce43c777e779e9141b2c213aca46408cc57d9c22
diegoaspinwall/Unit3
/fives.py
106
3.96875
4
#Diego Aspinwall #9-27-17 #fives.py num = int(input('Enter a number: ')) i=5 while i<=num: print(i) i+=5
abe6186dcccda09293dd055eb09cbb0c24de9a93
saidaHF/InitiationToPython
/exercises/converter2.py
1,031
4.15625
4
#!/usr/bin/env python # solution by cpascual@cells.es """ Exercise: converter2 --------------------- Same as exercise converter1 but this time you need to parse the header to obtain the values for the gain and the offset from there. Also, you cannot assume that the header has just 3 lines or that the order of the i...
4993df0152c6d2f1b80a43a29390d0450a81243c
saidaHF/InitiationToPython
/exercises/cheat/converter1.py
2,430
3.9375
4
#!/usr/bin/env python # solution by cpascual@cells.es """ Exercise: converter1 -------------------- Make sure that you work on the "exercises" directory and that it contains the file named `sp8c.dat` The file sp8c.dat contains the data of a positron-decay spectrum (detector counts as a function of time) saved in AS...
482f5bddc4435e4f5c5ccc286a2d31869917bdc3
saidaHF/InitiationToPython
/exercises/cheat/converter3.py
3,361
3.921875
4
#!/usr/bin/env python # solution by cpascual@cells.es """ Exercise: converter3 -------------------- Refactor your solution to exercise converter2 to use functions: - Create a function called `split_file` that accepts the name of the input file as its only argument and returns 2 values: 1. the whole header as a si...
9d5f2c9ac245eef872cc785b4f6d3e58287f20ea
leclair-7/Didactics
/Notes/DivideAndConquor/sorting_basics.py
1,554
3.6875
4
def swap(arr, indexa,indexb): st = arr[indexa] fi = arr[indexb] arr[indexa] = fi arr[indexb] = st def selectionSort(a): for i in range(len(a)): minindex = i for j in range(i+1,len(a)): if a[j] < a[minindex]: minindex = j #swap minindex swap(a,i,minindex) ''' st = a[i] fi = a[minindex] a[i...
50d6555a73ab1760c039833dc371a454f92506ee
leclair-7/Didactics
/AlgorithmToolbox/week2_algorithmic_warmup/4_least_common_multiple/gcd.py
342
3.734375
4
# Uses python3 import sys ''' We're going to get least common multiple gcd a b ==> d s.t. a|d and b|d ''' def gcd_euclid(a, b): if b==0: return a a_prime = a % b return gcd_euclid(b,a_prime) a,b = 28851538, 1183019 gc = gcd_euclid(a, b) print(a * (b//gc) ) a,b = 6,8 gc = gcd_euclid(a, b)...
0e43faa04c00b65676248c86d13032d313b5663a
leclair-7/Didactics
/AlgorithmToolbox/week2_algorithmic_warmup/4_least_common_multiple/lcm.py
464
3.546875
4
# Uses python3 import sys def gcd_euclid(a, b): if b==0: return a a_prime = a % b return gcd_euclid(b,a_prime) def lcm_lucas(a, b): gc = gcd_euclid(a, b) result = max(a,b) * (min(a,b)//gc) return result if __name__ == '__main__': input = sys.stdin.read() a, b = map(int, input...
9185030d03bf2fddd243c90025f728aa06f519e7
woodongk/python-algorithm-study
/Programmers/전화번호 목록.py
1,128
3.71875
4
# def solution(phone_book): # phone_book = sorted(phone_book, key=lambda x: x[0]) # # prefix = phone_book[0] # 최솟값을 prefix로 설정한다. # phone_book = phone_book[1:] # 최솟값 제외한 전화번호 목록 갱신한다. # # while len(phone_book) > 0: # for p in phone_book: # if str(p).startswith(prefix): # ...
af8f649cc22d9cfed705157700350309733ed9b8
woodongk/python-algorithm-study
/Programmers/유형별 문제/[정렬] K번째 수.py
272
3.5625
4
def solution(array, commands): answer = [] for cmd in commands: i, j, k = cmd answer.append(sorted(array[i - 1: j])[k - 1]) return answer if __name__ == '__main__': print(solution([1, 5, 2, 6, 3, 7, 4],[[2, 5, 3], [4, 4, 1], [1, 7, 3]]))
7b736ce3a90e03a05fad7fc92445a502752f22e9
woodongk/python-algorithm-study
/파이썬 알고리즘 인터뷰/[6-02] 937. Reorder Data in Log Files.py
1,707
4.0625
4
""" You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except the identifier) consist of lowercase English letters. Digit-logs: All words (except the identifier) consist of digits. Reorder these lo...
cd668690e86c480cf0f03c51411778a97e19650d
jpachmann/daily_coding_challenges
/problem_155.py
533
3.9375
4
"""Given a list of elements, find the majority element, which appears more than half the time (> floor(len(lst) / 2.0)). You can assume that such element exists. For example, given [1, 2, 1, 1, 3, 4, 0], return 1. """ def solution(list_x): counter = {} for item in list_x: if item not in counter: ...
5d80f4a527ef06d51b840936ff26562505d8bbc5
Asboss10/quiz1angelsalazar
/ejercicio 1 quiz Angel Salazar.py
620
3.953125
4
def contraseña(): contraseña = input("ingrese su contraseña :") upper=0 space=0 num=0 largo = 0 espacio = " " if contraseña.isupper()==True: upper=True if espacio in contraseña: space =True while 1<=len(contraseña)<=8: if upper==True and space=...
3a977995499c7bb85ac67c3b55f125767152b3de
JamieWu1224/assign5
/comparemaxunittest.py
620
3.75
4
import unittest def maxcompare(n): lis = map(int, n.split(',')) threeans = [] for i in range(3): maxnum = lis[0] for j in lis[1:]: if int(j)>maxnum: maxnum = j lis.remove(maxnum) threeans.append(maxnum) ...
fca891de4e4e380e38d1bec0d233bb82b9ada65b
jeffreynorth/uci-ds-and-algorithms-python
/triangle.py
1,404
3.953125
4
# name: Nickolas Decker # email: deckernickolas@gmail.com # problem: triangle # define the recursive function triangle after this comment def triangle(n): if n == 1: return '*' result = triangle(n-1) result = result + "\n" + '*'*n return result def main_test(): tests = [0, '...
2607b8a3bc6c8170e4a79c4e296d36ebd2ecdd93
mhedenstrom/aoc2018
/days/02/checksum.py
718
4.0625
4
from functools import reduce # ex: aab => {a: 2, b: 1} def letter_frequencies(word): frequencies = {} for letter in list(word): frequencies[letter] = frequencies[letter] + 1 if letter in frequencies else 1 return frequencies # words containing exactly `count` of any letter def containing(words, co...
6e5fd690d42f49314923456a74d82ff5f57c5b18
Mohammad-Rahmdel/Deep_Learning_Specialization
/1.Neural Networks and Deep Learning/week4/PA4/PA4.py
5,070
3.59375
4
""" Week4 - Programming Assignment 4 Instructions: https://github.com/Mohammad-Rahmdel/deep-learning-specialization-coursera/blob/master/01-Neural-Networks-and-Deep-Learning/week4/Programming-Assignments/Deep_Neural_Network_Application_Image_Classification/Deep_Neural_Network_Application_v3.ipynb ...
d617cbbff84af2ad2cb0bec31145c27397704a64
Mohammad-Rahmdel/Deep_Learning_Specialization
/2.Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization/week2/PA4.py
10,868
4.4375
4
""" Week2 - Programming Assignment 4 study this link good explanations about Batch, mini-batch and stochastic Gradient Descent https://github.com/Kulbear/deep-learning-coursera/blob/master/Improving%20Deep%20Neural%20Networks%20Hyperparameter%20tuning%2C%20Regularization%20and%20Optimization/Optim...
de3a45a8508434ee554e77c2123eabd9d3bb75fa
pradippatil/leetcode
/problems/easy/reverse_string.py
1,225
4.09375
4
# -*- coding:utf-8 -*- # @Script: reverse_string.py # @Author: Pradip Patil # @Contact: @pradip__patil # @Created: 2019-03-20 22:48:07 # @Last Modified By: Pradip Patil # @Last Modified: 2019-03-20 22:57:17 # @Description: https://leetcode.com/problems/reverse-string/ ''' Write a function that reverses a string. The i...
9b33865dad32ff558db1143c96b6c417728f4072
yangluo0901/Python_basics_2019
/Stocks/test.py
396
3.75
4
class A(object): def __init__(self): self.word = "This is A !" def print(self): print(self.word) class B(A): def __init__(self): self.word = "This is B" def print(self): print(self.word) class C(B): def __init__(self): self.word = "This is C" def pr...
262bfce0dd07e2f13e30b1c091d4e30c259c5df5
yangluo0901/Python_basics_2019
/my_singleton_metaclass.py
2,278
4.03125
4
class MySingleton(type): # A class can be used as a template for instances A type can be used as a template for other class _instances = {} def __call__(cls, *args, **kwargs): print(" I am inside the MySingleton __call__") if cls not in cls._instances: cls._instances[cls] = super(M...
e9db195838dde65b726c0861ed278b231d2edc43
jddunn/interview-exercises
/palindrome_checker.py
1,883
3.578125
4
# Sentence-length palindrome checker class StripText(): def strip(self, str_text): punct_chars = [' ', '.', ',', '!', '?', '&', '"', "'", '-', ':'] str_text = [i for i in str_text if i not in punct_chars] str_text = ''.join(str_text) return str_text class ReverseStr(): ...
cd0a6e6f5f951a914f495eb144d66d55d1808581
Hasbanmalick549/assigment
/main.py
1,022
3.90625
4
sub1 = int(input("maths")); sub2 = int(input("physics")); sub3 = int(input("chemestry")); sub4 = int(input("urdu")); sub5 = int(input("english")); all_subject = (sub1+sub2+sub3+sub4+sub5)/5 if all_subject >= 80 and all_subject <= 100 : print("Percentage") print(all_subject) print("Grade A+") elif all_subje...
0800c1e225acceed0cc608779bd686fb39c9e307
joha0033/pyWars
/dnaComplement.py
567
3.8125
4
def DNA_strand(dna): dnaList = list(dna) complementList = [] for d in dnaList: if d == 'A': complementList.append('T') if d == 'T': complementList.append('A') elif d != 'A' and d != 'T': if d == 'C': complementList.append('G') ...
e1be8a6391e8d69d9906b8712357a171952493c4
mauricejenkins-00/Python-Challenge
/pypoll/main2.py
2,486
4.34375
4
#Import libraries os, and Csv import os import csv #Give canidates a variable to add the canidates and vote count to candidates = {} #election_csv is a variable that calls for the election data file in the resources folder election_csv = os.path.join('.','Resources','election_data.csv') #With statement opens...
1c4c1304afa4fb8619848032eafba93110c4eb19
jackmar31/week_2
/parkingGarage/# Best Case: O(n) - Linear.py
901
4.28125
4
# Best Case: O(n) - Linear def swap(i,j, array): array[i],array[j] = array[j],array[i] def bubbleSort(array): # initially define isSorted as False so we can # execute the while loop isSorted = False # while the list is not sorted, repeat the following: while not isSorted: # assume t...
6b719a1c04d74de6a5867cef5522c8035fa3d1d0
jhansibode/Python-Programming
/Palindrom.py
166
3.875
4
a =str(input()) b =str(a[ : : -1]) print(a) print(b) if (a==b): print("value matching") else: print("value not matching") print("palindrom program")
9c3a48801a65a13415cb5f4ff705facfb5bf2469
cleitonPiccini/calculo_numerico
/metodo_newton.py
797
4.34375
4
#python 3 #Cleiton Piccini #Algoritmo do metódo de Newton para encontrar raizes de funções. import math # Função def funcao (x): #x = (x / (math.e**(10*x))) - (1 / (math.e ** 5)) x = math.cos(50 * x + 10) - math.sin(50 * x - 10) return x # Derivada da Função def derivada (x): #x = (math.e**(-10*x)) *...
06ea29eec33fe7ef9b2254a7b3fcd28b33bd6a60
simgroenewald/StringDataType
/Manipulation.py
869
4.34375
4
# Compulsory Task 3 strManip = input("Please enter a sentence:")#Declaring the variable StrLength = len(strManip)#Storing the length of the sentence as a variable print(StrLength)# Printing the length of the sentence LastLetter = strManip[StrLength-1:StrLength] #Storing the last letter of the lentence as a variable...
a81c877d006f0551c659d2395466088ecf26d638
SifatHamidi/Bangla-Handwritten-Digit-Recognizer
/model training.py
2,099
3.75
4
# -*- coding: utf-8 -*- """Model In this segment the functional model has been created using numerous feature extractor. then ,a portion of examples also shown about how this network working. """ def my_model(img_size=32,channels=1): model = Sequential() input_shape = (img_size,img_size,channels) model.a...
3c96037cac76ca10ecc6bbe4ad738424d3b21d34
lytenica/Zadachi
/4is_prime/solution.py
205
3.921875
4
def is_prime(n): if n<0: return False if n%2==0 and n%3==0: return False else: return True def main(): print(is_prime(5)) if __name__ == '__main__': main()