blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bae66fd1190c013b7091d34e74ab5f271bb1c2df
caseyprogramming/Intro-to-Python-Programming
/GuessingGameAI.py
1,107
3.828125
4
#Python 2.7 import random gameActive = True #this can be used to make sure the player isnt cheating userNumber = input("Please give me a number to guess: ") userInput = input("What is the maximum range, 1 to ___? ") computerGuess = random.randint(1,userInput) ceiling = 100 floor = 0 print "Is your number " + s...
410ef287fbcdab73b4f3e3d1567bcbd76ee998aa
nascarsayan/lintcode
/677.py
1,112
3.640625
4
from collections import deque class Solution: """ @param grid: a 2d boolean array @param k: an integer @return: the number of Islands """ def numsofIsland(self, grid, k): # Write your code here try: nr, nc = len(grid), len(grid[0]) except IndexError: return 0 isls = 0 visi...
769e589afad3c538ae643ae24981eec3a8a1dca6
eoriont/machine-learning
/src/graphs/graph.py
1,841
3.5625
4
from node import Node class Graph: def __init__(self, edges, vertices=None): self.nodes = [Node(i, value=v) for i, v in enumerate(vertices)] for x, y in edges: self.nodes[x].set_neighbor(self.nodes[y]) def depth_first_search(self, starting_index): return self.nodes[starting...
8cb29059defb808bd0b053a807991665e39a2574
tsabz/python_practice
/functions.py
277
3.859375
4
# to write a function start with def def say_hi(name): print("hello " + name) # print("Top") say_hi("tonia") # print("Bottom") # list = [5, 2, 3, 1, 4] def order_list(arr): arr.sort() arr.append(2) # arr.count(2) print(arr) order_list([5, 2, 3, 1, 4])
75b6c90c7727681316416185103a75a1c5f32247
xiaochuanjiejie/python_exercise
/Exercise/15-18/exercise_13.10.py
950
3.609375
4
#-*- coding: utf-8 -*- class PerlArray(object): def __init__(self,li=[]): self.li = li def empty(self): if len(self.li) == 0: return 1 else: return 0 def shift(self): if self.empty(): print '空数组' else: print 'remove [',...
c0bbb9e98cebedae5041fdc2a2f5081456031571
thiagocharao/tw-galaxy-convert
/resources.py
904
3.875
4
from exception import UnknownResource class Resource(object): """Represents a resource Attributes: credits_per_unit (float): Amount of credits per galaxy unit """ credits_per_unit = 0 def __init__(self, credits_per_unit=0): self.credits_per_unit = credits_per_unit @staticmet...
8a6752a6dd39b1e61af963340af98cb35ff8f293
z1223343/Leetcode-Exercise
/134_109_ConvertSortedListtoBinarySearchTree.py
2,595
3.5
4
""" 1. Recursion 2. Recursion + Conversion toArray 3. Inorder Simulation (有点骚) time space 1. O(NlogN) O(logN) 2. O(N) O(N) 3. O(N) O(logN) """ # solution 1: class Solution: def sortedListToBST(self, head: ListNode) -> TreeNode: if not head: return None mid = self...
920174306a7f30463c9c4d73906f62773361aaad
JonesQuito/estudos_de_python
/cursos/EXERCICIOS_PYTHON_EXCRIPT/exercicios/TiposDeDados.py
803
4.28125
4
num_int = 5 num_dec = 10.5 val_str = "um texto qualquer" """ print(type(num_int)) print(type(num_dec)) print(type(val_str)) """ print("\n") print("O valor de 'num_int' é:",num_int) #Concatenamos um texto com outro valor qualquer usando uma vírgula para separá-los print("O valor de 'num_int' é: %i" %num_int) # Usando os...
ee909e994807a6d44501cee466150de50af4dc23
matheusmcz/Pythonaqui
/Mundo2/ex043.py
441
3.84375
4
from math import pow nome = str(input('Insira seu nome: ')).strip().lower() altura = float(input('Altura: ')) peso = float(input('Peso:')) imc = peso / pow(altura, 2) print('Paciente: {}'.format(nome.title())) if imc <= 18.5: print('Abaixo do Peso.') elif 18.5 < imc <= 25: print('Peso Ideal.') elif 25 < imc <= ...
32c2d3bc8f5282f81777e94aa1af4d18a2298f81
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4322/codes/1602_1014.py
85
3.5
4
TotalDeVendas = float(input("valor da venda?")) print(round(TotalDeVendas * 0.3, 2))
8f752a1d9fdde3085794d9524dde9b695716c403
kaydee0502/Data-Structure-and-Algorithms-using-Python
/DSA/Queue/queue_ll.py
1,561
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 29 21:07:12 2020 @author: KayDee """ class Node(): def __init__(self,data): self.data = data self.next = None class Queue(): def __init__(self,size): self.first = None self.last = ...
b97351b554c1e98334a7c9ca229e43292c66dcaf
vinoroy/homeBakedPi
/app/dateTimeConversion.py
2,495
4.0625
4
#!/usr/bin/env python """ @author: Vincent Roy [*] This module contains functions to convert a datetime object into a datenumber and back to a datetime object. The datenumber system is based on the Excel datenumber system which sets datenumber 0 equivalent to 1900\01\00 """ from __future__ import division from datet...
53f709efcc1fc23132797108ebf58f05edd9437a
k200x/algo_practice
/medium/first_duplicate_value.py
283
3.90625
4
def firstDuplicateValue(array): queue_list = list() for i in array: if i in queue_list: return i else: queue_list.append(i) return -1 if __name__ == '__main__': arr = [2, 1, 5, 2, 3, 3, 4] print(firstDuplicateValue(arr))
d44791828bc2896fb05779c120ab5441b79af228
leleluv1122/Python
/py1/0603/0604-1.py
254
3.90625
4
# 처음 - 끝 효과적이지못함 def linearSearch(lst, key): for i in range(len(lst)): if key == lst[i]: return i return -1 lst = [1,4,4,2,5,-3,6,2] i = linearSearch(lst, 4) print(i) j = linearSearch(lst, -4) print(j)
fbd8021cb0e543c3310cbca60af12fe3850412ce
coolcrazycool/python_developer
/main.py
2,732
3.5625
4
from array import array class Arr: def __init__(self, element_type, *elements): self.el_type = element_type self.data = array(element_type, elements) def __getitem__(self, item): if isinstance(item, slice): return self.data[item] else: return self.data[...
5e978694991902734968a0c73d665f90fbcbf760
ismailsinansahin/PythonAssignments
/Assignment_04/Question_12.py
547
4.21875
4
package = input("What is your package: A, B, or C --> ") hours = int(input("How many hours did you use internet this month: ")) if package == 'A' or package == 'a': if hours > 10: charge = 9.95 + (2 * (hours-10)) else: charge = 9.95 elif package == 'B' or package == 'b': if hours > 20: ...
d021495427f2fc2f5b4436a20bc58d8225058274
Karl8/PythonCNN
/codes/network.py
2,111
3.5
4
import numpy as np import matplotlib.pyplot as plt class Network(object): def __init__(self): self.info = [] self.layer_list = [] self.params = [] self.num_layers = 0 def add(self, layer): self.layer_list.append(layer) self.num_layers += 1 self.info.appe...
be051315c65036c7ecbbbf3749f2176d4be9e365
jxie0755/Learning_Python
/LeetCode/LC520_detect_capital.py
1,690
4.125
4
# LC520 Detect Capital # Easy # Given a word, you need to judge whether the usage of capitals in it is right or not. # We define the usage of capitals in a word to be right when one of the following cases holds: # All letters in this word are capitals, like "USA". # All letters in this word are not capitals, like "lee...
f64782317bf7504fdb0b437fcb2703a77bf8dfec
dmbee/seglearn
/examples/plot_nn_training_curves.py
3,031
3.625
4
""" ======================================= Plotting Neural Network Training Curves ======================================= This is a basic example using a convolutional recurrent neural network to learn segments directly from time series data """ # Author: David Burns # License: BSD import matplotlib.pyplot as plt ...
59b0c7f955c1396bd9c842f07e71eabd5f51d398
SaveliiLapin/learning_projects
/4_xor.py
251
3.90625
4
def xor(xx, yy): if xx: if yy: return 0 else: return 1 else: if yy: return 1 else: return 0 x = int(input()) y = int(input()) print(xor(x, y))
c00bb8733591a6e8f0167ddf82553367d2cf6820
tnakaicode/jburkardt-python
/geometry/line_imp2exp.py
2,346
3.65625
4
#! /usr/bin/env python # def line_imp2exp ( a, b, c ): #*****************************************************************************80 # ## LINE_IMP2EXP converts an implicit line to explicit form in 2D. # # Discussion: # # The implicit form of line in 2D is: # # A * X + B * Y + C = 0 # # The explicit form...
c7e67402418367eace4403cefd8f5f1cae2e510a
ishantk/GW2020P1
/Session20F.py
973
3.78125
4
import os print(os.name) print(os.uname()) print(os.getlogin()) print(os.getppid()) # Process Id in which this program is getting executed print("Current Working Directory:", os.getcwd()) path_to_directory = "/Users/ishantkumar/Downloads" path_to_file = "/Users/ishantkumar/Downloads/key.json" print("Downloads Direc...
0be041124b4aea04e7e97676c91cc627a8863ea2
Abhi2285/icdstest
/carprking.py
203
3.6875
4
#print("My First Python code") #5Earningfortheday=0 Earningfortheday = input("Enter the earning: ") print(Earningfortheday) if int(Earningfortheday) > 500: print("profitable") else: print("Loss")
5d03047ccf7aef5a6c335d51bc82a5ffe96005d4
uabinf/nlp-group-project-fall-2020-disneyqanda
/disneyqanda/local_dependencies/quest_processing/focus.py
1,279
3.5625
4
# -*- coding: utf-8 -*- # Function to get head words, to find the focus of the question being asked # import spaCy for dependency parsing import en_core_web_sm nlp = en_core_web_sm.load() def q_head_words(q): # Use en_core_web_sm for dependency parsing doc = nlp(q) words = [(x.text, x.pos_, x.head....
5bfd8f9c029b70a035f67d119b8ff0492c27e089
radiosd/csvDataBase
/rgrCsvData/csvDataBase.py
9,526
4.1875
4
# -*- coding: utf-8 -*- """ Access to csv database CsvItem A line in the file held as a dict with the heading used as the keys CsvDataBase A list of CsvItems read from a csv file All items that are not under a heading are grouped together into a list...
631e6d481c8e42781a98831736bc8ab72c2f0dfe
BaeNayeong/Algorithms
/Dynamic Programming/4_bottom_up_fibonacci.py
147
3.65625
4
d = [0]*100 def fibonacci(n): d[1]=1 d[2]=1 for i in range(3, n+1): d[i]=d[i-1]+d[i-2] return d[n] print(fibonacci(6))
d02ebbec43c4c23b6968c9348c931dd5c027cb3f
darya-ver/PhotomosaicCreater
/getSquare.py
1,323
3.609375
4
#################### # getSquare.py #################### from PIL import Image import math # # converts the image into a square # # returns: [array of pixels of square image, size of new image] # # im: image that is being converted into sqaure # def squareImage(im): # load the pixe...
2fb81e0776b2020a75ff280878c4c18238e8dadd
loftusa/playing-with-git
/james-powell-talk.py
1,080
4.28125
4
# dec.py """ 0. run python file in console, open as environment 1. use dis to get information about method 2. look at byte code for method 3. look at default arguments for method 4. look at name of method """ # %% # foo is a decorator which will add ', heckin.' to the sentence created by bar. # bar is a method that ...
05ad2579b6438516fbcee55ed6795943edd6c03f
syurskyi/Python_Topics
/070_oop/008_metaprogramming/_exercises/templates/abc_Abstract Base Classes/a_003_abc_subclass.py
1,198
3.6875
4
# # abc_subclass.py # # # Implementation Through Subclassing # # Subclassing directly from the base avoids the need to register the class explicitly. # # ______ a.. # ____ a_001_abc_base ______ P.. # # # c_ SubclassImplementation P.. # # ___ load input # r_ i__.r.. # # ___ save output data # r...
302c3449f89640aabbf2c07263847106d3eeba51
satyampandeygit/ds-algo-solutions
/Algorithms/Implementation/Almost Sorted/solution.py
1,034
3.984375
4
# input array size input() # input array elements array = [int(x) for x in input().split(" ")] # store the sorted array sorted_array = sorted(array) # If the array is already sorted, output yes on the first line if array == sorted_array: print("yes") # If you can sort this array using one single operation out of th...
04451784bb25fd576ac64f18b42a2d8d8939109c
Rishab9991/EE5609
/Assignments/Assignment3/Assignment3.1/Assignment3.1.py
1,286
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 29 16:08:45 2020 @author: Rishab """ '''import matplotlib.pyplot as plt''' import math as m ''' Different inputs are used in .tex and .py files''' a = [0,3] b = [0,0] c = [3,-0.5] d = [3,5] def distancebetn(P,Q): return float(m.sqrt((Q[0]-P[0])**...
5404109d7442cddea0aa44b7ba148bb394868e04
computerscienceioe/Lesson-14
/Challenge 5.py
1,993
3.609375
4
students = ["John Smith","Jane Doe", "Mary Murphy", "Michael Lawlor", "Conor Whelan", "Kate Walsh", "Shane Duffy"] ages = [16, 17, 18, 17, 18, 15, 19] marks = [90, 88, 50, 60, 100, 75, 95] zipped_lists = zip(students, marks) sorted_pairs = sorted(zipped_lists) tuples = zip(*sorted_pairs) sorted_students, sorted_marks...
030d4a2026e4d89e5828aaf228d534314f513854
daniel-reich/ubiquitous-fiesta
/LgXMXThsKcYtdYHrb_11.py
115
3.5
4
def split_and_delimit(txt, num, delimiter): return delimiter.join(txt[a:a+num] for a in range(0,len(txt),num))
0d9cde392f0a05f5fb33236a03795565289975de
Ponkiruthika112/Guvi
/prime20.py
691
3.625
4
stack=[] st=[] list=[] new_list=[] new_list2=[] list3=[] for x in range(1,100): c=0 for y in range(2,x): if x%y==0: c=1 if (c==0) and (x!=1) and (x!=2): stack.append(x) for x in stack: sum=0 while x>0: temp=x%10 sum=sum+temp x=x/10 st.append(sum) for x in st: d=0 for y in range(2,x): if...
3128b0b7d3f17c3f2a270f7916b784840eb9b587
mxtdsg/interview
/longestCommonPrefix.py
361
3.515625
4
#### # # find the longest common prefix of a list of strs # # leetcode 14. # #### def longestCommonPrefix(strs): if len(strs) == 0: return "" minlength = min([len(st) for st in strs]) re = "" for i in range(minlength): for st in strs: if st[i] != strs[0][i]: return ...
90d386972d19b62895d32ec74559d7385eb4cf54
balloonio/algorithms
/lintcode/advanced_algorithm/4_sweep_line_binary_search/391_number_of_airplanes_in_the_sky.py
833
3.6875
4
""" Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end """ class Solution: """ @param airplanes: An interval array @return: Count of airplanes are in the sky. """ def countOfAirplanes(self, airplanes): # wr...
6c77382fb52578d6465e88289d67209650cd690b
mauung-sudo/python-exercises
/e6.py
268
3.84375
4
def computepay(hours,rate): if hours > 40: bonus_hr = hours - 40.0 bonus = bonus_hr * rate * 0.5 xp = hours * rate + bonus else : xp = hours * rate print("Pay : " , xp) computepay(float(input ("Enter Hours: ")), float(input ("Enter Rate: ")))
7ac0ace8b17c80af072aa80be36b1831684c91da
1505069266/python-
/面向对象/静态方法.py
1,015
4.125
4
class Student: name = '' age = 0 # 一个班级里所有学生的总数 sum1 = 0 # 实例方法 def __init__(self, name, age): # 构造函数 实例化的时候会运行这里的代码 self.name = name self.age = age self.__class__.sum1 += 1 print("当前班级人数:" + str(self.__class__.sum1)) # print('我是:' + name) ...
3a0eaa713296fd01d25964d192dd6ce1756ac503
thePortus/dhelp
/dhelp/text/_bases.py
5,966
3.734375
4
#!/usr/bin/python import re from collections import UserString class BaseText(UserString): """Performs text manipulation and natural language processing. Base class for all Text objects. Can be used on its own to perform a number of operations, although it is best used with on of its language-specific ...
2f214aae5e30e4e01471a8a0f8cd0af1c401f0da
Aparecida-Silva/ProjetoAnimal
/Animal.py
462
3.546875
4
class Animal(): def __init__(self, nome, numMembros, habitat): self.nome = nome self.numMembros = numMembros self.habitat = habitat def mover(self): print(self.nome + " movendo de forma genérica") def comer(self): print(self.nome + "comendo de forma genérica...
68dff3090cd12f29fdb060bda651e8d355311e71
0xjojo/Exercise-Chapter-Eight-8.4
/Exercise-Chapter-Eight-8.4.py
407
3.6875
4
#file_name = input ("Enter file:\n") #file_hand = open(file_name , 'r') file_hand = open( 'romeo.txt', 'r') count = 0 words = [] smart_words = [] for line in file_hand : words = line.split() x = len(words) while count < x : if words[count] in smart_words : count = count + 1 continue smart_w...
9a637f31bbc919382f667c673390454e2d5abdef
colbydarrah/cis_202_book_examples
/CH7_list_if-clause_select_specific_pieces_of_loop.py
1,164
4.25
4
# Colby Darrah # 3/23/2021 # IF CLAUSES pg 398 # Use "if-clause" to select only certain elements whne processing a list. # this code only selects integers from the list taht are less than 10 def main(): #========================= NUMBERS ============================================ ####### EXAMPLE ########...
db57f7378de6635b01ac57b040796a254a94f5a6
dcl67/DataStructures
/Assignment1/main.py
346
4.25
4
from palindrome import isPalindrome def main(): print("Welcome to Palindrome Checker!\nEnter a word. The program will tell you if it is a palindrome.\nTo quit enter a blank line.") string = input("Enter word to check: ") while string != "": isPalindrome(string) string = input("Enter word to check: ") if __name...
fc19f2c514d6d8f0ae83238f52b196108b4190a4
dlomelin/Algorithms
/algorithms/test/test_Sort.py
1,089
3.71875
4
import unittest import algorithms.Sort as Sort class TestSort(unittest.TestCase): def setUp(self): self.unsortedList = [5, 2, 4, 7, 1, 3, 2, 6] self.pythonSorted = sorted(self.unsortedList) def test_merge_sort(self): # Function sorts list in place Sort.merge_sort(self.unsorted...
eff9c4bb282b42acbf0d28e05ed41f81daea25a3
caseymm/python_class_materials
/assorted/num_count.py
781
4.03125
4
array = [0, 3, 2, 5, 6, 3, 4, 1, 0, 4] def find_duplicates(array): #Create an empty dicitonary to store i as key and count as value num_dict = {} for i in array: #counts number of times item appears in array num_count = array.count(i) #outputs results to dictionary...
9a94f60360f9dc8c1979e5817f572334b19e9861
sandrejev/bioopt
/model.py
45,748
3.625
4
#!/usr/bin/env python import re import thread import itertools import warnings import math def _is_number(s): if s in ['0', '1', '2', '1000']: return True try: float(s) return True except ValueError: return False def _starts_with_number(s): return s[0...
e2b1714e3281dca2021ece4056c88777966f817e
udwivedi394/misc
/redundantBraces.py
574
4.15625
4
#https://www.interviewbit.com/problems/redundant-braces/ #Return 1 if redundant Braces are present def redundantBraces(A): stack = [] for i in A: if i == ')': valid = False while stack[-1] != '(': if stack.pop() in ('+','*','-','/'): valid = ...
e28a8b4dc17de6c52e3a268cb1b99fe8d10696d9
skimaiyo16/andela-bc-5
/data_stuctures.py
881
3.921875
4
# phone book example # use a list class PhoneBookList(object): def __init__(self): self.book = [] def add_contact(self, username, phone_number): record = [username, phone_number] self.book.append(record) def search(self, username): ''' returns a `dict` wih a phone number and the number of...
44ab6bef6931cd9225b02bb385f59760bda9fd89
dwibagus154/TUBES-TPB-ITB
/cari_pemain.py
427
3.734375
4
import csv def CariPemain(): user = input('Masukkan username:') userfile = csv.reader(open('user.csv')) found = False for row in userfile: if user == row[3]: found = True print("Nama Pemain: ", row[0]) print("Tinggi Pemain: ", row[2]) print("Tang...
337f8bc0691e6fd6944dcfe9066419330e2f0c4a
Andrewlearning/Leetcoding
/leetcode/Stack/581. 最短的无序连续子串(stack).py
1,395
4.0625
4
""" 给你一个应当是从小到大排列的数组(允许元素相等),但里面有一部分连续的子串是混乱的 让你求, """ class Solution(object): def findUnsortedSubarray(self, nums): """ :type nums: List[int] :rtype: int """ stack = [] left = len(nums) right = 0 for i in range(len(nums)): while len(stack...
2b5e877f6edb6686bd3d496efc8014ac60e47bd7
JoseBorras/Tarea1Modelacion
/ejemplo4-3-Malalasekera.py
5,002
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Example 4.3 from Malalasekera Book ---------------------------------- In the final worked example of this chapter we discuss the cooling of a circular fin by means of convective heat transfer along its length. Convection gives rise to a temperature-dependent heat loss...
a6a8fe06f493e2c73f067d0c39c5d24c493fa1cd
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_2.py
98
3.765625
4
#enter username name=input("Enter your name\n") #print greeting to user print("Hello %s!" %name)
318f8f830dc562f1d1497d6d6eeb57420fe66da5
Hironobu-Kawaguchi/atcoder
/atcoder/abc067_a.py
183
3.59375
4
# https://atcoder.jp/contests/abc067/tasks/abc067_a A, B = map(int, input().split()) if A % 3 and B % 3 and (A + B) % 3: print("Impossible") else: print("Possible")
37bad9107dfc386f518b5f849f1e98c7ae69be2b
deepakdeedar/python_projects
/reduce.py
448
3.828125
4
from functools import reduce my_list = [1, 2, 3] your_list = [10, 20, 30] their_list = [5, 25, 125] def multiply_by2(item): return item*2 def only_odd(item): return item % 2 != 0 def accumulator(acc, item): print(acc, item) return acc + item print(list(map(multiply_by2, my_list))) print(list(fil...
577ea0241ef48d173c69f38d4eeb3b4185b7bf90
Jeson-fly/tools
/data_structure/double_link_list.py
3,317
3.828125
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/13 13:13 @Author : lining @email:lining01@tuyooganme.com @desc: 双端链表 """ class ListNode(object): def __init__(self, data=None): self.pre_node = None self.next_node = None self.date = data def clean_pointer(self): """清空指针,避免不必要的连接错误"...
a372e99100bec16f1ce6ecab0c73ccacf8d8d830
RicardoStephen/algorithms
/test/test_heapq.py
2,773
3.53125
4
import unittest import math from algorithms.graphs import Heapq class TestHeapq(unittest.TestCase): """ Note, the heappush tests are only smoke tests. """ def setUp(self): self.heaps = {'empty': []} states = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'] for idx, sta...
67854c3ac91cf58a13601f30e600afae7db2d0ea
UnderLurker/insect
/PythonApplication1/day03_numpy.py
6,401
4.1875
4
import numpy as np """ 安装了anaconda,在pycharm 中import numpy 不成功的。 1、cmd中 输入python-------import numpy 2、如果成功,设置pycharm的setting 其他方法安装:cmd------输入:pip install numpy """ # 一、创建数组 # 1、array函数,可以传入列表、元组。 arr1 = np.array([1, 2, 3]) # print(arr1) # arr2 = np.array([[1, 2, 3], # [2, 3, 1] # ...
099a75fb765ccb5b8178baf4de97d5213eb9ba6f
lianlian-YE/Mypycharm
/Python_file/python_westos_teacher_doc/day09/11_私有属性和变量.py
1,092
3.8125
4
#!/usr/bin/env python # coding:utf-8 """" Name: 11_私有属性和变量.py Date: 2018/05/19 Connect: xc_guofan@163.com Author: lvah Desc: """ # 子类也不能直接使用父类的私有属性和私有方法; class Student(object): def __init__(self, name, age, score): self.name = name self.age = age # 以双下划线开头的属性名或者方法名, 外部是不可以访问的; s...
7ae875dedd85b4a3ca039d319c659b02bcf7648a
epheat/ieeextreme_10
/problems/painters_dilemma/painter.py
2,503
3.609375
4
def main(): tests = int(input()) for i in range(tests): brush1 = 0 brush2 = 0 changes = 0; numc = int(input()) clrs = input() clrs = clrs.split(" ") for k in range(numc): ...
c02230439b102cc186dfe29c0e2e672f6382e492
xiaoyaoshuai/-
/作业/7.11/erase_zero.py
226
3.625
4
a = int(input("苹果(元):")) b = float(input("香蕉(元):")) c = int(input("火腿(元):")) d = float(input("可乐(元):")) money = a+b+c+d print ('总计(元)') print (money) print ("实际金额") print(str(int(money)))
96d6d4e94404ee9a6b60edcaabbdcadae33438a6
RevansChen/online-judge
/Codefights/arcade/intro/level-6/25.Array-Replace/Python/solution1.py
158
3.65625
4
# Python3 def arrayReplace(inputArray, elemToReplace, substitutionElem): return [ (substitutionElem if e == elemToReplace else e) for e in inputArray ]
c04d46e418d294fb9b7fa4b8ff688ff76e976716
OmarMontero/150-challenges-for-python
/twenty-two.py
208
4.09375
4
name = input("Write your name in lower case, please: ") surname = input("Write your surname in lower case, please: ") name = name.title() surname = surname.title() whole = name + " " + surname print(whole)
cb7cf447a2081958d3ac7e012485e254bc9a17b1
amitdh123/codeabbey-solutions
/sumloop.py
196
3.75
4
def sumloop(items, numberlist ): sum = 0; for i in range(0,items): sum = sum + numberlist[i] return sum length = 5 numberlist = [1,5,0,4,3,] result = sumloop(length,numberlist) print(result)
b0bbba917c888e069d23921f6681662ad02172ef
Ajay-2007/Python-Codes
/hackerearth/Data Structures/Arrays/1-D/Monk_And_Welcom_Problem.py
915
3.703125
4
"""Monk and Welcome Problem Args: arrays(int) Returns: array(int) Algorithm: arr_c[i] = arr_a[i] + arr_b[i] Problem Link: https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/monk-and-welcome-problem/ """ class Monk_And_Welcom: def __init__(self, size_n, arr_a, ar...
96b6264ac02434da30ca4320f3590d6a78865dd9
ShreyashSoni/linear_regression
/regression-demo.py
2,542
3.59375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 22 20:47:34 2017 @author: Shreyash Soni """ from numpy import * def compute_error_for_line_given_points(b, m, points): #initialize at zero totalError = 0 #for every point for i in range(0, len(points)): #get the x-values x = points[i, 0] ...
7ddcf156628e85b6a5d55b31b76aa194e79203c6
stubbi/nqs
/nqs/operator.py
1,776
3.5
4
from ._C_nqs.operator import * import numpy as _np def Ising(hilbert, h, J=1.0): """ Constructs a new ``Ising`` given a hilbert space, a transverse field, and (if specified) a coupling constant. Args: hilbert: Hilbert space the operator acts on. h: The strength of the transverse field...
f14c2fc7a425e87e6050b802fe20e5f36ca6a60f
JohnsonClayton/DeepLearning-DNSoverHTTPS
/utils/data_preprocessing.py
2,187
3.90625
4
def get_data(path, layer=0, nans=False): """ get_data function Description: This function will take the given path and user-defined layer from the dataset, import the datafiles, and then return the combined pandas DataFrame Arguments: path => string, path to the directory containing th...
5fe155a646573315ba63f4579407656a7f0af6bb
navneetpurohitt/LibraryManagementSystem
/check.py
2,206
4.1875
4
## import pickle # Let we create a class class Car: def __init__(self, name, model, color): self.name = name self.model = model self.color = color def display(self): print(self.name, "\t", self.model, "\t", self.color) def dump(): with open("car.pkl", "wb") as f: l...
e9ed1f96ff9806251fbe107b11b887c98825a5c4
adamltyson/imlib
/imlib/array/size.py
759
4.15625
4
import numpy as np def pad_with_number_1d(array, final_length, pad_number=0): """ For a given array, pad with a value (symmetrically on either side) so that the returned array is of a given length. :param np.array array: Input array. :param int final_length: How long should the final array be. ...
00357bbb66656ce9c0e36e8c1dcd090ed77ed3fc
Harshhg/Apache_Spark
/py code/Spark RDD/RDD_word_count.py
1,433
3.8125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import findspark findspark.init('/home/ec2-user/spark') # In[2]: import pyspark from pyspark import SparkContext # In[3]: sc = SparkContext() # In[33]: # Creating a RDD data = ["Hello world how are you? are you ok? thanks world"] rdd = sc.parallelize(data) ...
554b81a4fd49416c21baf3b30fc7f39d4b29860e
gibbson/bootcamp
/thirdday.py
673
3.671875
4
import numpy as np xa_high = np.loadtxt('data/xa_high_food.csv', comments='#') xa_low = np.loadtxt('data/xa_low_food.csv', comments='#') def xa_to_diameter(xa): """ Convert an array of cross_sectional areas to diameters with commuensurate units """ # Compute diameter from area # A = pi * d^2 / 4 ...
91f35ccdb4e4a3dcaf5c05f68af985bb9cd90ae9
bj730612/Bigdata
/01_Jump_to_Python/Chapter05/185.py
494
3.625
4
class Service: secret = "영구는 배꼼이 두 개다" name = "" def __init__(self,name): self.name = name print("맴버변수 %s 를 초기화 하였습니다." %self.name) def sum(self, a, b): result = a + b print("%s님 %s + %s = %s 입니다." %(self.name, a, b, result)) def __del__(self): print("저희 서비...
c80d4ce37fd06f5e5b5671f598d285730f3d16ba
wsullivan17/Adoption-Center
/test1.py
701
3.75
4
class Animals: """Holds data for each individual animal""" def __init__(self, animal, age, status): self.animal = animal self.age = age self.status = status def to_string(self): return f"{self.animal} : {self.age} : {self.status}" #dog1 = Animals("b", "c", "d") #print(d...
e99eaca490fbc26c0d341b57513949e7e3e43bf9
77fang/sc-projects
/breakout_game/breakout.py
1,483
3.59375
4
""" stanCode Breakout Project Adapted from Eric Roberts's Breakout by Sonja Johnson-Yu, Kylie Jue, Nick Bowman, and Jerry Liao YOUR DESCRIPTION HERE """ from campy.gui.events.timer import pause from breakoutgraphics import BreakoutGraphics from campy.graphics.gobjects import GOval, GRect, GLabel FRAME_RATE = 1000 / ...
fd2692d10d396014b7f99cbd9cb887704b8085dc
expeon07/grid_position
/main.py
3,447
3.90625
4
from typing import Dict import string import matplotlib.pyplot as plt def assign_coordinates(starting_position: tuple, spacing: int) -> Dict: """ Assigns coordinates to the points Args: starting_position (tuple): Coordinates of point A1 spacing (int): Spacing per step on x column...
698da78ad82dd604b8a703ce18f6a2cd14584a45
danilsyah/python-learning
/12-If-Elif-Else/Main.py
1,200
3.8125
4
nilai1 = 75 nilai2 = 80 # nesting if if nilai1 == 75: print("nilai anda", nilai1) print("step 1") if nilai2 == 80: print("nilai anda", nilai2) print("step 2") nilai = 50 if nilai == 75: # equal eksplisit print("nilai anda :", nilai) if nilai is 60: # equal print("nilai anda :", ...
4f91284d77c5d8e9b529d721e29550b68977c838
mskyberg/Module7
/fun_with_collections/basic_tuple.py
1,202
4.375
4
""" Program: basic_tuple.py Author: Michael Skyberg, mskyberg@dmacc.edu Last date modified: June 2020 Purpose: Demonstrates the use of a basic tuple """ def average_scores(*args, **kwargs): """ Description: calculates the average of scores and returns a string :param: *args, score arguments :param: ...
7c9cbd2dbacc043455fb9fa59fb78e3608290c43
adusa1019/atcoder
/ABC087/A.py
182
3.578125
4
def solve(string): x, a, b = map(int, string.split()) return str((x - a) % b) if __name__ == '__main__': n = 3 print(solve('\n'.join([input() for _ in range(n)])))
f28bb47bc7f43d7c29947a5589920c8ed30dfdb9
sagudecod97/holbertonschool-higher_level_programming
/0x02-python-import_modules/2-args.py
393
3.828125
4
#!/usr/bin/python3 import sys if (__name__ == "__main__"): argv = sys.argv i = 1 if (len(argv) == 1): print("0 arguments.") elif (len(argv) == 2): print("1 argument:\n1: {:s}".format(argv[1])) else: print("{:d} arguments:".format(len(argv) - 1)) while (i < len(argv)):...
752d2010609004e61a8276b2e62e35c913b9a485
filipov73/python_fundamentals_september_2019
/07.Data Types and Variables - More Exercises/02. Exchange Integers.py
138
3.53125
4
a = int(input()) b = int(input()) print(f"Before:\na = {a}\nb = {b}") # a, b = b, a c = b b = a a = c print(f"After:\na = {a}\nb = {b}")
8181aefef00e17576c3fba1f57c400c697c2b0e6
Niccoryan0/OldPythonProjects
/Hangman/main.py
3,939
3.71875
4
import random # suits = ['Hearts', 'Diamonds', 'Spades', 'Clovers'] # ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') # values = {'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5, 'Six': 6, 'Seven': 7, 'Eight': 8, 'Nine': 9, 'Ten': 10, 'Jack': 10, 'Queen': 10, ...
39def8c8accd6ad0f726bce6fabca223246c98b7
jaquepalmeira/programasDiversos
/remove_repetidos.py
218
3.859375
4
def remove_repetidos(x): y = [] for i in x: if i not in y: y.append(i) return sorted(y) x=eval('[' + input("Digite os números da sua lista separados por vírgula:")+']') print (remove_repetidos(x))
e3ef1ac0af8b6a9a8c93d56dd0f2581613e04945
DarrenYee/Monash-Python-Projects-
/sorts.py
17,805
4.21875
4
""" Name: Darren Yee Jer Shien Student ID: 31237223 FIT2004 Assignment 1 """ def sort_counting_stable(new_list, column): ''' Precondition: new_list must have at least one item This is an a full implementation of the counting sort algorithm which is used to be used in the radix sort for question 1 of as...
a8beaf70cc33f1f2935116a27d71948b0d7829bf
chispa73/hello-world
/Change Machine Checkout.py
2,032
3.875
4
#Give correct change in canadian denominations as a cash register with the least number of coins import decimal #Value of Canadian denominations LOONIE = 1 TOONIE = 2 QUARTER = 25 DIME = 10 NICKEL = 5 PENNY = 1 #Ask user to input value of shopping cart goods_value = decimal.Decimal(input('Please enter the...
4a35d766b71e9471abb77014bbc31caf5eab1ebb
kmgowda/kmg-leetcode-python
/palindrome-permutation/palindrome-permutation.py
440
3.703125
4
// https://leetcode.com/problems/palindrome-permutation class Solution(object): def canPermutePalindrome(self, s): """ :type s: str :rtype: bool """ d= collections.Counter(s) odd = 0 for cnt in d.values(): if cnt % 2: odd += 1 ...
a08009727d95fa01c25f32da1756612cbb69e7f1
raviqqe/char2image.py
/char2image/__main__.py
690
3.53125
4
import argparse import json import sys from . import char2image def get_args(): parser = argparse.ArgumentParser() parser.add_argument('document_file', nargs='?', type=argparse.FileType(), default=sys.stdin) parser.add_argument('-s', '--size', type=int, default=32) parser.add_...
58f11c5cc8ea4b0138e34902ecfc97676ac54dc2
hb5105/LabsSem6
/IT LAB/WEEK4/week4/week4/q2.py
452
3.796875
4
class Pair: def pairs(self): flag=0 a=input("enter a list of numbers\n").split(' ') targ=int(input("enter target value:\n")) print("the pairs are:") for i in range(len(a)): for j in range(i+1,len(a)): if(int(a[i])+int(a[j])==targ): ...
a22c6fa520b234182e5e6956572eb3219913864a
carlhurst/introduction-to-computer-science
/GUI-Drawing-Different-Shapes/Drawing_Multiple_Squares.py
708
3.796875
4
import time from graphics import * import random import time # This programme is designed to create a number of squares based on user clicks # Author Carl Hurst # Create a window win = GraphWin("",300,300) def draw_Square(x,y): s1 = Rectangle(Point(x,y),Point(x+30,y+30)) s1.setFill("Red") s1.draw(win)...
32956bd830c62d244645963c5eeacc60f5aade1c
Hemanadh/Python-tutorial
/Class.py
476
3.546875
4
class Dog: def __init__(self,color,breed): self.color=color self.breed=breed def speak(self): print("bhou..bhou") def wish(self,name): print("hello, " + name) def hi(self): print("I am a {} colored {}".format(self.color,self.breed)) tommy = Dog("yellow...
bfbc6c9747f6d766e5600d584633482d98db9154
TheSleepingAssassin/CodeFolder
/py/School/FINAL/Practice Worksheet/Q2/app.py
132
4.28125
4
n = int(input("Enter a number: ")) if n % 7 == 0: print("It is divisible by 7.") else: print("It is not divisible by 7.")
beb4a9fe7841fa81b5967e6019ec47d1465bc3f0
jimwh/pydev
/fibonacci.py
1,308
4.375
4
#!/usr/bin/python # generators are used to generate a series of values # yield is like the return of generator functions # the only other thing yield does is ave the "state" of a generator function # a generator is just a special type of iterator # like iterators, once can get the next value from a generator using nex...
16c31d7468e2ff3d226a1055a15f08b4d8c19043
zhuohuwu0603/interview-algothims
/lecture_basic/Lecture7.Array__Numbers/56. Two Sum.py
751
3.96875
4
''' Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are zero-based. E...
12ac373f4821c6fdda2bd2da461dfdc815444d99
paulkoerbitz/pauls_tools
/math.py
1,711
3.859375
4
"""Some handy math tools""" import numpy as np from scipy import derivative def diff(f, x, i, n=1, eps=0.01, n_points=3): """Takes the i-th derivative of a multi-dimmensional function """ def func_for_diff(x_i): return f(np.concatenate((x[:i],[x_i],x[i+1:]))) x = np.atleast_1d(x) return ...
0bc6d583a5fb3675d79bd0b45154886a677c6bf9
aamerino/Ejercicios-Iniciacion-Programacion
/21.py
1,784
4.21875
4
# Escribe un programa que solicite por teclado 5 números positivos, # forzando al usuario a que únicamente introduzca valores positivos. # A continuación el programa tiene que escribe cuál es el valor más # pequeño y cuál es el mayor valor de los introducidos por el usuario. def numMayorMenor(listNum): for i in l...
77e12af650c5126b385966a785da934be816e2fe
KnightZhang625/Data_Structures_and_Algorithms
/3_2_Union.py
1,721
3.84375
4
class Union(object): class node(object): def __init__(self,data,parent): self.data = data self.parent = - parent def __str__(self): return str(self.data) + ' ' + str(self.parent) + '\n' def __init__(self): self.list_1 = [] def add_union(self,s...
3bb288529fac9ccfb774167169216b631e14fa5d
bluehat7737/pythonTuts
/47_joinFunction.py
279
4.21875
4
list = [ "C", "C++", "Python", "Java", "JavaScript", "R", "Ruby" ] for items in list: print(items+" and", end=" ") print("other languages.") # join function a = " and ".join(list) print("\n"+a) a = " , ".join(list) print("\n"+a) a = " or ".join(list) print("\n"+a)
a4aea2cc4bf75b03d6d16b73cca916d0d9858ab4
sdivakarrajesh/Interview-Prep-questions
/Module 3/9/answer-py.py
549
4
4
from math import sqrt start,end = map(int,input().split()) def isPrime(n): for i in range(2,int(sqrt(n))): i = int(i) if n%i== 0: return False return True def isCircular(n): length = len(n) for i in range(0,length): n = n[1:] + n[0] if isPrime(int(n)): ...
a201d99807e53899dee99adddf5549986d9599c2
gschen/where2go-python-test
/1906101038江来洪/day20191115/训练题_3.py
187
3.65625
4
#小明买了多少罐啤酒. y = 0 s = 0 while True: for x in range(y+1): if x*23+y*19 == 823: print(x) s += 1 y += 1 if s != 0: break
24a2633d5631df7e7c6d6356fc7c574fda11f00f
flilyday/upgrade
/vervreqests/22.str combination on method.py
2,301
3.875
4
# 22.str combination on method.py # 0. 기본적인 사용 방법 # String formatting method calls : '메도스 호출'을 통해 문자열 조합하기 # '__{}_{}__'format(value, value) 스타일 문자열 조합 fs = '{0}...{1}...{2}' ms = fs.format('Robot', 125, 'Box') #.format은 매소드이다. print(ms) print('{0}...{1}...{2}'.format('Robot', 125, 'Box')) print('{2}...{1}...{0}'.fo...
a231eb0e038c0cf9e05c6899b6b69f681ed9fa40
vin136/lagom
/lagom/runner/base_runner.py
1,400
3.671875
4
from abc import ABC from abc import abstractmethod from lagom.envs.vec_env import VecEnv class BaseRunner(ABC): r"""Base class for all runners. Any runner should subclass this class. A runner is a data collection interface between the agent and the environment. For each calling of the run...