blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c77f712d6f3884cf359c38910c9fbf7f6fe4d05c
AugustoDipNiloy/Uri-Solution
/Python3/uri1017.py
232
3.59375
4
class Main: def __init__(self): self.a = int(input()) self.b = int(input()) def output(self): print("%0.3f" % ((self.a * self.b) / 12)) if __name__ == '__main__': obj = Main() obj.output()
59461ccc175dee4e08e714548d4e4f129ba23239
bheki-maenetja/small-projects-py
/courses/python_data_structures_queues/Exercise Files/Ch02/02_03/End/stacks.py
515
4.1875
4
class Stack: def __init__(self): self.items = [] def push(self, item): """Accepts an item as a parameter and appends it to the end of the list. Returns nothing. The runtime for this method is O(1), or constant time, because appending to the end of a list happens in con...
37e4139ffdc1d85f026e44e48c05a60b2babc642
caspd3v/Python-Calculator
/main.py
940
4.21875
4
import sys #Print the help menu print(''' Calculator App --------------- a -> Add/+ s -> Subtract/- m -> Multiply/* d -> Devide// --------------- By CaspD3V ''') #Number Variable int1 = int(input("Number 1: ")) #Choose Addition, Subtraction, Multiplication, or Devision choice = input("a, s, m, or d: ") #Number Variabl...
f8ad168010da0b1ccd8d2013d45139cc2968eb62
Lolita88/BioinformaticsAlgorithms
/Python/Bioinformatics/BeginningBioinformatics/ApproximatePatternMatching.py
782
3.640625
4
def ApproximatePatternMatching(Pattern, Text, d): positions = [] # initializing list of positions #for every i in the range of 0 to length of text: if (call function) Hamming Distance with parameters (slice Text from i to length of pattern, pattern) is less than or equal to d: postions.append[i] for i...
de17b0f171a03809acd6ad7ddf4fc7b0d15d4244
eduardoramirez/adventofcode
/2019/day3/day3.py
1,943
3.59375
4
import math INPUT = open('input.txt', 'r').read().split() wire_directions = list(map(lambda l: l.split(','), INPUT)) def create_points(directions): all_points = [(0, 0)] for d in directions: steps = int(d[1:]) (x, y) = all_points[-1] if d.startswith('R'): points = [(step_x...
eca5db6ebf6e92768a8a89d86857a12a5537dbed
AnansiCoding/Macchanger
/mac.py
13,116
3.796875
4
#!/usr/bin/env python3 # This Program has almost all the features of mac changer in terminal # Christopher Valdez # August 23, 2018 # mac.py version 1.0 #To do list #[1] find a way to internally find computer's wifi and ethernet names to get rid of user input import sys import os import time import dialogue from ad...
051ea04aaa0f1eeb520645c2eef1560241dd1386
odgiedev/python-cev
/PythonCeV/ex102.py
534
3.71875
4
def fatorial(num=0, show=False): """ ver o fatorial de um numero. parametro 'num': o numero que vc quer o fatorial; parametro 'show': se vc quer ver a conta; return: o valor do fatorial do num(que foi passado). """ f = 1 for c in range(num, 0, -1): f = f * c if ...
ad930443e80c01089e720230f04de34a58d3dec4
Astony/Homeworks
/homework2/task01/text_func/fill_weight_list.py
598
4.125
4
def fill_word_weight_list(list_of_words, dict_of_chars_count): """Since we counted the number of repetitions of chars, and we have a list of all words, we will replace each char in the word with its number of repetitions, which represented its uniqueness, and then add these values and get the weight ...
e66f0915f85642425415ef7e41854ac782e78e26
MaroderKo/Labs
/Lab10/1.4 Iterable.py
778
3.640625
4
""" 1. Сформувати функцію для введення з клавіатури послідовності чисел і виведення її на екран у зворотному порядку (завершаючий символ послідовності – крапка) Виконав: Перепелиця А.С. """ from datetime import datetime a = list() j = input() # ввод начальных значений значений start_time = datetime.now() # Нача...
f112f8b14f10ebec36ff6a241e16856da277524c
AlelksandrGeneralov/ThinkPythonHomework
/tuples_sort.py
532
3.5
4
import cProfile import pstats def sort_by_length(): """sort a words by len1""" t = [] words = open('words.txt') for word in words: line = word.strip() t.append((len(line), line)) t.sort(reverse=False) res = [] for length, line in t: res.append(line) return(res...
b6f986bd31f92954abfcba100f6871213879a9a3
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/dngmon002/question3.py
240
3.9375
4
import math p=0 prox=2 nxt=0 while nxt!=1: p=math.sqrt(2+p) prox*=2/p nxt=2/p print("Approximation of pi:",round(prox,3)) radius=eval(input("Enter the radius:\n")) area= prox*(radius**2) print("Area:",round(area,3))
1da3970bd09e1f08d9288d99c9930f32c9322f52
FReeshabh/sarraf-machine-learning-class
/project_5/Project5.py
4,882
3.796875
4
import numpy as np import matplotlib.pyplot as plt np.random.seed(137) # # PART 1 - 2 layered Neural Network with 2 hidden Units # -1, as inputs, gave funky results so switched it out for 0's def PART_1(): INPUT_UNITS = 2 HIDDEN_UNITS = 2 OUTPUT_UNITS = 1 C_INPUT = np.array([[0, 0], [0, 1], ...
bc96a2a4c9b837f689864113810e71413a136bf2
zhulijuan1128/1128
/私有属性.py
466
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 9 16:10:43 2020 @author: tute """ #class_student.py class Student: def __init__(self,name,age): self.name=name self.__age=age def say(self): return self.name def getage(self): return self.__age ...
2d7ef57ce631879d49c000dc239eead5faf0566b
Naateri/JustForFun
/DataStructures/R-Tree.py
3,882
3.546875
4
class Coord: #coordinates def __init__(self, x, y): self.x = x self.y = y class Objct: def __init__(self, data, lower, upper): self.data = data self.ll = lower self.ur = upper self.type = 1 class BBox: #bounding box def __init__(self, lower, upper): ...
280abf36cef0ba80bf0a238498b8676299c52764
ConnorLeeJones/cons_coding_challenge
/main/flag.py
1,125
4.625
5
# Jump The Flag # A Kangaroo, is trying to reach a flag that's flagHeight units above the ground. # In his attempt to reach the flag, the kangaroo can make any number of jumps up the rock wall where it's mounted; # however, he can only move up the wall (meaning he cannot overshoot the flag and move down to reach it). #...
4c933228c8e655bc7ec70f48ae821c6e6288c37c
RomanAdriel/AlgoUnoDemo
/Bili/UTN_Unidad_2/ejercicio_3.py
1,082
4.46875
4
# Ejercicio 3 # Cree un diccionario con las claves: #· identificador #· nombre #· apellido #· telefono #Nota: al utilizar claves no utilice acentos u # otros caracteres en español, por ejemplo no # ponga “teléfono” sino “telefono”. #Realice un programa que a partir del # diccionario creado retorne en una oración: #...
22ef4070e49acd4e3ce95e4821047e5548b6b9f9
pharaon1815/math_functions
/division.py
633
3.984375
4
# Error handling practice def quotient(): # define quotient function response = input('Do you need help with division? (y/n): ') while response == 'y': # loop to continue asking try: n = input('numerator: ') # input numerator d = input('denominator: ') # inp...
3f5a55ea2f7bccf348d3257c9c668063b68d43c4
rafaelperazzo/programacao-web
/moodledata/vpl_data/40/usersdata/106/24720/submittedfiles/funcoes.py
1,338
3.734375
4
#ARQUIVO COM SUAS FUNCOES # -*- coding: utf-8 -*- from __future__ import division #Estabelecer a função valor_absoluto para comparar o valor do cosseno com o epislon def valorabsoluto(x): if x>=0: valorabsoluto = x else: valorabsoluto = x*(-1) return valorabsoluto #calculo do valor de pi d...
1dfb76eb98c50de8b7511d53219a856ce6d8d5da
ConstanceBeguier/tensorflow-examples
/2_manage_overfitting.py
3,606
3.875
4
#!/usr/bin/env python3 """ TensorFlow code to learn the following network on the MNIST database [28, 28, 1] -> Conv2D(30, (5, 5), relu) -> MaxPooling(2, 2) -> Conv2D(15, (3, 3), relu) -> MaxPooling(2, 2) -> Flatten -> Dense(128, relu) -> Dense(50, relu) -> Dense(10, softmax) Early stopping and regularizers are used to...
8827a7b1690357f40922e0b77574b0d16489351e
GabrielCB1/StructuredProgramming2A
/unit1/Codes/one.py
385
3.875
4
num = int (input("Join your number:... ")) def evaluar_primo(num): contador=0 resultado=True for i in range (1, num+1): if (num%i==0): contador +=1 if (contador>2): resultado=False break return resultado if (evaluar_primo(num)==True): print("Th...
85bbc85f0cb8dea5a52e02beae92303b113cbec1
karleypetracca/week-1-python-exercises
/dict-name-to-number.py
615
4.46875
4
# Series of basic dictionary exercises with given dictionary # Print Elizabeth's phone number. # Add an entry to the dictionary: Kareem's number is 938-489-1234. # Delete Alice's phone entry. # Change Bob's phone number to '968-345-2345'. # Print all the phone entries. phonebook_dict = { 'Alice': '703-493-1834', ...
957559b306fe090effe9d4cb7d5dc5471a7445ab
mycho2003/TIY
/6/6-6.py
353
3.671875
4
favorite_languages = {"jen": "python", "sarah": "c", "phil": "python", "edward": "ruby"} pollers = ["michael", "phil", "josh", "ben", "jen"] for poller in pollers: if poller in favorite_languages: print("Thank you for responding to the poll, " + poller.title() + "!") else: print(poller.title() ...
6c384deeebd011fb078c897832aea41747f9adb3
season101/PasswordEncrpyter
/test.py
717
4.03125
4
print("Welcome to the program where we will encrpypt your passowrd in image for you.") print() print("Press any key to continue...") input() print() print() masterKey = input("Enter a key that you want to use throughout your lifetime: ") imageName = input("Enter the image name you want to put password to: ") output...
bbcba63fc120e7d6e237804e5a64e4a1ef7ff41c
JoeMaurice88/testayed2021
/Unidad 3/ejercicio6.py
306
3.875
4
""" Determinar si una persona tiene fiebre. (fiebre : 37.5 grados) o tiene menos de 30° y sino esta sano """ temperatura= float(input("Ingrese su temperatura: ")) if temperatura>= 37.5: print("tiene fiebre") elif temperatura<= 30: print("tiene baja temperatura") else: print("Estas sano")
95e025f9c688a41e505e037bd4c7e188b82e8655
RoxanaTesileanu/Py_for_kids
/py_for_kids_ch5.py
5,038
4
4
Python 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] on linux2 Type "copyright", "credits" or "license()" for more information. >>> # questions = conditions >>> # we combine these conditions and the responses into if statements >>> >>> age= 13 >>> if age> 20 : print ('You\'r too old') >>> age=23 >>...
1cf1b29b66e158ece7739ca5c9bc31c39f35deff
asethi-ds/Algorithm-Toolbox
/binary_search/first_occurence.py
814
3.9375
4
def findFirst(arr, a): """ Unlike binary search, cannot return in the loop. The purpose of while loop is to narrow down the search range. Can combine two conditions: `arr[m] >= a` """ if not arr: return -1 l, r = 0, len(arr) - 1 # exit loop when l + 1 == r, i.e. consecutive while l + 1 < r: # av...
6ddd82dfe0eacffb84221bf3d1c5d0d25c90e949
rabi-siddique/LeetCode
/Arrays/MedianOfTwoSortedArrays.py
779
4.15625
4
''' Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. Follow up: The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input...
72df9cd5936d7bd80abd4316ffd3a1c9d7515e08
avinsrid/Hangman
/hangman.py
1,898
3.890625
4
#!/usr/bin/env python # blitzavi89 # ---------------------------------------------------------------- # SIMPLE HANGMAN GAME WITH GUI (Python 3.x) # ---------------------------------------------------------------- from Hangman_GUI import * import random import json import tkinter # Begin the Game Here def Begin_Game...
d5ff4d04602f58c0dc5a539d5a1abb759e2f365c
rlyyah/2nd-self-instructed-week
/code/trying-out/strings.py
240
3.65625
4
word = 'tomek' for i in range(-1,-len(word)-1,-1): print(word[i]) print(word[1:4]) print(word[-4:-1]) print(word[::-1]) print(word[0:len(word):2]) print(word[1:len(word):2]) print('format-=====') print(word+ '{}'.format('kappa'))
fca0f9ad72989f88ec599b65b84b1046b63dd55a
zhlthunder/python-study
/python框架/flask/补充:对象的内置方法.py
1,017
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #author:zhl class Foo(object): def __add__(self, other): return 123 obj1=Foo() #当执行: obj1+2 #就会自动执行obj1的__add__方法,就和 ‘对象()’ 会自动执行对象的__call__方法一样,也是一个语法糖 #上面的2可以看成是int类的一个对象,所以 两个对象相加时也一样会调用这个方法 obj2=Foo() v=obj1+obj2 print(v) #输出 123 class Foo(object): ...
6908e6bd68cc725f00502d017f6f0fece2e2b069
DanThePutzer/tars
/2-12-Linear_Regression/6-Pickling_And_Scaling.py
627
3.53125
4
import pandas as pd import numpy as np import pickle from sklearn import preprocessing, model_selection from sklearn.linear_model import LinearRegression from matplotlib import pyplot as plt # Importing model from pickle pickle_in = open('Data/GoogleStockClassifier.pickle', 'rb') clf = pickle.load(pickle_in) # Impor...
83a22251f0766fd285a337548eaf486f334f59bc
gautambp/codeforces
/509-A/509-A-46916805.py
157
3.671875
4
n = int(input()) def getMatrixVal(i, j): if i == 1 or j == 1: return 1 return getMatrixVal(i-1, j) + getMatrixVal(i, j-1) print(getMatrixVal(n, n))
0149a9129fb64d7bc2ceb246956ab2d036dc0e7f
Yfke/AoC2020
/15/15a2.py
848
3.5
4
import time test1 = [0, 3, 6] input = [15, 12, 0, 14, 3, 1] def main(): start_time = time.time() start = input history = [-1] * 30000000 # initialize fixed input (but skip the last one) # -1 signifies "this value hasn't occurred yet" for i in range(len(start) - 1): history[start[i]] ...
f026cea4a1e8284b8228b54e26e531ac339cc6b5
Ichbini-bot/python-labs
/13_list_comprehensions/13_06_SLT.py
281
3.765625
4
letters = [i for i in "codingnomads"] print(letters) letter = [] for char in 'CodingNomads': letter.append(char.lower()) print(letter) class MyCustomException(Exception): pass try: raise MyCustomException("There was a problem") except Exception as e: print(e)
74b439f7675086d2c0b70a8bcdecde4acd17d6a5
xandrd/CourseraPhython
/week4/module4/solution_summa.py
109
3.671875
4
def summa(a): if a != 0: a += summa(int(input())) return a a = int(input()) print(summa(a))
5d83dc0f354d12718b5ae1c879c8b4b169c508e5
alexwei316/SortPractice
/SortPractice/bruteForceSort.py
317
3.578125
4
__author__ = 'WEI' def brute_force_sort(A): for p in range(len(A)): brute_force_sublist_sort(A, p) return A def brute_force_sublist_sort(A, p): for i in range(p + 1, len(A)): if A[i] < A[p]: swap(A, i, p) def swap(A, i, j): temp = A[i] A[i] = A[j] A[j] = temp
a0d23de90fdab5aa7e3ecaf0cd0eee4ad024d7dc
pns845/Selenium
/listof.py
854
3.640625
4
#to find all the tags are present or all buttons are present #finding multiple elements from selenium import webdriver from selenium.webdriver.common.by import By class FindList(): def test(self): baseURL="https://learn.letskodeit.com/p/practice" driver=webdriver.Chrome(executable_path="C:\\U...
91fe273774cdf2abc109f852d2ce6cce19639260
yzl232/code_training
/mianJing111111/Google/Given N dices.Each dice has A faces.That means each dice has numbers from 1 to A.Given Sum S,Find the number of ways to make the sum S if dices are rolled together..py
2,192
3.921875
4
# encoding=utf-8 ''' Given N dices.Each dice has A faces.That means each dice has numbers from 1 to A.Given Sum S,Find the number of ways to make the sum S if dices are rolled together. ''' #http://www.geeksforgeeks.org/dice-throw-problem/ ''' Given n dice each with m faces, numbered from 1 to m, find the number of w...
4c6f96f009bd105216be5f59051f491c63976588
ishchow/alexa_chess
/flasks/classdef.py
7,652
3.859375
4
from itertools import product class Board: """The game board. Contains information about: locations of chess pieces number of active pieces x-axis: a-h y-axis: 1-8 """ def __init__(self): self.board = {(x,y):None for x in range(8) for y in range(8)} self.pieceC...
2c4b4b25d19e504d43c5c623a9ddabcbaf394131
gits00/MachineLearning
/Homework/HW12/KMeans.py
1,356
3.671875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 15 15:18:38 2020 @author: digo """ import matplotlib.pyplot as plt import numpy as np # import KMeans from sklearn.cluster import KMeans #Reading File ##Train data f_train = open('training_set.txt', 'r') data = f_train.read() f_train.close() data_train = data.split() d...
5efd98152a534c3aaab472cf094c5d0499ad403e
juank27/Python
/intermedio/f_orden_superior.py
497
3.875
4
#funciones de orden superior def saludo(func): func() def hola(): print("Hola!!") def adios(): print("Adios!!") saludo(hola) saludo(adios) # uso con filter my_list = [1,4,5,6,9,13,19,21] odd = list(filter(lambda x: x%2 !=0, my_list)) print(odd) #uso con map my_list2 = [1,2,3,4,5,6] squares = list(map(lamb...
e01712481aae9f2c4b78f9989ceb374fa12d7fde
jaroslaw-wieczorek/SI-Numbrix-Game-and-SAT-Problem
/board/cell.py
766
3.53125
4
import sys from os import path class Cell(): """ ID is the value representing the cell |1||2||3| |4||5||6| |7||8||9| """ def __init__(self, ID, value): if type(ID) != int: raise TypeError("TypeError: ID") elif ...
0dd0e7ddba42d63680229c3b64bdeafcfeda48b5
meznak/advent-of-code-2020
/aoc2020/day08/__init__.py
2,652
3.75
4
''' Advent of Code Day 08 Handheld Halting ''' SAMPLE_SOLUTIONS = [5, 8] class Instruction(object): '''A single instruction nop - No operation acc - Add value to accumulator jmp - jump to instruction at offset ''' def __init__(self, code: str, value: int): self.code = code sel...
6cd6051345f5604a830415b808f4756eb941728f
jzhangfob/jzhangfob.csfiles
/CS313e/Blackjack.py
8,205
3.78125
4
# File: Blackjack.py # Description: Create a program that will stimulate one round of blackjack between the player and the dealer # Student's Name: Jonathan Zhang # Student's UT EID: jz5246 # Course Name: CS 313E # Unique Number: 50940 # # Date Created: 9/21/2016 # Date Last Modified: 9/23/2016 im...
879db25fc729b0e70249046bc094dec30c3ff804
lawieXhoiger/PythonNotes
/MultiThreading/Global_Interpreter_Lock.py
725
3.515625
4
import threading from queue import Queue import copy import time # test gil def job(l,q): res = sum(l) q.put(res) def multithreading(l): q = Queue() threads = [] for i in range(4): t = threading.Thread(target=job,args=(copy.copy(l),q),name='T%i'%i) t.start() threads.append...
0f823b49bdfbf438e55d90e6ba23003e4e8b2569
local80forlife/CollegeClasses
/Barton_wk8_homework - Copy.py
2,761
3.734375
4
#Characters: 65 #Letters: 32 #Consonants: 21 #Digits: 22 #spaces: 2 #Word Characters: 4 #Punctuation: 5 def main(): try: userInput = "C:/Users/v-bartan/OneDrive/College/data.txt" except: print("ERROR: Unable to load file, please try again") userFile = open(userInput...
a1d4fc6ba7f6ecb980a8555a76cc84465ce0f689
Automedon/Codewars
/8-kyu/Merging sorted integer arrays (without duplicates).py
267
3.984375
4
""" Description: Write a function that merges two sorted arrays into a single one. The arrays only contain integers. Also, the final outcome must be sorted and not have any duplicate. """ def merge_arrays(first, second): return sorted(list(set(first + second)))
5805d9b9b0e997562965ad87f76c953ab82a8c41
PBiret/AdventOfcode2019
/day6/puzzle1.py
1,776
3.625
4
import numpy file = open("C:/Users/Pierre/Documents/AdventCode2019/inputs/day6.txt","r") input = file.read().splitlines() def list_planets(input): planets_list=[] for orbit in input: planets=orbit.split(")") for planet in planets: if not(planet in planets_list): plan...
d944d1cea2d5c0b82e87db6a7704f37fadd3dc8f
EssamEmad/Middle-In
/huffman/main.py
4,859
3.5625
4
from huffman_node import HuffmanNode from heapq import heappop, heappush from binary_io import BinaryWriter import binascii import struct import argparse def build_freq_dict(filename, is_binary): """ calculates freq of each character in a file and store the result in a dictionary :param filename: input...
32dfcbe151af9a677d321800a6d72775fff03665
AlexisDongMariano/miniProjects
/email_phone_extractor.py
3,513
3.765625
4
''' Date: Jun-26-2020 Platform: Windows Description: Copy text from any source and this script will extract the phone numbers (000-000-0000) and email (username@domain.com) then place in the clipboard to be pasted in text editor or same form. Sections: A-D (Working code located in Section C) ''' #########...
61c836185b3855af1bc678dec6bcfb8061818444
nabeel-m/python_hardway
/ch01/ex2.py
523
3.828125
4
cars=100 space_in_car=4.0 drivers=30 passengers=90 car_not_driven=cars - drivers cars_driven=drivers carpool_capacity=cars_driven * space_in_car average_passengers_per_car=passengers / cars_driven print("there are",cars,"available") print("there are only ",drivers,"available") print("there will be ",car_not...
6ebff97a8c43ab708731a33561a74c7173b9782e
malanb5/srt_parser
/srt_parser.py
14,050
3.640625
4
#!/usr/bin/python """ quick parsing script for parsing srt subtitle files to a full transcript Author: Matthew Bladek """ import pysrt, argparse, sys, logging, subprocess, os, yaml import Utils.Quiet_Run # init logger logging.basicConfig() logger = logging.getLogger('logger') def is_language_file(file, language): ...
33071d645521e331b3125c6947913c3646b03299
bry012/DataStructures
/Lab8/Lab 8/sorts/selectionSort.py
754
3.8125
4
def selectionSort(alist): # Loop for the total number of passes (n-1) # Each pass will generate a decreasing passnum for the next loop for fillslot in range(len(alist)-1,0,-1): # Create variable to hold where the position is positionOfMax=0 # Loop through the correct items for the pa...
2e29e38bbcbcc07dd628bbb1332d0dae7ca0b2d5
scar86/python_scripts
/examples/testGetKeys.py
1,075
4.5
4
'''Test the function to extract keys from a format string for a dictionary.''' def getKeys(formatString): '''formatString is a format string with embedded dictionary keys. Return a list containing all the keys from the format string.''' keyList = list() end = 0 repetitions = formatString.c...
d2003fb7ab532464c94928cf64bc6ab863f66dc6
Noronha1612/wiki_python-brasil
/Estruturas de repetição/ex41.py
952
3.8125
4
from functions.validação import lerFloat, lerInt from functions.visual import formatDinheiro from time import sleep divida = lerFloat('Valor da dívida: R$', pos=True, erro='Digite uma quantia válida') if divida == 0: print('Nenhuma dívida registrada') print('Programa encerrado') exit() while True: par...
8e40aafccc4500bb7743087fc95331db8bd22067
dingwengit/Code_practice
/Python/string/sentence_break.py
966
3.671875
4
# given a string, print out all possible words that make up the entire string # e.g., s = "onpinsandneedles" # result: # ['on", "pin", "sand", "needles"], # ['on", "pins", "and", "needles"] dictionary = ["on", "pin", "pins", "and", "sand", "needles"] def sentence_break(s, res): if s == '': print(res) ...
dc5fbca4672b4fcf6d216e48d2e4781fbe1540c4
Knniff/python-vorkurs
/Uebung08/Aufgabe2.py
1,039
4.1875
4
def chiffre(input: str, key: int, direction: str) -> str: input = input.lower() output = "" if direction == "encrypt": for letter in input: if letter.isalpha(): temp = ord(letter) temp = temp + key if temp > 122: temp_ke...
be3ff677381a2d6b3706f179d96b9d4000c94c26
noveljava/study_leetcode
/completed/137_single_number_2.py
447
3.515625
4
from typing import List class Solution: def singleNumber(self, nums: List[int]) -> int: from collections import defaultdict result = [] count = defaultdict(int) for i in nums: count[i] += 1 if count[i] == 1: result.append(i) elif c...
602fc18177762b632c2613e49078b22ab9ba981c
mathans1695/Python-Practice
/Own Python Module/gameoflife.py
911
3.625
4
from life import LifeGrid INIT_CONFIG = [(0,0), (0,1), (1,0), (1,2), (3,2), (3,4), (5,4), (5,6), (7,6), (7,8), (9,8), (9,10), (11,10), (11, 12), (12, 11), (12,12)] GRID_WIDTH = int(input("Enter grid width: ")) GRID_HEIGHT = int(input("Enter grid height: ")) NUM_GENS = int(input("Enter the num of generations: ")) de...
5850dc6375d0bc9deb12bc2601b6c0d19f76db1f
JMW0503/CSCI_4
/Lotto.py
586
3.6875
4
""" Lotto Number Gen Author: Justin Wilson Date Created: 9/12/2019 Description: Outputs five (5) numbers, each number ranging from 1-47 """ import sys import random randomNumber = random.randint(1,47) randomNumber2 = random.randint(1,47) randomNumber3 = random.randint(1,47) randomNumber4 = random.randi...
aefdf57f94b3b671dd431ed3d9571a975ec2a335
SakuraGo/leetcodepython3
/PythonLearning/fourteen/c5.py
1,437
4.09375
4
##可迭代对象 ## 列表、元组、集合 ## for in # for in iterable # 对象 class class Book: pass ##把一个类变成可迭代的.. ##迭代器 # Iterator ##一组书 class BookCollection: def __init__(self): self._data = ["《往事》","zhineng","huiwei"] self.cur = 0 def __iter__(self):##需要实现这两个函数,就能把这个类变成可迭代的。 return self def __ne...
d4d714b783a8d8ed3762798b6dedcd6e58465977
MrAlekzAedrix/MetodosNumericos
/data.py
122
4
4
name = input('Whats your name? ') age = int(input('Whats your age? ')) print('Hi!', name, 'you are', age, 'years old')
dc23022392afad671741b7df896a7a3e793c4947
yeasy/code_snippet
/python/regex.py
171
3.515625
4
#!/usr/bin/python #-*- coding: utf-8 -*- import re regex = re.compile('[a-z]{10}') t1 = re.match(regex,'1234567890') t2 = re.match(regex,'abcdefghij') print t1 print t2
cf3d5e9ae92e0692a4395e048c489fc93c0e14f0
bwoodru87/SQLAlchemy_Homework
/hawaii_bw.py
4,636
3.625
4
# Import my dependencies import numpy as np import sqlalchemy from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session from sqlalchemy import create_engine, func from flask import Flask, jsonify # Create our engine, connecting it to the assigned sqlite database engine = create_engine...
cccb78c3947720bbc99661ab20ac2d5e3f434cdc
burakbayramli/books
/Introduction_to_Python_for_Econometrics/Python_introduction_solutions/logical_operators_and_find_solutions.py
1,724
3.953125
4
"""Solutions for 'Logical Operators and Find' chapter. Solutions file used IPython demo mode. To play, run from IPython.lib.demo import Demo demo = Demo('logical_operators_and_find.py') and then call demo() to play through the code in steps. """ # <demo> auto from __future__ import print_functio...
b195259246424078508425061224a3d2283a4ae5
OldTruckDriver/Chexer
/ChexerBattle/Chexers-master/random_player/utils.py
1,705
3.640625
4
# The minimum and maximum coordinates on the q and r axes MIN_COORDINATE = -3 MAX_COORDINATE = 3 # Delta values which give the corresponding cells by adding them to the current # cell MOVE_DELTA = [(0, 1), (1, 0), (-1, 1), (0, -1), (-1, 0), (1, -1)] JUMP_DELTA = [(delta_q * 2, delta_r * 2) for delta_q, delta_r ...
abd686c671e269973e862b7ff6382b2924aeb10c
nikisix/classes
/examples/python/groups_of_lists-naive.py
428
3.84375
4
''' i have a list a = [1, 2, 3, 5, 2] i need to group these list elements to where they are in groups that their sum `<= 5` ie; this would produce myNewList = [[1,2,2], [3], [5]] ''' a = [1, 1, 2, 3, 5, 2] a = sorted(a, reverse=True) target = 5 #"target val" result = [] f=lambda x: x<=target t = [] for i in a: ...
38b51be998f199f8f47f44a181eed6c32a143b48
mcxu/code-sandbox
/PythonSandbox/src/misc/powerset_subsets.py
3,619
4.25
4
''' Powerset Function that takes array of unique integers, and returns powerset. Powerset of set X, P(X), is set of all subsets of X. Sample input: [1, 2, 3] Sample output: [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] ''' class PS: """ Time complexity: O(n!*n): get permutations ...
6518ae0ce6d8e6dbc5287af9c15aa31035b3a884
WilliamQLiu/python-examples
/algorithms/insertion_sort.py
785
4.40625
4
""" Insertion Sort """ def insertionSort(mylist): for index in range(1, len(mylist)): print("Index is ", index) # 1, 2, 3, 4, 5, 6, 7, 8; this is the outer loop # setup first case (only one item) currentvalue = mylist[index] position = index # this is the inner loop, loop...
0386db2baac8bdec271f15928ba0a5c699ed1a0a
bitfun-eu/ARLM-mpy-tinybit
/voice_control.py
1,478
3.703125
4
# Add your Python code here. E.g. from microbit import pin1, sleep from tinybit import run def listen(level=100, duration_ms=1000, speed=70, wait=300): noise = pin1.read_analog() if noise > level: run(speed, speed) sleep(duration_ms) run(0, 0) sleep(wait) while True: listen() # Qu...
f196cdc37d85d6030ebd2f5c05822e12a1f52cbd
johnkmur/Battleship
/main.py
15,682
3.671875
4
#! /usr/bin/python # John Murphy # Coatue Coding Challenge # Types of ships with their abbreviations as well as their length. ship_list = {"carrier":['5', 'C'], "battleship":['4', 'b'], "submarine":['3', 's'], "cruiser":['2', 'c'], "destroyer":['2', 'd']} # Player...
0d4c91a22a4e4f9822d773ac2d701ee7f1d6b0e9
mynameischokan/python
/Strings and Text/1_13.py
865
4.03125
4
""" ************************************************************ **** 1.13. Aligning Text Strings ************************************************************ ######### # Problem ######### # You need to format text with some sort of alignment applied. ######### # Solution ######### # For basic alignment of strings,...
f56b7728d9dd9677b8bb498a9c679e1961da4bdc
Adomkay/sql-intro-to-join-statements-lab-nyc-career-ds-062518
/sql_queries.py
933
3.515625
4
# Write your SQL queries inside the strings below. If you choose to write your queries on multiple lines, make sure to wrap your query inside """triple quotes""". Use "single quotes" if your query fits on one line. def select_hero_names_and_squad_names_of_heroes_belonging_to_a_team(): return "SELECT superheroes....
bfb87251e8500338aa182edcdf96940323f10770
DevinTyler26/learningPython
/mvaIntroToPython/if-else.py
315
4.125
4
g = 9 h = 8 if g < h: print('g < h') else: if g == h: print('g == h') else: print('g > h') name = 'Devin' height = 2 weight = 110 bmi = weight / (height ** 2) print('bmi: ') print(bmi) if bmi < 25: print(name) print('is not overweight') else: print(name) print('is overweight')
afeb98a626530d7aa205909b49df3c9cc32104db
JunyoungChoi/programmers
/K번째수.py
231
3.53125
4
def solution(array, commands): answer = [] arr = [] for i in range(0,len(commands)): arr=array[commands[i][0]-1 :commands[i][1]] arr.sort() answer.append(arr[commands[i][-1]-1]) return answer
4e811e34951024d6ad626c7e5b8091d1e5ac6ba0
srvasquez/TareaBuda
/dijkstra.py
1,636
3.640625
4
def insert_open(open_queque, visited, station): distance_new_station = visited[station]['distance'] for i in range(len(open_queque)): compared_station = open_queque[i] distance_station = visited[compared_station]['distance'] if distance_station and distance_new_station <= distance_statio...
6267db4390d60165430bf4ea2d3c8043534ae8e3
timkao/Tim-Python-Codes
/findNextPerfectSquare.py
377
3.59375
4
# identify if the given number is a perfect square number # if not, return -1 # if yes, return next perfect square def findpsquare(num): A = 1 B = [] while num/A >= A: if num % A == 0: B.append(num/A) B.append(A) A += 1 for i in B: if B.count(i) == 2: return (i + 1)**2 if num == 0: return ...
4589a9e5ff5a5dbcecc4160960318be0ad16dc34
ferreirads/uri
/uri1097.py
196
3.515625
4
i = 1 somador = 0 for I in range(1, 6): print(f'I={i} J={7 + somador}') print(f'I={i} J={6 + somador}') print(f'I={i} J={5 + somador}') i = i + 2 somador = somador + 2
7b9a2718f812762c1e3ba3bdae22a9f92abdbfda
asafepy/desafio-zoox
/questoes/q8.py
226
3.59375
4
def escrevaSort(alist): tempLista = [] for i, num in enumerate(alist): tempLista.append(num) print(sorted(tempLista)) if __name__ == '__main__': alist = [7, 5, 81, 3, 99] escrevaSort(alist)
b0039a55b1b3f690c4f7ea5d42c4b5d1b2308afd
Zahidsqldba07/python_course_exercises
/TEMA 2_CONDICIONALES/Iteraciones_3/Ej2.28.py
751
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #Solicitar por teclado un número en hexadecimal y calcular su valor en decimal. hexadecimal = str(input("Introduce un numero hexadecimal para convertirlo a decimal: ")) exponente = len(hexadecimal) decimal = 0 for digito in hexadecimal: if digito == 'A': digi...
cbac5138b1e78127eaea686089bda03edf111389
ruddyadam/prometheus
/project_euler/002_sum_of_even_fibbonaccis.py
394
3.59375
4
fiblist = [1] def fib(fiblist): while fiblist[-1] < 4000000: if len(fiblist) == 1: fiblist.append(1) else: fiblist.append(fiblist[-1] + fiblist[-2]) print fiblist sumlist = [] for n in fiblist: if n%2 == 0: sumlist.append(n) print "sum ...
60e148a5d3ddfc1140be103dfb5dcefbc708f609
haojian/python_learning
/31. nextPermutation.py
729
3.671875
4
class Solution: # @param num, a list of integer # @return nothing (void), do not return anything, modify num in-place instead. #pseudo code #find the increasing pair and swap it #which pair? the swap should happen at the lower digit, the lower the better #happen means the left digit def nextPermutation(se...
6047ef64e86dc2ca1eee87546496466674c4469e
songjiyang/Mypython
/myPractice/List_util.py
1,188
3.859375
4
# -*- coding:utf-8 -*- """ 写一个列表工具类,可以对列表进行去重,合并,求差,初始化的时候打印hello world,销毁的时候打印Good bye """ class List_util(object): """列表工具类,可以对列表进行去重,合并,求差操作""" def __init__(self): super(List_util, self).__init__() print 'hello world' @classmethod def remove_repeat(cls, inlist): rsp_list = [] for item in inlist: if...
8fa50331c168a0edcb00befe30b51dca21f5d2c7
darraes/coding_questions
/v2/_cracking_code_/10_Completed/10.7_tower_routine.py
855
3.6875
4
from collections import namedtuple Person = namedtuple("Person", ["height", "weight"]) def max_possible_tower(artists): ''' Longest Increasing Subsequence ''' artists.sort(key=lambda p: p.height) gmax = 0 dp = [0] * len(artists) dp[0] = 1 for i in range(1, len(dp)): for ...
057ea667098f74b6602a9bb4a264a1bdfffade47
kmouse/Game_1
/Game/Data/Code/mouse.py
399
3.65625
4
import pygame TRANSPARENT = (0, 0, 0, 0) BLACK = (0, 0, 0) SIZE = (10, 10) class Mouse: def __init__(self, color=(47, 204, 222)): self.image = pygame.Surface(SIZE, pygame.SRCALPHA) self.image.fill(TRANSPARENT) # Draw a circle with a black outline pygame.draw.circle(self.im...
c0a57d90fd86692d489bb6fa51a9af9b2b0069c1
nayakrujul/python-scripts
/Old Programs/BMI Calculator.py
1,056
4.3125
4
print("") testlist = [1, 2, 3] def test(): testlist.append(4) print(testlist) test() print("") print("-------------------------------------") print("") name = input('What is your name? ') print("Welcome " + name + ". This is your Python world.") age = int(input('How old are you? ')) if age < 12: print("Y...
d83115460437362de99d1d1f34b566c6cbaacf69
zettran/PRACTICE-PYTHON
/webpage.py
964
3.9375
4
""" Use the BeautifulSoup and requests Python packages to print out a list of all the article titles on the New York Times homepage. """ import requests from bs4 import BeautifulSoup # the URL of the NY Times website we want to parse base_url = 'http://www.nytimes.com' # http://docs.python-requests.org/en/master/ r =...
a49dff3215ac533fd89824cc3c0b583b5b07c2ba
Ackermannn/PythonBase
/PythonCode/my_roulette.py
454
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 30 22:53:09 2019 @author: Administrator """ ## my常用函数库 ## 轮盘赌函数 import numpy as np from numpy import cumsum from numpy.random import rand def roulette(p): cum = cumsum(p) pr = rand() for i,item in enumerate(cum): if pr < item: return i ...
e57cd1b2a183be160f0f8f5b56fab83b535e274e
adalbertobrant/cursoPythonModerno
/decToBin.py
152
3.921875
4
def decBin(num): if num > 1: decBin(num // 2) print(num % 2, end='') num = int(input("Entre o número inteiro decimal")) decBin(num)
85c5a349050b7290dd3b9e059fc74ee8cf5a10bd
gabrielavirna/interactive_python
/problem_solving_with_algs_and_data_struct/chp2_analysis/dictionaries.py
1,731
4.1875
4
""" Dictionaries ============ - dictionaries differ from lists in that you can access items in a dictionary by a key rather than a position. - Operations: the get item and set item operations on a dictionary are O(1). - Another operation: the contains operation - Checking to see whether a key is in the dictionary or n...
23a47e9b99ee03b9c0ab8216d194fc94a8a3e794
gitJaesik/algorithm_archive
/acmicpc/1110.py
526
3.78125
4
def getStrNum(num): newValue = "" if num < 10: newValue = "0" + str(num) else: newValue = str(num) return newValue def getNextPlusCicle(num): num2 = getStrNum(num) sum = int(num2[0]) + int(num2[1]) sum2 = getStrNum(sum) return int(num2[1] + sum2[1]) def main(): ...
23e7836aee72d0f0cb9fae9cd975cc21f18646b7
Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021
/answers/Drish-xD/Day-16/Question-1.py
714
3.984375
4
# Program to count the number of 1's in a binary array :) def count_1(array, x, y): while y >= x: z = (x + y) // 2 # Finding mid term if array[y] == 0: # If last term of array is 0, so count of 1 = 0 return 0 elif array[x] == 1: # If first term of array i...
447dae5a34f62bf47dc7fa2c1ef5c2f9991bb36c
mechanicalgirl/young-coders-tutorial
/games/number_guessing/guess_one.py
161
3.8125
4
secret_number = 7 guess = input("What number am I thinking of? ") if secret_number == guess: print "Yay! You got it." else: print "No, that's not it."
e1a2a6c55edba7a76c9fd5e7b7db80387b8a271f
RiteshBhola/literate-octo-train
/fibonacci.py
210
3.71875
4
""" FIbonacci program: This program prints first n fibonacci numbersG 02/09/2019 Ritesh Kr, Bhola """ def fibonacci(k): f0=0 f1=1 print(f0) for i in range(1,k): print(f1) temp=f0 f0=f1 f1=temp+f1
5b9e00a7f9c8a6bed1a8c3ae24f45dfdb2d5df61
richard-yap/Lets_learn_Python3
/module_2_data_types.py
6,043
3.90625
4
# ---------------------MODULE 2 Data Types---------------------- # . # . # . # . # . # . # . # . # . # . # number/ int, float # string # list # tuple # dictionary # set # you can also write a variable like this in atom, but not in jupyter notebook: a, b = 1, 2 c = a + b a b # .format nicely ...
bdb37d4b31d2be06a8e320d63f92eee4d1d2f380
fyrtoes/project_01_Stage_Reader
/colconverter.py
3,647
4.375
4
# GCAV Information # 1/22/2015 FINISHED on 1/25/2015 # The purpose of this program is to convert the column index from Meyer's into a number. A = 1, B = 2, etc. ''' print "\n" # Here is where I will ask the user to provide the column, from where I will store it. column = raw_input('Enter the column index (a, b, ac, e...
d4faa91c74c189a892ac7441e18a2eef59354a17
12Me21/markup
/parse1.py
3,808
3.65625
4
def highlight(code, language): return code def escape_html(code): return code.replace("&","&amp;").replace("<","&lt;").replace("\n","<br>") def escape_html_char(char): if char=="<": return "&lt;" if char=="&": return "&amp;" if char=="\n": return "<br>" if char=="\r": return "" return char def parse(c...
4a62e8e097e7433ae8266ffd517fc88927acbb81
waveletus/yang
/wordhunt.py
5,601
3.5625
4
################################# #Basic idea: # word is inserted into table by sequence of horizon and vertical # line or column is selected by probability of left space number # The first step is to select line or column and put into the free space (more space more probability) # The second step is to try to compact...
67950b8dbc12adbba0f7ed69fa3d2cb37830ab62
ash-xyz/Galaxy-Zoo
/src/model.py
805
3.5
4
import tensorflow as tf from data import CLASSES, IMAGE_SHAPE def create_model(): """Creates a keras model for training Returns: model: keras model """ # Densenet Model conv_net = tf.keras.applications.MobileNetV2( include_top=False, input_shape=IMAGE_SHAPE) neural_net = tf.ke...
20f11235ad844ba085625e2f870295da07dbb596
kvp250688/assignment8
/assignment8.py
1,038
3.578125
4
# coding: utf-8 # In[2]: import numpy as np import pandas as pd # In[3]: from pandasql import sqldf # In[ ]: import sqlite3 import pandas as pd from pandas import DataFrame, Series from pandasql import sqldf pysqldf = lambda q: sqldf(q, globals()) sqladb = pd.read_csv("https://archive.ics.uci.edu//ml//ma...