blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e5654460c1849e1bc7930a70bab8e82a17433a51
akhvn/Matlab
/Dynamic chaos/1_1.py
280
3.546875
4
import matplotlib.pyplot as plt import numpy as np from random import* f=lambda x:4*r*x*(1-x) x0=random() r=float(input('введите r:')) x=[f(x0)] n=[i+1 for i in range(60)] for i in range(59): x.append(f(x[-1])) ax = plt.subplots() plt.plot(n,x) plt.show()
8d2074377552df05d8c63082d8a74953ebe6d575
chaosWsF/Python-Practice
/leetcode/1021_remove_outermost_parentheses.py
1,955
3.59375
4
""" A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. A valid parentheses string S is primitive if it is nonempty, and there d...
40af9b8278fb77a315be3df2e2d595748202493d
Leticiamkabu/globalCode-18
/advPython/Map,Filter & Lambda/lambda.py
481
4.53125
5
print("Using the Lambda Function: \n") # the Lambda Function also called an anonymous func, # does not have a name and is called implicitly originalList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] #using the filter func & a Lambda Function, each value in originalList #is tested even if true add to the newList newlist = list(fi...
1d56cf702ca94e61628c3d9a1867114b2421b32b
shenbanakshetha24/set5
/4.py
66
3.609375
4
c=int(input()) if(c>1 and c<10): print("yes") else: print("no")
dd8cf4a07fc72eadf74bb3ae948c99af0d861e40
hanyanru0719/vip5
/20200314homework.py
2,289
4.09375
4
# Python练习题: # 1、打印小猫爱吃鱼,小猫要喝水 # class Animal(object): # name = 'cat' # def eat(self,food): # print("%s爱吃%s"%(self.name,food)) # # def drink(self): # print("%s要喝水"%(self.name)) # # a =Animal() # a.name = '小猫' # a.eat('鱼') # a.drink() # 2、小明爱跑步,爱吃东西。 # 1)小明体重75.0公斤 # 2)每次跑步会减肥0.5公斤 # 3)每次吃东西...
afd33a280b7622b0d724c2aff9f73d328e607570
Laharah/advent_of_code
/2017/day07.py
1,817
3.5625
4
from common import Input import re class Node: def __init__(self, name, weight): self.name = name self.weight = weight self.children = [] class UnbalancedTree(Exception): pass def build_tree(base, parents, weights): tree = Node(base, weights[base]) for n in (name for name, ...
25144b43aa4bb60a48d77d12febddea63229d0b1
robgoyal/CodingChallenges
/HackerRank/Algorithms/Strings/0-to-10/hackerrankInString.py
840
4.3125
4
# Name: hackerrankInString.py # Author: Robin Goyal # Last-Modified: November 17, 2017 # Purpose: Determine if 'hackerrank' is in a string in the correct order def hackerrankInString(s): ''' s: string return: "YES" or "NO" YES if hackerrank is in s in the order of the characters in hackerrank ...
7b9409134ca6ff7238a9ade74740fce3d670aa51
SAURAVBORAH22/toxic_comment_classifier
/app.py
3,915
3.765625
4
import streamlit as st import pandas as pd from PIL import Image from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import LogisticRegression import pickle import numpy as np def main(): activities=['About','Toxic Comment Classification System','Developer'] option=st....
f000f33571fe758b20ec8c999d3e5fd4e3e4c814
i386net/w3resource
/Python basic part I/22.py
161
3.84375
4
# 22. Write a Python program to count the number 4 in a given list. def counter(lst): return lst.count(4) l = [4, 1 ,2 , 4, 6 , 5] c = counter(l) print(c)
b571c6441b37188abff2adf2cfd3ec377429d745
masipcat/Informatica
/Q1/s6/EOT-46.py
658
3.859375
4
def foraVocals(cadena): r = "" vocals = "aeiouAEIOU" for char in cadena: if char not in vocals: r += char return r def modificaCadena(cadena): count = len(cadena) i = 0 r = "" a = "bogeria" while i < count: r += cadena[i:i+3] + a print "(", i,")", r i += 3 return r cadena = raw_input("Introdueix...
f725419b9eef3279a3cecd3f65c995c3fe49ff2e
Jbiloki/Cryptography
/caesar.py
515
3.796875
4
#!/usr/bin/python3 class Caesar: def __init__(self): self.key = None return def setKey(self, key): try: self.key = int(key) return True except: print("Key is not able to convert to int") return False def encrypt(self, text): ct = '' for i in range(len(text)): ct += chr((((ord(...
74e9fe36f9bbdb2a949d222d3bf677ab07137225
nevesrye/project_euler
/euler005.py
626
3.8125
4
##Smallest multiple ##Problem 5 ##2520 is the smallest number that can be divided by ##each of the numbers from 1 to 10 without any remainder. ## ##What is the smallest positive number that ##is evenly divisible by all of the numbers from 1 to 20? def sm(n): for i in range(n, factorial(n) + 1, n): ...
8d6f0060047cbcf9241535afb31f35c9d25afc75
kitbitsks/ib_Solutions
/ib_linkedList_reverseLinkList2.py
1,434
3.96875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param A : head node of linked list # @param B : integer # @param C : integer # @return the head node in the linked list def reverseBetween(self, A, B...
318d9e1a596fc7601ecc6384ddae6f159b5a9e5f
danielraf23/pythonProject
/DanielRaf/EX_1.6.py
103
4.1875
4
radius=int(input("circle_radius: ")) PI=3.141 h=2*PI*radius s=PI*radius*radius print(h) print(s)
34116335da09a7c4766811e305de502b9bc8f121
13950090228/Web-Python-LearningNotes
/Web+Python学习笔记/day12(函数名使用和闭包和迭代器)/作业练习.py
184
3.75
4
n=int(input('请输入要几行:')) for i in range(1,n+1): for j in range(2*n-2*i): print('',end=' ') for k in range(2*i-1): print('*',end=' ') print('')
3bfe60a6dbc1b384b7bf511d45bdce52dc2bdb3a
oneytlam/mlwithpython
/mouse_control_with_head.py
2,207
3.5
4
# Adapted from https://www.analyticsvidhya.com/blog/2020/12/deep-learning-with-google-teachable-machine/ # Import necessary modules import numpy as np import cv2 from time import sleep import tensorflow.keras from keras.preprocessing import image import tensorflow as tf import pyautogui # Using laptop's we...
ee055afe4b6b9224f2e2980165344f9145867da6
kanglicheng/Adventure-in-Data-Science
/Data-Structures-and-Algorithms/quickSort.py
1,345
4.03125
4
def quickSort(array): helper(array, 0, len(array)-1) return array # Recursion def helper(array, first, last): # need first & last index as func argument if first >= last: return else: splitpoint = partition(array, first, last) helper(array, first, splitpoint-1) ...
5bf2471afd3b6f0ba45d51fcfc043ee9f1e39b22
juhyun0/python_turtle5
/Korean_flag.py
308
3.75
4
import turtle def draw_shape(radius,color1): t.left(270) t.width(3) t.color("black",color1) t.begin_fill() t.circle(radius/2.0,-180) t.circle(radius,180) t.left(180) t.circle(-radius/2.0,-180) t.end_fill() t=turtle.Turtle() t.reset() draw_shape(200,"red") t.setheading(180) draw_shape(200,"blue")
af383752efa60c3101c45149672df6df3d8fa3c5
Rukshani/udacity-cs373
/hw3.py
1,091
3.78125
4
#! /usr/bin/env python # 1. empty cell print "what is the probability that zero particles are in stat A?" print "4 states, N uniform particles" print "when N = 1, 4, 10?" def pN(N): return (3./4.)**N print pN(1.), pN(4.), pN(10.) # 2. motion question print "consider 4 states, [[a b],[c d]]. motion step" print "5...
56cfd653835b8faaff928eef401032ccd4e46f5c
s21911-pj/ASD
/Heap sort.py
1,358
3.75
4
import datetime import random def heapify(arr, n, i): largest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and arr[i] < arr[l]: largest = l if r < n and arr[largest] < arr[r]: largest = r if largest != i: arr[i], arr[largest] = arr[largest], arr[i] heapify(arr, n...
48f5ecb3097d45abe4d87081c94ce5124579d332
acid9reen/Artezio
/Lesson_8_http_regexp/task2.py
622
4.09375
4
'''Convert currency from one to another''' import requests def converter(amount: float, from_curr: str, to_curr: str) -> float: '''Convert currency from one to another''' url = 'https://api.exchangerate-api.com/v4/latest/' \ + from_curr response = requests.get(url) data = response.json() ...
7723977ccf4e5c414024d6541cc271d2f474f991
ivoryli/myproject
/class/phase1/day03/exercise01.py
716
3.78125
4
# n = input("季节") # # if n == '春': # print("1,2,3") # elif n == '夏': # print("4,5,6") # elif n == '秋': # print("7,8,9") # elif n == '冬': # print("10,11,12") # else: # print("请输入正确季度") #----------------------------------------- ''' 输入月份得天数 ''' # n = int(input("输入月份")) # # if n < 1 or n > 12: # ...
56840ca9ef184c643f6db59c5eed9c0b634fd16a
cu-swe4s-fall-2019/trees-mchifala
/binary_tree.py
1,293
3.9375
4
import sys sys.setrecursionlimit(10**6) class Node: """ This class serves as the nodes of a tree. Attributes: - left(Node): the left child of the node - right(Node): the right child of the node - key(int): the key of the node - value(varies): the value of the node """ def __init_...
990a41c55bb8b8b7b288a6c2f6887911cec8e5ef
Aritra222/area_python
/index.py
932
4.25
4
x = "The area of Circle" y = "The area of Rectanngle" z = "The area of square" t = "The area of triangle" g = '' print (x) print (g*6) a = 6 print ("Supoose radius of circle is :" , a) areaofcircle = 3.14*a*a print (g*6) print ("Area of Circle is:",areaofcircle) print (g*6) print (y) b= 12 c= 23 d=b*c ...
73a0e00ec9e91543f23b0363f59bf33844cce67f
PalashMatey/Project_BigData
/NLTK_modules/final_chunk.py
960
3.734375
4
''' Basically implies that, you can use some part of data and ignore the rest. A method of elimination, unlike that of chunking. Chunking is a method of selection. You chink something from a chunk basically ''' import nltk from nltk.corpus import state_union from nltk.tokenize import PunktSentenceTokenizer from nltk i...
9cccd97302b4d7fcdf94f788421d0b02a4c5f715
manishrana93/python_trg
/33_is_prime.py
480
3.90625
4
from _typeshed import StrPath def is_prime(n): start=2 stop=n-1 i= start while ( i <= stop): if n % i ==0: return False i = i + 1 return True def print_is_prime_status(n): if is_prime(n): print(f"{n} is a prime number") else: print(f"{n} is no...
95e73dc7932734b4d2df7cd5ab11a6936c841af5
eddiegz/Personal-C
/DMOJ/CCC/telemaker or not.py
177
3.75
4
a=int(input()) b=int(input()) c=int(input()) d=int(input()) if a==9 or a==8: if b==c: if d==9 or d==8: print('ignore') else: print('answer')
eb46aa65ba9f86627bb369bac2072aaf8cbca4de
Bangatto/Voting_Simulator
/instant_run_off.py
3,927
3.6875
4
# COMP 202 A3 # Name GATTUOCH KUON # ID:260-877-635 from single_winner import * ################################################################################ def votes_needed_to_win(ballots, num_winners): ''' (list, int)-> int want to return the number of votes a candidate need to win using the Droop ...
9426a9009201c32985225eb8b931df787178ce60
Akshata2704/APS-2020
/58-strings_anagram.py
450
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 28 23:33:52 2020 @author: AKSHATA """ def is_anagram(a,b): a=list(a) b=list(b) if(len(a)!=len(b)): return 0 else: a=sorted(a) b=sorted(b) for i in range(0,len(a)): if(a[i]!=b[i]): ...
e542a324945ea7f354ddbfe6dd39448a80ed77fb
TyDunn/hackerrank-python
/CTCI/queue_via_stacks.py
906
3.859375
4
#!/bin/python3 import sys class Stack: def __init__(self): self.items = [] def empty(self): return not self.items def push(self, item): self.items.append(item) def pop(self): val = self.items.pop() return val class Queue: def __init__(self): self.new_stack = Stack...
8563b8d82c7e8acdb12baaa0172cb68d8c11a9c5
saikatsahoo160523/python
/Ass17.py
449
4
4
# 17. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a program to make a list whose elements are intersection of the above given lists. def intersect(a, b): """ return the intersection of two lists """ return list(set(a) & set(b)) if __name__ == "__main__": a = [1,3,6,78,35,55]...
480be8d49cd8bb67222eaa4611a3b3d00544e4ca
TSAI-HSIAO-HAN/Signal_Processing
/animation/tryBar.py
1,002
3.59375
4
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib.widgets import Slider TWOPI = 2*np.pi fig, ax = plt.subplots() plt.subplots_adjust(bottom=0.2, left=0.3) t = np.arange(0.0, TWOPI, 0.001) s = np.sin(t) l = plt.plot(t, s) redDot, = plt.plot([0], [np.sin(0)], ...
88e7637ece727d1fd45984d0423645847a7c09bf
frankieliu/problems
/leetcode/python/403/sol.py
1,011
3.890625
4
Elegant Python Simple Solution https://leetcode.com/problems/frog-jump/discuss/88887 * Lang: python3 * Author: vimukthi * Votes: 0 class Solution(object): def canCross(self, stones): map = {val:idx for idx, val in enumerate(stones)} visited = {} return self.jump...
107ca69346d27a16b7875277ac157b165fa63e91
MarioLinJueSheng/VmixFootballControl
/a0.95.py
24,843
3.53125
4
# -*- coding: utf-8 -* #!/usr/bin/env python3 #球队名 file = open('away.txt', mode='r', encoding="utf-8") t = file.readlines() # 读取整个文件内容 file.close() # 关闭文件 away_list = [x.strip() for x in t] file = open('home.txt', mode='r', encoding="utf-8") a = file.readlines() # 读取整个文件内容 file.close() # 关闭文件 home_list = [x.strip() f...
fa87a729cfc4b1d9a92b96f4fe2e1e5bb3b7ce05
khknopp/wiigamers
/summarize_wybiorcze.py
1,260
3.734375
4
def summarize(text): # importing libraries import nltk from nltk.corpus import stopwords from nltk.tokenize import word_tokenize, sent_tokenize nltk.download('punkt') nltk.download('stopwords') stopWords = set(stopwords.words("english")) words = word_tokenize(text) freqTable = dict(...
efcb203febc0907f2230ba05fe0c1be5e922ec54
rachel619/paths-to-cs-public
/m7/clock 2.py
603
4.15625
4
class Clock(): def __init__(self, time): self.time = time def get_time(self): return self.time def __str__(self): return "Time: " + self.time class AlarmClock(Clock): def __init__(self, time, alarm): self.time = time self.alarm = alarm def get_alarm(self)...
62e8fda4c21aef0bae385bd491a2742a23b35155
greenfox-zerda-lasers/brigittaforrai
/week-04/day-02/02.py
490
3.96875
4
class Rectangle(): def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height self.x2 = x + width self.y2 = y + height def is_over(self, other_rect): return other_rect.x2 > self.x and other_rect.x < self.x2 and...
3ac980c4a45bb36424b4e4705a1ce724b7d95df9
Xenomorphims/Python3-examples
/new folder/continue.py
411
3.609375
4
while True: s = input ('Enter something: ') if s == 'quit': break if s == 'q': break if s == 'exit': break if len(s) < 5: print ('Too small') if len(s) > 10: print ('Too large') continue print ('Input is a sufficient length') pr...
fb214b83e90d1a79d854162e37461b477e93e63d
alivcor/leetcode
/215. Kth Largest Element in an Array/main.py
370
3.6875
4
import Queue, random def findKthLargest(nums, k): """ :type nums: List[int] :type k: int :rtype: int """ q = Queue.PriorityQueue() for x in nums: q.put(x) if(q.qsize() > k): q.get() return q.get() random_nums = [random.randint(0,50) for _ in xrange(8)] prin...
8d3e3ee75a0d8ce2f400dac9f5cd5320592c815e
BestBroBradley/movie-collection
/app.py
2,645
3.828125
4
menu = "You can add a movie (a), list all movies (l), search for a title (s), or quit (q): " user_library = [] def query_user(): user_selection = input(menu) if user_selection == "a": add_movie() query_user() elif user_selection == "l": view_all() query_user() elif user_selecti...
ba89a3cd90c1ecc31b5dfc3038e357cff20e4f7f
kimtaeuk-AI/Study
/keras1/keras33_LSTM4_irirs.py
2,055
3.5625
4
# sklearn 데이터셋 # LSTM 으로 모델링 #Dense 와 성능비교 # 다중분류 import numpy as np import tensorflow as tf from sklearn.datasets import load_iris # x, y= load_iris(retrun_X_y=True) # 이것도 있다. dataset = load_iris() x = dataset.data y = dataset.target # print(dataset.DESCR) # print(dataset.feature_names) x = x.reshape(150,4,1)...
8274a7053589208bd813e2c0c0baa82809c995b4
dthinley/Interview-Questions_2
/interviews4.py
2,584
3.90625
4
class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree(object): def __init__(self, root): self.root = Node(root) def question4(T, r, n1, n2): # Build a tree from the matrix bst = build_tree(T, r) ...
6948615afe675e37ba923e6375844d3f716afab9
MysteriousSonOfGod/python-workshop-demos-june-27
/src/structures.py
1,142
4
4
# lists nums = [1,2,3,4, 20] names = ['kevin', 'hayk', 'dan'] print(names) print("The first name: {}".format(names[0])) print("The last name: {}".format(names[-1])) # add new people names.append('michael') names.append('hannah') names.append('ted') names.append('rob') print(names) print(names[0][0]) print( names[1...
90f61f22e2f74bf1b1e58a55f0ff0eb879c30c3d
ChristopherBare/AckermannFunction
/ackermann.py
423
3.984375
4
def ackermann(m,n): if m == 0: return int(2)*int(n) elif m >= 1 and n==0: return 0 elif m >= 1 and n==1: return 2 else: return ackermann(m - 1, ackermann(m, n - 1)) x=int(input("What is the value for m? ")) print x y=int(input("What is the value for n? ")) print ...
72e4e4333f023aa06d7b772ec1b7476d79ef580f
sudocrystal/scc-compsci
/CalcGPA-PointSystem.py
3,484
3.875
4
''' You should be able to run this script in a folder which contains downloaded grade reports from Canvas. The script should calculate GPAs and both print to the screen as well as to an output file the final gpa score to be entered into instructor briefcase. ''' import os, csv, math def gpa(decimal): # this is t...
b3415478810e06448d7260ad75bea69a20a2c396
rlavanya9/cracking-the-coding-interview
/chapt-04-bits/reverse.py
139
3.53125
4
def reverse_bit(nums): i = 0 m= 0 while i < 32: m = m << 1 + (nums & 1) nums >> 1 i += 1 return m
097527ad3bc607972bb58b5c64a0efe64d8df13d
Nishith170217/Python-Self-Challenge
/Array programs/Python Program for array rotation.py
230
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 28 09:43:49 2021 @author: Nishith """ def arryRotation(arr,d,l): arr[:]=arr[d:l]+arr[0:d] return arr arr=[1,2,4,5,7,22] l=len(arr) print(arryRotation(arr,4,l))
ee5519ee595eb789d0cdb0ef05db56e6e9a3f300
tomyc/workshop-python
/_bin/podstawy-oceny.py
1,099
4.0625
4
""" Napisz program, który wczytuje od użytkownika kolejne oceny i: * sprawdza czy wprowadzona ocena jest na liście dopuszczalnych na wydziale ocen * jeżeli ocena jest na liście dopuszczalnych na wydziale ocen, dodaje ją na listę otrzymanych ocen * jeżeli wciśnięto sam Enter, oznacza to koniec listy otrzymanych ocen * ...
3bca777791e9b24834c6d842dff1ec63419f6a7b
Sarthak-Singhania/Work
/Class 11/longest word.py
222
3.609375
4
a=input('Enter a sentence:') b='' lenght=0 cnt=0 for i in range(len(a)): if a[i]!=' ': b+=a[i] else: if len(b)>lenght: lenght=len(b) else: break b='' print(b)
9afdfb063b86544403f9174d9494cd68780622bf
archanasheshadri/Python-coding-practice
/binarytreepath.py
1,134
4.1875
4
#Given a binary tree, return all root-to-leaf paths. ''' For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] ''' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left =...
702f3d226613c225a20ce896efb7fbc6b8500880
serignefalloufall/Python_Repository
/exercice26.py
718
3.9375
4
my_liste = [] print("Saisir le nombre d'element de la liste") n = int(input()) for i in range(1,n+1): print("Saisir un entier : ") my_liste.append(int(input())) # Remplissage de la liste print(my_liste) # Affichage de la liste resultat = False elementPrecedent = my_liste[0] # Recuperation de la premier elem...
b143e84cc17fc1c15bb178f9bc938e08747140e5
snigdhasen/myrepo
/examples/ex17.py
2,671
3.984375
4
''' Using private variables and public properties ''' class Person: def __init__(self, **kwargs): self.name = kwargs.get('name', None) self.age = kwargs.get('age', None) # overriding the inherited (from object class) method def __str__(self): return 'Person [name={}, age={}]'.forma...
ff7e51820fd73485779d418f7d2a5a358d5d859e
SamuelNunesDev/starting-point-in-python
/venv/Scripts/ex102.py
531
3.90625
4
def fatorial(n, show=False): ''' -> Calcula o fatorial de um número. :param n: Valor a ser calculado o fatorial. :param show: Opção de ocultar ou mostrar o processo do cálculo. :return: O fatorial do número n. ''' f = 1 if show == True: for c in range(n, 1, -1): f...
c3d241ff3342b2ed78948eb4f9be3c65b978a110
chetandekate1/CovidIndiaData
/fetchCovidIndiadata.py
1,823
3.5
4
import urllib.request as request import urllib import json """from dictor import dictor""" class Covid19IndiaData(): """ Covid19IndiaData class implements all the functionality to fetch data of India Covid19 data """ __CODECACHE__ = None def __init__(self): self._Covid19India_dat...
0ea59b9e2710d87b3503f30fdad59cb3d0c43e5c
himabinduU/Python
/Code for hangman game/hangman_game.py
1,224
4.0625
4
print "It's time to play Hangman game" print "Start guessing the letters in the secret word..." f = open("hangman_text") lines = f.readlines() print "Enter any integer number between 1 to 10" num = int(raw_input()) line = lines[num] word = '' ct = 0 for c in line : word += c ct += 1 if ct == (len(line) - 1): b...
eea2df6d471e246ac23310fbe105278b3f2f0ad3
sreekanth-bg/python-snippets
/fact.py
160
3.953125
4
def fact(x): f = 1 for i in range(1,x+1): print (i) f = f * i return f if __name__=="__main__": print ("factorial of 3=",fact(3))
8f4e3985ec00c0cb6a6648f0cb0331b07dd39821
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/f6718608-eba5-4780-bcff-77117493b0ea__squareroot.py
285
4.25
4
#!/usr/bin/env python3 import sys def squareRoot(number): num1 = 1 num2 = 0.5*(1+int(number)) while abs(num1 - num2) > 0.0001: num2 = num1 num1 = 0.5*(num2 + int(number)/num2) return num1; print ("The square root of " + sys.argv[1] + " is " + str(squareRoot(sys.argv[1])))
8e041abfaffd99ae5d93c6a9c81fd795953b5219
sodrian/codewars
/kt17_the_highest_profit_wins.py
1,693
3.5625
4
"""Title: The highest profit wins! URL: https://www.codewars.com/kata/the-highest-profit-wins Description: ### Story Ben has a very simple idea to make some profit: he buys something and sells it again. Of course, this wouldn't give him any profit at all if he was simply to buy and sell it at the same price. Instead,...
79320fc872c2d778c86e07e3079b09674b2b486e
tashaylee/reddit-cmd-tool
/command_tool/RedditPost.py
2,240
3.984375
4
import json import requests """ This class represents all RedditPosts """ class _RedditPost: def __init__(self, url): self.__url = url self._response = self._get_response() """ Sends a request to reddit api. Returns: A json response. """ def _get_response(self): ...
c25b6e77e940951edeec10920213815baa285dd4
brianhaines/TreasuryCurve
/getCurveFromDB.py
674
3.71875
4
""" This will retrieve specified curves from the database. """ import sqlite3 import sys #Where is the DB located? str='' dbPath = [] #dbPath.append('/home/bhaines/Documents/HackerSchool/Python/XMLparse/') # This can be left out dbPath.append('curveDB') #without the path, this db is created in the current directory d...
1b32b7e7b390935275cf2bad95658567895bd32a
chris-jantzen/AI_AStar_And_BFS_Search
/priority_queue.py
1,088
3.796875
4
class PriorityQueue(object): def __init__(self): self.queue = [] def __str__(self): return " ".join([str(i.state) for i in self.queue]) def __iter__(self): return PriorityQueueIterator(self) def isEmpty(self): return len(self.queue) == [] def insert(self, node): ...
8b92651bc9f7027509ed43f4eef1cff35867b338
TomaszBorusiewicz/diet_algoritm
/test_diet.py
891
3.5
4
import diet_algoritm.diet import csv algoritms = diet_algoritm.diet.Algorithms("products.csv", 1000) # def test_get_sample_product(): sample_product = algoritms.get_product_from_csv(0) print(sample_product) all_ids = algoritms.get_random_product_from_csv() print(all_ids) # dieet = diet.Diet(100, 180, "male") # # # d...
32ff5b06cafd6ea5085fee431027ff639d85dae4
chintan8195/Leetcode-practice
/leetcode/395. Longest Substring with At Least K Repeating Characters.py
1,359
3.84375
4
""" Input: s = "aaabb", k = 3 Output: 3 The longest substring is "aaa", as 'a' is repeated 3 times. Example 2: Input: s = "ababbc", k = 2 Output: 5 The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times. """ # Solve using template from https://leetcode.com/problems/minimum-windo...
669563710a76da0b0965af59920ba5fa960381db
Alrin12/ComputerScienceSchool
/source_code/python/python_advanced/strings/bytes.py
129
3.671875
4
b = b"abcde" #print(b) #print(b.upper()) #print(b.startswith(b"ab")) #bytes -> string string = b.decode('UTF-8') print(string)
f042e349d08bdbfdda097be85169be066ba0d3e2
SkiAqua/CEV-Python-Ex
/exercícios/ex059.py
1,059
3.671875
4
from os import system from time import sleep def lin(txt): print(txt+'-'*(30-int(len(txt)))) opt = '0' chos = ['1','2','3','4','5'] lin('MenuPython') while opt != '5': opt = '0' st = int(input('Digite o primeiro número: ')) nd = int(input('Digite o segundo número: ')) lin('') while opt not i...
14cb42a62c095fe8472f8d743f5e35e847cc9f7e
doraemon1293/Leetcode
/archive/2593SumSmaller.py
712
3.625
4
# coding=utf-8 ''' Created on 2016?12?14? @author: Administrator ''' class Solution(object): def threeSumSmaller(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort() ans = 0 for i in xrange(len(nums) - 2): ...
a600370f288075d8a1d2899c4e293f4ab747715b
mdar4/Projetos_python_blue
/ProjetoJokenpo.py
2,408
3.78125
4
import random from time import sleep resp = None pedra = 'Pedra' papel = 'Papel' tesoura = 'Tesoura' jogador = 0 pc = 0 while True: while resp != 'N': rod = int(input('Número de Partidas: ')) for c in range(rod): pcEsc = [pedra, papel, tesoura] escolha = random.choice(pcEsc) print(''' ...
e7025e31895eeccac54f104704dbb04af6377c95
RePierre/metis
/pipeline/parsers/dictquery.py
738
3.515625
4
class DictQuery(dict): """Handles nested dictionaries Taken from https://www.haykranen.nl/2016/02/13/handling-complex-nested-dicts-in-python/ """ def get(self, path, default=None): keys = path.split("/") val = dict.get(self, keys[0], default) for key in keys[1:]: va...
499bd7ca5319401a02e54093c7bf5482ea224d9b
DaDudek/Monopoly
/board.py
2,651
3.96875
4
from banker import Banker class Board: """ This is a class for represent board on game - most of the logic need this class Attributes: player_number (int) : how many players play on this game (basic 4) """ def __init__(self, player_number=4): """ The construc...
7b73275902ecf6699da596aa8a7be8f870734f06
kipflip1125/client-server
/client.py
5,445
3.765625
4
# ******************************************************************* # This file illustrates how to send a file using an # application-level protocol where the first 10 bytes # of the message from client to server contain the file # size and the rest contain the file data. # ************************************...
f290f405ddcf7c10eb46fdbd89fafd0287d9bb18
pengboyun/project2
/Course1/class4homwork3.py
678
4.0625
4
class multiplication(object): def __init__(self): self.take_several_times = 0 def pithy_formula(self): x = 0 for x in range(1,self.take_several_times): y = ' ' for i in range(1, x+1): y = y + str(i) + '*' + str(x) + '=' + str(i * x) + ' ' ...
47bbbe57bf629dbe8df53f04eafe3e5c7316b530
diegoglozano/TFG
/Preprocesado/variablesOrdinales.py
256
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 6 11:06:32 2018 @author: diego """ import numpy as np import pandas as pd datos = pd.DataFrame([2,3,2,'NA','NA','NA',5,3],columns=['num']) datos[datos['num']=='NA'] = 0 print(datos)
ba09f26b67567f2fd2bf4f408ce7155d0b5679a1
acarcher/lmpthw
/ex7_grep.py
1,022
3.546875
4
# grep # get cmd line args # load the file # read the file into a list # iterate through the list searching for pattern # import argparse import re def parse_args(): ap = argparse.ArgumentParser() ap.add_argument("pattern", type=str, help="pattern to search for") ap.add_argument("file", type=str, help...
46113fa4f8ac25d943ca4616cc6468028bcfa3d5
Chinna2002/Python-Lab
/L4-Adding Two Sparse Matrix.py
2,527
3.765625
4
def add(A1,A2): sum = [] l1 = len(A1) l2 = len(A2) if l1==0 : sum = A2 if l2==0 : sum = A1 i = 0 j = 0 while l1>0 and l2>0: if A1[i][0]==A2[j][0] and A1[i][1]==A2[j][1]: sum.append([A1[i][0],A1[i][1],A1[i][2]+A2[j][2]]) i += 1 j += ...
06a961e0c70ff96c7779845a2dba179cd581f119
Pattriarch/100-apps
/100_apps/diff_3_of_10_Caesar_Cipher/Caesar Cipher.py
3,365
4.03125
4
from art import logo import time alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] # Function that encode and decode text def caesar(simple_text, shift_amount, directions): cipher_text = '' act = -1 # ...
0a08e49c443ac02f3a9667b6fd561d5693022d27
LQXshane/leetcode
/dp/buyNsellStocks.py
869
3.5625
4
# coding: utf-8 # Input: [7, 1, 5, 3, 6, 4] # Output: 5 # # max. difference = 6-1 = 5 (not 7-1 = 6, as selling price needs to be larger than buying price) # # # ## A variation of maximum subarray problem and can be solved using Kadane's algo # In[9]: import numpy as np class Solution(object): def maxProfit(s...
72128ea5fece59062505b46f046c880e97578eff
GeraldoLucas/Python_3.8
/fundamentals/ex032.py
572
3.78125
4
print('\033[1;33m === EXERCÍCIO 032 === \033[m') import datetime print('\033[1;46m-=-\033[m' * 10) print('\033[1;36mANO BISSEXTO, LEAP YEAR\033[m') print('\033[1;46m-=-\033[m' * 10) ano = int(input('\033[1mDigite o valor de um ano, digite 0 para o ano atual: ')) if ano == 0: ano = datetime.date.today().year ...
2d4ca925c1e20d810d4dfa2956e10ac2187831fc
gondsuryaprakash/Python-Tutorial
/Numerical/Prime Factor Of Number/PrimeFactorOfNumber.py
447
3.953125
4
import math def getPrimeFactor(n): arr = [] while n % 2 == 0: arr.append(2) n = n // 2 print(int(math.sqrt(n))) for i in range(3, int(math.sqrt(n))+1, 2): while n % i == 0: arr.append(i) n //= i if n > 2: arr.append(n) print(arr) return...
6fb7793831f074ea1aff6e9229e47aaccc98590d
srishtipandey06/Quiz-Hurdle-Race-Game
/Hurdle Jump Game/main.py
3,969
3.78125
4
import pygame from player import Player # Import our Player class from hurdle_handler import Hurdle_Handler WINDOW_SIZE = (720, 360) GROUND_Y = 280 def event_handler(): """ Returns all pygame events. Checks and handles the QUIT event. Returns: events (list): pygame events """ events = py...
1993a83cb8185c34f1fa7c3d09f3f39d5173599c
onestepagain/python
/函数/2_形参和实参.py
347
3.546875
4
# -*- coding: utf-8 -*- def greet(name): print(name) greet("libai") #复杂点的 #关键字实参 #可以指定传入参数的顺序 #使用默认值 def greet(name, gender = "female"): print(name) if(gender == "female"): print("nv") else: print("nan") greet("libai") greet("libai", "male")
e5e2cb8461cc1ad6eb177970312efb19e0ed2510
zwarshavsky/introtopython
/Exercises/ex_7.3/ex_7.3.py
609
3.734375
4
# Use the file name mbox-short.txt as the file name fname = input("Enter file name: ") try: fh = open(fname) except: if fname == "fuck you": print("got you, asshole") exit() else: print("unkown filename:", fname) exit() count = 0 f3 = 0 for line in fh: line = line.rstr...
99b32e824ab47b13b5de0a4b625f9583897aa05c
scientiacoder/ALG
/ALG/isSameTree.py
491
3.921875
4
# -*- coding:utf-8 -*- # __author__='' # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isSameTree(self, p, q): if p.val == q.val: return self.isSameTree(p....
e54874901ed785e33d41570701a6f38e5e08a543
Alpha-W0lf/Lambda-Expressions-Anonymous-Functions---Video-Notes
/lambda_functions.py
1,486
4.0625
4
# # This is a sample Python script. # # # Press Shift+F10 to execute it or replace it with your code. # # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. # # # def print_hi(name): # # Use a breakpoint in the code line below to debug your script. # print(f'Hi, {na...
3df2b980200f6a5a5546fd465617d4eecc335b7a
park-in-gwon/Python_Summary
/2_ 파이썬의 코어문법/2-4_ 예외처리/4-사용자정의예외,예외만들기.py
1,138
3.578125
4
# 직접 예외 처리 만들기 class KimDongError(Exception): pass try: word = input() if word == 'kimdong': raise KimDongError('오류입나이다') except KimDongError as e: print(e) """ 사용자 정의 예외: 파이썬에는 내장된 함수가 있으면 사용자 정의 함수가 있듯이, 내장된 예외(지금까지 사용했던 예외)가 있으면 사용자 정의 예외도 있다. 사용자 정의 예외는 클래스에 Exception 을 상속받아서 만들 수 있으며, 에...
7b6616890d9a8e78db0b7cda3a3e2cc67051a820
shivakarthikd/practise-python
/arrays/string_compress.py
1,314
3.640625
4
import collections def compress_string(st): c_dic=collections.defaultdict(int) c_str='' for i in st: c_dic[i]+=1 for key,val in c_dic.items(): c_str= c_str+ key + str(val) print(c_str) def compress_string_1(st): c_str='' c=0 while(c<len(st)): count=0 fo...
b887e7a548059fd919d74dc550df235a1cdfa9f9
mcloarec001/queens-puzzle
/Queen.py
1,106
3.96875
4
class Queen: _nb_conflicts = 0 line = 0 column = 0 def __init__(self, new_line: int, new_column: int): """Initiate a Queen object Args: new_line (int): value of the line position new_column (int): value of the column position """ self.line = new_...
91d278a8b16c3f22c70ebe829b8662088cb79f95
Maryville-SWDV-630/ip-1-kylekanderson
/Assignment.py
1,068
4.09375
4
# SWDV-630: Object-Oriented Coding # Kyle Anderson # Week 1 Assignment # Using Thonny, Visual Studio or command line interface expand on the Teams class defined as: class Teams: def __init__(self, members): self.__myTeam = members def __len__(self): return len(self.__myTeam) #...
85ccdd9e29f2242a01f1a8474a38fd45c1cc5e5e
BrantLauro/python-course
/module02/ex/ex068.py
929
3.875
4
from random import randint n = c = 0 while True: choose = '' pc = randint(1, 10) n = int(input('Type a number between 1 and 10: ')) if 1 <= n <= 10: choose = input('Even or Odd? [E/O] ').strip().upper()[0] if choose == 'E': if (pc + n) % 2 == 0: print(f'Pc ch...
2cb99b70438fe3fc8eef2f2a2944d34db9b96c8b
pawelkowalski88/poker_py
/pokerthegame/api/utils/dealer.py
2,444
3.75
4
import random from pokerthegame.api.utils import Card from pokerthegame.api.utils import Hand class Dealer: """Represents a dealer responsible for dealing and collecting cards. """ def __init__(self, table): """Initializes a new instance of the Dealer class with a reference to the main table. ...
94cb6d338cf04f9080184b3b67d1f182708ffeb4
jjcss/Python-Workshop-CSS
/FinishedProject/Python-Workshop/main.py
2,272
3.875
4
# import turtle from Screen from carManager import CarManager # import player from Player from turtle import Screen from player import Player # import car_manager from CarManager from carManager import CarManager # import scoreboard from Scoreboard from scoreBoard import Scoreboard # import time import time def main()...
8d69c58f3e7ea8aed88982fe0bb9883b2307400b
shekharpandey89/cursor-execute-python
/insert_record_execute.py
530
3.8125
4
#python insert_record_execute.py #import the library import mysql.connector # creating connection to the database conn = mysql.connector.connect( host="localhost", user="sammy", password="password", database="dbTest" ) mycursor = conn.cursor() # execute the query with their record value query = 'INSERT INTO...
1db179934e58fe6597e3746f4b90e0b91628956c
GeraldineE/Python
/EjemploDiccionarioPython/ejemploDiccionario.py
172
4.09375
4
nom={} print(nom) for i in range(5): nombre=input("Ingrese su nombre:") cedula=int(input("Ingrese su cedula:")) nom.update({nombre:cedula}) print(nom)
ea6c389ed39e5fb6f4096cb5101dd9c8cd5696a7
akabraham/practice
/cci/ch1.py
3,899
3.9375
4
from copy import deepcopy # 1.1 def is_all_unique(s): return sorted(set(s)) == sorted(s) # 1.1 def is_all_unique_no_special(s): """ Returns whether a string has all unique characters, without use of additional data structures. Assumes at least 1 character. """ ordered = sorted(s) for i, ...
3a1d1319869bf195731eef5fe9fedfd6ee934a9d
broepke/ProjectEuler
/009_special_pythagorean_triplet.py
714
4.15625
4
import time start_time = time.time() # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which # # a2 + b2 = c2 # For example, 3^22 + 4^2 = 9 + 16 = 25 = 5^2. # # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. def pythag(a, b, c): if a ** 2...
6b9287965daee6845d715d792572e9d6eeb1ed51
lradebe/Practice-Python
/count_occurances_of_string_elements.py
293
4.1875
4
def count_occurances_of_list_element(List,element): """count occurances of a specific element in a list""" count = 0 for i in List: if i == element: count += 1 print(count) List, element = [1, 2, 3, 4, 5, 5], 5 count_occurances_of_list_element(List, element)
82fe749dc68cc9d3d2711078ba791b05030987a5
Nancuharsha/ML
/mymlfolders/sixteenth.py
2,075
3.78125
4
#libraries to load into the program import numpy as np from sklearn.cluster import MeanShift import pandas as pd #Loading Data using pandas libirary df = pd.read_csv('Deduplication Problem - Sample Dataset.csv') #placeing missing data with 0 df.fillna(0,inplace=True) #Function to convert non-numerical dat...
992a0a13034760db5a7e74e97e7c4381b5578479
zhangray758/python-final
/day03_final/3-func.py
1,800
3.859375
4
# Author: ray.zhang #有参函数:传参 先定义后调用 def my_max(x,y): if x > y: print(x) elif x < y: print(y) my_max(2,3) #直接打印结果 res=my_max(2,3) #先执行my_max 打印操作出结果,后赋值。 print(res) # 没有return,结果为NONE,等同于return None #因此怎么样能够拿到函数的结果呢?用return,上面的可以改写为: def m_max(x,y): if x > y: ...
bd8d4ac8d21f46f51bb65f8eb69e6aec1f70030a
jeff-ali/deliverable
/billsearch-with-asterisks.py
2,892
3.78125
4
import os import sys import re from xml.etree import ElementTree from zipfile import ZipFile def bill_search_asterisk(regular_expression): """ This method will unzip the Data Engineering Deliverable file and scan the XML files for a regex match. It will return a list of bills that match the regex along w...
4965a4b329afd354418f264c4665ddeb6c6391ea
ftpatrick/bensk.github.io
/Battleship.py
598
4.03125
4
# Create a variable board and set it equal to an empty list. board = [] board = [] for x in range(0,5): board_list = ["O","O","O","O","O"] board.append(board_list) print board # Exercise 5 board = [] for x in range(0,5): board_list = ["O","O","O","O","O"] board.append(board_list) def print_board(...
28a0206bac0d6be587321c3acadadb60c213785f
JSAbrahams/mamba
/tests/resource/valid/control_flow/for_statements_check.py
423
3.734375
4
b: set[int] = {1,2} for b in b: print(b + 5) new: int = b + 1 new = 30 print(new) e: set[int] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} for d in e: print(d) print(d - 1) print(d + 1) for i in range(0, 34, 1): print(i) for i in range(0, 345 + 1, 1): print(i) a: int = 1 b: int = 112 for i...