blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cf06594ee43636d9c74882b95b16399563b3797a
AmalieDue/TMTO-attack
/RainbowAttack.py
2,904
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Apr 19 13:39:32 2021 @author: andershartmann """ #Import useful packages to perform AES encryption from Crypto.Cipher import AES from Crypto.Random import get_random_bytes IV = get_random_bytes(16) #Definng the IV used in AES CBC-mode BLOCK_SIZE = 16...
e8d7c1dd9deace9e8390030452e96da4c91cbaf8
eron93br/CANbtl
/crc_check.py
779
3.921875
4
def crc_remainder(input_bitstring, polynomial_bitstring, initial_filler): ''' Calculates the CRC remainder of a string of bits using a chosen polynomial. initial_filler should be '1' or '0'. ''' len_polynomial = len(polynomial_bitstring) range_len_polynomial = range(len_polynomial) len_input = len(input_bitstrin...
e619675dd169f0ed9fd9204644bf0d924c3424ec
StMSoAP/gearcalc
/gearcalc.py
1,469
3.96875
4
import math #Say what you're going to do print ("\n" + "Welcome to Zombo.com!" + "\n" + "Wait, that's not right." + "\n" + "\n" "Welcome to a simple gearing calculator." + "\n" + "Trying to keep your legs from falling off?" + "\n" + "This might help." + "\n") '''implement mode choice here singl...
cd2b62fd46b7563c7fe18f9d724cbac6ffdde421
johanWallgren/projectEuler
/Euler3.py
548
3.734375
4
''' The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' import math def is_prime(n): if n % 2 == 0 and n > 2: return False return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2)) bigNum = 600851475143 primes = []...
300b5e7d7f1953c82c52825176a5cb79cb9c2fb9
Zsailer/np2d
/np2d/random.py
1,007
3.6875
4
from .base import * import numpy as _np @check_2d def choice(a, size=None, replace=True, p=None): """Choose random samples from a 2-D array. Parameters ---------- a : array 2-D array to sample size : int Number of elements to choose from array replace : bool Sample with...
8c139ad988ed7a84ccc21a666862cd040f6c72d7
stumash/hanoiSim
/hanoi_player.py
2,067
4
4
# towers.py: a program that # beats a game of Towers of Hano # imports from hanoi_board import HanoiBoard def main(): f = open("debugOutput.txt", "w") # string constants NUM_RINGS_ASK = "How tall should this Towers of Hanoi be? " BAD_INP_TYPE_MSG = "Must input positive integer." # initialize th...
132cca3c179809353228d36efe6d215648374b5e
CoomaQin/intro_to_Ai
/search/grid_draw.py
1,031
3.625
4
from tkinter import * from matrix import generate_maze # from search_algs import * def draw_grid(grid, startx=20, starty=20, cellwidth=20): master = Tk() canvas = Canvas(master, bg="white") canvas.pack() colors = ['white', 'gray', 'black', 'red', 'white', 'white'] width = 2 * startx + len(grid) ...
2df34fd0c2e4a6f70c78a56800ad81df915334da
hanao18182/100nk
/100nk05.py
1,292
3.8125
4
#UTF-8を設定しておく #coding: utf-8 """bigram(2文字づつ抜き出す場合)文字数10文字の場合9個出力される trigram(3文字づつ抜き出す場合)文字数10文字の場合8個出力される 上記のように抜き出したい文字数(例えば10文字の時)は2文字づつだと-1の9個出力 3文字づつだと-2の8個出力4文字づつだと-3の7個出力されると規則性が存在する。""" #入力されたbun(文章)を1文字(単語)ずつ、ずらしながらn文字分抜き出す #def n_gram(n-gramの関数) (引数1、引数2) def n_gram (bun,n): #returnを利用して与えられた文章を1文...
6be60e62680b575e2b0e3dddcc73e0a9101ee0ce
hanao18182/100nk
/100nk09.py
2,482
3.984375
4
#UTF-8を設定しておく #coding: utf-8 import random #英語の文を入力させ用意しておいたbunに格納する #inputで相手に入力させることができる bun = "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind." #Typoglycemia関数を作成しinputで入力されたbunの5文字以上のものをランダムに生成するものを作成する def Typoglycemia(bun): #result(戻り値)のリストを...
93039a31ebb56de2da60220d108bb7ef18a4609e
danielvargas97/ejemplosPython
/Substraction.py
4,782
3.625
4
# -*- coding:utf-8 -*- # #Substraction - Example# #EJEMPLO de Substraccion# #SE SUPONE QUE NO HAY NADA QUE AGREGAR NI NADA QUE QUITAR# #DENTRO DEL DISEÑO# from random import * class MazoAbs(object): def revolver_mazo(self): pass def llenar_mazo(self): pass def ver_mazo(sel...
032e58c74091082fc3f66eb8150a817016332b3f
danielvargas97/ejemplosPython
/Facade.py
818
3.515625
4
# -*- coding: cp1252 -*- class Banio: def entrar(self): print("entrando al bao") def salir(self): print("saliendo del bao") class Shampoo: def aplicar(self): print("aplicando shampoo") class Jabon: def enjabonar(self): print("enjabonarse") class Lava...
73bf93510cc899a992acd00c565adc489366b0b1
him2000pat/python-practice-tests
/PythonPractice/Palindrome.py
668
4.28125
4
def palindrome(input): if input is None: return None if len(input) == 1: return "Not a valid input" revStr = reverse(input) if(input == revStr): print("{0} is Palindrome".format(input)) else: print("{0} is Not Palindrome".format(input)) def reverse(input): #...
708ba319dc9fe5cc70ba2809188a6a9a7fc0c6e5
aa-ag/ds_and_a_projects
/Show_Me_the_Data_Structures/problem_4.py
2,629
3.640625
4
############------------ HELPER CODE ------------############ class Group: def __init__(self, _name): self.name = _name self.groups = set() self.users = set() def add_group(self, group): self.groups.add(group) def add_user(self, user): self.users.add(user) def ...
9adb760ed5fd8b0ea25623239194e8e39a504065
aa-ag/ds_and_a_projects
/Show_Me_the_Data_Structures/problem_6.py
5,154
3.953125
4
############------------ HELPER CODE ------------############ class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class LinkedList: def __init__(self): self.head = None def __str__(self): curren...
61bb649e38015c08665519d496dc81c39d8d344e
Codfor/myPractice
/count words2.py
980
4.46875
4
# count most used word in a text file word_counter = dict() # enter the text you want to count words open_file = input('enter your text: ') # split words to create a list for the dictionary read_file = open_file.split() print(read_file) # loop through the list to add words and their counts to the dictionary for wor...
edabbf5f5ddfef945ff49be8ef0e1f8f588bac9d
infrasparker/Rendering
/ray_tracer_p3b/classes.py
5,371
3.515625
4
class Surface: def __init__(self, cdr, cdg, cdb, car, cag, cab, csr, csg, csb, p, krefl): self.cdr = cdr self.cdg = cdg self.cdb = cdb self.car = car self.cag = cag self.cab = cab self.csr = csr self.csg = csg self.csb = csb self.p = p ...
e4f4a05b108c90cd4d84fb3a6832906df7869365
gilsonsf/hadoop-platform
/files/join2_mapper.py
344
3.515625
4
#!/usr/bin/env python import sys for line in sys.stdin: line = line.strip() key_value = line.split(",") tv_show = key_value[0].strip() count_channel = key_value[1].strip() if count_channel.isdigit() or count_channel[0:3]=='ABC': print( '%s\t%s' % (tv_show, coun...
18ec958f503277e837c8f89b2e25f70229f48fe1
NurbekSakiev/HackerRank
/Python/Algorithms/Warm_Up/Song_of_Pi.py
432
3.546875
4
# Hacker Rank (www.hackerrank.com) # Song of Pi # author: Nurbek Sakiev import string T = int(raw_input()) pi = "31415926535897932384626433833" for i in xrange(T): my_str = raw_input().split() current = 0 check = 0 list = [] for j in my_str: list.append(str(len(j))) check = ''....
759630f791a7d51b45f7066883b5a5f9f45fa1d5
soraef/nlp100
/1/3.py
218
3.625
4
text = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." words = text.replace(",", " ").replace(".", " ").split() words_count = map(len, words) print(list(words_count))
3cec8eaf6f68590519155613b2667106672eb034
soraef/nlp100
/1/8.py
330
3.75
4
import re def convert(match): return chr(219 - ord(match.group())) def cipher(text): return re.sub(r"[a-z]", convert, text) # p21 名前に情報を追加する plain_text = "ABCdefg1234あいうえおに" encrypted_text = cipher(plain_text) print(encrypted_text) plain_text = cipher(encrypted_text) print(plain_text)
3925d30acfe3fdac1b4e60ec3bd0de9a1cabc024
soraef/nlp100
/1/6.py
440
3.625
4
def ngram(n, words): ngrams = [] for i in range(len(words)): if(i+n > len(words)): break ngrams.append(words[i:i+n]) return ngrams text1 = "paraparaparadise" text2 = "paragraph" X = set(ngram(2, text1)) Y = set(ngram(2, text2)) print(X | Y) #和集合 print(X & Y) #積集...
797efee005c384f88bf1d318d1629ce4159aafa4
soraef/nlp100
/6/51.py
871
3.640625
4
import re file_path = "../data/nlp.txt" def load_file(path): with open(path) as f: data = f.read() return data # テキストを分割 def split_text(text): return re.findall(r"(.*?[.;:?!])\s\n?(?=[A-Z])", text) # 記号を除去 def remove_symbol(text): return re.sub(r"[.;;?!()'\",]", "", text) text = load_file(f...
c434d9efce42b66624a64526ab754650f68150ad
mmucha123/gitrepo
/python/figury.py
392
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # figury.py # def main(args): a=int(input("podaj 1, liczbę: ")) b=int(input("podaj 2, liczbę: ")) z=(input("podaj znak: ")) for i in range(a): for j in range(b): print(z, end='') print() return 0 i...
5c57ace2e2b561762a53c7f86ee02cae13fe9bfe
vickychen928/TSP-Problem
/TSP_final_english.py
10,937
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu May 13 00:29:23 2021 @author: vicky """ import numpy as np import pandas as pd import random from itertools import combinations import copy import time import matplotlib.pyplot as plt ##Dynamic Programming class Dynamic_Programming: def __init__(self, vertex_num): ...
10fa3b982415515ffda6f72dc5e92940400616e3
saikiran1111/Python-Notes
/regularexpressions.py
1,175
4.09375
4
#re-defining regualar expression import re module import re #Method # match-- match operation at the starting of the string and create match if finds any pattern.. # search-- # findall # compile #654 645-5453 #\d-digits #\w-alphanumeric #{}-specifing the length # r'\d{3} \d{3}-\d{4}' # match1=re.match(r'\d{3} \...
0d8cc6d111b1c4a236ad0fe9e998c026236caac5
saikiran1111/Python-Notes
/functions.py
1,504
4.25
4
#set of statements that will do a specific task #defining a fucntions # def functionname(): # statement # def addition(): # print(3+4+5+6) # addition() # def addition(a,b): # print(a+b) # addition(3,4) # addition(5,6) #passing arguments #1.Default arguments # def addition(a,b=10): # print(a+b) # addition...
0516b723b0a18d3ec4fd788aa062b74c516e1508
saikiran1111/Python-Notes
/tuples.py
288
3.65625
4
a=4,5,6,"python",[11,12,13,14] # print(type(a)) # a=(4,) # print(type(a)) # print((1,2,3)+(4,5,6)) # print((1,2,3)*4) # print(a[4]) # print(a[0:3]) # print(a[0:5:2]) a[4][1]="a" print(a) # print(a) print(a.count(5)) print(a.index(6)) print(max(a)) print(min(a)) print(len(a))
e735c1cf652b1af67c34dca020928e27f61d2a70
vinod-designer1/algos
/euler/prob1/prob1.py
197
3.53125
4
sumMultiples = 0 for i in range(3,1000): if i%15 == 0: sumMultiples += i elif i%5 == 0: sumMultiples += i elif i%3 == 0: sumMultiples += i print(sumMultiples)
27844fa57a70903eec87ca6408d6c71b11a3d1c1
THINK989/Neural-Network-from-Scratch
/MLP_from_scratch/initialization_of_parameters.py
5,248
3.875
4
import numpy as np np.random.seed(9) #used so that we get the same random values generated everytime """ Layer dimension is an array with values specifying number of nodes in each layer eg:- [3,4,2] here, layer1 has 3 nodes #weights1 with shape(4,3) and #bias1 with shap...
b9a28fe95422ba70f696bb97125cf940caa16b19
bellyfat/keystore
/cks-py/cks/benchmark.py
537
3.53125
4
def read_input(filename): with open(filename, "r") as f: lines = f.readlines() lines = [l.strip() for l in lines] data = [float(l) for l in lines] return data def read_twocolumn(filename): with open(filename, "r") as f: lines = f.readlines() lines = [l.strip() fo...
04f2d8d807a62a6e273f1e0dabb858eb2a55933c
JMaio/deliver.ai
/raspi-i2c/motor_mover.py
2,361
3.890625
4
import smbus # import time class MotorMover(object): ''' This class interfaces with the Motor Control board connected to the I2C pins on the Rasberry Pi. It is based off a basic Arduino class called SDPArduino.cpp (which at the time of writing is available from http://homepages.inf.ed.ac.uk/gd...
2e68b5d86554f742129742272eaf9027435bf923
JMaio/deliver.ai
/navigation/office.py
705
3.609375
4
#! /usr/bin/env python3 class Office(): def __init__(self, name="HOME", coords=(0, 0)): self.name = name self.coords = coords self.right = None self.left = None self.upper = None self.lower = None def setRightNeighbour(self, office): self.right = office...
9c3eaa80314f666e9549d2650893f425508685fa
hafdhisofien/holbertonschool-interview
/0x00-lockboxes/0-lockboxes.py
439
3.78125
4
#!/usr/bin/python3 def canUnlockAll(boxes): """ Method to check if all boxes can be opened """ if len(boxes) == 0: return False keys = [0] seen = 1 for key in keys: for i in boxes[key]: if i not in keys: if i != key and i < len(boxes): ...
b7d132d47f8448aeb6077d1264063bf458f2674c
thran/the_code
/Project Euler/014 - Collatz sequance.py
305
3.609375
4
def next_collatz(n): if n % 2 == 0: return n / 2 return 3 * n + 1 def collatz_lenght(n): if n == 1: return 1 return collatz_lenght(next_collatz(n)) + 1 m = 0 best = 0 for i in range(1, 10**6): l = collatz_lenght(i) if m < l: m = l best = i print m, best
6eae12c83259717c7ab63cd65241935389be6453
thran/the_code
/Project Euler/058 - spiral primes.py
361
3.78125
4
from primes import is_prime skip = 0 last = [1] * 3 side = 1 primes = 0 count = 1. while True: count += 4 side += 2 for i in range(3): skip += 2 last[i] += skip skip += 2 for n in last: if is_prime(n): primes += 1 print primes / count if primes / count...
84f192e8c07c7fefda69c1f19fd833af9e921d07
thran/the_code
/Project Euler/052 - permuted multiples.py
281
3.5625
4
def digits(n): s = list(str(n)) s.sort() return "".join(s) def check(n): s = digits(n) for i in range(2, 7): if s != digits(i * n): return False return True i = 1 while True: if check(i): print i break i += 1
662f428366b6a8713dd89bf3fadea9f707bd452f
thran/the_code
/primes.py
1,191
3.640625
4
from fractions import Fraction from functools import reduce from math import sqrt from collections import defaultdict from utils import memoize @memoize def factorization(n): found_primes = defaultdict(lambda: 0) while n > 1: found = False for i in primes(): if n % i == 0: ...
a0b9804233303ece47a99a027bb5fbc1651182e4
thran/the_code
/interlos/2021/p5.py
424
3.6875
4
numbers = ['⋅', '∶', '⋮', '∶⋮', '∶∶', '∶⋅', '⋮⋅', '⋮∶', '⋮⋮'] n = '⋮⋮⋅∶⋅⋅⋮⋅∶∶⋅⋮∶⋅∶' def expand(A): l = max(map(len, A)) C = ['⋅' * (l - len(n)) + n for n in A] B = ['∶' + n for n in C[::-1]] C = ['⋮' + n for n in C] return A + B + C while n not in numbers: numbers = expand(numbers) print(...
5183a92f9a0aaea1c59c1a351e921c7643a4d07a
aschmied/advent-of-code-2020
/day10/test_main.py
1,499
3.8125
4
import unittest from main import count_valid_arrangements class TestCountValidArrangements(unittest.TestCase): def test_base_case(self): self.assertValidArrangements([1, 2], 1) self.assertValidArrangements([1, 4], 1) self.assertValidArrangements([1, 5], 0) def test_three_numbers__excl...
235952359f59846be59f4a8e1e30ba33f4418ca0
aschmied/advent-of-code-2020
/day13/main.py
2,916
4.1875
4
import itertools import math def main(): lines = read_notes('input') arrival_time, bus_ids = parse_notes(lines) bus_id, wait_time = find_earliest_bus(arrival_time, bus_ids) print(f'The earliest bus I can take has ID {bus_id} and I will have to wait {wait_time} minutes for it.') print(f'The product ...
3cb1e9373ab831030694e9b4c3b5bb33d6822d45
Aldemerian/RLP-XML
/skilldb.py
1,814
3.703125
4
import sqlite3 import uuid ''' sqliteConnection = sqlite3.connect('SQLite_Python.db') cursor = sqliteConnection.cursor() sql_command = """ CREATE TABLE SqliteDb_developers ( id VARCHAR(36) PRIMARY KEY, name VARCHAR(128), email VARCHAR(128), joining_date VARCHAR(128), salary VARCHAR(128));""" cu...
176f4b500da7c3a6c1b79ea8436a05fc0699afee
parradox26/learning-python
/binaryquery.py
1,130
3.625
4
n, q = map(int,input().split()) nlist=list(map(int,input().split())) for query in range(q): query=input() if query[0] == '1': print(nlist) t,x = map(int,query.split()) if nlist[x-1] == 1: nlist[x-1] = 0 else: nlist[x-1] = 1 print(nlist) else: ...
fa953f843b817725a96ac8108b60f6fe11f619bd
Hassan6678/Python_Tasks
/Task 06.py
475
4.28125
4
'''Sqaure Root''' def squareroot(number): if number == 0: return 0 # Step 1 --> take initial guess guess = number/2.0 # Step 2 --> Take second guess2 guess2 = guess + 1 # Step 3 while guess != guess2: n = number / guess guess2 = guess guess = (guess + n) / 2...
b95e324f6f5bbad56ecd61805ffa894c167a571f
Shweta-yadav12/Files
/FileQ3.py
387
3.5625
4
# Courses # Login/Signup # Question 3 # Aapke paas ek list hai. Iss list mein har string ko ek file-question3.txt naam ki file mein nayi line # mein daalo. Aapki list yeh rahi: banks_list = ["Kotak\n", "HDFC\n", "RBL\n", "SBI\n", "Bank of Baroda\n"] # for i in banks_list: f=open("people3.txt","w") i=0 while i<len(...
c55a547f845ad09456f09695206c86b27ec9f591
crisgrim/python-katas
/10-kata.py
906
3.734375
4
from random import * def generaNumeroAleatorio(minimo, maximo): try: if minimo > maximo: aux = minimo minimo = maximo maximo = aux return randint(minimo, maximo) except TypeError: print("Debes escribir numeros") return -1 numero_buscado = ge...
adbe596a908bc5144c4de789233bd44b5e27eca8
crisgrim/python-katas
/15-kata.py
262
3.984375
4
def lessthan(a,b): if a < b: print(str(a) + " is less than " + str(b)) elif b < a: print(str(b) + " is less than " + str(a)) else: print(str(a) + " and " + str(b) + " are equals") lessthan(5,8) lessthan(10,4) lessthan(20,20)
b8d53a8fcf32be032e9d331e82d8c51563bc14a9
DYJ1111/Algorithm_not_be_confused
/Week_04/1-4 模拟行走机器人.py
845
3.578125
4
class Solution: def robotSim(self, commands: List[int], obstacles: List[List[int]]) -> int: # 贪心 # time: O(n * len(commmand)), space: O(obstacles) x, y = 0, 0 obstacles = set(map(tuple, obstacles)) max_distance = 0 dx, dy = 0, 1 # x have left and right, y have up and...
549ef57f6353050fe1c83ca7ef8e9db7a342e704
DYJ1111/Algorithm_not_be_confused
/Week_02/2 两数之和.py
830
3.5
4
def twoSum(self, nums: List[int], target: int) -> List[int]: """ 1. 暴力,双循环 O(n^2) """ """ method 2 遍历一次存入hash,再遍历第二次查询 target-num 是否存在于hash O(n), O(n) """ dic = {} # key val: num , index for i in range(len(nums)): dic[nums[i]] = i for i in range(len(nums)): ...
96ef375557e799ed23b01f1d9d9f62b20d41c83f
DYJ1111/Algorithm_not_be_confused
/Week_02/3 N叉树的前序遍历.py
634
3.703125
4
def preorder(self, root: 'Node') -> List[int]: res = [] # def recursion(root): # if not root: # return # res.append(root.val) # for child in root.children: # recursion(child) # recursion(root) # return res """ 迭代法:参考二叉树前序遍历的迭代法 O(N), O(N) ...
53b3585e4928a547cf24d0dbf9f27b1ad013534f
sunny2309/scipy_conf_notebooks
/Numpy-Tutorial-SciPyConf-2016/exercises/wind_statistics/wind_statistics.py
2,585
4.125
4
# Copyright 2016 Enthought, Inc. All Rights Reserved """ Wind Statistics ---------------- Topics: Using array methods over different axes, fancy indexing. 1. The data in 'wind.data' has the following format:: 61 1 1 15.04 14.96 13.17 9.29 13.96 9.87 13.67 10.25 10.83 12.58 18.50 15.04 61 1 2 14...
be6e7bcb12553c66b7eb4b747e89d7b88f6efd7c
sunny2309/scipy_conf_notebooks
/Network-Analysis-Made-Simple/solutions/03-extract_neighbors.py
364
3.515625
4
# Possible Answer def extract_neighbor_edges(G, node): neighbors = G.neighbors(node) newG = nx.Graph() for n1, n2 in G.edges(): if (n1 == node and n2 in neighbors) or (n1 in neighbors and n2 == node): newG.add_edge(n1, n2) return newG fig = plt.figure(0) newG = extract_neighbor_e...
219298f8f3c0040f9617990861f7456729d05ce3
susverwimp/T208-Probabilistic-Programming-A-Case-Study
/programming/anglican/ppaml-summer-school-2016/lectures/intro-to-clojure/snippets/factorial.py
485
4.15625
4
from __future__ import print_function import sys def factorial(n): '''computes n * (n - 1) * ... * 1''' if n == 1: return 1 else: return n * factorial(n - 1) def factorial_loop(n): '''computes n * (n - 1) * ... * 1''' result = 1 for n in range(2, n + 1): result *= n ...
ee0d84932be0184ce20b7d32e00b06bca1af5c85
susverwimp/T208-Probabilistic-Programming-A-Case-Study
/programming/anglican/ppaml-summer-school-2016/lectures/intro-to-clojure/snippets/looping.py
324
4.03125
4
def factorial(n): '''computes n * (n - 1) * ... * 1''' result = 1 for n in range(2, n + 1): result *= n return result def factorial(n): '''computes n * (n - 1) * ... * 1''' result = 1 ivals = range(2, n + 1) while ivals: i = ivals.pop(0) result *= i return re...
f7b2acd56457f804acbeac39a74e270dba787564
Moli19931/Python-program-to-check-2pl-protocol
/Mallika_2pl_final.py
4,976
3.515625
4
#----------------------------------------------------------- trans = [] #It is used to store all the transaction in list format f = open("Transactions_4.txt") #f = open("file.txt") ts = {} #it is used to store the timestamp of the transactions maxoptr = {} #it is used to store the value of...
949d1c08fcf8cfaf9f88cc7a48b4a5cbd5fed163
HarryBurnGFT/Decorators
/main.py
888
3.546875
4
# This is a sample Python script. # Press ⌃R to execute it or replace it with your code. # Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press ⌘F8 to togg...
6e92a4963353acc56c701ca909c6b759fea9ba64
RudyHarun99/Morse
/Fibo.py
220
3.5
4
class fibo: def cek(self,x): if x<2: return x else: return self.cek(x-1)+self.cek(x-2) fibonacci=fibo() print(fibonacci.cek(1)) print(fibonacci.cek(6)) print(fibonacci.cek(10))
040460ab2618c869894b7f549b2839f5aef69d03
RudyHarun99/Morse
/Kondisi.py
2,982
3.953125
4
# #Kondisi if adalah kondisi yang akan dieksekusi oleh program jika bernilai benar atau TRUE # nilai = 9 # #jika kondisi benar/TRUE maka program akan mengeksekusi perintah dibawahnya # if(nilai > 7): # print("Selamat Anda Lulus") # #jika kondisi salah/FALSE maka program tidak akan mengeksekusi perintah dibawahny...
d72951f87c32632cc956f19a2fb95c0f17b141b7
kingdom32307/lemon_hpo
/optimizer/parzen_estimator/kernel.py
6,020
3.5
4
import numpy as np from scipy.special import erf from optimizer.constants import EPS, sq2, sq_pi class GaussKernel(): def __init__(self, mu, sigma, lb, ub, q): """ The hyperparameters of Gauss Kernel. mu: float In general, this value is one of the observed values. sigm...
5d2f2485572e66a0f39832901539b6f7be58623a
Klitke/python-practice
/OOP/static-and-class-methods.py
785
3.609375
4
class Employee(): # class variable num_emps = 0 def __init__(self, emp_num): self.emp_num = emp_num Employee.num_emps += 1 @staticmethod def print_num_emps(): print(Employee.num_emps) @classmethod def change_num_emps(cls, num_emps): cls.num_emps = num_...
f2fe403e52ab3e5893124410a0e2f45bbb270b3c
DatAsian218/Python-Exercises-and-Activities
/Python Work/HW from Lessons/LessonFourHW/LessonFourHW.py
15,972
3.9375
4
""" Alexandra Triampol 7/12/16 This is a code for double transposition. It will decipher a text file called encrypted_logs.txt. There is an encrypt() method and decrypt() method. """ # allows code to read encrypted_logs.txt file encryptedLogs = open('encrypted_logs.txt',"r") textFile = encryptedLo...
339589c52f0859e0d8a1fd5c4d36f58d18ed2c7d
DatAsian218/Python-Exercises-and-Activities
/Python Work/HW from Lessons/Lesson1HW/DrJDansGuestGreeter.py
595
4.46875
4
""" Alexandra Triampol 6/21/16 This code creates a greeting that uses user input such as their full name, age, and favorite ice cream. """ # takes in user input for the greeting fullName = input("What is your first and last name?: ") age = input("How old are you? (if you don't mind me asking): ") iceCream = input("Wh...
fd94bef0740174ef6f776c933474cc1e8986661a
RonCom/algorithm_specialisation
/1.Algorithmic_Toolbox/5.Dynamic_Programming/placing_parentheses.py
1,863
3.5
4
# Uses python3 import re,sys def evalt(a, b, op): if op == '+': return a + b elif op == '-': return a - b elif op == '*': return a * b else: assert False def get_maximum_value(dataset): #write your code here list1 = re.split('\+|-|\*|/',dataset) for i in ra...
99d0d297c9de6f906a8a17a1831c50534932d584
RonCom/algorithm_specialisation
/3.Graphs/2.Decomposition_Graphs_2/strongly_connected.py
1,584
3.90625
4
#Uses python3 import sys sys.setrecursionlimit(200000) visited = {} visited_rev = {} exp = [] '''These functions are for exploring the given graph''' def explore(adj, x): #write your code here visited[x] = 1 for w in adj[x]: if visited[w] == 0: explore(adj, w) exp.insert(0, x) def dfs(adj): #write your ...
e5740953f2adc16db2c2ee2438df273dd8eb7980
Avaneesh-Nisal/Digits-or-Letters.py
/Digit or Letter.py
335
3.96875
4
input1 = input('Enter first input: ') input2 = input('Enter second input: ') if input1.isdigit() and input2.isdigit(): print(int(input1) + int(input2)) elif not input1.isdigit() and not input2.isdigit(): print(input1, input2) else: print('One of the given values is a string and the other is integer. Try...
8b7ef1c13148b1e093fcce10d8d496509136c428
Madeyro/recommender
/algorithms/utils.py
1,915
4.21875
4
#!/bin/pyhton3 def normalize(df, col_name, replace=True): """Normalize number column in DataFrame The normalization is done with max-min equation: z = (x - min(x)) / (max(x) - min(x)) replace -- set to False if it's desired to return new DataFrame instead of editing it. """ co...
7eedd099f606a778ab175ccdfd948306140ccd95
BabyYang2049/STF_RNN
/utils/Point.py
1,608
3.5
4
from datetime import datetime, date, time from haversine import haversine import math class Point(object): def __init__(self, lat, long=None, the_date=None, the_time=None, **kwargs): if isinstance(lat, Point): self.lat = lat.lat self.long = lat.long self.date = la...
6d51d32b13f097e4d139f2d16662881475c16f1c
Lorranysousc/EstruturaDeDecisao
/ListaDeExercicios/ex10.py
711
4
4
'''10. Faça um Programa que pergunte em que turno você estuda. Peça para digitar M-matutino ou V-Vespertino ou N- Noturno. Imprima a mensagem "Bom Dia!", "Boa Tarde!" ou "Boa Noite!" ou "Valor Inválido!", conforme o caso.''' turno = str(input(f'Olá! \nEm que turno você estuda? \n[M]matutino [V]vespertino [N]noturno\n...
e3f89c2366ea951b52819ea2b51c266fbe7f143e
Lorranysousc/EstruturaDeDecisao
/ListaDeExercicios/ex06.py
385
4.15625
4
'''6. Faça um Programa que leia três números e mostre o maior deles.''' num1 = float(input('1º número: ')) num2 = float(input('2º número: ')) num3 = float(input('3º número: ')) #Testando possibilidades if num2 < num1 > num3: maior_numero = num1 elif num1 < num2 > num3: maior_numero = num2 else: maior_numer...
be7198ffc84210718fd20403fc90c1a6914238af
kaushikmit/hotspotprediction
/predict.py
883
3.859375
4
# Import the linear regression class from sklearn.linear_model import LinearRegression from matplotlib import pyplot as plt import numpy as np # Initialize the linear regression class. regressor = LinearRegression() data = np.genfromtxt('predict.csv', delimiter=',', names=['temp', 'vapour','cloudcover','precipt','...
5c769c997339f87736df36da01d9c4cd6d9e459c
luoyuedong/python-data-structure-algorithm
/算法/on^2排序算法.py
1,729
3.890625
4
from random import randint import timeit def bubble_sort(alist): n = len(alist) for i in range(n-1): exchang = False for j in range(0,n-1-i): if(alist[j]>alist[j+1]): alist[j], alist[j + 1] = alist[j + 1], alist[j] exchang = True if...
89a23eebece493ffcf649cd28cd1231dd9eb6b06
rzsquirrel/syslab_files
/reversequiz.py
2,398
4.21875
4
######################### #Reed Zhang p. 1 12/4/14# ######################### from copy import deepcopy def reverseLst(Lst): return [Lst[i] for i in range(len(Lst)-1,-1,-1)] #------------------------------------------------------------------------------------------------------------ def main(): #---Method 1. Use ...
b71e5cafc1a647dcc2ed8aa3334a3686d4050508
rzsquirrel/syslab_files
/flower.py
2,158
3.5625
4
######################## #Reed Zhang p.1 3/25/15# ######################## def setUpCanvas(root): root.title("Fractal Flowers by Reed Zhang") canvas = Canvas(root, width=root.winfo_screenwidth(), height=root.winfo_screenheight(), bg="black") canvas.pack(expand=YES, fill=BOTH) return canvas def displa...
51e1ee93e0bc07ecbaac122958f3eeabf6e19588
violetyk/study-effective-python
/fib.py
277
3.609375
4
#!/usr/bin/env python3 # print(__name__) # fib # フィボナッチ数列(前の2つを加えると次の数になる) def fib(n): a, b = 0, 1 while a < n: print(a, end= ' ') a, b = b, a + b # print() def myfunc(): print('myfunc!')
9e42ba4e4619de72d1961c87de2adb8c9651423f
violetyk/study-effective-python
/loops.py
1,229
4.46875
4
#!/usr/bin/env python3 def main(): # リスト values = [0, 1, 2] for value in values: print(f'The value is {value}') # タプル values = (0, 1, 2) for value in values: print(f'The value is {value}') # 辞書はそのままだとキーがループされる items = {'a': 1, 'b': 2, 'c': 3} for key in items: ...
7ecd7a88dd79e0ea2b8452f1c199c2a5cdc47898
rolnasz95/car_loan_calculator
/main.py
2,586
4.1875
4
import CarLoan def main(): # Empty list to store CarLoan objects loanList = [] while True: customerName = input("Enter name of the customer (or q to quit): ") # Exit loop if user input is q or Q if customerName == 'q' or customerName == 'Q': print("Done creating cust...
324d69f4660676e45da019ae1f5d8a28fb9e1e2a
hamzalimouri/leetcode_Top_Interview_Questions
/Array and Strings/Valid Sudoku/isValidSudoku.py
603
3.609375
4
from collections import defaultdict class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: row = defaultdict(set) col = defaultdict(set) box = defaultdict(set) for i in range(9): for j in range(9): n = board[i][j] if n !...
7675656bda0ebbe1dfbcc916cac2f30abfb3e544
mhsNSnair/My-Work
/ICS3U/Unit 3/Nicholas_Snair_ConditionalPractice01.py
952
4.65625
5
""" course: ICS3U filename: Nicholas_TRIANGLE_PROBLEM date: 26/02/20 name: Nicholas Snair description: Given 3 side lengths it will tell you wether these lengths would give you a triangle tha tis Equilatera, Isosceles, or Scalene. """ # Prompts the user for the side lengths of a trian...
d2923afbf448fde8a80eeceeb6c0db0a5b400519
mhsNSnair/My-Work
/ICS3U/Unit 4/Nicholas_envImpact.py
3,769
4.5625
5
""" course: ICS3U filename: Nicholas_envImpact date: 04/01/20 name: Nicholas Snair description: This program is a database taht will teach you the enviromental impacts of computers in the context of highschools. """ #Welcomes the user to the program print ("\033[1;37;40m\nWelcome to the environmental impact dat...
a13c47c3fb2c4f0e34749bfad9ae4da308596090
mhsNSnair/My-Work
/ICS3U/Unit 5/Lists p 5.py
166
3.921875
4
print('Please input a list of numbers') sum = 0 list = input().split() for s in range (len (list)): sum+=int (list[s]) print ("The sum is",sum)
4d1fdb85d7e76c0ea14d1b04657b2c18fa37dc3e
TopMaths/LogiqueBinaire
/Shift.py
334
3.765625
4
a=12 FormatDec="en décimal : {} << {} = {} " FormatBin="en binaire : {} << {} = {} " for i in range(3): print(FormatDec.format(a, i, a<<i)) print(FormatBin.format(bin(a), i, bin(a<<i))) print() for i in range(3): print(FormatDec.format(a, i, a>>i)) print(FormatBin.format(bin(a), i, bin(a>>i)))...
9938e33c76b4da03a324cb2fd70dd679d1572a7a
wenyoufu/Python-Programming
/chapter_10_文件和异常处理/1_文本文件分隔_异常处理_示例/分析文本.py
902
4.03125
4
# !/usr/bin/env python # -*-coding:utf-8 -*- """ # File : 分析文本.py # Time :2019/12/16 14:17 # Author :Yan You Fei # version :python 3.6 # Description: """ # title = "Alice’s Adventures in Wonderland" # print(title.split()) # split()以空格分隔符将字符串拆成多个部分 def count_words(filename): """计算一个文件大致包...
094c70d8d2ac3fb81980f4aaacc9106c1136a3d7
wenyoufu/Python-Programming
/chapter_10_文件和异常处理/1_文本文件分隔_异常处理_示例/练习_10_猫和狗.py
711
3.703125
4
# !/usr/bin/env python # -*-coding:utf-8 -*- """ # File : 练习_10_猫和狗.py # Time :2019/12/16 15:57 # Author :Yan You Fei # version :python 3.6 # Description: """ def print_content(filename): """打印文本中的内容,对文件不存在的异常问题进行处理""" try: with open(filename,'r',encoding='utf-8') as f: ...
3746884f43017dd0b2f923f34768560fd7754252
wenyoufu/Python-Programming
/chapter_10_文件和异常处理/1_文本文件分隔_异常处理_示例/练习_10_统计常见单词数.py
721
4.09375
4
# !/usr/bin/env python # -*-coding:utf-8 -*- """ # File : 练习_10_统计常见单词数.py # Time :2019/12/17 9:32 # Author :Yan You Fei # version :python 3.6 # Description: """ def count_words(filename,word): """统计文件中,某个单词的数量""" try: with open(filename,'r',encoding='utf-8') as f: c...
c03f6a076d84ecd5d886051515d3a779d36fc665
lyb1527/data-structures
/hash-function.py
736
4.09375
4
''' Hash functions are used to convert a string or any other type into an integer smaller than hash size and bigger or equal to zero. A good hash function can avoid collisions as few as possible. A widely used hash function algorithm is using a magic number 33. Hashcode('abcd') = ascii(a)*33^3 + ascii(b)*33^2 + asci...
d6391dade4422d55ae8886daab084b0fc42ec567
johnwatterlond/think_python
/rotate_pairs.py
1,182
4.5
4
""" Two words are rotate pairs if you can rotate one of them and get the other. This exercise asks to find all rotate pairs. """ from words import word_set def rotate_letter(l, n): """Shift/Rotate the letter l by integer n.""" return chr(((ord(l) - ord('a') + n) % 26) + ord('a')) def rotate_word(w, n): ...
4b53953355e939fc4005eaabc48bc86e5dec8139
vaib999/Computer-Architecture
/moesi.py
6,626
3.515625
4
table = {'00':'I','01':'I','02':'I','03':'I','10':'I','11':'I','12':'I','13':'I','20':'I','21':'I','22':'I','23':'I'} def read(cache,line): state = table[cache+line] if state == 'I': print() print("Cache",cache,"Bus Read",line) print("Miss") print() return Fals...
fb054b2c42b77e873561587913bb0af0badf5e94
dhavalshah18/PLARR2020
/Exercise03/graph.py
1,528
3.578125
4
import torch.nn as nn import torch.nn.functional as F ## TODO: Define the convolutional neural network class Net(nn.Module): def __init__(self, NUM_CLASSES=10): super(Net, self).__init__() self.num_classes = NUM_CLASSES # ***** TODO: Define the network layers ***** self.conv1 = nn...
a6049370e1798524ace0857b6bf86f3713374391
requiemwell/riversimulator
/fish.py
1,298
3.828125
4
#!/usr/bin/env python # coding: UTF-8 # ## @package fish # the fish class extends the animal class, providing the implementation # of the getAge (), maxAge () and incrAge () methods # @author Wellington Oliveira # @since 23/02/2018 from animal import * ## # constructor # @param age inherited fr...
efd61967bdebf23d52abae44d6286e456cb3f06f
rudraatech/dsmp-pre-work
/subhash-chettiar/code.py
1,420
4.125
4
# -------------- # Code starts here class_1=['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio'] class_2=['Hilary Mason','Carla Gentry', 'Corinna Cortes'] new_class=class_1 + class_2 print (new_class) new_class.append('Peter Warden') print (new_class) new_class.remove('Carla Gentry') print (new_class) ...
4c0cf55667d3d00c80c8249e6696fa4b59ef656f
jasonrbriggs/python-for-kids
/ch3/lists.py
272
3.703125
4
numbers_and_strings = ['Why', 'was', 6, 'afraid', 'of', 7, 'because', 7, 8, 9] print(numbers_and_strings) numbers = [1, 2, 3, 4] strings = ['I', 'kicked', 'my', 'toe', 'and', 'it', 'is', 'sore'] mylist = [numbers, strings] print(mylist) print(mylist[0]) print(mylist[1])
c7a2bed03b951f538c67deb79454610620dd1fc6
jasonrbriggs/python-for-kids
/ch3/list_arithmetic.py
258
3.796875
4
list1 = [1, 2, 3, 4] list2 = ['I', 'tripped', 'over', 'and', 'hit', 'the', 'floor'] print(list1 + list2) list1 = [1, 2, 3, 4] list2 = ['I', 'ate', 'chocolate', 'and', 'I', 'want', 'more'] list3 = list1 + list2 print(list3) list1 = [1, 2] print(list1 * 5)
3c779d9ecc29238e2f62656bfd68b6e87ed20281
jasonrbriggs/python-for-kids
/ch8/animal-class-4.py
722
3.53125
4
class Thing: pass class Animate(Thing): pass class Animal(Animate): def breathe(self): print('breathing') def move(self): print('moving') def eat_food(self): print('eating food') class Mammal(Animal): def feed_young_with_milk(self): print('feeding young') clas...
b7fa00c48c377207d64b2083d80218da6ebee6d4
wsinbol/python-learn
/mini-demo/greatest_common_divisor.py
392
3.578125
4
# 计算最大公约数和最小公倍数 x = int(input('input x = ')) y = int(input('input y = ')) if x > y: end = x else: end = y ''' 如果采用升序的方式遍历,那么就无法提前break出来 采用降序的方式提升了性能 ''' for i in range(end, 0, -1): if x % i == 0 and y % i == 0: print('最大公约数:',i) print('最小公倍数', x * y // i) break
e2300e545edf4f586021db8e3c9165a13a000524
wsinbol/python-learn
/cluster/show.py
135
3.796875
4
def show(n): for i in range(n): if i < 5: print('*') else: print('-') show(10)
c705ed63747ac544a03702e408d4f180218cd007
herrdiener/Schach_Projekt
/lucapiece2.py
21,422
4.3125
4
""" This file is going to set the class for the pieces. It will set the information needed to define each piece. """ import pygame #Initialize pygame pygame.init() #Set Dimensions WIDTH = 800 HEIGHT = 800 #Size of a square SQUARE = WIDTH//8 or HEIGHT//8 #Set a display screen DISPLAY_SCREEN = pygame.display.set_mod...
2ba772e1cb6c77b589a14a84234a79b0e09b5571
vzpd/myBrushRecord
/exercise/bd_相交链表.py
2,335
3.546875
4
class ListNode: def __init__(self, x, next=None): self.val = x self.next = next def generateList(lLeft): if lLeft: return ListNode(lLeft[0], generateList(lLeft[1:])) def showList(l: ListNode): while l: print(l.val) l = l.next class Solution: def getIntersect...
1c2e07d830d833af85ade41719a17183c991dfc8
vzpd/myBrushRecord
/exercise/每日一题_最接近的三数之和.py
1,538
3.546875
4
# 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数, # 使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。 # #   # # 示例: # # 输入:nums = [-1,2,1,-4], target = 1 # 输出:2 # 解释:与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。 #   # # 提示: # # 3 <= nums.length <= 10^3 # -10^3 <= nums[i] <= 10^3 # -10^4 <= target <= 10^4 from typing import List f...
276703e26b84d564eca8707dc3f16f6eb3e3ce7c
vzpd/myBrushRecord
/exercise/mergeArray.py
1,766
3.59375
4
# 给出一个区间的集合,请合并所有重叠的区间。 # # 示例 1: # # 输入: [[1,3],[2,6],[8,10],[15,18]] # 输出: [[1,6],[8,10],[15,18]] # 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. # 示例 2: # # 输入: [[1,4],[4,5]] # 输出: [[1,5]] # 解释: 区间 [1,4] 和 [4,5] 可被视为重叠区间。 from typing import List from exercise.myUtils import timer class Solution: @timer def merg...
aa34b48cc354f627ce2d9f2f2f2346a257e1dbe5
vzpd/myBrushRecord
/exercise/bd_合并区间.py
1,767
3.578125
4
# 给出一个区间的集合,请合并所有重叠的区间。 # # 示例 1: # # 输入: [[1,3],[2,6],[8,10],[15,18]] # 输出: [[1,6],[8,10],[15,18]] # 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. # 示例 2: # # 输入: [[1,4],[4,5]] # 输出: [[1,5]] # 解释: 区间 [1,4] 和 [4,5] 可被视为重叠区间。 from typing import List class Solution: def merge(self, intervals: List[List[int]]) -> List[List...
e78b1855190efa133a1fac86f614a6d4b024a25e
vzpd/myBrushRecord
/exercise/canJump.py
3,747
3.59375
4
# 给定一个非负整数数组,你最初位于数组的第一个位置。 # # 数组中的每个元素代表你在该位置可以跳跃的最大长度。 # # 判断你是否能够到达最后一个位置。 # # 示例 1: # # 输入: [2,3,1,1,4] # 输出: true # 解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。 # 示例 2: # # 输入: [3,2,1,0,4] # 输出: false # 解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。 from typing import List from exercise.myUt...