blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
5468fbd0e46101ccc8b76373e5c7b84598edd911
zfhrp6/competitive-programming
/atcoder/arc026_2.py
470
3.546875
4
from math import sqrt def check(n): ret = 0 for i in range(1,1+int(sqrt(n))): if n%i==0: ret += i + n//i if sqrt(n)%1 == 0.0: ret -= int(sqrt(n)) return ret-n def main(): n = int(input()) ## n = i if n == check(n): print('Perfect') eli...
2cadb3fbdad626683e7508697151155d34bd592a
AEGriffith/ML_KNN
/hw03.py
1,474
3.65625
4
""" Author: Amanda Griffith Course: EEL5840 - Fundamentals of Machine Learning Assignment: 03 Purpose: Choose a dataset and create a K-NN Classifier Due: November 10, 2020 """ from sklearn import metrics from sklearn.model_selection import cross_val_score """ Imports """ import pandas as pd import processing as prep i...
2f4d06024b202257b75f5b7230d616c3262a8150
Tashwri93/Python-Exercise9---Classes
/exercise9.2.py
709
3.609375
4
class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print("\nThis restaurant is called " + self.restaurant_name.title()) print("This type of cuisine i...
18a377e7aa1d8ef8f0ff3f12a22a5fbc5fff6ba0
Dave-Perkins/Fall-2020-CS-101
/lab code/lab 0 A/turtle_maze.py
934
3.53125
4
import turtle t = turtle.Turtle() t.screen.bgpic("maze.png") # get maze as background t.up() # solve the maze t.goto((-150,150)) t.down() t.fd(55) t.right(90) t.fd(20) t.left(90) t.fd(60) t.right(90) t.fd(20) t.left(90) t.fd(35) t.right(90) t.fd(18) t.left(90) t.fd(...
c71dd160273456125298ba41a2e13364f2b9738d
marcelormourao/python-calculator-with-tests
/calculatorTest.py
882
3.609375
4
import unittest from calculator import Calculator class CalculatorTest(unittest.TestCase): calc = Calculator() def test_sum_0_dot_5(self): self.assertEqual(self.calc.sum(0.3, 0.2), 0.5) def test_sum_6(self): self.assertEqual(self.calc.sum(3.5, 2.5), 6) def test_sum_0_dot24(self)...
88b8ee2f2f39222a63d6a8832c0375184765470b
Benjarseen/INS121---Programaci-n-1
/numeros_primos.py
662
3.8125
4
""""n = int(input("Ingrese un numero entero positivo: ")) if n > 0: for i in range(2, n): creciente = 2 esPrimo = True while esPrimo and creciente < i: if i % creciente==0: esPrimo= False ...
ee39ee09c0f1a45a723f284359b8fc638f8e69dd
gillkyle/python-hashtable
/main.py
1,864
3.5
4
#!/usr/bin/env python3 from hashtable import StringHashtable, GuidHashtable, ImageHashtable import sys def main(): # create the string hashtable ht1 = StringHashtable() for line in open('strings.txt'): line = line.strip() ht1.set(line.lower(), line) print('String hash table:') prin...
cf23295734b27771618d68f7bd500bde052ee3a1
bogdanalinmuresan/SPF
/visualize.py
397
3.640625
4
#! /usr/bin/env python import json # Importing the matplotlib library import matplotlib.pyplot as plt with open('data.txt') as json_file: data = json.load(json_file) numberList = [] for i in range(0,1000): numberList.append(i) # Passing the parameters to the bar function, this is the main function which create...
ff0c0f4739c66b27e4dfaf9c7db9bc98514963c8
JustMeliyu/training
/next_station/Algorithm/A04Fibonacci.py
374
3.859375
4
# encoding: utf-8 # 斐波那契数列,又称称黄金分割数列 a, b = 1, 1 m = [a, b] while b < 100: a, b = b, a + b print "b is :", (b) print "a is :", (a) m.append(b) print m def fib(max_len): n, x, y = 0, 0, 1 while n < max_len: print y x, y = y, x + y n += 1 s = fib(6) print s print type(s...
6c6d21053db05b6a979a87ca26c26df609c0d90f
JustMeliyu/training
/next_station/big_or_home/github/G01_PythonFeatures/quote_object/C07quote_obejct.py
932
3.59375
4
# encoding: utf-8 # 这是一个简单的赋值语句,整数 1 为一个对象,a 是一个引用,利用赋值语句,引用a指向了对象1 a = 1 # 你可以通过python的内置函数 id() 来查看对象的身份(identity),这个所谓的身份其实就是 对象 的内存地址 # python一切皆对象的理念,所以函数也是一个对象,因此可以使用 id() 函数的__doc__方法来查看这个函数的具体描述 print id.__doc__ h = 3 j = 3 print id(h), id(j) m = 'qsdfdas1324324' n = 'qsdfdas1324324' print id(m), id(n) # 让引...
a19b4ab15dbd27bdfc2800ce0b48a0c345059b00
JustMeliyu/training
/next_station/big_or_home/codingonway/B12linked_list.py
1,182
3.765625
4
# encoding: utf-8 class ListNode(object): def __init__(self, x): self.val = x self.next = None # class Solution(object): # def __init__(self): # pass # # def exchange_list(self, listnode): # if listnode is not None: # listnode.val, listnode.next.val = listnode.ne...
28c7b888700ee851e9e02340612648e7ac88a159
PabloGonzalezM/Python-Katas
/kata_03_opposite_number/test_opposite_number.py
868
3.875
4
import unittest from random import random from kata_03_opposite_number.opposite_number import opposite, lambda_opposite class TestOppositeNumber(unittest.TestCase): def test_opposite_number(self): input_data = random()*100 input_data_integer = int(input_data) self.assertEqual(opposite(input_data), -input_da...
cf228a5a6ce9b4e97ce8ec9fb6ecb35b58aecdd2
yashasps/python_challenge
/bull.py
361
3.8125
4
numbers="1" def counting(numbers): count = 0 lastterm = numbers[0] x = "" for i in numbers: if i is lastterm: count+=1 else: x += str(count) + lastterm count=1 lastterm=i x+=str(count)+lastterm return(x) for i in range(0,30): numbe...
044c06e807092cb315effddb1bf318f86edca5cc
allen791210/LeetCode
/339_Nested_List_Weight_Sum.py
772
3.5
4
""" Input: [1,[4,[6]]] Output: 27 Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1 + 4*2 + 6*3 = 27. Input: [[1,1],2,[1,1]] Output: 10 """ class Solution: def depthSum(self, nestedList: List[NestedInteger]) -> int: if not nestedList: return 0 depth = 1 ...
3ba1d20533da874b721112f38de3dac0d1cec685
allen791210/LeetCode
/291_Word_Pattern_II.py
1,647
3.796875
4
""" Input: pattern = "abab" str = "redblueredblue" Output: true Explanation: "a"->"red","b"->"blue" """ class Solution: """ @param pattern: a string,denote pattern string @param str: a string, denote matching string @return: a boolean """ def wordPatternMatch(self, pattern, str): return ...
86fd62ccd4b638c1c564f275d8e8d96db78ae112
allen791210/LeetCode
/Lintcode_596_Minimum_Subtree.py
1,160
3.953125
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ import sys class Solution: """ @param root: the root of binary tree @return: the root of the minimum subtree """ def findSubtree(self, root): self.mi...
1d3ae6119d591917280c8871a94e64ed86377a8d
allen791210/LeetCode
/1214_Two_Sum_BSTs.py
914
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def twoSumBSTs(self, root1: TreeNode, root2: TreeNode, target: int) -> bool: if not root1 or not root2: return False ...
3736af6c73ef21c4c9319106b30866004a49b8ba
allen791210/LeetCode
/108_Convert_Sorted_Array_to_Binary_Search_Tree.py
1,006
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None """ Given the sorted array: [-10,-3,0,5,9], One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST: """ class Soluti...
2bfbd1d95316bb87ee9d54f07bcab24a41675c6c
allen791210/LeetCode
/143_Sort_Colors_II.PY
802
3.5625
4
class Solution: """ @param colors: A list of integer @param k: An integer @return: nothing """ def sortColors2(self, nums, k): if nums == []: return None start_idx = 0 for i in range(1, k + 1): start_idx = self.partition(nums, start_idx, l...
cfc01957ffd4ff6e7e72a4c62385ce8aaad452a1
allen791210/LeetCode
/242_Valid_Anagram.py
879
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 9 16:32:38 2017 @author: Mac 242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. Note: You may assume th...
64483e980d06702a7f80de28a7f3e045cdf95157
allen791210/LeetCode
/78_Subsets.py
908
3.703125
4
""" Input: nums = [1,2,3] Output: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ] """ """ 因为 nums = [] 的时候如果 target = 0 的话,存在且仅存在一种方案,应该return [[]] 作为结果。 但是如果 target != 0 就是 return [] not nums 可能是 nums = None 也可能是 nums = []. """ class Solution: def subsets(self, nums: List[int]) -> List[List[int...
76c11b2492b21732ca5800ede5a59543c3d132b6
allen791210/LeetCode
/2_Add_Two_Numbers.py
1,924
3.609375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None """ Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 Explanation: 342 + 465 = 807. """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # ...
80b157a0241a8e561ff05fe2c2f68c8ce8280e83
allen791210/LeetCode
/120_Triangle.py
601
3.734375
4
""" [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). """ class Solution: def minimumTotal(self, triangle: List[List[int]]) -> int: if not triangle: return 0 return self.dfs_min_path(triangle, 0, 0) de...
5d4080097941422f80745bf71df86c8cecdab383
allen791210/LeetCode
/56_Merge_Intervals.py
604
3.828125
4
""" Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. TIME: SPACE: """ class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: result = [] intervals = sorted(intervals, key=lambda ...
b2e8fde85d6b2e1a265562019f31955558599fe0
ravitejaruthala/python
/matplotlib/program_002.py
1,222
3.578125
4
# Creating and customizing bar charts using MATPLOTLIB import numpy as np from matplotlib import pyplot as plt #For changing the style of the plot plt.style.use('fivethirtyeight') dev_x = [25,26,27,28,29,30,31,32,33,34,35] dev_y = [38496,42000,46000,52000,58000,61000,63000,67000,71000,76000,80000] py_dev_y = [40000,...
da5e9f7c9712e3197e069a9a7a26d6bb4db658c7
SimonFromNeedham/Project_Euler_Problems
/euler17.py
2,259
4.0625
4
# If the numbers 1 to 5 are written out in words: # one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? # NOTE: Do not count spaces or hyphens. For example, 342 (...
b4699ac88ca520da273f70a788cbfc8b1fe285bf
SimonFromNeedham/Project_Euler_Problems
/euler12.py
1,247
3.859375
4
# The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. # The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # Let us list the factors of the first seven triangle numbers: # 1: 1 # 3: 1,3 # 6: 1,2,3,6 # ...
3a50f698d6a65fafa0c72bfc75b8ec175896b9d8
SimonFromNeedham/Project_Euler_Problems
/euler16.py
1,072
4.125
4
# 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. # What is the sum of the digits of the number 2^1000? # I'm aware that this approach is more complex than necessary and that I could just use a long to store the number, # But I honestly find it a lot more interesting to work through the problem tryi...
8aeb8e2c3e90ebbc464f361471543f7ac67aa1e5
ANVRRT/Python-Simple-Blockchain
/blockchain.py
1,723
3.953125
4
from block import Block class Blockchain(): #<--------------- Starts Constructor ---------------> def __init__(self): self.blocks = [] #Initializes empty blockchain. self.generate_genesis_block() #Starts genesis block. #<--------------- Ends Construc...
a206e1e18d40fb485b14f0545f3bd8eeee4e14b9
ErickViz/WSQs
/WSQ12.py
232
4.03125
4
#WSQ12 #Erick Iván Vizcarra Hernández def gcd(x,y): if(x>y): while(x>y): x=x-y res=x elif(x==y): res=x else: while(x<y): y=y-x res=y return res x=int(input("Dame un numero: ")) y=int(input("Dame otro numero: ")) a= gcd(x,y) print(a)
2815ac6113912534b24613720c39cfff3dc74e8a
alabid/simpleredblack
/VerifyRBTree.py
2,991
3.875
4
""" VerifyRBTree.py Contains functions that verify that a given Red Black tree fulfills the properties of a standard red black tree. The 5 properties of the red black tree are described below. """ from TreeNode import * #### constants VERIFY_RBTREE = True #### # helper function to return # the color of a node (if it'...
b50d46ef662260950e7191b325413df5cdf18c52
Freemanlabs/detectron
/api/process_file.py
779
3.546875
4
import os import docx def read_docx(docx_file): return docx.Document(docx_file) def docx_to_txt(docx_file): doc_file = read_docx(docx_file) output_file = os.path.splitext(docx_file)[0] + ".txt" with open(output_file, "w") as file_: for paragraph in doc_file.paragraphs: file_.wri...
176ca3d0e411f5fc7c3cbe45ae6704ef3846ecde
shailendra-singh-dev/ProgrammingChallenges
/Caribbean Online Judge COJ/2939 - Back with Pandigital Numbers.py
123
3.671875
4
for i in xrange(int(raw_input())): N = bin(int(raw_input())) if "01" in N or "10" in N: print "YES" else: print "NO"
e4ce80afb96ca84bbcf47a53a13887b24dacf701
shailendra-singh-dev/ProgrammingChallenges
/Caribbean Online Judge COJ/1318 - Abc.py
486
3.5625
4
arr = [] arr = map(int, raw_input().split()) sorting = raw_input() arr.sort() a = arr[0] b = arr[1] c = arr[2] out = "" if sorting[0] == 'A': out += str(a) + ' ' elif sorting[0] == 'B': out += str(b) + ' ' else: out += str(c) + ' ' if sorting[1] == 'A': out += str(a) + ' ' elif sorting[1] == 'B': o...
bb273dd266e34e14325ce70b1a50e7e2248dbd65
shailendra-singh-dev/ProgrammingChallenges
/Caribbean Online Judge COJ/2700 - Uniqwords Comparison.py
456
3.59375
4
first = raw_input() second = raw_input() out1 = "" out2 = "" equal = "" i = 0 while True: if i == len(first): break if not first[i] in second: out1 += first[i] else: equal += first[i] i += 1 i = 0 while True: if i == len(second): break if not sec...
c0bdf60e9dd878b032e2372faf6babe022ee1201
littlejoe1216/Daily-Python-Exercise-01
/#1-Python-Daily-Exercise/Daily Exercise-1-02082018.py
290
4.1875
4
#Joe Gutierrez - Python Daily Exercise - 2/16/18 # 1. Write a statement that concatenates at least two variables (you can have more than 2 for this practice). name = input('Enter First name:') sna = input('Enter Last name:') joe = name + sna print ('Is your name ' + str(joe))
b0bfa34bd7e61e40a85926803e8910b060a263d1
cathyjw/Leetcode
/Algorithms/9.py
309
3.515625
4
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x<0: return False result=0 temp=x while x>0: result=result*10+(x%10) x=x//10 return temp==result
e3122f42bea1c759162ba7c8dadb8e67e98f70c9
island-ZRY/python-for-ry
/Python programming from entry to practice/Chapter 6/pkg_2/ry5.py
421
3.53125
4
alien_0={'x_position':0,'y_position':25,'speed':'medium'} print(f"Original position: {alien_0['x_position']}") # 向右移动外星人 # 根据当前速度确定将外星人向右移动多远 if alien_0['speed']=='slow': x_increment=1 elif alien_0['speed']=='medium': x_increment=2 else: x_increment=3 alien_0['x_position']=alien_0['x_position']+x_increme...
96304c77f6ac9df14930d2c7a24b95426003d74b
skynette/File_Organizer
/media-organizer.py
1,046
3.828125
4
import os import math from duplicate_checker import check_for_duplicates num_of_files = 0 num_of_folders = 0 size_of_dir = 0 print("File counter, select head folder path") path = input("Path: ") def search_file(directory): global num_of_files global num_of_folders global size_of_dir size_of_dir = ...
ebf813de314ff9821add90a7c66c734e3d976a66
caichang5201314/git_project
/basic/homework.py
748
3.75
4
# -*- coding: utf-8 -*- total = 0 for i in range(1, 101): total = total + i print(total) lists = [] for i in range(101): if i % 3 == 0 and i % 5 != 0: lists.append(i) print('能被3整除但不能被5整除的数有:', lists) # #[expression for iter_val in iterable if cond_expr] # lists=[i for i in range(101)...
eec9707551866baae5e39989af76641060fc6c65
qixu1987/car_count_yolo
/yolo/yolos/zone.py
1,517
3.625
4
"""class of detection zone """ class Zone: def __init__(self,xmin,ymin,xmax,ymax,count=0): self.ymin = ymin self.ymax = ymax self.xmin = xmin self.xmax = xmax self.count = count # nb of object passed through the zone self.active = False def count_increment(self,...
43c9ee7ba7e074a0d37c44e7391d8181d706193d
CSSBO/websystem
/算法分析/fenxingtree.py
1,203
4.28125
4
import turtle #画分形树,用的是创建二叉树的算法 def treeoface(length): #如果枝干长度小于15就不画 if length<15: return 0 turtle.forward(length)#往前画 turtle.up()#在回退的时候关闭画笔的工作 turtle.backward(length * (1 / 3))#回退到三分之一的地方 turtle.down()#重新打开画笔工作 turtle.left(60) #time.sleep(1)#画左枝干,长度为主枝干的...
8bd24e96d04a18fe0ad98bcc49d68bc18ca864eb
justwon322/DataMiningClass
/class1.py
4,923
3.5
4
#linear search ########################### # 1. 선형검색 # - 검색의 대상이 되는 list와 찾을 값을 각각 alist,key_value로 입력 받는 함수 # - 결과값으로 입력리스트에 검색값이 있으면 "True"와 n번째 인덱스를 출력하고 # 없으면 "False -1" 을 출력 ########################### def sequential_Search(alist,key_value): is_match = False #리스트에 검색 값이 있는지 여부 기본 false for x in ran...
f9f10fb6f7be9f8d39777003be21de4d38ed14cf
OlegLeva/beetroot
/turtel flower.py
768
3.53125
4
from turtle import * import random as r t = Turtle() t.screen.setup(800, 800) a = 0 b = 0 col = ["red", "blue", "green", "cyan", "purple"] def coord(): global a global b a = r.randint(-200, 200) b = r.randint(-200, 200) def flower(x, y, color): t.up() t.goto(x, y - 200) t.setheading(90) ...
e576fc37c4ddc5229802af37de6fab9aa40426ac
OlegLeva/beetroot
/less11_task_3.1.py
3,135
3.8125
4
class Product: my_type = "" name = "" price = 0 def __init__(self, my_type, name, price): if type(my_type) != str: raise ValueError("Type should be a string") else: self.my_type = my_type if type(name) != str: raise ValueError("Type should be ...
79ff449adfb2914c9b852d189b98431449d66ac8
OlegLeva/beetroot
/lesson10/task_1.py
353
3.90625
4
class Person: def __init__(self, last_name, first_name, age): self.last_name = last_name self.first_name = first_name self.age = age def talk(self): return f'Hello, my name is {self.last_name} {self.first_name} and I’m {self.age} years old”' person1 = Person("Carl", "Johnson"...
c73919059181c8cdec7aeb884be5762ed5d19bc8
OlegLeva/beetroot
/lesson20/animal.py
480
3.59375
4
from typing import Union class Animal: def __init__(self, breed: str, nikname: str, age: Union [str, int]): self.breed = breed self.nikname = nikname if not (type(age) == str and age.isdigit()) and type(age) != int: raise ValueError(f'{age} must be an integer') self.age...
9646da503e921a3aa32144701db011bf1f4d7a72
OlegLeva/beetroot
/lesson 3/task_2.py
180
4.3125
4
# the valid phone number program x = input('Enter phone number: ') if x.isdigit() and len(x) == 10: print('Your phone number: ', x) else: print('Incorrect phone number')
decdf3da2714fd1107cd9d7093947ffc0a4c0149
OlegLeva/beetroot
/lesson 9/task_2_func.py
2,735
3.640625
4
def add_f(lst, dct): id = input('Enter id: ') first_name = input('Enter first name: ').strip().lower().title() last_name = input('Enter last name: ').strip().lower().title() full_name = first_name + ' ' + last_name phone = input('Enter phone: ') region = input('Enter region: ').strip().lower().t...
23862d49de788dd2a117f9d30b0a9290b635f9f9
dominiquetheodore/tournament_planner
/tournament.py
4,574
3.515625
4
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 def connect(database_name="tournament"): try: db = psycopg2.connect("dbname={}".format(database_name)) cursor = db.cursor() return db, cursor except: print("Error establish...
7de4c6e65f3f8da219df6dcf106dcfd16bd8a2c0
wasit7/cs402
/python_class/myfunction.py
326
4.03125
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 19 11:47:11 2015 @author: Wasit """ def print_height(mylist): x=max(mylist) y=min(mylist) print "maximum height %.2f \nminimum height: %.2f" % (x,y) return (x,y) if __name__ == "__main__": mylist=[158,171,158,167,180] x,y = print_height(mylist...
fdde0c2635b2a22efc0c0fdded36ac6f9c3b22c4
t-corato/numerical-option-pricing
/Code/Lecture5.py
3,889
3.578125
4
from math import exp import numpy as np # A node in the binomial tree class Node(object): # Node contains theoretical value at time t def __init__(self, S, t, parent = None): self.S = S self.t = t self.parent = parent self.up_child = None self.down_chil...
1baaef694f79bbec7377737241a4190255da372e
Chandu8817/python_code
/Python codebetter training/class&objects/program3.py
447
3.609375
4
class Student: def inputinfostd(self,sn,sid,spercent): self.s=sn self.id=sid self.sp=spercent self.s=input("enter name of student ") self.id=int(input("enter student id no ")) self.sp=float(input("enter percentage of student ")) def outputstddata(self): ...
1e3bd0ca1acc8e978b097dd32786d5d068b3b73b
Chandu8817/python_code
/Python codebetter training/class&objects/staticnnonstatic/Books.py
1,176
3.796875
4
class Books: discountrate=15 count=0 def __init__(self,tittle,price): self.tittle=tittle self.price=price def calculatediscount(self,finalprice): self.finalprice=finalprice self.finalprice= self.price-(self.price*self.discountrate/100) def Display(self...
db67c5dfa59e2f22b51b07fdd727dbe4afdd8c36
Chandu8817/python_code
/scrapedoordash/doordashscrap.py
1,633
3.515625
4
# requirements python packages # pip install BeautifulSoup4 # pip install pandas # pip install selenium from selenium import webdriver from bs4 import BeautifulSoup import pandas as pd import requests driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver") category = [] item_name = [] description = [] pr...
f1dcb2b6dc8864df816b2806f7fd5e94216ca7bc
Chandu8817/python_code
/Python codebetter training/assignment/factorial.py
123
3.84375
4
n=int(input("enter a number ")) t=n for i in range(n,1,-1): print(i,end='*') t=t*(i-1) print("1 =",t)
392dc43eff968a4dbc983a0f3e4f5c3c0c21092b
Chandu8817/python_code
/Python codebetter training/iflelseconditon.py
4,918
4.0625
4
# n1=int(input("no 1st ")) # n2=int(input("no 2nd ")) # if n1%n2==0: # print("no is divisbalbe") # else: # print("no is not divsiable") # qus17 # n=int(input("no ")) # if n%2==0: # print("even") # else: # print("odd") # qus=18 # n1=int(input("no 1st ")) # n2=int(input("no 2nd ")) # if n1>n2: # ...
709a2535f672bf3bd5236ad39f6925518242cea6
shwethashyam10/ODU
/a15.py
1,721
3.703125
4
import random import sys n=6 row=1 col=0 pos=0 col_s=0 f=0 d=0 roll_again = "yes" flag=[[0 for j in range(n)] for i in range(n)] def check( flag ): count=0 for i in range(n): count=0 for j in range(n): if(flag[i][j]==1): count=count+1 if(count==n): print ("The row %d was...
8fca543f04cfd2d33f36f65f3f2d5e62b101dbb7
Fover21/Data-structure-and-algorithm
/algorithm/quick_sort.py
1,019
3.546875
4
# __author: ward # data: 2018/12/17 import random # 算法导论思路,以结尾为基准 # def partition(li, left, right): # tmp = li[right] # i = left - 1 # for j in range(left, right): # if li[j] <= tmp: # 归到左半部分 # i += 1 # li[i], li[j] = li[j], li[i] # li[right], li[i+1] = li[i+1], li[rig...
4420173690e8ea16b7ec4db3376050d564da6f4a
Fover21/Data-structure-and-algorithm
/algorithm/bubble_sort.py
613
3.71875
4
# __author: ward # data: 2018/12/17 import random def bubble_sort1(li): for i in range(len(li) - 1): for j in range(len(li) - 1 - i): if li[j] > li[j + 1]: li[j], li[j + 1] = li[j + 1], li[j] print(li) def bubble_sort2(li): for i in range(len(li) - 1): exc...
60730ea5c9dda167e8cb96bb573c11db8dfb8993
jaynwauche/start-task3
/user_login.py
1,451
3.8125
4
from messages import message_log message1 = 'login succesful' message2 = 'login not successful please try again' def collect_user_details(): ''' input: user details output: ''' global username global password username = input('Username:\n') password = input('Password\n') ...
e45b329820b641c33b3bbfdaa211490831d5b3c5
ohchangwook/0516
/0516/tri.py
314
3.609375
4
#삼각형의의 면적을 구하는 프록램을 작성하시오. #삼각형의 면적= 높이 *"밑변 *0.5 height=int(input("높이 입력:")) base=int(input("밑변 입력:")) area=height*base*0.5 print("높이는",height,"이고 밑변은",base, "인 삼각형의 면적은", area, "입니다.")
b506f877527d45c65938c2b783d3ada0fe7c8226
vipinkjonwal/Python-GUI-with-Tkinter
/widgetsFit.py
418
4.09375
4
from tkinter import * root = Tk() root.title(string = "Widgets") one = Label(root,text = "Welcome", bg = "cyan", fg = "red") one.pack() two = Label(root, text = "You're inside Tkinter", bg = "grey", fg = "blue") two.pack(fill = X) #fill = X will fill the label to full X axis. three = Label(root, text =...
f7f52d781a5994af908dbcbd1979fe73f204eab8
ypiatkevich/automatic-synonym-detection
/main.py
5,166
3.671875
4
import sys from extraction import * from text_processing import * from corpora_processing import * from tripple_processing import * from synonym_recognition import * # text = "An instruction set architecture (ISA) is the interface between the computer's software and hardware and also " \ # "can be viewed as th...
518087b3406afc65b712cee808f5849e98d40197
palepriest/python-notes
/src/ex32.py
635
4.1875
4
# -*- coding:utf-8 -*- t_count = [1, 2, 3, 4, 5] fruits = ['apples', 'bananas', 'Blueberries', 'oranges'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # print a integer list for number in t_count: print "The number is %d." % number # print a string list for fruit in fruits: print "The fruit type is %s....
7e566c850a060025ca2bea57c35778741317edd6
palepriest/python-notes
/src/ex36.py
1,485
3.984375
4
# Description: write a interesting game with # lists, functions and modules you have learned. # Design: draw a map first for figuring out # the rooms, monsters and traps, which players encounter. # Coding according to the splited tasks. # -*- coding:utf-8 -*- from sys import exit # common events def battle(): def...
079c116178948800771fca24b78607a1d99dc4b2
XCELSOR/My_firsrt_game
/binS.py
826
3.59375
4
from random import randint from datetime import * array = [randint(1, 10000) for i in range(100000000)] array.sort() def binSearch(arr, key): low = 0 high = len(arr) - 1 mid = (low + high) // 2 while arr[mid] != key and low <= high: mid = (low + high) // 2 if key > arr[mid]: ...
ca03996c06e344c39557e27a53fd7a4b8d243471
Nasir1004/assigment-3-python-with-dahir
/lopping numbers from one to ten.py
235
4.1875
4
''' numbers=1 for i in range (1,10): print(i) #this is example of for loop numbers from one to ten ''' # the whileloop example is current_number = 1 while current_number <=10: print(current_number ) current_number += 1
f314167596d12703cefd84d3ea73d711cfafdcb3
niko1aew/EulerProject
/Task_1.py
592
3.6875
4
""" Если выписать все натуральные числа меньше 10, кратные 3 или 5, то получим 3, 5, 6 и 9. Сумма этих чисел равна 23. Найдите сумму всех чисел меньше 1000, кратных 3 или 5. """ import Utils def task_1(): summ = 0 for i in range(1, 10): if (i % 3 == 0) | (i % 5 == 0): summ += ...
a33676d31f23a9e800f5e21b6c7c025306ac7bad
wbluke/python_dojang
/02_sequence_type.py
1,141
4.09375
4
# if you want to use several line strings a = """Hello, world! 안녕하세요 It's Python! """ # list b = [0, 1, 2] b = list(range(3)) print(b) # [0, 1, 2] # range c = range(0, 10, 3) print(list(c)) # [0, 3, 6, 9] # tuple : cannot change values(read only) d = (0, 1, 2) # "value" (not) in sequence print(0 in d) # True pr...
db42b6acb7d451e412f58c2837e4d1c309a412dc
wbluke/python_dojang
/01_input_output.py
649
4.15625
4
# if you divide integer by integer, result is float. num = 4 / 2 print(num) # 2.0 # convert float to int(int to float) num = int(4/2) print(num) # 2 num = float(1+3) print(num) # 4.0 # delete variable del num # if you want to know class' type print(type(3.3)) # <class 'float'> # when save input data on variable...
d198bd307c99c29e72efbdad28cb045958eb1e58
BaekMS/Sound-Source-Localization
/tools/validations.py
7,509
3.953125
4
# !/usr/bin/env python """In this script, validations will contain wrappers used to check validations for all the functions and classes.""" import functools import warnings import numpy as np # TODO: # 1) Clean up repeatedly used functions. Why can't class decorators inherit from other decorators? class ValidateLi...
730386e6a7dda223e408d954130cfb793434e082
rmoh13/Tic-Tac-Toe-Game
/Multiplayer Version/serverUNFINISHEDVERSION.py
10,042
3.859375
4
# Python program to implement server side of chat room. import socket import select import sys from _thread import * from colorama import Fore, Back, Style # server = "" we just wanna use localhost meaning anyone on the same WiFi as me and connect to this server so look below # server = "10.0.0.63" port = 5...
5df2a16112d8a65c50b2557b4ea0a5e5339a6a9a
ethan-mccarthy/EMS-Display
/maintenanceDuty.py
4,814
3.78125
4
import pandas as pd # Pandas is what allows us to work with the retrieved data as a data frame from datetime import date, time, datetime, timedelta from googleAPI import * ################################################################### def getMaintenanceData(verbose=True): # Get date/time data which is import...
63eab59423871b325c2783f50615b07df8843253
calgagi/leetcode
/0206/fast_answer.py
538
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseList(self, head): prev = None # Set Previous to null while head: # While head is not none cur = head # Current gets ...
c753fcc83e97a86ff4be0d5c484206bcb57a2837
calgagi/leetcode
/0876/another_answer.py
436
3.78125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def middleNode(self, head): """ :type head: ListNode :rtype: ListNode """ it_f, it_s = head, head whi...
4df5f4f912e51465974e6961e67ab1f8ec461158
calgagi/leetcode
/0517/answer.py
382
3.515625
4
class Solution(object): def distributeCandies(self, candies): """ :type candies: List[int] :rtype: int """ num_candies = len(candies) sis_candies = num_candies // 2 num_types = len(list(set(candies))) if sis_candies >= num_types: return num...
fcc74428e9a17615b926f8d4b41d7ab4db6bcdec
calgagi/leetcode
/0160/ON_answer.py
590
3.671875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ itA, itB =...
eb908fc55693673c3cc93ab012c9a47c7c021b17
calgagi/leetcode
/0876/answer.py
433
3.78125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def middleNode(self, head): """ :type head: ListNode :rtype: ListNode """ it = head count = [] ...
3d0c8948753c7e53738b87806383ad8405d1e739
wonjongkyu/JK_COIN_BOT
/src/5장/05_13.py
405
3.578125
4
import pybithumb import time # if문을 통한 예외처리 while True: price = pybithumb.get_current_price("BTC") if price is not None: print(price/10) time.sleep(0.2) # try - except 구문을 이용한 예외처리 while True: price = pybithumb.get_current_price("BTC") try: print(price / 10) except: pr...
3520b8193ac12414e7cced92ac97a5703b54ae12
zhaomengqi/Modeling-for-Diabetes-Data-Set-s-Analysis
/project.py
5,273
3.625
4
import csv import random import math #1, Data Ingestion by usingloadCsv() to read data def loadCsv(filename): lines = csv.reader(open(filename, "rt", encoding="utf-8")) dataset = list(lines) for i in range(len(dataset)): dataset[i] = [float(x) for x in dataset[i]] return dataset #2, splitData ...
f4673f731aaf0d9aa6d17d47692837d52c189987
encadyma/Hamster-Labs
/HamsterLabGrid/starter_grid_graph.py
4,545
4.1875
4
''' /* ======================================================================= (c) 2015, Kre8 Technology, Inc. Name: grid_graph_starter.py By: Qin Chen Last Updated: 6/10/18 Definition of class GridGraph. Description of all the methods is provided. Students are expected to i...
fb8c811e39751337d6edc5f40b7fcd0de56122bc
aeaa1998/proyecto_3_logica
/utils.py
2,496
3.90625
4
import re from typing import Union, List def intInput(text: str, sign: str = "=", limit: int = 0): while True: c = input(text + "\n") try: c = int(c) if sign == "=": return c elif sign == "+" and c > limit: return c e...
3788cbd9e3efee07d6c1ad537a07c5a259b1bca5
baijunyao/book
/_book/tmpdoc/yield_learn.py
2,210
3.890625
4
# -*- coding: utf8 -*- def yield_func(i): print 'before yield' yield i print 'after yield' a = yield_func(1) for i in a: print i # before yield # 1 # after yield # 调用yield_func的时候,并没有输出before yield, 而是返回了一个generator # print type(a) # print a.next() # print a.next() # Traceback (most recent call last...
1bb2d28e3d31086e0e9bfaff69504ae033baf3e9
rahatm1/SudokuSolver
/outputformatter.py
410
3.53125
4
import argparse parser = argparse.ArgumentParser(description="Enter file to be formatted") parser.add_argument('inputfile') args = parser.parse_args() file = open(args.inputfile, "r") output = "" for line in file: everything = line.split() for thing in everything: output += thing outputfile = open(ar...
5f6e9ca2336e593af4c522a1b1de6af1e6de83a8
Zahidsqldba07/codesignal-practice-1
/Python/condenseLinkedList.py
1,155
3.90625
4
# Given a linked list of integers, remove any nodes from the linked list that have values that have previously occurred in the linked list. Your function should return a reference to the head of the updated linked list. # Example: # Input: (3) -> (4) -> (3) -> (2) -> (6) -> (1) -> (2) -> (6) -> N # Output: (3) -> (4) ...
98fc10daee97ae89b4d28cc5df48f268c05a857f
Zahidsqldba07/codesignal-practice-1
/Python/csBinarySearch.py
1,380
3.84375
4
# Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search for target in nums. If target exists, then return its index, otherwise, return -1. # Example 1: # Input: nums = [-1,0,3,5,9,12], target = 9 # Output: 4 # Explanation: 9 exists in nums and its index is ...
15bb95cd371312f6aab66a77dc02d294a2e8295f
Zahidsqldba07/codesignal-practice-1
/Python/csFriendCircles.py
2,395
4.09375
4
# There are N students in a baking class together. Some of them are friends, while some are not friends. The students' friendship can be considered transitive. This means that if Ami is a direct friend of Bill, and Bill is a direct friend of Casey, Ami is an indirect friend of Casey. A friend circle is a group of stude...
b24086aca04c7faa0a06cc09d25e37f27ff3da85
trreitz/Workout-of-the-Day-Random-Select
/workout_loop.py
628
3.703125
4
workoutlist = [{ "name": ['Murph'], "ex1": ["1 mile run"], "ex2": ['100 Air Squats'], "ex3": ['1 mile run'], "equip": ['Pull-up bar'], "body zone": ['arms', 'legs'], "aerobic score": int(10) }, {"name": ['Cindy'], "ex1": ["15 Pull-ups"], "ex2": ['100 Air Squats'], "ex3": ['9 Pushups'], "equip": ['Pull-up bar'], "body ...
95c68a047722c88cb9e677916f178c3aaa7844cc
sonkadak/coding-practice
/Hackerrank/Interview-preparation-kit/Arrays/Minimum-Swaps.py
1,020
3.515625
4
#!/bin/python3 import math import os import random import re import sys # Complete the minimumSwaps function below. def minimumSwaps(arr): # 정렬된 배열 ref_arr = sorted(arr) # 값: 값의 현재 위치를 나타내는 딕셔너리 index_dict = {v: i for i,v in enumerate(arr)} swaps = 0 for i,v in enumerate(arr): # 현...
48f329d8339b0eab0baf7e4e051343104755dbf8
chenyuanzhen/tanke_fight-1
/Game_Funciton.py
11,898
3.5
4
""" 内容: 这是关于游戏内部玩法代码设置 """ import pygame import sys import random from Tank import Bullet from Map import Brick, Iron_brick, Prop_tank_speed, Prop_bullet_speed, End_theme # 道具刷新时间计数器 count = 2000 refresh_time = 2000 # 初始化音乐文件 def music_player(): # 加载音频文件 my_music = pygame.mixer.Sound("./music/start.wav...
f7d62d4c0ef9dc2e31d0f47d92e3259f314c2cfa
SikarinKaewjutaniti/w7-Friday-group1-repo
/boardgame1.py
2,715
4.03125
4
class TicTocToe: def __init__ (self): self.board = [[" "," "," "],[" "," "," "],[" "," "," "]] self.all_player = {'X':'Player 1', 'O':'Player 2', 'player1':'X', 'player2':'O'} self.player = "" def startGame(self): self.round = 1 print("Start Game : Tic-Tac-Toe!...
d99a690596cbd7cb931efca05f6bf594f9ae7464
khalidfarooq/Analog-Clock
/analogclocl.py
1,437
3.828125
4
import time import turtle wn=turtle.Screen() wn.bgcolor("black") wn.setup(width=600, height=600) wn.title("simple analog clock by @khalidfarooq") wn.tracer(0) #traces the prog pen=turtle.Turtle() pen.hideturtle() pen.speed(0) pen.pensize(3) def draw_clock(h,m,s,pen): #clock face pen.up() pen.goto(0,210)...
21b417cbc4ffd52cdeb8db202e3bfbc42c52ccf4
yaptide/converter
/converter/solid_figures.py
4,596
3.640625
4
from dataclasses import dataclass, field from abc import ABC @dataclass(frozen=False) class SolidFigure(ABC): """ Abstract solid figure in 3D space. It is characterised by position in space and rotation along X,Y,Z axis in its own reference frame. Size of the figure (its extend in space) is defined in...
55f8f504bbd6fe813f39db96c61d104ba55cf35c
sun912/rep-lit.
/Recurssion/mk_lottery.py
420
3.640625
4
#make lottery number using recursive function def go(numbers, i, num_set): if len(num_set) == 6: print(' '.join(map(str,num_set))) return if i == len(numbers): return go(numbers,i+1,num_set+[numbers[i]]) go(numbers,i+1,num_set) #2. cnt > n #3. cnt < n while True: n, *numbers = list(map(in...
76118b20cdc7f1dc54657a052b1dd63a44e11cf1
FAxel79/Chisla
/venv/matrix.py
395
3.546875
4
import random class Matr: """Создает матрицу""" def __init__(self, x = 4, y = 4, n = 9): self.x = x self.y = y self.n = n self.matrica = [] for i in range(0,self.y): stroka = [] for j in range(0,self.x): stroka.append(random.randi...
dfbd74ebc29c7fb694fc20488dacdb4d32c1cee9
vladpr31/NumericAnalysis
/GaussianQuadrature.py
1,401
3.5
4
import math import scipy.special import sympy as sy import sympy as sp from sympy import sympify # function for Gauss-Legendre rule def gauss(f, n, b, a): G = 0 nodes, weights = scipy.special.p_roots(n) for i in range(n): G += 0.5 * (b - a) * (weights[i] * f(0.5 * (b - a) * nodes[i] + ...
2c2feb287326e778bad3e8b878844fbc061778a5
alexilarduya/cw_kata
/format_duration.py
680
3.578125
4
#http://www.codewars.com/kata/human-readable-duration-format/ from numpy import zeros def format_duration(seconds): if seconds == 0: return 'now' str_list = [] keys = ['year', 'day', 'hour', 'minute', 'second'] secs_key = [ 365 * 24 * 60 * 60, 24 * 60 * 60, 60*60, 60, 1] for...
4f57236601365b90dd65099863291bac8f8fcba5
felidadae/_general
/playground/Python/context_manager/main.py
613
3.703125
4
def f(): raise Exception("dupa") def f2(): for i in range(10): try: f() except Exception as e: print("Poczatek oblsuginwania wyjatku") raise Exception("Wyjatek z wyjatku ziom!") return "Powrotny z wyjatku" except InvalidArgumentException as...
d61ecd5913c8a6c2d524fbddf8c9d29691bfe0e5
felidadae/_general
/playground/CPlusPlus/virtualFun/sample.py
948
3.890625
4
import itertools def is_region_surronded(ix, iy, board): def is_border_(node): (ix, iy) = node return ix == len(board)-1 or ix == 0 or iy == len(board[0])-1 or iy == 0 def is_border(nodes): return any([ is_border_(node) for nodes in nodes]) nodes = [(ix, iy)] while nodes: ...