blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a45bf73ebffb6843273285ba851adfc1ea857762
Anisha7/Tweet-Generator
/tasks1-5/study_vocab.py
1,150
3.9375
4
# vocab study game # give a word, get definition input, output real definition import random; def str_equal(s1, s2) : s1 = s1.strip().split(" "); s2 = s2.strip().split(" "); if (len(s1) != len(s2)) : return false; for i in range(0, len(s1)) : if (s1[i] != s2[i]) : re...
54e3a14e030e841b25a6488e653538e08b79ea6f
j39m/katowice
/split_fi_bill.py
1,857
3.765625
4
#!/usr/bin/python3 """ Splits our monthly Fi bill. """ import sys from fractions import Fraction class Splitter: """Main splitter context.""" def __init__(self, *args): self.__parse(*args) self.__check_parsing() def __parse_single(self, dollar_amount: str) -> Fraction: (dollar...
2369793fb4509957524937a4d47e2231436e46d9
gazibo-Pixel/OOPewPie
/actors.py
1,373
3.65625
4
from random import randint class Player: def __init__(self, name, level): self.name = name self.level = level def __repr__(self): return ( 'Player {} is at level {}'.format(self.name, self.level) ) def get_attack_power(self): return randint(1,100)*s...
0976f65dd954937cc738ccf7ca6108e3d26d1eaf
war19047/Data_Structures
/queue.py
1,446
4.40625
4
''' Welcome to the queue tutorial! ''' import random class Queue: def __init__(self): # Initialize the queue as an empty array. self.queue = [] def __str__(self): # return the queue as a string representation. return str(self.queue) # Remember when we enqueue we appen...
7c2343ab1ff05fefca1734454e78fedc4c491970
gcman/project-euler
/123-Prime-Remainders/main.py
963
3.71875
4
def bs(arr, l, r, x): """Binary Search arr from index l to r for x""" while l <= r: mid = l + (r - l)//2 if arr[mid] == x: return mid + 1 elif arr[mid] < x: l = mid + 1 else: r = mid - 1 return r + 1 def primes(n): """Sieve of Eratost...
2262c5e376de21d635f3bd196fe36551cbde9481
EnricoCB/python
/PythonEx/ex06.py
136
3.640625
4
n = int(input('Digite um numero:')) print(f'o dobro, o triplo e a raiz quadradada de {n} são respectivamente \n {n*2}, {n*3} e {n**2}')
b626c7730740194a2fb69f6fc834580fd8be2375
DuskPiper/Code-Puzzle-Diary
/LeetCode 0759 Employee Free Time.py
633
3.515625
4
""" # Definition for an Interval. class Interval: def __init__(self, start: int = None, end: int = None): self.start = start self.end = end """ class Solution: # 41 78 def employeeFreeTime(self, schedule: '[[Interval]]') -> '[Interval]': intervals = sorted([interval for personSchedule i...
484e60e8d6eb429a508f18f57bdaf7877b20e7af
blackplusy/0801
/例子-0819-01.python的输出.py
1,044
4
4
#coding=utf-8 ''' #coding=utf-8 设置字符集 字符集相当于翻译官,解析不同的语言用于显示 中国的字符集:GBK2312 ''' ''' 1.直接输出 ''' #直接输出是通过print()函数进行打印 #输出翻滚吧牛宝宝!!! print("翻滚吧牛宝宝") ''' 2.变量输出 ''' #变量可以理解为容器,容器的值是不固定的,设置什么保存什么 name='python' print(name) #变量之间也可以进行操作 a=20 b=30 print(a+b) a='heygor is ' b='handsome!!! ' print(...
6c172e13786e30e38fcd42ac20a60f3ea2ba752c
doyin315/Algorithms
/Leetcode/minstack.py
644
3.78125
4
class MinStack: def __init__(self): self.numbers=[] self.min=None def push(self, x: int) -> None: if len(self.numbers) == 0: self.min = x self.numbers.append([x,x]) else: lastmin=self.min self.numbers.append([x,lastmin]) ...
4f01b3debeb62841a6be8fa0b6cace76d7d69e3c
vo4uk3/python
/banking/banking.py
3,135
3.71875
4
from account import * import sqlite3 class Bank: def __init__(self): self.logged_in = False self.conn = sqlite3.connect('card.s3db') self.cur = self.conn.cursor() self.create_table() self.menu() def create_table(self): sql_create_card_table = """CREATE TABLE IF...
a70cacb9cece3d584e61e2357087a8d69ffb4262
thiagofinardipenteado/gscap
/gscap.py
751
3.6875
4
#%% #Dado um conjunto representado por uma lista, quantos subconjuntos tem a soma divisível por 13 import random as rng import numpy as np MOD = 13 N_SIZE = 3 MIN_RANDOM_INT = 1 MAX_RANDOM_INT = 10 def bitmasking(arr, n, mod): print(f"Input: {arr}") right_subsets = 0 for i in range(2**n): ...
b8abc15db7d04511e2fbc18afc4e1d5575d20966
vchi90/SoftDevSpring
/18_listcomp/app.py
440
3.625
4
def pyTriples(a): return([(m**2-n**2,2*m*n,m**2+n**2) for m in range(1,a) for n in range(1,a) if 2*m*n > 0 if m**2-n**2 > 0 if m**2+n**2 > 0]) def quickSort(arr): if arr == []: return [] pivot = arr[0] lower = quickSort([x for x in arr[1:] if x < pivot]) upper = quickSort([x for x in arr[1:]...
c5dfa62dbc43f066bbd1928fb12cbb06b2053d23
buptwxd2/leetcode
/Round_1/701. Insert into a Binary Search Tree/solution_1.py
1,054
4.03125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def insertIntoBST(self, root: TreeNode, val: int) -> TreeNode: node = TreeNode(val) if not ...
77be6e3af6fbab584c5738d56384104d210ec223
bgenchel/practice
/LeetCode/LargestNumber.py
544
4.3125
4
#LARGEST NUMBER (medium) # #Given a list of non negative integers, arrange them such that they form the largest number. # #For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. # #Note: The result may be very large, so you need to return a string instead of an integer. # #Credits: #Specia...
0d8b92d04e07edf93a1c7b770dc2542b302ccb04
mrgrant/Algorithm
/QuickSort/QuickSort2.py
1,169
3.703125
4
# in-place quick sort # without taking extra memory import random def partition(array, l, r): # pivot_idx = random.randint(l, r) global cnt pivot_idx = l + (r-l)//2 p = array[pivot_idx] # swap the random pivot to the head of array array[l], array[pivot_idx] = array[pivot_idx], array[l] i ...
680e52cf252a6fdcc136bf7b11d89c067a14fcb3
mikejthomas/biote100_pset2
/hamming.py
1,329
4.25
4
#Python Problem 2 #hamming.py #Introduction to Bioinformatics Assignment 2 #Purpose:Calculate Hamming Distance #Your Name: Michael Thomas #Date: 10/10/15 #stores 3 database sequences seqList = ["AGGATACAGCGGCTTCTGCGCGACAAATAAGAGCTCCTTGTAAAGCGCCAAAAAAAGCCTCTCGGTCTGTGGCAGCAGCGTTGGCCCGGCCCCGGGAGCGGAGAGCGAGGGGAGGCAGATTCGG...
d9f7d1bdccfb33c71c9ec83b5f1fcd0057828094
fingerman/python_fundamentals
/python_bbq/OOP/001_Person.py
833
4.0625
4
class Person: first_name = "FirstName" second_name = "SecondName" age = 1 def __init__(self, first_name, second_name, age): self.first_name = first_name self.second_name = second_name self.age = age def show_age(self): print(self.age) class Student(Person): ...
b270f7bf704cbe169b9391e5145dd31a3053e97e
infomotin/Neural-Networks-from-Scratch-in-Python
/src/adding Layer/Training Data.py
699
3.546875
4
from nnfs.datasets import spiral_data import matplotlib.pyplot as plt import nnfs # The nnfs.init() does three things: it sets the random seed to 0 (by the default), creates a # float32 dtype default, and overrides the original dot product from NumPy. All of these are meant # to ensure repeatable results for following ...
8e92df1f6224500fb66da6764a2ce75cd044c292
bakienes/Python
/Source Code/21_alarm.py
1,749
3.734375
4
from tkinter import * import datetime import time import pygame def alarm(set_alarm_timer): while True: time.sleep(1) current_time = datetime.datetime.now() now = current_time.strftime("%H:%M:%S") date = current_time.strftime("%d/%m/%Y") print(now) if n...
16d8fd7a76d8d9c662e3b4ae81ece990542d0496
Colin0523/Ruby
/Ruby/Advanced Topics in Python.py
1,033
4.125
4
my_dict = { "Name": "Colin", "Age": 20, "A": True } print my_dict.keys() print my_dict.values() for key in my_dict: print key,my_dict[key] doubles_by_3 = [x*2 for x in range(1,6) if (x*2) % 3 == 0] # Complete the following line. Use the line above for help. even_squares = [x**2 for x in range(1,11) ...
c9d4b14dd184c339055ea2d253a21aa22787593c
sincere-Hwang/algorithm-study
/Intermediate/06_Queue/Problem_02_DistanceofMaze/DistanceofMaze_jykim.py
1,545
3.859375
4
def IsEnd(row, colm) : if Array[row][colm] == 3 : return True return False def IsPath(row, colm) : if (row < 0 or colm < 0 or row >= N or colm >= N or Array[row][colm] == 1 or (row, colm) in Visit): return False return True def Maze2(row, colm) : Queue = [StartNode] Floor = [0...
b1a79d4c2bf693a1f2ba0c273780820e03e9422c
mbryant1997/mbryant1997
/dictionaryIntro.py
607
4.03125
4
"""" thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) print(thisdict["brand"]) """ # register #login #method1 """ aSampleList = [1,2,3,4,5] dictOne = { "key1" : "value1", "key2" : "value2", "key3" : "value3" } print (dictOne) print (aSampleList) """ #method2 dictTwo = {...
8b9acf03bca6788cd7f85e4992560153d44adab9
DeepKandey/PythonLearning
/Methods.py
520
3.578125
4
class MethodsTypes: school = 'Telusko' def avegrage(self): return (self.m1 + self.m2 + self.m3) / 3 def __init__(self, m1, m2, m3): self.m1 = m1 self.m2 = m2 self.m3 = m3 @classmethod def getSchoolName(cls): return cls.school @staticmethod def info...
0a49e2919833a601401ffa50f5e7c3358b3b8086
avinfinity/RandomPythonScripts
/FileReadWrite.py
311
3.53125
4
filename = "" lines = open(filename) for line in lines.readlines(): print(line) #rb is read binary with open("myfile", "rb") as f: byte = f.read(1) while byte: # Do stuff with byte. byte = f.read(1) with open("myfile", "rwb") as f: f.write(b"This is writte as byte array")
753e913252c7462ab0117151ead47f35e5554b4b
lixiang2017/leetcode
/leetcode-cn/0690.0_Employee_Importance.py
1,728
3.734375
4
''' approach: Hash Table + Queue/BFS Time: O(N) Space: O(N) 执行用时:168 ms, 在所有 Python3 提交中击败了54.94%的用户 内存消耗:16 MB, 在所有 Python3 提交中击败了40.11%的用户 ''' """ # Definition for Employee. class Employee: def __init__(self, id: int, importance: int, subordinates: List[int]): self.id = id self.importance = imp...
589760425b61379560b2336bf5832a3d707be201
cravingdata/List-of-Divisors
/PracticePython_Exc4_Divisors.py
281
4.3125
4
number = float(raw_input("Enter a number to find its list of divisors: ")) divisor = 0 while number > 0: divisor = divisor + 1 if number % divisor == 0: answer = divisor print answer #finding list of all divisors no matter the user input quantity
39db7396b73c599d957516756f0bab06a5be4513
rerelurelu/babigo
/converter/babi_converter.py
1,503
3.734375
4
def babi_converter(hiragana: str) -> str: """ Insert "ba, bi, bu, be, bo" into a sentence """ result = '' length = len(hiragana) - 1 for idx, letter in enumerate(hiragana): next_letter = hiragana[idx+1:idx+2] if (next_letter in 'ぁぃぅぇぉゃゅょ') & (idx < length): pass ...
1410871d2dd4f39ead86cf65779a08d7e6160930
dannymulligan/Project_Euler.net
/Prob_225/prob_225.py
1,829
3.796875
4
#!/usr/bin/python # coding=utf-8 # # Project Euler.net Problem 225 # # Tribonacci non-divisors # # The sequence 1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201, ... # is defined by T1 = T2 = T3 = 1 and Tn = Tn-1 + Tn-2 + Tn-3. # # It can be shown that 27 does not divide any terms of this sequence. # In fact, 27 ...
81bf3c4e149aa9477d2749fbb6ebb662016bcf2b
SyTuan10/C4T16
/Session10/dict_list1.py
364
3.765625
4
book ={ 'name': 'Doraemon', 'year': 1969, 'chars': ['ratel', 'nobita', 'chaien', 'xeko'], } for k,v in book.items(): print(k, v) # print(book) # for k,v in book.items(): # print(k, '-', v) # book['chars'] = ['cat', 'xuka', 'chaiko'] # book['chars'].append('dekhi') # book['chars'].pop(0) # # d...
118e44c7ec3e6a558b871475345eaab2e1652770
JiaxinYu/machine_learning_examples
/kmeans_clustering.py
4,347
3.796875
4
# A pedagogical example of k-means clustering. # Creates a set of means (cluster centers) and # generates random points around each center # using spherical Gaussian noise. Then applies # k-means clustering on the random points to # allow us to compare the true clusters vs. # predicted clusters. # A link to the tutori...
34f9cc4509507433abdcd5b87d4822000778fcf9
VVdovichev/Algoritms_Teaching
/Lesson_3/Task_8.py
787
3.96875
4
""" Матрица 5x4 заполняется вводом с клавиатуры, кроме последних элементов строк. Программа должна вычислять сумму введенных элементов каждой строки и записывать ее в последнюю ячейку строки. В конце следует вывести полученную матрицу. """ m_row = 5 m_str = 4 my_list = [] for i in range(m_str): new_list = [] ...
cbbf20c5a0d6043ab040b9686cc0cb90593ec1d3
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4062/codes/1642_2450.py
100
3.6875
4
n1=input() n2=input() if (n1.upper()<n2.upper()): print(n1) print(n2) else: print(n2) print(n1)
f9c05889e9e6becb1b945569c031c72dba98f5f3
yuvrajschn15/Source
/Python/08-print2.py
787
4.40625
4
# To write multiline string you can use # ' """ string here """ ' print("""Hello, This is the second line of string This is the third line of string This is the fourth line of string This is the last line of string""") # To print a new line within a string use "\n" all_days = "\nMonday...
43a1b1c084ae966c3013954df622cd5a6d1ead34
Taoge123/OptimizedLeetcode
/LeetcodeNew/Tree/LC_606_Construct_String_from_Binary_Tree.py
2,604
3.9375
4
""" https://leetcode.com/problems/construct-string-from-binary-tree/solution/ Example 1: Input: Binary tree: [1,2,3,4] 1 / \ 2 3 / 4 Output: "1(2(4))(3)" Explanation: Originallay it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it w...
f2202df3224bae6ba87d2503a37e5d10d2973b65
zhuozhuo9601/py_weixin
/sumbit.py
1,067
3.546875
4
from tkinter import * def submit(): print(u.get()) p.set(u.get()) root = Tk() root.title("测试") frame = Frame(root) frame.pack(padx=8, pady=8, ipadx=4) lab1 = Label(frame, text="获取:") lab1.grid(row=0, column=0, padx=5, pady=5, sticky=W) #绑定对象到Entry u = StringVar() ent1 = Entry(frame, textvariable=u) ent1.grid(ro...
4d004d7476f28cd155e26e1b91f7c09a3d2f3ea3
Novark/Hanabi
/utilities/types.py
872
3.640625
4
""" Data-types """ import collections class Enum(object): def __init__(self, *enums): for i, val in enumerate(enums): if collections.Counter(enums)[val] > 1: raise Exception("Duplicate ENUM entry found: %s" % val) else: self.__setattr__(val, i, False...
fd3959917f3fb29a49b5a49fdedd6597a1a2707f
maaaato/python-lab
/singleton/singleton.py
725
3.953125
4
class Singleton(object): def __new__(cls, *args, **kargs): print(cls) if not hasattr(cls, "_instance"): cls._instance = super().__new__(cls) return cls._instance class Myclass(Singleton): def __init__(self, input): self.input = input class Youclass(Singleton): ...
fcf68338e293695538a127aa83319c06472cea22
vicchu/leetcode-101
/01 List/Problems/09_left_rotate_one.py
947
3.578125
4
from typing import List # Approach 1 : Inbuilt functions pop/del & append def leftRotateByOne(inputList: List) -> List: if(len(inputList) <= 1): return inputList firstEle = inputList.pop(0) inputList.append(firstEle) return inputList # Approach 2 : RAW method :) def leftRotateByOne2(inpu...
f4e2e864d5d584124c8cd93c0aee456056c99c90
berkeaksu/PythonDersleri
/Lesson2/HataYonetimi_Ornek.py
665
3.921875
4
try: number = int(input("Lütfen birinci sayiyi giriniz : ")) number2 = int (input("Lütfen ikinci sayiyi giriniz : ")) toplam = number+number2 fark = number-number2 bolum = number/number2 carpim = number*number2 print("Sayilarin toplamı : ",toplam, "\nSayıların farkı : ",fark, ...
146cfbe4e50c100e7ef8007c86cdba2c97c9e262
BabouZ17/MacGyver
/frame.py
5,054
3.921875
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # This class represents the game frame and provides methods # in order to manage the events in the game such as a move # from the character, checking if the game is over or # preparing the map. """ This class represents the game frame and deals with all the logic which o...
d5d075c82c1a398fee191c6c73c97c8405409603
jamesfallon99/CA116
/lab_week06/sort-three.py
438
3.90625
4
#!/usr/bin/env python n = input() m = input() r = input() if n < m and n < r: print n if r < m: print r print m else: print m print r elif m < n and m < r: print m if r < n: print r print n else: print n print...
64a1c1c9b7225b7d08ece526175cb8b886f81ead
noceanfish/leetcode
/RegularExpression.py
1,946
3.6875
4
import re class Solution: def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ if not p: return not s pattern = re.compile(p) res = pattern.match(s) if not res: return False else: ...
8a33063b2e789deb290eacdd64df756d6ff5170b
AmiteshMagar/Physics-Dept._PyTut-2
/p12.py
454
3.75
4
def integration(a,b,n,func): h = (b-a)/n step = a+h fa = func(a) fb = func(a +h) su = 0 for i in range(n): su = su + (0.5*h*(fb + fa)) fa = fb #a = b step = step + h fb = func(step) return su #testing integration -- working perfectly ''...
61a0a6366d8fbd013dfbc18bcf5d9a8c0a555d44
musically-ut/extraction
/extraction/examples/custom_technique.py
2,094
3.8125
4
""" This file includes an example of a custom Technique tailored around parsing articles on my blog at lethain.com. Usage is:: >>> import extraction, requests >>> url = "http://lethain.com/digg-v4-architecture-process/" >>> techniques = ["extraction.examples.LethainComTechnique"] >>> extractor = extrac...
fe6c4fda679a807d88af5ed83b4373e6604aecaa
BarryFishyBear7/notes
/multiples.py
529
4.5625
5
# How to tell if one number is a multiple of another myNum = int(input("Enter a number to check: ")) print("Checking if your number is a multiple of 3 or 5...") # hint: use % (gives you the remainder) # check if the remainder is 0 if myNum % 3 == 0: print("Your number is a multiple of 3! ") if myNum %...
5980b49989999cf8aef64c72e0e122f31c149d7b
git4shashikant/pythonBasics
/fundamentals/Loops.py
522
4.0625
4
def while_usage(n): x = 0 while x < n: print(x, end=', ') x += 1 def for_usage(n): for x in range(0, n): print(x, end=', ') # use a for loop over a collection def for_collection(months): for month in months: print(month) def for_enum(months): for i, month in enu...
7dc2ae79da913accf0bc854875fb2f2bc14dfbd3
quadrant26/python_in_crossin
/Lesson/lesson34_task.py
378
3.921875
4
from random import randint print('Guess I want think!') computer = randint(1, 100) while True: print('Press you number') num = int(input()) if num < 0: print('Exit...') break; if num > computer: print('Too big...') elif num < computer: print('Too small') elif ...
8cb646b4fdc8acafcdcf682a4ea0dac3ca7a51a6
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/palindrome-products/9b0578a281b74ca7bbb51e0a396046df.py
554
3.734375
4
from math import ceil def smallest_palindrome(max_factor, min_factor=0): return min(_palindromes(max_factor, min_factor)) def largest_palindrome(max_factor, min_factor=0): return max(_palindromes(max_factor, min_factor)) def _palindromes(max_factor, min_factor): for a in range(min_factor, max_factor +...
80af3818c4aa9d6f8c3c8454a63d3117d8dfa3b6
Joshua-Enrico/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-to_json_string.py
177
3.5
4
#!/usr/bin/python3 """ to_json_string function """ import json def to_json_string(my_obj): """Returns s json representation of a object""" return json.dumps(my_obj)
6171f2bfa91102cbe969001e6cb01823fa153989
CarlosAntonioITSZ/Curso-Python
/Diccionarios/Exercise1.py
343
3.9375
4
#Exercise1 ''' Write a python program that asks for a number by keyboard and that creates a dictionary whose keys are from the number 1 to the indicated number, and the values ​​are the squares of the keys. ''' #@CarlosAntonio number=int(input("Enter a number: ")) dicc={} for i in range (1,(number+1)): dicc[i...
b2b7d1de838b99bc84c650f37170176b6f439fab
nsid10/Project-euler
/problems/012.py
998
3.71875
4
def prime_factors_2(n): if n < 2: return {} factors = {} while n % 2 == 0: n //= 2 factors[2] = factors[2] + 1 if 2 in factors else 1 while n % 3 == 0: n //= 3 factors[3] = factors[3] + 1 if 3 in factors else 1 i = 5 limit = int(n**0.5) while i <= limi...
62ebcf973f17f5616c1fa8828be9f27dcbc3aa95
eselyavka/python
/leetcode/solution_404.py
1,655
3.84375
4
#!/usr/bin/env python import unittest class TreeNode(object): def __init__(self, val): self.val = val self.left = None self.right = None class Solution(object): def sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ res = []...
5d89158e48dc7a30cbab7c974193ea1092ed8917
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_96/1683.py
1,907
3.625
4
import sys def getIfPossibleUnsurprising(score, maxScore): print ("Score is: " + str(score) + " " + "max is:" + str(maxScore)) if maxScore == 0: return True if int(score) == 0: return False return True if (int(score) >= int(maxScore*3 - 2)) else False def getIfPossibleSurpris...
30ac44d38ebe7dddadbde7258e998a1e69deb39b
JudsonMurray/MovieDB
/JP/src/MovieDataBase.py
12,971
4.15625
4
#Name: Potter Nerdling # Date: 07/05/18 #Movie Data Base def DisplayMovieList(MovieList):# Displays Movie Titles in list MovieNum = 1 if len(MovieList) > 0: print(" Movies in your collection:") for i in MovieList: # loop to display each movie in the list print(" ", MovieNum,")", " "...
0e363944a647e56f5f85a158594a6f078c830442
gubertoli/grokking-algorithms
/Chapter 1 - Intro/1_binary_search.py
1,184
4.03125
4
def main(): n = int(input("> Enter number of elements (list): ")) lst = [] for i in range(0, n): ele = int(input(">> Element " + str(i) +": ")) lst.append(ele) number_to_find = input("> Enter the integer to find: ") number_to_find = int(number_to_find) print("** First require...
6b405031c702495be8cdf6494e329d846aa7fbe8
psb-seclab/malware_classifier
/tests/TestCase.py
2,522
3.984375
4
import unittest import os class TestCase(unittest.TestCase): """The base class of all test cases in this project. Intended to provide convenience methods to allow easier test case creation. """ def compare_list(self, value_list, expected): """Assert that the list of values is equivalent to...
bcedc18e92e70757a3a7628f70efab2cc82759f8
WilliamPerezBeltran/studying_python
/clases-daniel_python/ejercicios/abecedario_con_numeros.py
1,326
3.8125
4
# abecedario=[] # for num in range(97,123): # letra=chr(num) # abecedario.append(letra) # print(abecedario) abecedario=[] abec=[ chr(ord('a')+num) for num in range(26)] print(abec) # [x for x in range(sdf)] # contador= 0 # for x in range((3,9)): # prin(contador, x) # contador +=1 #...
acaeee0cf63d0ed3f9dc1196c4fdb34e91e78846
cc0819/untitled
/demo/demo79.py
431
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 17/8/1 上午11:22 # @Author : C.C # @File : demo79.py # 题目:字符串排序。 if __name__ == '__main__': str = ["e", "f", "c", "d"] print("before=", str) for i in range(len(str) - 1): for j in range(len(str) - i - 1): if str[j] > str[j ...
afec2bda09e99650a06be619959585799aecefe0
wreyesus/Python-For-Beginners---2
/0002. Strings - Working with Textual Data.py
1,238
4.34375
4
message = "Hello World" print(message) print(len(message)) print(message[0]) print(message[1]) #Print Index from beginning - In example it will not include 4th #Starting Index print(message[0:4]) print(message[:5]) #Stop Index print(message[6:]) #Using Methods print(message.lower()) print(mes...
d5cb9ce94603fedb3cee698c14fa6fb8ad10fe9b
nandakishoremmn/Balls_pygame
/main_old.py
1,182
3.734375
4
from pygame import * from balls import * from target import * from player import * done = False def collision(): global n if (player.x-player.width/2 < target.x < player.x+player.width/2) and (player.y-player.height/2 < target.y < player.y+player.height/2): balls.append(BALL()) n+=1 ta...
611592adc67ae182c8689cf29a4b1d4ece2c9d32
darrylweimers/python-3
/tutorials/print_test/print_test.py
256
3.90625
4
#print format name = "Darryl" age = 24 print("My name is %s. I am %d years old." % (name, age)) # Concatentate items seperated by commas print("Hello Peter,", "a table for ", 5, "is ready.") # End without newline print("Hello", end="") print(" World")
9b9061f17d6465ffe44ae18c5076b2434943a175
fabriceb/PyArithmetic
/prime.py
1,982
3.859375
4
""" This module is a collection of functions related to prime manipulation and prime-related arithmetic operations Copyright 2011 Fabrice Bernhard <fabriceb at theodo.fr> """ _primes = [2, 3, 5, 7] def isprime(n): """Tests primality >>> isprime(157) True >>> isprime(157 * 13) False """ ...
f87ef2e245a7d63094c1e75c574ccc534262984d
DevanshRaghav75/Hacktoberfest_contribution_2021
/python programmes made by me/fizz buzz/fizzbuzz day 1.py
205
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 28 23:37:00 2019 @author: admin """ for i in range(1,51): if(i%3==0): print(str(i)+("= fizz")) if(i%5==0): print((str(i)+("= buzz"))
eaab973cf6a6deb6ca672df23fdc4f61fafe1b83
carlacastro/code2040
/Documents/code2040APIChallenge/stage3.py
1,402
3.65625
4
''' author: Carla Castro Code2040 API Challenge December 1 2014 ''' import requests # Sends the post request with a json dictionary # containing the information to send. This function will # return the json-encoded content of the response. def sendPostRequest(url, dictionary): req = requests.post(url, json=dictiona...
16501d5c42dd59e4ed43b93d6e24a2d41047f32c
Doggy228/SysProgLAB
/labfinal/5-20-Java-IO-83-Omelyanskyi/5-20-Java-IO-83-Omelyanskyi/test/test3.py
163
3.546875
4
def func_a(): return 10 def func_b(a,b): return func_a()+a-b def main(): a = func_a() c = 20 c += func_a()+func_b(c,a) return c
b4364879c9f3d42c56bbf7f472299cad88c4c745
safaripenguin/drought_evaluation_CMIP5
/read_ascii_tools.py
926
3.609375
4
#THIS MODULE CONTAINS SCRIPTS FOR READING ASCII (TEXT) FILES #EACH SUBROUTINE IS SEPARATED BY A LINE -------- #----------------------------------------------------------------------------- # #Reads a single column ASCII # #INPUT # file - input file name, including full path, of the ASCII file to be read # # def read...
976c1ff8338009d9395d8c20b586bcba41d62871
zhichengMLE/python-design-pattern
/Creational Patterns/Abstract_Factory/abstract_factory.py
1,581
3.828125
4
class Circle(object): def get_shape(self): return ("circle shape") class Square(object): def get_shape(self): return ("square shape") class Rectangle(object): def get_shape(self): return ("rectangle shape") class Red(object): def get_color(self): return ("red color") ...
69a35122db349253166d20299d5aeeb86cc36db6
saadhasanuit/Assignment-2
/p 3.42.py
180
3.5
4
print("MUHAMMAD SAAD HASAN 18B-117-CS SECTION:-A") print("ASSIGNMENT # 3") print("PROBLEM 3.42") def avg(lst): avg = [sum(i)/len(i) for i in lst] print( avg, end='\n')
9e28670b3721c8308d724fa11073c283cb41d7c6
eymin1259/Baekjoon_Python
/Step_09/4153.py
284
3.8125
4
def right(least, middle, max): if least**2 + middle**2 == max**2: return "right" else: return "wrong" while 1: num_list = list(map(int, input().split())) num_list.sort() if num_list.count(0)==3: break print(right(*num_list))
e73fb2935d97389ecf16a843a23fb10cac173d54
StoychoVladikov/PythonCourse
/Hackerrank.md/Print Function.py
184
3.953125
4
if __name__ == '__main__': n = int(input()) appended_numbers = "" for number in range(1,n+1): appended_numbers+=str(number) print(appended_numbers)
f000b969aac10ad8b18028d7d0aa67cad61aef4c
www111111/git-new
/cc_text/0510_sj/player1.py
268
4
4
import random a=5 while(a>0): pc=random.randint(1,3) user=int(input('输入123')) if(user==1 and pc==2) or (user==2 and pc==3) or (user==3 and pc==1 ): print('win') elif user==pc: print('ping') else: print('lose') a=a-1
8f5dce219484819f2600975e86e91e1855f00924
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/246d36aefeb4427f90fdfa4547f6d08f.py
557
4.03125
4
from datetime import date from calendar import monthrange def meetup_day(year,month,day_of_week,which_day): num_days_in_month = monthrange(year,month)[1] days_in_month = (date(year,month,day) for day in range(1, num_days_in_month + 1))\ possible_days = [d for d in days_in_month if get_day(d) == day_of_week] if w...
6d358cc53edd48ced8e949d74bd650d0e4fcd39f
rafaelperazzo/programacao-web
/moodledata/vpl_data/189/usersdata/353/65208/submittedfiles/al2.py
123
3.5625
4
# -*- coding: utf-8 -*- #ENTRADA a = float ( input ( ' Digite o valor de a : ' )) #PROCESSAMENTO b = (a%1) #SAIDA ptint (b)
10613638f0b645d140a11beb11e7c27398e0ca8f
Daishijun/InterviewAlgorithmCoding
/baidu3.py
927
3.59375
4
# -*- coding: utf-8 -*- # @Date : 2019/4/8 # @Time : 18:40 # @Author : Daishijun # @File : baidu3.py # Software : PyCharm N, M = list(map(int, input().split())) cout = 1 def power(base, exp): if exp == 0: return 1 if exp == 1: return base res = power(base, exp>>1) res *= res ...
183f3350e7d59b3d913997afa1c53d292a678083
AmynJiwani/ChooseYourOwnTopicProject
/main.py
52,805
4.5
4
# Name: Amyn Jiwani # Date: June 15/20 # main.py # Description: This program's function is to create a "Choose Your Own Science Topic" simulator, similar to the "Choose Your Own Adventure" series, with each path being controlled by user input. #libraries needed to run the code import random # library used to generate ...
dd6edc9e477a1c603979878d8485c00f6f944d63
JaehoonKang/Computer_Science_110_Python
/GUI_example/kiloConverterGUI1wExcHandling.py
2,954
3.875
4
import tkinter #import tkinter.messagebox import kilotomiles ''' Converts kilometers to miles Displays result in dialog box ''' class KiloConverterGUI: # --------------------------------------------------------------------------- # Constructor def __init__(self): # Create instance of MODEL self.__kiloVal...
b31af1b4ee3c4594bcc75b1c7f50f68448e08c62
volnova/pychallenge
/cat.py
526
3.5
4
# -*- coding: utf-8 -*- """Написать программу cat не ограничивая количества файлов-аргументов""" def cat_files(*args): """function cat files in console""" try: for filename in args: with open(filename, 'r') as my_file: read_data = my_file.read() print(read_d...
a8e8f5e1bb704e312ab9fd34b65409241c6f00de
DunnyDon/birthday
/birthday
690
4.3125
4
#!/usr/local/bin/python from datetime import date,datetime,time today = datetime.today().date() date_of_birth = raw_input("Birthday (Please enter in the format of dd/mm/yyyy): ") format_str = '%d/%m/%Y' # The format birthday = datetime.strptime(date_of_birth, format_str).date() days_until_birthday = (birthday-today)...
1a0ad473cb05e3e6b160fc37bb254b10f1e5b6e4
shouliang/Development
/Python/PyDS/sort/logn/merge_sort_02.py
1,026
3.90625
4
def merge_sort(alist): if not alist: return [] if len(alist) == 1: return alist # 递归终止条件 # 数组一分为二 mid = (len(alist)) // 2 left = merge_sort(alist[:mid]) right = merge_sort(alist[mid:]) # 嵌套递归调用左右部分 left = merge_sort(left) right = merge_sort(right) # 合并左右有序的数组 ...
b4ec5615b3036f267175430691558dcbaf86e9b4
LeoLevin91/Labs-OC
/Lab_2/Cript_Csezar py/Encode.py
1,111
3.84375
4
#Создаем словарь со всеми буквами алфавита DIC = {chr(x): x-97 for x in range(97, 123)} #Кодирование def encode(string, key): '''шифрование''' new_string = '' for i in string: if i not in DIC: # если символа нет в словаре оставляем как есть new_string += i continue ...
26d7051f43ecfc68e6b1e4c765e0411ba8ea1fbc
kaetojn/401
/A2/code/preprocess.py
1,716
4.0625
4
import re def preprocess(in_sentence, language): """ This function preprocesses the input text according to language-specific rules. Specifically, we separate contractions according to the source language, convert all tokens to lower-case, and separate end-of-sentence punctuation INPUTS: in...
91aac8c239a72dab4750888b36d706351be3bc2d
thmslmr/TF-Examples
/3 - Regression in Eager execution/main.py
2,041
3.734375
4
# Simple regression example using Eager execution # Imports import time import tensorflow as tf import tensorflow.contrib.eager as tfe import matplotlib.pyplot as plt import utils # Define paramaters LEARNING_RATE = 0.01 N_EPOCHS = 100 LOSS_TYPE = 'HUBER' # Call `tfe.enable_eager_execution` to use eager execution tf...
d04fc87e5ac0b75d38d2a7fedf8fddcfb98cf507
LucasAraujoBR/Python-Language
/ListaPythonBrasil/conversorMparaCM.py
255
3.96875
4
""" Faça um Programa que converta metros para centímetros. """ try: valor = input('Digite a quantidades de Metros que quer converter para CM: ') valor = float(valor) print(f'{valor} M = {valor*100} CM') except: print('Dados inválidos')
dda9e3b6ca54d797933676b289494dd9df3bf37e
meghalrag/MyPythonPgms
/tuple/tuplesample.py
102
3.515625
4
tup=1,2,3,4 print tup print tup[0],tup[1] list1=[1,2,3] print list1 print tuple(list1) print list(tup)
229518c1f18e99dc81786925a96377728071d689
artyomka0/IT_practics
/IT_Praktika_19/IT_Praktika_19/1-2(2)_programm.py
243
3.90625
4
import math x = float(input('Введите x ')) y = float(input('Введите y ')) if x * y <= -1: f = math.sin(x * math.exp(y)) elif x * y >= 5: f = x * x + math.tan(y) else: f = math.sqrt(math.fabs(math.cos(x * y))) print('f = ', f)
a5aaadbe528644d42ba5585cf1e63ab527e1be8f
MathematicianVogt/Artificialintelligence
/SearchGraph.py
3,520
3.671875
4
import sys # SearchGraph.py # # Implementation of iterative deepening search for use in finding optimal routes # between locations in a graph. In the graph to be searched, nodes have names # (e.g. city names for a map). # # An undirected graph passed in as a text file (first command line argument). # # Usage: python ...
a3a57de135700c1fb40d6266e0889986a875c0c6
vaishnav-197/DSA-Algo
/leetcode/leetcode_merge_intervals.py
381
3.671875
4
def merge_interval(intervals): if intervals == []: return [] result = [] intervals.sort() for i in intervals: if result == [] or result[-1][1]<i[0]: result.append(i) else: result[-1][1]= max(result[-1][1],i[1]) return resu...
fe43d5fc3d18017729e6a322c0dbce3d2128c5f0
pimoroni/inky
/examples/phat/calendar-phat.py
5,963
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import calendar import datetime import os from inky.auto import auto from PIL import Image, ImageDraw print("""Inky pHAT: Calendar Draws a calendar for the current month to your Inky pHAT. This example uses a sprite sheet of numbers and month names which are composited...
eea1e41a4d802a3c2030258355ebf298bd3835cb
mikeygaw/musicrandomizer
/Main v.51.py
12,747
3.609375
4
# Music Randomizer # imports import random import sqlite3 conn = sqlite3.connect('music.db') conn.row_factory = lambda cursor, row: row[0] cursor = conn.cursor() global selection def transferband(): def moveband(): # Starts by getting the band the user wishes to move as well as the f...
1c63bc580b1465624766a7d952d61c3b2fbe6dc9
107318041ZhuGuanHan/TQC-Python-Practice
/_5_function/503/reference_solution.py
151
3.609375
4
def compute(a, b): ALL = 0 for i in range(a, b + 1): ALL += i return ALL a = eval(input()) b = eval(input()) print(compute(a, b))
c169369bafff7c7547266b0fe07c3e9a83ef6391
Rylee2000/Codex
/c_lib/Parent.py
2,102
4.125
4
# parent abstract class used by other classes that utilize return_current_action, # return_modified statement, and num_line # for more information on how to create abstract classes in python, the following videos may help: # https://www.youtube.com/watch?v=PDMe3wgAsWg and https://www.youtube.com/watch?v=rOaRMW8jYOo #...
c11a1dd725f4bc694a0de184aac5cd6e801ce81d
paulosrlj/TicTacToe-Python
/ticTacToe.py
2,936
3.765625
4
from random import choice from os import system class Board: def __init__(self): self.board = [' ' for x in range(9)] def displayBoard(self): system('clear') or None print() print(f'{self.board[0]} | {self.board[1]} | {self.board[2]}') print(f'{self.board[3]} | {...
b99eb1ced0e33d4bc9b8017354cfcd1da5956c1c
heltonavila/MC102
/lab03/lab03_media_final.py
1,098
4.28125
4
# O programa criado tem como objetivo calcular a média final dos alunos de MC102. Primeiramente, pede-se como entrada os valores da prova 1, prova 2 e média dos laboratórios realizados. Como saída, são dadas a média das provas, a média antes da realização do exame e a média final. Caso a média antes do exame esteja ent...
ecc29c171db87d388e20a093d22e0775f893ef81
chalseoko/si-206-data-oriented-programming
/project1/206W17-project1.py
10,436
4.21875
4
import random import unittest class Card(object): suit_names = ["Diamonds","Clubs","Hearts","Spades"] rank_levels = [1,2,3,4,5,6,7,8,9,10,11,12,13] faces = {1:"Ace",11:"Jack",12:"Queen",13:"King"} def __init__(self, suit=0,rank=2): self.suit = self.suit_names[suit] if rank in self.faces: # self.rank handles ...
e586529ca3cc4dcae4c55765e414547a95692827
joaovicentefs/cursopymundo2
/exercicios/ex0051.py
484
3.578125
4
# cont = 0 print('='*30) txt = '10 TERMOS DE UMA PA' x = txt.center(30,' ') print(x) print('='*30) '''num = int(input('Primeiro termo: ')) raz = int(input('Razão: ')) for c in range(num, 9999, raz): cont += 1 if cont <= 10: print(c, '--> ', end='') print('ACABOU')''' # Versão do Guanabara primeiro = int(input('Prim...
322ade10776e5423d8fc37530c5bfcc911397162
sowmyamanojna/BT3051-Data-Structures-and-Algorithms
/self_assesment/self_assesment2/q4.py
582
3.671875
4
from numericalStack import Stack as ArrayStack from queueList import Queue as ArrayQueue stack = ArrayStack() queue = ArrayQueue() [stack.push(i) for i in range(1,11)] [queue.enqueue(i) for i in range(1,11)] print(stack) print(queue) while (not stack.is_Empty()) and stack.top()>=5: queue.enqueue(stack.pop()) prin...
28f68de95e194a4e6c40825689f283139cffad4e
DamonMok/PythonLearning
/MySQL数据库_数据库查询_5.分页.py
614
3.5
4
-- 分页 -- limit * start,count -- 限制查询出来的数据个数 select * from student limit 2; -- 查询前3个数据 select * from student limit 0,3; -- 每页显示2个,查询第1页 select * from student limit 0,2; -- 每页显示2个,查询第2页 select * from student limit 2,2; -- 每页显示2个,查询第3页 select * from student limit 4,2; ...
2489138f42652cd45ebfd3cff1599190824051c2
idelfrides/python_read_json
/handle_json_files/json_module.py
1,283
3.609375
4
""" This medule solve the issue using json module """ # import modules import json def with_json_method(): # mycontent = None try: myfile = open('test.json', 'r') mycontent = myfile.read() file_name = myfile.name myfile.close() print('\n SUCCESS \n File {} was opened a...
b457d5933fcb1da94e8e59c7678eb1729bf46072
myanir/Campus.il_python
/next.py/3.3.2.py
533
3.53125
4
class UnderAgeException(Exception): def __init__(self, arg): self._arg = arg def __str__(self): return "Provided age %s is less than 18. In %d years you can join the party!" % (self._arg, 18 - self._arg) def get_arg(self): return self._arg def send_invitation(name, age): try:...
dc4133c4597f59ffc7cf300e88bcf14d67c14b66
dsolus/coms6020
/daniel_lab1.py
679
4.5625
5
#!usr/bin/env python3.5 #Daniel Solus #Lab 1 - fraction to mixed number converter """This program asks for a numerator and denominator. Performs division and outputs a mixed number. This task is repeated 3 times.""" from fractions import Fraction def frac_converter(): #input num = input("please enter the numer...