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
95ae69a68f37ef7311380514541995a36f7c8686
golan1202/verilog-parser
/data_from_csv.py
768
3.5
4
import csv import os import sys def parse_from_csv(fname): if os.path.exists(fname) and os.stat(fname).st_size != 0 and fname.endswith('.csv'): with open(fname) as f: data = dict() try: reader = csv.reader(f, delimiter=',') next(reader) # skip the h...
b0a07c7c13f8973b1406df6a06b86710ead5581d
rebetli6/first_project
/data_structures.py
146
3.640625
4
name = ["John Doe", "Jack Doe"] print(len(name)) print(name[1]) numbers= [11, 24, 55, 12, 21] s=0 for c in numbers: s += c print(c) print(s)
67dd8f9a9ace275c3abbe429744e82e558918189
CesarNaranjo14/selenium_from_scratch
/create_pickles.py
1,111
3.578125
4
""" DESCRIPTION Create a set of pickle files of neighborhoods. These files are for the use of giving the crawlers a "memory", that is, we remove a neighborhood every time a crawler finishes to scrap it in order to not iterate again. HOW TO RUN You have to run inside this directory: python create_pickle start """ ...
f1579f18820ec92be33bbf194db207d4b8678b89
nonelikeanyone/Robotics-Automation-QSTP-2021
/Week_1/exercise.py
717
4.1875
4
import math def polar2cart(R,theta): #function for coonverting polar coordinates to cartesian print('New Coordinates: ', R*math.cos(theta), R*math.sin(theta)) def cart2polar(x,y): #function for coonverting cartesian coordinates to polar print('New Coordinates: ', (x**2+y**2)**(0.5), math.atan(y/x)) print('Conver...
6c3a9013ec4b575035995144a1239ebc2f2d97ff
yuhaitao10/Language
/python/first-class/first_class_fun.py
288
4.03125
4
#!/usr/bin/python def square(x): return x*x def cube(x): return x*x*x def my_map(func,arg_list): result = [] for i in arg_list: result.append(func(i)) return result squares = my_map(square, [1,2,3,4,5,6]) print(squares) cubes = my_map(cube, [1,2,3,4,5,6]) print(cubes)
4f4fddc6e1b35d24a52d7cbf4e3468aab4bca6d2
yuhaitao10/Language
/python/scripts/data_types.py
1,486
3.984375
4
#!/usr/bin/python #working on dictionary print "\nWorking on dictionary" hosts = {} hosts['h1'] = '1.2.3.4' hosts['h2'] = '2.3.4.5' hosts['h3'] = '3.4.5.6' for server,ip in hosts.items(): print server, ip for server,ip in hosts.items(): print ('serer: {} ip: {}'.format(server, ip)) hosts2 = {'h1':'1.2.3.4','h2'...
eb2fa02366ac7da73b69491e146e50dc6c4f9072
zhngfrank/notes
/pynotes.py
3,222
4.40625
4
#division normally operates in floating point, to truncate and get integer division use #// e.g. print ("3//5 = ", 3//5, "whereas\n3/5 =", 3/5) #when python is used as a calculator, e.g. through python3 command terminal, the last saved answer #is stored in the variable "_" (underscore). same as 2nd ans on TI calcul...
07fa76c6a9fcbc33d34229f1e62c27e22ec93365
juanperdomolol/Dominio-python
/ejercicio15.py
595
4.1875
4
#Capitalización compuesta #Crear una aplicación que trabaje con la ley de capitalización compuesta. #La capitalización compuesta es una operación financiera que proyecta un capital a un período futuro, # donde los intereses se van acumulando al capital para los períodos subsiguientes. capitalInicial= float(input("Cu...
70d854315f7ccfd8d4a3f46d604991b7a41f82d6
juanperdomolol/Dominio-python
/ejercicio3.py
630
3.890625
4
#Intervalos #Generar un número aleatorio entre 1 y 120. #Decir si se encuentra en el intervalo entre 10 y 50, o bien si es mayor de 50 hasta 100, # o bien si es mayor de 100, o bien si es menor de 10. import random Aleatorio = random.randrange(1, 120) if (Aleatorio>10 and Aleatorio<50): print("se encuentra en ...
3c82383327e8e17cb8b22247916cb89861c50d46
thouis/plate_normalization
/welltools.py
377
3.5625
4
import re def extract_row(well): well = well.upper().strip() if len(well) > 0 and 'A' <= well[0] <= 'P': return well[0] return '(could not parse row from %s)'%(well) def extract_col(well): # find the first block of numbers m = re.match('[^0-9]*([0-9]+)', well) if m: return m.gr...
865f27d25b6f07ac8fb8ff2564ad663641104943
michael-deprospo/OptionsTradingProject
/MultiRegression.py
1,999
3.625
4
from yahoo_fin import stock_info as si import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model from sklearn.model_selection import train_test_split #This class pertains to multiple linear regression modeling, with ordinary least squares as the loss function. This class...
c8bf6025d729849c121bd1b9ad4702dfae8a3a13
brobinson124/ai3202
/Assignment5/assignment5.py
6,478
3.5
4
#Brooke Robinson #Assignment 5 #Used Assignment 2 as a base #Worked with Mario Alanis import sys class Node:#node represent a grid squard def __init__(self, locationx, locationy, type_val): self.x = locationx self.y = locationy self.p = None self.typeN = type_val #0 is free, 1 is mountain, 2 is wall, 3...
baf478cdd62e5bd29bfaaa725f32fa2d041ae191
louissock/Python-PPA
/ccipher.py
6,844
3.84375
4
""" Filename: ccipher.py Author: Sang Shin Date: 09/05/2012 """ #!/bin/env python import sys CONST_ALBET = 'abcdefghijklmnopqrstuvwxyz' MOD_ALBET = '' def exit_program(): # Prompt the user with a exiting greet and terminate. print "Thank you for using the Caesar Cipher Program." print "Have a ...
fcd42737dc107cd0ddda3a5ea2963abbca0bff55
louissock/Python-PPA
/gasoline.py
1,469
3.671875
4
""" Filename: gasoline.py Author: Sang Shin Date: 08/09/2012 """ #!/bin/env python from __future__ import division CONVERSION_GAL_LITER = 3.7854 CONVERSION_GAL_BARREL = 19.5 CONVERSION_GAL_POUND = 20 CONVERSION_GAL_ENERGY = 115000 CONVERSION_GAL_ENERGY_ETH = 75700 CONVERSION_GAL_DOLLAR = 4.00 def main(): ...
ff69e17bc700225f4eb40e087d613599d79aedfa
louissock/Python-PPA
/digicount.py
847
3.734375
4
""" Filename: digicount.py Author: Sang Shin Date: 08/10/2012 """ #!/bin/env python def userInputChecker(diag): check = 1 while check == 1: try: inp_str = raw_input(diag) inp_int = int(inp_str) check = 0 except ValueError: check = 1 ...
a57504d5e5dd34e53a3e30b2e0987ae6314d6077
MattCoston/Python
/shoppinglist.py
298
4.15625
4
shopping_list = [] print ("What do you need to get at the store?") print ("Enter 'DONE' to end the program") while True: new_item = input("> ") shopping_list.append(new_item) if new_item == 'DONE': break print("Here's the list:") for item in shopping_list: print(item)
5682494536ebd893e233685b4395290391c6c2b2
VanSC/Lab7
/Problema6.py
575
3.875
4
pares=0 impares=0 neutro=0 negativos=0 positivos=0 limite=5 for x in range(limite): number=int(input("ingres el numero ")) if number % 2 == 0: pares+=1 else: impares+=1 if x<0: negativos+=1 else: positivos+=1 if number == 0: neutro = 0 pr...
edea61d2217ce4cb2beceb5211bfbd0a844b4a1a
dennisliuu/Coding-365
/102/003.py
795
3.828125
4
import math triType = input() triHeight = int(input()) if triType == '1': for i in range(1, (triHeight + 1) // 2 + 1): for j in range(1, i + 1): print(j, end='') print() for i in range(1, (triHeight + 1) // 2): for j in range(1, (triHeight + 1) // 2 - i + 1): pr...
5635f384336ab7a9cda34f2217deb0b2aede9388
dennisliuu/Coding-365
/101/001.py
337
3.765625
4
name = input("姓名:") std_id = input("學號:") score1 = int(input("第一科成績:")) score2 = int(input("第二科成績:")) score3 = int(input("第三科成績:")) total = score1 + score2 + score3 print("Name:" + name + '\n' + "Id:" + std_id + '\n' + "Total:" + str(total) + '\n' + "Average:" + str(int(total/3)))
f174320582815cb1397828890720288b72bab536
dennisliuu/Coding-365
/103/003.py
2,800
3.75
4
# class poly: # __a = [0]*20 #存放第一个输入的多项式和运算结果 # __b = [0]*20#存放输入的多项式 # __result = [0]*20#结果 # def __Input(self,f): # n = input('依序输入二项式的系数和指数(指数小于10):').split() # for i in range(int(len(n)/2)): # f[ int(n[2*i+1])] = int(n[2*i]) # print(f, n) # self.__output...
b33e6d93be650bfcfe25852ffd17b411915c7d4f
ghmkt/3th_EDU
/Session03_Python_element_3/Session03_Quest_answer_3.py
1,838
3.609375
4
# 클래스 연습문제 class stock_analysis: def __init__(self, code): try: with open("c:\\Users\\LYJ\\Desktop\\파이썬세션데이터\\{0}.csv".format(code)) as f: self.lines = f.readlines() except FileNotFoundError: print("{0} 파일을 로드하는데 실패했습니다".format(code)) else: self.le...
5c9da03dc72008401f422d092f27b27bedd28177
AspenH/K-Nearest-Neighbor-Algorithm
/knn.py
3,625
3.78125
4
# Programmed by Aspen Henry # This program uses two .csv files within its directory (trainging data and test sample data) # to classify test samples using the K Nearest Neighbor algorithm. import math #This function is used to preformat the csv files for use #It assumes that the csv is in the form [class_label, a1, a2...
df3157fb21a7d9d35fdd8ce4550733a859f3a64c
Potrik98/plab2
/proj5/fsm/utils.py
166
3.625
4
# # Check if a string is an integer # def is_int(string: str) -> bool: try: int(string) return True except ValueError: return False
c259e8f8f0be2ae221e13062855d370df14d9691
Potrik98/plab2
/proj3/crypto/AffineCipher.py
1,281
3.5
4
from crypto.SimpleCipher import SimpleCipher from crypto.Cipher import Cipher, alphabet, alphabet_length from crypto.MultiplicationCipher import MultiplicationCipher from crypto.CaesarCipher import CaesarCipher class AffineCipher(SimpleCipher): class Key(Cipher.Key): def __init__(self, ...
ec44a59c2bfda5f812b86363dd4ad98c114361a1
yashmalik23/python-domain-hackerrank
/the minion game.py
339
3.515625
4
def minion_game(s): vowels = 'AEIOU' kev = 0 stu = 0 for i in range(len(s)): if s[i] in vowels: kev += (len(s)-i) else: stu += (len(s)-i) if kev > stu: print ("Kevin", kev) elif kev < stu: print ("Stuart", stu) else: ...
7ebd2319068650b767db0961f553832b4af556b1
PythonHacker199/Bargraph-3d-
/main.py
541
4.09375
4
# Hi gus #welcome to hacker python channel # today we will learn how to make bar graph #we need to install matplotlib package from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig=plt.figure() ax1=fig.add_subplot(111,projection='3d') xpos=[1,2,3,4,5,6,7,8,9,10] ypos=[1,2,3,4...
2b908cba6c3ff6eea86011228e03224a22bec643
Kenneth-Fries/Kenneth_Fries
/Pairs 2-25-19 best path.py
5,195
4.25
4
"""The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess. The knight has an in...
27fd01141cf75a31a087b5fa5b47e7b203b0bdbd
FuelRats/pipsqueak3
/src/packages/utils/autocorrect.py
1,450
3.578125
4
""" autocorrect.py - Methodology to attempt auto-correcting a typo'd system name. Copyright (c) 2019 The Fuel Rat Mischief, All rights reserved. Licensed under the BSD 3-Clause License. See LICENSE.md This module is built on top of the Pydle system. """ import re def correct_system_name(system: str) -> str: ...
7c967ec0e9a7286ab5569133662f8966efcfd80b
coder-kiran/pythonCalculator
/pythonCalculatorByKK.py
10,311
3.625
4
# Python Calculator by Kiran K K from tkinter import * from tkinter.messagebox import * import math window = Tk() window.geometry("230x350") window.title("I Calculate") window.configure(bg='#000066') window.resizable(0,0) s0 = s1 = s2 = "" famous="" equalClickedOn = False font=('verdana',10) #------------------ funct...
331ea7efc532c4d9f09da6b6497be679c91de9ff
layanabushaweesh/math-series
/tests/serises_test.py
1,828
3.65625
4
# testing fibonacci function :) from math_serises.serise import fibonacci def test_fib_0(): expected=0 actual=fibonacci(0) assert actual == expected def test_fib_1(): expected=1 actual=fibonacci(1) assert actual == expected def test_fib_2(): expected=1 actual=fibonacci(2) assert actual == expected def test...
b6a2e295b45e45114c947f339cfae96b8faa8229
rompe/adventofcode2020
/src/day02.py
503
3.71875
4
#!/usr/bin/env python import itertools import sys def solution(input_file): """Solve today's riddle.""" lines = open(input_file).read().splitlines() valids = 0 for line in lines: count, char, password = line.split() char = char[0] lowest, highest = count.split('-') if ...
d0bca1738a9a21e3888084c65786e73bff22fe7d
CodecoolBP20161/python-pair-programming-exercises-4th-tw-miki_gyuri
/3-phone-numbers/main.py
1,266
3.796875
4
import csv import sys from person import Person def open_csv(file_name): with open(file_name, 'r') as phone_number: names_n_numbers = [line.split(",") for line in names_n_numbers.readlines()] numbers = [] numbers = numbers.digits for element in names_n_numbers: for i in...
f62b64433ab03f57cc107b63c7c853590be44a9f
koiku/nickname-generator
/main.py
1,028
3.640625
4
""" * 0 - Vowel letter * * 1 - Consonant letter """ import random VOWELS = ['a', 'e', 'i', 'o', 'u', 'y'] CONSONANTS = [ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z' ] MIN_LEN = 3 MAX_LEN = 8 def main(): length = random.randint(MIN_LEN, MAX_LEN) nickname...
d924bcfa89f8453db0f96e452469e2bbd15c21d3
ScottRWilson11/WebScrapingHW
/webscraping.py
889
3.546875
4
import pandas as pd from bs4 import BeautifulSoup import requests url1="https://www.nasa.gov/feature/jpl/nasas-next-mars-mission-to-investigate-interior-of-red-planet" r = requests.get(url1) data = r.text soup = BeautifulSoup(data, features="html.parser") news_title = soup.title.text print(news_title) ta...
64b86298ac0017b88bf25e6d658a6bc9b4c22d0a
panwuying/homework5
/work6.py
203
3.53125
4
a="4 4 213 123 124 1 123 " a=a.split() a=[int(x) for x in a] def all_list(b): c = min(b) for i in range(len(b)): if c==b[i]: print(i) break all_list(a)
96aa4c549c9a5341a565699832cdbbf30ff406e7
liweinan/hands_on_ml
/sort_class.py
982
4.125
4
from collections import OrderedDict class Student: def __init__(self, name, order): self.name = name self.order = order tom = Student("Tom", 0) jack = Student("Jack", 0) rose = Student("Rose", 1) lucy = Student("Lucy", 2) users = OrderedDict() users[rose.name] = rose users[lucy.name] = lucy user...
6c112be7a3443ebd31b68bfe73f424af50ca34af
abhishekshrestha008/Binary-and-Linear-Search-Algorithms
/searchMain.py
1,242
3.84375
4
import random from search import linear_search, binary_search from time import time import matplotlib.pyplot as plt elapsed_linear = [] elapsed_binary = [] x = [] for i in range(10000, 100000, 10000): #Data data = random.sample(range(i), i) sorted_data = sorted(data) random_number = random.randint(0,len(da...
ebb33953daccc725fab8383a652c8fd60c181ff1
ferdirn/hello-python
/python_min.py
185
3.65625
4
#!/usr/bin/env python list1, list2 = ['xyz', 'abc', 'opq'], [8, 9, 3, 5, 6] print 'list1', list1 print 'list2', list2 print 'min(list1)', min(list1) print 'min(list2)', min(list2)
be66511c268ce38ea8d4e3ce561894c390bccbc2
ferdirn/hello-python
/hari.py
349
3.84375
4
#!/usr/bin/env python nama_hari = raw_input('Masukkan nama hari : ') if nama_hari == 'sabtu' or nama_hari == 'minggu': print 'Weekends' elif nama_hari == 'senin' or nama_hari == 'selasa' or nama_hari == 'rabu' or nama_hari == 'kamis': print 'Weekdays' elif nama_hari == "jum'at": print 'TGIF' else: pri...
7937dba17b2af72fcedc087ce51375b73258e3e0
ferdirn/hello-python
/yourname.py
195
3.875
4
#!/usr/bin/env python firstname = raw_input('Your first name is ').strip() lastname = raw_input('Your last name is ').strip() print "Hello {} {}! Nice to see you...".format(firstname, lastname)
4de4ba9a0b6507c01147f52527413bfbf0305982
ferdirn/hello-python
/ternaryoperator.py
231
4.1875
4
#!/usr/bin/env python a = 1 b = 2 print 'a = ', a print 'b = ', b print '\n' #ternary operator print 'Ternary operator #1' print 'a > b' if (a > b) else 'b > a' print '\nTernary operator #2' print (a > b) and 'a > b' or 'b > a'
fc7b4eb2b4ffe1f9021b3cf27842600cdc88e098
ferdirn/hello-python
/bitwiseoperators.py
337
3.796875
4
#!/usr/bin/env python print 'binary of 5 is', bin(5)[2:] print 'binary of 12 is', bin(12)[2:] print '5 and 12 is', bin(5&12)[2:] print '5 or 12 is', bin(5|12)[2:] print '5 xor 12 is', bin(5^12)[2:] print 'not 5 is', bin(~5) print '2 shift left 5 is', bin(5<<2)[2:], ' or ', 5<<2 print '2 shift right 5 is', bin(5>>2)[2...
986e29934e3ad5528978247f8eaf1be4173e10e3
ferdirn/hello-python
/comparison_operators.py
411
3.546875
4
#!/usr/bin/env python print 'is equal' print '10 == 20 ' + str(10 == 20) print '\nis not equal' print '10 != 20 ' + str(10 != 20) print '10 <> 20 ' + str(10 <> 20) print '\ngreater than' print '10 > 20 ' + str(10 > 20) print '\nless than' print '10 < 20 ' + str(10 < 20) print '\ngreater than or equal to' print '10...
683501e8b36347e0fc89b461d33ca8ade2457895
ferdirn/hello-python
/kelvintofahrenheit.py
294
3.796875
4
#!/usr/bin/env python def KelvinToFahrenheit(temperature): assert (temperature >= 0), "Colder than absolute zero!" return ((temperature-273)*1.8)+32 try: print KelvinToFahrenheit(273) print KelvinToFahrenheit(-5) except AssertionError, e: print e.args print str(e)
4da324086fd2415baf3a247e24841560fc29a8b1
sharpvik/python-libs
/search.py
2,353
3.640625
4
# # ================================== BBBBBB YY YYY MMMM MMMM RRRRRR VV VVV RRRRRR # = THE = BBB BB YY YYY MMMMM MMMMM RRR RR VV VVV RRR RR # ===> Search functions library <=== B...
fb89441290c0ebb8992bbe6ac22ef88da84b0afd
sharpvik/python-libs
/graphD.py
5,155
3.734375
4
# # =============================== BBBBBB YY YYY MMMM MMMM RRRRRR VV VVV RRRRRR # = THE = BBB BB YY YYY MMMMM MMMMM RRR RR VV VVV RRR RR # ===> Graph class <=== BBBBBB ...
55075c4e6d4561690da93b466a2f1a7c2319be64
MMahoney6713/cs50
/pset6-Python/credit.py
243
3.640625
4
card = input('Card Number? ') var = 0 for i in range(1, length(card), 2): value = int(card(i)) * 2 if value > 9: value = str(value) value = int(value[1]) + int(value([2]) var += value print(f"{round_1_sum}")
4b089ecb061076b81df93e125f0b86f259b3197d
bognan/training_python
/guess the random namber/random number from computer.py
1,121
3.703125
4
import random number = random.randint(1, 100) users_count = int(input('Введите количество игроков: ')) users_list = [] for i in range(users_count): user_name = (input(f'Введите имя игрока {i}: ')) users_list.append(user_name) count = 1 levels = {1: 10, 2: 5, 3: 3} level = int(input('Выбирете уровень сложнос...
2bc2bbc4f60dddbef026efbc41a63ab24182cd25
bognan/training_python
/HW/HW№2.py
234
4.03125
4
number = int(input('Введите любое число: ',)) while (number > 10) or (number < 0): number = int(input('Побробуйте еще: ',)) else: if number <= 10: print('Результат:', number ** 2)
4415824dde9566902bf6a7bb9015764785597c02
mateusPreste/Testing
/Testing/Plot.py
202
3.65625
4
from matplotlib.pyplot import * import numpy as np def f(t): return t**2*np.exp(-t**2) t = np.linspace(0, 3, 310) y = np.zeros(len(t)) for i in range(len(t)): y[i] = f(t[i]) plot(t, y) show()
6b94e8638f16b58df5460af29cb8f13e2a8e53bc
mittalpranjal12/Basic-Python-Codes
/swap_two_numbers.py
312
4.09375
4
#swap two numbers x = int(input("Enter first number: x= ")) y = int(input("Enter second number: y= ")) print("Value of x and y before swapping is {0} and {1}" .format(x,y)) #swapping using temp temp = x x = y y = temp print("\nThe value of x and y after swapping is {0} and {1}" .format(x ,y))
9392258cba43a64ce272d77ab90b889c020946d9
LorenBristow/module3
/ch04_UnitTesting/is_prime.py
1,237
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 28 10:00:27 2019 @author: loren """ #### TASK 1 - PRIME NUMBERS to FAIL & TASK 2 - to PASS #### def is_prime(number): '''Return True if number is a prime number''' if number <= 1: return False elif number > 1:#to prevent div by 0 error for ea...
771b2e1c61a2466875e9b9ed32ba91d9c7625e01
ChChLance/sc_project
/stancode_project/boggle_game_solver/boggle.py
3,669
3.90625
4
""" File: boggle.py Name: ---------------------------------------- TODO: """ # This is the file name of the dictionary txt file # we will be checking if a word exists by searching through it FILE = 'dictionary.txt' word_lst = [] bog_lst = [] ans_lst = [] legal_edge = [] record_lst = [] look_up_dict = {} def main(): ...
0d6582833054a0596747ea349f9d714deeb5b355
fxyan/data-structure
/code/反转链表.py
214
3.859375
4
def reverseList(head): """ :type head: ListNode :rtype: ListNode """ q = None while head is not None: p = head head = head.next p.next = q q = p return q
9185b85e3286d25f7e59612585b183302cb81b47
fxyan/data-structure
/queue.py
813
4.0625
4
class Node(object): def __init__(self, element=None, next=None): self.element = element self.next = next def __repr__(self): return str(self.element) class Queue(object): def __init__(self): self.head = Node() self.tail = self.head def empty(self): ret...
e86aed6b3987db89dd58700410da0a25a030f5f7
fxyan/data-structure
/code/剑指/删除链表中重复的节点.py
1,226
3.96875
4
""" 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留。 样例1 输入:1->2->3->3->4->4->5 输出:1->2->5 样例2 输入:1->1->1->2->3 输出:2->3 这个题是比较绕的,思路有些清奇 首先先设定一个虚拟节点 None 将他的next连到头结点上去 p永远是前一个节点 q是p的下一个节点 while 如果让q等于p.next 直到q的值为一个新的节点的值 然后拿 p的第二个节点对比如果相等那么p直接下移 如果不等那么将p的next指向q """ # Definition for singly-linked lis...
99bad259f692251137282ccf7b168ba6a67d1ac0
fxyan/data-structure
/code/lookup_array.py
654
3.6875
4
""" 二维数组查找数据 首先确定行数和列数 将左下角第一个数设为n 如果这个整数比n大,那么就排除这一行 向上查询 如果这个整数比n小,那么就排除这一列像右查询 """ class Solution: # array 二维列表 def Find(self, target, array): # write code here rows = len(array) - 1 cols = len(array[0]) - 1 i = rows j = 0 while j <= cols and i >= 0: ...
97b3f526a267e916bb6ae64e4a1db6b5d5bb372d
fxyan/data-structure
/code/剑指/机器人移动范围.py
1,394
3.578125
4
""" 地上有一个 m 行和 n 列的方格,横纵坐标范围分别是 0∼m−1 和 0∼n−1。 一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格。 但是不能进入行坐标和列坐标的数位之和大于 k 的格子。 请问该机器人能够达到多少个格子? 样例1 输入:k=7, m=4, n=5 输出:20 样例2 输入:k=18, m=40, n=40 输出:1484 解释:当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。 但是,它不能进入方格(35,38),因为3+5+3+8 = 19。 这里还是用了深搜 """ class Solution(object): ...
d926c569be01e185ea52383e988360694ec1809c
fxyan/data-structure
/Array.py
602
3.96875
4
# 定长的列表 class Array(object): def __init__(self, size=8): self._size = size self._item = [None] * size def __len__(self): return self._size def __getitem__(self, index): return self._item[index] def __setitem__(self, key, value): self._item[key] = value def...
348fd28791be8033b293c27087b6861ec35b6989
fxyan/data-structure
/exercise.py
12,479
4.0625
4
""" 冒泡排序 首先从第一个数循环到倒数第二个数 n-1 最后一个数已经被安排了 内层循环开始从第一个数开始循环 n-1-i次,因为i也被安排了 边界检测如果为没有数 def bubble_sort(array): if array is None or len(array) < 2: return array for i in range(len(array)-1): for j in range(len(array)-i-1): if array[j] > array[j+1]: array[...
8880877537ac0e945bde820806c56cb008125b9f
leox64/ADT
/Array.py
1,087
3.78125
4
#array class Array: def __init__(self,n): self.data=[] for i in range(n): self.__data.append(None) def get_length(self): return len(self.__data) def set_item(self,index,value): if index >= 0 and index < len(self.__data): self.__data[index...
ffc2780064c17ff9d45e2b817fbd0c4208c330a9
Anthonywilde1/pythonpractice
/practice.py
814
3.828125
4
# Fibonacci series: # the sum of two elements defines the next a, b = 0, 1 while a < 1000: print(a) a, b = b, a+b letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] name = letters[0] + letters[13] + letters[19] + letters...
91764a0218ca3632eac11064e1312c30e1ead470
SrCarlangas1/Practica7
/Exercici_06.py
233
3.828125
4
print "Dime un nombre" prime=raw_input() pepe=list(prime) print pepe print "Dime un caracter" susti=raw_input() if susti in pepe: print "El caracter esta en tu nombre" else: print "El caracter no esta en tu nombre"
c3bc1f9db4fd2ab9b4ba40ce7e8d69b0da87fd42
lior20-meet/meet2018y1lab2
/MEETinTurtle.py
972
4.15625
4
import turtle turtle.penup() #Pick up the pen so it doesn’t #draw turtle.goto(-200,-100) #Move the turtle to the #position (-200, -100) #on the screen turtle.pendown() #Put the pen down to start #drawing #Draw the M: turtle.goto(-200,-100+200) turtle.goto(-200+50,-100) turtle.go...
7235257c51e5a1af67454306e76c5e58ffd2a31c
VeronikaA/user-signup
/crypto/helpers.py
1,345
4.28125
4
import string # helper function 1, returns numerical key of letter input by user def alphabet_position(letter): """ Creates key by receiving a letter and returning the 0-based numerical position of that letter in the alphabet, regardless of case.""" alphabet = string.ascii_lowercase + string.ascii_uppercase ...
ed3c20641bdad8b23f85153994fef6345af81de5
echibe/Projects
/Python/Scrape.py
660
3.796875
4
#Elliot Chibe #September 15th, 2016 #Given a YouTube video link this will output the title, description, and user of the video #Uses BeautifulSoup and requests for Python import requests from bs4 import BeautifulSoup url = raw_input("What is the URL: ") r = requests.get(url) soup = BeautifulSoup(r.content, "lxml") ...
a87fe2d7477098d5cb41c018fccc47b787b1ff8d
rlazarev/powerunit
/powerunit.py
1,048
3.65625
4
#!/usr/bin/env python # Import the modules to send commands to the system and access GPIO pins. from subprocess import call import RPi.GPIO as GPIO from time import sleep # Map PinEleven and PinThirteen on the Power.unit PCB to chosen pins on the Raspberry Pi header. # The PCB numbering is a legacy with the original ...
3f4b48b07ce6785b6a30ab7651d62ab2b730adc3
MBScott1997-zz/Python_Projects
/Scott_MarvelMart.py
7,535
3.640625
4
''' Python Project - Marvel Mart Project Michael Scott Due: March 10, 2020 ''' import csv import numpy as np import pandas as pd import collections from collections import defaultdict pd.set_option('display.float_format', lambda x: '%.3f' % x) #Part 1: Cleaning the data #Cleaning ints out of Country ...
237cbd779d44ac9cdc04edd467647769c4781c97
andxu282/poker_engine
/models/rank.py
510
3.546875
4
""" The rank of the card (2 through Ace). The rank is represented by a single character string (the number itself for 2-9 and T, J, Q, K, A for 10, Jack, Queen, King, and Ace respectively. """ from helpers.constants import rank_dict class Rank(): def __init__(self, rank_str): self.rank_str = rank_str ...
22f0b036d436b9d8b3021b349c612f7322720db3
sayalijo/my_prog_solution
/hacker_rank/Algorithms/Warmup/min_max_sum/min_max_sum.py
243
3.796875
4
#!/bin/python3 import sys def miniMaxSum(arr): # Complete this function x = sum(arr) print (x-(max(arr)), (x-(min(arr)))) if __name__ == "__main__": arr = list(map(int, input().strip().split(' '))) miniMaxSum(arr)
ff2c1fc5723a4c3309b97226e849bd0c7f824210
sayalijo/my_prog_solution
/geeks_for_geeks/Algorithms/Searching/binary_search/binary_search.py
566
4.0625
4
def binary_search(arr, x, start_index, end_index): if end_index >= 1: mid_index = start_index + (end_index - start_index)//2 if arr[mid_index] == x: return mid_index elif arr[mid_index] > x: return binary_search(arr, x,start_index, mid_index - 1) else: return binary_search(arr, x, mid_index+1, end_i...
c4d7076b3ef58086aa5b0d53c3168d5292e57836
sayalijo/my_prog_solution
/geeks_for_geeks/Arrays/arrangements/move_all_zeros_end/move_all_zeros_end.py
368
3.78125
4
# arr[] = {1, 2, 0, 0, 0, 3, 6} # Output : 1 2 3 6 0 0 0 def rearrange(ar): i,j = -1, 0 for j in range(len(ar)): if ar[j] > 0: i += 1 ar[i], ar[j] = ar[j], ar[i] return ar array = list(map(int, input("Enter your array:\t").split(" "))) result = rearrange(array) print("Now...
b5fe57756695c05b2f96eb62de309d88a45fb40f
sayalijo/my_prog_solution
/hacker_rank/Algorithms/Implementation/manasa_and_stones/manasa_and_stones.py
753
3.515625
4
#!/bin/python3 import sys def stones(n, a, b): a,b = min(a,b), max(a,b) diff = b - a stones = n - 1 current_stone = a * stones max_stone = b * stones #result = [] if a == b: #result.append(current_stone) yield current_stone return result else: while ...
4db6f63da2c03590a2765d346707db7667d82d36
jaykumarvaghela/python-for-fun
/printfunction.py
138
3.640625
4
n = int(input()) list = [] i = 1 while (i <= n): list.append(i) i = i + 1 for j in range(n): print(list[j], end="")
c3607404f5ac3cc66c9a3222fd122c7e05789569
k5tuck/Digital-Crafts-Classes
/end_of_lesson_exercises/lrg_exercises/python/lrg_exercise2.py
970
3.96875
4
num = int(input("What number would you like to factor?: ")) if num % 2 == 0: print("%i is a positive number" %num) even_list = [] p = 1 while p <= num: if num % p == 0: q = num / p even_list.append(p) even_list.append(int(q)) p += 1 else...
1b658c4f93e2273d593ad60070c170d88b147ce0
k5tuck/Digital-Crafts-Classes
/python/wk_1/comparisons1.py
249
3.90625
4
my_number = 29 compare1 = 18 compare2 = 7 compare3 = 29 if my_number == compare1: print(True) elif my_number == compare2: print(True) elif my_number == compare3: print(True) else: print("This number is equal to none of the above")
bcde179facbf825efb934e779b2257e2e608d211
k5tuck/Digital-Crafts-Classes
/end_of_lesson_exercises/small_exercises/python/wk2_exercise5.py
254
3.875
4
# Exercise 5 numbers = [-23, -52, 0, -1.6, 56, 231, 86, 20, 11, 17, 9] for num in numbers: if num > 0: print(num) # Exercise 6 new_numbers = [] for num in numbers: if num > 0: new_numbers.append(num) print(sorted(new_numbers))
b775e2235930821da179884ff859d592d3d5ada7
k5tuck/Digital-Crafts-Classes
/end_of_lesson_exercises/small_exercises/python/wk2_exercise2.py
246
4.09375
4
numbers = [6,7,8,4,312,109,878] biggest = 0 for num in numbers: if biggest < num: biggest = num else: pass print(biggest) #Alternative using sort method numbers.sort() print(numbers[-1]) #Alternative print(max(numbers))
fe219eb50f78b4c717b8a4a17567073ddb435621
k5tuck/Digital-Crafts-Classes
/end_of_lesson_exercises/small_exercises/python/exercise3.py
310
3.9375
4
print("Please fill in the blanks below:\n") print("____(name)____ loves ____(activity)____ whenever possible!\n") name = input("What is your name? ") activity = input("What is %s's favorite activity to do whenever they get the opportunity? " %name) print("%s loves %s whenever possible!" %(name, activity))
9bdbbea001d9ddbc0c7330ab7b71fc575ac467ce
sankarmanoj/CTE-Python
/second/rand.py
743
3.78125
4
import random import copy randomArray = [random.randint(0,100) for x in range(10)] print "Random Array =",randomArray #Sort Array randomArray.sort() print "Sorted Array = ",randomArray #Largest Element print "Largest Element In Array = ",max(randomArray) #Smallest Element print "Smallest Element in Array = ",min(ran...
7ec2ef1c7ecdc53dadc8c11a3a57fd6da40c1920
sankarmanoj/CTE-Python
/third/third.py
197
3.859375
4
a = range(3) b = range(10,13) c = [] for x in a: for y in b: c.append((x,y)) print c c = [(x,y) for x in a for y in b] print c import itertools c = itertools.product(a,b) print list(c)
0d81f91728bed2c804208f94df5311a26d27df1e
sankarmanoj/CTE-Python
/recur.py
172
3.703125
4
def insertion(a): if len(a)==2: if a[0]>a[1]: a[0],a[1] = a[1],a[0] return a else: return a
c5366570917b06ef617db8abd9c478cbf2c79628
JohnVonNeumann/selenium-py
/custom_logger.py
892
3.53125
4
import inspect #allows users to get info from live objects import logging # the purpose of this file is to act as something of a module that we can # call when needed, it sets itself a name, file and other params. def customLogger(logLevel): # Gets the name of the class / method from where this method is called ...
01412ba71dea158f097e6da5e831c0c7cea44d50
iabok/sales-tracker
/web/sales_app/apps/helpers/processProductSales.py
2,650
3.609375
4
''' Process the product sales fields ''' from collections import namedtuple import operator class ProductSales: """ Product process class """ def __init__(self, product_name, quantity, price): ''' constructor ''' self.product_name = product_name self.quantit...
272adc9f1c787a36e7702e6ee2caa36ae8a547d8
RagingTiger/MontyHallProblem
/montyhall.py
4,080
4.1875
4
#!/usr/bin/env python # libs import random # classes class MontyHall(object): """A class with various methods for simulating the Monty Hall problem.""" def lmad(self): """Interactive version of Monty Hall problem (i.e. Lets Make A Deal).""" # start game print('Let\'s Make A Deal') ...
802f19a0bbe365b4fba2cb6c6d3fbba1db803066
qilinchang70/oh-yeah
/028 星座.py
1,551
3.921875
4
n=eval(input()) for i in range(0,n,1): [month,date]= input().split() month= eval(month) date= eval(date) if month==1 and date >=21: print("Aquarius") elif month==2 and date <=19: print("Aquarius") elif month==2 and date >19: print("Pisces") elif month==3 ...
c47734a966d5996428b2ae19beeb8a396a3c734f
Gouenji/Dynamic-Programming
/Weighted Job Scheduling Dynamic Programming.py
1,699
3.625
4
def doNotOverlap(job1,job2): if job1[0] < job2[0] and job2[1] < job1[1] : return 0 if job2[0] < job1[0] and job1[1] < job2[1] : return 0 if job1[1] > job2[0] and job1[0]<job2[0]: return 0 if job2[1] > job1[0] and job2[0]<job1[0]: return 0 else: return 1 from o...
1b775b3d85e54f9c236f1a4ba71409e99a4ab1d3
Gouenji/Dynamic-Programming
/Maximum Sum Increasing Subsequence Dynamic Programming.py
1,478
3.890625
4
print ("Enter the array to find Maximum Sum Increasing Subsequence (space separated)") a=map(int,raw_input().strip(' ').split(' ')) from copy import copy def MaximumSumIncreasingSubsequence(array): max_sum_array=copy(array) actual_sequence=[] for i in range(len(array)): actual_sequence.append(i) ...
7b709a867ddc325c7f905dcee39dc8a0001ed6b5
prajwaldhore/pythonlab
/ams.py
161
3.65625
4
x=int(input(' enter the number ' )) p=(x//10) q=(x%10) s=(p//10) r=(p%10) z=(s**3+q**3+r**3) if x==z: print('amstrong') else: print('not')
de07a3442ceabc74bbebe758ac77672f8d8441e0
RiderBR/Desafios-Concluidos-em-Python
/Python/Desafio 002.py
250
3.78125
4
#RiderBR-TEKUBR dia = int(input("Qual o dia que você nasceu? ")) mes = str(input("Qual o mês de seu nascimento? ")) ano = int(input("Qual o ano de seu nascimento? ")) print("Você nasceu em {} de {} de {}. Estou correto?".format(dia, mes, ano))
01113ddaf86fac3d3c169ce261a1789ee2731516
RiderBR/Desafios-Concluidos-em-Python
/Python/Desafio 045.py
843
3.84375
4
import random lista = ['Pedra', 'Papel', 'Tesoura'] print('-='*13) print('''Escolha uma das opções: [ 1 ] - Pedra [ 2 ] - Papel [ 3 ] - Tesoura''') print('-='*13) jogador = int(input('Sua escolha: ')) print('-='*13) print('Vez do computador.') pc = random.choice(lista) print('O computador escolh...
e6fa51b5a6851f3536f05d31d4ed14d9394e2e9e
wjdghrl11/repipe
/sbsquiz6.py
418
3.6875
4
# 문제 : 99단 8단을 출력해주세요. # 조건 : 숫자 1 이외의 값을 사용할 수 없습니다. 소스코드를 수정해주세요. # 조건 : while문을 사용해주세요. # """ # 출력 양식 # == 8단 == # 8 * 1 = 8 # 8 * 2 = 16 # 8 * 3 = 24 # 8 * 4 = 32 # 8 * 5 = 40 # 8 * 6 = 48 # 8 * 7 = 56 # 8 * 8 = 64 # 8 * 9 = 72 # """ # 수정가능 시작 num = int(input("8을 입력해 주세요"))
bc1f578d4254a5a6d336acceeb1e0e90bebcdd3a
wjdghrl11/repipe
/sbsquiz5.py
107
3.640625
4
# 반복문을 이용해 1 ~ 10까지 출력해주세요. num = 1 while num <= 10: print(num) num += 1
a2b9d9b20dacdbcf9650b924e27b2be4a55bad61
wjdghrl11/repipe
/quiz8.py
676
3.65625
4
# 1 ~ 10 까지 수 리스트 선언 list1 = [1,2,3,4,5,6,7,8,9,10] print(list1) # 리스트 값 짝수만 가져오기 print(list1[0]) print(list1[1]) print(list1[3]) print(list1[5]) print(list1[7]) print(list1[9]) i = 0 while i < 10 : if list1[i] % 2 == 0 : print(list1[i]) i += 1 # 리스트에 11,13,15 추가하기 list1.append(11) list1.append(13) list1.appe...
0e509745b1acc82ae4142d6b2daafdfde2861533
wjdghrl11/repipe
/4.py
431
3.515625
4
# # 삼자택일, 삼지선다 # a = 0 # if a < 0 : # print("음수") # elif a == 0 : # print("0") # else : # 위에서 조건을 다 끝내고서 맨 마지막 # print("양수") b = 15 if b < 1 : print("1보다 작습니다.") elif b < 3 : print("3보다 작습니다.") elif b < 5 : print("5보다 작습니다.") elif b < 10 : print("10보다 작습니다") else : print("10보다 크거나 같습니다.")
714077f21c473536d8f64b6ba9c1f11c968d172b
wonderfullinux/work
/calculator_challenge2.py
929
3.546875
4
#!/usr/bin/env python3 import sys def calculator(gz): yn = gz - 0.165 * gz - 5000 if yn <= 0: ns = 0 elif yn <= 3000: ns = yn * 0.03 elif yn <= 12000: ns = yn * 0.1 - 210 elif yn <= 25000: ns = yn * 0.2 - 1410 elif yn <= 35000: ns = yn * 0.25 - 2660 ...
15d38f06d05b2330c9d0269c4882c701d371eb69
DiggidyDev/euleriser
/graph.py
7,852
3.671875
4
import random from interface import Interface from node import Node __author__ = "DiggidyDev" __license__ = "MIT" __version__ = "1.0.1" __maintainer__ = "DiggidyDev" __email__ = "35506546+DiggidyDev@users.noreply.github.com" __status__ = "Development" class Graph: """ Graph is an object which represents a ...
d67990ec50f962766c1017b19e5b89f5798fa710
otmaneattou/OOP_projects
/calories_app/temperature.py
1,679
3.625
4
from selectorlib import Extractor import requests class Temperature(): """ A scraper that uses an yaml file to read the xpath of a value It needs to extract from timeanddate.com/weather/ url """ headers = { 'pragma': 'no-cache', 'cache-control': 'no-cache', 'dnt': '1', 'upgrade-i...
ab9343311a6c6d43501b8e2196b1682e3d0398f6
panoptes/PEAS
/peas/PID.py
2,683
3.546875
4
from datetime import datetime class PID: ''' Pseudocode from Wikipedia: previous_error = 0 integral = 0 start: error = setpoint - measured_value integral = integral + error*dt derivative = (error - previous_error)/dt output = Kp*error + Ki*integral + Kd*derivative p...
dd45a9660cfd3f30085b148fbbdc2c57691be9a9
hpvo37/PyGame-games
/GameEffects/ShadowForText.py
1,636
4
4
""" example non-animated entry for the pygame text contest if you would like to change this for your own entry, modify the first function that renders the text. you'll also probably want to change the arguments that your function used. simply running the script should show some sort of example for your text renderin...