blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b02c3710c778ed71534721cea03c11db41f6072c
kivy/kivy
/examples/widgets/recycleview/rv_animate_items.py
3,628
3.984375
4
'''How to use Animation with RecycleView items? In case you really want to use the Animation class with RecycleView, you'll likely encounter an issue, as widgets are moved around, they are used to represent different items, so an animation on a specific item is going to affect others, and this will lead to really conf...
2cd4eb98d4adb5d85a6a640d653978ac10a54608
neuromaancer/PRD
/nn/preprocess.py
21,478
3.671875
4
import numpy as np import csv class Preprocess: def convertRHtoSeq(self, r, h, size): """ Function can use the numbers : r and h. and create a sequence like (0000011111). 0: the poisiton out of window 1: the position in the window :param r: start position :param h:...
fe42adbde67a34e2e1dcafa1292b455520e44afe
amontoya98/MCMC
/MCMCWeather/mcmcWeather.py
810
3.796875
4
#MCMC #Probability of the Weather import random #function definitions def genMarkovDays(n): climate = "SR" days = "" days += random.choice(climate) for i in range(1, n): if days[i-1] == 'S': weather = random.choices(climate, weights=(90,10), k=1) elif days[i-1] == 'R': ...
e1ce505df346a3f496f6952a53c53e20d1867c6f
BenDataAnalyst/Practice-Coding-Questions
/CTCI/Chapter3/3.1-Three_In_One.py
2,842
3.609375
4
# CTCI 3.1 # Three in One import unittest class ThreeStacks(): def __init__(self): self.array = [None, None, None] self.current = [0, 1, 2] def push(self, item, stack_number): if not stack_number in [0, 1, 2]: raise Exception("Bad stack number") while len(s...
066b67be792f305d212b5a161c082b41fa0ccdd2
hxyair/Google
/2.Using Python to Interact with the Operating System/Week7/csv_to_html.py
400
3.796875
4
#!/usr/bin/env python3 # regexr.com # print(sorted(names)) import re line = "May 27 11:45:40 ubuntu.local ticky: INFO: Created ticket [#1234] (username)" re.search(r"ticky: INFO: ([\w ]*) ", line) fruit = {"oranges": 3, "apples": 5, "bananas": 7, "pears": 2} sorted(fruit.items()) import operator sorted(fruit.items(...
9d24913160e0f6c8ac21da6328f3d9b34854bd4b
Platforuma/Beginner-s_Python_Codes
/10_Functions/6_Functions--Reverse-Strings.py
1,088
4.34375
4
''' Write a Python program to reverse a string. Sample String : "1234abcd" Expected Output : "dcba4321" ''' #using string index method print('----String Index Method----') def r_string(fstring): rstring = '' index = len(fstring) while index>0: rstring += fstring[ index - 1 ] ...
f170e332a4041b2fe14d6482209b667c66237032
AndresNunezG/ejercicios_python_udemy
/ejercicio_04.py
678
4.15625
4
""" Ejercicio 4. - Pedir dos (2) números al usuario - Hacer todas las operaciones básicas matemáticas - Mostrar el resultado en pantalla """ #Solicitar numeros al usuario num_a = int(input('Ingrese el primer número: ')) num_b = int(input('Ingrese el segundo número: ')) #Operaciones básicas suma = num_a +...
75ec852a74486ad47d532c467798d5cf5a1f7c84
mathuraveeraganesh/IBM-SDET-LONG-Batch-1_Python
/Python/ListSumCalculator.py
273
4.09375
4
"""Write a Python program to calculate the sum of all the elements in a list. Bonus points if you can make the user enter their own list""" num = list(input("Enter the Sequence seperate by comma").split(",")) sum=0 for nums in num: sum+=int(nums) print(sum)
6bf4d215cfbab686736406161b6950dfd5652a26
murali-kotakonda/PythonProgs
/PythonBasics1/functions/FuntionProg2.py
570
3.796875
4
def f2(name): print("input =", name) f2(12) f2("user1") f2(1213.78) f2(True) #sum of two nums def sum(x, y): z = x + y print("sum = ", z) sum(30, 20) a = 40 b = 90 sum(a, b) n1 = int(input("enter n1")) n2 = int(input("enter n1")) sum(n1, n2) #find big of two nums def findLarge(a,b): if a>b: ...
b2c89954836f967e02d1ea04e9ed446e7e6a6cc8
vahidsediqi/Python-basic-codes
/Data-Structures/lists/sorting.py
142
4.09375
4
numbers = [3,2,1,5,8,6,10,9,7,4,0] numbers.sort() print(numbers) # if we want to sort it reverse numbers.sort(reverse=True) print(numbers)
42eb167f71336c113b5a5b9c739de078420c675f
learnerofmuses/slotMachine
/csci152Spring2014/lab7/p2.py
614
4.375
4
#Write a program that randomly generates the 2-dimensional list. Make #sizes of the list user input. Program prints all odd elements. import random def main(): row = int(input("enter number of rows: ")) col = int(input("enter number of cols: ")) odd = [] a = [[0 for i in range(col)] for j in range(row)] for ...
05fc5b4da34e7ed1e4253b0432ea1474252be0f5
delaven007/project-2
/dict_select.py
2,354
3.5
4
"""用户可以登录和注册 1.确定并发方案,确定套接字,具体细节和需求分析 *Process多进程 tcp套接字 *注册后直接进入二级界面,历史记录最近10个 2.使用dict -->words 用户表:id name passwd create table user (id int primary key auto_increment,name varchar(32) not null ,passwd varchar(128) not null); 历史记录表:id name word time create table hist (id int primary key auto_increment,nam...
81a8d22c412f507abf0a8ca9713d8f23e8fb2f77
D-Muturi/Zookeeper
/Problems/Calculating S V P/main.py
257
3.84375
4
a = int(input()) b = int(input()) c = int(input()) sum_of_rectangle = (4 * (a + b + c)) area_of_rectangle = (2 * ((a * b) + (b * c) + (a * c))) volume_of_rectangle = (a * b * c) print(sum_of_rectangle) print(area_of_rectangle) print(volume_of_rectangle)
74ee10a79197b18ea12bd8722736302f3c25045e
LinnTaylor/reflections
/MachineLearning/Regressions/QuizOne/studentRegression.py
731
3.53125
4
import numpy as np from sklearn import linear_model def studentReg(ages_train, net_worths_train): ### import the sklearn regression module, create, and train your regression ### name your regression reg ### your code goes here! reg = linear_model.LinearRegression() # Train the model using the ...
b1bf4a5bb183e1e28e49a2373ae041c8c1ab551a
degerej/homework3
/nodes.py
1,527
3.96875
4
# Joe Degere # 2/24/2020 # Nodes homework; Advanced class Node: def __init__(self, data): self.data = data self.next = None def __repr__(self): return repr(self.data) class LinkedList: def __init__(self): self.head = None def __repr__(self): nodes = [] ...
819b9ab6ba3cd04848576ffad17b2d82e2245b08
ahmedmeshref/coffee-shop-ms
/backend/src/models.py
2,368
3.53125
4
import os from sqlalchemy import Column from flask_sqlalchemy import SQLAlchemy import json db = SQLAlchemy() def setup_db(app): """ setup_db(app) binds a flask application and a SQLAlchemy service """ db.app = app db.init_app(app) db.create_all() class Drink(db.Model): """ D...
f029ced78adb32b6b983c75532b295ba5c65b95d
MichaelENGs/Falcons_Income_Estimator
/src/asuProject_capitalgainloss_visuals_scatter.py
5,347
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 8 14:31:12 2021 """ import pandas as pd import matplotlib.pyplot as plt import numpy as np df_columns = ['age','workclass','fnlwgt','education','education-num','marital-status','occupation','relationship','race','sex','capital-gain','capital-los...
7e8153a30feab9b93730d18bfc7365fa6d65fb7d
comp-think/comp-think.github.io
/exercises/development/intermediate/exercise_6.py
1,325
3.515625
4
# -*- coding: utf-8 -*- # Copyright (c) 2019, Silvio Peroni <essepuntato@gmail.com> # # Permission to use, copy, modify, and/or distribute this software for any purpose # with or without fee is hereby granted, provided that the above copyright notice # and this permission notice appear in all copies. # # THE SOFTWARE I...
6070dea4fa5b4834d583e3d906d8dca52656dd7f
grayfelt/CS1440
/cs1440-felt-grayson-assn0/lsn/0-ASCIIChars/ex1.py
639
3.75
4
def listOfChars(intList): list = [] # TODO: Append to characters to `list` for val in intList: list.append(chr(val)) return list if __name__ == '__main__': provided = [ 65, 32, 115, 104, 111, 114, 116, 32, ...
87e08c29db5e459b67b54b1b7367cdb55f72a17d
frclasso/turma3_Python1_2018
/Cap05_Operadores_Basicos/op_associacao.py
310
3.921875
4
# in e not in pessoas = ['Fabio', 'Joao', 'Sandro', 'Douglas', 'Guilherme', 'Marcelo', 'Marcelo Caon', 'Mauricio'] print('Mauricio' in pessoas) # True print('Jessica' in pessoas) # False print('Jessica ' not in pessoas) # True # if => se if 'Fabio' in pessoas or 'Jessica' in pessoas: print('OK')
24546e17d82b0e0cde675a5f5162177d550d4522
DimpleOrg/PythonRepository
/Python Crash Course/vAnil/Chapter-10/10-11-part1.py
218
3.6875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 14 21:49:41 2021 @author: ANIL """ import json fav_num = input('Enter your favorite number: ') with open('fav_num.json', 'w') as f: json.dump(fav_num, f)
313b8533ab6fa8d263c25e2f3aae7ce1e783dbd5
blitu12345/spojCodes
/gregcontor.py
827
3.78125
4
def cloumn1(sum): n=0 p=True while(p): if(sum<=n*(n+1)/2): p=False return n else: n+=1 for i in range(input()): sum1=input() n=cloumn1(sum1) #print "n" #print n count=n*(n-1)/2 #print "count" #print count if(n%2==0): #print "if-1" a=1 b=n p=True #print "a" #print a #print "b" #p...
1977ddef769cbff86257b43a84e3a660c5092389
shg9411/algo
/algo_py/boj/bj2220.py
230
3.53125
4
n = int(input()) heap = [0, 1] for i in range(2, n+1): heap.append(i) heap[i], heap[i-1] = heap[i-1], heap[i] j = i-1 while j!=1: heap[j],heap[j//2] = heap[j//2],heap[j] j = j//2 print(*heap[1:])
26434cf9ea269ace4841bf1ec8c4d17ede18f067
DidiMilikina/DataCamp
/Machine Learning Scientist with Python/23. Winning a Kaggle Competition in Python/02. Dive into the Competition/07. Time K-fold.py
1,289
3.578125
4
''' Time K-fold Remember the "Store Item Demand Forecasting Challenge" where you are given store-item sales data, and have to predict future sales? It's a competition with time series data. So, time K-fold cross-validation should be applied. Your goal is to create this cross-validation strategy and make sure that it w...
c1268b4bddddef1aeb0332094fe776e2581869ab
QkqBeer/PythonSubject
/面试练习/15.py
919
3.84375
4
__author__ = "那位先生Beer" def threeSum(nums): """ :type nums: List[int] :rtype: List[List[int]] """ #复杂度是n ** 2 # dic = {} # for num in nums: # dic[num] = dic.get(num, 0) + 1 # print(dic) nums.sort() reList = [] for i in range(len(nums)): if i > 0 and nums[i] =...
59ce5f75542580020c3ea0c1b783faf6c992d57e
Tedworthy/ATLAST
/ast/node.py
1,289
3.5
4
''' Node This base class is the basic structure for all nodes in the abstract syntax tree for our first order logic grammar. ''' from codegen.symtable import SymTable class Node(object): def __init__(self, lineNo, position): self._lineNo = lineNo self._position = position self._children = [] self._...
33cbdedef379ff81d9a62df1b908f94099865173
MLN888/CDIOProject2020
/CircleDetectionImage.py
1,435
3.78125
4
import cv2 import numpy as np #https://www.geeksforgeeks.org/circle-detection-using-opencv-python/ # Read image. #img = cv2.imread('eyes.jpg', cv2.IMREAD_COLOR) cap = cv2.VideoCapture(cv2.CAP_DSHOW + 1) #cap = cv2.VideoCapture(0, cv2.CAP_DSHOW) #cap.set(cv2.cv.CV_CAP_PROP_FOURCC, cv2.cv.CV_FOURCC('M','J','P','G'...
c9e5dc84b0d9847e4d5aa82fee81890998282232
EmonMajumder/All-Code
/Python/Hipsterslocal.py
1,260
4.0625
4
#Don't forget to rename this file after copying the template for a new program! """ Student Name: Emon Majumder Program Title: IT Programming Description: Assignment- 1 (Hipster Local) """ def main(): #<-- Don't change this line! #Write your code below. It must be indented! #1. Print name of shop #2. Input...
3e6e792b30affb72ed7ba497ebba4c9a14c7e5a3
awkwardbunny97/DangQuangAnh-Fundamentals-C4E32
/Session03/Homework/Turtle_Exercises/turtle_01.py
378
3.734375
4
from turtle import * for i in range(3): color('red') forward(100) left(120) for i in range(4): color('blue') forward(100) left(90) for i in range(5): color('brown') forward(100) left(72) for i in range(6): color('yellow') forward(100) left(60) for i in range(7): c...
292ad196eaee7aab34dea95ac5fe622281b1a845
LJ1234com/Pandas-Study
/06-Function_Application.py
969
4.21875
4
import pandas as pd import numpy as np ''' pipe(): Table wise Function Application apply(): Row or Column Wise Function Application applymap(): Element wise Function Application on DataFrame map(): Element wise Function Application on Series ''' ############### Table-wise Function Application ####...
98d4a9997bac3ed19193bd018580635e2975bd9e
bkbhanu/mytrypy2
/functions.py
461
3.9375
4
def sqaure(n,a): return a**n x=1 a=1 n=2 while (x<=10): ## a = int(input("what is the number:")) ## n = int(input("What is the exponent:")) print(a) print(n) outFile=open('C:\Python34\programs\writefile2.txt','a') ## sq == square(n,a) ## print("returning",y) print("The resul...
930354b812871c2c41f004a5211293c36b8ac6f5
khinthandarkyaw98/Python_Practice
/ufunc_rounding_decimals.py
950
3.9375
4
# rounding decimals # There are primarily five ways of rounding off decimals in Numpy # truncation # fix # rounding # floor # ceil # Truncation # to integer closet to zero. Use the trunc() and fix() functions. # example # truncate elements of following array: import numpy as np arr = np.trunc([-...
f2985a94c8d343182b92d75ef3c97144f16be89e
emmet-gingles/Python-Grades
/grade.py
399
3.90625
4
input = raw_input("Enter score between 0 and 1: "); try: score = float(input); if score >= 0 and score <= 1: if score >= 0.9: print "A"; elif score >= 0.7: print "B"; elif score >= 0.5: print "C"; elif score >= 0.4: print "D"; ...
fba88279ead81d1846bf85db59c1162896808c92
dtingg/Fall2018-PY210A
/students/DanCornutt/session02/fizz_buzz.py
375
3.53125
4
def fizz_buzz(high_num = 100): lst = list(range(1, high_num + 1)) fizz = list(range(3,101,3)) buzz = list(range(5,101,5)) for f in fizz: lst[f-1] = 'Fizz' for b in buzz: if isinstance(lst[b-1], str): lst[b-1] = lst[b-1] + 'Buzz' else: lst[b-1] = 'Buzz...
7a5c55bba2b0e9e49fd4dbe4d634d36f6a0ac9a9
jll2269/python
/20210329/list5.py
157
3.65625
4
L = [1, 2, 3] def Add10(i): return i+10 for i in map(Add10, L): print("Item: {0}".format(i)) X = [1, 2, 3] Y = [2, 3, 4] print(list(map(pow, X, Y)))
80450571bba3d9bdaf71b65ab346bda55437efa6
Athena1004/python_na
/venv/Scripts/nana/set.py
930
3.59375
4
s = set() print(type(s)) print(s) s = {1,2,3,4} print(type(s)) print(s) print("=" * 20 ) s1 = { } print(type(s1)) print(s1) s = {"lala","456",1,2,3} print(s) if 1 in s: print("cool") else: print("bad") s = {4,5,6,"i","love","money"} for i in s: print(i , end = " ") print("=" * 20 ) s = {(4,5,6),("i","l...
5a0f25d200c96ddc6b2c8b336090f6cf0ccdb516
aaa-wen/Project-Euler
/Problem_7.py
280
3.671875
4
def prime(x): if (x == 1): return False i = 2 while i < x: if (x % i == 0): return False i = i+1 else: return True x = 2 count = 0 while count < 10001: print (x) if (prime(x) == True): x += 1 print (x) count += 1 print (count) else: x += 1 print (x)
2dde3b9130ee197923fa9232350b819b805a0435
rsmith-nl/misc
/splitdict.py
677
3.8125
4
# file: splitdict.py # vim:fileencoding=utf-8:fdm=marker:ft=python # # Copyright © 2018 R.F. Smith <rsmith@xs4all.nl>. # SPDX-License-Identifier: MIT # Created: 2018-12-04T00:08:57+0100 # Last modified: 2018-12-04T00:18:19+0100 def splitdict(words): """Split a string of whitespace delimited words or a list/tuple ...
3eaaf925c99e2436db9d03f4ed13513ec4c112d2
Pocom/Programming_Ex
/3_LongestSubstringWithoutRepeatingCharacters/t_1.py
697
3.5
4
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: str_list = list() ret_len = 0 for str in s: if str_list.count(str) != 0: # str exists in str_list print("列表中已有该元素: ", str) seq = str_list.index(str) ret_len = max(l...
09855cfbd462b2365ffdce3e99f4c034b9f85cfe
hopnguyen123/Lab3_1_MatMaHoc
/Lab3_1/Task3.1/1_ 10 largest prime number under 10 first Mersenne prime numbers.py
1,217
3.640625
4
from random import randrange, getrandbits def Check_SoNguyenTo(n, k=128): if n <= 1: return False if n <= 3: return True s = 0 r = n - 1 while r & 1 == 0: s += 1 r //= 2 for _ in range(k): a = randrange(2, n - 1) x = pow(a, r, n) if x != 1 and x != n ...
7337e1b5d21ef710901508369057c32e7147d11d
Dikaadityaoctaviana/Praktikum-metnum2
/lat gaus seidal.py
2,687
3.53125
4
# Iterasi Gauss Seidel # Definisikan Persamaan yang akan diselesaikan # Dalam bentuk dominan secara diagonal # Iterasi Gauss Seidel # Definisikan Persamaan yang akan diselesaikan # Dalam bentuk dominan secara diagonal f1 = lambda x,y,z: (-4+3*y-0*z)/4 f2 = lambda x,y,z: (40-2*x+5*z)/-4 f3 = lambda x,y,z: ...
22e31f5529bcd5644c9c5121965318fe1a9f6d54
Ashvineekhatri/Vidhymaan_Autonetics
/attendence.py
3,606
3.71875
4
from tkinter import * from tkinter import ttk class Student: def __init__(self,root): self.root=root self.root.title("Student Management System") self.root.geometry("1350x700+0+0") title = Label(self.root, text="Student Management System",bd=10,relief=GROOVE,font=("times new roman",...
7939fd860fadd8084fa5d5e2d970eb87fae85d8d
irisnunezlpsr/class-samples
/codetotest.py
181
3.984375
4
print("What is your favorite number?") number = (input()) while number != 14: print("Pick another number!") number = (input()) if number == 14: print("That's the best number!")
bd6f648911b803d558231afe82e5951091314bc1
dkoh12/gamma
/CtCI/python/bits.py
1,510
3.65625
4
# 5.1 def MinN(M, N, i, j): M = int(M, 2) N = int(N, 2) # print(M, bin(M), N, bin(N)) # print(i, j) count = i while M > 0: bit = M & 1 N = (bit << count) | N M = M >> 1 count += 1 # print("M", M, bin(M)) # print("N", N, bin(N)) return bin(N) # 5.6 def conversion(a, b): count = 0 num = a ^ b w...
589c2abe9d84cc15965bb55cc32862929d1c7f2f
alosaft/NatassjaBot
/graph.py
2,154
3.578125
4
class Transition: def __init__ (self, answer, condition, node_to_go): self.answer = answer self.condition = condition self.node_to_go = node_to_go pass class Node: def __init__ (self, question, transitions, actions): self.question = question self.transition...
97f3569d1328633e511b8866e21ab0e95c441940
SrikanthParsha14/test
/testpy/timezonecalc.py
236
3.515625
4
from datetime import datetime from datetime import timedelta date = datetime.utcnow() print "PC's Local Time is", datetime.now() print "CN Beijing Time is", date+timedelta(hours=8) print "US Pacific Time is", date+timedelta(hours=-8)
3f03207d052cc47b36c8e21d5d60132317ce73d1
terzeron/PythonTest
/asyncio/test03.py
565
3.59375
4
#!/usr/bin/env python import sys import asyncio async def my_coroutine(task_name, seconds_to_sleep=3): print("%s sleeping for %d seconds" % (task_name, seconds_to_sleep)) await asyncio.sleep(seconds_to_sleep) print("%s is finished" % (task_name)) async def main(): tasks = [ my_coroutine('ta...
ee515c5e8864a5a29494a03acb8503471ec2d922
avalool/Python-Code
/HospitalTemp.py
375
4.03125
4
"""program that prints out a health warning message if one of the patient temperatures is higher than 40 degrees Celsius""" #Temperatures: 36, 32, 45, 38 temperatures = ['36', '32', '45', '38'] for temperature in temperatures: if temperature == '45': print('Warning, possible COVID patient! Isolate immedia...
3a03368d5b16d37b6044ca4a356ff6f5374b4ec7
ZJocelyn/sy2.1-server
/server.py
2,496
3.65625
4
# coding:utf8 ''''创建服务器端程序,用来接收客户端传进的字符数据''' from socket import * #引入socket模块内的函数,创建一个套接口 from time import ctime #引入time模块内的ctime()函数,ctime()函数会显示当前日期与时间 def server(): #定义server端函数 HOST = '127.0.0.1' #指定服务器ip为本机ip地址 PORT = 65533 #指定监听端口为65533 ADDR ...
1290eb7cd1d5c6c4d1fca084dfc1c61165f2127c
saetar/pyEuler
/done/py/euler_046.py
1,009
3.875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Jesse Rubin - project Euler """ Goldbach's other conjecture Problem 46 It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×1^2 15 = 7 + 2×2^2 21 = 3 + 2×3^2 25 = 7 + 2×3^2 27 = 19 + 2×2^...
e2c7876bc034d166dda2491e4f35e8b6600af5ae
aramian-wasielak/python-snippets
/src/snippets/tree.py
1,005
3.75
4
import unittest class TreeNode: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right class TestTreeMethods(unittest.TestCase): @staticmethod def generate_tree(depth): root = node = TreeNode(1) for i in range(depth - 1)...
2b4a5b7fd6caa98a32b12fbc5e5eb020ea129661
alicesilva/P1-Python-Problemas
/palavras.py
518
3.765625
4
# coding: utf-8 # Aluna: Alice Fernandes Silva /UFCG, 2015.1, Programação 1 # Mais ocorrência caractere palavras = [] while True: palavra = raw_input() if palavra == "fim": break palavras.append(palavra) caractere = raw_input() N = int(raw_input()) lista1 = [] for i in range(len(palavras)): cont_acima = 0 fo...
0dbe0f1f164f3ebe136352fe8eaeb0292b313969
Madhav2108/udemy-python-as
/function/intro/swapfuc.py
139
4.09375
4
def swap(x, y): temp = x; x = y; y = temp; print(x) print(y) x = 2 y = 3 swap(x, y) print(x) print(y)
ee5ab229d06fb8ebc08af5950ccd67025608893e
Burymis/PY4E
/Exer_C3_3.py
651
3.59375
4
# Exercises, part 3 Conditional execution # https://www.py4e.com/html3/03-conditional # Exercis 3: def grade(score): try: score = float(score) if score > 1: user_grade = "Bad score!" elif score >= 0.9: user_grade = "A" elif score >= 0.8: user_...
d9c42239586aeb317254ec62f1d07d56e4e38e46
leealessandrini/bakingcake
/bakingcake/stocks.py
1,314
3.515625
4
""" This module will house all stock related functions. """ import datetime import pandas as pd from iexfinance.stocks import get_historical_data def get_price_action( ticker_list, start=datetime.datetime.today() - datetime.timedelta(days=31), end=datetime.datetime.today() - datetime.timedelta...
5fdef4f708a876c33329509df5ff3626ffd8c903
uthambathoju/30days_leetcode_april_challenge
/group_anagrams.py
2,818
3.5625
4
import collections class Solution: def groupAnagrams(self, strs): hash_table = {} temp_anagrams = [] ang_list = [] #print(strs) """ if all('' == space for space in strs): ang_list.append(strs) return ang_list str_...
53e2a0a7eed63ff673edd590c319b189474dcbcc
windard/leeeeee
/925.long-pressed-name.py
2,532
3.640625
4
# coding=utf-8 # # @lc app=leetcode id=925 lang=python # # [925] Long Pressed Name # # https://leetcode.com/problems/long-pressed-name/description/ # # algorithms # Easy (44.38%) # Likes: 266 # Dislikes: 34 # Total Accepted: 19.9K # Total Submissions: 44.8K # Testcase Example: '"alex"\n"aaleex"' # # Your friend ...
0ab4a7daca04a783f66ed7d6ec066f8e080b092c
sudarsan005/Yelp_Top_Businesses
/yelp_ranking_v2.py
6,438
3.890625
4
""" This code queries data by using the Search API to query for businesses by a search term,location and category. The data is then ranked using True Bayesian Estimate method and Top 50 from the result in the search criteria is printed in the console. This Code also generates two files " Top50_Ranked_Data_"Date/Time" ...
73df1c31a5ad0c35c90dfc4fea4dffe14cedf4fe
Infinidrix/competitive-programming
/Take 2 Week 1/isPalindrome.py
745
3.84375
4
# https://leetcode.com/problems/palindrome-linked-list # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome(self, head: ListNode) -> bool: if head == None: return True ...
63eeb95dbc9eafa087ea55bfacd8c1a983ae1707
austinsonger/CodingChallenges
/Hackerrank/_Contests/Project_Euler/Python/pe074.py
1,454
3.78125
4
''' Digit factorial chains Problem 74 The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145: 1! + 4! + 5! = 1 + 24 + 120 = 145 Perhaps less well known is 169, in that it produces the longest chain of numbers that link back to 169; it turns out that there are only t...
c1807d4cdcdee1629e6278298d28509df5ad2908
mgclarkson/lqsninohtyp
/test/drop_demo.py
3,640
3.5625
4
======================================================= ##################### ### Original Python2 File: ### drop.py2 ##################### #!/usr/bin/env python2.py for i in range(10): print i, print sql: CREATE TABLE Customers ( name VARCHAR(100) , last VARCHAR(15), phone int...
9861904200baadaa299243a943434ee5ab3d1416
YektaAkhalili/Hello-World
/Hello-World.py
204
4.3125
4
#just a silly code to put on Github for starters! #written May 16th, 2019 n = input("Hey there, What's your name?") print("I wanted to say Hello, World! But, you're not World! You're {}!".format(n))
d4e8a0ca8fea05edbb1808ab6b16632c79e783a3
DylanFouche/RaspberryPi
/Prac1/main.py
1,799
3.546875
4
#!/usr/bin/python3 """ Names: Dylan Fouche Student Number: FCHDYL001 Prac: Prac 1 Date: 22/07/2019 """ # import Relevant Librares import RPi.GPIO as GPIO from time import sleep #integer to store counter value count = 0 #bools to store led state bit_0 = 0 bit_1 = 0 bit_2 = 0 def init_GPIO(): #config GPIO GPIO...
dba0d69ba88bac69a74bea766bf12be9beaa7a4b
michaelstrefeler/100daysofcode-with-python-course
/days/37-39-csv-data-analsys/alcohol_consumption_analysis/analyse.py
1,482
3.53125
4
from os import path from csv import DictReader from collections import namedtuple from typing import List data = [] Record = namedtuple( 'Record', 'country, beer_servings, spirit_servings, wine_servings,' 'total_litres_of_pure_alcohol') def get_data(): base_folder = path.dirname(__file__) filename =...
0c4c47abc6e5c8bd439659850c09ae659b11695d
Rapak/hello-world
/lesson2-1/Task3.py
159
3.75
4
a = (1,2,3,3,5,5,5,1,1) b = (1, 'a',2,3,2,'a') uniq_el = set(a) rez = list(uniq_el) print(rez) uniq_el2 = set(b) rez2 = list(uniq_el2) print(rez2)
c98b7e874549bb11196f36310dba0ce0659c4fc5
digipodium/string-and-string-functions-AdityaKD88
/string_in_uppercase.py
94
3.765625
4
#6. Convert the string "How are you?" in uppercase msg = "How are you?" print(msg.upper())
4288d6a1782a5a840fc39ec588202c9be25feb95
jaycamp23/tlg_learning_python
/elif.py
277
4.09375
4
age = 31 age = float(input('how old are you:')) if age >= 35: print('you are old enough to be a senator or the president') elif age >= 30: print('you are old enough to be a senator or president') else: print('your not old enough') print('have a nice day')
5b3c25fd4cc24ff16fd6d3839e23b241a5a70d23
zazaraisovna/AdventOfCode2020
/Advent Of Code - Day 2.py
1,347
3.609375
4
#!/usr/bin/env python # coding: utf-8 passwords = input().split() a = [] for i in range(0, len(passwords)-2, 3): new_elem = passwords[i], passwords[i + 1], passwords[i + 2] a.append(new_elem) ## first ## берём каждый элемент (подсписок) списка b ## берём первый элемент (подсписка) и достаём их элемент...
df48bee32e5094798e0e19e258636f0b9f062c8a
Park-jeong-seop/codility
/codility_lesson_3-1.py
234
3.765625
4
""" X is start from Y is destination D is distance to move X, Y, D are Int X = 10, Y = 85, D = 30 res = 3 """ def solution(X, Y, D): tmp = (Y-X) % D res = int((Y-X) / D) if tmp != 0: return res + 1 return res
cdebb5a25667e67ee52919b43475606ff00604e5
Davisanity/backpropagation
/neural.py
5,052
3.5625
4
import random import math #implement 2D empty list # list=[] # for i in range(10): # new=[] # for i in range(10): # new.append(None) # list.append(new) class Neural: def __init__(self,input,output,i,layerNum_h,h,o): self.input = input self.hidden= [[None for _ in range(h)] for _ in ra...
e42e95a442fb8e235c15926b8cedb9daee774840
nisn/exercises
/ex38.py
791
3.796875
4
# min-max hackerearth def maior_menor(): global menor global maior global num_numeros global numeros for i in range(num_numeros): if i == 0: menor = int(numeros[i]) maior = int(numeros[i]) else: if int(numeros[i]) < menor: menor = i...
a550cad8c05a571d579673395558ca2d768abf96
erinnlebaron3/python
/ImpemetRangeSlice.py
3,961
4.625
5
# ranges and the word slices are used many times interchangeably # advanced ranges and advanced slices inside of Python lists. # start with development and then it's going to go and it's going to go all the way up to the very last element. # It's not going to include it because remember with ranges and slices it is...
b55abc80adaf5574c10f990b4e930d381fc5751f
yadmyaso/logical_shem
/summato.py
228
3.75
4
def xor(a,b): if (a==1 and b==0) or (a==0 and b==1): return True else: return False a,b,p=[int(i) for i in input().split()] k=xor(a,b) pr=xor(k,p) print(pr) x1=a and b x2= k and p d=x1 or x2 print(d)
f21d0efea87ed5c184eca149f4698d88c0bcfa3a
akashgupta910/python-practice-code
/oops_5.py
411
3.75
4
# SPEED() AND OVERRIDING class Junior: junior_class1 = ["Akash","Raj"] def __init__(self): self.senior = ["Golu"] self.junior = ["Ranveer_singh"] class Senior(Junior): senior_junior = ["Kashi","Dil Mohammad"] def __init__(self): super().__init__() self.senior = ["Golu...
baedb7753be411e564b13cf3cf100889ac30a626
reo11/AtCoder
/atcoder/abc/abc101-200/ABC141/b.py
225
3.734375
4
s = list(str(input())) l1 = ["R", "U", "D"] l2 = ["L", "U", "D"] ans = "Yes" for i, c in enumerate(s): if i % 2 == 0 and c not in l1: ans = "No" elif i % 2 == 1 and c not in l2: ans = "No" print(ans)
f4a3bcbc4990d1a510c29e17c0a31368427f91d2
salvadorhm/poo
/semana_2/programa_14.py
321
3.65625
4
class Cadenas: cadena_1 = "Hola" cadena_2 = 'Hola' cadena_3 = """variable cadena de varias lineas""" cadena_4 = '''Variable cadena de varias lineas''' def __init__(self): pass objeto = Cadenas() print(objeto.cadena_1) print(objeto.cadena_2) print(objeto.cadena_3) print(objeto.cadena_4...
caaf9aece2ad385822a941ed975c8e45abe4bbee
windtux/calculadora
/calculadora-sencilla.py
532
3.828125
4
def suma(): nume1 = float(input('ingrese un numero (no necesariamente deben ser enteros) ')) nume2 = float(input('ingrese otro numero (no necesariamente deben ser enteros) ')) resultado = nume1 + nume2 print ('el resultado de ambos numeros es ',resultado) pregunta = (input('desea continuar usando la...
5ddadacffad4ef04ae3d1d65ff063b497483f70e
matheusclementeg/gerador-de-senhas
/GeradorDeSenhas/GeradorComInterface.py
2,152
3.59375
4
# -*- coding: utf-8 -*- """tkinter Exemplo de utilização do Tkinter. OBS: Não está sendo utilizada orientação a objeto (classes). """ from tkinter import * import random def gerar_senha(): """Gerar senha. Função responsável por gerar uma senha aleatória com base na escolha que o usuário fi...
dd814e77957947b9846dee8ee782702a8760b3b3
raygolden/leetcode-python
/src/powersetWDuplicates.py
763
3.75
4
#!/usr/bin/env python """ powerset with duplicates """ def powersetWDup(s): s.sort() results = [[]] cur_dup = None for elm in s: i = 0 if elm != cur_dup: # not a duplicate cur_dup = elm l = len(results) pre = [] while i < l:...
df06c0d7cd9891070978efaffa54092fc7d8f82a
RAMESHMAXX/python_refresher
/05_list_tuples_sets_range_code/code.py
799
4.28125
4
l = ["Ramesh", "prince", "maxx"] t = ("Ramesh", "prince", "maxx") s = {"Ramesh", "prince", "maxx"} # Access individual items in lists and tuples using the index. print(l[0]) print(t[0]) # print(s[0]) set is unordered so cannot accessed # Modyfing l[0] = "Smith" #list are mutabe means changable so updated # t[0] = ...
b1bf9a87e090aac543f172bddd83f84e47f2103d
hector-han/leetcode
/dp/prob0673.py
2,228
3.53125
4
""" 最长上升子序列,给定一个未排序的整数数组,找到最长递增子序列的个数。 medium 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n2) 。 进阶: 你能将算法的时间复杂度降低到 O(n log n) 吗? 1、递归,dp[i] 表示以nums[i]结尾的最长上升子序列。则dp[i+1] = max(dp[j], where j<i+1, and nums[j] < nums[i+1]) 2、分成牌堆。如...
505bff60e81f6c0d51ef19e570c5760c9bcb8fd1
tyriem/PY
/Intro To Python/60 - DateTime - Convert.py
1,687
4.6875
5
### AUTHOR: TMRM ### PROJECT: INTRO TO PYTHON - Convert Seconds / Minutes ### VER: 1.0 ### DATE: 06-25-2020 ############################## ### DATE / TIME - CONVERT ### ############################## ### OBJECTIVE ### # Convert the below code to yield minutes per week, day, hour ### OBJECTIVE ### """ #Python's p...
b8b48fc2b2ac8008b7a31085b30997b88db55590
DylanB5402/DrivetrainSim
/src/NerdyMath.py
226
3.609375
4
import math def distance_formula(x1, y1, x2, y2): return math.sqrt((x1-x2)**2 + (y1-y2)**2) def get_greater_value(a, b): if a > b: return a elif a < b: return b elif a == b: return a
df263a7eda99e2923c356290eb8e8e0d3773603b
Te-Stack/Texas-em-Poker-Card-Game
/Tests/test_player.py
1,276
3.625
4
import unittest from unittest.mock import MagicMock from Poker.card import Card from Poker.hand import Hand from Poker.player import Player class PlayerTest(unittest.TestCase): def test_stores_name_and_hand(self): hand = Hand() player = Player(name = "Boris", hand = hand) self.assertEq...
7ed783248e11baa56f173bc7eecc099be40a7625
kdef/example
/str_perm/str_perm.py
377
3.96875
4
import sys # print all permutations of an input string def permute(str_in, str_out): if len(str_in) == 0: print str_out else: for i in range(len(str_in)): tmp = str_out + str_in[i] rest = str_in[:i] + str_in[i+1:] permute(rest, tmp) try: test = sys.argv[...
bb33f40e75ef8e824cf86e37cedbfb37de70470c
medesiv/ds_algo
/matrix/search_2d_matrix.py
1,800
3.796875
4
""" Search 2D matrix: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. """ class Solution: def searchMa...
e0d45c43b11c9984153b30a29220dc4ad37fe683
Tom83B/ProjectEuler
/prob33/prob33.py
637
3.703125
4
from fractions import Fraction pairs = [ (a,b) for a in range(1,10) for b in range(1,10) if a<b ] special = [] for c in range(1,10): for a,b in pairs: if Fraction(int(str(c)+str(a)),int(str(c)+str(b)))==Fraction(a,b): special.append(Fraction(a,b)) if Fraction(int(str(a)+str(c)),int(str(c)+str(b)))==Fraction(a...
b431200f74464bd11675eb6e52fd49a238680e87
Benjamin-Marks/reversi
/board.py
8,100
3.953125
4
"""Represents the Board of a Reversi game.""" import json import logging class Square(object): """Enum to differentiate between teams. Note: We don't extend from enum to allow for easy serialization. """ white = 0 black = 1 blank = 2 class Board(object): """Represents the board of a reversi game.""" ...
0da3f8a2808dfed048ad653b059cac1e94673f38
MoonAuSosiGi/Coding-Test
/Python_Algorithm_Interview/Sparta_algorithm/week_3/06_stack.py
1,131
4.0625
4
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.head = None def push(self, value): if self.is_empty(): self.head = Node(value) else: new_node = Node(value) ...
bce7bedcf84457b53d50a6fa70c39819dfbb9550
NguyenVanDuc2022/Self-study
/101 Tasks/Task 083.py
375
4.15625
4
""" Question 083 - Level 03 By using list comprehension, please write a program to print the list after removing delete numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155]. Hints: Use list comprehension to delete a bunch of element from a list. --- Nguyen Van Duc --- """ li = [12, 24, 35, 70, 88, 120, 15...
9c6fdb5cb664b9113903f092e6b53f651e1e1f14
ssulav/interview-questions
/leetcode/5_longest-palindromic-substring.py
1,040
3.96875
4
""" https://leetcode.com/problems/longest-palindromic-substring/ Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. """ import timeit class mySolution: def longestPalindrome(self, s: str) -> str: print(s) ...
d32b855ea3eea0f87ccaccf4fa022c5e7046ff30
NilsBergmann/ProjectEuler
/src/Python/Tasks/009.py
577
4.1875
4
""" Project Euler Problem 9 ======================= A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ""...
d7134ec9563951eb5cd81f3dfe6a792e991b2524
henrypj/codefights
/Intro/02-EdgeOfTheOcean/adjacentElementsProduct.py
1,022
4.40625
4
#!/bin/python3 import sys """ # Description # # Given an array of integers, find the pair of adjacent elements that has the # largest product and return that product. # # Example: # # For inputArray = [3, 6, -2, -5, 7, 3], the output should be # adjacentElementsProduct(inputArray) = 21. # # 7 and 3 produce the large...
1ffa55b423f202267b53a0eea7da44434a4185b0
nuptaxin/pythonStudy
/d_advanced_features/b_iteration.py
479
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- d={'a':1,'b':2,'c':3} for key in d: print('key:',key) for value in d.values(): print('value:',value) for k,v in d.items(): print('key:',k,',value:',v) #迭代字符串 for ch in 'ABC': print(ch) #判断是否为可迭代对象 from collections import Iterable print...
6fbcf3d126aa31a4548292a16ad9e32926d76cfd
LabosFisicaUBA/Dynamica_Systems
/Capitulo_02/Program_02d.py
279
3.546875
4
# Program 02d : Power series solution of a second order ODE. # See Example 8. from sympy import dsolve, Function, pprint from sympy.abc import t x = Function('x') ODE2 = x(t).diff(t,2) + 2*t**2*x(t).diff(t) + x(t) pprint(dsolve(ODE2, hint='2nd_power_series_ordinary', n=6))
f0c24080bc0458d63dfdb5ba19453431bf8386b3
raymondmar61/pythoncodecademy
/studentbecomestheteacher.py
1,777
4
4
from statistics import mean lloyd = {"name": "Lloyd", "homework":[90.0, 97.0, 75.0, 92.0], "quizzes":[88.0, 40.0, 94.0], "tests":[75.0, 90.0]} alice = {"name": "Alice", "homework":[100.0, 92.0, 98.0, 100.0], "quizzes":[82.0, 83.0, 91.0], "tests":[89.0, 97.0]} tyler = {"name": "Tyler", "homework":[0.0, 87.0, 75.0, 22.0...
df01632f73d985f1901c3d4c4463fe7888331c76
vovamedentsiy/Deep-Learning
/medentsiy_assignment1/code/train_mlp_numpy.py
6,450
3.875
4
""" This module implements training and evaluation of a multi-layer perceptron in NumPy. You should fill in code into indicated sections. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import numpy as np import os from mlp_numpy import M...
6bc409697ccf2c17b0d4b2cdc0f2aad9451bc8ee
liuyongchen521/DataStructuresStudy
/.vscode/刷题学习/迭代器和生成器.py
5,954
3.6875
4
# 这里有个关于生成器的创建问题面试官有考: # 问: 将列表生成式中[]改成() 之后数据结构是否改变? # 答案:是,从列表变为生成器 # >>> L = [x*x for x in range(10)] # >>> L # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] # >>> g = (x*x for x in range(10)) # >>> g # at 0x0000028F8B774200> # 通过列表生成式,可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的 # 。而且,创建一个包含百万元素的列表,不仅是占用很大的内存空间 # 如:我们只需要访问前面的几...
34e0e5bf9739821f5339da3925cbce99a7da7846
KIDJourney/algorithm
/leetcode/algorithm/Pascal's Triangle II.py
676
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Position: E:\Program\LeetCoder_Python\algorithm\Pascal's Triangle II.py # @Author: KIDJourney # @Email: kingdeadfish@qq.com # @Date: 2015-03-16 class Solution: # @return a list of integers def getRow(self, rowIndex): anslist = [] for i...
f5d8e8e219d3b9e28b4051e4b82ceb7560161cef
AlanAS3/Curso-de-Python-Exercicios
/Exercícios/Mundo 2/Exercícios Normais/ex039.py
480
4.09375
4
from datetime import date print('==== Alistamento Militar ====') Anas = int(input('Informe a seu ano de nascimento: ')) Aatual = int(date.today().year) idade = Aatual - Anas if idade == 18: print('É hora de fazer o Alistamento Militar!') elif idade > 18: print('Já passou da hora de se Alistar!!') print(f'Já...