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
c1f8a50cbbb3e2124eb61b9be92b1f3076b8c659
vamshivarsa/tikinter_project
/billtable.py
1,438
3.53125
4
from tkinter import * import psycopg2 def submit(): conn=psycopg2.connect(dbname="vamshi",user="postgres",password="davs",host="localhost",port="5432") cur = conn.cursor() name1 = namebox.get() status1=statusbox.get() amount1=amountbox.get() paid_on1=paidbox.get() query='''insert into bill(...
bb4b1b40079b1fa58fb6b46a30ccaae7a2158b3d
livepo/lc
/148.sort-list.py
1,466
3.90625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None # def __str__(self): # p = self # value = [] # while p: # value.append(p.val) # p = p.next # return str(value) class Solutio...
f599a7298c12ab2a7ae6bc13636add5afaf1c94f
livepo/lc
/257.binary-tree-paths.py
904
3.890625
4
# 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 binaryTreePaths(self, root): """ :type root: TreeNode :rtype: List[str] """ p...
8f42788f0e9212f0bfcd543d496263e4eb816d84
livepo/lc
/155.min-stack.py
1,048
3.984375
4
class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] self.small_stack = [] def push(self, x): """ :type x: int :rtype: None """ self.stack.append(x) if not self.small_sta...
d6ecf561ae750b0317e1c02a02dd843294ebece8
livepo/lc
/23.merge-k-sorted-lists.py
1,319
3.765625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ lists = filter(lambda x:...
4d1061318ba7b012b4e19702bd9cc41b5636b928
livepo/lc
/TOP100/22.generate-parentheses.py
628
3.703125
4
class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ result = [] if n == 0: return result self.helper(n, n, '', result) return result def helper(self, lc, rc, path, result): if lc > rc: return ...
416d4ae26f9e897ba828e76e26776c1126f74507
livepo/lc
/78.subsets.py
624
3.609375
4
class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result = [] if not nums: return result self.helper(nums, 0, [], result) return result def helper(self, nums, i, current, result): if i...
83a387f7e85e2184570b99d97db0d61e337b754c
livepo/lc
/TOP100/94.binary-tree-inorder-traversal.py
1,114
3.953125
4
# 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 inorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ ...
7e0474816b046687bd523308cd908ab8b189592d
livepo/lc
/71.simplify-path.py
705
3.78125
4
class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ newpath = path.replace('//', '/').replace('..', '*') while newpath != path: path = newpath newpath = newpath.replace('//', '/').replace('..', '*') ...
c4cb087cd6a13a05eb65290d15a9c643dfe27c1f
1109287684a/ramseytadpoles
/modpows.py
475
3.875
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 13 08:05:30 2014 @author: tperish """ def modpows(generator, modulus, printlist='default'): """"Finds all powers of a generator in a given mod""" powers = [] current = 1 for _ in range(modulus): current = generator * current % modulus pow...
aeb9f7a1bab8f632af5265adfbeabef861180da2
LABETE/Python3_Homework
/Python3_Homework07/src/test_furnishings.py
692
3.625
4
""" Testing the furnishings module """ import unittest from furnishings import Furnishing, Sofa, Table, Bed, Bookshelf, map_the_home class TestFurnishings(unittest.TestCase): def setUp(self): self.home = [] self.home.append(Bed('Bedroom')) self.home.append(Sofa('Living Room')) self...
9f64f6916aa1c8088aec3213a36a52b6b1df19cc
thingscouldbeworse/GearBall
/ball_components.py
4,068
3.59375
4
import util import copy class face: position = 0 def __init__(self, color, position): # 4 corners, 4 edges, 1 center, gears are handled at the ball level # because faces don't know which faces they border self.pieces = { 'top_right': piece(color, 'top_right'), ...
07ec1679cba8647a534024d68c478809ee147d25
belgort-clark/ctec-121-lab-4
/module-5-lab-4.py
1,353
4.09375
4
# YOUR NAME # Module 5 - Lab No. 4 # Make sure you changed Line 1 to be your first and last name teacher = "Bruce Elgort" # Using string slicing print the first letters "Bruc" from the teacher variable # Using string slicing print out the last 2 letters from the teacher variable # Write a for loop that displays e...
9e2cb6da8203d1464592f1763cb6484d5d002de3
iloveeway/pythonwork
/input6car.py
979
3.5
4
from random import randint import re def randomnums(): s = "" for i in range(0,12): t = randint(0,9) s = s+(str(t)) return s def oddeven19(string): s = 0 for i in range(0,len(string)): if(i % 2 != 0): t = int(string[i]) * 2 if (t >= 10): ...
222f918e43905ce8fb0304d6e79439fe06035e23
Evaluates2/Polyglot-TDD-Fizzbuzzified-String
/python/fizzbuzz.py
427
3.6875
4
def fizzbuzzified_word(index, word): if (index + 1) % 15 == 0: return 'fizzbuzz' if (index + 1) % 5 == 0: return 'buzz' if (index + 1) % 3 == 0: return 'fizz' return word def fizzbuzzify(input_string): words = input_string.split() fizzbuzzified_words = [ ...
0397862535441ab36fe0efc55af18415967cdfd4
lindsaymarkward/CP1404-2016-2
/strings_demo.py
263
3.828125
4
__author__ = 'Lindsay Ward' # for i, char in enumerate(__author__): # print("{:10} - {}".format(i, char)) # name = "Monty" # money = 73.6 # # print("{} has ${:.2f}".format(name, money)) s = "Hi every one here" words = s.split() for word in words: print(word)
5adefe150767c4f7cf7bbc58530fcd8af5a5b6a4
lindsaymarkward/CP1404-2016-2
/shopping.py
829
4.0625
4
""" Do this now - start with the Cart class Create a shopping program that uses the classes Product and Cart A Cart can store multiple products in it - find out the current total price - add and remove products - display all products sorted by price """ from cart import Cart def main(): print("Welcome") prod...
defed641093bb4a66c05d6a66eef7c41fc166e32
sonijha1522/k-meanclustering
/KClustering.py
2,058
3.59375
4
import numpy as np import matplotlib import random as rd import matplotlib as mp from sklearn.cluster import KMeans import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing import MinMaxScaler import matplotlib.pyplot as plt import seaborn as sns from matplotlib import pyp...
8e3b555fa1c1cfc6e7f661cf1d13665ecd530afc
ogrotten/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
1,553
4.09375
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, new_next): # se...
ebba3c73c933c9b32ba3b2e1a59600e1bfb84d3e
aaazezeze1/BMI-Python
/bmi.py
544
4.34375
4
print("BMI Calculator\n") name = input("Enter your name: ") weight = float(input("Enter your weight (kg): ")) height = float(input("Enter your height (mtr): ")) bmi = weight / (height * height) if bmi <= 18.5: print('\nYour BMI is', bmi, 'which means you are underweight') elif 18.5 < bmi < 25: p...
8ab15526ba72041586c6d10dc1a4ecac23de4689
weiluoyan/code
/python/test2.py
775
3.859375
4
# -*- coding:UTF-8 -*- class Employee: empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print "total employee %d" % Employee.empCount def displayEmployee(self): print "name:",self.n...
a10f9fc600292faa07ba1a4f4d3b03558fd3c0e7
OdellDotson/a_to_b
/policy.py
4,915
4.21875
4
import math class AbstractPolicy: """ AbstractPolicy: abstract class that defines the interface between a policy to the simulation """ def __init__(self): raise NotImplementedError def getNextStep(self, world_state, request_list): """ This method is the main exposed part of...
ccd5438c7a16943922815beb7a71a13061c5c252
hbradlow/solver
/server/parser/gui.py
2,335
3.5
4
import Tkinter as tk class Point2D: def __init__(self, position, radius=3, fill="red", outline="black"): self.position = position #a numpy array self.radius = radius self.fill = fill self.outline = outline def __repr__(self): return "<Point2D: " + str(self.position) + "...
f9ea18a1e2e324bcf235b11fe021f23f19101c07
davidov541/PythonFFT
/src/Utilities/SigUtil/FFT.py
1,100
3.578125
4
''' Created on Oct 2, 2009 @author: David McGinnis ''' import math from Utilities.IOUtil import PrettyPrint # Takes A, and converts all elements using the getYk function into # the term for the Discrete Fourier Transform. def DFT(Sig): returnable = [] n = 0 for elem in Sig: yk = ge...
2d782f94097de9031113940e6a13fdbbcdcd3d29
AneliaPetrova/SoftUni-Software-Engineering
/Python-Basics/First Steps in Coding - Exercise/05. Birthday party.py
236
3.6875
4
rent_for_hall = int (input()) cake_price = rent_for_hall * 0.20 drinks_price = cake_price - (cake_price*0.45) animator_price = (1/3)*rent_for_hall needed_sum = rent_for_hall+cake_price+drinks_price+animator_price print (needed_sum)
24d0e247dba6571430a2283c714cc16d6bc8c836
xuanchuong/google-foobar
/bom-baby/solution.py
925
3.59375
4
import math def solution(x, y): x = int(x) y = int(y) count = 0 while x != y and x > 0 and y > 0: if x > y: ((x, y), time) = replicate(x, y) else: ((y, x), time) = replicate(y, x) count += time if x == y and x == 1: print(count) else: ...
9f17bba6c0b94b41e2f6af9c7def943f8db26972
fightpig/Python5937
/1_偏函数.py
1,671
4
4
""" 函数在执行时,要带上所有必要的参数进行调用。但是,有时参数可以在函数被调用之前提前获知。这种情况下,一个函数有一个或多个参数预先就能用上,以便函数能用更少的参数进行调用。 偏函数是将所要承载的函数作为partial()函数的第一个参数,原函数的各个参数依次作为partial()函数后续的参数,除非使用关键字参数。 就像足球比赛安排首发一样,主教练可以固定让某位球员一直首发,而剩余10人,则是等到赛前才决定 所以偏函数,又叫偏心函数 这跟scala的函数柯里化相似 def ass(x: Int, y: Int) = x + y 则调用时,必须add(1, 2) def add(x:Int)(y:Int) = x + y...
a81a023a783392b76e347d8acfb4f764242c9423
JuggernautRhino/CurrencyDiscBot
/CreatingATable.py
1,199
3.78125
4
import sqlite3 def tableCreation(): # Connect to database conn = sqlite3.connect('Bal.db') # create a cursor c = conn.cursor() #creating the table c.execute("""CREATE TABLE users ( user TEXT, balance INTEGER ) """) #you can define the datatype as one of 5 datat...
c677732baff55f64e21619adf18ecf93c382dd90
AoWangPhilly/math-projects
/Searching Algorithm/Linear Search/LinearSearch.py
262
3.796875
4
def linear_search(nums, find): for i in range(len(nums)): if(nums[i] == find): return i return -1 nums = [-1, 0.5, 99, 0, -5, 100] print(nums) find = 99 print(str(find) + " can be found at index: " + str(linear_search(nums, find)))
0a760e773775ebda9139999ecfa4cd659acae841
AoWangPhilly/math-projects
/SortingAlgorithms/Insertion Sort/InsertionSort.py
488
4.0625
4
""" Author: Ao Wang Date: 08/18/19 Description: Insertion Sort Algorithm """ def swap(nums, a, b): temp = nums[a] nums[a] = nums[b] nums[b] = temp def insertion_sort(nums): for i in range(1, len(nums)): j = i while j > 0 and nums[j - 1] > nums[j]: swap(nums, j - 1, j) ...
13d667574244312f9b8ab00cc6948f8b2a9d63f7
bicsu/algorithm_practice
/BOJ_1181.py
207
3.578125
4
n = int(input()) dicts = {} for i in range(n): w = input() dicts[w] = len(w) keys = list(dicts.keys()) values = list(dicts.values()) res = sorted(keys, key=lambda x: (len(x), x)) for i in res: print(i)
494555f38bcccebe1ef2c0faa6360c0903ec8f57
KParamJoshi/multiplication
/main.py
103
3.59375
4
def mul(n1,n2): if n1==1 & n2==1: return 1 else: return n1 * n2 a=mul(3,4) print("mul=",a)
f45417b008ccdb2f2b359c35a7c77a3f185dc9cc
DponyG/AI
/text.py
3,123
3.515625
4
import pygame # file: text.py # Author: Samuel Grenon # Class: Text # Handles the Text in pygame class Text: agentOneScore = 0 # Static Variable used to increment the score agentTwoScore = 0 num = 0 pile = [] previousPile = [] def __init__(self): self.black = [0,0,0] self.g...
f1778bbe519ae012e91b06d884230f7a07ecd9d7
miguelmontcerv/Summer
/Adonai/hola.py
183
4
4
#Mi primer programa en Python print("Introduce un numero") numero = input() print("El numero es "+numero) print("Introduce otro numero") numero = input() print("El numero es "+numero)
415ac67705946ca5fa76ba2c4a59d5cccf0bab60
jiangxiaolin25/pythondemo
/PYproject/stringdemo.py
696
4
4
#!/usr/bin/python3.6 # -*- coding: utf-8 -*- # @Time : 2019/10/25 11:43 # @Author : jiangxiaolin # @Email : jiangxiaolin@xgd.com # @File : stringdemo.py # @Software: PyCharm for i in range(-10, 10) : print i def hello() : print("Hello World!") a='测试变量' class people: #定义基本属性 name = '' __...
bd8da22a95236477b0b31e87a1aeea0147ecb756
Vipin382/Guesss_Game
/Guess Game with Import Module.py
1,386
4.0625
4
import random print("In This game you have to guess the number Between 1 to 20.You have 6 Lives Lest") while True: x = input("You Wanna Play this Game.Type Y for yes and N to quit: ") a = random.randint(1,20) t = 7 i = 20 if x=="Y": while True: t = t-1 if t=...
78c62a3782836e9cac4eb65182438ea61e8bb46f
ishitasinghal/GUI_Python
/sentence_reversal.py
1,430
3.578125
4
import tkinter as tk import datetime rowfor = 1 window=tk.Tk() window.title("Sentence Reverser") window.resizable(False,True) heading_label=tk.Label(window, text="Enter the sentence",fg="white",bg="red") heading_label.grid(row=0,column=0,sticky="nsew") columnForEntry = tk.Frame(window) columnForEntry.grid(row=1,colum...
344f6007501c77a6bd7f93ad505b553411c535e8
eimearn/counties
/counties.py
5,921
3.578125
4
""" Title: Programming for GIS Assignment 1 Author: Eimear Nicholl Date: 25/03/2019 Programme purpose: The purpose of this programme is to read and perform tasks on the CSO 'counties' dataset Specific tasks 1. Download and save the counties dataset as a shapefile. You can get this at http://mf2.dit.ie:8080/geose...
ac63512b11c7029728d5f0373d28bba95c17d197
zaviermiller/blackjack-networking
/server/Card.py
245
3.546875
4
class Card: def __init__(self, suit, value): self.suit = suit self.value = value def __repr__(self): return (f'{self.value} of {self.suit}') def show(self): print (f'{self.value} of {self.suit}')
d2918ddccb827e8475d5878c7bb75f1f3b91895f
Morpheus2112/Rosalind-exercise
/bioinformatics stronghold/LEXF.py
1,692
3.9375
4
# -*- coding: utf-8 -*- """ Problem Assume that an alphabet A has a predetermined order; that is, we write the alphabet as a permutation A=(a1,a2,…,ak), where a1<a2<⋯<ak. For instance, the English alphabet is organized as (A,B,…,Z). Given two strings s and t having the same length n, we say that s precedes t in the l...
403a2867edf20908db9447cc7706ceae1ecab603
Morpheus2112/Rosalind-exercise
/bioinformatics textbook track/BA5N.py
2,796
3.625
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 15 15:32:52 2018 @author: palan """ import copy class edge_weighted_graph: def __init__(self): # set of vertex self.vertex = set() # adjacency list of set of edge : # key = vertex initial # value = ( ..., (vertex final, dist...
b20770daf7f3e264fbf44a245364c5335278c188
Morpheus2112/Rosalind-exercise
/algorithmic heights/CC.py
760
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 31 00:34:59 2017 @author: Memphis """ import networkx as nx import matplotlib.pyplot as plt def cc(): with open("rosalind_cc.txt") as f: n, m = map(int, f.readline().strip().split()) lines = f.readlines() edge_list = map(lambda x: map(int, x.str...
1bc39b661381583b5b5d6e80e6a2e73bec2dde28
Morpheus2112/Rosalind-exercise
/bioinformatics stronghold/DNA.py
827
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 31 19:25:42 2017 @author: Memphis """ """ Problem A string is simply an ordered collection of symbols selected from some alphabet and formed into a word; the length of a string is the number of symbols that it contains. An example of a length 21 DNA string (whose alphabe...
ef26cbec4009a424e7a7b5c735b6881c40079cbb
Morpheus2112/Rosalind-exercise
/algorithmic heights/GS.py
2,426
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 03 21:21:36 2018 @author: Memphis """ #!/usr/bin/env python3 def read_graph(reads): n, e = reads[0] adjacent_lists = [[] for _ in range(n)] for _ in range(e): v1, v2 = reads[_+1] adjacent_lists[v1 - 1].append(v2 - 1) return adjacent_...
cd5a23b4cd93020e94ede5946305a50d09375d6c
Morpheus2112/Rosalind-exercise
/bioinformatics stronghold/TREE.py
325
3.71875
4
# -*- coding: utf-8 -*- """ see http://rosalind.info/problems/tree/ """ # The number of edges required is N-E-1, # where N is the number of nodes and E is the number of edges. def tree(): lines = open("rosalind_tree.txt").read().splitlines() n = int(lines[0]) e = len(lines)-1 return n-e-1 print tr...
e0852416c303e4529b605bbc583367bbd4e13ca0
Morpheus2112/Rosalind-exercise
/algorithmic heights/HS.py
2,014
3.8125
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 31 09:42:22 2017 @author: Memphis """ # http://rosalind.info/problems/hs def heapify(heap, i): """Given a heap and recently added element at heap[i], perform up-heap operation to conserve the heap property""" if i==0: return parent = (i-1)/2 ...
f74a738152239ff3ed43e74291d70d29d41bab8f
Morpheus2112/Rosalind-exercise
/algorithmic heights/BFS.py
1,288
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 31 00:28:07 2017 @author: Memphis """ import networkx as nx import matplotlib.pyplot as plt def bfs(): with open("rosalind_bfs.txt") as f: n, m = map(int, f.readline().strip().split()) lines = f.readlines() edge_list = map(lambda x: map(int, x.s...
62b343873cedbdc43d16bea8ed16c7ffb59a2ce8
ReinaldoDuguet/codeforces
/too_long_words.py
220
3.640625
4
n = int(input()) for oportunidades in range(n): word = input() long_word = '' if len(word)>10: long_word = word[0]+str(len(word[1:-1]))+word[-1] print(long_word) else: print(word)
15ad247b6ab040ad85ec9179787bf087e86e9104
helloLFJ/shiyanlou-code
/parsefile.py
1,090
3.65625
4
#!/usr/bin/env python3 import os import sys def parse_file(path): """ 分析给定的文本文件,返回其空格,制表符,行相关信息 :arg path:要分析文本文件的路径 :return:包含空格数,制表格数,行数的元组 """ fd = open(path) i = 0 spaces = 0 tabs = 0 for i,line in enumerate(fd): spaces += line.count(" ") tabs += line.count("\...
eee5bf6161faf0de0986bd8bfb3d171920774d36
liuhanyu200/pygame
/11/employee.py
285
3.515625
4
class Employee(object): def __init__(self, first_name, last_name, employee): self.first_name = first_name self.last_name = last_name self.employee = employee def give_raise(self, money=5000): self.employee += money return self.employee
d7e11270745ab9033b0683c88dbfc4e8c5d00ba6
liuhanyu200/pygame
/6/6-6.py
573
3.859375
4
# -*- coding:utf-8 -*- favorite_numbers = { 'wangyue': 8, 'liuseng': 2, 'luoliuzhou': 9, 'liushaoqiang': 1, 'caohongsheng': 100, 'xiongmao': 6, 'xixi': 6, } for name in favorite_numbers: print(name + "favorite number is " + str(favorite_numbers[name]) + '.') # 遍历字典需要加上.items() for name...
a10af3143ac80e572b27cc14e1861d63b7e78bd5
liuhanyu200/pygame
/7/7-8-9.py
496
3.765625
4
sandwich_orders = ['pastrami', 'fish', 'pastrami', 'cabbage', 'pastrami', 'sala', 'pig', 'chicken'] finished_sandwich_orders = [] print(sandwich_orders) print("'pastrami' soled out!") while 'pastrami' in sandwich_orders: sandwich_orders.remove('pastrami') print(sandwich_orders) while sandwich_orders: finished ...
7e8c9f53006f7465a9644d88451bc3e59a760b33
liuhanyu200/pygame
/9/9-5.py
859
3.515625
4
# coding:utf-8 class User(object): def __init__(self, first_name, last_name, **describes): self.first_name = first_name self.last_name = last_name self.login_attempts = 0 self.describes = {} for key, value in describes.items(): self.describes[key] = value de...
63d7c280f8c8ca1b33cac667d08ccdac5eac8ab4
liuhanyu200/pygame
/9/user.py
607
3.5
4
# coding:utf-8 class User(object): def __init__(self, first_name, last_name, **describes): self.first_name = first_name self.last_name = last_name self.login_attempts = 0 self.describes = {} for key, value in describes.items(): self.describes[key] = value de...
34ae547bb6a89a0ae230ec06f7a33679a21b5732
liuhanyu200/pygame
/5/5-8.py
259
3.609375
4
user_names = ['admin', 'zhangsan', 'lisi', 'wanger', 'zhoubin'] if user_names != '': for user_name in user_names: if user_name == 'admin': print(user_name + ", 欢迎回家!") else: print(user_name + "你好!")
24edd5bcf108b17e2507fa5c5f5ed568f01cdc74
liuhanyu200/pygame
/7/7-10.py
407
3.796875
4
# coding:utf-8 name_promote = "What's your name? " place_promote = "If you could visit a place, where would you go?" flag = True favorite_flace = {} while flag: name = input(name_promote) place = input(place_promote) favorite_flace[name] = place _exit = input("anyone wan't to next ? no to exit .") i...
b8704239174d0ce43e40ec627bf00d0ef0a30746
jouejem/Local-Search
/problem_instance.py
520
3.671875
4
#A Random problem instance for knapsack problem import numpy as np from random import Random seed = 5113 myPRNG = Random(seed) #Number of available items or, #number of elements in a solution n = 150 #values and weights of items for the knapsack problem value = [] for i in range(0,n): value.append(round(my...
3120b443dd401e4ded7bea7b96009ae6fd47c72f
diazMafer/creacion-de-automatas
/thompson.py
6,243
4.0625
4
import re from transition import * from automata import * #method from https://www.geeksforgeeks.org/python-get-unique-values-list/ def unique(alphabet): # insert the list to the set list_set = set(alphabet) # convert the set to the list unique_list = (list(list_set)) return unique_list """ Th...
68b0ed0774592899b32fc7838d54d9d361a05ff8
gevuong/Developer-Projects
/python/number_game.py
1,407
4.21875
4
import random def game(): # generate a random number between 1 and 10 secret_num = random.randint(1, 10) # includes 1 and 10 as possibilities guess_count = 3 while guess_count > 0: resp = input('Guess a number between 1 and 10: ') try: # have player guess a number ...
8f8cb15ef494edb05050d9eb8e82047c89dd1ad1
chandrikakurla/inorder-traversal-using-stack-in-python
/bt_inorder traversal using stack.py
1,018
4.28125
4
#class to create nodes of a tree class Node: def __init__(self,data): self.left=None self.data=data self.right=None #function to inorder traversal of a tree def print_Inorder(root): #initialising stack stack=[] currentnode=root while True: #reach leftmost...
681101a4ea24708339d19a201dfddfe55b67246d
lauw04/Sphynx-HPC-SP-MJL
/CODE/i_boole.py
635
3.53125
4
# _*_ coding: utf-8 _*_ def boole(f,a,b,n): """Voici la fonction qui calcule l'intégrale d'une fonction donnée en paramètre par la méthode des trapèzes :param function f: la fonction dont on calcule l'intégrale par la méthode des rectangles :param float a: le début de l'intervalle :param float b: la fin de l'i...
492e13d5bb2f8ea111890f77795670c289062b9c
iparedes/Toros
/Toro.py
698
3.515625
4
from tools import * class Toro: def __init__(self,n=-1,b=-1,s=-1): """ :param n: Nobleza. Un toro noble embiste cuando se le cita y da embestidas limpias :param s: Stamina. Energia del animal. Decrece a lo largo de la faena :param b: Bravura. Agresividad, afecta a las cogidas cuand...
e82de007d7a98c446c98cdef03d4ee1ddaea0998
Goktug22/Artificial-Intelligence
/ai/hw2/main.py
15,241
4.59375
5
""" Group Name: TERRA Group Members: Göktuğ Öztürkcan Ibrahim Eren Tilla Emre Orta Mehmet Bora Kurucu İsmail Yavuzselim Taşçı Programming Language: Python 3 In our program, we used the heuristic number 1 which is the number of misplaced tiles. It is an...
5a15edc16ec8e3aa8eb34aae5280609d520b6bcb
katsuyamiz/PythonPractice
/formatting.py
569
4.0625
4
# print('this is string {}'.format('INSERTED')) print('the {} {} {} '.format('a', 'b', 'c')) print('the {2} {1} {0} '.format('a', 'b', 'c')) print('the {0} {0} {0} '.format('a', 'b', 'c')) print('the {q} {q} {q}'.format(f='fox', b='brown', q='quick')) result = 100/777 print(result) print("the result was {}".format(re...
34e136246665689b382cc5292f2d514a8fcffa0a
katsuyamiz/PythonPractice
/sets.py
242
3.640625
4
my_set = set() print(my_set) my_set.add(1) print(my_set) my_set.add(2) print(my_set) my_set.add(2) print(my_set) # have to be unique value # the same value cannot be added twice my_set2 = set() my_set2.add('mississippi') print(my_set2)
073a54f94adcef1d5f23f8a9c14ab22b0c635c39
katsuyamiz/PythonPractice
/tutorial.py
5,213
3.90625
4
# # st = 'Print only the words that start with s in this sentence' # word_list = st.split(' ') # print(word_list) # for word in word_list: # if word[0] == 's': # print(word) # # # for x in range(0, 11): # if x % 2 == 0: # print(x) # # # result = [x for x in range(1, 51) if x % 3 == 0] # print(re...
fbd4caa4b40267dea74abbe178597d00f117e72c
putsy-caballero/VintageDraft
/entities/Player.py
439
3.625
4
from abc import ABC, abstractmethod class Player(ABC): def __init__(self, playerID: str, firstname: str, lastname: str, stats): self.playerID = playerID self.firstname = firstname self.lastname = lastname self.stats = stats @abstractmethod def valid_year(self, year, leagu...
c32643619dc00b921c3ea9ee0d550d900edaf8b9
nsreeen/fcc-algorithms-python
/palindrome.py
395
3.796875
4
import doctest, math def palindrome(string): """ >>> palindrome("eye") True >>> palindrome("race car") True >>> palindrome("not a palindrome") False """ string = string.replace(" ", "") if len(string) <= 1: return True if string[0] == string[-1]: return pa...
1398699207d99c1fd94e7ed1e72fc3ec0cb661de
cvk1988/biosystems-analytics-2020
/assignments/01_strings/vpos.py
1,425
4.375
4
#!/usr/bin/env python3 """ Author : cory Date : 2020-02-03 Purpose: Find the vowel in a string """ import argparse import os import sys # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( description='Rock the Casb...
fa6575214072291c0530476319adb5e26d914188
sushilgoyal1970/python-work
/search.py
523
3.8125
4
class node: def __init__(self, data): self.data= data self.next = None class Linkedlist: def __init__(self): self.head = None def push(self, new_data): new_node = node(new_data) new_node.next = self.head self.head = new_node def search(sel...
87ede5187b244f8c0e26bd4026304a9e80fcf248
cherishbrowne/Portfolio_SchoolProjects
/LogicAndProgrammingI_Python/Assignment3/GirlGuideCookiesProgram3.py
2,448
4.0625
4
#Don't forget to rename this file after copying the template #for a new program! """ Student Name: Cherish Browne Program Title: Girl Guide Cookie Sell-Off Description: """ #make a function to calculate the average def findTheAverage(parameterNum): totalNum = 0 for counter in range(len(parameterNum)):...
2c3fc6c8274675fdea3b3be6145a8ff7c6356276
lumapps/lumbda
/lumbda/collection.py
2,624
3.8125
4
import uuid def to_uuid(value): """ Convert the value to uuid if it's not already a uuid Args: value (string): the value to convert Returns: the converted value Raises: TypeError: when the value cannot be converted to a uuid ValueError: when the string is badly f...
5d0d41bf0566ee13c14f8c5f85eb5342e4be33e5
pedrorijo91/pythonUtils
/testNumber.py
2,757
3.59375
4
from numberUtils import * print "Starting Number testing" assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True assert is_prime(11) == True assert is_prime(13) == True assert is_prime(4) == False assert is_prime(6) == False assert is_prime(8) == False assert is_pr...
37affb20e4cadf0667dd7bfc21081f0615e2f992
jtizon001/currency_exchange
/dates.py
5,826
3.578125
4
import sqlite3 import datetime import foreXchange #script to create table of Dates to find exchange rate for any 2 currencies at some date #USED FOR GRAPH #in memory database, make a file #conn = sqlite3.connect(":memory:") conn = sqlite3.connect("currencies.db") cursor = conn.cursor() #__________________________...
36267b437270fa533b4ae6d5e5ca328ff2eb884e
sideroff/python-exercises
/various/files/with.py
1,063
3.75
4
class Withable(): openned = False def __init__(self): print('constructor called, self.openned = {}'.format(self.openned)) # should return self if you intend to use aliases: # with x as y # ^ def __enter__(self): self.openned = True print('enter c...
113a349e982a7390dbad6f1c9719ec04026dafae
sideroff/python-exercises
/softuni_python_2016/exercise_03.py
1,218
4
4
def get_input_prices(): input_text = input('Enter a price or "stop": ') prices = [] while input_text != 'stop': new_price = None try: new_price = float(input_text) except: print('Input could not be parsed. Please choose another.') input_text = inp...
39b53834d3870f1661bb1bdc64f4a4f39923fc8d
sideroff/python-exercises
/various/slotted_classes/index.py
638
3.765625
4
from sys import getsizeof class Planet: def __init__(self, cities, rivers): self.cities = cities self.rivers = rivers class SlottedPlanet: __slots__ = ['cities', 'rivers'] def __init__(self, cities, rivers): self.cities = cities self.rivers = rivers earth = Planet(['So...
c6f28c527ef45c48fe6c6978fd27fb6addc2f595
sideroff/python-exercises
/softuni_python_2016/exercise_01.py
119
3.625
4
input_text = input('Enter text: ') if len(input_text) > 10: input_text = input_text[:9] + '...' print(input_text)
d5ff9d18c1fdf3e489080b6925293d5626adae93
sideroff/python-exercises
/01_basic/exercise_024.py
363
4.25
4
def is_vowel(char: str): vowels = ('a', 'e', 'i', 'o', 'u') if len(string_input) > 1: print("More than 1 character received. Choosing the first char as default.") char = string_input[:1] print("Your char is a vowel" if char in vowels else "Your char is not a vowel") string_input = input(...
b1b90d4a847c308af642abfa191b4da86098c100
sideroff/python-exercises
/01_basic/exercise_032.py
224
3.65625
4
from exercise_031 import euclidian_gcd input_int = float(input("Choose a number: ")) input_int2 = float(input("Choose another number: ")) print("lcm = %.0f" % ((input_int*input_int2)/euclidian_gcd(input_int, input_int2)))
5196d65883e62a71aa999af834a5ee06760c9d24
sideroff/python-exercises
/01_basic/exercise_026.py
142
3.71875
4
int_list_input = list(map(int, input("Choose a list of ints seperated by ', ': ").split(", "))) for num in int_list_input: print("@"*num)
58a9abb0dae2450fd180b6e00ae41748647b9176
sideroff/python-exercises
/various/class_properties.py
634
4.15625
4
# using property decorator is a different way to say the same thing # as the property function class Person: def __init__(self, name: str): self.__name = name def setname(self, name): self.__name = name def getname(self): return self.__name name = property(getname, setname) ...
abc5a7f32bcce35ea084826ff220c0a9109163bd
jkainic/Spanning-Trees
/Version3.py
4,365
3.90625
4
from graph import * class node: #optional parameter keeps track of ancestor def __init__(self, G = Graph(), ancestor = []): self.tree = ancestor[:] self.G = G #make tree node unique by exchanging an edge for a fundamental edge def new_node(self, new_edge, stale_edge): self.tree[new_edge] = 1 #do we need ...
e6f65dfc64711b4e19a0c2d0391197a050402ac1
judyhuang209/001Data-Science
/hw2/euclideanDistance.py
606
4.375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 14 14:00:49 2019 Ref: https://machinelearningmastery.com/tutorial-to-implement-k-nearest-neighbors-in-python-from-scratch/ @author: 105502506 """ import math def euclideanDistance(instance1, instance2, length): distance = 0 for x in range(length): distanc...
3eb78bf9dc81c0815f22afd52bfe44942fa433ae
mirzaKarahan/python
/mukkemelSayi.py
286
3.578125
4
sonuc = 0 for b in range(100000): sayi = b degerler = 0 for a in range(sayi-1,0,-1): if sayi % a == 0: degerler += a #print(a) if degerler == sayi: print("Mükemmel Sayıdır :",degerler) sonuc +=degerler print(degerler)
bd11a5ebbf2cdb102526ec1f39866c801e04ff54
ladamsperez/python_excercises
/Py_Gitbook.py
2,123
4.75
5
# # Integer refers to an integer number.For example: # # my_inte= 3 # # Float refers to a decimal number, such as: # # my_flo= 3.2 # # You can use the commands float()and int() to change from onte type to another: # float(8) # int(9.5) # fifth_letter = "MONTY" [4] # print (fifth_letter) # #This code breaks because Py...
8c650f2e69061c4d164e8028b41009512e47d715
ladamsperez/python_excercises
/task6_9.py
636
4.125
4
# Write a python function that takes a list of names and returns a new list # with all the names that start with "Z" removed. # test your function on this list: # test_list = ['Zans', 'Dan', 'Grace', 'Zelda', 'L.E.', 'Zeke', 'Mara'] test_list = ['Zans', 'Dan', 'Grace', 'Zelda', 'L.E.', 'Zeke', 'Mara'] def noznames...
8bc8613c411857bc34c49a912ebb2b866695b43c
ladamsperez/python_excercises
/pigex.py
2,909
4.03125
4
import random def greeting(): '''Displays a greeting for the game Pig''' print("Oink! Oink! Let's Pig Out!") class Game: def __init__(self,p1_human=True,p2_human=False): self.die=Die() self.p1 = Player('Player 1',p1_human) self.p2 = Player('Player 2',p2_human) ...
8ad75dfd50914311c1bb9dfee5b808b6db2c3e06
sanjana-reddy1652/Project_Euler
/Smallest multiple.py
502
3.734375
4
''' 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? ''' # importing the module import math # function to calculate LCM def LCM(a): lcm = a[0] for i in range...
b30b546fce4d302b31855adc90f1843a7cb0fafe
armiro/Deep-Learning-A-to-Z
/Convolutional_Neural_Networks/cnn.py
3,814
3.578125
4
# Convolutional Neural Network # Installing Tensorflow # pip install tensorflow # facing problem? install via wheel file url address (or download the file and install via pip using local file address) # python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.w...
2647e6a46a3eea679234d276fcbc7fe21a9d24b0
peteyan/pylearn
/pattern/decoration.py
841
3.984375
4
#coding:utf-8 # 装饰模式 """ 模式特点:动态地为对象增加额外的职责 程序实例:展示一个人一件一件穿衣服的过程。 代码特点:无 """ class Person: def __init__(self,tname): self.name = tname def Show(self): print "dressed %s" % (self.name) class Finery(Person): componet = None def __init__(self): pass def Decorate(self,ct): self.componet = ct def Show(self)...
49e49eb50b5beca72b1e6261390d99b1d45922a5
Vuyanzi/Python
/app.py
307
4.125
4
name = input ('What is your name? ') print ('Hi '+ name) colour = input ('What is your favourite colour ' + name + '') print (name + ' likes ' + colour) year_of_birth = input (name + ' Please enter your year of birth ' ) age = 2019 - int(year_of_birth) g = 'Your current age is ' v = age print (g + str(v))
841be83bceec1885e25b22dea795185bd99fefe3
Quantizr/RandomStreamAlgorithm
/RandomStream.py
3,719
3.953125
4
def main(): # initialize a tree with root value "psi" root = Tree() root.value = "psi" # To use as an actual stream, you would convert input binary (0s and 1s) # to "H"s and "T"s and pass each incoming value into: # RandomStream(root, value, depth) # where: root is the Tree defined abov...
bf2a8c21df5062ec2d302e0eae8f18afbe41143d
DariaMinieieva/sustainable_energy_project
/sustainable_energy/unittests/linkedlist_test.py
565
3.515625
4
from unittest import TestCase from map_creator.linkedlist import LinkedList, Node class test_linkedlist(TestCase): def setUp(self): self.lst = LinkedList(1) self.lst.add(Node(2)) self.lst.add(Node(3)) def test_add(self): self.assertTrue(self.lst[1].data == 2) self.asse...
5f4e183a43fcc1a8b6ec7d2bae4d0fce88a4a7fa
jpablolima/python-analise-de-dados
/metodo.py
371
3.578125
4
class Circulo(): pi = 3.14 def __init__(self, raio = 8): self.raio = raio def are(self): return (self.raio * self.raio) * Circulo.pi def setRaio(self, novo_raio): self.raio = novo_raio def getRaio(self): return self.raio circ = Circulo() circ.getRaio() print('Ra...
7816945813febe2936ba26f6177c1bbfae2e4724
lisachen0112/Coffee-machine
/coffee_machine.py
2,499
4.34375
4
water = 400 milk = 540 coffee_beans = 120 cups = 9 money = 550 espresso = {"water": 250, "milk": 0, "coffee_beans": 16, "money": 4} latte = {"water": 350, "milk": 75, "coffee_beans": 20, "money": 7} cappuccino = {"water": 200, "milk": 100, "coffee_beans": 12, "money":6} def home(): print(f"""The coffee machine ha...
39f81d3f396bd5741a0ddf78cd60eb2638c347ba
LiangLun/LeetCode
/DP/Leetcode_62.py
1,516
3.859375
4
''' 62. 不同路径 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? 示例 1: 输入: m = 3, n = 2 输出: 3 解释: 从左上角开始,总共有 3 条路径可以到达右下角。 1. 向右 -> 向右 -> 向下 2. 向右 -> 向下 -> 向右 3. 向下 -> 向右 -> 向右 示例 2: 输入: m = 7, n = 3 输出: 28 ''' # 方法1:排列组合 # 从起点到终点一共需要m+n-2步,在m+n-2步选出m-1步向右,剩下...
0acb6530ed3968e54acb821f0e398d2f6228e880
yaskh/Feature-Selection
/features selection.py
983
3.5
4
import pandas as pd from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import chi2 import seaborn as sns import matplotlib.pyplot as plt data = pd.read_csv("train.csv",sep = ',') X = data.iloc[:,0:20] #independent columns y = data.iloc[:,-1] #target column i.e price range #apply Se...
a92ae2b5c8707a56a541ac9aa442c1e0d8cc5aa8
LuisCarmonaV/Mision_03
/Auto.py
757
3.671875
4
#Luis Adrian Carmona Villalobos #A01748395 def calcularRendimientoKmL(kmRecorridos, litrosGasolina): rendimientoKmL = kmRecorridos/litrosGasolina return rendimientoKmL def calcularRendimientoMiGal(kmRecorridos, litrosGasolina): millas = kmRecorridos*0.621371 galon = litrosGasolina*0.264172 ...
dbcfef0ceb07c38f19c3daeabe7a04851ae231a6
cognoscentai/crowd-seg
/analysis/TileEM/scatter_toolbox.py
3,407
3.640625
4
import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model from sklearn.preprocessing import StandardScaler def regression_results(df,x_attr,y_attr,PLOT=False,normScale=False,ylim01=False): print "---------------------------------------------" print "Regression x={0};y={1}".format(x_att...