blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
78d02680ca659f88c2aa6b95c30ad52ffed0242c
Fiachra1/SPOJ
/PALIN-The next Palindrome.py
1,606
3.890625
4
#A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without...
74043430583df0fce3adda38bc1634a04a43b139
krunaljain/Data-Mining-top-influencers-in-a-social-network
/Graph.py
1,461
3.8125
4
#!/usr/local/bin/python3.6 class Graph : def __init__ (self) : self.edges = {} def add_edge (self, from_, to) : if from_ not in self.edges : self.edges[from_] = [to] else : self.edges[from_].append(to) # if to not in self.edges : # self.edge...
c8018a69d750424bf8637e53f52f840d67668a55
linsalrob/PPPF
/pppf_db/database_handles.py
1,182
3.859375
4
""" Create and maintain the connections to the SQLite database """ import sys import os import sqlite3 from pppf_accessories import color def connect_to_db(dbname, verbose=False): """ Connect to the database :param dbname: the database file name :param verbose: print addtional output :return: the...
0c58ff9472b1d1b85c1b6b68d0758f9aa5554f3d
DeltaHarbinger/api_example
/main.py
2,507
4.34375
4
''' Example of a simple flask API with multiple routes ''' from flask import Flask, request ''' The application is defined here ''' app = Flask(__name__) ''' To access the api, you may go to 127.0.0.1:5000/ OR localhost:5000/ Routes are like paths. They may redirect to different pages that have different functions....
43a8934b50e01ac050bc78bd4286419ec991314b
A284Philipi/1101_Sequencia-de-Numeros-e-Soma_Python
/main.py
493
3.5
4
cont = int(0) while cont == 0: a, b = input().split(" ") a = int(a) b = int(b) if (a < 1 or b < 1): cont = 1 else: if (a < b): c = int() c = a a = b b = c lista = [] soma = int(0) while b <= a: ...
667806034f2e62c10bbc397dfeb4d710b691cd54
symonk/python-musings
/object_data_model/__str__.py
703
4.15625
4
""" dunder __str__ is invoked by all three of the following builtin functions: print(x) | str(x) | format(x). dunder __str__ should return an 'informal' nicely printable string representation of the object. dunder __str__ should return a string. """ class CustomObject: def __init__(self, x: int, y: str) -> None: ...
0ef0f0415aab2084876a1a8f54ffe9ac4d70b338
symonk/python-musings
/object_data_model/__del__.py
2,317
3.78125
4
from sys import getrefcount """ Another core part of object customisation is the dunder __del__ (finalizer). This is called when an object is about to be destroyed. If a base class implements a custom __del__ implementation, derived subclasses of the base should ensure to call super().__del__() to ensure proper dele...
471ce97aee7de78dbdca0a20ec17df8a19acfc15
symonk/python-musings
/collections/set.py
22,290
4.25
4
""" Python offers two flavours of built in sets, these are sets and frozen sets. As you can imagine, frozen sets are themselves immutable and thus hashable so can be stored inside other sets and also used as dictionary keys. By default, sets are mutable as we can add elements to them etc. Note: For TLDR Notes, please...
d309d54f9bdd67c492b97345c1fc76741e40990e
knowlage-storage/rpg
/examine.py
6,740
4.25
4
import re import operator from utilities import clear_screen def find_item(item, text_input): """ A function to search user text entry for regex patterns. We first rejoin the text list into a string separated with spaces. We then create a regex item using the value entered into the function. We then chec...
47fb1c3186b7d1b22c96e9bf3cf5b4261fab6689
jsatt/advent
/2020/d12/p2.py
1,515
3.578125
4
import re from collections import deque # FILENAME = 'test_input.txt' FILENAME = 'input.txt' def read_input(): with open(FILENAME) as f: return [parse_line(l) for l in f.readlines()] def parse_line(line): action, val = re.match('(\w)(\d+)', line).groups() return action, int(val) def move_wayp...
a3b51cea993ad3347b30ea85e8c21094288af713
jsatt/advent
/2020/d18/p1.py
1,148
3.578125
4
from math import prod FILENAME = 'test_input.txt' FILENAME = 'input.txt' def read_input(): with open(FILENAME) as f: return [list(l.strip().replace(' ','')) for l in f.readlines()] def evaluate(group): group_iter = iter(group) running = 0 op = sum for char in group_iter: if ch...
061e6d8f67728fb50f76f37ef9a06894aa66b31d
jsatt/advent
/2020/d9/p1.py
1,141
3.6875
4
FILENAME = 'test_input.txt' PREAMBLE_LEN = 5 # FILENAME = 'input.txt' # PREAMBLE_LEN = 25 def read_input(): with open(FILENAME) as f: return [int(i) for i in f.readlines()] def find_sum(nums, target): for c1 in nums[:-1]: for c2 in nums[0:]: if c1 + c2 == target: ...
a5e1ccf606e860e87a34fc8b5001675b3da045c3
anemesio/Python3-Exercicios
/Mundo 02/ex038.py
254
4.0625
4
num1 = float(input('Primeiro número: ')) num2 = float(input('Segundo número: ')) if num1 > num2: print('O PRIMEIRO número é maior!') elif num2 > num1: print('O SEGUNDO número é maior!') else: print('Os dois valores são iguais.')
1e416ccea3b4487e666b6c630116db79faf27227
anemesio/Python3-Exercicios
/Mundo 03/ex083.py
276
3.796875
4
x = str(input('Digite uma expressão: ')).strip() cont1 = 0 cont2 = 0 for c in x: if c == '(': cont1 += 1 elif c == ')': cont2 += 1 if cont1 == cont2: print('A expressão está correta!') else: print('Sua expressão está errada!')
d334272a1758f62f85261dc8949467ac14fe30bd
anemesio/Python3-Exercicios
/Mundo 02/ex059.py
1,020
4.0625
4
num01 = int(input('Primeiro valor: ')) num02 = int(input('Segundo valor: ')) escolha = 0 while escolha != 5: print('''\033[1;34mESCOLHA UMA DAS OPÇÕES: [1] SOMAR [2] MULTIPLICAR [3] MAIOR ENTRE OS DOIS [4] ENTRE COM NOVOS NÚMEROS [5] SAIR DO PROGRAMA\033[m''') escolha = int(input('...
bd4757a002c5a7725e077dac4c1d9139d5b0a4b7
anemesio/Python3-Exercicios
/Mundo 02/ex051.py
251
3.875
4
print('=' * 20) print('10 TERMOS DE UMA PA') print('=' * 20) p = int(input('Primeiro Termo: ')) razao = int(input('Razão: ')) décimo = p + (9 * razao) for c in range(p, décimo + razao, razao): print(c, end = ' → ') print('ACABOU!')
e397b2646d7b28d83bb8699f770475aaa7e32cf8
anemesio/Python3-Exercicios
/Mundo 02/ex070.py
820
3.71875
4
print('-' * 20) print('LOJAS PYTHON') print('-' * 20) total = 0 caro = 0 qttde = 0 while True: produto = input('Nome do Produto: ') preco = float(input('Preço: R$ ')) total += preco qttde += 1 if preco > 1000: caro += 1 if qttde == 1 or produto_mais_barato > preco: ...
93922081ed8156ddbba723aca65c1e362dbe1292
anemesio/Python3-Exercicios
/Mundo01/ex035.py
465
3.78125
4
print('\033[1;34m-=-\033[m' * 10) print('\033[1;30;44mAnalisador de Trinângulos\033[m') print('\033[1;34m-=-\033[m' * 10) a = float(input('Primeiro segmento: ')) b = float(input('Segundo segmento: ')) c = float(input('Terceiro segmento: ')) if (b - c) < a < (b + c) and (a - c) < b < (a + c) and (a - b) < c < (a +...
0cb4b1fe235b256d392d5822798087177cf5ac77
anemesio/Python3-Exercicios
/Mundo 03/ex096.py
243
3.59375
4
def area(): print('Controle de Terrenos') print('-' * 20) l = float(input('LARGURA (m): ')) c = float(input('COMPRIMENTO (m): ')) print(f'A área de um terreno de {l:.2f} x {c:.2f} é de {l * c:.2f}m².') area()
6ed32e080702682b9d8c1dcd7b14898d432271ad
anemesio/Python3-Exercicios
/Mundo01/ex0013.py
190
3.765625
4
s = float(input('Qual é o salário do funcionário: R$ ')) ns = s * 1.15 print('Um funcionário que ganhava R$ {:.2f}, com o aumento de 15%, passará a ganhar R$ {:.2f}.'.format(s, ns))
7b14412ed55509274f87e507379ff149c67ae00a
anemesio/Python3-Exercicios
/Mundo 02/ex044.py
1,212
3.828125
4
from time import sleep print('\033[1;34m====== LOJAS PYTHON =====\033[m') valor = float(input('Preço das compras: R$ ')) print('''FORMAS DE PAGAMENTO:) [1] À vista com dinheiro ou cheque; [2] À vista no cartão; [3] Parcelado 2x no cartão; [4] Parcelado 3x ou mais no cartão.''') opção = int(input('Qual é sua opç...
743d742a5dc276cb1a80b9c17fa875a2e0492811
anemesio/Python3-Exercicios
/Mundo 02/ex062.py
1,206
3.890625
4
primeiro = int(input('Primeiro Termo: ')) razao = int(input('Razão: ')) termo = primeiro count = 1 while count <= 10: print('{} → '.format(termo), end=' ') termo += razao count += 1 print('PAUSA!') count2 = 1 total = 10 #Mostra o total de termos da progressão mais = int(input('Quantos termos você...
d7e729a1527e45d6b4192f4ae71b40ffb7bbd04f
anemesio/Python3-Exercicios
/Mundo 02/ex049.py
224
4
4
num = int(input('Digite um número para ver sua tabuada: ')) print('-=-' * 6) print('APRENDA A TABUADA!') print('-=-' * 6) for c in range(0, 11): print('{} x {:2} = {:2}'.format(num, c, num * c)) print('-=-' * 6)
f9f3da55cb4a9f88b6272b3f906c82c814951cda
jonasht/programmingPython-book
/1-chapter-aSneakPreview/1-step1-representingRecords/4-0usingDictionary.py
204
3.5625
4
# coding: utf-8 bob = {'name': 'bob smith', 'age': 24, 'pay': 3000, 'job': 'dev'} bob sue = {'name': 'sue jones', 'age': 30, 'pay': 4000, 'job': 'hdw'} sue bob['name'].split()[-1] sue['pay'] *= 1.10 sue['pay']
bcd0955d8c6e705bbfbd936dcba67e78833621ad
jonasht/programmingPython-book
/08-ATkinterTour_part1/02-toplevelWindows/toplevel0.py
338
3.8125
4
import sys from tkinter import Toplevel, Button, Label # quando eh apertado o botão, fecha tudo # when the button is pressed, exit all of windows win1 = Toplevel() win2 = Toplevel() Button(win1, text='span', command=sys.exit).pack() Button(win2, text='span', command=sys.exit).pack() Label(text='popups').pack() ...
9df3626ec578db84ba46cdaf85549b11b156c024
kryten10/test2
/session3-q.py
145
4.03125
4
text = str('') while True: text = input("enter a letter: ") if text.upper() == "Q": break else: print("try again")
adaaedef6cea824e44c3295a2b7ce708056ca899
kryten10/test2
/session2-loan.py
394
4.0625
4
LoanAmount = float(input("Loan amount?")) MonthlyInterestRate = float(input("Monthly Interest Rate (e.g. 1.0)?")) / 100 NumberOfYears = float(input("number of years to pay off loan?")) MonthlyPayment = (LoanAmount * MonthlyInterestRate) / (1 - (1 / ((1 + MonthlyInterestRate) ** (NumberOfYears *12)))) TotalPayment = Mon...
634d48b4d10c2bf27026796da3ac0a4098c1a9a0
kryten10/test2
/session4_integer_list.py
227
4.125
4
int_list = list() newint = input("input an integer or 'q' to quit: ") while newint != 'q': int_list.append(int(newint)) newint = input("input an integer or 'q' to quit: ") int_list.sort() for e in int_list: print(e)
a2ae941543fb7600df403cacacd332223fb9d4bb
Sulorg/Python
/Self-taught-programmer-Althoff/Инструкции.py
476
4.15625
4
print ("Str1") print ("Str2") print ("Str3") x = 8 if x == 10: print ("Десять") if x >= 10: print ("Больше десяти") else: print ("None") x = 78 if x <= 10: print ("10") elif x >= 10 and x <= 25: print ("Между 10 и 25") elif x > 25: print (x) x = 12 y = 10 z = x // y print (z) x = 12 ...
ff88dc1bd4ae0d6c07cea0ce3c77f5af2029fd6c
Sulorg/Python
/Self-taught-programmer-Althoff/Циклы.py
654
3.71875
4
#Задание №1 series = ["Ходячие мертвецы", "Красавцы", "Клан Сопрано", "Дневники вампира"] for serie in series: print(serie) #Задание №2 for i in range(25,51): print(i) #Задание №3 series = ["Ходячие мертвецы", "Красавцы", "Клан Сопрано", "Дневники вампира"] for index,serie in enumerate(series): print...
8fb89611cdbf9bb8ef3a16484a0708e12a4c7b7b
adriaanbd/bricklee
/bricklee/entrypoint.py
480
3.703125
4
import argparse import sys def greet(name): if name: return f'Hello {name}.' return f'Hello Panama City, Panama.' def main(args=None): parser = argparse.ArgumentParser(description='Say hello') parser.add_argument('hello', type=str, help='a generic greeting') parser.add_argument('--name', h...
02fe13cfdcd0850aefdb393acf24f2dbeb834c80
VictorF19/devops-aula6
/src/primos.py
389
3.65625
4
inputPrimo = int(input("Digite o range dos numeros: ")) index = 1 listaPrimos = [] while True: if index > 1: for i in range(2,index): if (index % i) == 0: break else: listaPrimos.append(index) if (len(listaPrimos) == inputPrimo): print(listaPrimos...
c64bcc7c431425357c30974eb2e02cd0c167e8d3
fryn3/GeekBrains_Python1
/DZ3/hw03_normal.py
3,328
3.921875
4
# Задание-1: # Напишите функцию, возвращающую ряд Фибоначчи с n-элемента до m-элемента. # Первыми элементами ряда считать цифры 1 1 # 2017.03.11 13:47:00 checked. P.Rusanov # Отлично! def fibonacci(n, m): a = [1, 1] i = 2 while i < m - 1: # Цикл for? a.append(a[-1]+a[-2]) i += 1 ...
d1d8d2ab5c2deac35ff2109d8552e0855e331ad8
lizhizhou/hackthon
/test/.svn/pristine/9e/9e85f07914d456742420b9400f11a546c2702b22.svn-base
1,914
3.96875
4
#!/user/bin/env python """ Tower of Hanoi Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 1744 Accepted: 583 Description The Tower of Hanoi is a puzzle consisting of three pegs and a number of disks of different sizes which can slide onto any peg. The puzzle starts with the disks neatly stac...
a134dfecb9fbc723810fe387895ad23d7615d8db
lizhizhou/hackthon
/test/.svn/pristine/cf/cfb83c8ac374a80ce6d83d7b6f3c61f2ae824193.svn-base
194
3.515625
4
#!/user/bin/env python case = [] with open('input.txt', 'r') as f: for line in f: case.append(line.strip().split(' ')) print case
c4fd198d3dcdc827d9704ca3a429590b15421553
Javed765/Think_Python_3
/6. Chapter 6 - fruitful functions/Chapter 6.py
2,668
4.4375
4
############################################################################### ### Chapter 6 ############################################################################### ### Boolean functions def is_divisible(x, y): if x % y == 0: return True else: return False is_divisible(...
5db3e345c2865c3c0da0264197f7d6570db6d6be
skaytouch33/generate-binary-and-decimal
/genarator.py
1,282
3.9375
4
print(''' #***********************************# # Generator Program # #***********************************#''') print(''' 1-Binary to Decimal 2-Decimal To Binary 3-exit press the key ''') while(True): işlem=int(input("\nEnter the number of the transaction you want to do:...
c34ebcb84169f073e6377684b21c9d859afe1118
MahaAmin/Learn-Python-By-Games
/guessTheNumberGame.py
824
3.953125
4
#"Guess The Number" Game import random5 number = random.randint(1,50) numberOfGuesses = 0 print('Hello! What is your name?') playerName = input() print('Well, '+ playerName + ' I am thinking of a number between 1 and 50, Can you guess it?') while (numberOfGuesses < 8): print('Your Guess: ') guess = input...
745e96859f4acda5821dc1242879053dd14d3f2e
seun-beta/OOP
/classes_and_instances_2.py
478
3.796875
4
class Employee(): def __init__(self, first, last, pay): self.fname = first self.lname = last self.pay = pay self.email = first + '.' + last + '@company.com' def fullname(self): return self.fname + ' ' + self.lname def main(): emp_1 = Employee('Corey', 'Schafer...
3e8610d50db829b4a6e12b05838b8683137e9135
seun-beta/OOP
/car.py
1,723
4.03125
4
class Car: num_of_cars = 0 def __init__(self, manufacturer, engine_capacity, seats, engine_type, fuel): self.manufacturer = manufacturer self.engine_capacity = engine_capacity self.seats = seats self.engine_type = engine_type self.fuel = fuel C...
a5717f35c0fb508823d481616abf3516c4bd68e6
bryanpramana/PythonClass
/data statistics(1).py
1,809
4.34375
4
#This program process a sequence of values input by user, and then #outputs statistics pertaining to this input valCount = 0 #number of values input by user valSum = 0 #sum of input values negatives = 0 #number of negative values evens = 0 #number of even value...
b78aa18c36a5a7b2ecfa61f41a86a0877c49bef9
bryanpramana/PythonClass
/HW4.py
2,812
4.34375
4
# I am not quite sure with the assignment instruction, # Whether students need to make a program that ask the user to input 3 data set at a time or one by one # So I decided to make a program that ask and compute 3 data set a time def main(): #Asking the user to input 3 set of data's range print('Run 1:') ...
07512aeb5e3f75c7ec386f04d981f599728a61da
bryanpramana/PythonClass
/present value.py
572
4.25
4
#Programming Assignment 1 #Obtain payment amount, term and interest rate data from user paymentAmt = float(input('Please enter payment amount: ')) term = int(input('Enter term: ')) intRate = float(input('Enter interest rate: ')) #Compute present value presentValue = paymentAmt * (1 - (1 + intRate) ** -term) /...
1853188e0bae25c48df76672a942f8009ad7b009
lemonsaurus/aoc-2019
/day8/models.py
381
3.546875
4
import enum class ValueTracker: fewest_zeroes = None number_of_ones = None number_of_twos = None class PixelColor(enum.Enum): BLACK = 0 WHITE = 1 TRANSPARENT = 2 class Pixel: def __init__(self, value=None): self.value = value def __str__(self): if self.value == Pix...
0eea0aebda3714dbc8b78a80e6164f709fa440fe
S1R4QSA/Siracusa
/code/modules/module.py
582
3.53125
4
import abc from node import Node from abc import ABC, abstractmethod # abstract class class Module(ABC): """ properties: params : contain module params as a dict. """ def __init__(self, params): self.params={} for param in params: key,value = param.split("=") ...
75629d042ed34957856990bbdd8fee0693d0c7ee
andy12290/Udacity--Python-Foundation
/Fundamental_Py_sent/dict.py
157
3.578125
4
exdict = {"Jack": 12, "bob":13, "alice": 89} print(exdict) print(exdict["Jack"]) # os module import os c = os.getcwd() print(c) # import pandas as pd
30de42f07252678de346995a38d476354a4b1461
Garvey98/Sudoku
/solve_sudoku.py
3,219
3.890625
4
#!/usr/bin/python3 """ This is the module that solves the sudoku""" import numpy as np class SolveMySudoku(): """ This is the class that solves the sudoku""" mysudoku = np.zeros((9, 9), dtype=int) def __init__(self, Soduku_Path): """ Load the sudoku from the file and call the solution function to ...
9383be942b63aed552ab0f8a9bea08c0af9c28e6
bwjubrother/Algorithms
/Homework/5108_numadd.py
2,208
3.609375
4
import sys sys.stdin = open('5108.txt', 'r') class Node: def __init__(self, data): self.data = data self.next = None def __str__(self): return str(self.data) class linkedList: def __init__(self, data): new_node = None(data) self.head = new_node self.list_...
64786545946a48113995d73dd276cca4bd4930ff
bwjubrother/Algorithms
/Tests/kakao_craneDoll.py
470
3.671875
4
def solution(board, moves): answer = 0 stack = [] # 스택 for move in moves: pick = 0 for depth in range(len(board)): if board[depth][move-1] != 0: pick = board[depth][move-1] board[depth][move-1] = 0 break if len(stack) > ...
533085982d660f4b699c47c2c748b696b9f576ba
bwjubrother/Algorithms
/Learn_advanced/5177_digitHeap.py
998
3.59375
4
class Tree: def __init__(self): self.lst = [0] def sort(self, num): if num >= 2: if self.lst[num] < self.lst[num // 2]: # 자리 바꾸기 self.lst[num], self.lst[num // 2] = self.lst[num // 2], self.lst[num] self.sort(num // 2) # 계속 정렬 de...
d07f482c9a50e832f93315fb486c945706c32d7a
kamar24/AI2-lab5-PY
/venv/Include/Transportation.py
1,184
4.09375
4
class Transportation: wheels = 0 def __init__(self): self.wheels = -1 def travel_one(self): print("Travelling on generic transportation") def travel(self, distance): for _ in range(distance): self.travel_one() def is_auto(self): return self.wheels == 4...
a6484a785c5ed33741d45a4cb93ced60d1f11da0
ThomasLynn/Raspberry-Pi-RFID-Network-Commands
/write.py
329
3.875
4
#!/usr/bin/env python # Type some text data, then present a tag to the scanner # to write that data to it. import RPi.GPIO as GPIO from mfrc522 import SimpleMFRC522 reader = SimpleMFRC522() try: text = input("New data: ") print("Now place your tag to write") reader.write(text) print("Written") finally: GPIO.cle...
031b9b2ba1454f9542561518c25e451956213c15
luiz-amboni/linguagem-programacao-II-N1
/exe004.py
934
3.78125
4
import datetime import random #O decorador é um padrão usado quando você precisa anexar responsabilidades dinamicamente sem precisar de uma grande hierarquia de subclasses. #Decorator nada mais é que um método para envolver uma função, modificando seu comportamento. #Em Engenharia de Software, um padrão de projeto é u...
ced8d6ce1391f1c885573ebb1a06cca5aab39909
Hemraj-luv/Bank-payment
/pay bill.py
2,119
3.703125
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 10 23:36:43 2019 @author: Hemraj """ def payment(): class Bill: def __init__(self,items,price): self.items=items self.price=price self.total=0 for i in self.price: self.total+=i ...
4c79996e7be2ba19ed70f01665448b8e197972bb
omerfarukcelenk/PythonCalismalari
/demo-imdb.py
1,581
3.71875
4
import pandas as pd df = pd.read_csv("imdb2.csv") # 1- Dosyada hakkındaki bilgiler. result = df # result = df.columns # result = df.info # 2- ilk 5 kaydı gösterin # result = df.head() # 3- ilk 10 kaydı gösterin # result = df.head(10) # 4- Son 5 kaydı gösterin # result = df.tail() # 5- Son 10 kaydı gösterin # res...
b4f3a0eb1ad0bff7b7a8c01fae6be2283d6b44be
coryswainston/machine-learning-python
/knn2.py
2,415
3.875
4
# -*- coding: utf-8 -*- """ Using knn with more interesting data @author: coryswainston """ import numpy as np import pandas as pd from pandas.api.types import CategoricalDtype from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # a method to replace categorical da...
a753876f57c204ad7c7159d7b255bb19fcedd50a
dlogushiv/courseraBasePythonCourse
/Week-4/add2-TrianglePerimetr.py
341
3.828125
4
def dist(x1, y1, x2, y2): dx = abs(max(x1, x2) - min(x1, x2)) dy = abs(max(y1, y2) - min(y1, y2)) return (dx ** 2 + dy ** 2) ** 0.5 x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) x3 = float(input()) y3 = float(input()) print(dist(x1, y1, x2, y2) + dist(x1, y1, x3, y3) + d...
967a9bae31271ab678887e8d4f2942367d444231
dlogushiv/courseraBasePythonCourse
/Week-6/add2-ShoeStore.py
289
3.53125
4
size = int(input()) stock = sorted(list(map(int, input().split()))) res = 0 prevShoe = 0 for shoe in stock: if shoe >= size and prevShoe == 0: res += 1 prevShoe = shoe elif prevShoe != 0 and shoe - prevShoe >= 3: res += 1 prevShoe = shoe print(res)
e72a6548bf286a6dce83fb3229e2b525c09e95d3
dlogushiv/courseraBasePythonCourse
/Week-5/add5-SummOfFactorials.py
165
3.734375
4
def fact(a): if a > 1: return a * fact(a - 1) else: return 1 n = int(input()) res = 0 for i in range(n): res += fact(i + 1) print(res)
31a57bee16e366fcf4ff6a324c31a37f20e0978a
petr-tik/euler_project
/euler25.py
812
4.15625
4
# euler 25 # define first 2 terms and the rest of fib seq a = "" n = 1 # ask for the number of digits limit = int(raw_input("How many digits do you want in your fibbonacci term? ")) # recursively define fib def fib(n): # first 2 terms of fib seq if n == 1 or n == 2: return 1 elif n == 0: ...
6d48abf6965fe14a5b9c3f3cc12e43641455c309
Valar207/Bootcamp_PYTHON
/d00/ex07/filterwords.py
341
3.59375
4
import sys import string if (len(sys.argv) == 3 and sys.argv[2].isdigit() is True and sys.argv[1].isdigit() is False): av1 = sys.argv[1] av2 = int(sys.argv[2]) le = av1.translate(str.maketrans("", "", string.punctuation)).split() le = [elem for elem in le if len(elem) > av2] print(le) else...
c57a2393d64b99c09a34cea5615ffe338db1d872
jamescole/cp1404practicals
/prac_04/practice_and_extension_3.py
761
4.09375
4
def main(): print("Enter empty string to end getting input") input_strings = get_input_strings() repeated_strings = get_repeated_strings(input_strings) if len(repeated_strings) > 0: print("Strings repeated: {}.".format(", ".join(repeated_strings))) else: print("No repeated strings e...
d095ea6da3b105f5324c37d59362458535d04c70
jamescole/cp1404practicals
/prac_07/date_test.py
282
3.921875
4
from prac_07.date import Date def main(): date = Date(26,12,1978) print(date) print("Is leap year? {}".format(date.is_leap_year())) print(date._DAYS_IN_NON_LEAP_YEAR_MONTH) print(date._DAYS_IN_LEAP_YEAR_MONTH) date.add_days(37) print(date) main()
870e8b73f40689540afab8f90e69cf0ad1270f99
jamescole/cp1404practicals
/prac_03/broken_score.py
622
3.96875
4
""" CP1404/CP5632 - Practical Broken program to determine score status score must be between 0 and 100 inclusive; 90 or more is excellent; 50 or more is a pass; below 50 is bad """ def main(): score = float(input("Enter score: ")) if score < 0 or score > 100: print("Invalid score") else: ...
e401906d517f5942acd80ed6eb587d66af73ed3d
jamescole/cp1404practicals
/prac_05/colour_names.py
1,262
4.1875
4
COLOUR_NAMES = {"AliceBlue": "#f0f8ff", "AntiqueWhite": "#faebd7", "AntiqueWhite1": "#ffefdb", "AntiqueWhite2": "#eedfcc", "AntiqueWhite3": "#cdc0b0", "AntiqueWhite4": "#8b8378", "aquamarine1": "#7fffd4", "aquamarine2": "#76eec6", "aquamarine4": "#458b74"}...
816fc3d207872d273720b594f937107b8df1b0e0
Rohith-githu/python-projects
/Tkinter/buttons.py
406
3.96875
4
from tkinter import * root = Tk() # creating an simple buton widget. # here the padx and pady adjusts padding of the widget. def letclick(): mylabel = Label(root, text='look i clicked a Button') mylabel.pack() # the command attribute runs the function which is written in it. mybutton = Button(root, text='click...
544ca62d722c2d1915385f55a2506075b099ece8
Rohith-githu/python-projects
/Tkinter/grid.py
251
4.21875
4
from tkinter import * root = Tk() # creating a label widget's label1 = Label(root, text="Hello World") label2 = Label(root, text="my name is rohith") # arranging to grid label1.grid(row = 0, column =0) label2.grid(row = 1, column =5) root.mainloop()
2bde77c7481d47914dc5ef10a7f8427ff86af467
Rohith-githu/python-projects
/python projects/rockpapersisscor.py
1,199
4.3125
4
import random print('Welcome to the rock paper sissors game ') print('Rules for the game are : \n1.rock vs paper > paper wins \n2.rock vs sissors > rock wins \n3.paper vs sissors > sissors wins') while True: user_score = 0 computer_score = 0 ask_user = input('Enter your choice: ') computer_choice = ra...
d39798e458fcb253a1515b960fc0380436cd704a
oMatheusCaetano/jogo-da-forca
/forca.py
4,076
3.796875
4
from random import randrange def imprime_mensagem_abertura(): print('*'*33) print('** Bem vindo ao jogo da Forca! **') print('*'*33) def carrega_palavra_secreta(): palavras = arquivo_para_array('palavras.txt') numero_aleatorio = pegar_numero_aleatorio(palavras) return palavras[numero_aleatorio...
3a165aedeb9d37de4d2bec41a8addda0a7386452
olga231198/pythonlab
/1_2.py
210
3.765625
4
c = float(input('Введіть температуру у гр. Цельсія: ')) k = c + 273.15 f = c * 1.8 + 32 r = 0.8 * c print('K: ', round(k, 2)) print('F: ', round(f, 2)) print('Ré: ', round(r, 2))
a5f4ef58f9964fb647484aaa21817964df80d14d
olga231198/pythonlab
/lab3python/3_3.py
188
3.53125
4
n = 9 r = [] for i in range(n): r.append('a' * (i+1) + '\n') f = open('file.txt', 'w') f.writelines(r) f.close() print('Результат записано в файл file.txt')
77d7bccdfe86979bc6eb73072100174ba2d890ad
starryxy/Data-Engineering
/5 Data Wrangling with MongoDB/5.2 Complex Data Extraction XML-HTML/2_process_scraping_data_quiz.py
3,045
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Let's assume that you combined the code from the previous exercise with code on how to build requests, and downloaded all the data locally. The files are in a directory "data", named after the carrier and airport: "{}-{}.html".format(carrier, airport), for example "FL-A...
30520d4e2dfc0cd2035c7fbee74c0af2867528bc
hkh9715/pythonworkspace
/learnagain_python/programtutorial2_add3+5.py
498
3.765625
4
# input 1~999 (integar) # output sum of 'multiples of 3 and multiples of 5' # def multiple(n): # result = [] # for i in range(1, 1000): # if i % 3 ==0: # result.append(i) # return result # # multiple(3) = [3,6,9,cdots,999] #multiples of 3 # # multiple(5) = [5,10,15,cdots,995] #multiple...
1ff6579c2f16ce2d3de5faef366cf5cf0668d7df
hkh9715/pythonworkspace
/py4e/chapter_6/loop.py
158
4.03125
4
# word = 'banana' # index = 0 # while index<len(word): # print(index, word[index]) # index +=1 word = 'banana' for letter in word: print(letter)
6e641bf651291ae664e087700364519972df4d90
okiochan/skikits
/knn/knn.py
890
3.71875
4
import numpy as np import matplotlib.pyplot as plt import classification_map as Map import LOO from sklearn import neighbors, datasets def KNNski(x,k, X,Y, W='uniform'): # we create an instance of Neighbours Classifier and fit the data. clf = neighbors.KNeighborsClassifier(k, weights=W) clf.fit(X, Y) ...
42ca9138ca440fe622c0d1eb20c0affcec774705
Yuri-MRQ/l_dnn_model
/dnn_helpers_fn.py
13,484
3.546875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt # In[2]: def sigmoid(z): """ Compute the sigmoid of z Arguments: z -- A scalar or numpy array of any size. Return: s -- sigmoid(z) """ A = (1/(1+np.exp(-z))) cache = z ...
5a7827de66cd401b34124c16d80b766ed7ed0ca7
cs-learning-2019/python1contsat
/Lessons/Week14/click_and_destroy/click_and_destroy.pyde
1,531
3.859375
4
# Focus Learning: Python Level 1 Cont # Click and Destroy # Kavan Lam # Dec 19, 2020 x = [10, 100, 300, 600] y = [100, 300, 400, 700] direction = [1, -1, 1, -1] def setup(): size(900, 900) def draw(): global x global y global direction # Clear the previous frame bac...
8a3c1b7ae0d58cd1b3d7bbe41ba1cc2c684807d4
xhanak2/CodeWars-Python
/SecDuration.py
1,189
3.546875
4
def format_duration(seconds): #your code here sec=seconds y=0;d=0;h=0;m=0;s=0;comp=0 out='' if sec==0:out+='now' while sec>=31536000:sec-=31536000;y+=1 while sec>=86400:sec-=86400;d+=1 while sec>=3600:sec-=3600;h+=1 while sec>=60:sec-=60;m+=1 while sec>=1:sec-=1;s+=1 if y>...
3413f1c98777b330f45164b460bf154ab6dceb31
aashish-sapkota/assignment_II
/assignment_2.6.py
197
3.8125
4
# question 6 my_list = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow','Purple','Blue'] print (my_list) my_list.pop(0) my_list.pop(4) my_list.pop(5) print("the final result") print(my_list)
6e0cbb9fe62d213facd326ca8a1306d23e357a12
SyTuan10/C4T16
/Session5/intro2.py
138
3.609375
4
from random import randint x = randint(0,100) print(x) if x<30: print("Rainy") elif x<60: print("Cloudy") else: print("Sunny")
be9156be19f5a0851e2d85aa659e2d44e0f77b13
SyTuan10/C4T16
/Session11/store.py
434
3.65625
4
store={ 'HP': 20, 'DELL': 50, 'MACBOOK': 12, 'ASUS': 30, 'ACER': 25, } n= 0 # print('Số lượng MACBOOK có trong kho: ',store['MACBOOK']) # n= str.upper(input('Hãng máy tính: ')) # print('Số máy tính có trong kho là: ',store[n]) # store['TOSHIBA'] = 10 # store['DELL'] = 60 # store['MACBOOK'] = 2 sto...
4f8d3d96df00087153f0cd933b658c6ff538989a
SyTuan10/C4T16
/Session8/update.py
133
3.796875
4
items = ['Sport', 'Lol', 'Drama'] new_item = input("New : ") items.append(new_item) items[3] = 'Spider Man' print(*items, sep= ', ')
e6ce6e723ecb7daed9c46d57b816c136d98bf661
ievahaa/Izdruka
/uzdevumi/skol_uzd.py
840
4.1875
4
#Izveido funkciju, kura salīdzina saraksta pirmo un pēdējo skaitli: Ja pirmais skaitlis ir lielāks, nekā pēdējais, sarakstu izprintē atmuguriski, ja pēdējais skaitlis ir lielāks par pirmo, sarakstu izprintē normāli. def salidzini(saraksts): pirmais = saraksts[0] pedejais = saraksts[-1] if pirmais < pedejai...
f9f918485606f39abd198e7a5349a9001d739f0a
ievahaa/Izdruka
/uzdevumi/uzd_par_cikliem.py
3,721
3.90625
4
""" #uzd1 #Lietotājs ievada divus veselos skaitļus – intervāla galapunktus. Izdrukāt visus norādītā intervāla skaitļus, ieskaitot abus galapunktus.[a;b] #Papilduzdevums - ja norādīts nekorekts intervāls, tad izdrukā attiecīgu paziņojumu un liek ievadīt datus no jauna a = int(input("Ievadi sākuma skaitli: ")) b = int(i...
dd63fef5ba3c62a41c7f7ad6c730a365069ff2d9
DavidGilkeson/pforcs-problem-sheet
/squareroot.py
2,448
4.46875
4
# Author: David Gilkeson # Write a program that takes a positive floating-point number as input and outputs an approximation of its square root. # You should create a function called <tt>sqrt</tt> that does this. # I am asking you to create your own sqrt function and not to use the built in functions x ** .5 or math.s...
4e2a57aa9c5027f8157840fe90bc8ca3d6d8fa1c
DavidGilkeson/pforcs-problem-sheet
/plottask.py
1,492
4.28125
4
# Author: David Gilkeson # Write a program called plottask.py that displays a plot of the functions f(x)=x, g(x)=x2 and h(x)=x3 in the range [0, 4] on the one set of axes. # Some marks will be given for making the plot look nice. import numpy as np import matplotlib.pyplot as plt x = np.array(range(0,4)) fx = x gx ...
ce7219dc772170cc346b6c0f8103c93342e13bea
kongkongyi/MyPractice
/bubblesort.py
610
4.09375
4
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- import random def BubbleSort(num): tmp=0 swap_count=0 count=0 loop=len(num)-1 flag=False while loop>0: flag=False #print(loop) for j in range(loop): count += 1 if num[-1-j] < num[-1-j-1]: swap_count += 1 tmp = num[-1-j] num[-1-j] = num[-1-j...
93b59048c2d745591e3fbab5f7557ae0860b6513
kongkongyi/MyPractice
/number_cnt.py
649
3.609375
4
#!/usr/local/bin/python3 # -*- utf-8 -*- if __name__=='__main__': unit = ['个','十','百','千','万','十万','百万','千万','亿'] num = input("Plase input a number:").strip().lstrip('0') try: if isinstance(int(num), (int)): length = len(num) count = [0]*10 print("The length of the number is {}".format(length)) ...
c5a0a671f9f996e8cd87d4b7a2f366cff7fd8057
Nfrederiksen/PythonRep
/ML/UsingKeras2.py
2,409
3.515625
4
import pandas as pd from keras.models import Sequential, load_model from keras.layers import Dense from keras.callbacks import EarlyStopping # read in training data train_data = pd.read_csv("train.csv") # read the test data test_data = pd.read_csv("test.csv") # fill in missing values with 0 train_data.fillna(0, inpla...
97df3714ccd7223d92f945176152c249a065bf4e
Nfrederiksen/PythonRep
/ML/DoesThisFindKLargest.py
1,313
3.515625
4
class Solution(object): def findKthLargest(self, arr, k): left = 0 right = len(arr) - 1 while left <= right: pivotIndex = self._partition(arr, left, right) if pivotIndex == len(arr) - k: return arr[pivotIndex] elif pivotIndex > len(arr) - k...
c3a4998e2630bb6eb1d2503906648837a6a82a0b
abdelrahmanna/Cryptography-Ciphers
/Classical Ciphers/Caesar Cipher/python/Caesar Cipher.py
1,153
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 26 19:48:28 2019 @author: Abd-Elrahman """ #file handeling class from fileIO import FileIO class CaesarCipher: def encrypt( self, string, step): incryptedString = "" for i in string: if(i.isalpha()): incryptedS...
7b485584ec97adc0d5a0eb4d506006563f697cf2
SieniAlessandro/E2E-Secure-Chat
/Server/Database/Database.py
10,782
3.828125
4
import pymysql class Database: #In the init function the class try to establish a connection with the database, in order to allows #the programmer to modify the information stored in the database using the methods offered by this class def __init__(self,_host,_port,_user,_password,_db): """ ...
dc9ecd41ec3cce69fe0c1c08db06b41e5aaa0083
Vale-Mais/birthdays
/testing.py
1,861
3.609375
4
""" This module tests all the functions in the package """ import unittest import checker as c import adding as a import pandas as pd import csv class TestName(unittest.TestCase): @classmethod def tearDownClass(cls): db = pd.DataFrame(pd.read_csv('people_birthday.csv')) index = db.loc[db["Per...
77135d71ab7740786839151ffe97bd8287f98c1f
RachelA314/Aboutme
/DataVisualizationProject/greater_than.py
555
4.5
4
list = [2,5,6,3,8,12,1,9] #list of numbers list2 = [] #empty list for greater numbers #for loop to go through list and find numbers greater than 5 for i in list: if i >= 5: #numbers 5 and > added to list with append list2.append(i) print(list2) #prints list2 of greater numbers #sum...
bc4402c732907f7e6c2ee6f3206a0393ec5f3548
RachelA314/Aboutme
/python/function.py
658
3.953125
4
'''def is_even(num): if num % 2 == 0: return True else: return False is_even(6) print(is_even(10)) list = ["7", "11", "18", "5"] a = 7 b = 11 c = 18 d = 5 def calc_total(): sum = a+b+c+d print(sum) calc_total()''' #Declare a dictionary with known values '''spanish_english ={ 'hola'...
58b1042259f62be619db35071e8b4d46cdcf707f
eskay101/area.py
/kc1.py
194
3.75
4
a = int (input ( ' enter value for A :')) b = int (input ( ' enter value for B :')) c = int (input ( ' enter value for C :')) d = float ((- b + 4 * a * c )/ 2 * a) print ( ' answer = ' , d )
903ea0cec44a6b81aed2b5a7ee606e904b0cc18c
lucaseduardo101/MetodosII
/Diferenciação Numérica /Parte 2/main.py
1,158
3.6875
4
import sys import leitura import derivada2 arq = sys.argv[1] l = leitura2.ler(arq) i=l[0]#recebe o numero da funcao escolhida h=l[1]#recebe o valor de h -obs: vai ser uma posicao do vetor simples,ajeitar isso x=l[2]#recebe o valor de x onde a funcao deve ser diferenciada -obs:ajeitar isso #n=4#numero de pontos a se...
a9af433e8ecd88c6807dac0ae7b5492a64b14062
kayartaya-vinod/2018_10_PHILIPS_PYTHON
/Examples/ex14.py
1,885
3.765625
4
class Person(object): def __init__(self, **kwargs): self.name = kwargs.get('name') self.email = kwargs.get('email') self.phone = kwargs.get('phone') self.age = kwargs.get('age') self.city = kwargs.get('city', 'Bangalore') # print('from inisde of Person.__init__') ...
44d6f549d51054c49700309e1f5c9da779b331bb
kayartaya-vinod/2018_10_PHILIPS_PYTHON
/Examples/ex03.py
536
3.5
4
from myutils import factorial def main(): num = input('Enter a number: ') num = int(num) fact = factorial(num) print('Factorial of {} is {}'.format(num, fact)) # print('Name of this module is ', __name__) # When you import this module, the value of __name__ is 'ex03' # When you execute this scri...
502622223d610ed9604b4f57ea66a379857d7698
eraserpeel/Project-Euler
/problem_4.py
484
3.90625
4
def is_palindrome(string): str_length = len(string) - 1 for i in range(0, str_length): if string[i] != string[str_length - i]: return False return True def main(): max_product = 0 for number1 in range(999, 99, -1): for number2 in range(number1, 99, -1): product_as_str = str(number1 * number2) if n...