blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b98469045d429299e2e553b57f37fb19f6e9f0b4
luyihsien/leetcodepy
/diary/0912.py
117
3.703125
4
''' res=[1] for i in res: res.append(i) print(res) ''' n=2 for i in range(n): n=n+1 print(n) print(n)
4bf9ca59084b40af7802371b4fc97a94a391aed6
SukiKim/Bit_Python
/quiz02_2.py
116
3.546875
4
for i in range (1,10): print(i, "단") for j in range(1,10): print(i, "X", j, "=", i*j) print()
84df40a53fd35155dd43d8a9b8023e7262549721
kiir07/test_python
/week_2/w2_Untitled-3_сумма_квадратов=.py
371
3.796875
4
# По данному натуральному n вычислите сумму 1²+2²+3²+...+n². # Формат ввода # Вводится натуральное число. # Формат вывода # Выведите ответ на задачу. n = int(input()) sumSquare = 0 i = 1 while n >= i: sumSquare = sumSquare + i * i i += 1 print(sumSquare)
be5ff191df24bea176517347660776fd80258f91
mirupandey/MyCart
/db_creation.py
4,274
3.53125
4
from sqlalchemy import Table, Column, Integer, DECIMAL, String, ForeignKey from sqlalchemy.dialects import mysql def create_tables_and_insert_dummy_data(meta, engine) -> None: """ A method to create database tables and insert dummy datas :return: None """ admin_login = Table( 'admin_lo...
cb50133589e16e3979f4636e5ce51640ee0fb8ab
onp/ProjectEuler-py
/Problem004.py
708
3.796875
4
# Project Euler Problem #4 # Largest Palindrome Product ''' 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. ''' #solution assumes a is within 200 of b...
3934458f58878abdef6f3e51652dfbcb2ba951b5
henryh28/coding_practice
/data_structures/valid_parenthesis.py
1,142
3.609375
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] length = len(s) lookup = {')': '(', ']': '[', '}': '{'} # Quick check for odd lengthed string, if odd length cannot close all open chars ...
66243a3b3d9b4483d06a7c16b7a85e302cc574d9
bneb/advent-of-code-2020
/day18/day18.2.py
2,210
3.515625
4
'''Day 18 of Advent of Code 2020 We're taking mathy strings with valid characters in [ \d\+*()] and then evaluating them based on different rules than normal arithmetic. For 18.2, + has higher precedence than * ''' from argparse import ArgumentParser from pathlib import PurePath import re def main(file_path): w...
6d445a4509a3ddada2177cb93e405cf1cb112145
ravi4all/AdvPython_JuneReg_19
/01-OOPS/Inheritance/03-Multiple.py
1,311
3.515625
4
class CarV1(): def __init__(self): self.brand = "Tata" self.sedan = True self.wheels = 'Simple' self.speed = 200 self.avg = 20 self.hybrid = False def showDetails(self): print("Welcome to {}".format(self.brand)) print("Features are : ...
af57859cc43f72c0ba5feded2a6fcd9c9048c7b5
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4271/codes/1635_2703.py
107
3.75
4
idade = int(input("digite a idade: ")) if (idade >= 18): x = "eleitor" else: x = "nao_eleitor" print(x)
62dc14b8e840f9806a0432cefeeabe43ef59ea3f
gateway17/holbertonschool-higher_level_programming
/0x03-python-data_structures/10-divisible_by_2.py
563
4.1875
4
#!/usr/bin/python3 # Write a function that finds all multiples of 2 in a list. # Prototype: def divisible_by_2(my_list=[]): # Return a new list with True or False, # depending on whether the integer at the same position # in the original list is a multiple of 2. # The new list should have the same size ...
dd47e98a4834251183bfeb39b257c034e3e02ffb
Wolfant/EspePython
/Parte1/PackUnpack/packunpack2.py
461
3.859375
4
# funcion que imprime exactamente 3 argumentos def fun1(a, b, c): print(a, b, c) # PACKING. # se crea un tupla *args. # debe tener mas de dos argumentos # los dos deben ser str def fun2(*args): # Convierte la tupa en lista.. porque? args = list(args) # Modifico los argumentos args[0] = 'P...
a36bad0763408fe64f1e783f20109a73b6c78aa7
dshakoory/UCI_Homework_Repo
/Homework3/Python_Challenge/PyBank/main.py
2,212
3.640625
4
#importing the libraries import os import csv #creating the budget object based on the existing csv file budget = os.path.join("budget_data.csv") budgetanalysis = os.path.join("budgetanalysis.txt") #variable definition date = [] profandloss = [] change = 0 monthscount = 0 #Total number of months pl = 0 #profit/loss...
8a05d83bea2f084dad3950d61ae1744765b8f340
NEONITIN3/python-work
/min max list.py
226
3.546875
4
#seperate the list value from max 45 and min 45 l=[12,34,55,67,89,34,40,44,62,79,100,1,3,59] maxlist=[] minlist=[] [ maxlist.append(x) if x>=45 else minlist.append(x) for x in l ] print (minlist) print(maxlist)
8fae7466bbcd7c533b0f0ff8e4c9c25589b4c85e
aprilyichenwang/small_projects
/coding_exercise/reverse_string.py
159
4
4
def reverseString(s): """ :type s: str :rtype: str """ return "".join([s[i] for i in range(len(s)-1, -1,-1)]) print reverseString('hello')
210a662b23da9bf342f506b65ca32c216932b5cf
21lucasmessias/CursoEmVideo-Python
/ex080.py
566
3.953125
4
lista = list() for item in range(0, 5): valor = int(input('Digite um valor: ')) if item == 0: lista.append(valor) print('O item foi adicionado no final da lista.') else: posicao = 0 for i in range(0, len(lista)): if valor > lista[i]: posi...
1ef0a76aa46ccda4c7ada34dacb77a2760be825e
xp11/test
/partial锁定.py
133
3.546875
4
from functools import partial def add(x,y): return x+y print(add(2,3)) print(partial(add,2,5)()) add=partial(add,2) print(add(3))
78cd091cab598df78c174ecc2119e53669ada5f6
1798317135/note
/python/python数据类型/迭代器.py
3,087
3.53125
4
# 1.0 迭代是访问集合元素的一种方式 # # 2.0 迭代可以按照某种顺序来依此访问可迭代对象 # # 3.0 可迭代对象可以被迭代 ,但是可以被迭代的不一定的是可迭代对象 # # ####################### 验证是否是可迭代对象的方法 ######################## # # #********可迭代对象 一定可以使用 for in 进行遍历****** num = "abc" boo = True #这个就不能遍历 所有就不是可迭代对象 arr = [1,2,3,54,"aa"] tup = (1,2,3,4,5) obj = {1,2,...
d50f8785fcd85cb567193f397fe9b56f6f5ebf57
wh2per/Programmers-Algorithm
/Programmers/Lv2/Lv2_프린터.py
562
3.53125
4
def solution(priorities, location): answer = 0 temp = max(priorities) while True: top = priorities.pop(0) if top == temp: # ?꾨┛??媛€?? answer += 1 if location == 0: # 李얠븯?? break else: location -= 1 temp = max...
8d16071641d6be7cb794be5e30367862ac8bde96
Eckertc/Python-for-fun
/mapIt.py
402
3.546875
4
# mapIt.py - Launches a map in the browser using an address from the command line or clipboard import sys import webbrowser import pyperclip #from webbrowser import pyperclip if len(sys.argv) > 1: #grab address from command line address = ' '.join(sys.argv[1:]) else: #grab address from keeb address = p...
03caf4f8de8d98e88f4cbba6066b43ebba2f4963
chloegom/brainboard
/examples/plot_visual_interpretability.py
22,412
4.25
4
# -*- coding: utf-8 -*- """ Inspect trained networks ======================== Credit: A Grigis Various techniques are available for understanding how neural networks work, what do they learn and why they work in a given manner. Specifically, we will try out various visualization techniques to understand them more dee...
f7ef9197ad62f6288b67c89b319f7afb95b9a62d
jeremy763/LeetCode
/1.two_sum.py
719
3.59375
4
def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in range(0, len(nums)-1): for j in range(i+1, len(nums)): if nums[i] + nums[j] == target: return [i, j] def two_sum(nums, target): for i in range(0, len(nu...
72f0210ed190e92554939975a71e8389437524f9
webnard/edgemont-game
/coin.py
757
3.609375
4
import pygame import random class Coin(pygame.sprite.Sprite): image = None rect = None start_y = None shift_y = 8 movement = 1 up = None def __init__(self): random.choice([True,False]) pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load('coin.png').convert_alpha() self.rec...
e65eb04e26da970db2fe0dfa9236b5c591c26ce6
Pooja1301/ds_and_algo_with_python
/pascals_triangle.py
410
3.5
4
class Solution: # @param A : integer # @return a list of list of integers def solve(A): mat=[[0 for j in range(i+1)] for i in range(A)] for i in range(A): for j in range(i+1): if j == 0 or j == i: mat[i][j] = 1 else: ...
863bfa10fd84855e89971bc61cb594b16aa9cd7e
nicolasmonteiro/Exercicio_Colaboracao_Etapa1
/2-Tupla_Q2.py
1,305
3.84375
4
''' Mathias está ansioso para saber qual vai ser o game do ano no evento The Game Awards, esse evento é considerado o 'Oscar do videogame'. Os indicados são : The Last of Us Part 2, Animal Crossing:New Horizon,Final Fantasy 7 Remake,Ghost of Tsushima e Hades. Para se preparar para o evento decidiu jogar todos os jog...
98fd7277f85fe9b9bd4e1ac98bd07f4acf0a7302
Jocomol/random_python_games
/Gentechlabor/Labor.py
1,679
3.640625
4
from Pflanse import Pflanze from random import randint import time startend = False rdy = False farben = ["grün", "gelb", "schwarz", "rot"] while startend != True: print ("Hallo das hier ist der Umlitamo Blumenmacher") action = input("Willst du 10 Zufällige oder 1 Benutzerdefinierte Pflanzen erstellen? <b> o...
6eab133a42dc5524b250673ae45a2ae2379f7191
GBaileyMcEwan/python
/src/input.py
351
4.1875
4
#!/usr/bin/python3 name = input("What is your name? ") age = int(input("What is your age? ")) print(f"Your name was {name} and your age was {age}.") print(f"Your age divided by 2 is: {age / 2}") if name == "Gorgs": print("You're such a nerd") elif name == "Diego": print("Would you like some Ciabatta?") else: ...
66e4978f0be6f7d19f7cdea2e36f02e432dbbdc3
zschuster/Udemy_AdvancedPython
/magic_functions/examples.py
347
3.9375
4
# create dictionary class that inherits from dict class class Dictionary(dict): def __add__(self, other): self.update(other) return Dictionary(self) if __name__ == '__main__': dict_1 = Dictionary({'name': 'Zach'}) dict_2 = Dictionary({'hobby':'golf'}) print(dict_1) print(dict_2) print('\n dict_1 + dict_2...
bc9cbf24656fbf672d61fcbc64d3b832fd072cf9
MrBiggles87/Python
/Textincommands.py
218
4.09375
4
phy=input("Enter Physics Number:") chem=input("Enter Chemistry Number:") math=input("Enter Maths Number:") total=int(phy)+int(chem)+int(math) per=total*100/850 print("The Result is:",total) print("The Percent is:",per)
9d509f3637a6a66b22324e0c4ea7d957dbff5313
junsoyoung/20170904_python_ex
/20180114_rep.py
488
3.703125
4
import re p_Re = re.compile('[a-z]+') m_Re = p_Re.match("python") if m_Re: print(m_Re) print( m_Re.group()) else: print("not match") s_Re = p_Re.search("3 python") if s_Re: print(s_Re) print(s_Re.group()) else: print("not search") ret_Re = p_Re.findall("life is too short") print(ret_Re) re...
fb7979ec54a3a4c09af9d1ca9dbec95fedecfed2
TGlove/AlgorithmLearning
/Algorithm training/test.py
824
3.71875
4
#-*- coding: UTF-8 -*- import json # x,lo=( x for x in raw_input().split(' ')) # print x,lo # a,b=0,1 # while a<1000: # a,b=b,a+b # print(a,b) # def a(): # a=1 # def b(x): # return x*6 # # return b(a) # print(a()) # str1,a = (x for x in raw_input().split(' ')) # str1 = ...
a66884e2c3cb289ce78d632d092737cdc82643c5
jasperthegeo/Python_1
/PyPoll/main.py
1,540
3.6875
4
import os import csv vote_dict ={} votes_per_candidate={} csvpath = ("Resources\election_data.csv") with open (csvpath, 'r', encoding='utf-8') as csvfile: csvreader = csv.reader(csvfile) next (csvreader) for row in csvreader: vote_dict[int(row[0])]=row[2] votes_cast = len(vote_dict) #num...
3d3d407cac6198fc717efdfdc54aa116da300156
tech-learner123/leetcode_python
/380-medium.py
1,846
3.9375
4
""" The idea of GetRandom is to choose a random index and then to retrieve an element with that index. There is no indexes in hashmap, and hence to get true random value, one has first to convert hashmap keys in a list, that would take linear time. The solution here is to build a list of keys aside and to use this lis...
a1f066f21cef92707f02c1a351990611e4f8354c
harababurel/homework
/sem1/fop/lab10/util/sorter.py
2,410
3.78125
4
from random import randint def sorter(xs, compare): """ Method takes a list xs and returns its sorted permutation, According to the relation given by the comparison function. Algorithm: patience sorting. Runtime complexity: O(n^2) with current implementation O(n log n) wit...
5973574b893e1bd19ec8467a99aa49a8b9e1a398
D1egoS4nchez/Ejercicios
/Ejercicios/ejercicio75.py
255
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Definimos una lista vacia lista = [] #disponemos de un cliclo de 5 vueltas for x in range(1,5+1): valor = int(input("Ingrese el valor {} entero: ".format(x))) lista.append(valor) print(lista)
462b328cf8489ea2f3413fc2e790ee6d9d18af23
AlphaWolf384/pythonlearning
/Game/Dice Simulator.py
424
3.734375
4
from random import randint print("Hello World!", "Welcome to Dice Simulator") last_number = 0 while True: user_input = raw_input('Roll? Y|N: ') random_number = randint(0,5) + 1 if user_input == 'Y' or user_input == 'y': print print random_number ...
fca1c184c8a536d6dff224e4ca315bc5afa72c6b
mlaizure/holbertonschool-higher_level_programming
/0x0B-python-input_output/100-append_after.py
617
3.984375
4
#!/usr/bin/python3 """Module with function that inserts a line of text to a file, after each line containing a specific string""" def append_after(filename="", search_string="", new_string=""): """inserts a line of text to a file, after each line containing a specific string""" with open(filename, encodin...
e06fbb47355cfe324cc0dc0ebf7da70e1f5407e4
noooorfatima/mouse-in-a-maze-game
/FindTheCheese.py
1,272
3.90625
4
""" The main algorithm for the mouse in the maze should be written in this file """ # make Python look in the right place for logic.py import sys sys.path.append('/home/courses/python') from logic import * from Graphics import moveForward, turnLeft, turnRight, lookAhead, lookLeft, lookRight, eatCheese, mazeDebugOn, m...
587e45ff300f74ab8a2e3e1a6ffd22134576f209
Taoge123/OptimizedLeetcode
/LeetcodeNew/python2/LC_1061.py
717
3.578125
4
class UnionFind: def __init__(self, n): self.parent = [i for i in range(n)] def find(self, i): if i == self.parent[i]: return self.parent[i] return self.find(self.parent[i]) def union(self, i, j): x = self.find(i) y = self.find(j) if x < y: ...
a8d0d2273b5f8eef6051735e3cfbfc00634a339b
weikent/Python
/python/pythonFirstGame/Theurgy.py
4,766
3.859375
4
#-*- coding: utf-8 -*- class Attack(object): """ """ def __init__(self, user): """ Arguments: - `user`: """ self._user = user self._attackSurface = "one" self._name = "Attack" def use(self, enemy): """ Arguments: - `se...
82c5ea33b1930cc6a72736d6e8a438930224fd18
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_155/3758.py
1,317
3.5
4
import sys def start_standing_ovation(shyness_levels): count = 0 no_of_people_standing = 0 for i in range(0, len(shyness_levels)): if shyness_levels[i] != 0: if no_of_people_standing < i: # you need to add frnds here. count += i - no_of_people_standing ...
74155c2f4d20e019ef5e17b238aac726b4fb1142
blestem/CURSOR_Martian-Manhunter_HW-
/hw_3_oop_practice/house_sale.py
2,930
3.9375
4
from abc import ABC, abstractmethod import random class Person(ABC): def __init__(self, name: str, age: int, money: (int, float), house: list = []): self.name = name self.age = age self.available_money = money self.own_home = house @abstractmethod def info(self): r...
a14109bf2f33b65d3947574b27bc37c52a9bcdc5
dzhonapp/python_programs
/Basics/areasRectangle.py
436
4.3125
4
'''2. Areas of Rectangles The area of a rectangle is the rectangle’s length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.''' length = float(input('What is the lenght of rectange...
706d1f91e8368a8372f63d2c130a5a266bc4489f
saleed/LeetCode
/549.py
1,134
3.671875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def longestConsecutive(self, root): """ :type root: TreeNode :rtype:...
65ccd6de52e9795cfeafb56abe28b9a8fd6bd552
Wohker/AprendaPython
/Compara.py
850
4
4
#Compra.py # Autor: Daniel Isai Saldaña Rodríguez #Fecha de creación: 25/09/2019 numero1=input('Numero 1:”) numero2=input('Numero 2:”) Salida='Números proporcionados: {} y {}. {}.” if(numero1==numero2): #En dado caso de que los números introducidos son iguales #se mostrara lo siguiente:. print(salida....
df208a805653f4f666907dd1b1b5c0c6a3178ee5
Live4dreamCH/python
/hhh.py
903
3.78125
4
from threading import Thread class myThread (Thread): """多线程,调用threading库,需要新建一个类,继承Thread,并且重载run函数""" def __init__(self, n): """传抢课需要的参""" Thread.__init__(self) self.n = n def run(self): """每一个线程做的事""" print("\n开始线程:" + self.getName()) print(self.n, ':', ...
4fdb66e9469c642d06dcc680a36bc8b3798b5b4d
Shivani45/practice_questions-for-file-handling-with-python
/16.py
192
4
4
#taking text file as a input and counting number of words in file(some words can be separated by a comma) f=input() file=open(f) d=file.read() d.replace(","," ") print(len(d.split()))
8689f131ca0ea27a5178e0a6da1bde8ffd8c7583
qianna97/pid-tuning-ai
/step_info.py
2,651
3.53125
4
import numpy as np class StepInfo: ''' This class is for calculate and find step info from control data system step data require for calculate fitness function in genetic algorithm ''' def __init__(self, x_list, y_list, setpoint): self.x_list = x_list self.y_list = y_list se...
26b3126cefc5a23d556047bafa87f1e5ade24b70
aaronshang/TDDDemo
/pythonNotes/sort.py
1,901
4.0625
4
# sort three num count=0 print 'please input three num for sort' while count <3: print 'please input num%d'%(count+1) input=raw_input('num%d='%(count+1)) if input.isdigit()==False: print 'input error, not a num' continue count+=1 if count==1: num1=input #print 'num1 is',num1 elif count==2: num2=inpu...
77594b8469bccfa400d8442b4be90d02e9b277dd
vbyravarasu/StockBrain
/src/python/Reader.py
1,862
3.5
4
""" Reader module has file reading classes. List of Classes: StockReader: To read the stock history files. NewsReader: To read instant news articles from web. (has to be implemented). """ import pandas_datareader as ot_web class StockReader: """ StockReader reads stock from internet. Parameters: ...
d89f68498ed1b3b144a171ef07e6bb88f25ab5b4
RyanWangZf/Learning_from_data
/pa1/softmaxRegression.py
1,279
3.515625
4
# -*- coding: utf-8 -*- import numpy as np from tensorflow.examples.tutorials.mnist import input_data import pdb def softmax(y): ''' Input: y = np.dot(x,theta): (m,n)*(n,10) = (m,10) Output: softmax(y): (m,10) ''' exp_y = np.exp(y) return exp_y / np.sum(exp_y,axis=1).reshape(-1...
e2f3fb0b2cd06aa86431aeceac94f5e1d44be481
ResilientSamuel/python
/for_loop.py
268
3.765625
4
for i in range(1,11): print i for j in [1, 2, 3]: print j print"\n" for s in range(0,20,2): print s print "\n" for d in range(20): print d print "\n" for k in range(0,4): print "****" print "\n" for j in range(0,5): print '*' * j
7eebe55e61186d197d77d60b966968e9a00852a8
P-blip3110/Python
/Exercises/sum13.py
202
3.6875
4
def sum13(nums): for i in range(len(nums) - 1): if nums[i] == 13: nums[i] = 0 nums[i + 1] = 0 if nums[-1] == 13: nums.pop() return sum(nums) print(sum13([13, 1, 2, 2, 13]))
8e50f408fb05a1d421f076bbb045aaf8b825baba
wognsdl1126/kmove_python
/basic/test.py
285
3.6875
4
food = "python's favorite \"food\" 혜성이 멸치" print(food) a=[] b=[1,2,3] c=["life","is"] d=[1,2,[1,2,3]] print(a) print(b) print(c) print(d) print(type(a)) a=[1,2,3] del a[1] print(a) a.append(4) print(a) a=[1,7,6,4,3,2,58,45] a.sort() a.reverse() print(a.index(1)) print(a)
d18e06939da29194ae309451950c2e5e05fb2098
Glutamato/Conversor_de_monedas
/conversor.py
389
4.15625
4
#Compilador en línea # https://www.programiz.com/python-programming/online-compiler/ Bolivares= input("¿Cuántos Bolívares tienes disponible?: ") Bolivares= float(Bolivares) Valor_dolar= input("¿A cuánto está cotizando el dolar?: ") Valor_dolar= float(Valor_dolar) Dolares=Bolivares/Valor_dolar Dolares=round(Dolares,0) D...
37d3655444daab462357e340e3de9b6fe91bf30a
anoopmishra4293/python-questions
/07_find_n_largest_elements_in_list.py
514
3.984375
4
a = [] element = int(input("enter the number of elements in list: ")) for i in range(element): x=int(input()) a.append(x) n = input("Enter number of largest elements you want from list : ") n = int(n) # first method a.sort() result=a[-n:] print(result) #second method # b=[] # if n < element: # for i in ra...
fb8e935fab61bc94d3cdf9d7ec6efa9fd8f63554
ziqi97/python-
/类的宿主/18_2.py
565
3.875
4
# 1、__new__方法实现 class dog: def __new__(cls, *args, **kwargs): if not hasattr(cls,'_instance'): # 第一次调用__instance是空走这个分支,创建一个obj obj = super(dog,cls) # 把obj赋值给类属性__instance cls._instance = obj.__new__(cls,*args,**kwargs) # 第二次调用类属性__instance有值,走这个分支,...
8cc4bf2ae9b20c54733a4f500db3575cee67a579
swadipa123/Python-Examples
/forloop_sum_number.py
132
3.8125
4
#sum 1234 ------>1+2+3+4 total=0 num = input("Enter number ") for i in range(0,len(num)): total += int(num[i]) print(total)
6daccf5038f21e21001f4afbde5e407015b562ee
cjwood032/CSC1570
/CSC1570/pet_driver_Wood.py
1,680
4.5625
5
#pet_driver_Wood #this program creates a class for storing the information on a pet #Programmer: Christopher Wood #4/20/18 #program name: pet_driver_Wood.py #psuedocode #1. create the pet class #2. set the init method #3. define self. and get. for name, type, and age #4. create a function that will prompt the user to i...
e12bdee84b529bd61138b4b6a4f6f24ab4be97f5
JingwenX/data-structure-algorithm
/warm-up/lint_no13_ImplementingStrstr.py
2,290
4
4
class Solution: """ @param source: @param target: @return: return the index Example 1: Input: source = "source" ,target = "target" Output: -1 Explanation: If the source does not contain the target content, return - 1. Example 2: Input:source = "abcdabcdefg"...
a81791869a9134de5163bf591fb930871253bc8a
StivenZ/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
239
4.03125
4
#!/usr/bin/python3 """Module to append string into a file""" def append_write(filename="", text=""): """Append a string into a file""" with open(filename, "a", encoding="utf-8") as fd: n = fd.write(text) return (n)
34289da5783f8ddc006154e8bf9409dae050ff8a
umr-marbec/python-training
/data_types/strings.py
7,212
3.671875
4
# --- # jupyter: # jupytext: # formats: py:light,ipynb # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.10.3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # Strings # # ## Usage...
dea8733f42afe090beba381688cea8089bc43f3c
JansenLefever/Ops-401d2
/ops37.py
1,560
3.578125
4
#!/usr/bin/env python3 # The below Python script shows one possible method to return the cookie from a site that supports cookies. import requests, os # targetsite = input("Enter target site:") # Uncomment this to accept user input target site targetsite = "http://www.whatarecookies.com/cookietest.asp" # Comment thi...
40214619d1fa59592205cbe32d32293c8fd86957
anoyo-lin/algorithm
/geeksforgeeks/binary_search.py
1,738
3.75
4
#!/usr/bin/python3 class binary(array=[], target): def __init__(self): self.array=array self.target=target self.lower_bound=0 self.upper_bound=self.array.length()-1 def search(self): if self.upper_bound>=self.lower_bound: middle = array.length()-1//2 ...
9696b2d4e73d269602d449a3dbbc643033268da8
Akshay-Chandelkar/PythonTraining2019
/Ex43_Add2,3,4,5Nos.py
644
4.0625
4
def add(a, b, c=0, d=0, e=0): return a+b+c+d+e def main(): res = add(10, 20) print("The addition of two numbers :: {}".format(res)) res = add(10, 20, 30) print("The addition of three numbers :: {}".format(res)) res = add(10, 20, 30, 40) print("The addition of four numbers :: {}"....
26fa18bcaf74759ba1dd483d580fbf084fd2a404
meloun/py_ewitis
/libs/utils/utils.py
357
3.546875
4
'''cconvert integer(time in ms) to string (HH:MM:SS:mSmS)''' def time_to_string(time): hours = time / (100*60*60) time = time % (100*60*60) minutes = time / (100*60) time = time % (100*60) seconds = time / (100) milliseconds = time % (100) return '%02d:%02d:%02d,%02d' %(h...
804ce7cc2c9f3f0a7601ab65aad145455c781305
pdst-lccs/lccs-python
/Section 5 - Programming Logic/Breakouts/Breakout 5.5 - Multiplication Maths Tutor (MMT)/MMT_Pg165V_3.py
652
4.25
4
'''multiplication tutor V3 the user should be provided with more detailed feedback about their answer i.e. correct, too high or too low''' import random n1 = random.randint(0, 12) # Generate the 1st number n2 = random.randint(0, 12) # Generate the 2nd number ans = n1*n2 # Calculate the product and store it i...
856d77b5ef0954bfaebd8f5bb9602cacc4af8142
adison330/testdemo
/test019.py
201
3.5625
4
#! /usr/bin/env python a = 10 def demo(): print("%d" % a) print("%d" % b) print("%d" % c) #全局变量要定义在调用之前,所以最好都在最前面定义。 b = 20 demo() c = 30
0fa49bbc78e509fd58f029280bc2ff7f0c740a06
vitorrcunhaa/8puzzle-artificial-intelligence
/8_puzzle_vitor.py
3,382
3.90625
4
import sys from copy import deepcopy class Node: def __init__(self, state, misplaced_pieces): self.state = state self.misplaced_pieces = misplaced_pieces def ask_initial_state(): # Get puzzle initial state from user puzzle = [] print("Enter inital state separated by spaces. Example...
a62d0bfe56c9ea1db6b705596e54f9e3109a376b
ashanaka/Web-Scrapping-using-python
/lucky.py
942
3.59375
4
import requests, sys, webbrowser, bs4 #request : to download the webpage #sys : to get the command line arguments #webbrowser : to open the perticular link using the Web Browser of your PC #bs4 : to get the HTML of the downloaded web page print("Googling...") #print this while the process is going on res =...
2adafe5f25c14370523868de7ad914fc295b7411
shuyiz666/stock_analysis
/shuyiz_5_1.py
3,128
3.640625
4
''' assignment1: kNN (using sklearn) add results of trading using knn (we only trade year 2) ''' import os import numpy as np import pandas as pd from sklearn.neighbors import KNeighborsClassifier import matplotlib.pyplot as plt from sklearn.metrics import confusion_matrix import matplotlib.ticker as mtick wd = os.get...
737dac4de2c1f61efdbc016bff07797c03811258
klipanmali/datastructures
/py/datastructuresGraphTwoNodesonSamePath.py
1,882
3.828125
4
from collections import defaultdict class Graph: def __init__(self, num_of_vertices): self.num_of_vertices = num_of_vertices self.adjacent = defaultdict(list) self.visited = set() self.intime = [0] * self.num_of_vertices self.outtime = [0] * self.num_of_vertices se...
61dd7d6056ccdcffb4365cfe56e332331e7faf42
mk668a/python_aoj
/alg2/randomized.py
341
3.75
4
from random import random as rand def PI(n): inCircle = 0 for i in range(n): x = rand() y = rand() d = (x - 0.5)**2 + (y - 0.5)**2 if d < 0.25: inCircle = inCircle + 1 return 4 * inCircle / n n = 1 for i in range(1, 6): n *= 10 print("n =", n) prin...
cd2fecefbb689d1bf23f3a4e12a593eb6e73bb1c
iamzero-j/PythonAlgorithm
/Programmers/arraySort_K.py
760
3.78125
4
#정렬 문제 #프로그래머스 - [K번째수] #문제 출처: https://programmers.co.kr/learn/courses/30/lessons/42748 #배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 한다. # array=[1,5,2,6,3,7,4] i=2,j=5,k=3 ==> [5,2,6,3] -> 정렬 : [2,3,5,6] => 3번째 숫자 =5 # 이차원 배열 [[i,j,k]] 로 반환. def solution(array,commands): temp=[[]] arrays=[[]] ...
91186a43450852dc3f224c305c6346e4284fe344
Kevinrobot34/atcoder
/abc/abc_001_041/abc011/c.py
273
3.578125
4
n = int(input()) ng_list = [int(input()) for _ in range(3)] if n not in ng_list: for i in range(100): for j in reversed(range(1, 4)): if n - j not in ng_list: n -= j break ans = "YES" if n <= 0 else "NO" print(ans)
37af55e0f834b411daf59205819c6e280cb3d1b4
Tobi-273/arduinopy
/plotcsv.py
952
4.09375
4
"""Functions for choosing a file and for 2D-plotting by selecting two columns of a .csv file""" import pandas as pd import plotly.express as px import tkinter as tk from tkinter import filedialog def plot_from_csv(file, x='Timestamp', y='Value', title='Measurements'): """Plots a 2D-graph and shows it. Expect...
c013e7b1da25427f92b3d113887250ad0e2da75d
Bgumel/Automate-The-Boring-Stuff
/Practice-Projects/Ch 11 - Image Site Downloader
3,489
3.734375
4
#! python3 # cyanide_and_happiness.py """ Write a program that goes to a photo-sharing site like Flickr or Imgur, searches for a category of photos, and then downloads all the resulting images. You could write a program that works with any photo site that has a search feature. For this project, I decided to download C...
dd49bbd3212bd1c77674f3b8f68ef134a6f7b253
pr1malbyt3s/Py_Projects
/Runcode.ninja/Simple_Cipher.py
579
4.28125
4
#!/usr/bin/env python3 # This script is used to decode a special 'cipher'. # The cipher pattern is each first word in a new sentence. import sys # Create a list to store each parsed first word from an input file. message = [] with open(sys.argv[1], 'r') as f: cipher = f.read() # While reading file, split the file ...
6396a28d4332d5cc04cdc5104fd6fc16e80cb419
Habibur-Rahman0927/1_months_Python_Crouse
/Python All Day Work/29-04-2021 Days Work/list.py
1,445
4.25
4
# python list my_list = [] # empty list print(my_list) my_list1 = [1, 2, 3] # list of intgers print(my_list1) my_list2 = [1, 'Hello', 3.5] #list with mixed data type print(my_list2) my_list3 = ['Hero', [1, 2, 3], ['a'], 'rock'] # nested list print(my_list3) #list indexing my_list4 = ['Hero', 'zero', 'nothing'] pri...
c85216392e843edcea4d436cd9c0ccf740d19cbf
dazheng-yin/test
/huffman_tree2.py
2,510
3.8125
4
#哈弗曼树复现 class huffman_tree: #哈弗曼树类 class Node: #定义哈弗曼树结点 def __init__(self,data,weight): self.data=data self.weight=weight self.left=left self.right=right def min(self,data): #此函数找到权值最小的两个结点 min2=[Node(None,float...
3160c4b2a3e46ee85b0af5202a3d952568ceecf6
3wnbr1/TD-Informatique-ECAM
/SUP/TD1_correction/exercice_21.py
217
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 4 20:58:37 2015 @author: Pierre """ n = input("DOnner un nombre entier.") s = 0 for c in n: s += int(c) print("La somme des chiffres de",n,"vaut",s)
a9c4ea98c7c98f6285a09d001115ac04871990bc
anudeeptreddy/GraphAlgorithms
/week2/strongly_connected_2_3.py
1,857
3.828125
4
#Uses python3 import sys sys.setrecursionlimit(200000) def dfs(adj, vertex, visited, topological_order): # depth first search algorithm visited[vertex] = True for adj_vertex in adj[vertex]: if not visited[adj_vertex]: dfs(adj, adj_vertex, visited, topological_order) topolo...
53a21010112ed6fa62429e52335a8ef91156ccd2
jackie-may/tech_academy_python_projects
/app2.py
1,107
3.75
4
import app def print_app2(): #declaring a function name = (__name__) #calling outside of this function to the function in app.py return name if __name__ == "__main__": """ saying if this script is being ran do the following code underneath otherwise don't do anything on this page this is how ...
3440c5be3366be1e1b64260ebd70fc14db374a5e
Marcin52/Python
/games/pong.py
6,498
3.5625
4
import pygame import sys from pygame.locals import * class Board(): ''' Game board ''' def __init__(self, width, height): ''' Game board constructor. Prepares game window. ''' self.width = width self.height = height self.surface = pygame.display.set_mode((width, height), 0, 32) pyg...
aa45f5a45ff887b8fdb5172064f46e55a99a504c
SaidMuratbekov/msai-python
/homeworks/01_assignment/unique_03.py
321
3.6875
4
# Write a function that takes a list of arbitrary elements and returns a list of # unique objects (elements that are in different memory locations) def unique(seq): """ :param seq: List of arbitrary elements :return List: unique elements in seq with different ids """ # Write your code here ......
282ec9ef60af5ae5ce69bf7d8ae007e923f90597
rodcordeiro/codewars
/Kata/Highest-Scoring-Word.py
896
4.03125
4
# -*- coding: utf-8 -*- # Author: Rodrigo Cordeiro # Given a string of words, you need to find the highest scoring word. # Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc. # You need to return the highest scoring word as a string. # If two words score the same, re...
2f141602b025091d66c5a656f805da60275b3156
alx5246/srnnetTraining
/src/sandBox/analysisFunctionDevelopment/SpikeCount.py
4,914
3.859375
4
# S. Pickard # June 2016 # (Using python 3.4.4, and brian2 2.0rc) # # DESCRIPTION # Function/method that produces an output vector of averaged spike counts across neurons per time step # This analysis was inspired by Lazar et al.(2009) Figure 5.b # Goal is to find how many spike occur in each sub time interval i...
181f74c69ab6e2a79a8850f9aae43e93596da2e1
Galante97/sound-convolution
/my_conv.py
3,301
3.546875
4
## JAMES GALANTE ## JOSH WEINICK import numpy as np import math def myconv(x,h): ############################################################################ # A function to generate the output signal y as convolution of input signal # x and impulse response signal h ############################################...
c2f622f51bbddc54b0199c4e0e2982bc2ebfa030
qdm12/courses
/Fundamental Algorithms/Lesson-03/algorithms.py
2,479
3.875
4
from operator import itemgetter from math import floor def radix_sort_alpha(words): l = len(words[0]) for w in words: if len(w) != l: raise Exception("All words should be of same length") for i in range(l, 0, -1): words = sorted(words, key=itemgetter(i - 1)) ...
b812e5986174d3ab4cbd810339d993e663d445e1
oksanayolkina/qa_python_kurs
/homework3/unittest_func_ITEmployee.py
1,512
3.59375
4
import unittest from homework3.class_ITEmployee import ITEmployee class EmployeeWithoutPositionTests(unittest.TestCase): def setUp(self): self.emp = ITEmployee("Oksana", "Alekseienko") def test_names(self): self.assertEqual(self.emp.name, "Oksana") self.assertEqual(self.emp.surname, ...
b17b9d9015875dda4f2f0f029d297ef4d2eba713
nitinkumar-patel/Data-Structures
/Graph/graph.py
1,570
4
4
""" # Edge List graph = [[0, 2], [2, 3], [2, 1], [1, 3]] # Adjacent List graph = [[2], [2, 3], [0, 1, 3], [1, 2]] # Adjacent Matrix graph = [ [0, 0, 1, 0], [0, 0, 1, 1], [1, 1, 0, 1], [0, 1, 1, 0], ] # Adjacent Matrix graph = { 0: [0, 0, 1, 0], 1: [0, 0, 1, 1], 2: [1, 1, 0, 1], 3: [0...
6c84231802d7ae09eee57958d6747a7306a0a63c
VladimirGas/BW1_Goodreads
/analysis.py
642
3.6875
4
import numpy as np import pandas as pd # Functions def analydsis(DataFrame, author): df = DataFrame # Creates the group out of the years group = df.groupby(['original_publish_year']) # Finding the mean of minmax_norm_ratings means = df.groupby('minmax_norm_ratings').mean() # Returns the book w...
b224f3d8ccb38f37235f57e861db83f74c9852a5
Bleiben1/unbeat.py
/unbeat.py
1,399
3.921875
4
# coding=utf-8 import sys, os ##-----TODO------ # # # Nothing # # Suggestions? # ##---------------- money = 12 def printCoins(amount): for i in range(0,amount): print """($)""", def discount(amount): global money money = money - amount def machine(): print "" if (money > 3): de...
a9b6f3e0fe1f7d520e80fff71a0ea47e6852e529
sandrahelicka88/crackingcoding
/Stack/queueviastack.py
1,030
3.796875
4
import unittest class Queue: def __init__(self): self.newestOnTop = [] self.oldestOnTop = [] def enqueue(self, item): self.newestOnTop.append(item) #always add elem to first stack(newestonTop) def dequeue(self): self.shiftStacks() return self.oldestOnTop.pop() de...
ce9e6ac12dc4f2f3fa51aa19b7f8324d266c7dfa
elxavi82/py_projects_repo
/HelloWorld.py
609
3.578125
4
#!/usr/bin/env python import numpy as np import pandas as pd import matplotlib from matplotlib import pyplot as plt def y_func(x): return 2*x+3 def func(x): return 3*x-1 x = list(range(0,15)) y1 = [] y2 = [] dataset_two = [-10, 30, 4, 5, 10, -20] dataset_two.sort() print(dataset_two) for i in x: y1.append(...
2d4980d3555be1aac96a7340f9c9c54fa6844679
Bea-Jae-Kyeong/Python
/2_making_trees.py
2,516
3.765625
4
#while 트리만들기 1-1 i,j=0,0 num=int(input("값 입력: ")) while j<num: j=j+1 i=0 while j>i: print('*',end='') i=i+1 print() print() #while 역 트리만들기 1-2 i,j, k=0,0,0 while j<num: i=1 while num-j>i: print(end=' ') i=i+1 j=j+1 i=0 while j>i: pr...
1a17441046274b0a361b60bb2bf9f1a84451c836
patrickbucher/python-crash-course
/ch06/people.py
576
3.71875
4
r_emelo = { 'first_name': 'Randy', 'last_name': 'Emelo', 'age': 53, 'city': 'Fraudsterville', } eschuja = { 'first_name': 'Elisabeth', 'last_name': 'Schulze-Jägle', 'age': 49, 'city': 'Schwäbisch Gmünd', } dirty_harry = { 'first_name': 'Harald', 'last_name': 'Burger', 'age'...
67cb4bea9ef824807c058dbab7c70c7bf82d70ac
NUsav77/Python-Exercises
/Arrays/student_grades.py
513
3.765625
4
if __name__ == '__main__': records = [] for _ in range(int(input())): name = input() score = float(input()) records += [name, score] # Sorts the scores and names from lowest to highest scores = sorted(records[1::2]) names = sorted(records[::2]) # second_lowest = names[...
78a784dfd18a82f49af616e92dfa1d460dece052
eliaahadi/Programming-Foundations-with-Python
/Lesson6_UseCasesTurtle/1.6.5.turtle.py
936
3.96875
4
import turtle from turtle import * def draw_square(some_turtle): for i in range(1,4): some_turtle.forward(100) some_turtle.right(90) def draw_triangle(some_turtle): for i in range(1,4): some_turtle.forward(100) some_turtle.left(120) def draw_art(): window...
1d5bbb2773116d9c6c05c1a0dcee3ee075471049
EAcosta2584/Programming-for-Video-Games-Resources
/UsingImages.py
5,821
3.578125
4
################################################ # File Name: UsingImages.py # Creator Name: Mr. Acosta # Date Created: 2-3-2020 # Date Modified: 2-6-2020 ################################################ # This program will demonstrate using images # ################################################ import pygame, sys,...
a4da101bc4df5b6d25460f9f6ed4f8d7b0187284
bijaythapaa/fluffy-octo-parakeet
/PythonCrashCourse/dictionary_one.py
315
3.71875
4
d1 = { 'key1': 'value1', 'key2': 'value2', 'key3': [1, 2, 3,], } print(d1['key1']) print(d1['key2']) print(d1['key3'][2]) my_list = d1['key3'] print(my_list[0]) d2 = { 'key1': 'value1', 'key2': { 'innerkey': [4, 5, 6,] } } print(d2['key2']) print(d2['key2']['innerkey']) print(d2['key2']['innerkey'][1])