blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9e7183bcf3d1673a836edc624d881c538a113201
mattblk/Study
/Python/level1/level1_문자열내마음대로정렬하기.py
182
3.671875
4
strings=["abce", "abcd", "cdx"] n=2 def solution(strings, n): strings.sort() answer = sorted(strings, key=lambda k :k[n]) return answer print(solution(strings,n)) #8점
ccb988ec5cc4a16821c8d6a8c3b11cac393a9ed3
antiface/pybot
/cnjokes.py
527
3.5
4
import urllib2 import re import json """ Return the website json response for Chuck Norris jokes """ def getJsonForJokes(): apiCall = urllib2.urlopen('http://api.icndb.com/jokes/random/') return json.loads(apiCall.read()) """ Returns the joke as a string without the parentheses """ def getJoke(response): ...
629c12d7ef38a57f3453ef78090988f418b2475a
JLowe-N/Algorithms
/AlgoExpert/checkbstequality.py
2,846
3.921875
4
''' Given 2 arrays that represent BSTs and the order in which elements are inserted into each BST, check and return a boolean if the 2 arrays produce equivalent BSTs. Do not construct a BST to implement this algorithm. ''' # Solution 1 - Recursive Approach with Pointers # Complexity - O(N^2) Time | O(d) Space # Where...
ff21fb3637537b9d00186742381a4b388ac89e47
jkbockstael/leetcode
/2020-07-month-long-challenge/day07.py
1,527
3.96875
4
#!/usr/bin/env python3 # Day 7: Island Perimeter # # You are given a map in form of a two-dimensional integer grid where 1 # represents land and 0 represents water. # Grid cells are connected horizontally/vertically (not diagonally). The grid # is completely surrounded by water, and there is exactly one island (i.e., ...
7396f18aea8cd11de075e5998081a7191fb8a36e
nkowdley/AutoInterview
/Rank.py
3,153
3.671875
4
import sys import StringIO class Rank: skills = [] gpa = 0.0 graduation = 'Undergrad' #topTierCompanies = [] def __init__(self, arrayOfStrings): self.arrayOfStrings = arrayOfStrings def enterDiscrimination(self): listOfSkills = raw_input('Enter the skills your require: ') ...
9427fcd08cff9abfe8aa8fd74a71bd5c0c092359
sinha414tanya/tsinha
/armstrong.py
414
3.625
4
num1=int(input()) def check_armstrong(num1): if num1<=100000: num = num1 st=str(num1) l=len(st) sum=0 while(num>0): c=num%10 sum=sum+(c**l) num=num//10 if int(num1)==sum: return True else: ...
f44bbaafaed7dd847dc4cecb6c23929d33aea33f
omerfarballi/Python-Dersleri
/04.variables.py
844
4.03125
4
klavye = 50 gozluk = 300 kdv_oranı= 0.18 kdvli_klavye = klavye+(klavye*kdv_oranı) kdvli_gozluk = gozluk+(gozluk*kdv_oranı) print("kdvli gözlük : ",kdvli_gozluk,"kdvli klavye: ",kdvli_klavye) # değişken isimi verirken dikkat etmemmiz gereken durumlar: # sayı ile başlayamaz number1 = 99 print(number1) number1...
731dd5ebf7927e965ff639430e59f952f3845d98
mckilem/python1_hw
/lesson1/hard.py
680
4.5
4
# Задание-1: # Ваня набрал несколько операций в интерпретаторе и получал результаты: # Код: a == a**2 # Результат: True # Код: a == a*2 # Результат: True # Код: a > 999999 # Результат: True # Вопрос: Чему была равна переменная a, если точно известно что её значение не изменялось? # Пришлось поискать есть ли беск...
28086150814e85d850cb2d1ff157dc879e5e3e36
Zoe8888/error-handling
/window.py
1,314
4.03125
4
from tkinter import * from tkinter import messagebox # Initializing the window root = Tk() # Creating a title root.title('Exception handling') # Setting the window size root.geometry('300x200') # Ensuring the window size cannot be adjusted root.resizable('False', 'False') # Setting a background color root.config(bg='...
b9ec028ff6eda91cc29e75e1b96256d0ad7c2179
ShaunaVayne/python_version01
/com/wk/DbDemo/test.py
716
3.734375
4
# 连接mysql import mysql.connector connect = mysql.connector.connect(user='root', password='root123', database='wangkun') # cursor = connect.cursor() # # 创建user表 # cursor.execute('create table user (id VARCHAR(10) PRIMARY KEY , NAME VARCHAR(20))') # # 插入一行数据 # # 注意, 在python中mysql的占位符是%s, java中是? # cursor.execute('inser...
8525f2d4ea50e2809449332c57a6e0447aa5fb7a
Velu2498/codekata-array-python
/150.py
410
3.828125
4
""" Given a number N, print all the prime factors once in ascending order. Input Size : N <= 100000 Sample Testcase : INPUT 100 OUTPUT 2 5 """ n=int(input()) ans=[] i=1 while(i<=n): k=0 if(n%i==0): j=1 while(j<=i): if(i%j==0): k=k+1 j=j+1 if(k==2)...
443d623364fde55c25c7c510e3f4699836275de1
saparia-data/data_structure
/geeksforgeeks/dynamic_programming/12_0_1_knapsack_problem.py
1,371
3.96875
4
''' You are given weights and values of N items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that we have only one quantity of each item. In other words, given two integer arrays val[0..N-1] and wt[0..N-1] which represent values and weights associated with N items r...
4911fa14f055ca3f6dfdc66284dfb2f18b73297d
italoohugo/Python
/Geometria/C.py
247
4
4
print('Programa Calculo da area de um Trapezio') Base = float(input('Digite a base Maior: ')) base = float(input('Digite a base Menor: ')) h = float(input('Qual a autura: ')) area = (Base + base) * h / 2 print('A area de um Trapezio é:',area)
93abbc4b3978bcaa2eef75f402288645a5a31509
tdworowy/PythonPlayground
/Playground/dice_game/dice_game.py
2,781
3.671875
4
import itertools from typing import Union def count_wins(dice1: list, dice2: list) -> tuple: assert len(dice1) == 6 and len(dice2) == 6 dice1_wins, dice2_wins = 0, 0 for res in itertools.product(dice1, dice2): if res[0] > res[1]: dice1_wins += 1 if res[1] > res[0]: ...
c13c703d11980c4313fe826b112934adc0808ec3
fbidu/Etudes
/Python/exceptions/chaining.py
539
3.625
4
# Exception masking a = {"key": "value!!"} try: unvalid = a["heey"] except KeyError as ke: raise Exception("I'll mask the key error!") from ke # Python 3.7 Output """ Traceback (most recent call last): File "chaining.py", line 6, in <module> unvalid = a["heey"] KeyError: 'heey' The above exception was...
085bf90e0c8ebe9b2ff1836f12a74932008d84d9
JaisonVB/INTRODUCAOPYTHON
/aula1/exercicio5.py
431
3.921875
4
# Elaborar um programa que efetue a leitura de três valores inteiros (variáveis A, B, C) # e apresente como resultado final o valor do quadrado da soma var_A = int(input('Digite o primeiro valor ')) var_B = int(input('Digite o primeiro valor ')) var_C = int(input('Digite o primeiro valor ')) soma = var_A + var_B + va...
01b72080419d548f8f1646dec0a22c552e36c7dd
bbb1991/devlabs-python
/week2/examples/example18.py
278
3.8125
4
# coding=utf-8 # Разное # Укороченная запись if else def my_abs(x): return x if x >= 0 else x * -1 print(my_abs(-5)) # Печать подключенных модулей print(dir(__builtins__)) # аналог type() print(isinstance(1, int))
58ab5f53b6f3192e7477ee823a606f6d66116b36
ssiddam0/Python
/Lab4/lab4-16_Sowjanya.py
1,183
4.40625
4
# program - lab4-16_sowjanya1.py 12 April 2019 ''' This program will perform the following actions: 1. ask for the input of number of squares to draw 2. Based on the input, draws a design using repaeated squares. ''' # ==============================import the turtle graphics system import turtle # ====...
1326ba7d5aaf18d8375fbdae7a98abe0aa05e5dc
cutoutsy/leetcode
/medium/problem24/Solution.py
780
3.75
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: re...
87402b2ab768de560be94667f2dbf033bcd63a4f
Kaushik8511/Competitive-Programming
/Mathematics/isPrime(O(sqrt(N)).py
280
4.1875
4
num = int(input("enter a number")) def isPrime(n): if n==0 or n==1: return False i=2 while(i*i<=n): if n%i==0: return False i+=1 return True print(isPrime(num))
6b820f76f2c1c1dfbe59e5b9792288746808bf54
natanno4/home_assistant
/db/db_handler.py
2,263
3.734375
4
import sqlite3 class DbHandler: def __init__(self, db_path): """ constructor :param db_path: db file path to connect to. :type db_path: str """ self.__path=db_path self.__conn = None self.__cursor = None def get_path(self): """ ...
c16f182399168fca334dbf809031d8404a5a1404
tbhall/Ciphers
/rsa_cipher.py
4,080
3.96875
4
#!/bin/python # -*- coding: utf-8 -*- ###################################################################### ### ### ### Description: Uses the RSA encryption method to encrypt ### ### and decrypt data. #...
b532e610f45e7aa88c5eee2c3c78132988a2cf97
Hongtao-Lin/Leetcode
/Python/109. Convert Sorted List to Binary Search Tree.py
1,006
3.953125
4
""" Idea Consider a one-pass O(n) time and O(1) space solution Using the in-order framework, we can move the linked list forward and only consider the current node assignment """ class Solution(object): def sortedListToBST(self, head): """ :type head: ListNode :rtype: TreeNode ...
f555b1d903d9646e4fdbcafaa300a424d5239efe
liuyanhui/leetcode-py
/leetcode/implement-strstr/implement-strstr.py
3,365
3.984375
4
""" https://leetcode.com/problems/implement-strstr/ 28. Implement strStr() Easy ----------------------------------- Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "hello", needle = "ll" Output: 2 Example 2: Inpu...
1207d889d8e4e5d304270e91b6cbb8ff50c3720a
DmitryVlaznev/leetcode
/35-search-insert-position.py
1,102
4.0625
4
# 35. Search Insert Position # Given a sorted array and a target value, return the index if the # target is found. If not, return the index where it would be if it were # inserted in order. # You may assume no duplicates in the array. # Example 1: # Input: [1,3,5,6], 5 # Output: 2 # Example 2: # Input: [1,3,5,6], 2...
f35290dbd65ecf08f11d1a780f24d275a58b57d8
evilgod/Leetcode
/ReverseInteger/reverseInt.py
443
3.625
4
class Solution: # @return an integer def reverse(self, x): result = "" if x == 0: return 0 if x < 0: result = "-" x = abs(x) while x > 0: p = x%10 q = x/10 result = result + str(p) x=q ...
2206893a32ea57675028d45cc09868ea100f6985
nigel2912/guess_number
/guess_number.py
2,176
4.46875
4
# implement a guessing game # where the computer has a secret no. which we have to guess # having the computer gen a secret no import random # random.randint(a,b) returns a no 'n' in range (a,b) such that a<n<b # computer generates the random number and user guesses it def guess(x): random_number = r...
aea204e593f7caba9431f82bd78e64b6bd1744f8
DBeardionaire/learning-python
/thehardway/test.py
1,288
3.984375
4
lloyd = { "name": "Lloyd", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0] } alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } tyler = { "name": "Tyler", "homework":...
4bdd28d1987d8dbfec3e34f2740951e8593dcc20
QiongWangUSCEE/EE511-Simulation-Methods-for-Stochastic-Systems
/project2/Q3(ab).py
535
3.640625
4
import random import matplotlib.pyplot as plt for times in range(20): X2 = 0 num = 1000 degree = 9 sample = [] for i in range(num): sample.extend(random.sample(range(10), 1)) for i in range(degree + 1): X2 += ((sample.count(i) - num / (degree + 1)) ** 2) / (num / (degree + 1)) ...
4151807b069f082f6b8426e033b7caf997507d7d
jennyChing/onlineJudge
/350.py
1,378
3.96875
4
''' functions - 350 - Pseudo-Random Numbers A common pseudo-random number generation technique is called the linear congruential method. If the last pseudo-random number generated was L, then the next number is generated by evaluating ( tex2html_wrap_inline32 , where Z is a constant multiplier, I is a constant increm...
0041608cafd2a0c1ca58b94404f8d430d3596415
aninda052/Computative_Programming-
/LeetCode/9/9-Palindrome_Number.py
369
3.53125
4
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0: return False reverse_x = 0 tmp_x = x while tmp_x: remainder = tmp_x % 10 tmp_x /= 10 reverse_x = (reverse_x...
7293396f1e7b631b089af28dfe6f9c98ed0cfcb6
Ghostfyx/machine_learning_algorithms
/linerRegression/computeCostMult.py
607
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/12/15 18:07 # @Author : fanyuexiang # @Site : 求解多特征数据集损失函数 # @File : computeCostMult.py # @Software: PyCharm import numpy as np def computeCostMult(X, y, theta): """ Compute cost for linear regression with multiple variables J = ...
cd9dd2ba8e0959bd0a93e193914b5aea89dcab0b
azuretime/Digital-World
/W5/extract_value calc_ratios.py
501
4.15625
4
def extract_values(values): values=values.strip().split() return (int(values[0]),int(values[1])) '''strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters). str = "0000000this is string example....wow!!!0...
83d9662eb0e9a60f15cbfd66bf46b12713620813
jkusita/Automate-Ideas-for-Similar-Programs-1
/tempCodeRunnerFile.py
224
3.5625
4
# Enter seconds here # # 1800 seconds = 30 minutes, 120 seconds = 2 minutes # time_limit = 10 # while time_limit != 0: # print(time_limit) # So that you can see the time left # time_limit -= 1 # time.sleep(1)
c36b7fcd888b222dad589e37e971f1c637f915c3
banditypte/leet-code
/longest_common_prefix.py
841
3.734375
4
class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(strs) == 0: return '' prefix = strs[0] for string in strs[1:]: cur_prefix = '' for i_char, char in enumerate(prefix): ...
2bab7c39d62579f60dae4c6f75d60a90f4658465
thaysom22/dsa-problems
/fibonacci.py
789
3.609375
4
# import random def calc_fib(n): if n < 2: return n fib_vals = [0]*(n+1) fib_vals[1] = 1 for i in range(2, n+1): fib_vals[i] = fib_vals[i-1] + fib_vals[i-2] return fib_vals[n] # def calc_fib_naive(n): # if n < 2: # return n # return calc_fib_naive(n-1) + calc_fib_...
5689cc2e627b3547810153939e1375c189604c37
pu-bioinformatics/python-exercises-Fnyasimi
/Scripts/exercise05_bank.py
1,895
3.828125
4
#! /home/user/anaconda2/envs/bioinf/bin/python #This script was made in Python 3.7.2 acountbal = 50000 print('%s' % "Welcome to Festus Enterpise Bank".center(60)) print('%s' %"We are commited to serve you".center(60)) choice = input("Please enter 'b' to check balance, 'w' to withdraw, or 'd' to deposit: ") while choic...
2f1db5676446327f2787d8d1c61c941472a3fa91
shady1924/chap1
/Assisgments/ch7_10_main.py
491
3.890625
4
from Assisgments.ch7_10 import Time def main(): # create object for current time t1 = Time() print('Current time is {0}:{1}:{2}'.format(t1.getHour(),t1.getMinute(),t1.getSecond()) ) # get input from the user setseconds=eval(input("Enter the elapsed time:")) ## 55550505 # set the new time fo...
4f94380c66e2d2248431f0893d22ffbbb69e5c99
JianHangChen/LeetCode
/Lint14. First Position of Target.py
545
3.859375
4
class Solution: """ @param nums: The integer array. @param target: Target to find. @return: The first position of target. Position starts from 0. """ def binarySearch(self, nums, target): low = 0 high = len(nums) - 1 while low < high: mid = low + (hig...
cef70e7eb527c89e7b29a493de495f01f5ca1cc6
nkukarl/leetcode
/remove_nth_node_from_end_of_list_test.py
832
3.515625
4
from unittest import TestCase from remove_nth_node_from_end_of_list import Solution from utils_linked_list import compare_linked_lists, get_head_linked_list class TestRemoveNthNodeFromEndOfList(TestCase): def test_remove_nth_from_end(self): # Setup sol = Solution() N = 5 linked_li...
e16960d3759677e4f7f13b30728b07d321c94af5
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 2/ex044 - Gerenciador de Pagamentos.py
1,409
4.0625
4
""" Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu preço normal e condição de pagamento: -Á vista dinheiro/cheque: 10% de desconto -À vista no cartão: 5% de desconto -Em até 2x no cartão: Preço Normal -3x ou mais no cartão: 20% de Juros """ valor = float(input("Digite o valor do...
a9a5df8868059c15d4dfdc949291b2670f545198
Mugeri/Bootcamp-7
/andelabs/reverse_string.py
137
4
4
def reverse_string(string): if string == '': return None string1 = string[::-1] if string1 == string: return True return string1
c699c7428a17620bbf365ab7f919b1d167f3b884
calonso/IEAlgorithmsDataStructures
/bubble_sort.py
225
4.0625
4
def bubble_sort(data): for i in range(len(data)): for j in range(len(data)-i-1): if data[j] > data[j+1]: temp = data[j] data[j] = data[j+1] data[j+1] = temp return data print(bubble_sort([3, 6, 2, 1]))
dc481c354f1afe3d93e1db3f17c1b7d033b98bb2
burglim/practiceprojects
/notebooks/games/blackjack/blackjack.py
4,713
3.765625
4
from random import shuffle from IPython.display import clear_output nums = ['Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace'] suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9...
c5789c34bddd97d0ddb811a068c393fd530b4ec5
yeshaj/CS261
/assignment3/max_stack_sll.py
2,369
3.75
4
# Yesha Jhala # CS 261 # Assignment 3 Part 3 # Description: Implementation of a stack built off of a singly linked list structure, and keep track of max value of stack for O(1) getter method. from sll import * class StackException(Exception): """ Custom exception to be used by MaxStack Class DO NOT CHAN...
403424c6ac3cb4acb1c9ce2a3d6e5402c1875bce
GuoQin8284/PythonCode
/学院管理系统/student.py
447
3.578125
4
class Student(): def __init__(self, name, age): self.name = name self.age = age self.stu_data = self.load_student_info("./stu_data.txt") def __str__(self): data = f'{self.name}, {self.age}' print(type(data)) return data def load_student_info(self,file_path)...
91f1e4782ea97fad00f6c77a791dea06359658a2
Zebfred/ENIT_reference
/Mobile_Laptop/Additional_Resources/code_signal/CodeSignal-WorkingSolutions/Codesignal Arcade - Intro/44 - findEmailDomain.py
201
3.671875
4
def findEmailDomain(address): address_spl = address.split("@") c = [ i for i in address_spl ] if len(address_spl) == 2: return c[1] if len(address_spl) == 3: return c[2]
ea806becec12909e6cd578908b9bbf80e379a7a1
InfoTech-Academy/Python_Week3
/3.week-homework-7.py
110
3.765625
4
def word_upper(): x= input("please enter word or sentence : ") return print(x.title()) word_upper()
6012b80dd8bb2a00df247b7af87dc0c11e7d6b3d
kdandiwala/Calculator
/project.py
2,871
4.0625
4
from tkinter import * root = Tk() root.title("Calculator") root.configure(background='white') root.resizable(False, False) console = StringVar() console.set('') window = Entry(root, textvariable = console) text = str(window) window.grid(row = 0, columnspan = 4, ipady=7) def button_press(num): global text t...
be157fb4c4a78da4069c0840f525345ac37211e2
daviswu/selfteaching-python-camp
/exercises/1901100294/1001S02E05_string.py
1,844
3.734375
4
text = ''' The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although p...
bcce1ed1bb63873e81ab2b6ba87602a7ef569d67
kdaivam/leetcode
/DI String match.py
420
3.515625
4
class Solution: def diStringMatch(self, a: str) -> List[int]: low = 0 high = len(a) res = [] for i in a: if i == 'I': res.append(low) low += 1 else: res.append(high) high -= 1 ...
b4365951efb1e6b398afd76c9404e9fa85d654ac
rhitayu2/solar-cell-maintenance
/solar_cell.py
1,093
3.515625
4
import RPi.GPIO as GPIO import time filename = "/home/pi/solar_cell_reading" #Setting the configuration as board instead of BCM GPIO.setmode(GPIO.BOARD) #Setting the pins in which the 8 bit output will come GPIO.setup(3, GPIO.IN) GPIO.setup(5, GPIO.IN) GPIO.setup(8, GPIO.IN) GPIO.setup(10, GPIO.IN) GPIO.setup(11, GP...
f5eb203c7d67edf5c3b9a753782ed84f14ed7c92
ankita30/Exam-Statistics
/Exam_statistics.py
705
3.9375
4
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade def grades_sum(grades): return sum(grades) def grades_average(grades): return grades_sum(grades)/ float(len(grades)) def grades_variance(grades): average = gr...
ecb38516d5992fcc4cb0824ac99a955b78f8aa6c
Travmatth/LeetCode
/Medium/jump_game.py
1,393
3.90625
4
""" Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. """ class Solution(object): def canJump(self, nums): """ :typ...
86f33d38a055d94ed4a119e3d94031817ec11c17
darkbodhi/Some-python-homeworks
/pyramid2.py
324
3.703125
4
total = int(input("Please, insert the number of rows: ")) y = int(1) counter = int(0) my_list = [] my_list.append(y) for counter, i in enumerate(range(0, total)): for j in range(1): print(*my_list, end=" ") my_list.clear() for w in range(counter): y += 1 my_list.appen...
293538e544b8e97db6f02e8e78c41d86dedada3e
saigowtham96/testing-repository
/cspp1-practice/m6/p3/digit_product.py
296
3.859375
4
''' Given a number int_input, find the product of all the digits ''' NUM = int(input()) # NUM = -12345 temp = NUM I = 1 if NUM < 0: NUM = NUM * -1 while NUM >= 1: A = NUM%10 I = A*I NUM = NUM//10 if temp < 0: I = I * -1 if temp == 0: print(temp) else: print(I)
611d73ab4d1797da6db8354ada4c6a69d1f2c4d1
matiyashu/pythonProjectCodeCademy
/Strings_medical-Insurance.py
2,579
3.96875
4
medical_data = \ """Marina Allison ,27 , 31.1 , #7010.0 ;Markus Valdez , 30, 22.4, #4050.0 ;Connie Ballard ,43 , 25.3 , #12060.0 ;Darnell Weber , 35 , 20.6 , #7500.0; Sylvie Charles ,22, 22.1 ,#3022.0 ; Vinay Padilla,24, 26.9 ,#4620.0 ;Meredith Santiago, 51 , 29.3 ,#16330.0; A...
25ac9f4e9558c2044c1d5aad20f3c602204a43e6
decimozack/coding_practices
/leetcode/python/longest_palindromic_substr.py
2,105
3.59375
4
#!/usr/bin/python3 # https://leetcode.com/problems/longest-palindromic-substring/ class Solution: def longestPalindrome(self, s: str) -> str: lg_str = '' lg_count = 0 str_len = len(s) for idx, char in enumerate(s): # check for odd palindrome ...
359b62716f35e25db41cafbb4132e92b5bb2c8e0
qmshan/DataEngineering_Challenge
/src/process_log.py
12,599
3.65625
4
from sys import argv import heapq import time import datetime from collections import deque from sets import Set import sys """ log class is used to store log information after string parsing """ class log(object): def __init__(self, IP, time, stamp, resource, status, size, line): self.IP = IP...
8d68b252611c68b2ff236d3ebd4ad817ddbf13b5
lujun9972/word_grouping.py
/word_grouping.py
1,190
3.53125
4
import sys from edit_distance import edit_distance def distance(group, s): 'Calulate the average distance between seq S and seqs in GROUP' if not group: return 0 distances = list(edit_distance(s, seq)[0] if seq[0:2] == s[0:2] else 9999 for seq in group) # 前两个字母不同的单词不在一起 r...
5dfc0ffe1f36566d3d72c062aeefd5c8dfa49287
saltmania/web-caesar
/helpers.py
939
3.96875
4
def alphabet_position(someChar): alphabet = 'abcdefghijklmnopqrstuvwxyz' position=0 newChar=someChar.lower() position=alphabet.find(newChar) return(position) def giveNewChar(someChar, x): #The only real purpose of this function is to maintain Uppers vs. Lowers. alphabetLOWER = 'abcde...
862d6475a0c66bbcc9e99628162ef58ca7c90cc8
gambxxxx/scripts
/practice-stuff/error_exc.py
298
3.75
4
def exception_handling(): try: for i in ['a','b','c']: print (i**2) print('code weas executed correctly') except: print('Nuh Uh!') finally: print("c'monbruh!") def main(): exception_handling() if __name__ == "__main__": main()
0b3f7be835d17ab358760961d8749b11a903f07a
ranji2612/Algorithms
/sorts/selectionSort.py
243
3.53125
4
def selectionSort(A, printStep = False): l = len(A) for i in range(l-1): k = i for j in range(i+1,l): if A[j] < A[k]: k = j #Swap the min t = A[k] A[k] = A[i] A[i] =t if printStep: print 'Iter '+str(i+1),A return A
4a48b9e2d888dc74eca3482c18dfb503f899a83e
ddavid/supervisely
/plugins/import/watermark-images/supervisely_lib/imaging/color.py
3,421
3.65625
4
# coding: utf-8 import random import colorsys def _validate_color(color): if not isinstance(color, (list, tuple)): raise ValueError('Color has to be list, or tuple') if len(color) != 3: raise ValueError('Color have to contain exactly 3 values: [R, G, B]') for channel in color: if 0...
7121dd7448252c5bda04f388eef62bb27dfc351f
ganpatparmar/python_practice
/ex10.py
437
3.8125
4
print("i am 6'2\" tall") print('i am 6\'2" tall') tabby_cat = "\ti'am tabbed in" persian_cat = "\tI'm split\n \t on a line:" backlash_cat = "\tI'm \\a\\car" fat_cat = ''' let me make a list: \ooo* Cat Food \t* Fishes \t* Cat tip\n\t* Grass """ ''' print(tabby_cat) print(persian_cat) print(backlash_cat) ...
28000eb1b3ed46449256fb844db76e8e77d03cc7
challeger/leetCode
/初级算法/leetCode_45_有效的括号.py
1,292
3.953125
4
""" day: 2020-08-15 url: https://leetcode-cn.com/leetbook/read/top-interview-questions-easy/xnbcaj/ 题目名: 有效的括号 题目描述: 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 注意空字符串可被认为是有效字符串。 示例: 输入: '()' 输出: ture 输入: '([)]' 输出: false 输入: '({})' 输出: ...
6414adde77a522780a3ccef062feaa6f6fa87cff
forbearing/mypython
/Process/1.2_multiprocessing.py
4,308
3.765625
4
https://blog.csdn.net/brucewong0516/article/details/85776194 1:概述 1:multiprocessing类似于threading模块支持生成进程的包,是Python的标准模块,它既可以 用来编写多进程,也可以用来编写多线程。如果是多线程的话,用 multiprocessing.dummy 即可,用法与 multiprocessing 基本相同 2:由于python使用全局解释器锁(GIL),他会将进程中的线程序列化,也就是多核cpu实际上并 不能达到并行提高速度的目的,而使用多进程则是不受限的,所以实际应用中都是推荐多...
e03cfa63c699a133d9dff021cbc9e1040973df23
crystalattice/Python_MicroDegree
/function_decorator.py
730
4.375
4
from math import pi def arg_checker(input_func): def wrapper(num): if type(num) != float: raise TypeError("Argument is not a float") elif num <= 0: raise ValueError("Argument is not positive") else: return input_func(num) return wrapper @arg_checke...
da0f3749566f4ecf4a8d3cd6b7d1580e3b92b155
kzl5010/HackerRank-Python
/InsertionSort.py
371
3.828125
4
def insertionSort(ar): key = 0 i = 0 for j in range(1, len(ar)): for i in range(j): if ar[j] < ar[i]: key = ar[j] ar[j] = ar[i] ar[i] = key for x in ar: print (x, end = ' ') print() m = input() ar = [int(i) f...
9f67d565658f49607f2dce62d54d1e6efd102971
Italo-Neves/Python
/Paradigmas_Program/aula01.py
3,679
4.40625
4
""" CEUB - Ciência da Computação - Prof. Barbosa Atalho de teclado: ctlr <d>, duplica linha. ctrl <y>, apaga linha. ctrl </>, comenta linha - Valor default Quando declaramos as variáveis na classe Conta, aprendemos que podemos atribuir um valor padrão para cada uma delas. Então, atribuo um valor padrão ao li...
3553661a4854d98fba76f9caa19025d2e373806d
bhirbec/interview-preparation
/CTCI/2.2.py
1,011
3.78125
4
class Node(): def __init__(self, value, next_node=None): self.value = value self.next_node = next_node def main(): head = Node(12, Node(10, Node(3, Node(1, Node(156, Node(43)))))) print find_kth_from_tail(head, 2) print find_kth_from_tail_runner(head, 2) print find_kth_from_tail(N...
9d0a614fb0935e2e5ec4d62fbccafa54c12ecb16
KaylaZhou/PythonStudy
/PPy/海归图库的用法.py
1,985
4
4
#!/usr/bin/python3 import turtle turtle.screensize(400, 400, '#a9758b') # 设置画布宽和高的大小,颜色 turtle.setup(400, 400, 0, 0) # 设置画布窗口宽和高,以及坐标x,y的距离(距屏幕左上角的距离). turtle.speed(1) # 设置画笔移动的速度,(1-10)数字越大,速度越快. turtle.pencolor('#ffaf50') # 设置画笔的颜色 # 画笔运动命令: turtle.pensize(10) # 设置画笔的宽度 turtle.forward(100) # 向当前画笔方向移动dist...
0e2d658ab423943a077af23369eb8d007e91dfb8
judacribz/python_repo
/csci_3070u/ass/A2/part2.py
2,707
3.6875
4
from util import * # ============================================================================= # Constants # ============================================================================= RAND_MAX = 1000000 NUM_VALUES = 10 # ============================================================================= # Radix So...
784773db84f4abcd40217530d82f4e5fb2b40b34
daniel-reich/turbo-robot
/jWHkKc2pYmgobRL8R_14.py
816
4.21875
4
""" Write a function that takes in a string and for each character, returns the distance to the nearest vowel in the string. If the character is a vowel itself, return `0`. ### Examples distance_to_nearest_vowel("aaaaa") ➞ [0, 0, 0, 0, 0] distance_to_nearest_vowel("babbb") ➞ [1, 0, 1, 2, 3] d...
c6c115f2e6a2c1123d0372dd111c6d5cc86e2476
peteryanggy/python
/VariableType.py
2,714
3.546875
4
# -*- coding: UTF-8 -*- ''' 数据类型转换 ''' #数据类型转换 print('int') print(int('64', 16)) print(int('64', 10)) print(int('64', 8)) print('\nlong') print(long('64', 16)) print(long('64', 10)) print(long('64', 8)) print('\nfloat') print(float('64.5997')) print('\ncomplex') print(complex(1, 56.597)) listvar = [1, 2, 3, 4, 5]...
b3b02871392b88dc429f4eae7750de3d00a34577
edbeeching/ProjectEuler
/Problem_023.py
1,997
3.890625
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 28 17:13:56 2017 @author: Edward A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A ...
d48524b4056e1263df3698a979ef064742cf8262
BronzeCrab/remont_task
/remont_task.py
1,402
3.65625
4
import requests as rq import json from math import sin, cos, sqrt, atan2, radians PARIS_LONG = 2.350987 PARIS_LAT = 48.856667 DISTANCE_FROM_PARIS_KM = 450 API_URL = "https://opensky-network.org/api/states/all" def calc_distance(lat1, lon1, lat2, lon2): """ https://stackoverflow.com/questions/19412462/getting...
973b01333d9fb23e51d7385523e2b444e475a483
SJMagaziner/5-Card_Poker_Hand_Simulator_and_Visualizer
/Program_components/Main_program.py
2,664
3.890625
4
#%% MAIN PROGRAM: Auto hand-drawer, visualizer, and data compiler. # Enter the number of hands you desire to generate how_many_hands = 5 # Do you want images to appear for each hand (if yes, input 1, if false input 0? #### TOO MANY HAND IMAGES BEING GENERATED WILL SLOW DOWN YOUR COMPUTER GREATLY make_images_appear = ...
3396ff3192f3a30a0e7d7e0218a5abda2e7bb375
Aaron44201/Selection
/Task 4 class excersises.py
314
3.9375
4
#Aaron Bentley #30/09/2014 #dev ex 4 grade = int(input("Test score out of 100: ")) if grade >= 81: print("Grade A") elif grade >= 71: print("Grade B") elif grade >= 61: print("Grade C") elif grade >= 51: print("Grade D") elif grade >= 41: print("Grade E") else: print("Grade U") ...
5c07eeb88e213c6712e7fdc6b42853ab45527290
minwoo2305/minwoo_Git
/Weight_optimize_using_genetic_algorithm/Genetic_Algorithm.py
3,615
3.640625
4
import numpy as np import random class genetic_algorithm(): def __init__(self, init_chromosome_list, num_of_population=10, extend_range=0.01): self.chromosomes = init_chromosome_list self.number_of_population = num_of_population self.extend_range = extend_range self.popula...
d222c22c204fb728b8c3afdf909e11cb055f9ce8
rebahozkoc/To_learn2
/quiz5-2.py
390
3.625
4
import sys def diamond_comprehension(x): for i in range(1, x+1): temp_list = [" " for m in range(x-i)] + ["*" for n in range(2*i-1)] print(temp_list) print("".join(temp_list)) for k in range(x-1, 0, -1): temp_list = [" " for p in range(x-k)] + ["*" for o in range(2*k-1)] ...
e27199d30e9ddb40e2fd7534df36bf98fa7a1a14
Lubright/training-python
/Function/ex3_star_function_kwargs.py
673
3.796875
4
# 使用 ** 建立可變參數函式 def formMolecules(**kwargs): if len(kwargs) == 2 and kwargs["hydrogen"] == 2 and kwargs["oxygen"] == 1: return "water" elif len(kwargs) == 1 and kwargs["unobtanium"] == 12: return "aether" print(formMolecules(hydrogen=2, oxygen=1)) print(formMolecules(unobtanium=12)) print(form...
1053521ce30551b0831ecf3548242ad18a689f9e
brewersey/dsp
/python/q8_parsing.py
881
4.09375
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
a6fa7da843440683cbc34f8c97aa7834e8566c85
rajgopav/Algorithms
/DynamicProgramming/Equal.py
2,090
3.546875
4
# Importing standard libraries import sys # Parsing functions def parseInt(stream): return int(stream.readline().rstrip()) def parseIntArr(stream): return [int(x) for x in stream.readline().rstrip().split()] ''' Function that returns the total number of minimum operations required. This has thre...
d7642ac4fb38d4f31e37fb8fcfd1334f2d995266
christian-miljkovic/interview
/Leetcode/Algorithms/Medium/Arrays/MinimumDominoRotations.py
1,963
4.46875
4
""" In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A are th...
d704ac06646836bafa4203d67f3522e3f4748eb4
riderswhocode/streamlit_opencv
/main.py
1,808
3.625
4
import cv2 import numpy as np import streamlit as st st.title('OpenCV Thresholding') st.write(""" Adding threshold to images to further simplify visual data analysis. """) st.sidebar.header('User Input Features') uploaded_img = st.sidebar.file_uploader("Upload your image", type=["png","jpg","jpeg"]) ...
29fd25304e8cd43d16019a837d8512fb61bdf3f6
shivam-agarwal-17/Udacity-Nanodegree-Data-Structures-and-Algorithms
/Projects/P1/problem_3_HuffmanCoding.py
4,864
3.6875
4
import sys from heapq import heappush, heappop class Node: def __init__(self, freq=0, letter=None): self.freq = freq self.letter = letter self.left = None self.right = None self.parent = None def increment_freq(self): self.freq += 1 def is_leaf(sel...
51cadc47f14714ba709577739b9785f1375c212b
Frank-en-stein/DataShall
/4.py
1,203
3.6875
4
Text = "Dude!!!! And I thought I knew a lotttt. Phewwwww!\ I won’t back down. At least I understand now Daaata Science \ is much more than what we are taught in MOOOCs. That is allllright. \ I won’t get demotivated. I’ll work harder and in noooo time, I’ll \ get better & be backkk next time." result = [Text[0], Text[1...
1d469389efddafcbd0ba208f285c6c973f39bc27
mash716/Python
/base/slice/slice0004.py
240
3.640625
4
# 開始位置と終了位置を指定することで範囲内の要素を取得することができます # 開始位置:0~4 # 終了位置:1~5 test_list = ['https','www','python','izm','com'] print(test_list[3:5])
b8db3e492e3e303851f3a6236099bcc45e5bce5b
krolmarcin/PythonLearn001
/Lessons/lesson17.py
518
3.703125
4
lista = list(range(10)) nowa = [i * 2 for i in lista] nowa2 = [i + 2 for i in lista if i % 2 == 0] #dodawanie działa po sprawdzeniu ifa: nowa3 = [i + 1 for i in lista if i % 2 == 0] print(lista) print("Nowa lista, arg * 2:", nowa) print("Nowa2:", nowa2) print("Nowa3 (nieparzyste bo dodawanie działa po sprawdzeniu if:...
4aa7c6a3d8267169c26e61d72fd6b6e819d26a6f
desenvolvefacil/SSC0800-2019-02-Introducao-a-Ciencia-de-Computao-I
/SSC0800 (2019-02) - Introdução à Ciência de Computação I/EX 002 - Lista 1 - Dados e Expressões - Operações Aritméticas.py
594
3.828125
4
''' Escreva um programa em pn2thon para realizar adição, subtração, multiplicação , divisão e modulo de dois números. Input: 12, 5 Ouput: A soma dos números dados é : 17 A subtração dos números dados é : 7 O multiplicação dos números dados é : 60 A divisão dos números dados é : 2.400000 O modulo é = 2 ''' #le os...
dacc3d740aafc3b9b803d2737721fa4d46ccb909
poojasgada/codechefsolns
/Practice-Easy/Easy-AMMEAT2.py
1,106
3.546875
4
''' Created on Jul 3, 2013 @author: psgada ''' import sys from math import floor #Ha, we dont really need to find primes def primes_sieve_way(n): prime_dict = {} for i in range(2, n+1): prime_dict[i] = True for i in range(2, n+1): for j in range(i+i, n+1...
8be0c3e4a2699ddf77ba405ee17baca05ae7475e
AbhinavPelapudi/leetcode_problems
/Facebook/linked_list/ reorder_list.py
1,527
4.09375
4
# time: O(n) # space: O(n) # Reorder List # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None """ Given 1->2->3->4->5 reorder it to 1->5->2->4->3. double_ll = [[1, N], [2,1], [3,2], [4, 3], [5, 4]] double_ll = [[4, 3], [5, 4]] double...
57dbe8819e480b5eec4d3ebee741be470f46029c
amankn/Day--2-Start-Code
/main.py
560
4.0625
4
#Data Types #String print("Aman"[3]) print("123" + "345") print("12" + "18") #Integers print(123 + 345) # How to put commas in large Integers - python we use underscores print(3_45_000) #FloatingPoint print(3.124) #Boolean print(True) print(False) #TypeError, Type Conversion num_char = len(input("What is y...
8059fee40edfad48c46ded1e1a34128ee4a2e85b
epangar/automate-the-boring-stuff-with-python
/Basics/TicTacToe/tictactoe.py
482
3.546875
4
import random board = { "UL": " ", "UM": " ", "UR": " ", "ML": " ", "MM": " ", "MR": " ", "DL": " ", "DM": " ", "DR": " ", } def print_board(): print(board['UL'] + '|' + board['UM'] + '|' + board['UR']) print('-+-+-') print(board['ML'] + '|' + board['MM'] + '|' + board['MR']) print('-+-+-') ...
b5cbc61d5070481fa9cfa55d74918563ba7ebec8
KetanMehlawat/python-programs
/temperature conversion.py
1,621
4.25
4
while True: print "Press 1 to continue" print "press 0 to exit" ch=input("enter your choice") if ch>1 or ch<0: print ("please press correct button") continue elif ch==1: while True: print"Menu" print"1.From celcius to fahrenheit" print"2....
a45e9d3eecb1936f5fea8b6b648cc15cfbdff137
Audio/SPOJ
/LASTDIG/solution.py
214
3.6875
4
# http://aditya.vaidya.info/blog/2014/06/27/modular-exponentiation-python/ lines = int(input()) for i in range(lines): ab = input().split(' ') a = int(ab[0]) b = int(ab[1]) print( pow(a, b, 10) )
21b858e51b841c168779eb9393f13398fad1fd20
yuwinzer/GB_Phyton_Algorithms
/les_01/task_07.py
1,297
3.65625
4
# 7. По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника, # составленного из этих отрезков. Если такой треугольник существует, то определить, является ли он разносторонним, # равнобедренным или равносторонним. l_1, l_2, l_3 = [int(i) for i in input("Введите длины трех от...
6ec2c4481a0e90ed24d88cc86de8e8d2567d5862
TheheiWorld/example
/com.juststand.study/oo/reflect_test.py
338
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # author : juststand # create_date : 2018/12/18 下午4:03 class Dog(object): def __init__(self, name): self.name = name def eat(self): print("%s is eating" % self.name) d = Dog("dog") choice = input(">>>").strip() if hasattr(d, choice): getatt...
aeb069d66f949e7f9d2d0e81441abb7d42f7ed1a
explocomposer/TP
/Année binaire.py
646
3.75
4
année = int(input("Saisissez une année: ")) if 4 % année == 0: bissextile = True elif 100 % année == 0: bissextile == True elif 400 % année == 0: bissextile = True print("L'année est bissextile") else: bissextile = True print("L'année est bissextile") # Si une année n'est pas ...