blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0472b230535ab54a4f023d18cc8750cedb33e67a
ttomchy/LeetCodeInAction
/hash/q523_continuous_subarray_sum/hash_presum.py
742
3.71875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ FileName: hash_presum.py Description: Author: Barry Chow Date: 2021/3/5 5:06 PM Version: 0.1 """ class Solution: def checkSubarraySum(self, nums: List[int], k: int) -> bool: pre = 0 dic = {0: -1} for i in range(len(nums)): pre...
44dfb4b250eec822884613c6cb8272713e6a635a
ChangRui-Yao/pygame
/LINUX系统/linux实战/13.0/04--闭包的引入.py
503
3.6875
4
def test(): print("哈哈哈哈我是一个Test") test() #函数名是一个特殊的变量 ret = test print(ret) #id()获取对象地址 #print("%x" % id(ret)) #print("%x" % id(test)) #通过ret调用函数 ret() #1)所谓函数名是一个特殊的变量,保存了函数在内存中的首地址 # 2)通过自定义变量可以获取获取函数地址 # 3自定义变量调用函数 “变量名()” 变量名=函数名 name1 = "132" name2 = "132" print(id(name1)) print(id(name2))
69b753a5a0081147cd6d8023c9511e5b581dfbda
lww2020/linux
/python/第三周/lists/list_di.py
600
4
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # Author: davie names=['shanshan','Longting','Alex',1,3,4,5,6,7,7,8,8,9,9,0,0,2,3,4] print(names) names.append('Peiqi') # 追加 print(names) names.insert(0,'abc') print(names) names.insert(names.index('Longting'),'DaWang') # 嵌套 print(names) # 修改 names[names.index('shansha...
46fbdc21b1eea9838e48eb4651634412ec6e3d2b
Newester/MyCode
/Py/Python/Debug.py
980
3.96875
4
#!/usr/bin/env python3 #使用 print 将变量打印出来,简单粗暴 def foo(s): n = int(s) print('>>> n = %d ' % n) return 10 / n def main(): foo('0') #main() #使用断言 assert #如果断言失败会抛出 AssertionError def foo_2(s): n = int(s) assert n != 0, 'n is zero!' return 10 / n def main_2(): foo('0') #main_2() #可以使用 -0 参...
fe748286b219b23af3627f9ccb8cb426f83e3b05
AustinH1131/R_P_S_L_S
/Game.py
4,448
3.640625
4
from Human import Human from Ai import AI import random from Player import Player class Game: def __init__(self): self.player1 = Human() self.player2 = Human() self.player2.select_gesture() self.winner = False def display_greeting(self): print("Welcome to Rock Paper Sci...
744ba8a6157d5d49855f41dfed09d1891c9ce2e2
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/6d8d7be312a54afe933635d5d5d88435.py
783
3.671875
4
import datetime range_map = { "1st": range(1,8), "2nd": range(8,15), "3rd": range(15,22), "4th": range(22,29), "teenth": range(13,20), "last": range(31, 0, -1)} day_map = { "Monday": 0, "Tuesday": 1, "Wednesday": 2, "Thursda...
05248c83cc5eb78dc0dabc12d8c07826f9514d4d
timwu64/Python-for-Data-Science-for-Beginners
/python_tensorflow_advance/deepnet.py
2,446
3.53125
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #... #input > weight > hidden layer 1 (activation function) #feedforward #compare output to intended output > cost function (cross entropy) #optimization fucntion (optimizer) > minimize cost (adamOtimizer.. SGD, adaGrad) #backrpogragati...
d71afbf08a4088e3770dc46957e7b9e45a6d3e03
aniGevorgyan/python
/math_util.py
1,194
4.1875
4
#!/usr/bin/python # 1. Math simple actions """ :input a, b :output: a+b, a-b, a*b, a/b """ def mathActions(a, b): add = a + b minus = a - b mult = a * b div = a / b return ('Addition is ' + str(add), 'Subtraction is ' + str(minus), 'Multiplication ' + str(mult), 'Division is ' + str(div)) # 2. ...
f5b1255a3ac0b55fa0173b238e500d5592858c24
Ressull250/code_practice
/part4/55.py
1,352
3.703125
4
# -*- coding:utf-8 -*- # python不允许程序员选择采用传值还是传引用。 # python参数传递采用的肯定是“传对象引用”的方式。 # 这种方式相当于传值和传引用的一种综合。 # 如果函数收到的是一个可变对象(比如字典或者列表)的引用,就能修改对象的原始值--相当于通过“传引用”来传递对象。 # 如果函数收到的是一个不可变对象(比如数字、字符或者元组)的引用,就不能直接修改原始对象--相当于通过“传值'来传递对象 # 看到这类题心中只有暴力v1,TLE # 根据别人的解法写的v2 #v1 class Solution(object): def canJump(self, nums): ...
fb94c6a19a45378943b090755283f3abc89cc0e0
sltsgh/leetcode
/top100liked/104.py
624
3.578125
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 maxDepth(self, root: TreeNode) -> int: def helper(t, n): if t.left: nl = n + helper(t.left, n) ...
fb44ada862235c7afe389f8f2a19eca1b5e538e6
SensenLiu123/Lintcode
/434.py
1,785
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: sensenliu """ DIR = [(0,1), (1,0), (0, -1), (-1, 0)] """ Definition for a point. class Point: def __init__(self, a=0, b=0): self.x = a self.y = b """ class UFS: def __init__(self): self.root_hash = {} self.count = 0 ...
7add6de3998dc7388665a5950da29c887c6685bd
BadoinoMatteo/ES_PYTHON_quarta
/PHYTON/prova.py
89
3.671875
4
lista=[10, 3, -4, 6] lista.append(5) print (lista) lista2=lista[2 : 4 ] print(lista2)
09dfc1173cb7569f32f4d2d1e02316204cbf398b
mikpim01/Outliner
/outlinergui.py
11,010
3.578125
4
""" " File: outlinergui.py " Written By: Gregory Owen " " The GUI manager (view) for the Outliner """ from Tkinter import * from outlinermenu import OutlinerMenu from outlinermodel import OutlinerModel import dndlist class TopicLine(Frame): """ A frame that contains a label, a reference to a topic, a but...
4f17e85a185c9f5a68b4986632137ee5f4abf735
tourky2010/Encryption
/Ready scripts/Chapter 2/Scoping.py
244
3.5625
4
#!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills # adding x here makes it in scope x = 0 for i in range(1,25): # x is in scope x = i + x # x is now out of scope print(x)
866780c5b0e281317576b9ee749982542ab9e7f0
ErhardMenker/MOOC_Stuff
/fundamentalsOfComputing/algorithmicThinking/notes_linear_and_binary_search.py
1,094
4.0625
4
### Linear and Binary Search # Searching is the art of finding a key in a list of values and returning the index. def linear_search(x, l): ''' find if element x is in list l and return the index ''' idx = -1 for elem in l: # increment the index idx += 1 # if x is equal to the iterated element, return the i...
30e30eb5534ed97f0b7b0952d41c95fd55426d23
MR3299/Python-programming
/p13.py
281
3.9375
4
def fun(x): if(x == 1): print("nor prime nor composite") return for i in range(x-1,1,-1): if(x%i==0): print(x," is not a prime number") return print(x," is a prime number") a=int(input("enter number: ")) fun(a)
1f521f304e81cf003142d96786d3b944dd83abbf
rizkiulia/Python-List-and-Dictionary
/List Manipulation.py
128
3.609375
4
a = [ [5, 9, 8], [0, 0, 6] ] # change list value b = a[0] b[2] = 10 # change list value c = a[1] c[0] = 11 print(a)
865b6f644275cebfbeeee496c8603f7697e7e6fb
llgeek/leetcode
/252_MeetingRooms/solution.py
507
3.875
4
""" the idea is to find is there any intersections """ class Solution: def meetingRoom(self, intervals): intervals = sorted(intervals, key = lambda x: x[0]) for i in range(len(intervals)): if i + 1 < len(intervals) and intervals[i][1] > intervals[i+1][0]: return False ...
b3c73a6f26eeb6b10618198e35b53dc46f12823e
rrajesh0205/python_in_HP
/Bubble_Sort_User_input.py
485
3.96875
4
def sort(nums): for i in range(len(nums)-1, 0, -1): for j in range(i): if nums[j] > nums[j+1]: temp = nums[j] nums[j] = nums[j+1] nums[j+1] = temp nums = [] nl = int(input("Enter the list size : ")) for i in range(0, nl): print("Enter number a...
74ffd2c2be5e9d9ba9055c7b3a64ef392c872d90
nicolas0p/Programming-Challenges
/oddSum/oddSum_test.py
604
3.625
4
import unittest import oddSum as odd class oddSumTest(unittest.TestCase): def test1(self): num = [-2, 2, -3, 1] result = odd.odd_sum(num) self.assertEqual(3, result) def test2(self): num = [2, -5, -3] #import pdb; pdb.set_trace() result = odd.odd_sum(num) ...
b925f343ba69c9df6fb771aae3eaed55c29635c8
DebugConnoisseur/practice-programs
/simpleaddirtion.py
179
3.921875
4
a=int(input("enter first number") b=int(input("enter second number") c=int(input("enter third number") d=a+b+c e=a-b-c f=a*b*c print(d) print(e) print(f)
728095f1e53cfd307006fd79f2ea84612b30acf4
wojole/pajacyk_python_pom
/pajacyk_test.py
891
3.609375
4
import unittest from selenium import webdriver import pajacykPage class PajacykPlSearch(unittest.TestCase): """A sample test class to show how page object works""" def setUp(self): self.driver = webdriver.Chrome() self.driver.get("http://www.pajacyk.pl") def tests_pajacyk_pl(self): ...
8eeda52a0f09f8f33845ab5be07df0234c373cb8
tbtreppe/mini_python_practice
/14_compact/compact.py
324
3.546875
4
def compact(lst): List1 = [] for i in lst: if(bool(i)): lst.append(i) return lst compact([0, 1, 2, '', [], False, (), None, 'All done']) """Return a copy of lst with non-true elements removed. >>> compact([0, 1, 2, '', [], False, (), None, 'All done']) [1, 2, 'All done']...
f24725258d02c4daaeed12350a6aa1b8edd54a19
krzysztof-piasecki/python-hackerrank
/HackerRank/MediumTasks/GreenBin.py
325
3.515625
4
test_cases = int(input()) array = [] count = 0 anagrams = {} for i in range(test_cases): string = sorted(input()) final_version = "".join(string) if final_version in anagrams: anagrams[final_version] += 1 count += anagrams[final_version] else: anagrams[final_version] = 0 print(c...
b9bc259db4410a26d43be2c9694a51d4508c88f8
tiaotiaodan/python
/day1/python-for循环.py
169
3.765625
4
#!/usr/bin/env python # _*_ coding: utf-8 _*_ # Author:shichao # File: .py for i in range(10): print("loop:", i ) for i in range(0,10,1): print("loop:", i )
f0a5f479584d6c8e84ff22f1eb21ebe3849dd119
nmhkahn/neural_network_numpy
/nn/layers.py
15,444
3.71875
4
import numpy as np from nn.init import initialize class Layer: """Base class for all neural network modules. You must implement forward and backward method to inherit this class. All the trainable parameters have to be stored in params and grads to be handled by the optimizer. """ def __init__(...
8e0bfb1a143962dff42e5539fa20d77be8788b05
jingong171/jingong-homework
/张璟玥/第一次作业/第一次作业 张璟玥 2017310399/4.py
146
3.671875
4
number=[] for x in range(2,100): for y in range(2,x): if x%y==0: break else: number.append(x) print(x)
56e6e2f860d83e272a3ecfdeaa8d7f392a720f16
Lexkane/Cryptology
/CaesarCipher/Caesar.py
461
3.734375
4
import sys def main(): pass alphabet = 'abcdefghijklmnopqrstuvwxyz' text = sys.argv[1].lower() shift = int(sys.argv[2]) coded_text = '' new_letter = '' letter_position = None for letter in text: letter_position = alphabet.find(letter) if letter_position != -1: new_letter = alphabet[(le...
41df5d48ec326b57196bcd0040e976a3dd236354
ElizabethMarais/Python-programming
/Coursera3_Network_python_org_more.py
1,445
4.5
4
print "COURSE: www.coursera.org: Course 3 - Using Python to access web data, Week 4." print "FUNCTION: Program uses BeautifulSoup to read and parse a web file." print "It prints lines with certain tags/words in." print " " print "Uses 'https://www.python.org' " import urllib from BeautifulSoup import * url =...
3fd4dfda6c9bd61ac727b46d5455429d05b6d532
gschen/where2go-python-test
/1906101007李和龙/Day20191204/实验七2.py
652
3.609375
4
""" 4.求和 求s= a + aa + aaa + … + aa…a 的值(最后一个数中 a 的个数为 n ), 其中 a 是一个1~9的数字,例如: 2 + 22 + 222 + 2222 + 22222 (此时 a=2 n=5 ) 输入:一行,包括两个整数,第1个为a,第2个为n(1 ≤ a ≤ 9,1 ≤ n ≤ 9), 以英文逗号分隔。 输出:一行,s的值。 输入例子:2,5 对应输出:24690 """ def get_sum(a, n): a = str(a) list_nums = [] sum = 0 for i in range(n): l...
7bc57d49659f3d554df0e5f228e1b6803df4c352
ochi96/prime_numbers-lab
/primeNumbers.py
491
3.859375
4
def prime_number(guess): if guess==0 or guess==1 or abs(guess)!=guess: return False elif guess>=2: for number in range(2,guess): if (guess%number)==0: return False else: return True else: return True def primeNumbers(maximum): pr...
a072cba60c050218999f55ccc04a5b79b7810830
kathd/project
/deal_or_no_deal.py
12,503
4.03125
4
# Deal or No Deal (Modified w/ only 14 cases) # Python 2.7.13 # Hackbright Prep Project, May 2017 # by Kathleen Domingo import os # needed for function to clear screen import random # needed for function to randomize prize values # set randomized prize values prizes = random.sample([.01, 5, 25, 75, 200, 400, 750, 100...
2889d3eb2903be9b712a1f4afff7e8bbbc54c9f1
snailQQ/lxf_python
/8_4inheritance.py
1,581
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Animal(object): def run(self): print('Animal is running.') class Dog(Animal): def run(self): print('Dog is running.') class Cat(Animal): def run(self): print('Cat is running.') def run_twice(animal): animal.run() animal....
18b9dfa93faa90800e8103b8a73355103bc2df1d
chrisrobak/project_euler
/python/problem_4/problem_4.py
1,587
4.5625
5
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is: 9009 (91 x 99) Find the largest palindrome made from the product of two 3-digit numbers. Usage: problem_4.py <num_digits> [options] Options: -h --help shows this screen. """ from...
932d02f6a86e33598381413009898fbca4ba48d9
betty29/code-1
/recipes/Python/498272_Rich_iterator_wrapper/recipe-498272.py
2,963
3.875
4
__all__ = ['Iter'] from itertools import * class Iter(object): '''A wrapper class providing a rich-iterator API. From the user point of view, this class supersedes the builtin iter() function: like iter(), it is called as Iter(iterable) or (less frequently) as Iter(callable,sentinel) and it retur...
7695bbb92e98974720b70261ef018a54a39669f6
TonyWong0512/CS325-W13
/implementation1/algorithms/brute_force.py
653
4.21875
4
#! /usr/bin/env python """ Inversion Counting - Brute Force This algorithm works simply by checking all possible pairs of elements to count the total inversions. """ def brute_force(lst): invs = [0] brute_force_helper(lst, invs) return invs[0] def brute_force_helper(lst, invs): """ Brute force method ...
6ce059afb059b5bdca07f3e69d870e64741a92e7
emrum01/algo1
/05_division/b_c.py
687
3.71875
4
import math def merge(a, l, mid, r): global cnt L = a[l:mid] + [math.inf] R = a[mid:r] + [math.inf] i = 0 j = 0 for k in range(l,r): cnt += 1 if L[i] <= R[j]: a[k] = L[i] i += 1 else: a[k] = R[j] j += 1 print(*a) def ...
3e756c7e5e1be32f196da7fda9fb26d6b4f4a9bc
MohMaya/KIET-Python-Bootcamp
/Assignments/Day1Assignments/FizzBzz.py
206
3.84375
4
p=input("enter the number") p=int(p) for l in range(p): if l%5 == 0: print('buzz') elif l%3==0: print('fizz') elif l%15==0: print('fizzbuzz') else: print(l)
43337c3591b23f4a45ed7d3b118d3e091f53be96
eagleliujun/leetcode
/N172.py
435
4.125
4
""" Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one trailing zero. """ def trailingZeroes1(n): sum = 0 while n >= 1: n = n // 5 sum += n return s...
09eb72f4cb518f4c35a409f31729ac004093a647
Li-Yangchen/python100
/2.py
846
3.5
4
#!/usr/bin/python # -*- coding: UTF-8 -*- ''' 企业发放的奖金根据利润提成。 利润(I)低于或等于10万元时,奖金可提10%; 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%; 20万到40万之间时,高于20万元的部分,可提成5%; 40万到60万之间时高于40万元的部分,可提成3%; 60万到100万之间时,高于60万元的部分,可提成1.5%, 高于100万元时,超过100万元的部分按1%提成, 从键盘输入当月利润I,求应发放奖金总数? ''' i=int(input("利润:")) arr = [1000000,600000,40...
3a1eee0a9d2368728106ce0e8e9c5079e41bd08d
TFakeye6943/code-change-test
/grid.py
176
3.546875
4
import turtle window=turtle.Screen() DeShawn=turtle.Turtle() def square(size): for x in range(4): DeShawn.forward(size) DeShawn.right(90) square(100)
c3070722327b4f87855e893f2fb5ac075172a059
kimtk94/test1
/readtxt.01.py
844
3.78125
4
import sys def read_txt(file_name, 'r') -> str: ret = '' with open(file_name, 'r') as handle: for line in handle: if line.startswith(">"): continue ret += line.strip() return def read_csv(file_name:str) -> list: ret = [] with open(file_name, 'r') as ...
73ebefbdc2e2ea9b1c02c6ff324c0c1694cec5f7
cmathx/news_recommend
/code/cjw/PLSA/utils.py
1,453
3.6875
4
# -*- coding: utf-8 -*- #! /usr/bin/env python from random import gammavariate from random import random """ Samples from a Dirichlet distribution with parameter @alpha using a Gamma distribution Reference: http://en.wikipedia.org/wiki/Dirichlet_distribution http://stackoverflow.com/questions/3028571/non-uniform-dis...
865b6b962f56f1eb67e0c0138c708e8f5198217c
egalli64/pythonesque
/cip/w5/scribble.py
769
3.859375
4
""" Code in Place 2023 https://codeinplace.stanford.edu/cip3 My notes: https://github.com/egalli64/pythonesque/cip Section Week 5: Scribble - Draw a circle wherever the mouse is located on the screen """ from graphics import Canvas import time CANVAS_WIDTH = 300 CANVAS_HEIGHT = 300 CIRCLE_SIZE = 20 DELAY = 1 def ma...
9a981e99ebd1688cebfb5d908b27ed13adfed7cc
xiaomengxiangjia/Python
/practice_10_5.py
276
3.703125
4
filename = 'reasons.txt' with open (filename, 'a') as file_project: while True: questions = input("Why you like to program? press 'quit' to quit.\n") if questions == 'quit': break; else: file_project.write(questions + "\n")
d52afbc258bc03df884d6b7dfbdb47545cde4e7b
C-CCM-TC1028-111-2113/homework-1-SofiaaMas
/assignments/18CuentaBancaria/src/exercise.py
491
3.828125
4
def main(): #escribe tu código abajo de esta línea santerior=float(input('Inserte su saldo del mes anterior:')) ingresos=float(input('Inserte sus ingresos:')) egresos=float(input('Inserte sus egresos:')) cheques=int(input('Inserte el número de cheques expedidos:')) c=13 costcheques=cheques*c stotal=santerior+...
b26dea42cadd5a299d57f50ad6c5cfd684c055ee
garybergjr/PythonProjects
/UnitTestingWithPython/test_phonebook.py
344
3.640625
4
class Phonebook: def __init__(self) -> None: self.numbers = {} def add(self, name, number): self.numbers[name] = number def lookup(self, name): return self.numbers[name] def test_lookup_by_name(): phonebook = Phonebook() phonebook.add("Bob", "1234") assert "1234" ==...
e6a9c889a415d34277ed760e6fee3504454a4fde
x-zh/parkers
/utils/lat_lng_to_miles.py
1,301
4.34375
4
# coding=UTF-8 """ Created on 9/9/14 @author: 'johnqiao' The following code returns the distance between to locations based on each point's longitude and latitude. The distance returned is relative to Earth's radius. To get the distance in miles, multiply by 3959. To get the distance in kilometers, multiply by 6373...
a3569b72b26c4ef2ce33f0a34d216a89be8a92cc
bilalsaeed232/python-internet-data
/03_json/json_requests_demo.py
674
3.5625
4
import requests import json def main(): # TODO: url for getting valid json URL = 'http://httpbin.org/json' result = requests.get(URL) # TODO: convert the response json to valid python dict pyDict = result.json() # TODO: first display json string received # print("JSON ------------") ...
2209a3fc058d2c747cafcac97ed096d8db006499
santoshskm/python_practice
/1_extract_username.py
190
3.828125
4
email=input("Enter your email id:") li=list(email) index_num=li.index("@") print("Username:") for i in range(0,index_num): if(li[i].isalpha()): print(str(li[i]),end="")
7ac5ff8b27d9f7a7e587c4157f74dbaadb1eeaef
haiyogi/Hackerearth
/firstoccur.py
400
3.984375
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 16 18:55:36 2020 @author: K Yogesh """ def program(): s=input() unique = [] occurenceset = set() for x in s: if x not in occurenceset: unique.append(x) occurenceset.add(x) for x in unique: ...
d45714eaa00d6287e50e5e38d22f856585c3d182
junwoo77lee/Python_Algorithm
/divide_and_conquer/selection_sort.py
642
3.71875
4
from typing import List, Sequence def selection_sort(seq: Sequence) -> Sequence: # return a sorted sequence by using the selection sorting algorithm # find the minimum and assign it to the first element idx = 0 while idx < len(seq): idxmin = 0 for i, number in enumerate(seq[idx:]): ...
f565e09b31514c641b9b3abc7c1e0d7f65891553
TEAMLAB-Lecture/baseball-seungwoo-h
/baseball_game.py
3,920
3.71875
4
# -*- coding: utf-8 -*- import random def get_random_number(): return random.randrange(100, 1000) def is_digit(user_input_number): # isdigit() 으로 숫자로만 구성된 문자열인지 확인 # 불린형으로 반환됨 result = user_input_number.isdigit() return result def is_between_100_and_999(user_input_number): # 단순 부등식 검사 ...
040af6bc8369572b69410b753d63ba96bedb043f
kiwi1018/gui_tkinter
/gird.py
750
3.984375
4
import tkinter as tk # 使用Tkinter前需要先匯入 # 第1步,例項化object,建立視窗window window = tk.Tk() # 第2步,給視窗的視覺化起名字 window.title('My Window') # 第3步,設定視窗的大小(長 * 寬) # geometry('長x寬+X+Y') window.geometry('500x300') # 這裡的乘是小x height = tk.Label(text="Height") height.grid(row=0, column=0) weight = tk.Label(text="Weight") weight.grid(...
afd01cac2bed20d34cf345338ef18826b08abfee
abhinav-gautam/machine-learning-projects
/Regression/Weather/Linear Regression.py
1,873
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 10 18:35:13 2019 @author: abhinav """ #Linear Regression Model import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as seabornInstance from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression ...
b4e4185bfad333ea933235260670e68de2b5f9e3
hayleyguillou/eul
/eul059.py
473
3.796875
4
import itertools def eul59(): """Decrypt the message and find the sum of the ASCII values in the original text.""" cipher = [c.rstrip('\n') for c in open('resources/p059_cipher.txt')] cipher = [int(c) for c in cipher[0].split(",")] for key in itertools.product(range(97, 123), repeat=3): msg = ...
64c4948ab428a58e8384df29e327d6c7dd979d74
inambioinfo/Genomic-Scripts
/assignment5/generate_promoters.py
2,280
3.59375
4
#!/usr/bin/env python3 """ This script: 1) Takes a bed file of gene coorinates and creates a bed file of their promoters Definition of promoters within this code: 1) On average promoters are approximately 250 base pairs upstream of the start site 2) Promoters can vary from 100 - 1,000 base pairs, therefore I am using ...
193f45d48ffc8a4feb62c624ec9eac7bf22d0d2f
11Nithya/Python_Training_task
/exceptiom_handling.py
258
3.9375
4
#Write a code for reading a file ( all exceptions handled ) s="hello" try: f=open("read.txt","r") f_contents=f.read() print(f_contents) except Exception as e: print(e) else: print("no error") finally: print("end")
5c2d8323e27f99d15212ce9ac46082b5c3defff1
sztxr/JetBrains_Projects
/Coffee Machine/Coffee Machine/task/machine/coffee_machine.py
3,409
4.09375
4
class CoffeeMachine: money = 550 water = 400 milk = 540 beans = 120 cups = 9 def __init__(self): while True: action = input('Write action (buy, fill, take, remaining, exit):') if action == 'buy': self.buy() elif action == 'fill': ...
02e276a90d89929e8c5ddc794420c9a93829cc7b
SlyCodePanda/AdvancedPython-Udemy
/Decorators/classDecorators.py
933
4.1875
4
# Example 01 class x: def __init__(self): print("An instance or object was initialized") def __call__(self, *args, **kwargs): print("Arguments are ", args, kwargs) a = x() print("Calling Objects or Arguments") # Use call function. a(4, 5, z=12, v=20) # Using the a object, we can call the 'c...
52a67f91a74aacf658f7cd55a0d77412c71a654c
phdevs1/Comprogram
/uri/uri1019.py
184
3.5
4
val = int(input()); if val>3600: h = val/3600; hm = val%3600; val = hm; else: h = 0; if val>60: m = val/60; mm = val%60; s=mm; else: m=0; s=val; print("%i:%i:%i" % (h,m,s));
b2f55a101a16b6849b48e4b446ee1e22238bb1a8
luangcp/Python_Basico_ao_Avancado
/stringIO.py
876
3.71875
4
""" stringIO ATENÇÃO: Para ler ou escrever dados em arquivos do sistema operacional o software precisa ter permissão: - Permissão de leitura -> Para ler o arquivo. - Permissão de escrita -> Para escrever no arquino StringIO -> Utilizado para ler e criar arquivos em memoria. ele não vai gravar no disco...
ab8edc23313e86713d2a5dfaf68ca55bcd06eb0b
hrssurt/lintcode
/lintcode/1069 Remove Comments.py
1,635
3.5
4
"""*************************** TITLE ****************************""" """1069 Remove Comments.py""" """*************************** DESCRIPTION ****************************""" """ Given a C++ program, remove comments from it. The program source is an array where source[i] is the i-th line of the source code. This...
a9fc1c06de3e1b1d72b8c9ae02f3b7e05bab7176
igm-team/orion-public
/src/luigi_parameter_extension.py
934
3.53125
4
import os class InputFileParameter(Parameter): """ Paramater whose value is an existing file. """ def parse(self, s): """ Returns the real path to the file from the string if it exists. """ if os.path.isfile(s): return os.path.realpath(s) else: ...
aeaeda3f6c846c08c3ee3dbc1bfd19d88ece8118
alexalex1228/py_game
/game3/dragon.py
1,033
4.15625
4
import random import time def display_intro(): print(''' You are in a land full of dragons.In front of you, you see two caves. In one cave, the dragon is friendly and will share his treasure with you. The other dragon is greedy and hungry, and will eat you on sight. ''') print() def choo...
5015cb3bf03824b4c9c9813cf9a9fb46fde63339
iasminqmoura/algoritmos
/Lista 2/Exercicio07.py
150
3.859375
4
raio = float(input("Insira o valor do raio da circunferência: ")) area = 3.14159 * (raio ** 2) print("A área da circunferência é: ", area)
315a5b7b226baa7e4811e9ad073474f5ab45cbae
JustinB9/tictactoe
/tictactoe_ai.py
3,368
3.875
4
import random from basic_ttt_functions import * def basic_ai(board_array): # if board is full, immediately stop if not check_for_spaces: return board_array # options to be randomly selected from are initialized empty board_options = [] # trawls through board adding options for x in r...
6e8e261ff711b48c3288db34f89b1c29af8e85a5
choupi/puzzle
/leetcode/p29.py
1,108
3.53125
4
# 29. Divide Two Integers # https://leetcode.com/problems/divide-two-integers/ class Solution(object): def mdivide(self, dividend, divisor): q=0 res=dividend while res >= divisor: res-=divisor q+=1 return q, res def divide(self, dividend, divisor): ...
06b770e59924749510b9ee7e50f414c43daf4ddc
farriscd/square-skunk
/trivia_parse.py
2,592
4
4
# todo: switch between words and numbers i.e 'zero' -> '0' # fix parse_parens # adjust scoring system i.e. ('carbon dioxide' passes as 'argon', 'morphine' as 'heroin') # figure out how to parse 'or', questions with multiple correct answers parsed = [ '/', ' !', ' ?', ' .', ' & ', ...
cbf07ce8e14b2d6e64a25aae61688e337cb6f2dd
Flandre33/spider
/12_try_lxml.py
1,236
3.53125
4
from lxml import etree text = """ <div> <ul> <li class="item-1"><a>first item</a></li> <li class="item-1"><a href="link2.html">second item</a></li> <li class="item-inactive"><a href="link3.html">third item</a></li> <li class="item-1"><a href="link4.html">fourth item</a></li> <li class="item-0"><a href="link...
ea445f68d3969140a5cbfb1043e9de8f8bebaa9f
HeHisHim/livePuff
/record/property_in_python.py
1,308
3.75
4
# 使用property来对类属性进行限制, 实现类似java的get / set方法 class Spirit: def __init__(self): self._speed = 1 def get_speed(self): return self._speed def set_speed(self, speed): # 对self._speed的赋值做限定 if isinstance(speed, int) and 0 < speed and speed < 11: self._speed = speed ...
ed3053ad8afc41ef445d1e7d2cee62a5c44ab8be
B-Tech-AI-Python/Class-assignments
/sem-4/Lab1_12_21/operators.py
472
4.15625
4
# \\OPERATORS\\ # arithmetic # comparison # assignment # logical # membership vowels = ['a', 'e', 'i', 'o', 'u'] user_name = input("\nEnter your name: ") print("\nHello" + " " + user_name + "!") count = 0 for letter in vowels: if letter in user_name.lower(): count += 1 if count > 0: print(f"\nYou h...
46b9bd183baf23c94d972961d973681bb02feed7
jia-yi-pan/tic-tac-toe-computer-play
/game_board.py
754
3.6875
4
class GameBoard: def __init__(self): self.board = [" " for x in range(10)] def print_board(self): print(f" [ {self.board[1]} ] [ {self.board[2]} ] [ {self.board[3]} ]\n" f" [ {self.board[4]} ] [ {self.board[5]} ] [ {self.board[6]} ]\n" f" ...
a81a4d7d649fa37a9b96cb9ff9c1b7d99b944475
joshuacook/Eloranta_Lab
/FiniteDifferences/bin/discrete_reps.py
429
3.828125
4
import numpy as np indep_vec = np.linspace(0,1,101) # indep_vec is a discrete representation # of the closed interval [0,1] # Build a LINEAR Function f = lambda x: x # We have created a map # f: REALS to REALS by # f(x) = x # Build a Quadratic Function g = lambda x: x**2 # Discrete Functions # f: [0,1] to REAL...
659f35bf65aaab5e47fbd7ae31a1ac5f5b55e821
razmikarm/structures_in_python
/sandbox.py
1,635
4.28125
4
from linked_list import LinkedList from stack import Stack from queue import Queue def linked_list_example(): print('------------------->> Linked List Example <<-------------------') llist = LinkedList() llist.append(0) llist.append(1) llist.append(2) llist.append(3) llist.prepend(-1) ...
54338446d7914658549bd6102fb4947e8d3c23f2
stephwongwt/LearningGists
/HackerRank/Python/HR-Day08-PhoneBookDict.py
465
3.546875
4
#HackerRank 30 day of coding challenge. Day 8. #!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': n = int(input()) # a = list(map(str, input().rstrip().split())) pb = {} for i in range(n): a = str(input()).split(" ") pb[a[0]] = a[1] while True: try:...
b70ffeb3c45ba0da6d856d02fc9822a7900cc582
LouisTilloy/Projet-MOPSI-jeu-dame
/grid.py
2,144
4.15625
4
# -*- coding: utf-8 -*- """ Contains the class 'Grid' of the checkers game """ class NotInteger(Exception): def __init__(self, value): self.value = value def __str__(self): return "{} n'est pas un entier !".format(self.value) class NotPositive (Exception): def __init__(self, value): ...
be21b09fd4f69a38f01d437d5dbcdd4cfc5d76a3
JeffCohen/python-intro
/0_start.py
347
3.609375
4
# Welcome to Python! # # Start the Python REPL: # # $ python3 # # # We will talk about: # # * Variables # * Case sensitivity # * Built-in types: `int`, `str`, `float` # * User input # * A word about quotation marks # # Next, we will write Python scripts. # # * Writing scripts # * Printing to the screen ...
bc54abb09eaf4c57056a7dc43f381709881056de
nepomnyashchii/TestGit
/old/videos/04.py
356
3.59375
4
import pyowm city = input("What is is weather in: ?") API_key = '1bdcae6b7d23f180361c8878a965c9f8' owm = pyowm.OWM(API_key) observation = owm.weather_at_place(city) w = observation.get_weather() temperature = w.get_temperature('celsius')['temp'] print("In " + city + " temperature now is: " + str(temperature) + " degree...
9242dea390be61512713095fd22324c9fe7e1008
JasonDong97/learn-python
/src/operators/test_bitwise.py
1,188
4.15625
4
"""位运算符 @see: https://www.w3schools.com/python/python_operators.asp 位运算符在位级上操作数字。 """ def test_bitwise_operators(): """位运算符""" # 与运算 # 同位都为1,则取1,否则为0. # # Example: # 5 = 0b0101 # 3 = 0b0011 assert 5 & 3 == 1 # 0b0001 # 或运算 # 如果两个位中有一个为1,则设置每个位为1。 # # Example: #...
f27f742acefeb4c0ee792b47ce786c4b182e783b
codeAligned/Interview-Problems-2
/Longest Consecutive Sequence.py
530
4.0625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 12 02:03:24 2019 @author: Anuj """ ''' Data Structure: set Step1 : I am going to check if the elements on the list is visited or not. If the element is visited I would then add'em to the list. var - visited type - list ''' def longest_consecutive(nums...
3e80f1b3950514395b1748e1c65955b4913ad329
SpoortiPatil/simple-linear-regression-using-python
/Simple linear 2.py
3,458
3.515625
4
# Importing necessary libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt # Importing the dataset sal = pd.read_csv("Salary_Data.csv") sal.columns # Renaming the columns for convinience sal= sal.rename(columns= {"YearsExperience" : "yrsexp", "Salary" : "slry"}) sal.columns ...
3ecd05c54ee02f244c2c8d051902774f87b1acb2
shree-guhun/Pythonprogram
/LICENSE.md/B4.py
263
4.28125
4
while True: print("Enter '0' for exit.") chr=input("Enter any character:") if chr=='0': break else: if((chr>='a' and chr<='z')or (chr>='A'and chr<='Z')): print(chr,"is an alphabet.\n") else: print(chr,"is not an alphabet.\n")
2507ba4fbc52408788b4805001967199d93a27ed
Hemant-Kulkarni7/test_git
/func_square.py
171
3.59375
4
def sqr (): l = [] l1 = [] i = 1 while i <= 30: l.append(i) i += 1 for i in l: l1.append(i*i) print(l1) sqr()
9731ae3d5b56394d9b519477ff13aacff9a1a2e4
gislfzhao/PythonCourse
/Forth_ProgramControlStructure/UserLogin.py
253
4
4
# User Login for i in range(3): username = input() password = input() if username == 'Kate' and password == '666666': print("登录成功!") break else: print("3次用户名或者密码均有误!退出程序。")
79a14647169b241d2d1ecc55519814829d1c60d2
jpdotcom/Hackerrank-solutions
/InsertionSortPt2(Easy)Solution.py
762
3.796875
4
def insertionSort1(n, arr): sorter=arr[n-1] i=n-2 while i>=0 and arr[i]>sorter: if arr[i]>sorter: arr[i+1]=arr[i] i-=1 arr[i+1]=sorter return arr def insertionSort2(n,arr): arr_seg=[arr[0]] for i in range(1,len(arr)): arr_seg.append(arr[i]) in...
eff98bf715776c5b4ce070b4f1f97bc15753ddee
yuanhaomichael/code-practice
/1. BFS/378-kth_in_sorted_matrix.py
1,208
3.875
4
# https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/ import heapq ''' For 2 sorted list, we can find the kth smallest by 2 pointers for multiple sorted list, we can keep a pointer for each list -Look at Seed's solution, solve using a priority queue https://gist.github.com/BazzalSeed/ef85b3701...
0a5e114c5a1df818ef1139323491cc8be9448ba8
kseniajasko/Python_study_beetroot
/hw26/Stack.py
773
3.890625
4
class Stack: def __init__(self): self._items = [] def is_empty(self): return bool(self._items) def push(self, item): self._items.append(item) def pop(self): return self._items.pop() def peek(self): return self._items[len(self._items) - 1] def size(sel...
0653feaec582543873d9b7be2d9aacf836c3b562
paalso/learning_with_python
/08 Strings/8-10.py
1,111
4.34375
4
## Chapter 8. Strings ## http://openbookproject.net/thinkcs/python/english3e/strings.html ## Exercise 10 ## =========== # Write a function that removes all occurrences of a given letter from a string: import sys def reverse(s): tmp_list = list(s) tmp_list.reverse() return ''.join(tmp_list) ...
8a3fcfbd4fd10a4ec2c41a9664e715f27f664812
kylefinter/old_programs
/CSC130/proj03.py
1,050
4.1875
4
''' Kyle Finter proj03.py Takes a string and transcodes them into morse code using a space as a delimiter between letters. ''' string=input("Enter a phrase to be translated to Morse code: ") string=string.upper() liststr=list(string) #(.=0)(,=27)(?=28)(0-9=29-38) letterlist=['.','A','B','C','D','E','F','G','H','I','J'...
2466bc4c0ff09e1844adc9155eb05d072f227eb1
rw54022n/Python_Tutorials
/Flask_Tuts/Flask_8Apps_Udemy/Terminal_Blog/menu.py
2,809
3.765625
4
from database import Database from models.blog import Blog class Menu(object): # Ask user for author name # Check if they've already got an account # If not, prompt them to create one def __init__(self): self.user = raw_input("Enter your author name: ") self.user_blog = None ...
83d0ab77d5de54e51c3ceec06f91362d9256a2b9
shivrajpatil12/HackerRank_Solutions
/word_order.py
296
3.640625
4
import collections no_of_words = int(input()) w_dict = collections.OrderedDict() for i in range(no_of_words): word = input() if word in w_dict: w_dict[word] +=1 else: w_dict[word] = 1 print(len(w_dict)) for key, value in w_dict.items(): print(value, end=' ')
5498ab4386f87f31d3ffbdc160fa89e1f70f87ef
Abdulaziz-04/Algorithmic-Toolbox
/week2_algorithmic_warmup/6_last_digit_of_the_sum_of_fibonacci_numbers/fibonacci_sum_last_digit.py
416
3.71875
4
# Uses python3 import sys fibval=[1]*62 def fib(n): a=0 b=1 sm=a+b fibval[0]=0 fibval[1]=1 if(n==0): return 0 if(n==1): return 1 for i in range(2,n+1): c=(a+b)%10 a=b b=c sm+=c fibval[i]=sm%10 def fibonacci_sum_naive(n): fib(60) return fi...
f0907a54e880ed5568eaeb8c66720855c76432ce
matt-ankerson/oosd
/blackjack/Deck.py
987
3.890625
4
import Card # Deck class # Author: Matthew Ankerson # Date: 24 Feb 2015 # This class holds cards and performs functions necessary for a Deck class Deck(): # Default constructor # Create the Deck of Cards def __init__(self, strategy): self.cards = [] self.strategy = strategy for s...
cc9bb6ef1a6ff6660a7b081d3215941a12910869
guojch/Python-learning-record
/study/list.py
537
3.890625
4
#!/usr/bin/python3 # list 有序集合 classmates = ['Michael', 'Bob', 'Tracy'] len(classmates) classmates[1] # 倒一,倒二元素 classmates[-1] classmates[-2] # 追加元素到末尾 classmates.append('Adam') # 插入元素到指定位置 classmates.insert(1, 'Jack') # 删除末尾的元素/指定索引的元素 classmates.pop() classmates.pop(2) # 替换 classmates[1] = 'Sarah' # list里面的元素的数据类...
04504bcb581edd3b2c1b1c14154e467b5110f683
NerdyStuff/AdventOfCode2020
/Day_7/day_7.py
715
3.671875
4
file = open("luggage_rules.txt", "r") def findColor(searchColor, bagList): if any(searchColor in string for string in bagList) == True: return True return False rules = dict() for line in file: line = line[:-2] bagColor = (line[:line.find("bags")])[:-1] bags = line[line.find("co...
35a403a8b0edc4449e110daa56d3a70183684e4c
Nachtfeuer/concept-py
/concept/game/tetris.py
2,557
3.875
4
""""Module tetris.""" from random import randint from concept.game.raster import Raster class Tetris(object): """Simple tetris game.""" SHAPES = [["****"], ["****", "* ", "* ", "* "], ["***", "*"], ["***", "* *"], ["***", " *"], ["***", "** ", "* "], ["***", " * "], [" **"...
9c90807ea2e8a6b3e8149edf847e0159b79dad58
examon/iv122_math_code
/libs/timer.py
830
3.71875
4
""" Tomas Meszaros Module with timing utilities. """ import time def timeit(message: str): """ Named decorator "@timeit". Times execution of the decorated function in milliseconds. Prints the @message + measured time. Note: the is some overhead from the function calls so the measured time is not...
c880cd4512636bed3e4e7b3a9803b7f110e62a84
atulchauhan89/LearnPythonByDoing
/OOPS Concept/Overriding_example.py
487
3.625
4
class Version(object): def __init__(self): #initializing values self.__version = 22 #private variable defined def getVersion(self): #prtinting the version print(self.__version) def setVersion(self, version): #changing the value self.__version = version obj = Version() #object def...
417968c74e4c0455b3ad17fe6f3c2c5ef4414623
A4ABATTERY/year-1-uni
/CS_LABS/CS_160/Assignment_Tester/assignment6_2.py
1,806
3.9375
4
def Assignment6_2(): def filter_list(Nums): Nums = [element for element in Nums if element.isdigit()] #print (Nums) return Nums def Convert_String(Nums): Nums = [int(x) for x in Nums] return Nums def Compare_LEN(Nums1, Nums2): if len(Nums2) == len(Nums1): ...