blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
52017324a577c708e9f4398a07225f1bcc558249
xhmmss/python2.7_exercise
/codewars/Highest_and_Lowest.py
898
4.15625
4
# In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. # Example: # high_and_low("1 2 3 4 5") # return "5 1" # high_and_low("1 2 -3 4 5") # return "5 -3" # high_and_low("1 9 3 4 -5") # return "9 -5" # Notes: # All numbers are valid Int32, no ...
71c556bfb2f229829b709d43710647e867f6c499
xhmmss/python2.7_exercise
/liaoxuefeng/list_tuple.py
226
3.703125
4
classmates = ['Michael', 'Bob', 'Tracy'] classmates.insert(1,'Jack') classmates.pop() print classmates d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} d.pop('Bob') print d s = set([1, 1, 2, 2, 3, 3]) s.add(4) s.remove(1) print s
0755152309220626c10382ed0db8b8441e025135
xhmmss/python2.7_exercise
/codewars/Bit_Counting.py
410
4.15625
4
# Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. # Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case def countBits(n):...
3b3bed7bfa08fe0a09872685983205d8156bef99
marinagbastos/Capstone-Project
/Exercise 1_Segmenting and Clustering Neighborhoods in Toronto.py
903
3.65625
4
#Importing table from HTML import requests import pandas as pd url = 'https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M' html = requests.get(url).content df = pd.read_html(html) df_canada = df[0] #Ignoring cells with a borough that is Not assigned df_canada = df_canada.drop(df_canada[df_c...
1792ebb96ef27f498c420ff8fb0f81189d1c8766
manaswisubramanyam/python
/demo11.py
334
4.09375
4
no=[] even_sum=0 odd_sum=0 n=int(input("enter number of list elements")) for x in range(1,n+1): value=int(input("enter %d element:" %x)) no.append(value) for j in no: if(j%2==0): even_sum=even_sum+1 else: odd_sum=odd_sum+1 print("number of even numbers",even_sum) print("number of odd num...
6f4f9575d61d8467fad85a82bd3ed6fa53bda928
ZESop/PythonTest-zesop-
/noob/map.py
1,619
3.65625
4
from functools import reduce # def f(x): # return x*x # r=map(f,[1,2,3,4,5,6,7,8,9]) # for n in r: # print(n) # m = list(map(str,[1,2,3,4,5,6,7,8,9])) # print(m) # def add(x,y): # return 10*x+y # print(reduce(add,[1,2,3,4,5,6])) # def char2num(s): # digits = {'0':0,'1':1,'2':2,'3':3,...
f4cae506b5e07907cff7e0a7b382264f3a26971e
DevRyu/random_mv_score_maker
/RandomMVScore0.1.py
1,075
3.5625
4
import random import csv # 평점 : 1~10 난수 # 사람 : 행 # 영화 종류 : 열 # 이중리스트로 결과값을 출력합니다 # 수정 배포 자유입니다. 출처만 남겨주세요 def ranmake (x,y): row = [] #열(겉의리스트) for i in range(x) : col = [] #안의 리스트 col.append([random.randint(1,10) for k in range(y)]) #난수 생성 내장 랜덤함수는 리스트로 출력되서 밑에처럼 풀어줘야함 # .sample()은 유니...
504df53f1efe7f9c442202e6c07a86e9828c303f
ntoliverapp/pong-game-py
/pong-game.py
3,324
3.59375
4
import turtle as t player_one_score=0 player_two_score=0 window=t.Screen() window.title('Ping-Pong Game') window.bgcolor('#162521') window.setup(width=800,height=600) window.tracer(0) #creating left paddle left_paddle=t.Turtle() left_paddle.speed(0) left_paddle.shape('square') left_paddle.color('#c0e0de') left_padd...
62b0372df82e9f6d391a54cf43e231461358461f
hongcong0715/py2702
/day14_0305/text_info.py
1,516
3.53125
4
def login_check(username=None, password=None): """ 登录校验的函数 :param username: 账号 :param password: 密码 :return: dict type """ if username != None and password != None: if username == 'python27' and password == 'lemonban': return {"code": 0, "msg": "登录成功"} else: ...
b3bd9f19e9929fc9ea635de928c9f39d695d3c5c
zxxixixi/python_study
/ceshi.py
1,047
3.84375
4
#!/usr/bin/python3 # Fibonacci series: 斐波纳契数列 # 两个元素的总和确定了下一个数 # a, b = 0, 1 # while b < 10: # print(b) # a, b = b, a+b # list=[1,2,3,4] # it =iter(list) # print(next(it)) # import sys # list=[1,2,3,4] # it =iter(list) # while True: # try: # print(next(it)) # except StopIteration: # sys.exit() #用类方...
637392eabaf25ab9e69ef1308f605284af3ef3f5
Rohan1215/DataStructuresAndAlgorithms
/Algorithms/binary_search.py
698
3.53125
4
# Uses python3 import sys def bs(a, x): l, r = 0, len(a) i=r//2 while(x!=a[i]): if(x>a[i]): l=i elif(x<a[i]): r=i i=l+((r-l)//2) if(r-l==1): if(a[l]==x): return l return -1 return i def linear_search(...
7bf7ac88c272f95f2a5b493a7586f78a0ab482cd
ContentsViewer/Python-stdlib
/db/fdependency_list.py
4,170
3.5625
4
from .fdependency import FDependency from itertools import combinations class FDependencyList(list): """ Functional dependency list class Example: fd1 = FDependency(['A','B'],['C']) fd2 = FDependency(['B'],['D']) fd3 = FDependency(['A','B','E'],['C','D']) fd4 = FDependency(['C...
dde9341c8ae5ac69a0f3f1fe3caef774161b6ca2
wudanny/Numerical_Analyzes_Functions--
/Interpolating_And_Spline.py
4,651
3.59375
4
import math from math import * #################### def factoringL(basis,i): #L[n][0] is the exponent and L[n][1] is the coefficient of the polynomial L=[[0.0,1.0]] for n in range(len(basis)): if(n != i): temp=copyList(L) for exponent in range(len(L)): ...
16a40d8c9e1dad82d183a8d05d93d8ee0a8b050d
sonikasahoo/Competitive-Programming-Algos
/sorting_dictionary_without_using_built-in func.py
551
4.0625
4
#sorting dictionary in ascending order without using buil-in functions d={} c=int(input("Enter number of values : ")) while(c!=0): key=int(input("Enter key : ")) val=int(input("Enter value : ")) d[key]=val c-=1 d_asc={} #low_key=0 print("Before sorting : ",d) for i in range(len(d)-1): lo...
37eff5bd1fffed3e3aa29dc0a476d8f334bb1f4b
ashishkashinath/Grad_School_Courses
/CS461_ECE422/MP References/stevenchiu30801/UIUC-Computer-Security-master/mp1/files/sol_1.1.2.4.py
670
3.75
4
import sys import math def main(): if len(sys.argv) != 5: print "Incorrect number of arguments" print "usage: python %s <ciphertext_file> <key_file> <modulo_file> <output_file>" return ''' open files ''' with open(sys.argv[1]) as ciphertext_file: ciphertext = ciphertext_file.read().strip() with open(sys....
0b013ea3f5c9e95b7b8591a7ff6a63b78af63dc4
AroopN/Design-1
/Problem1.py
2,308
3.78125
4
# // Time Complexity : O(N/Size) for all operations # // Space Complexity : O(N+Size) # // Did this code successfully run on Leetcode : No, got TLE # // Any problem you faced while coding this : Got TLE for separate chaining class Node: def __init__(self,key,value): self.key = key self.value = val...
56878aa8bb147f157d5463bc5436524a7bd4d833
suyashbatham/timezone
/Time Zone Challenge.py
1,081
3.515625
4
import datetime import time import pytz available_zones = {'1':'Africa/Tunis', '2':'Asia/Kolkata', '3':'Austraila/Adelaide', '4':'Europse/Brussels', '5':'Europe/London', '6':'Japan', '7':'Pacific/Tahiti', ...
44306f1c153fc23eae0df5070e49b8e704a1191f
deenababu92/-Python-Basics-Conditional-Loops
/assigntment 1 Python Basics, Conditional Loops.py
999
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: """1.Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line.""" n=[] for i in range(2000,3201): ...
f3ef879ac82cd55d50d1450ebc8b004af58cdae5
SomtirthM/HackerRank-Solutions
/TheMinionGame.py
456
3.6875
4
def minion_game(string): # your code goes here S=string.strip() S_length=len(S) plr1,plr2 = 0,0 for i in range(S_length): if S[i] in 'AEIOU': plr1 +=S_length-i else: plr2 +=S_length-i if plr1>plr2: print("Kevin",plr1) elif plr2>pl...
8405cea329bb593346cf4d50d004786b8d46c513
rajpathrecalls/nitcaa_forms
/dataprocess.py
952
3.6875
4
#val=input("Enter thing to be searched ") def search(val): f=open("datas.csv") lines=f.readlines() notset=True ar=[] for line in lines : if notset: temp="" for i in line : if i== '\t': ar.append(temp) temp="" ...
2193e59edd950d2420dc6aa64d8f88c443a61db7
kanishk2509/TwitterBotDetection
/ApproachV3/src/metrics/GenerateTwitterMetrics.py
14,424
3.703125
4
""" This file gets the times of all tweets of an user and then generates a binned array based on the time of tweets """ from collections import Counter import numpy as np def generate_binned_array(tweet_times): """ The tweet times array gives the times of each of the users tweets :param tweet_times: The...
2ef8fa1ed308de1a7fd934be7f9a90b657e725cd
ramsharma-prog/zoo_simulator
/simulator.py
4,494
3.90625
4
import tkinter as tk from math import floor from random import uniform from species import Monkey, Giraffe, Elephant, species window = tk.Tk() window.config(background="gray") # --------------iteration time in milliseconds-----------------# ITERATION_TIME = 3000 # ---------------------formatted time--------------...
5c90a75cabee2d3fc4eacc050f0964adc6152d99
gitcommituser/cs461
/NeuralNetSolution.py
9,198
3.78125
4
import numpy as np import scipy.io as so import scipy.optimize as opt ##### Function Definitions ################################################################# def costFunction(nn_params, *args): input_layer_size, hidden_layer_size, num_labels, X, Y, lambd = args[0], args[1], args[2], args[3], args[4], args[5]...
e30bcae28e5342bf32834d8c5a6bf570674fbe2e
AdamAndrei/algorithms-and-programming-course
/lab8/domain/CustomerCardValidator.py
4,124
3.765625
4
from domain.CustomerCard import CustomerCard from exception.InvalidCNPException import InvalidCNPException from exception.InvalidCustomerCardException import InvalidCustomerCardException class CustomerCardValidator: @staticmethod def validate_customer_card(customer_card: CustomerCard): """ Fun...
c6812dcd2707a5ec181d6e42b61d89d912bae681
AdamAndrei/algorithms-and-programming-course
/lab 3/another.py
754
3.875
4
import copy def read_n(): n = int(input("n =")) return n def read_matrix(n): a = [] for index in range(n): b = int(input("elment = ")) a.append(b) return a def max_product(list): list_two = [] lista = copy.deepcopy(list) a = 0 b = len(list) for i in range(b)...
6acff793588c281678a4eed04c8a6996888dadaa
AdamAndrei/algorithms-and-programming-course
/lab 3/business/Logic.py
3,679
3.609375
4
from .Domain import * def add_object_dictionary(list_of_objects, one_object): """ Description: Add an object to inventory :param list_of_objects: list :param one_object: list :return: A list of objects """ list_of_objects.append(one_object) def remove_object_dictionary(list_of_objects, I...
d91df76a0f6e21a47862e942668774e14698ebef
AdamAndrei/algorithms-and-programming-course
/lab 3/ALARM_CLOCK/L3 P16.py
1,160
3.671875
4
""" Description: -citeste o lista de numere intregi Out: -o lista de numere intregi """ def read_list(): n = int(input("Number of elements= ")) lista = [] for index in range(n): aux = int(input("\t x = ")) lista.append(aux) return lista """ Description: -af...
5fee77d1f0524e43319b4bd0e36f0fb91104c4c6
AdamAndrei/algorithms-and-programming-course
/lab 3/L3 P4.py
3,220
3.734375
4
def read_list(): n = int(input("Number of elements= ")) lista = [] for index in range(n): aux = int(input("\t x = ")) lista.append(aux) return lista def print_list(list): length = len(list) for index in range(length): if index == (length - 1): print(list[i...
55a86ded217d4435aa4d6474be63a9351f10ea6e
AdamAndrei/algorithms-and-programming-course
/lab 3/business/Main.py
3,181
3.921875
4
from .Test import * def print_menu(): print("1 - Add object") print("2 - Remove object") print("3 - Update object") print("4 - Move object from one place to another") print("5 - Add a string to the objects description with a higher price than a given number") print("6 - Determine the highest pr...
d8130312301efeb28ede9f9c9fc44b45d348caa6
AdamAndrei/algorithms-and-programming-course
/domain/experiment.py
6,948
3.71875
4
# x = input("x = ") # y = input("y =") # if y in x: # print("da") # else: # print("nu") # # # def to_string(a, b, c, d, e): # return "{},{},{},{},{}".format(a, b, c, d, e) # # def a(): # if 'asd' in to_string(1, "asd", "d", "1", 2): # return "da" # else: # return None # # # print(to_...
2980d7a3dad505310bf6623c363ab3215e949a27
AdamAndrei/algorithms-and-programming-course
/lab 3/ALARM_CLOCK/L3 P4 new.py
3,548
4.03125
4
def read_list(): n = int(input("Number of elements= ")) lista = [] for index in range(n): aux = int(input("\t x = ")) lista.append(aux) return lista def print_list(list): length = len(list) for index in range(length): if index == (length - 1): print(list[i...
0123c68cc68d74b29b5c1e7c91d7b3837b3a6632
AdamAndrei/algorithms-and-programming-course
/lab8/domain/MedicineValidator.py
1,438
3.515625
4
from domain.Medicine import Medicine from exception.InvalidMedicineException import InvalidMedicineException class MedicineValidator: @staticmethod def validate_medicine(medicine: Medicine): """ Function verify if an object respects some conditions and if it finds an irregularity raise an exce...
2fff3c93600fb832fc481695497b68653957d79a
nvg/ml_sandbox
/ml-supervised/SVM.py
4,734
4.03125
4
#!/usr/bin/env python # coding: utf-8 # # Support Vector Machines # # SVMs are a method that uses points in a transformed problem space that best separate classes into two groups: # * Find hyperplanes that correctly classify the training data # * Pick the one that has the greatest distance to the points closest to it...
3c0578cca5584c4cbc44002976132d01fc3b14e7
sharifh530/Learn-Python
/Beginner/Data types/12.list_slicing.py
357
4.40625
4
# List slicing is also work as a string slicing li = ["work", 5, "dinner", True] print(li) # Reverse print(li[::-1]) # String is immutable but list is not immutable we can change the values of list li[0] = "sleep" print(li) # Copy list li1 = li[:] li1[1] = "work" print(li) print(li1) # modify list li1 = li ...
614059899816b8059c60b24cf31ade9272bdeb07
sharifh530/Learn-Python
/Beginner/Data types/8.built_in_functions.py
143
3.78125
4
# len - Length of strings greet = "hellooooooooooo" print(len(greet)) print(greet.upper()) print(greet.capitalize()) print(greet.find("ll"))
1e07a9ff0fa5669f2596f188d4f716f183e07e3d
sharifh530/Learn-Python
/Beginner/Data types/3.augmented_assignment_operator.py
134
3.640625
4
some_value = 5 some_value = some_value + 5 print(some_value) some_value += 5 print(some_value) some_value -= 5 print(some_value)
d9c8e4793c3c82dedf5b9e6a80cb9aaa18601b5a
317295869/THC
/OK/OK-Python/Hackerrank/HackerTank.py
1,195
3.78125
4
# !/usr/bin/python3.6 # # Eduardo Alexis Valencia Dorantes # Python 3.6.8 # # cantidad_bugs=input() #import sys #nivel_bugs = str(sys.stdin.readline()) nivel_bugs=str(input()) nivel_bugs=nivel_bugs.split() mi_nivel=1 vida=10 vida_bandera=vida contSubirNivel=0 perdedor=0 contBugs=0 for bug in n...
5688bb7c10d731ec597cb27b18b7e8f44c1c1567
317295869/THC
/Python/Sumas.py
335
3.71875
4
# !/usr/bin/python3.7 # # Eduardo Alexis Valencia Dorantes # # # # def sumaI(n): """ """ r = 0 for i in range(n+1): r+= 1 return(r) def sumaG(n): """ """ return( n*(n+1) )/2 def sumaR(n): """ """ if (n==1): return(1) else: return( n + sumaR(n-1) ) print(s...
ec6bc71210f5531bf04c01e91300b7ebab4a9290
317295869/THC
/Python/ASEFE_PBS01.py
2,828
3.84375
4
#Valencia Dorantes Eduardo Alexis #29/10/19 # #Evaluación práctica """A partir de un rectangulo de base x y altura 1 definiremos la raíz cuadrada\ de un número cualquiera que sea mayor a cero""" print('x = 81') """bases=[] alturas=[] b=81 x=b h=1 print(" rectangulo b h") print(" 0 %.2f %.2f"%(b,h)...
14dfb5946985d0ca3af59d88f047a2160b8cc22b
317295869/THC
/OK/OK-Python/pelota02.py
441
3.8125
4
# !/usr/bin/python3 # Eduardo Alexis Valencia Dorantes # python 3.5.3 # 10/09/2019 # 12/09/2019 # # Calcula la posicion de una pelota con una velocidad inicial # de 5 m/s y un tiempo de 0.6 segundos v0 = 5 g = 9.8 t = 0.6 y = v0*t -0.5*g*t**2 print(y) print('En el tiempo t=%g segundos, la altura de la pelota es %.2f ...
d5db350a4be97d80f310e33b037296cfe9690313
317295869/THC
/Python/test.py
164
3.515625
4
from math import sin x=[7,8,17,28] y=[] for x in range(len(x)): y.append(sin(x)) print('{3}{0:2d}{3} {3}{1:3d}{3} {3}{2:4d}{3}'.format(x,x*x,x*x*x, '|'))
ad8a34542575a529b4c5ab95465f76130ddedf97
itepifanio/dataStructures
/linguagemProgramacao/lpII/avaliacaoLP2/pascal/recursive.py
570
3.515625
4
from sys import argv from contextlib import redirect_stdout def bin_coeff(n , k): result = 1 if(k > (n - k)): k = n - k for i in range(k): result *= (n - i) result = result // (i+1) return result if __name__ == "__main__": n = int(argv[1]) k = int(argv[2]) with open("triangle.out", "w", encodin...
224fd7ead9a0a08e98fe92aba0ff5adef49aebd1
itepifanio/dataStructures
/linguagemProgramacao/lpII/heranca/ex2.py
1,231
3.859375
4
class Figura: pass class Quadrado: def __init__(self, l): self.l = l def __repr__(self): return "Quadrado: {}".format(self.l) def calcularArea(self): return self.l**2 class Retangulo: def __init__(self, l, h): self.l = l self.h = h def __repr__(self):...
13f9903a2bbeced71d5eed2ae20663cfc1f64495
itepifanio/dataStructures
/linguagemProgramacao/lpII/heranca/ex1.py
796
3.65625
4
class Ponto2d: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "{}, {}".format(self.x, self.y) @property def x(self): return self.__x @x.setter def x(self, x): self.__x = x @property def y(self): return self.__...
2458194407c19ef69a8c995a2458d8dcb55319da
nampng/self-study
/python/CTCI/Chapter1/p1-5.py
1,544
4.09375
4
# 1.5 One Away # There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. # Given two strings, write a function to check if they are one edit (or zero edits) away. # Example # pale, ple -> True # pales, pale -> True # pale, bale -> True # pale, b...
7fa5f74a0d5e8aa4638604cc2b5f3ebd98fe9eef
nampng/self-study
/python/CTCI/Chapter4/p4-6.py
2,974
3.984375
4
# Problem 4.6 Successor # Write an algorithm to find the "next" node of a given node in a binary search tree. # You may assume that each node has a link to its parents. # 5 # 3 7 # 2 4 6 9 # 8 10 # if 3 is the chosen node, then the next successor is the right child. # this is beca...
408c67ca59f204f60c847e8de22c9cbfa5d44a55
nampng/self-study
/python/CTCI/Chapter4/p4-4.py
1,343
4.0625
4
# 4.4 Check Balanced # Implement a function to check if a binary tree is balanced. class TreeNode: def __init__(self, val): self.value = val self.left = None self.right = None def CheckBalanced(node): q = [node] while len(q) > 0: current = q.pop(0) print(f"Current i...
a890d305695336c1d5d8bd65a8fcd5659dd10d41
nampng/self-study
/python/CTCI/Chapter1/p1-7.py
576
4.3125
4
# 1.7 Rotate Matrix # Given an image represented by an N x N matrix, where each pixel in the image is # represented by an integer, write a method to rotate the image by 90 degrees. # Can you do this in place? # Super uneligant. Must optimize and also find a way to do it in place. def Rotate(image): array = [] ...
c39e15811691425717410b17eca58227f72f16a2
tiwarinaman/Data-Structure
/searching in linked list.py
1,236
3.953125
4
class node: def __init__(self,data): self.data =data self.next = None class LinkedList: def __init__(self): self.start = None def inertLast(self,value): new_node = node(value) if self.start == None: self.start = new_node else: ...
515840bc7e65a61accebb0ed5006e156031078f1
tiwarinaman/Data-Structure
/Infix to postfix.py
1,151
3.671875
4
class stack: def __init__(self): self.item = [] def isEmpty(self): return self.item == [] def push(self,value): self.item.insert(0,value) def pop(self): return self.item.pop(0) def peek(self): return self.item[0] def infixToPostfix(s): pr = {...
306c5243319a16bb8664b5ab2a65b82785a24731
ikmalpani/Python-Practice
/Object-Oriented-Design/parking_lot.py
2,785
3.875
4
# Design a parking lot. class Vehicle(): def __init__(self, license_plate): self.license_plate = license_plate def get_spots_needed(): return self.spots_needed def get_size(): return self.size def can_fit_in_spot(): return True class Car(Vehicle): def __init__(self, license_plate, spots_n...
3fd2c6a37b9aced4129c3c365d5406530d5028f0
SennaLippens/python3-1
/python3 lesbrief 1.py
805
3.6875
4
bedrijven = {"Apple": "Steve Jobs", "Microsoft": "Bill Gates"} print("hier komt de maken van apple") print(bedrijven["Apple"]) print("hier komt de maker van apple") print(bedrijven["Microsoft"]) print("") print("dit is opdracht 3") print(bedrijven.keys()) print("") print("nu komt opdracht 2") del bedrijven["Apple"] f...
5370472c113765a593cad38cb9e3cb44b52f1d1a
allenfrostline/Tetris-AI
/heuristic.py
3,267
4.28125
4
"""These heuristics attempt to assess how favourable a given board is. The board should already have the dummy 23rd row stripped out. When the heuristic says "block" it means one individual cell of a stone. How you weight the different heuristics is up to you. Most are designed to indicate bad things, and so should ha...
ce8e3b0e331041bae31e96816d2b6dc7688d4afe
Shally-bingqing/Quantemol-project
/Janaf/mySpider/spiders/tools.py
2,606
3.765625
4
# coding=UTF-8 import xlrd import xlwt from xlutils.copy import copy # Modify (append write):xlutils import os ##ref # https://blog.csdn.net/u013250071/article/details/81911434 def write_excel_xls(path, sheet_name, value): index = len(value) # Gets the number of rows to write to workbook = xlwt.Workbook() ...
4a66e96456065efd2dd42b8e0aa5326982ab310a
mkocka/galaxytea
/spectrum/novosad/spectrum.py
4,189
3.6875
4
import matplotlib.pyplot as plt import matplotlib import numpy as np import math import scipy ### fct - function ### a - left point of interval ### b - right point of interval ### N - number of steps ... for Simpson rule N must be odd!!!! ##################### declaration of integration methods #########...
6154c9d9f9b5b1606b7fb9daadfac5bec2660bc0
Eunovo/EvenMorePizza
/scorer.py
651
3.765625
4
def get_score(deliveries): sum = 0 for delivery in deliveries: ingredients = set() for pizza in delivery: for ingredient in pizza: ingredients.add(ingredient) sum += (len(ingredients) ** 2) return sum import unittest class TestScorer(unittest.TestCase...
fa8210f1b2f1f794b1e45c4b85864450b02c53f7
UlisesBrunoLozano/privatr
/ulises/Laboratorio 1/ejercicio6.py
648
3.9375
4
peso=input("kilogramos") altura=input("metros") def masacorporal(peso, altura): return peso/altura**altura if masacorporal<16: print "Delgadez" elif masacorporal<99 and masacorporal>16: elif masacorporal>16 and masacorporal<19.99 print "Delgadez moderada" elif masacorporal>17 and m...
62263bc7bc799adb500bae6ce8a5943300cb6c2a
UlisesBrunoLozano/privatr
/ulises/funciones.py
265
3.84375
4
#Importar librerias en Python import math #Calcular el area de un circulo radio=6 Areacirculo= math. pi* math. pow(radio,2) print Areacirculo cuenta=0 x=30 if(x%2==1): x=3*x+1 print x cuenta=cuenta+1 else: x=x/2 print x cuenta=cuenta+1
8b333e9fbfccbc586526296ed9a5fbf849e38cb0
phani-1995/bridgelabzMumbaiWeek1
/testingprograms/Monthly_payment.py
339
3.953125
4
def monthly_payment(P, Y, R): n = 12 * Y # years to months rate = R / (12 * 100) payment = (P * rate) / (1 - ((1 + rate) ** (-n))) print(payment) P = int(input("Enter the principal loan amount: ")) R= int(input("Enter the rate of intrest: ")) Y = int(input("Enter the time period in years: ")) monthly...
0053c1ad24ed7f0443333f1fc41b78bc3eb5d46a
phani-1995/bridgelabzMumbaiWeek1
/testingprograms/sqrt.py
952
4.28125
4
# import math def sqrt(c,epsilon): t=c while abs(t - c/t) > epsilon*t: t= ((c/t)+t)/2 return t epsilon=1 * 10 ** (-15) c=int(input("Enter a positive integer: ")) if (c<=0): print("number cant be negative or zero") c = int(input("Enter a positive integer: ")) print("Square root of number ...
fe072c018bb41dafa80891d096d50af4667de6c7
phani-1995/bridgelabzMumbaiWeek1
/review Question/gambler11.py
427
3.59375
4
import random def gambler(stake,num_of_days): bet=1 win=loss=temp=0 for j in range(1,num_of_days): if (random.random()>0.5): win=win+1 stake=stake+bet if stake == stake // 2: break else: loss=loss+1 stake...
37b0554e47a1740a2d42db133ccba5b380938085
jordanpippen23/python_work
/matplotlib/examples/colormapnorms.py
2,223
3.9375
4
""" Colormap Normalization ====================== Objects that use colormaps by default linearly map the colors in the colormap from data values *vmin* to *vmax*. For example:: pcm = ax.pcolormesh(x, y, Z, vmin=-1., vmax=1., cmap='RdBu_r') will map the data in *Z* linearly from -1 to +1, so *Z=0* will give a co...
b0f6e1326d0121a2433b61250ce48c89d5cfdbc3
LKian/Staircase
/staircase.py
190
3.96875
4
step = raw_input("What character do you want to use for the steps?\n") levels = input("How many floors do you like to build? \n") floor = 1 while floor <= levels: print step*floor floor+=1
f6a14cef4d9854c5cf048d468e4f2730fb06dd3f
cbohara/python_cookbook
/data_struct_and_algos/dict_comprehension.py
353
3.734375
4
#!/usr/local/bin/python3 prices = { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75 } high_price = {key:value for key, value in prices.items() if value > 200} print(high_price) tech_names = {'AAPL', 'IBM', 'HPQ', 'MSFT'} tech = {key:value for key, value in prices.items() i...
d0729c034ef8e31fe6f21d548c605306401aa831
cbohara/python_cookbook
/data_struct_and_algos/sort_list_of_dict.py
1,064
4.03125
4
#!/usr/local/bin/python3 from operator import itemgetter # let's say we have queried the database table to get a list of dictionaries that rep each member rows = [ {'fname': 'Brian', 'lname': 'Jones', 'uid': 1003}, {'fname': 'David', 'lname': 'Beazley', 'uid': 1002}, {'fname': 'John', 'lname': 'Cleese', 'u...
0553ece5f820a254e1dafb9d7da48b498bf70609
cbohara/python_cookbook
/data_struct_and_algos/countdown.py
371
3.984375
4
class Countdown: def __init__(self, start): self.start = start def __iter__(self): n = self.start while n > 0: yield n n -= 1 def __reversed__(self): n = 1 while n <= self.start: yield n n += 1 if __name__ == '__main__': countdown = Countdown(5) for number in countdown: print(number) ...
65c7ab612f9546a57e475e8c93fe9feadf4eb33d
cbohara/python_cookbook
/data_struct_and_algos/counter.py
788
4.375
4
#!/usr/local/bin/python3 from collections import Counter # determine the most frequent occuring item in a sequence words = [ 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes', 'lo...
b9948c5cf0d45c22a367c5180149b5576bc0ab23
tillahoffmann/opinion_dynamics
/edge_simulation.py
6,306
3.53125
4
__author__ = 'tillhoffmann' import numpy as np import networkx as nx def simulate(graph, initial_balls, num_steps, output='steps', control=None, **kwargs): """ Generates a step sequence `S[t, :]` of prior updates. Each row of `S` represents one time step. At time `t`, node `S[t,0]` transfers a ball of col...
9d6c3cd7c9bdc0c0a87177e04798451f627f7883
ShonnyAIO/red-social-backend
/upload/users/tME1qkPTdly2Cf1JwgzAALy_.py
1,173
3.859375
4
# Ejercicio 7 facturas = {} # ID, Monto cobro = 0 deudas = 0 while(True): print("----------------------------") print("Facturas Pendientes:", cobro) print("Montos acumuladas:", deudas) print("----------------------------") print("1) Ingresar una factura") print("2) Pagar una factura") ...
efa05b38ae0ca3eee2125c236a2b4223f2e7b333
alanx3x7/LeetCode
/0010_Regular_Expression_Matching/TrueRegularExpressionAccident.py
822
3.546875
4
# Accidentally implemented the real regular expression class Solution: def isMatch(self, s: str, p: str) -> bool: if s == p or p == "*": return True while not p == "": literal = p[0] if literal == ".": return self.isMatch(s[1:], p[1:]) ...
a590ad2c64004662cceed2b509b6b55ce885ddc9
joncurrier/generations
/3-Django/app/recipes/utils.py
2,816
4.21875
4
def format_duration(duration): """ Format a timedelta to be human-readable. Argument Format example < 1 minute "55 seconds" < 5 minutes "3 minutes" OR "3 minutes and 15 seconds" < 1 hour "17 minutes" else "2 hours and 14 minutes" """ if durati...
d21ad4188b577145b28a76fe578e515161ae29aa
dpwls64/homework
/0708_tot.py
719
3.59375
4
import sys l = [] for i in range(10): print(i+1,"]", end = " ") l.append(int(input("Input Number : "))) def my_max(list): max_val = list[0] for j in range(10): if list[j] > max_val: max_val = list[j] return max_val def my_min(list): min_...
056ce2986ce16c65f4664ed4592edacc09d7ffa9
sadsfae/misc-scripts
/python/currency.py
1,056
3.578125
4
#!/usr/bin/env python #-*- coding: iso-8859-15 -*- # simple script to convert Czech and US currency # I don't like having to hit a website for this # This may turn into a better flask app later (with all currencies via API) # For now let's just smash it with a hammer # 1 czk = .051 USD # 1 USD = 19.30 czk import os im...
c98a68b64296f59da92b4cf1d1ee7c3700f82318
sadsfae/misc-scripts
/python/hugs.py
1,295
4.25
4
#!/usr/bin/env python # everybody needs hugs, track it using a dictionary # simple exercise to use python dictionary import sys # create blank dictionary of hug logistics huglist = {} # assign people needing hugs as keys huglist['wizard'] = 5 huglist['panda'] = 1 huglist['koala'] = 2 huglist['tiger'] = 0 huglist['mo...
20a3e51cf4e7a9b394b7b5ccc82ba9d33d79b8a4
borisghidaglia/problem-solving
/Daily_Coding_Problem/Facebook/7_encoded_message.py
991
4.09375
4
"""This problem was asked by Facebook. Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'. You can assume that the messages are decodable. For example, '001' is...
57f833f9a44f0500f71374e0e558880d851a77f5
antedeguemon4428/Calculadora
/calculadora.py
814
4.0625
4
# Criando a CLASSE calculadaro class Calculadora: # Metetodos da classe calculadora # Metodo de soma utilizado pela calculadora def soma(self, * numeros): resultado = 0 for numero in numeros: resultado += numero return resultado # Metodo d...
b530f422b24418434eb4e632d0cda1b93a5f6a5f
rupaliwaghmare/python_list
/list.py
253
3.734375
4
# list=[] # i=0 # while i<10: # list.append(i) # i=i+1 # print(list) # a=[1,2,3,4,5,6] # b=[] # b.append(a) # print(b) n=[[1,2,3,4,],[5,6,7,8,]] i=0 while i<len(n): j=0 while j<len(n[i]): print(n[i][j]) j=j+1 i=i+1
0e52802fb6aa1beba8847dbe69d8cea4d6712b08
Oussamab21/Machine-Learning-Lab-
/SVM/2.py
3,223
3.5
4
import numpy as np X = np.array([[-1, -1],[-2, -1],[1, 1],[2, 1],[-1.0,0.5],[0,1],[0,0.5],[-0.5,3],[-1,2],[-0.5,-1.5]]) #we create 4 examples y = np.array([-1, -1, 1, 1,-1,1,1,-1,-1,1]) from sklearn.svm import SVC #import de la classe SVC pour SVM classif=SVC() #we create a SVM with default parameters classif.fit...
20f6ef2b9d0544f39da718d81295766a92f552a1
suman-pun/python-class
/task7.py
1,921
3.8125
4
# Print all friends name, contact and address for user Ram. # Find out which user have less friends # Find out which user have most friend in common. user=[ { "name":"Ram", "contact":"98342345", "address":"Ktm", "friends":[ ...
d71462d4ca9e05fa8641eca39b8835b5a837e3cf
suman-pun/python-class
/interitancetask.py
1,926
3.875
4
class User: def __init__(self, _id, username, password): self._id = _id self.username = username self.password = password def login(self, username, password): #Implement this function # Student and Teacher object should be able to log in # pass# ...
496c6119d63f6504fab0df273266ffb21fb13f1c
tzhao458/hotel-project
/poolLayer.py
1,320
3.515625
4
#This code is implemented for Machine Learning class in UNCC #License: non-commercial use only #Author : Tianyi Zhao <tzhao4@uncc.edu> #Created : <2016-05-02> from theano.tensor.signal import pool class PoolLayer(object): """Pool Layer of a convolutional network """ def __init__(self, input, poolsize=(2, 2),...
825b90607fb9845b1f026eb24270067abf9a892d
AngelOfTheNight246/Curso-em-V-deo-Python
/Mundo 1/Exercícios/ex009.py
534
3.9375
4
n = int(input('Digite um número: ')) n2 = int(n * 2) n3 = int(n * 3) n4 = int(n * 4) n5 = int(n * 5) n6 = int(n * 6) n7 = int(n * 7) n8 = int(n * 8) n9 = int(n * 9) n10 = int(n * 10) print('{}x1 = {} '.format(n, n)) print('{}x2 = {}'.format(n, n2)) print('{}x3 = {}'.format(n, n3)) print('{}x4 = {}'.format(...
10e37895f097eb155f1b1b2e982a7a608267bdd0
AngelOfTheNight246/Curso-em-V-deo-Python
/Mundo 1/Exercícios/ex015.py
239
3.515625
4
km = float(input('Quantos kilômetros você percorreu com esse carro ?')) d = float(input('Por quantos dias você alugou esse carro ?')) cd = float(d * 60) kmd = km * 0.15 pf = kmd + cd print('O preço final fica por {}R$'.format(pf))
8c999f21b38fd1147e85a451ad278e2664a06a3b
midnightkali/w3resource.com-python-exercises
/Excercise Solutions/question-2.py
617
4.40625
4
''' 2. Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number. Sample Output: Double the number of 15 = 30 Triple the number of 15 = 45 Quadruple the number of 15 = 60 Quintuple the number 15 = 75 ''' def compute(num): return lambda nu...
757b44fc7f4663ffde1ba31bd90ded1a39fdcba9
petertuton/python-game
/utils.py
2,976
3.90625
4
import os import sys # Global variables player_name = '' ############## # Utility functions ############## def printCentered(text:str): print(padToCenter(text)) # Centering multi-line text def padToCenter(text)->str: # This code adapted from stuff I found on Stack Overflow. I don't fully understand it y...
759bbbc8b66076cf966e724e20cd5375040b491e
DaHao/python-sundries
/HeapSort.py
1,411
3.640625
4
def PARENT(i): return i // 2 def LEFT(i): return 2 * i def RIGHT(i): return 2 * i + 1 def ConvertIndex(i): return i - 1 def MAX_HEAPIFY(A, i): l = LEFT(i) r = RIGHT(i) largest = i if l <= len(A) and A[ConvertIndex(l)] > A[ConvertIndex(i)]: largest = l if r <= len(A) ...
4d113c743e202d94c81a1b2b651646eb8abd15e4
Johnson-xie/python-notes
/logging_tutorial.py
808
3.8125
4
import logging ''' ref. https://docs.python.org/3.6/howto/logging.html Level , DEBUG < INFO < WARNING < ERROR < CRITICAL ''' def ex1(): # ex1 # will print 'warning message' , 'error message', because the default level is WARNING logging.warning('warning message') logging.error('error message') lo...
916b74555761f5039171effc39f1c4c3d67c8a2c
zouyangchn/pythonStudy
/函数/day03.py
2,688
3.921875
4
def power(x, n=2): sum = 1 while n > 0: n = n - 1 sum = sum * x return sum print(power(4, 2)) def enroll(name, gender, age=6, city='beijing'): print('name:', name) print('gender:', gender) print('age:', age) print('city:', city) print(enroll('xiaohong', '男')) enroll('li...
a2a27423ef64dce62e29d6276b5353cb0d0935f7
zouyangchn/pythonStudy
/函数/day02.py
2,601
3.90625
4
print(1 + 2 + 3 + 4) # Python的循环有两种,一种是for...in循环,依次把list或tuple中的每个元素迭代出来,看例子: names = ['lily', 'luce', 'mike', 'dana'] for name in names: print(name) # 所以for x in ...循环就是把每个元素代入变量x,然后执行缩进块的语句 sum = 0 for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: sum = sum + x print(sum) # 幸好Python提供一个range()函数,可以生成一个整数序列 d = ra...
899d2790c56fa731862d0cb2966e847b163b2d9b
JonathanPerlin/python_training
/Data_Visualization/Do_It_Yourself/15-10.py
579
4.03125
4
import matplotlib.pyplot as plt from die import Die # Create a D6 die = Die() # Roll the dice! for roll_number in range(1000): result = die.roll() # Show results of rolling a 6-sided die 1000 times. x_values = list(range(1, 7)) y_values = [x/6 + die.roll() for x in x_values] plt.scatter(x_values, y_valu...
b57b88b6584eecca6dcc37f8f7c9bd18d5092f1b
prplz/aoc-2020
/python/day03.py
973
3.65625
4
import math from collections.abc import Iterable from itertools import count def main(): with open('../inputs/03.txt') as f: data = list(map(str.rstrip, f)) width = len(data[0]) height = len(data) int_pair = tuple[int, int] int_pairs = Iterable[int_pair] def make_slope(step: int_pai...
9171008a118df3ecfcce74ce5b9db54377bfc963
karan-uppal3/tkinter-playground
/5-Calculator.py
2,954
3.84375
4
from tkinter import * root = Tk() e = Entry(root,width=20,borderwidth=5) e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) def button_click(number): current = e.get() e.delete(0,END) e.insert(0,str(current)+str(number)) def button_clear(): e.delete(0,END) def button_add(): first_num = float(e....
5e47d2828747132ee731c6135ffa897f545b81d0
BHarold-Ling/Precipitation_pub
/readdb/hourly.py
1,148
3.828125
4
""" Routines to pull hourly data """ from main.config import * import pandas as pd import sqlite3 def get_hourly(start_station: str, start_period: str, end_station: str = None, end_period: str = None) -> pd.DataFrame: """ Get hourly precipitation data for range of stations and periods. :param start_stat...
6787185c9fcaeacccc3cac1e620f4d64cfbe6927
wchamber01/Algorithms
/stock_prices/stock_prices.py
970
4.125
4
#!/usr/bin/python import argparse def find_max_profit(prices): #find highest_value in list highest_value = max(prices[1:]) # print(highest_value) #find lowest_value in list that occurs before the highest value for i in prices: temp_arr = prices.index(highest_value) # print(temp_arr) lowes...
410b61d6ca3c75d569c305ee104a680ed066b21b
canxuegigi/learn_python
/20180323/生成器.py
657
3.5625
4
#!/usr/bin/evn python #encoding=utf-8 #Author:canxue import time #列表生成式 a = [i*2 for i in xrange(10)] def add_two(var_num): var_num = var_num + 2 return var_num b = [add_two(i) for i in xrange(10)] print a print b g = (i*2 for i in xrange(10)) print type(g) def fib(max): n, a, b = 0, 0, 1 while ...
599fcc12bb2f1400abb000b245135005fafd7c87
canxuegigi/learn_python
/python_spider/random_test.py
1,025
3.71875
4
#!/usr/bin/evn python #encoding=utf-8 #Author:canxue import random a=['canxue',5,6,'kaka','gigi','gigi','残雪'] s='df4fdsOPsG' t=('canxue',5,6,'kaka','gigi','gigi','残雪') #随机生成的一个实数,它在[0,1)范围内 print(random.random()) #左开右闭,若设置了步长,则只能是起始位置,开始的步长n呗, print(random.randrange(25,29,4)) #左右都闭,整数,必须传两个整数参数,且前一个要小于等于后一个 print...
9a2c2c90cc1e66acf5aaef429df35c34c9038ad8
canxuegigi/learn_python
/20180821骚操作/test_operate.py
251
3.578125
4
#!/usr/bin/evn python #encoding=utf-8 #Author:canxue a=5 b=6 # print(a,b) b,a=a,b # print(a,b) a=['canxue','shi',['hahha','fdsfds'],'ren'] #print(' '.join(a)) a='abcdklgjfk' # print(a[::-1]) a=[1,2,3,4] b=a.copy() print(a,b) b[2]=10 print(a,b)
d59a10e1d60c8ce74224f7656fa5930447efa6fa
canxuegigi/learn_python
/20180314/redgreenlight.py
1,746
3.734375
4
#!/usr/bin/evn python #encoding=utf-8 #Author:canxue import time,threading #wait()是没设置flag就等,而车子在红灯时等,所以红灯时clear(),绿灯时set() #红灯要等,所以送灯时执行clear() #黄灯准备,所以送灯时执行clear() is_green = threading.Event() is_yellow = threading.Event() def light(): count = 0 while True: if count >= 0 and count < 5: ...
b2cf3c5d25e600356f1340baf4724f39bef92a8f
365cent/calculate_pi_with_turtle_py
/calculatePi.py
2,845
4.5625
5
""" References: https://stackoverflow.com/questions/37472761/filling-rectangles-with-colors-in-python-using-turtle https://www.blog.pythonlibrary.org/2012/08/06/python-using-turtles-for-drawing/ https://docs.python.org/3/library/turtle.html https://developer.apple.com/design/human-interface-guidelines/ios/visual-design...
7197045ea90b7e48e71fcc944d8479e99e1b6a0c
hnminhtri/ics-final-project
/battle_ship.py
8,543
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 6 09:58:56 2018 @author: hnminhtri """ import random random.seed(0) class Player(): def __init__(self, name): self.name = name def shooting(self): print("It is now your turn!") row, column = input('Please enter...