blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cb42198d430f4b66a4644422e6598d9414c79a5e
chauncyfxm/niPython
/python_03/continue.py
92
3.578125
4
i = 0 while i < 20: if i == 6: i += 2 continue i += 1 print (i) print ('ijjiij')
46c10809f08c9e8354fef2523dd7e284a2e2ad79
zhangqinlove/-
/ex-5.4.py
174
3.546875
4
def multi(*a): if len(a)==0: return 0 t=1 for i in a: t=t*i return t print(multi(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20))
7f8cd9222f9b6f8e6c9aecb004cee30a3019e67b
M0673N/Programming-Fundamentals-with-Python
/01_basic_syntax_conditional_statements_and_loops/exercise/10_christmas_spirit.py
744
3.984375
4
quantity = int(input()) days_left = int(input()) ornament_set = 2 tree_skirt = 5 tree_garlands = 3 tree_lights = 15 spirit = 0 price = 0 if days_left % 10 == 0: spirit -= 30 for day in range(1, days_left + 1): if day % 11 == 0: quantity += 2 if day % 2 == 0: price += quantity * ornament_set ...
83b42e1c81cffdb1c9cfdd9a68c8b4e58a585804
SadSack963/blackjack
/main.py
4,521
3.96875
4
import random from art import logo # Initialize variables deck = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] play = True cards = {} game = False # Initialize the hands def init_hands(): global cards cards = { "Player": {"hand": [], "score": 0}, "Dealer": {"hand": [], "score": 0}, } ...
923ae07135dc96a9849f7b526bb89bbf192e4566
dmcglinchey2779/Quantopian-Python-Scripts
/Quant_Tutor_L5.py
2,397
4
4
""" Lesson 5 - The Data Object data object - look up current or historical pricing and volume data for any security. data is available in handle_data() and before_trading_start() as well as any scheduled functions. data.current() - return most recent value of given field(s) for a given asset(s) Requires two arguements:...
db347195199dc2b1f1fd6daa85207f7e7ecea339
naye0ng/Algorithm
/Programmers/해시/전화번호목록.py
370
3.59375
4
""" 전화번호목록 """ def solution(phone_book): phone_book = sorted(phone_book) front = 0 while front < len(phone_book) : for target in phone_book[front+1:]: if phone_book[front].startswith(target) : return False front += 1 return True print(solution(["117","9767...
fa70cff2a89d673477cd4141b5ed6ac8d99c939a
vinayjawadwar/Learnpython
/OperatorOverloading.py
861
3.75
4
a =5 b=6 print(a+b) print(int.__add__(a,b)) #behind the seen __add __ used class Student: def __init__(self,m1,m2): self.m1 = m1 self.m2 = m2 def __add__(self, other): m1 = self.m1 + other.m1 m2 = self.m2 + other.m2 s3 = Student(m1,m2) return...
f07b63b0c9c48272ea9f192a39a7156009827a3b
itsEmShoji/TCScurriculum
/2_dungeon_crawl/hard/SmartDeque.py
557
3.546875
4
from collections import deque class SmartDeque: def __init__(self, mode_in): # TODO: initialize our instance variables def push(self, elt): # TODO:check if our mode is a stack ('s') # TODO: add elt to the left of our data # TODO: if our mode is not 's', append elt normally...
da94f8c14bac692267dfec2063b1bcd699eaa827
Jesta398/project
/datastruvctures/polymorphism/quest2.py
276
3.859375
4
class Parent1: def m1(self): print("inside parent1") class Parent2: def m1(self): print("inside parent2") class child(Parent1,Parent2):#chils is inheriting parent1 and parent2 def m3(self): print("inside child") c=child() c.m3() c.m1()
0942a221f908f3f7edde81247db6a0ffa8be7fb0
mrc-a2p/python-project
/turtle_funciones.py
1,002
3.953125
4
import turtle def main(): window = turtle.Screen() window.setup(350, 350, 0, 0) #TAMAÑO VENTANA window.title("Ejemplo de ventana") #window.screensize(300, 300) # turtle.dot(10, 0, 0, 0) dave = turtle.Turtle() #dave = turtle.hideturtle() #turtle.goto(50, 30) turtle....
2e0e4700abca6329602b242243b82c5692ea93e0
cenk-celik/rosalind_solutions
/python_script/open_reading_frames.py
2,774
4.03125
4
#!/usr/bin/env python # coding: utf-8 # # Open Reading Frames # ## Problem # # Either strand of a DNA double helix can serve as the coding strand for RNA transcription. Hence, a given DNA string implies six total reading frames, or ways in which the same region of DNA can be translated into amino acids: three reading...
681e8beaad24ff4e59fe482fd8bddd79df80fab1
sachinjose/Coding-Prep
/CTCI/Stack & Queue/q3.4.py
809
3.953125
4
class Stack: def __init__(self): self.s = [] def push(self,e): self.s.append(e) def pop(self): if len(self.s) == 0: return False else: return self.s.pop() def top(self): if len(self.s) == 0: return False else : return self.s[-1] def is_empty(self): return len(self.s) == 0 de...
bfad97f35cee5bbd84fb0133555872db1695a97c
anitrajpurohit28/PythonPractice
/python_practice/List_programs/1_interchange_first_last_elements.py
2,372
4.46875
4
# 1 Python program to interchange first and last elements in a list print("-----1------") def swap_list_using_temp1(input_list): temp = input_list[0] input_list[0] = input_list[-1] input_list[-1] = temp my_list = [1, 2, 3, 4, 5, 6, 7] swap_list_using_temp1(my_list) print(my_list) print("-----2------") d...
b7f7becea5df583f824a681213140a3c8111db6d
KlaudiaGolebiowska/aplikacja_bankowa
/test/test_cash_machine.py
2,631
3.640625
4
""" Bankomat: Czy można wypłacić pieniądze. Czy łączy się z kontem. Czy brak pieniędzy w bankomacie jest obsługiwany Czy brak pieniędzy na koncie jest obsługiwany. """ import unittest from parameterized import parameterized from app.account import Account from app.card import Card from app.cash_machine import CashMac...
23805f105c09f2c9a560563ed2ff2d5b02fdf126
quocthang0507/PythonExercises
/Chapter 1/Ex53.py
322
3.59375
4
# 53. Hãy đếm số lượng chữ số lớn nhất của số nguyên dương n. from Ex51 import MaxDigit if __name__ == "__main__": while True: n = int(input('n = ')) if n > 0: break count = str(n).count(MaxDigit(n)) print('There are {} max digits in {}'.format(count, n))
aed08fe1902657d51c9907c0553790d402ba4c51
oew1v07/Medial
/medial.py
1,994
3.78125
4
"""Set of functions to calculate the medial axis transform Steps involved: 1. Thresholding an image to create a binary image 2. Find all boundary pixels in the image. 3. For each non-boundary pixel find the distance to the nearest boundary pixel, using Euclidean distance 4. Calculate Laplacian of the distance ...
fa3ef45b0a879b392e6b39ccd2c4a919960a645b
physmath17/learning_python
/think_python/chap5/triangle.py
965
4.46875
4
def is_triangle(a, b, c) : """ takes a, b, c as the inputs and converts them to integers, these are the side lengths of the triangle """ if int(a) + int(b) > int(c) and int(c) + int(b) > int(a) and int(c) + int(a) > int(b) : print("Yes, the given side lengths form a triangle.") elif int(a) + int(b) ...
1cf0674a5cec62512c35341a550bef69f77967da
hrushibhosale92/numerical_computing
/newton_raphson.py
668
3.875
4
def func( x ): f = (x+5)**2 return f def derivFunc( x ): df = 2*(x+5) return df # Function to find the root def newtonRaphson( x ): h = func(x) / derivFunc(x) i = 0 x_old = x while True: h = func(x_old)/derivFunc(x_old) # x(i+1) = x(i) - f(x) / f'(x...
3d36a5dfa87f05f370e23d9942fd2026a62f6be5
dhumindesai/Problem-Solving
/ik/graph/is_graph_tree.py
2,667
3.78125
4
# from collections import deque # # # def is_it_a_tree(node_count, edge_start, edge_end): # if node_count < 1: # return False # # # bfs # def isCycleBfs(root): # q = deque() # q.append(root) # visited[root] = 1 # # while q: # node = q.popleft() # ...
72657c084eb68561cfda42a8c1920ddb0e04801c
jgam/hackerrank
/sorting/bubblesort.py
611
3.546875
4
def countSwaps(a): num_swap = 0 if a == sorted(a): print('Array is sorted in', num_swap, 'swaps.') print('First Element:', a[0]) print('Last Element:', a[-1]) return 0 else: for i in range(1,len(a)): for j in range(len(a)-i): if a[j] > a[j+...
8e5f3e81bb4094d7063543e05e5840469ef57061
Han1s/flask-official-tutorial
/flaskr/db.py
3,036
3.796875
4
import sqlite3 import click from flask import current_app, g from flask.cli import with_appcontext def get_db(): """ g is a special object that is unique for each request. It is used to store data that might be accessed by multiple functions during the request. The connection is stored and reused instead of ...
b6e1c06e7b76d5150954d939b1461c792296c9bf
JasmineBharadiya/pythonBasics
/task_9_pattern.py
195
4.0625
4
#max of 3 def max(x,y,z): if x>y and x>z: print "x is max" elif y>z and y>x: print "y is max" else: print "z is max"
52fb542600445cfa6758f93d4307913c71012af6
nigelbrennan/Anxiety-App
/programming_2_ca117-master/programming_2_ca117-master/Lab 11.1/file_111.py
3,638
3.828125
4
class File(object): FILE_PERMISSIONS = 'rwx' def __init__(self, fille, name, size=0, per=None): self.file = fille self.name = name self.size = size if per == None: self.per = 'null' else: self.per = per def __str__(self): return 'File: {}\nOwner: {}\nPermissions: {}\nSize: {} bytes'.format(self.fi...
cb816f84ef457424ab0e22e5080b7b7bc54513e9
roeiherz/CodingInterviews
/RecursionsDP/PaintFill.py
366
3.609375
4
__author__ = 'roeiherz' """ Implement the "paint fill" function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, fill in the surrounding area until the color changes from the original color. """ if __name__ == '_...
00db574758fc16263d193147cf51f329a654a2db
Striz-lab/infa_2019_strizhak
/lab4/03(edited).py
5,373
3.5625
4
from graph import* windowSize(720, 500) canvasSize(2000, 2000) brushColor(100, 200, 200) rectangle(0, 0, 720, 500) brushColor(20, 200, 0) penColor(20, 200, 0) rectangle(0, 300, 720, 720) penColor(0, 0, 0) def ellipsee(x, y, a, b, fi): penColor('orange') c=math.cos(fi) d=math.sin(fi) penSize(2) ...
920fd8f4c1712108a2e4e7e8c87de594f8f0569e
ZhiyuSun/leetcode-practice
/301-500/435_无重叠区间.py
1,479
3.6875
4
""" 给定一个区间的集合,找到需要移除区间的最小数量,使剩余区间互不重叠。 注意: 可以认为区间的终点总是大于它的起点。 区间 [1,2] 和 [2,3] 的边界相互“接触”,但没有相互重叠。 示例 1: 输入: [ [1,2], [2,3], [3,4], [1,3] ] 输出: 1 解释: 移除 [1,3] 后,剩下的区间没有重叠。 示例 2: 输入: [ [1,2], [1,2], [1,2] ] 输出: 2 解释: 你需要移除两个 [1,2] 来使剩下的区间没有重叠。 示例 3: 输入: [ [1,2], [2,3] ] 输出: 0 解释: 你不需要移除任何区间,因为它们已经是无重叠的了。 """ ...
789653e393b86d5541f2baa87422b8688a76f8b4
firdausraginda/python-beginner-to-advance
/zero-level/zero-level-#1-variables-data-types.py
1,050
4.3125
4
# USER INPUT # user_says = input("Please enter the string you want to print: ") # print(user_says) # ---------------------------------------------------------- # VARIABLES # 1. should start w/ a letter (can't start with a number) # 2. can't include spaces # 3. can't use symbols other than underscore (_) # 4. Hyphens...
03bc8b2025ca7584a2846770abecb5da4cb154da
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/njschafi/Lesson08/test_circle.py
2,977
4.0625
4
"""test code for circle.py""" # NEIMA SCHAFI, LESSON 8 Assignment - Circle Class import pytest import math from circle import * ######## # Step 1 & 2 ######## def test_init(): """ This tests if a proper numeric circle isinstance is created and then checks for correct radius and diameters """ ...
889cd91805cd44a62c240986866fcd7e972d1c8e
jithuraju/turbolab
/answer_2.py
413
3.96875
4
str1=input("enter the valid string of parenthesis:") def remove_outer_layer(str1): str2 ='' count=1 i = 1 while (i< len(str1)): if (str1[i]=="("): count = count+1 if count == 0: i =i+2 count=count+1 continue str2=str2+str...
6b92f9285e1756fc25e0797976c3f1c6952f94b4
robertz23/code-samples
/python scripts and tools/list_intersection.py
1,200
4.0625
4
""" List intersection: Finds intersections between various lists """ def check_intersection(first_list, second_list): #We use set builtin function to find the intersection between lists return set(first_list).intersection(second_list) def create_lists(line): #receive a line from the file containing asc...
40341bbf1b1099da8e9c539e42e557b385360404
suyogpotnis/Leet_Code_Solved
/Longest_Common_Prefix.py
862
4
4
""" Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input st...
ca17e71cea63b5914f0f45712d10df3a607c33cb
beminol/project_euler
/p23_non_abundant_sums.py
543
3.671875
4
def perfect_number(n): all_list = range(n + 1) all_list.remove(0) divisor_list = list() for i in all_list: if n % i == 0: divisor_list.append(i) divisor_list.remove(n) print divisor_list print "Sum of all divisors:", sum(divisor_list) if sum(divisor_list) == n: ...
94656f65640d5a375c408b3ce464529ef87de528
SavaTudor/StudentsLabsGrades
/validare/validatorLab.py
2,610
3.609375
4
from erori.exceptii import ValidError class ValidatorLab(object): def __validator_numar(self, s): ''' :param s: a string representing the lab number and the problem number :return: True if the string is valid, false otherwise s must be of the format "LabNumber_ProblemNumber" ...
253b3c33fc550949cd53066ca313ba444c5758e7
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_Another-One/Project Euler/Problem 03/sol2.py
384
3.953125
4
""" Problem: The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N? e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17. """ from __future__ import print_function n = int(input()) prime = 1 i = 2 while i * i <= n: while n % i == 0: prime = i...
ed080e4baa8b0ecd96a50f2e574576803bb027a6
jaycoskey/IntroToPythonCourse
/PythonSrc/Unused/lunar_lander.py
9,058
3.53125
4
#!/usr/bin/env python3 # Lunar lander. import argparse import math import sys verbose = False class Game: DEFAULT_INITIAL_FUEL = 100 DEFAULT_INITIAL_HEIGHT = 300 DEFAULT_INITIAL_VELOCITY = 0 EPSILON = 0.01 GRAVITY = -5.0 MAX_BURN_RATE = 50 MIN_BURN_RATE = 0 SOFT_LANDING = -5 de...
02938bc2492f97d074b7709a2079c8d8ed14943f
GIT-Ramteja/Projectwork
/CMD.py
387
3.796875
4
import sys a=int(sys.argv[1]) b=int(sys.argv[2]) def add(a,b): sum=a+b print("the sum",sum) def sub(a,b): sub=a-b print("the sum",sub) def mul(a,b): mul=a*b print("the sum",mul) def div(a,b): if b==0: print("division not possible") else: div=a/b ...
7e6e4ea245490f268f98bd588846ed208628d174
jadesym/interview
/leetcode/111.minimum-depth-of-binary-tree/solution.py
789
3.84375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution(object): def minDepth(self, root): """ :type root: TreeNode :rty...
73e9c57a8706afb74b46a43d76f103287a87a500
justindodson/PythonProjects
/CPR_Temps/resources/excel_extractor.py
2,423
3.609375
4
import openpyxl from resources.date_processor import process_date class ExcelData: def __init__(self, class_size, exel_file_name, counter=1, ): self.class_size = class_size self.counter = counter self.wb = openpyxl.load_workbook(exel_file_name) self.sheet = self.wb.get_sheet_by_na...
48cd5fb1aee8e9e9927dcf296def05596e618a49
szabgab/slides
/python/examples/dictionary/legal_drinking.py
1,717
3.71875
4
legal_drinking_age = { 0 : ['Angola', 'Guinea-Bissau', 'Nigeria', 'Togo', 'Western Sahara', 'Haiti', 'Cambodia', 'Macau'], 15 : ['Central African Republic'], 16 : [ 'Gambia', 'Morocco', 'Antigua and Barbuda', 'Barbados', 'British Virgin Islands', 'Cuba', 'Dominica', 'Grenada', 'Saint Lucia', 'Saint Vincent and the Gren...
35e4a987b8f607c92c80be5b07403948215e94e2
penroselearning/pystart
/Fast Five Car Rental.py
1,524
4.25
4
cars = [('Honda', 'Accord', 'Blue', 2019), ('Nissan', 'Patrol', 'Black', 2018), ('Infiniti', 'QX60', 'Silver', 2018)] action = int(input('''Would you like to: 1. Add a Car 2. Remove a Car 3. View Cars 4. Exit --------------------- Please choose the number corresponding to the action of your choice.\n''...
163bd525b712219462f9a84fbb5615404f39e608
Warherolion/Final-Project
/Main.py
43,645
3.546875
4
# Name: Ranvir Singh # Date: March 20th, 2019 # File Name: Main.py AKA Monopoly # Description: This program allows for the user to play monopoly with as many different AI players as they want or with # other human players taking turns on the terminal, the user can set their own difficulty settings, choose their own # n...
cedc6a2de3e6b79658b49baad032956ad1c2573a
MattBroe/Python-Graph-Algorithms
/Edge.py
1,469
3.875
4
#This class is used to represent a weighted edge of a graph. If e_1, e_2 are #two instances of Edge, then e_1 < e_2, e_1 > e_2, e_1 == e_2 are all evaluated #according to the respective weights of e_1 and e_2. This allows you to create #a minHeap full of Edge objects sorted by weight, which is a helpful data #structure...
68b645dfd7954c91f6dd06ab0bdf2fb1b4c8b57a
mohmmadnoorjebreen/data-structures-and-algorithms
/python/stack-queue-pseudo/stack_queue_pseudo/stack_queue_pseudo.py
1,708
4.03125
4
class Node: def __init__(self,data=''): self.data= data self.next = None class Stack: def __init__(self): self.top = None def push(self,value): node = Node(value) node.next = self.top self.top = node def pop(self): if not self.top: ...
1c5b9b3bc4a64c3071a1b745096c2e59c147abe7
kwaiman/Image-Downloader
/Image_Downloaders.py
1,060
3.609375
4
import requests import os def image_dl(): urlName = input('Please provide the URL name.\n') r = requests.get(urlName, stream = True) r.raw.decode_content = True pathAnswer = 0 while pathAnswer != 1 and pathAnswer != 2: pathAnswer = int(input('Do you want to save the images on (1) Desktop, o...
d26ad3fbeb864557edb32b2ad4398977d3db81b9
pocketgroovy/MachineLearningProj1
/qlearning_robot/ReversePriorityQueue.py
295
3.6875
4
from Queue import PriorityQueue class ReversePriorityQueue(PriorityQueue): def put(self, tup): newtup = tup[0] * -1, tup[1] PriorityQueue.put(self, newtup) def get(self): tup = PriorityQueue.get(self) newtup = tup[0] * -1, tup[1] return newtup
9a8c2e71714d5345fa7a0aab241fda4769d382e3
bwood9/Portilla-Intro_ML
/PY/Groupby.py
1,169
4.3125
4
# Groupby is a function common to SQL that allows user to group rows together # based off of a column and perform an aggregate (e.g. sum, mean, sd, etc.) function on them. import pandas as pd # create dictionary containing the data data = {'Company':['GOOG', 'GOOG', 'MSFT', 'MSFT', 'FB', 'FB'], 'Person':...
dbd2e0b8c5cf47f6e29c804ffba824c48af7d443
vprusso/toqito
/toqito/states/chessboard.py
3,195
3.546875
4
"""Chessboard state.""" import numpy as np def chessboard(mat_params: list[float], s_param: float = None, t_param: float = None) -> np.ndarray: r""" Produce a chessboard state [BP00]_. Generates the chessboard state defined in [BP00]_. Note that, for certain choices of :code:`s_param` and :code:`t_pa...
9cda78d105193a8a51cb4a869c41dfd69108342c
kvntma/coding-practice
/codecadamy/Towers_of_Hanoi/tower_of_hanoi.py
3,014
4.09375
4
from stack import Stack print("\nLet's play Towers of Hanoi!!") # Create the Stacks - Global Scope, can be changed to reduce pollution if needed. left_stack, middle_stack, right_stack = Stack( "Left"), Stack("Middle"), Stack("Right") stacks = [left_stack, middle_stack, right_stack] # Set up the Game def initi...
15970afc8a6f0b21b16231d145e6470cd3e43b8a
Peett2/infoshare
/day_12/test_example.py
698
3.90625
4
from unittest import TestCase from day_12.example import super_sum class TestExample(TestCase): def setUp(self): pass def tearDown(self): pass def test_sum_one_plus_two_equals_three(self): # given a = 1 b = 2 expected = 3 result = super_sum(a, b) ...
a734780940b6f24974b40623a325a0a2860eda36
AdventurousDream/Top-100-Liked-Questions-by-python
/45 Jump Game II.py
879
3.5
4
from typing import List class Solution: def jump(self, nums: List[int]) -> int: arr_len = len(nums) if arr_len == 1: return 0 ans = 0 curIdx = 0 maxPos = -1 nextIdx = -1 while True: if curIdx + nums[curIdx] >= arr...
e10a24ac8ed8a646dca9ac5587afc7c6ef3f686a
Gorsitho/PythonDocumentation
/Practica/P_01_ListasTuplasDiccionarios.py
2,728
4.375
4
"""Listas -Se pueden utilizar los operadores matematicos en ella -Se pueden agregar, eliminar, mirar cualquier objeto. -Admite cualquier tipo de valor en ellas. """ listaMascotas=[ "Pelusa","Mechis","Lulu",True,False,5.4,2 ]*2 listaMascotas.append("Juanchito") #Agrega un nuevo objeto al final de la list...
54ae5cef6dfec7dccc04cadcf204b215c5b8ea2d
bd52622020/appSpaceDanish
/Task 1 -Python coding challenges/Q2 - pascals triangle.py
374
3.890625
4
#!/usr/bin/env python def pastriangle(num = 5): for i in range(1, num+1): for j in range(1, num-i+1): print(" ", end="") for j in range(i,0,-1): print(j, end="") for j in range(2,i+1): print(j,end="") print() if __name__ == "__main__": x...
88f1e0a8076352f71af684260fcaa18f41e85ada
apoorvasindhuja/sindhuja473
/naveen.py
80
3.9375
4
x=input("enter string") if x[-1]==x[-2]: print(x+x[-1]) else: print(x)
680008d15a0e4bb1f4c2cbc6502fd270b413ed6b
hunterkun/leetcode
/数据结构与算法/数据结构/链表.py
16,207
3.90625
4
#coding=utf8 class Node: def __init__(self,e, node_next=None): self.e = e self.next = node_next class LinkedList(): def __init__(self): # 虚拟头节点,(头节点的前一个节点) self.dummyHead = Node(None, None) self.size = 0 def getSize(self): return self.si...
3876ad8420b7a719f9b96ed54a1d9f421eac62d6
kses1010/algorithm
/nadongbin/chapter07-binarySearch/chapter15-binarySearch-solution/find_fixed_point.py
453
3.6875
4
# 고정점 찾기 def solution(arr): start, end = 0, len(arr) - 1 while start <= end: mid = (start + end) // 2 if arr[mid] == mid: return mid elif arr[mid] < mid: start = mid + 1 else: end = mid - 1 return -1 arr1 = [-15, -6, 1, 3, 7] arr2 = [-15...
e18cc65f83326c5f592047646d3752eb2a362597
zimingding/data_structure
/10_array_stack.py
932
3.84375
4
class ListStack: def __init__(self): self._data = [] def pop(self): return self._data.pop(-1) def push(self, item): self._data.append(item) def print(self): print(self._data) class ArrayStack: def __init__(self, capacity: int): self._capacity = capacity ...
e71343ab011d7d2e49fd588b198f4b3ee8c8d098
ziqizhang/msm4phi
/code/python/src/util/produce_feature_files.py
2,067
3.546875
4
# Used to produce a new file with selected features # feature_columns needs to be changed accordingly # first argument is the name of the file with features import sys import pandas as pd feature_file = sys.argv[1] # read annotated data file # Read the file with annotated data annotated_df = pd.read_csv("merged_...
86fd8bd90a7461362881a18fa1ae7eb8120e8d12
pedrogomez2019upb/Taller_PracticaProgramacion
/44.py
496
3.921875
4
#Escribe un algoritmo que, dados dos números, verifique si ambos están entre 0 y 5 o retorne false sino es cierto. Por ejemplo 1 y 2 ---> true ; 1 y 8 ---> false #Primero hay que recibir los valores a analizar a=int(input("Bienvenido! Por favor ingresa el primer número: ")) b=int(input("Por favor ingresa el segundo val...
ad774a79994021d2ffd2ff0865ced5c4459203d1
Kaiquenakao/Python
/Variáveis e Tipos de Dados em Python/Exercicio3.py
326
3.9375
4
""" 3 - Peça ao usuário para digitar três valores inteiros e imprima soma deles """ num1 = int(input("Insira o seu primeiro valor para somar:")) num2 = int(input("Insira o seu segundo valor para somar")) num3 = int(input("Insira o seu terceiro valor para somar")) print(f"O resultado da soma é {num1 + num2 + num3}...
85a71bddeefa23891a8ca8c083057875d28eba05
crispinpigla/Mcgyver
/mcgyver/objramasse.py
923
3.734375
4
""" La classe des objets à ramasser est créee dans ce fichier """ import random class ObjetRamasse: """ Cette classe est celle des objets que le heros doit ramasser pour endormir le gardien """ def __init__(self, plateau, nom_de_lobjet): random.shuffle(plateau.place_potenti_objet_ramass) se...
9127af71c0ee9dfadbf63b8a7c5934bbaed407d8
gabriellaec/desoft-analise-exercicios
/backup/user_158/ch164_2020_06_22_03_29_20_149516.py
193
3.59375
4
def traduz(lista,dic): traducao = [] for i in lista: for palavara in dic: if lista[i] == palavara: traducao.append(dic[palavara]) return traducao
475d97304e797b85c141fe8c18519b3acd3f8a11
garimatuli/Udacity-Coding-and-Projects
/Python-Programs/polygons.py
446
4.0625
4
import turtle jack = turtle.Turtle() jack.color("yellow") def draw_polygon(length, color, sides): for side in range(sides): jack.color(color) jack.forward(length) jack.right(360 / sides) jack.penup() jack.backward(100) jack.pendown() draw_polygon(120, "cyan", 8) draw_polygon(100, "magent...
02eaa88c970d3bbe9af9a8526ff8cd894ca10268
countone/exercism-python
/triangle.py
617
3.78125
4
def is_equilateral(sides): if is_valid(sides): return len(set(sides))==1 else: return is_valid(sides) def is_isosceles(sides): if is_valid(sides): return len(set(sides))<=2 else: return is_valid(sides) def is_scalene(sides): if is_valid(sides): return len(set(...
bfcab6e46db9462479f113e66c96ab2509d05912
AdamZhouSE/pythonHomework
/Code/CodeRecords/2310/60636/245056.py
801
3.609375
4
n_root=input().split(" ") n=int(n_root[0]) root=int(n_root[1]) lists=[] for i in range(pow(2,n)): lists.append("*") sources=[] try: while(True): x=input().split(" ") source=[] source.append(int(x[0])) source.append(int(x[1])) source.append(int(x[2])) sources.appen...
7fdb758e37942cd07910b7b798cfa495c43a6102
jimmyodonnell/banzai
/scripts/dereplication/derep_fasta.py
4,671
3.71875
4
#!/usr/bin/env python ''' Authors: Walter Sessions, Jimmy O'Donnell Find and remove duplicate DNA sequences from a fasta file usage: python ./this_script.py infile.fasta 'ID1_' derep.fasta derep.map ''' import os from collections import Counter import fileinput import itertools import argparse import hashlib parser ...
64db558fc4c1a0236e424570c07b20cebe707325
luohuaizhi/test
/kwargs.py
538
3.546875
4
def test(a, b, c, d): print a, b, c, d return "->".join([str(a), str(b), str(c), str(d)]) def test1(a, b, c, d): print a, b, c, d return "->".join([str(a), str(b), str(c), str(d)]) def test2(*args, **kwargs): print "args: " + str(args) print "kwargs: " + str(kwargs) def main(): param =...
9acc2846f4270a634ea8417e96c79b4b9e97a8fd
qmnguyenw/python_py4e
/geeksforgeeks/algorithm/medium_algo/9_6.py
9,041
3.90625
4
Iterative Letter Combinations of a Phone Number Given an integer array containing digits from **[0, 9]** , the task is to print all possible letter combinations that the numbers could represent. A mapping of digit to letters (just like on the telephone buttons) is being followed. **Note** that **0** and **1...
a4b22cfa66b445d1b6edab1b8a744c2b29a49d13
avrudik/easy_it
/course_tasks/and/hmw_1/task_3.py
379
3.96875
4
def do_it(data, sub): data = data[data.find(sub) + len(sub):] return 1, data input_str = input('Input some string: ') sub_str = input('Input a sub-string: ') answer = 0 while input_str and sub_str in input_str: sum, input_str = do_it(input_str, sub_str) answer += sum else: print('String is over or ...
faa9043e9f9d5b99b7edcfd2b76bc9cd680ca4e7
biswajit2506/python
/shop_check_print.py
778
3.84375
4
def search(s): list=["apple","orange","kiwi"] avl=[] navl=[] nval=0; s=s.split(",") #print(s) #print(type(s)) for j in s: nval=0; for i in list: if j==i: #print(j," Avaiable in our Shop.") avl.append(j) break; else: nval=nval+1; #print(nval) ...
d5d397472354e64350ffd6eb0ab2efe4e2e44e07
xiaohuilangss/modeng_research
/test/tf_new_version_test/test1.py
20,155
3.953125
4
# encoding=utf-8 """ 测试最新版本TensorFlow 测试TensorFlow 2.3.0版本官网有关rnn的案例代码 """ """ ## Setup """ import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers if __name__ == '__main__': """ Title: Working with RNNs Authors: Scott Zhu, Francois Chollet Date...
35634eb26c5597a3535d16cbfb5d3c124f861f57
geuben/adafruit-pi-lcd-plate
/menu_framework/menu.py
1,989
3.609375
4
class Menu(object): def __init__(self, items): self._items = items self._items.append(Back()) self._pos = 0 self._active = True def items(self): return self._items def num_items(self): return len(self._items) def message(self): if self._active:...
7f07e66c94da1f249a95645900f1140a1d7bf596
jdk1997/CP
/HR/digfac.py
228
3.5
4
from math import factorial t = int(input()) for _ in range(t): n = int(input()) for i in range(len(s_num)): tmp = factorial(n) ans = 0 s_num = str(tmp) ans += int(s_num[i]) print(ans)
4eccdcb14d1e43c307069c789a2c21a7fcb4f8cd
Journey99/Algorithm
/Topic3/chapter4/example14.py
549
3.640625
4
# 최소 동전으로 거슬러 주기 def min_coin_count(value, coin_list): min_coin = 0 coin_list = sorted(coin_list, reverse= True) for i in range(len(coin_list)): coin = value // coin_list[i] min_coin += coin value = value - coin*coin_list[i] return min_coin # 테스트 default_coin_list = [100, 5...
84c5c4e35d9aa28b09ebad22c38a53abe48d20cc
roblivesinottawa/studies_and_projects
/PYTHON_BOOTCAMP/CONDITIONALS/one.py
268
4.15625
4
temperature = int(input("enter temperature between 0 and 40: ")) if temperature > 30: print("it's hot out") elif temperature > 15 and temperature < 30: print("it's nice out") elif temperature < 15: print("it's chilly out") else: print("it's freezing")
ef245082a7d5d140f754a8af7e022dd860319df8
guillox/Practica_python
/2013/tp1/tp1ej9.py
583
4.125
4
"""9.- a) Implemente una calculadora simple, en donde se ingrese (por entrada estandar) dos operandos y el operador(+,-,*, /) e imprima el valor de la operacion resultante(por el momento no tenga en cuenta errores de tipos, ej: que el operando no sea numero o que el operador no sea los enumerados). Nota: No codif...
055742f2d5fad1611f40a6009eedf6300e1c7ca5
cross-sky/sicp
/c1_2_6.py
347
3.703125
4
def divides(a, b): return b % a == 0 def smallest_divisor(n): return find_divisor(n, 2) def square(n): return n * n def find_divisor(n, test_divisor): if square(test_divisor) > n: return n if divides(test_divisor, n): return test_divisor else: return find_divisor(n, test_divisor + 1) def prime(n): retur...
ef1d4df052d0f2a4a71224915fc0c60d40cd7af7
jacindaz/algos_practice
/algos/dynamic_programming.py
1,135
3.578125
4
def fib(n): if n <= 1: return n return fib(n-1) + fib(n-2) def fib_dynamic_programming(n): a, b = 0, 1 for step in range(n): a, b = a + b, a return a def num_paths(height, width): if height == 0 and width == 0: return 0 if height == 0 or width == 0: return...
24b27ecce9485366a73d933f4f48debf2c5f16f6
xerprobe/LeetCodeAnswer
/141. 环形链表/pythonCode.py
1,215
3.765625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: if(head == None or head.next == None): return False quickHead = head.next while(quickHead != ...
3d4bc69f9f43db87d2b476096442eb0241f99a3d
ouedraogoboukary/starter-kit-datascience
/arthur-ouaknine/Lesson 1/wordcount.py
3,065
4.25
4
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
0d4f470ef24ddf2f531b95e9fda5c37207ed21a3
gabriellaec/desoft-analise-exercicios
/backup/user_221/ch149_2020_04_13_21_19_33_037376.py
891
3.921875
4
salario = float(input('Qual o seu salário bruto? ')) dependentes = int(input('Qual o número de dependentes? ')) if salario <= 1045: contribuicao = salario*0.075 elif 1045.01 <= salario <= 2089.60: contribuicao = salario*0.09 elif 2089.61 <= salario <= 3134.40: contribuicao = salario*0.012 elif 3134.41 <= sa...
4f444b251ffc8af652e7d386c6b363e43a6d6030
Jerrydepon/LeetCode
/3_tree/medium/98. Validate Binary Search Tree.py
691
3.9375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # traverse through tree and check the valid range for each node in the tree class Solution: def isValidBST(self, root: TreeNode) -> bool: return ...
c79507344fa6d0e8afbe294b6c9d28f59d36a3ce
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day1/11_count_substrings/solution.py
850
4.125
4
def count_substrings(haystack, needle): index = haystack.find(needle, 0) if (index == -1): return 0 else: count = 0 needle_length = len(needle) while (index < len(haystack) + 1): if (haystack.find(needle, index) != -1): index1 = haystack.find(needl...
d87c22fafc405dc867a71f884f8f52b92186c5c2
MichaelCurrin/daylio-csv-parser
/dayliopy/mood_report.py
1,665
3.890625
4
#!/usr/bin/env python """ Mood report application file. """ import pandas as pd from .lib.config import AppConf conf = AppConf() def print_aggregate_stats(df: pd.DataFrame, column_name: str) -> None: """ Print aggregate stats for a given DataFrame and column name. :param df: Data to work on. :para...
ab9f3bd9474d7dd1cbed403a0b58b9da43562de4
chrisbubernak/ProjectEulerChallenges
/46_GoldbachsOtherConjecture.py
1,288
4
4
# It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. # 9 = 7 + 2×1^2 # 15 = 7 + 2×2^2 # 21 = 3 + 2×3^2 # 25 = 7 + 2×3^2 # 27 = 19 + 2×2^2 # 33 = 31 + 2×1^2 # It turns out that the conjecture was false. # What is the smallest odd composite th...
8a860d5c64cda470cb724d40eaadbbc309e8528f
ic3top/KPI-labs
/Python-Gui-Labs/Sem_1/CPC_3/Task_18.py
201
3.90625
4
k1 = int(input("The length of the first leg of the right triangle: ")) k2 = int(input("The length of the second leg of the right triangle: ")) s = (k1*k2)/2 print(f'The area of the triangle: {s:^10}')
198f5ee48709be0c9c0520e785551c7eaf2fb34f
mustard-seed/graph_algo
/test_digraph_topological_order.py
1,299
3.734375
4
from digraph.digraph import * if __name__ == '__main__': numV = 13 edges = [ [0, 1], [0, 5], [0, 6], [2, 0], [2, 3], [3, 5], [4, 6], [5, 4], [5, 9], [6, 7], [6, 9], [7, 8], [9, 10], [9, 11], [9, 12], [11, 12] ] def checkOrder(orde...
384bea6bdc6515f50e2c07416532efaacdfaf173
saishg/codesnippets
/codeeval/towers.py
1,249
3.53125
4
#!/bin/python import sys class Tower: def __init__(self, line): self._blocks = map(int, line.split()) self._sum = sum(self._blocks) def sum(self): return self._sum def pop(self, height): while self._sum > height: self._sum -= self._blocks.pop(0) ...
3231452f80eed353eaca1b39db9b78b7970fa713
Peter-Gr/MLPositionExtrapolator
/simple2.py
1,248
3.6875
4
import numpy as np # sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) # input dataset # The pattern is - doulbe the first column other columns are irrelevant X = np.array([ [2,3,4], [3,2,60], [4,9,12], ...
362d7e4a070f686f0b73adac8b2fc1762a9458c0
TAHURASFRY/older-homeworks
/RPS.py
2,350
4.0625
4
import random items = ["ROCK","PAPER","SCISSOR","EXIT"] computer_score = 0 user_score = 0 computer_choice = random.choice(items) print("0-ROCK") print("1-PAPER") print("2-SCISSOR") print("3-EXIT") while True: user_choice_index = int(input()) user_choice = items[user_choice_index] ...
b952ea3f79d505379ecf7c4e99e53cadc86fe4ad
olaruandreea/KattisProblems
/grandpabernie.py
383
3.625
4
def createDictionary(): n = input() i = 0 d = {} while i < n: tokens = raw_input().split() if tokens[0] not in d: d[tokens[0]] = [tokens[1]] else: d[tokens[0]].append(tokens[1]) i+=1 n2 = input() i = 0 l = [] while i < n2: tokens = raw_input().split() l.append(sorted(d[tokens[0]])[int(tokens...
a91ea6afeb939f35606871c8d36cdf58fc3387c7
xyzrlee/LeetCode
/530. Minimum Absolute Difference in BST/530v2.py
1,188
3.65625
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def getMinimumDifference(self, root): """ :type root: TreeNode :rtype: int """ last, min = None, None ...
2b3eed20b9c8f9039824249c030c082eff21be2a
BlAcAnNy/kpk_33_0201
/180921/electronics_store.py
2,193
3.5
4
class Electronics: def __init__(self, name, characteristic, guarantee, producing_country, price): self.name = name self.characteristic = characteristic self.guarantee = guarantee self.producing_country = producing_country self.price = price def __str__(self): ret...
a0ab2fd77f10aa0a74757f05d6ec0c6aa028bc41
mcelroa/Python-GUI
/main.py
2,290
3.9375
4
import tkinter as tk from tkinter import filedialog, Text import os root = tk.Tk() apps = [] #If this is not the first time using the GUI then this code block will #add previously opened apps to the screen on start up. if os.path.isfile("save.txt"): with open("save.txt", "r") as f: tempApps = f.read() ...
12994e12df90c5506fed6820154f820005f32dc4
BeeverFeever/Tic-Tac-Toe
/Tic_Tac_Toe-Python/Tic_Tac_Toe.py
1,804
3.84375
4
board = ["-", "-", "-", "-", "-", "-", "-", "-", "-",] winner = None def GenerateBoard(): print(f"""{board[0]}|{board[1]}|{board[2]} {board[3]}|{board[4]}|{board[5]} {board[6]}|{board[7]}|{board[8]}""") def GetInput(player): position = int(input(f"'{player}' Turn, where would you like to place your piece (0-9): "...
cc9a91f14323ed854da9b86f4251e48b5d6cc3f1
ThomasLeonardo/Intro-to-CS
/guess_num.py
686
4.15625
4
# -*- coding: utf-8 -*- guess = 50 min_num = 0 max_num = 100 print("Please think of a number between 0 and 100!") while(True): print("Is your secret number", str(guess) + "?") i = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed corr...
ddee0144eb4b138ff6641ce9796a1291b0add1ee
fanyCaz/discrete-math
/exampleSets.py
621
3.65625
4
U = 191 F = 65 N = 76 M = 63 sets = [] print("Of the group of 191") print("Will you add a set? y/n") ans = input() while(ans == 'y'): print("Insert number of students, then after commas, the subject they're into : students,F,N,M") x = input() x = x.split(',',1) sets.append([x[1],int(x[0])]) print("W...
137275479f2d2488bf9b142328b4632b7307abc2
bala4rtraining/python_programming
/python-programming-workshop/def/tuple_args_great_super.py
534
4.625
5
#Tuple argument. A method in Python can receive any number of arguments stored in a #tuple. This requires the single-star syntax. A formal parameter of name *t can be #used as a tuple. #Tip: The tuple in this program, of identifier t, can be used in the same way as any tuple. #Python that receives tuple argument ...
49c4904fb4e4f5110ffade1cb1a42940f312cc2a
hhahhahhahha/python
/第一次上机/01.py
421
3.5625
4
#e1.1TempConvert.py TempTstr = eval(input("请输入温度值:")) s = input("请输入F或C以此选择温度类型(华氏温度: F,摄氏温度:C):") #print(TempTstr) if s in ['F','f']: C = (TempTstr-32)/1.8 print("转换后的温度{:.2f}C".format(int(C))) elif s in ['c','C']: F =1.8*TempTstr+32 print("转换后的温度是{:.2f}F".format(int(F))) else: print("输入格式错误")
c12aa498cc01e6099f1af676a36fb538dfac1da9
NathanMuniz/Exercises-Python
/Desafio/ex061.py
537
3.796875
4
print('Gerar Pa') print('-=' *10) first = int(input('Primeiro Termo')) reason = int(input('Rasão da PA')) term = first cont = 1 while cont <= 10: print('{}'.format(term), end='') print(' → 'if cont <= 9 else '', end='') term = term + reason cont = cont + 1 '''print('Gerar Pa') print('-='*10) first = in...
e5c116184f8ab10f218f70a5b86afb9251e3349a
ayk-dev/python-basics
/drawing/butterfly.py
734
3.921875
4
n = int(input()) # ширина 2 * n - 1 колони # height 2 * (n - 2) + 1 # Лявата и дясната ѝ част са широки n - 1 middle = n - 1 s = (n - 1) - 1 dash = '' r = 2 * (n - 2) + 1 # range = height spaces = n - 1 for row in range(1, r + 1): if row == middle: print(' ' * spaces + '@' + ' ' * spaces) ...