max_stars_repo_path
null
max_stars_repo_name
null
max_stars_count
null
id
null
text
string
score
float64
int_score
int64
from
string
blob_id
string
repo_name
string
path
string
length_bytes
int64
null
null
null
null
import collections # Person = collections.namedtuple("Person", ["name", "gender", "age", "class"], rename=True) Person = collections.namedtuple("Person", 'name, gender, age,', rename=True) obj = Person(name="Bob", gender="male", age=18) print(obj.name) print(obj.gender) print(obj.age) print(obj[0]) print(obj[1]) p...
3.765625
4
smollm
b000ac9a691b7fa6f39f17c19dcdcc46a98a4253
starkhu/python_space
/module_test/collections/namedtuple.py
334
null
null
null
null
def choose_bank_to_redist(banks): max_el = max(banks) return banks.index(max_el) def part1(banks): counter = 0 already_seen = {tuple(banks): counter} nbanks = len(banks) while True: counter += 1 redist_bank = choose_bank_to_redist(banks) redist_amount = bank...
3.640625
4
smollm
5e0423c76b6eca8476239bf5f5536b34ce512e9c
robquant/adventofcode2017
/06/december6.py
918
null
null
null
null
from collections import defaultdict registers = defaultdict(int) def compare(regname, op, value): if op == '<': return registers[regname] < value elif op =='<=': return registers[regname] <= value if op == '>': return registers[regname] > value elif op =='>=': return re...
3.71875
4
smollm
be01f15995c511968701d50363930ea3c4fbcfdd
robquant/adventofcode2017
/08/december8.py
1,538
null
null
null
null
#!/bin/python import sys def gcd(x,y): while y != 0: x,y = y,x % y return x # define lcm function def findlcm(x, y): lcm = (x*y)//gcd(x,y) return lcm t = int(raw_input().strip()) lcm = 1 l =[] for a0 in xrange(t): n = int(raw_input().strip()) for i in range(2,n+1): lcm = fi...
3.734375
4
smollm
29a8b2d77f0055af3240f0e28f0762c77a92fd67
faraza72/python
/small_multi.py
374
null
null
null
null
s = raw_input() s2 = '' for i in range(len(s)/3): s2 += 'SOS'; cnt = 0 for i in range(len(s)): if(s[i]!=s2[i]): cnt += 1 print cnt
3.59375
4
smollm
b8cee30cfda9f4b36cdb8182032f6fa83dced03a
faraza72/python
/mars.py
135
null
null
null
null
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import product A = (map(int,raw_input().strip().split(" "))) B = (map(int,raw_input().strip().split(" "))) print tuple(product(A,B))
3.75
4
smollm
e870a9c656c5152c8ba8211667b6a99092cea1af
faraza72/python
/thirteen.py
217
null
null
null
null
import sys from math import sqrt def chkprime(k): for i in range(2,k): if k % i == 0: return False return True t = int(raw_input().strip()) for a0 in range(t): n = int(raw_input().strip()) primes = [2, 3] t = 5 if n > len(primes): while len(primes) < n: ...
3.65625
4
smollm
52757e4c995a24b4e12546422224e522d9751b16
faraza72/python
/nprime.py
510
null
null
null
null
import matplotlib.pyplot as plt x_values = list(range(1, 5001)) y_values = [x**3 for x in x_values] plt.scatter(x_values, y_values, c=y_values, cmap=plt.cm.Blues, edgecolors='black', s=50) # Assigning a chart title and axis labels. plt.title("Square Numbers", fontsize=14) plt.xlabel("Values", fontsize=14...
3.71875
4
smollm
d921a293ddc1141f2ede6198e19a43d2e8538bba
pavel-malin/data_generation
/cubes_numbers0.py
438
null
null
null
null
#! /usr/bin/env python # # Methods to generate the points while playing The Chaos Game # import sys, re, random import numpy as np max_iter = 10**8 class ChaosGame: #method to play @staticmethod def play(ngon,frac): points = [] i = 0 x1,y1 = ngon.rand_in() while i <= ...
3.65625
4
smollm
bb8de4ddf8e57b54fd69b254c37e52bcbd401897
mccarthyryanc/chaos_game
/chaos_game.py
577
null
null
null
null
class ChessRules: def __init__(self): '''Set instance method for en passant moves.''' self.en_passant = (-1, None) def set_up(self, board, castle_variables, current_player): '''Called before using other methods. Sets instance methods for: The board setting rules are cheked on. The color of the current p...
3.546875
4
smollm
248cc9efb2e79620175cfa7d91f60de4c83e81cc
dariomihelcic/MiS_Chess
/src/ChessRules.py
10,498
null
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #NAME: Elijah Berumen #FALL 2018 CSCI 3308 #BUGS FIXED #1.) Bug in count vowels 3!=2. Changed the aeou in the regex portion to aeiou to include #all vowels #2.)The last portion of the regex phone number check in the phone number function #should check for the third chun...
3.671875
4
smollm
96b1df2fae56a3655e0cc00a370b0da21e8da01e
eliberumen27/CSCI3308
/CU-CSCI3308-PythonUnitTesting/textproc_test.py
2,141
null
null
null
null
#!.py from hashtable import HashTable import mmap def open_target_phone_numbers(filename): """opens a file with phone numbers for testing""" target = ('data/'+filename) with open(target) as file: lines = [line.rstrip('\n') for line in open(target)] return lines def get_costs(filename): """...
3.515625
4
smollm
4cfb5d99ec8a1cc2fc9af185b0184b48ed10e6b3
capt-alien/master_blaster
/routeing.py
1,460
null
null
null
null
"""Write a program which can compute the factorial of a given numbers.""" Number=5 Factorial=1 index=1 while (index>=1 and Number>=index): Factorial *= index index+=1 print(Factorial)
3.984375
4
smollm
34b50b643965e9a96aa6c460179dd89f0c88a880
mlbc-101/python-basics-FolFol
/problem_two.py
192
null
null
null
null
"""Escenario Espatifilo, más comúnmente conocida como la planta de Cuna de Moisés o flor de la paz, es una de las plantas para interiores más populares que filtra las toxinas dañinas del aire. Algunas de las toxinas que neutraliza incluyen benceno, formaldehído y amoníaco. Imagina que tu programa de computadora am...
3.984375
4
smollm
17ede11a4a3412f5a54150604e35249069b5dbb5
GunterBravo/Python_Institute
/3_1_1_11_Lab_OperadorCondicional.py
1,549
null
null
null
null
"""Objetivos Experimentar con el código Python existente. Descubrir y solucionar errores básicos de sintaxis. Familiarizarse con la función print() y sus capacidades de formato. Escenario Recomendamos que juegues con el código que hemos escrito para ti y que realices algunas correcciones (quizás incluso destructivas). ...
4.3125
4
smollm
5718368b578dee4609e0e10df55908c7707b99cb
GunterBravo/Python_Institute
/2_1_1_20_Lab_Formato_Salida.py
1,639
null
null
null
null
"""Earthquake event counter module.""" import collections import math # Path to data input file DATA_FILE = 'program/quake.txt' # Degrees to radians constant DEG2RAD = math.pi/180.0 # Approx. radius of the earth in miles EARTH_RADIUS = 3960 def get_events(origin_latitude=None, origin_longitude=None, radius=None,...
3.703125
4
smollm
8e407e02229f124ba20500742e0b984de9d3d79f
minism/uo-sciprog
/program/event_counter.py
4,041
null
null
null
null
from random import * #prints both random, randint import math #printing built in functions/modules: print(type(random)) print(random()) print(randint(10,200)) #print(sample((['person1', 'Ana', 'Mother Teresa'], 3))) print(choice((['person1', 'Ana', 'Mother Teresa']))) print(' ') print('Math:') num_rand = ran...
3.6875
4
smollm
43d372de57d7513713991e988eac5fbccbf75db9
TahsinKhan7/package-libraries-pip
/py_lib.py
491
null
null
null
null
__author__= 'Z.GE' """ contains main and associated methods to solve word puzzle using multiple processing techniques. """ from multiprocessing import Pool import datetime from utility_function import * import sys from super_word_search import puzzle_board def chunk(wordlist, n, board_dict): """split the word l...
4.0625
4
smollm
6202bada41b8f5dff053aabffc4136ceba630562
zyenge/Word_Search
/main_parallel.py
6,866
null
null
null
null
# ============================================================================= # Using os to locate the directory containing all the files # ============================================================================= import os path = os.chdir("C:\\Users\\amita\\Desktop\\test") i = 0 # =============================...
3.625
4
smollm
8bc24a5bc38e3b40292d364027534b16c7a7249a
Shamimwrf/renamemultiplefiles
/renamemultiplefiles.py
723
null
null
null
null
def longestWord(sentence): wordArray = sentence.split(" ") longest = "" for word in wordArray: if(len(word) >= len(longest)): longest = word return longest print(longestWord("Hello World"))
4.125
4
smollm
bfcb1d90954212422525116a0a027e4239b8e0bf
Dmendoza3/Python-exercises
/random/longestword.py
226
null
null
null
null
class base: def __init__(self,x): self.x = x class a(base): def __init__(self,x,y): super().__init__(x) self.y = y def sup(self): return super() class b(a): def __init__(self, x, y ,z): super().__init__(x,y) print(super().super()) self.z = z ...
3.625
4
smollm
e832f2a73f576874738ced907f77d9e7bfb019bf
Dmendoza3/Python-exercises
/random/test.py
471
null
null
null
null
class List2: def __init__(self, start): self.start = start # задаем в конструкторе стартовое значение def __iter__(self): self.count = 0 # счетчик обращений к итератору return self def __next__(self): cu...
3.859375
4
smollm
d7e8423a179a1fbe9c09ab0cee471d5e0e6d681d
Krugger1982/practica2
/Less_5_iterators.py
2,274
null
null
null
null
# HACKERRANK # PYTHON PROBLEM AND SOLUTIONS # link of the problem: # PROBLEM 1. # Python If Else # Given an integer, , perform the following conditional actions: # # If is odd, print Weird # If is even and in the inclusive range of 2 to 5, print Not Weird # If is even and in the inclusive range of 6 to 20, print W...
4.34375
4
smollm
3ca0a1751255a3965d742cea367e3058709af617
raghumina/Hackerrank
/Problem1.py
1,440
null
null
null
null
#!usr/bin/python # This method generates a random maze that guarentees that every room is accessible # The output is to a file named "level6" # The values to print are determined by generating a binary number based on which walls are visible. The binary number is then converted to hex and added to the output. # (The b...
3.890625
4
smollm
0db826375e4fe6c5dc5f972497b3c4d1cc9c495c
aherlihy/GLIDE
/sandbox/maze.py
4,727
null
null
null
null
# copyright Robert Hebert # fuck yeaAAAAAAAAAAAAAAAAAAAAAAAAAAA # Returns the sum of a and b def simple_sum(a: int, b: int) -> int: # i did it return a + b print("2 + 3 = {0}".format(simple_sum(2,3)))
3.765625
4
smollm
ac171f6647d665928989c9d2cc83131aa6a928ff
writetoleft/git-workshop-tutorial
/simple_sum.py
209
null
null
null
null
'''汉诺塔 递归''' count = 0 def hanoi(n,src,dst,mid): ''' :param n: 圆盘个数 :param src: 原柱子 :param dist: 目标柱子 :param mid: 中间柱子 :return: ''' global count if n == 1: print("{}:{}->{}".format(n,src,dst)) count += 1 else: # 将n-1个圆盘从src搬到mid hanoi(n-1,src,mi...
3.90625
4
smollm
dcfb15e784b6a3fa31edb9763362a91d9fc7234f
iflyzhang/MOOC
/test_str/hanoi.py
631
null
null
null
null
# import argparse import hashlib from tkinter import * root = Tk() root.title("HASHING PASSWORDS") root.geometry('944x344') root.configure(background="white") # #textbox # f2 = Frame(root, width=300, height=500, bd=8, bg="white") # f2.pack(side=TOP) Label(root, text=" Hashing Password", font="comicsansms 25 bold")....
3.75
4
smollm
aba76bef1f1277f7a08cd53320f116e5665a0f90
NPawar0125/Hashing_Password
/Hashing_passwords/hashing_passwords.py
2,063
null
null
null
null
# -*- coding: utf-8 -*- """ @author: Zachary Wozich Assignment 3 Class - Info 2820 Program: phone numbers The program will the user if they’d like to lookup up phone numbers or addresses. The program should repeatedly ask the user for a person’s name (first and last name) and look up and display the appropria...
4.40625
4
smollm
87985ba50fe3ddb00017d7715126a2295be158c4
ma1zwoz1/UMASS_Python_Scripts
/wozich_lookup.py
4,656
null
null
null
null
rows = 128 columns = 8 seats = [int("".join("1" if i == "B" or i == "R" else "0" for i in seat), 2) for seat in open("day5/input").read().splitlines()] def get_seat(): for row in range(1, rows - 1): for col in range(columns): seat = row * columns + col if seat not in seats...
3.59375
4
smollm
ee803f0838bc87c8c45792485a5624e3ce15b140
DanTGL/AdventOfCode2020
/day5/day5_2.py
415
null
null
null
null
# Copyright (c) 2020 DanTGL # This code is licensed under The MIT License (see LICENSE for details) import math inputs = open("day3/input").read().splitlines() def tree_encounters(slope_x, slope_y): result = 0 pos_x = slope_x pos_y = slope_y while (pos_y < len(inputs)): if inputs[...
3.609375
4
smollm
25779d4b23913e306f1d2672320673da4eab319c
DanTGL/AdventOfCode2020
/day3/day3_2.py
641
null
null
null
null
def addition(*args, **kwargs): print(locals()) ans=0 for ele in args: ans=ans+ele for v in kwargs.values(): ans = ans + v return ans ans = addition(3, 5, a=1, b=3, c=3, d=6) print(ans)
3.53125
4
smollm
aa17af85cfa04734ea480875285bfce6dcfc87ab
Salekya/pythonScripts
/Sum.py
226
null
null
null
null
def sum2(a, b): print locals() return a+b def sum1(*arg): print locals() ans = 0 for ele in arg: ans = ans + ele return ans # @todo complete sum3 and sum4 def sum3(**kwargs): return "kwargs" def sum4(*args, **kwargs): return "kwargs" # @todo do the same for min indexes def max_min_index(): s=[1,70,80,20...
3.703125
4
smollm
79ffec6d06600808102b89dc73a523e68d8da6b6
Salekya/pythonScripts
/foo.py
657
null
null
null
null
# 从文件读取数据 with open('../words.txt') as file_object: lines = file_object.readlines() # for line in file_object: # print(line) for line in lines: print(len(line)) # 写入文件 fileName = 'program.txt' with open(fileName, 'w') as file_obj: file_obj.write("hello\nworld\n") # 异常 # try except else # pass # 存储...
3.875
4
smollm
09e3c5550bd469e93900afba74323eabf54d1f2f
Qturing/backups
/python/s10/file.py
566
null
null
null
null
# 定义函数 def greet_user(username): """显示问候语""" print("hello, " + username.title() + "!") greet_user("jessi") # 传递实参 # 返回值 def get_formatted_name(first_name, last_name, middle_name = ''): """返回整洁的姓名""" if middle_name: full_name = first_name + ' ' + middle_name + ' ' + last_name else: ...
3.65625
4
smollm
4001b02336afde2e49b45a7b4be57900fd1b3907
Qturing/backups
/python/s8/function.py
1,838
null
null
null
null
import pymysql ''' 从MySQL中读取指定时间的新闻数据,返回结果 ''' def readinfo(date): db = pymysql.connect(host="127.0.0.1",user="root",passwd="123456",db="mypydb") cursor = db.cursor() sql = "select title,url from news where date='" + date + "'" try: cursor.execute(sql) results = cursor.fetchall() ...
3.5
4
smollm
b3ff92c738a8c6404be77b8593e797f91b985f9a
Qturing/backups
/scraping/readurl.py
1,138
null
null
null
null
number = int(input("Enter the positive number: ")) for i in range(number): for j in range(i): print(i, end=" ") print(" ")
4.09375
4
smollm
633fde85e505fb98c00685924d801236d9d604f8
Abdurrahmans/Star-Pattern-Problem-Solving
/StarPattern/Number_pattern.py
142
null
null
null
null
n = int(input("Enter the number of rows:")) for i in range(0, n): for j in range(0, n): if i == 0 or i == n - 1 or j == 0 or j == n - 1: print("*", end=' ') else: print(" ", end=' ') print(' ')
3.890625
4
smollm
07ad73bf91a3f0c1d04c82628733501b4390983d
Abdurrahmans/Star-Pattern-Problem-Solving
/StarPattern/HolloSquarPattern.py
252
null
null
null
null
"""back_prop_learning.py: Backpropagation algorithm for learning in multilayer networks.""" __author__ = "Jordon Dornbos" import random import hypothesis_network import multilayer_network from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np iteration_count = 0 def back_prop_l...
3.8125
4
smollm
17bf8d01c1e1e8a6fbafd4eda2bbe03ce1f26c7f
jordondornbos/neural-network-visualization
/back_prop_learning.py
8,795
null
null
null
null
def isPalindrome(str, start_index): if start_index >= len(str) - 1: return True elif str[start_index] != str[len(str) - 1 - start_index]: return False else: return isPalindrome(str, start_index+1) print(isPalindrome('abcdefghijihgfedca', 0))
3.78125
4
smollm
ff9a2ff0f4233a972b70fe08b67c008ab8da220e
pavancd/algorithms
/Palindrome/Palindrome.py
288
null
null
null
null
def three_largest_numbers(input_array): three_largest_numbers = [float('-inf'), float('-inf'), float('-inf')] for n in input_array: if n > three_largest_numbers[0]: three_largest_numbers[0] = n if n > three_largest_numbers[1]: temp = three_largest_numbers[1] ...
4.125
4
smollm
a614acc751ec7ca203462f8e6f8862a9564e01ab
pavancd/algorithms
/ThreeLargestNumbers/ThreeLargestNumbers.py
725
null
null
null
null
#This program tells about the arithmetic operators# a = 2+3 b = 6-1 c = 3*2 d = 3/2 e = 3%2 print( 'addition', a ,'\n''Subtraction',b,'\n' 'Multiplication',c, '\n' 'Division' ,d,'\n' 'Modulus',e)
3.984375
4
smollm
7487c7f76d491aa220daae0dfce6be9f67ec08bc
Pallaparaju/PythonTraining
/source/Arithmetic_Operators.py
198
null
null
null
null
#2. Реализовать функцию, принимающую несколько параметров, описывающих данные пользователя: # имя, фамилия, год рождения, город проживания, email, телефон. # Функция должна принимать параметры как именованные аргументы. Реализовать вывод данных о пользователе одной строкой. name = input("Напишите свое имя ") surname =...
4.09375
4
smollm
9e03b3ff3c3adb38589d2a1d95d24af32eb664c1
TYakovchenko/GB_Less3
/less3_HW2.py
1,375
null
null
null
null
x1 = float(input('x1: ')) y1 = float(input('y1: ')) x2 = float(input('x2: ')) y2 = float(input('y2: ')) m = (y2 - y1) / (x2 - x1) print(f'La pendiente es {m}')
3.890625
4
smollm
2848bc7d7b4bb0b3aae56519933b423882a91827
PedroMorenoTec/practica-examen
/2.1/pendientedeunarecta.py
168
null
null
null
null
from math import e poblacion_inicial = int(input('Poblacion incial: ')) tiempo = int(input('Tiempo en años: ')) tasa = float(input('Tasa de crecimiento: ')) poblacion_final = int(poblacion_inicial*e**(tasa*tiempo)) print(f'La población final sera {poblacion_final}')
3.59375
4
smollm
3f30d660cb28fd712012df716a5e7fb1c2bb519a
PedroMorenoTec/practica-examen
/2.2/crecimientodepoblacion.py
279
null
null
null
null
minutos = float(input('Minutos del caracol: ')) velocidad = 5.7 / 10 #cm/s distania = velocidad * minutos * 60 print(f'El caracol recorrerá {distania} cm')
3.75
4
smollm
e0485fbe416ce34f01d50ad98626d5c9331f6741
PedroMorenoTec/practica-examen
/2.1/distanciacaracol.py
163
null
null
null
null
from math import pi r = float(input('Introduce el radio de la esfera: ')) area = round(4*pi*r**2,2) volumen = round(4*pi*r**3/3,2) print(f'área = {area}') print(f'volumen = {volumen}')
4.03125
4
smollm
5be81dfa5b73c3c2c92f092c861f3f6f01322ab3
PedroMorenoTec/practica-examen
/EjerciciosProgramasQueRequierenCalculosConFuncionesPredefinidas/ejercicio1.py
196
null
null
null
null
"""8. Write a program which accept number from user and print that number of “*” on screen. Input : 5 Output : * * * * * """ def PrintStar(iNo): for i in range(iNo): print("*\t",end='') def main(): iNo=int(input("Enter No.: ")) PrintStar(iNo) if __name__=="__main__": main()
4.125
4
smollm
6068f7795546b84206f40e8095863b8c12603ab5
BerdeRadhika/Programs
/Python Programs/Assignment No 1/8.Print Star.py
301
null
null
null
null
from Card import Card from Deck import Deck class Player: short_val={ "2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8, "9":9, "10":10, "J":11, "Q":12, "K":13, "A":14 } short_suit={ "H":"Heart",...
3.796875
4
smollm
f31eea830daad4ee501c94cfee8e65089fdb2228
SamBurt/Hearts
/Player.py
2,915
null
null
null
null
import urllib.request import urllib.request from urllib.error import URLError, HTTPError import re import io import contextlib mainpage = "https://www.bigoven.com/recipes/main-dish/grill-and-bbq/page/" # look for pattern that starts with tag data-url on the mainpage # thanks to http://stackoverflow.com/ques...
3.59375
4
smollm
ae670a101bfa541de34fc882eb361428b9c61c71
anonyXmous/ExploreFoodRecipe
/getUrl.py
2,075
null
null
null
null
print("Enter the XOR Truth Table:") x1=[] x2=[] y=[] for i in range(0,4): i1=input("Enter values of X1:") x1.append(i1) for i in range(0,4): i2=input("Enter values of X2:") x2.append(i2) for i in range(0,4): i3=input("Enter values of Y:") y.append(i3) print ("X1 X2 Y") i=0 while i <=...
3.703125
4
smollm
9961f92d78f14acefb6aeeeaff7736561e74cc3b
PranjaliKumbhar/CI-Programs
/ciORbinary.py
851
null
null
null
null
""" To get name and age """ import datetime NAME = input("Hi\nWhat is your name?\n") AGE = int(input("Please enter your age:")) print ("Hi %s. You are %d years old and you will turn %d in %d" %(NAME, AGE, 100, datetime.datetime.now().year - AGE + 100))
3.875
4
smollm
9a6394c9281b4488f0692f2f5341806fc78f1c86
node31/practicepython
/q1.py
260
null
null
null
null
#!/usr/bin/env python data = "hello world" print(data) print(data[2:4]) # Try the exercises below # 1. Make a program that displays your favourite actor/actress. print("Tamanna") # 2. Try to print the word ‘lucky’ inside s. print("Whats digit %d in words? - seven" % 7) # 3. Try to print the day, month, year in th...
4.25
4
smollm
f1825c51071572b53808b315573feccfcdc69590
ImShakthi/play-with-python
/basics/strings.py
958
null
null
null
null
# -*- coding: UTF-8 -*- # 可写函数说明 def printinfo(arg1, *vartuple): """打印任何传入的参数 """ print "输出: " print arg1 for var in vartuple: print var return # 调用printinfo 函数 printinfo(10) printinfo(70, 60, 50) """ 这个东西内部是如何调用的还是说不通?并不是怎么想得明白?? 前面是参数,后面直接就是那个指针了,那它在里面是如何调用的也是一个问题?? print var 应该是...
4.0625
4
smollm
eeeeab76af44b64ae9aea0b96636138c84cdee1b
abbsmile/Python-base
/BaseForm/function.py
567
null
null
null
null
a_string = raw_input("Please input something:") print a_string print "***************************************" b_string = input("Please input a Python expression:") print b_string """ THE CONSOLE: Please input something:now we could input a math expression now we could input a math expression ********************...
4.375
4
smollm
a886c39239231e864fbee773299383abc3b7b098
abbsmile/Python-base
/BaseForm/file_input_output/input.py
519
null
null
null
null
import os import json ''' dotfile is a class for managing the local dotfile storage saves a file called, '.fu' to your home directory the file is format a json file { result : Last Search Result last : Last Copied command history : History of used commands } the entire dot file ...
3.90625
4
smollm
56f4ccfe6347b2f9a2b4387c0006b8754518ea3f
larsyencken/fu
/fu_core/config.py
2,395
null
null
null
null
def parityBits(strLen): num=2 while 2**num-1<strLen+num: num+=1 return num def hammingEncoder(userInput): s=list(userInput) k=parityBits(len(s)) lis=[] for i in range(k): s.insert(2**i-1,'0') for i,val in enumerate(s): if val=='1': lis.append(i+1) ...
3.953125
4
smollm
bff788e686273b9d7664d88afa3bf33db9d73904
chowsychoch/Network_Project
/hammingEncoder.py
556
null
null
null
null
def isValid(s): stack = [] for item in s: if item in ["(", "{", "["]: stack.append(item); elif len(stack) == 0: return False else: poppedItem = stack.pop() if item == ")" and poppedItem != "(": return False ...
3.859375
4
smollm
e65b31237f931c5475f48af838500b48f34ceecc
mehulgala77/LeetCode-Problems
/Classic Algorithms/Valid Parenthesis.py
784
null
null
null
null
""" module contains class Player imports model classes """ from model.ship import Ship from model.coordinates import Coordinates class Player: """ Player represents a human or AI playing the game Player class represents an actor of the game. Player has a name, a score and a set of ships """ def _...
3.984375
4
smollm
22bfbc44f3fe107b9e51ef2d2dc8eddd38eca993
ruslanabdulin1985/TheTask
/Battleships/model/player.py
2,370
null
null
null
null
print("This is a mean calculator LOL") print("▓ ▓ ▓ ▓▓▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ ▓ ▓ ▓▓▓▓▓▓▓") print(" ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓▓ ▓▓ ▓ ") print(" ▓ ▓ ▓ ▓ ▓▓▓▓▓▓▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓▓▓") print(" ▓ ▓ ▓ ▓ ▓ ▓ ▓ ...
4.15625
4
smollm
e4888cd751104eafae173e6b2af01936d5dfcf50
BenjaminFu1/Python-Prep
/Representing algorithms( (mean of three numbers).py
911
null
null
null
null
import random colour= random.randint(1,6) if colour == 1: print("Today, you should wear red coloured tie") elif colour == 2: print("Today, you should wear orange coloured tie") elif colour == 3: print("Today, you should wear yellow coloured tie") elif colour == 4: print("Today, ...
4.03125
4
smollm
50d2747400bf09052c085bbb45916e4467f57c78
BenjaminFu1/Python-Prep
/elif and if statement Chosing ties.py
504
null
null
null
null
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ s = 'This is a long string with a bunch of words in it.' # print(s.split()) # splits the string into a list # print(s.split('i')) # splits on the letter i l = s.split() s2 = ":".join(l) # returns This:is:a:long:string:with:a:bunch:of:words:in:it. print(...
4.1875
4
smollm
00063712450816dff77533fdd98bc05537b69caa
tu-nguyen/linkedinlearning
/Master Python for Data Science/Python Essential Training 1/Chap11/split-join.py
324
null
null
null
null
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ def main(): game = [ 'Rock', 'Paper', 'Scissors', 'Lizard', 'Spock' ] # i = game.index("Paper") # print(game[i]) # game.append("Computer") # appends to end of list # game.insert(0, "Computer") # insert at index 0 # game.remove("Pa...
4.25
4
smollm
50efe05a3c8cc7ad362d7a68bb69f51b4c94375b
tu-nguyen/linkedinlearning
/Master Python for Data Science/Python Essential Training 1/Chap08/lists.py
701
null
null
null
null
import psycopg2 from sql_queries import create_table_queries, drop_table_queries def create_database(): """ Connects to the database, generates a cursor, drops existing db, creates a new db, disconnects, reconnects and generates a new cursor. Arguments: None Returns: cur=cursor object, conn=connection obje...
3.640625
4
smollm
2c81741209aaa002d533f83d8bb93ffa2afff038
troublesomeMilo/song-relational-database
/create_tables.py
1,917
null
null
null
null
""" Linear least-squares fit. Following the procedure oulined in Philip R. Bevington, "Data Reduction and Error Analysis for the Physical Sciences" (Third Edition, 2003), Chapter 7.2, "Least Squares Fit to a Polynomial - Matrix Solution" Friedrich Schotte, 20 May 2008 - 27 Apr 2012 """ __version__ = "1.3.3" def line...
3.9375
4
smollm
784638d39c15dc21e9f17851fd6d06edc3892327
friedrich-schotte/Lauecollect
/linear_fit.py
4,335
null
null
null
null
""" based on: https://stackoverflow.com/questions/5189699/how-to-make-a-class-property Date created: 2018-10-10 Date last modified: 2018-10-10 Author: Mahmoud Abdelkader (mahmoudimus.com) Revision comment: Cleanup: Formatting, unused imports """ __version__ = "1.0" import logging class ClassPropertyMetaClass(type): ...
3.546875
4
smollm
6f513e3977d57d939795046fc7eed8ee5334b374
friedrich-schotte/Lauecollect
/classproperty.py
2,239
null
null
null
null
""" Author: Friedrich Schotte Date created: 2022-05-05 Date last modified: 2022-05-05 Revision comment: """ __version__ = "1.0" import logging def split_list(s): """Split a comma-separated list, without breaking up list elements enclosed in brackets or parentheses""" start = 0 level = 0 elements...
3.5
4
smollm
71d19a96ea1caeef1346bc180046afbba0275062
friedrich-schotte/Lauecollect
/split_list.py
964
null
null
null
null
""" Bitmap manipulation Friedrich Schotte, Hun Sun Cho, Dec 2008 """ version = "1.1" def grow_mask(mask,count=1): """Extents the area where the pixels have to value 1 by one pixel in each direction, including diagnonal by the number of pixels given by the parameter 'count'. If count is 1 or ommited a ...
3.65625
4
smollm
dd03343539801935809bf712f445334e7c11c8ef
friedrich-schotte/Lauecollect
/grow_mask.py
1,359
null
null
null
null
def partition(arr,start,end): l=len(arr) pivot=arr[end] #print 'Before Partition : ',arr i=start-1 j=start while j < l: if arr[j]>=pivot : pass else : i=i+1 arr[i],arr[j]=arr[j],arr[i] j=j+1 arr[i+1],arr[end]=arr[end],arr[i+1] #...
3.984375
4
smollm
d71b1b0d3328b55b3a773f28ca020485dabba6d6
dupandit/Datastructure-and-Algorithms
/greed1_activity_selection.py
1,702
null
null
null
null
class Sudoku: def __init__(self, sudoku = None): self.__puzzle__ = [] self.__originalPuzzle__ = [] self.__input__ = [' ','1','2','3','4','5','6','7','8','9'] # 0 index is used for the representing empty value in sudoku self.__validInput__ = [] self.__index__ = [0,1,2,3,4,5...
3.875
4
smollm
3d37860eda48da9218a0b7665cedcb02dc9ea1c6
Riya-Rai/Sudoku-Master
/Sudoku Python Project/Code exe files/sudoku.py
15,231
null
null
null
null
import pygame class GameField: """Класс игрового поля""" def __init__(self, screen): self._background_set_up(screen) self.size_field = (400,400) #Размер поля self.cell_size = 5 # Размер клетки в пыхселях self.game_area = (self.size_field[0] // self.cell_size, self.size_field[1] /...
3.78125
4
smollm
7c090c600f05670854e77c2d4fe5b76cc34f7889
Serufim/Super_snake
/classes/GameField.py
3,517
null
null
null
null
from math import prod def encounters(geography, slope=(3, 1)): width = len(geography[0]) height = len(geography) pos = (0, 0) count = 0 while pos[1] < height: here = geography[pos[1]][pos[0]] count += int(here == "#") pos = ((pos[0] + slope[0]) % width, pos[1] + slope[1]) ...
3.65625
4
smollm
5b15f1ce4456a28f7d6cb3c342e0aca873e9a019
imrehg/AdventOfCode2020
/day03/day03.py
684
null
null
null
null
#!/usr/bin/env python """ [...], the Elves in accounting just need you to fix your expense report (your puzzle input); apparently, something isn't quite adding up. Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together. For example, suppose your expense repor...
4.125
4
smollm
c5f97edd30f61119f839821118fed43db0459760
imrehg/AdventOfCode2020
/day01/day01.py
1,823
null
null
null
null
""" solution for day 1 reading from file """ # part 1 # simply read the file filename = 'input.txt' def findSum(): result = 0 with open(filename, 'r') as f: for line in f: result += int(line) return (result) # part 2 # keep track of what's been read import itertools def findr...
3.8125
4
smollm
4a42f04c0eabc5b037de6fae8bdd400c451b0103
DemetreJou/AdventOfCode2018
/1/solution.py
617
null
null
null
null
from string import * """ solution for day 5 """ line = open('input.txt').read().strip() oldline = None def collapse(s): result = ['.'] for c in s: # c is character were looking at v = result[-1] # the last character we've looked at if c != v and c.lower() == v.lower(): result.p...
3.65625
4
smollm
196db6ff1d3f96f7262c5f82452343af03c40969
DemetreJou/AdventOfCode2018
/5/solution.py
625
null
null
null
null
class pretty_board: def __init__(self, rows): self.rows = rows self.horizontal_line = ['─' * 3] * 3 self.prettyify() def __str__(self): return self.pretty_rows def prettyify(self): self.pretty_rows = self.top() + self.middle() + self.bottom() def middle(self)...
3.78125
4
smollm
75e1f3b5a11cccec229b284ad56dcbb89eb843ec
Brendonk13/tic_tac_toe
/pretty_board.py
1,133
null
null
null
null
from singly_linked_list import LinkedList import sys sys.path.append( '/Users/stephensaciolo/projects/computer-science/Data-Structures/stack/singly_linked_list.py') """ A stack is a value structure whose primary purpose is to store and return elements in Last In First Out order. 1. Implement the Stack class usin...
4.21875
4
smollm
622cc2195b2ccdccc3f92a4eabd6c191812b6c34
WindTalker22/Data-Structures
/stack/stack.py
3,751
null
null
null
null
""" Problem Someone just won the Code Jam lottery, and we owe them N jamcoins! However, when we tried to print out an oversized check, we encountered a problem. The value of N, which is an integer, includes at least one digit that is a 4... and the 4 key on the keyboard of our oversized check printer is broken. Fortun...
3.859375
4
smollm
1c323b59dde6aa53d36b569cb28556dbf8199be6
Rhysoshea/daily_coding_challenges
/google_codejam/2019/foregone_solution.py
2,120
null
null
null
null
""" Problem An alien robot is threatening the universe, using a beam that will destroy all algorithms knowledge. We have to stop it! Fortunately, we understand how the robot works. It starts off with a beam with a strength of 1, and it will run a program that is a series of instructions, which will be executed one at ...
4
4
smollm
e4fd30ea8d88ebd9007053ab6907d35905c3121a
Rhysoshea/daily_coding_challenges
/google_codejam/2018/saving_the_universe_again.py
4,850
null
null
null
null
''' The area of a circle is defined as pi.r^2. Estimate pi to 3 decimal places using a Monte Carlo method. Hint: The basic equation of a circle is x^2 + y^2 = r^2. circle inside a square 2r 1|--ooooooo--| | ooooooooo | |ooooooooooo| 2r | ooooooooo | -1|__ooooooo__| -1 1 area of...
4.46875
4
smollm
c525ecc7598bfde6fee772b1080ff03d29ad7cc2
Rhysoshea/daily_coding_challenges
/daily_coding_problems/daily14.py
1,325
null
null
null
null
""" You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a wall. Each False boolean represents a tile you can walk on. Given this matrix, a start coordinate, and an end coordinate, return the minimum number of steps required to reach the end coordinate from the st...
4.3125
4
smollm
606877454b9da944e973a319c732df5af00d61fa
Rhysoshea/daily_coding_challenges
/daily_coding_problems/daily23.py
3,969
null
null
null
null
''' Problem Vestigium means "trace" in Latin. In this problem we work with Latin squares and matrix traces. The trace of a square matrix is the sum of the values on the main diagonal(which runs from the upper left to the lower right). An N-by-N square matrix is a Latin square if each cell contains one of N different ...
3.546875
4
smollm
a41a7cab2e1d1657038fe5770f0e481ba4220bc1
Rhysoshea/daily_coding_challenges
/google_codejam/2020/vestigium.py
3,953
null
null
null
null
''' given a list of numbers and a number k, return whether any two numbers add up to k For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17 Bonus: can you do this in one pass? ''' def add_to_k(list, k): for i in range(len(list)): for j in range(1, len(list) - i): if (li...
4
4
smollm
b12a9eeb40ab28d4ccaec384162da184f3d1c755
Rhysoshea/daily_coding_challenges
/daily_coding_problems/daily1.py
458
null
null
null
null
''' For a 6x6 array, calculate the maximum hourglass sum where an hourglass is: a b c d e f g ''' def hourglassSum(arr): ans = 0 for x in range(int(len(arr)/2)+1): for y in range(int(len(arr[x])/2)+1): sum_nums = sum(arr[x][y:y+3]) + arr[x+1][y+1] + sum(arr[x+2][y:y+3]) ans ...
3.6875
4
smollm
9eeba07938408d8f892bc990211f39280b15a621
Rhysoshea/daily_coding_challenges
/other/hourglass_array.py
569
null
null
null
null
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. """...
3.96875
4
smollm
b510a544f3ad842bd88b85c52d93514ed9f36946
Rhysoshea/daily_coding_challenges
/leetcode/valid_parenthesis.py
1,137
null
null
null
null
# import the webapp2 module so we can get access to the framework import webapp2 # import the db module from appengine from google.appengine.ext import db # we'll create a simple Model class here. class PostName(db.Model) : # this model class has just one property - myname myname = db.StringProperty() # This c...
3.578125
4
smollm
df775d4606a88ca7aa7b3eefedc8ba81cd23f1fa
Aytros/CS1520
/class7/first.py
2,407
null
null
null
null
print('I want to calculate sphere, (set pi=3.1415)') r=int(input('Please enter radious of this sphere: ')) pi=3.1415 d=2*r c=round(2*pi*r,3) a=round(pi*r**2,3) v=round(4/3*pi*r**3,3) print() print('radious =',r) print('diameter =',d) print('circumference =',c) print('area =',a) print('volume =',v)
4.25
4
smollm
2c5940d088b898a912b67c3f8d532ec1ba20c841
GoldK11/Review
/day1.py
303
null
null
null
null
print("Welcome to Choose Your Own Adventure!") print(" ") print("Make sure to type your answer exactly how it is printed in the question!") print(" ") print(" ") print("Do you walk across the street?") choice = input("yes or no?") if choice == 'yes': print("You suddenly feel the need to commit a crime. Do you kill ...
4.1875
4
smollm
61ccb77df95e013731d2d257c44e204badc64ff7
elijahbeese1/chooseyourownadventure
/chooseAdventure.py
4,266
null
null
null
null
from permutation_non_recursive import _nodes BOARD_SIZE = 3 NUMBER_SIZE = BOARD_SIZE**2-1 graph = {} def nodes(): return _nodes() def adjacents(state): if graph.get(state) is None: graph[state] = _adjacents(state) return graph[state] def find_empty(state): i = NUMBER_SIZE while state % 10 != 0: s...
3.59375
4
smollm
9cf5056dbb468d90b6868e6056c3097bacd93f51
xanwerneck/analisedealgoritmos
/trab/deploy/graph_base.py
1,805
null
null
null
null
def quicksort(lista, pivot, right, nova_lista): if pivot < right: lim = Partition(lista, pivot, right, nova_lista); lista = nova_lista print pivot print lim + 1 quicksort(lista, pivot, lim+1, nova_lista); #quicksort(lista, lim+1, right, nova_lista); print lista def Partition(lista, pivot, right, nova_l...
3.9375
4
smollm
c9b7f6ec5734af6aab78c4beb426ef3ce642208e
xanwerneck/analisedealgoritmos
/quicksort.py
596
null
null
null
null
# Asks for a filename and tells you where it is from os import walk, path f = input("Find: ") # Ask for file to find; EXACT for root, dirs, files in walk("/"): # Go through everything if f in files: # If filename found.... print(path.join(root,f)) #...
4.15625
4
smollm
e078ab43347be83be9eaa612644c411b42e5dc72
hans-farnbach/python-sysadmin
/find.py
367
null
null
null
null
def askQuestion(question): while True: try: val = int(input(question)) except ValueError: print("Please input a integer between 0 and 100.") continue else: break return val def SMQ(): # def SMQtest(): data = open('smqLog.txt','a') ...
3.9375
4
smollm
5ec6d278833b7c69a13c8a29bc3099c8d84192d5
bionboy/SMQ
/SMQ_3.py
4,295
null
null
null
null
#Write a Python program to remove the intersection of a 2nd set from the 1st set. a = {1,2,3,4,5} b = {4,5,6,7,8} print("Sets:") print(a) print(b) print("Remove the intersection of a 2nd set from the 1st set using difference_update():") a.difference_update(b) print(a) a = {1,2,3,4,5} b = {4,5,6,7,8} print("R...
4.125
4
smollm
4bfd318e5ef480848ce26ea234d17a54e7bb1ce4
shreyashetty207/python_internship
/task 3 prb 5.py
407
null
null
null
null
#Write a Python program to map two lists into a dictionary. keys = ['Books', 'Pen', 'Paper'] values = ['#FF0000','#008000', '#0000FF'] stationary_dictionary = dict(zip(keys, values)) print(stationary_dictionary)
3.953125
4
smollm
e5681c3a213192abb533ce5a96b6784d073f07d7
shreyashetty207/python_internship
/task 3 prb 3.py
217
null
null
null
null
import random def checkGuess(secret, guess): if secret == guess: return(0) elif secret > guess: return(1) else: return(-1) def main(): print('please input your username') username=input() score=int(0) secret=int(len(username)+ (random.randint(0,10))) guesses=0...
4.0625
4
smollm
a47475281ea7c44990ea2be7b33336f296081f71
danalvin/guessing-game
/main.py
1,349
null
null
null
null
import random limit = 10 # score tracking variables score = 0 def get_valid_number(prompt, max): entry = input(prompt) valid = False while not valid: if entry.isnumeric() and int(entry) in range(1, max + 1): valid = True else: entry = input(f"Your entry must be bet...
4.0625
4
smollm
4c09d7f38d4698edc72cb452c31c9cb97293a5db
sablos/play_whe
/betting.py
2,052
null
null
null
null
def is_overlap(chr1, st1, end1, chr2, st2, end2): ''' Check if two regios are overlap. Parameters ---------- chr1 : str Chromosome ID of the first genomic region st1 : int Start coordinate of the first genomic region end1 : int End coordinate of the first genomic region chr2 : str Chromosome ID of th...
3.578125
4
smollm
0d0d845e08700da9b62f0670006921fc2913e2e0
liguowang/FusionVet
/lib/vetmodule/Overlap.py
780
null
null
null
null
import pyttsx3 import os pyttsx3.speak("Good Morning") print("Good Morning") #Python program using input function a = input ("Enter ur name: ") print ("Hi", a) pyttsx3.speak("Hi") print("Welcome to my chatbot".center(125)) pyttsx3.speak("Welcome to my chatbot") pyttsx3.speak("How can I help u") b =...
3.734375
4
smollm
0a8e9afed963b12ce070827e4eabe4a8f7cda9b8
pranjul26/Simple-Chat-bot
/humanprog.py
3,881
null
null
null
null
""" This class is responsible for storing all the information about the current state of a chess game. It will aslo be responsible for determining the valid moves at the current state. It will also keep a move log """ class GameState(): def __init__(self): #possible improvment - using numPy arrays ...
3.71875
4
smollm
7232fb34aecbdf5c7b2dc49b8e50e4b6dafc2b04
charliekelley21/Python_Chess
/ChessEngine.py
16,565
null
null
null
null
class Setting(): """ Clase que permite manejar las configuraciones del juego """ def __init__(self): """ Inicializa configuraciones predeterminadas """ # Configuración de la pantalla self.screen_width = 1200 self.screen_height = 650 self.bg_color = (26, 82, ...
3.53125
4
smollm
73d9d2d56f58a06e3c25bd633b5b616e111fca7a
Cruz-Bdllo/python-game
/setting.py
1,751
null
null
null
null
#!/usr/bin/env python print "*" * 60 print "Roth IRA Calculator - Version 1.0" print "Mark Gong-Guy" print "*" * 60 #Age Input and Variables retire_age = input("What age would you like to retire: ") current_age = input("What is your current age: ") moneyage = retire_age - current_age #Money Input and Variables curre...
3.890625
4
smollm
e5b0f51753521932207cec8184c9c18f127c0c77
mgongguy/Daily-Python-Script
/day14/rothcal
863