blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f62937a59fc575cc074780bbf33d09be33edb0c4
markfmccormick/ChessBaxter
/create_board_string.py
4,776
3.71875
4
""" Takes the 64 length array of board position piece classifications and constructs the FEN notation for the board state see: https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation Example of results, the input to the function results = ["rook","knight","bishop","queen","king","bishop","knight",...
857b96d69fa3d39f3f86c8930522ffc29f57c2ec
yhyecho/Python3
/day03/mapReduce.py
1,597
4.3125
4
# map/reduce # Python内建了map()和reduce()函数 # 1. map # map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回。 def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) L = list(r) print(L) # map()传入的第一个参数是f,即函数对象本身。由于结果r是一个Iterator,Iterator是惰性序列,因此通过list()函数让它把整个序列都计算出来并返回一个list。 # 不需要map...
20744c39976f8aedf68bc5d90f1115d208a5f9b0
standrewscollege2018/2021-year-11-classwork-Hellolightn3ss
/bidding auction.py
710
4.0625
4
auction = input("what item is up for sale today?") Reserve_price = input("what is the reserve price") print("The auction for the", auction,"has begun with the reserve price of $",Reserve_price,) name = input("whats your name?") bid = int(input("what's your bid? input as interger")) condition = 1 true = 1 admin =("a...
fef62cf65b04092023dfb0175155eaecc766cf9d
beatrizwang/advent_of_code_2020
/day02/solution.py
1,488
3.71875
4
import re import pprint def get_lines(): with open('day02\input.txt', 'r') as input_file: lines = [line.rstrip().split(':') for line in input_file] return lines def count_valid_passwords_by_letter_count(lines): count_valid_pass = 0; for line in lines: required_letter = line[0][-1]...
60bd29af7047f6234d46cb0c53f9db39a18c636b
leihuagh/python-tutorials
/books/AutomateTheBoringStuffWithPython/Chapter03/PracticeProjects/P01_make_collatz_seq.py
859
4.59375
5
# This program makes a Collatz Sequence for a given number # Write a function named collatz() that has one parameter named number. # If number is even, then collatz() should print number // 2 and return this value. # If number is odd, then collatz() should print and return 3 * number + 1. # Then write a program that ...
8761b9ea4862c5cb8801e75a560e171466bcc983
SRKACDGLD/Assignment2.2
/Assignment2.2.py
1,110
3.890625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 17 14:56:07 2018 @author: krishna.i Assignment 2.2: Create the below pattern using nested for loop in Python. * * * * * * * * * * * * * * * * * * * * * * * * * """ starval= 5 # Initialization of starval variable to set max stars needed if(starval ...
73021ba5b35bac7ecabc89c2ae3d0d071efbf376
cbass2404/bottega_classwork
/python/notes/conditionals.py
2,723
3.859375
4
# answer = False # # if answer == False: # answer = True # # print(answer) # def watermelonparty(watermelons): # if watermelons > 50: # print(True) # else: # print(False) # # # watermelonparty(51) # def kid(age): # if age > 15: # print('You can get a license') # elif age ==...
250246634ba80001c733ece18989763e91ed69c3
changdaeoh/Algorithm_study
/ch9_Stack_Queue/Q21_Remove_Duplicate_Letters.py
2,753
3.6875
4
''' Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Input: s = "bcabc" Output: "abc" Input: s = "cbacdcbc" Output: "acdb" Constraint * 1 <= s.length <= 10^4 * s consists of...
bd183d2c8eea7914e089146afa301d966cf9fd22
arnabs542/Leetcode-18
/199. Binary Tree Right Side View.py
886
4.09375
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 rightSideView(self, root: TreeNode) -> List[int]: bfs = [root] res = [] if not root: ret...
b8ae7b6929a2bbb6a1ef194f03a6a9bb6330e271
clemg/aoc2020
/AdventofCode/08/8.py
1,614
3.5
4
with open("input", "r") as fi: file = [line.strip() for line in fi] # Part 1 def part1(): ptr = 0 acc = 0 already_done = [] while True: if ptr not in already_done: already_done.append(ptr) value = int(file[ptr].split(" ")[1]) i...
e5b87f47632b42e94468628729f7729e496acb0c
hhonasoge/ds_algos
/queue.py
1,022
4.15625
4
import linked_list class Queue: def __init__(self): self.queue=linked_list.LinkedList() self.last=None self.first=None def isEmpty(self): return self.last==None def enqueue(self, data): node=linked_list.Node(data) if self.isEmpty(): self.queue.add...
49b6909079349350d03f13015472f4cc1eed8da5
stenioaraujo/cracking-interview
/chapter1/008/main.py
1,354
3.796875
4
def main(): matrix = [ [1,1,1,1], [2,2,0,2], [3,0,3,3], [4,4,4,4] ] print_matrix(matrix) matrix = [ [1,1,1], [2,0,2], [3,3,3] ] print_matrix(matrix) matrix = [ [1,1], [2,0] ] print_matrix(matrix) matrix = ...
c5224b57e783016e44d505ddd8a1eb571c74cabf
Geethachundru/CS17B009_PYTHON99prolog
/99py6.py
57
3.71875
4
my_list=[1,2,3,8,1] a=my_list[::-1] print(a==my_list)
f963e5c3771e2ea201ad4594a371239a5e4fe27b
Feedmemorekurama/py_course_bernadska
/homework_bernadska/hw_1/task_3.py
156
3.671875
4
number = 567 nextnumber = (number +1) lastnumber = (number -2) print("Your number:" ,number, "your nextnumber:" ,nextnumber, 'your lastnumber:' ,lastnumber)
9177ca1eb2409f43fe96a64588d70257c95a6c1e
joseruben123/EstructuraDatos
/S15-TAREA_4-Ejercicios_Clases/lista.py
1,548
3.859375
4
class lista: def __init__(self,tamanio=3): self.lista=[] self.longitud=0 self.size=tamanio def append(self,dato): if self.longitud<self.size: self.lsita +=[dato] self.longitud+=1 else: print("Lista esta llena") ...
fe10ba25129da1bb8441e57c44aa20c49ce78eb3
priyanka-111-droid/100daysofcode
/Day006/6-1.py
547
3.984375
4
###<<<CHALLENGE>>>### ''' To jump hurdles and carry Reborg from (x,y)=(1,1) to (13,1) Basic level - use move() and turn_left() Advanced level-define function named jump() and use that #Please write the code below in Reeborg's world text editor ! ''' def turn_right(): turn_left() turn_left() turn_left() de...
bf3d001fbb03a8c20285b7c74e631545b25c6f66
Monkey-Young/Python-Code-Practice
/force.py
293
3.78125
4
# coding:utf-8 ''' my first program. filename: force.py ''' import math f1 = 20 f2 = 10 alpha = math.pi / 3 x_force = f1 + f2 * math.sin(alpha) y_force = f2 * math.cos(alpha) force = math.sqrt(x_force * x_force + y_force ** 2) print('The result is: ', round(force, 2), 'N')
1ab7cf0a1c953282abef7916779bc5706e90f1ae
sky-dream/LeetCodeProblemsStudy
/[0221][Medium][Maximal_Square]/Maximal_Square_5.py
1,014
3.515625
4
# https://leetcode.com/problems/maximal-square/discuss/61845/9-lines-Python-DP-solution-with-explaination # leetcode time cost : 112 ms # leetcode memory cost : 14.4 MB class Solution(object): def maximalSquare(self, matrix): dp, maxLength = [[0 for _1_ in range(len(matrix[0]))] for ___ in range(len...
e9da45804fec6c0afb5d9887ec830d1b7d8a64de
benjaminek1337/dt179g_PythonProjects
/Laboration_2/assignment.py
2,955
3.625
4
#!/usr/bin/env python """ DT179G - LAB ASSIGNMENT 2 """ import argparse import sys __version__ = '1.0' __desc__ = "A simple script used to authenticate spies!" def main(): """The main program execution. YOU MAY NOT MODIFY ANYTHING IN THIS FUNCTION!!""" epilog = "DT0179G Assignment 2 v" + __version__ p...
0c06aa2d5f72b1e8243819c07fee8fc6359178b2
sake12/exercism.io
/python/rna-transcription/rna_transcription.py
266
3.703125
4
def to_rna(dna): rna = [] transcript = { "G": "C", "C": "G", "T": "A", "A": "U" } for char in dna: if char not in transcript: return '' rna.append(transcript[char]) return ''.join(rna)
3e4bc6c4ee76d5b629139bae0c6a258e46520be3
AngelaPSerrano/ejerciciosPython
/hoja1/ex01.py
172
3.71875
4
base = int(input("Introduzca la base: ")) altura = int(input("Introduzca la altura: ")) area = base * (altura/2) print("El área de su triángulo es ", area)
74bb078daf00d555275bcd3c7e7f329ff379149b
Sarbodaya/PythonGeeks
/Operator/Operator/SpecialOp.py
676
4.03125
4
# 1.Examples of Identity operators # is : True if the operands are identical # is not : True if the operands are not identical a1 = 3 b1 = 3 a2 = 'GeeksforGeeks' b2 = 'GeeksforGeeks' a3 = [1, 2, 3] b3 = [1, 2, 3] print(a1 is not b1) print(a2 is b2) # Output is False, since lists are mut...
da5721dfed38dea2fcc1f6b8cffe0ddf138e2803
timpeng1991/Data_Structures_and_Algorithms
/Algorithmic_Toolbox/Introduction/Least_Common_Multiple.py
254
4
4
#Uses python3 def gcd(a, b): if b == 0: return a else: a_p = a % b return gcd(b, a_p) def lcm(a, b): return (a * b) // gcd(a, b) x, y = [int(x) for x in input("Enter two integers: ").split()] print("LCM:", lcm(x, y))
b774f690386bdf0a7e9142c10e63f9c250963fb1
raman20/next_date
/next_date.py
1,238
4.25
4
def generate_next_date(day,month,year): #Start writing your code here next_day = day next_month = month next_year = year if month in [1,3,5,7,8,10,12]: if day<31: next_day=day+1 elif day==31: next_day = 1 if month == 12: next_year =...
4a1305f44a8424d7f5d018eccf1051bee955bb0f
lemonnader/LeetCode-Solution-Well-Formed
/backtracking/Python/0046.py
593
3.625
4
from typing import List class Solution: def permute(self, nums: List[int]) -> List[List[int]]: res = [] def dfs(nums, tmp): print('-', nums, tmp, not nums) if not nums: res.append(tmp[:]) return for i in range(len(nums)): ...
98427273cabbe338ee47cfa39fde2c69ec153cca
EmjayAhn/DailyAlgorithm
/04_30days_codechallenge/23_bst_level_order_traversal.py
1,016
4
4
# https://www.hackerrank.com/challenges/30-binary-trees/tutorial import sys class Node: def __init__(self,data): self.right=self.left=None self.data = data class Solution: def insert(self,root,data): if root==None: return Node(data) else: if data <= roo...
d8c7320a83f537a902a7f9cbfa35a1655756e0ea
HaylsDpy/Python---Udacity
/2.3 - multiplyingbyscalar.py
158
3.75
4
# Example as to multiplying a vector by a scalar aka single number # Expected output = array([3, 6, 9]) import numpy as mp v1 = np.array([1, 2, 3]) v1 * 3
ebe20ade0b67d0b32da780641b3620f2a8662b03
Eoghan-oconnor/CollatzEmergingTechLab
/collatz.py
458
4.3125
4
# The number we will perform the Collatz operation on n = int(input("Enter a positive integer: ")) # keep looping until we reach 1. # assuming the collatz conjecture is true while n != 1: # print current n value print(n) # see if n is even if n % 2 == 0: # if n is even divide by two ...
4b142da84eebf290c1f8e4eb2cbb5523105b622b
ilyarudyak/data_science
/python/oreilly_intermediate_python/unit4/jeopardy/clues.py
345
3.546875
4
import sqlite3 connection = sqlite3.connect('jeopardy.db') cursor = connection.cursor() cursor.execute("SELECT text, answer, value FROM clue LIMIT 10") results = cursor.fetchall() # TODO: process results format_string = "[$%s]\n%s\n%s\n" [print(format_string % (value, text, answer)) for (text, answer, value) in resu...
d55c6fd20ebd8d69fdf6ad44bf642c78c9e9ccde
bsextion/CodingPractice_Py
/MS/DFS/path_sum.py
801
4.03125
4
class TreeNode: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def has_path(root, sum): if root: if root.val == sum and root.right is None and root.left is None: return True if sum < 0: return False r...
a4aec1bbed4c05a2386a8c54ca9127e309fda13e
chezslice/A.I.-Personal-Assistant
/A.I. Personal Assistant/A.I._Personal_Assistant.py
1,550
3.53125
4
import speech_recognition as sr from time import ctime import time import os from gtts import gTTS def speak(audio_response): print(audio_response) tts = gTTS(text=audio_response, lang="en") tts.save("audio.mp3") os.system("mpg321 audio.mp3") def record(): r = sr.Recognizer() with sr.Microphon...
c38e62449fd9efdf488baee42e5923ca931dadb3
hedychium/python_learning
/mapAndReduce.py
1,436
3.640625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import reduce CHAR_TO_FLOAT = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '.': -1 } def str2float(s): nums = map(lambda ch: CHAR_TO_FLOAT[ch], s) point = 0 def to_f...
520c85458badb9b29eaba638f48d4e2ec304597f
myf-algorithm/Leetcode
/Leetcode/73.矩阵置零.py
1,551
3.671875
4
class Solution(object): def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: None Do not return anything, modify matrix in-place instead. O(m+n)额外空间 """ row = len(matrix) col = len(matrix[0]) row_zero = set() col_zero = set() ...
c199c4aff550e7a3b8dd83f386a5e69f8783ba8b
sm11/CodeJousts
/linkedLists.py
1,129
3.953125
4
class Node: def __init__(self, data): self.data = data self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext (self, newNext): self.next = newNext...
1fcc99b1efb6f4003e20a9856acc6ba13d623e3f
zouwen198317/TensorflowPY36CPU
/_15_Crawler/showStrOperation.py
3,096
3.78125
4
#!/usr/bin/env python #-*- coding: utf-8 -*- __author__ = 'hstking hstking@hotmail.com' def strCase(): "字串大小寫轉換" print (u'示範字串大小寫轉換') print (u"示範字串S儲存值為:' ThIs is a PYTHON '") S = ' ThIs is a PYTHON ' print (u"大寫轉換成小寫:\tS.lower() \t= %s"%(S.lower())) print (u"小寫轉換成大寫:\tS.upper() \t= %s"%(S...
75c8bd523df4378adf7cdb6840a871259ef3026a
AurelioLMF/PersonalProject
/ex023.py
394
3.96875
4
'''Faça um programa que leia um número de 0 a 9999 e mostre na tela cada um dos dígitos separados. Ex: Digite um número: unidade: 4 dezena: 3 centena: 8 milhar: 1''' num = int(input('Digite um número: ')) uni = num//1 %10 dez = num//10 %10 cen = num//100 %10 mil = num//1000 %10 print(f'Unidade: {uni}') print...
bbc291f2c47ef52147214abdd530308f5f5298ef
ketika-292/-t2021-2-1
/Program-2.py
333
3.96875
4
# Program to print an arithmetic series def printAP(a,d,n): # Printing AP by simply adding d # to previous term. curr_term curr_term=a for i in range(1,n+1): print(curr_term, end=' ') curr_term =curr_term + d # Driver code a = 2 # starting number d = 1 # Common difference n = 5 # N th term to be find print...
2bea9176297ebfb94fe29b42155078abd0fb54ea
I-ABD-I/School
/ex4_6_2.py
313
3.734375
4
def format_list(my_list): string = "" print(str(my_list[:-1:2]).replace("[","").replace("]",""),"and",my_list[-1]) format_list(["hydrogen", "helium", "lithium", "beryllium", "boron", "magnesium"]) def extend_list_x(list_x, list_y): list_x[:0] = list_y print(list_x) extend_list_x([4,5,6],[1,2,3])
1db6be890daf7b41138064e558bda45238359c4a
danielamezcua/Programming-Practice
/LintCode/interval_minimum_coverage.py
754
3.6875
4
""" Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end """ class Solution: """ @param a: the array a @return: return the minimal points number """ def getAns(self, a): # write your code here def take_...
5dae19f3cbb223ff86b4f2cd6d37980a810409b5
Ruanfc/lista3_python_para_engenharia
/09/main.py
1,109
4.0625
4
#!/usr/bin/env python3 # mensalidade é a prestação # atraso é o atraso em dias def valorPagamento(mensalidade, atraso): if atraso <= 0: return mensalidade else: return 1.03*mensalidade + 0.001*atraso info = [] while(True): e = input("Prestação e atraso separados por espaço: ") if e == ...
8c5b4750a019d71b21bcea88eb403bb150203331
thewchan/python_crash_course
/python_basic/userclass.py
2,343
4.1875
4
class User: """Simulate user info including first and last names.""" def __init__(self, first_name, last_name, age, gender): """Initiate user instance with first/last name, age, and gender""" self.first_name = first_name self.last_name = last_name self.age = age self...
dae81e040d70bbd06261ad6eed9694cc859614ad
YaniraHagstrom/PY-111-Intro_to_Python
/Example.py
228
3.546875
4
def add(x, y): return x + y def multipy(x, y): return x * y def substract(x, y): return x - y def divide(x, y): return x / y def mod(x, y): if(x > y): return x % y else: return y % x
545876341a5bc82abc601e99b210321f9f1fd6c7
raghavddps2/Technical-Interview-Prep-1
/UD_DSA/Course1/Trees/Tree.py
3,188
4.375
4
# this code makes the tree that we'll traverse class Node(object): def __init__(self,value = None): self.value = value self.left = None self.right = None self.is_visited_left = False self.is_visited_right = False def set_value(self,value): self....
0bca363abf2580366e8bac016762dba373efb41d
DroneOmega/Random
/College/Python/Zig Zag KS4 Programs/Exercise1-NumberGame/original/q1-numGame.py
1,333
4.03125
4
import random counter = 0 def guess(): try: num = int(input("\u0332".join("Please enter your guess: "))) val = int(num) if num > 100: print("The number you have entered is too large.") print("Please try again.") guess() elif num < 1: ...
e31b2398dba970c79f21e1fef69d437882bf177a
SherbazHashmi/HackathonServer
/arcpyenv/arcgispro-py3-clone/Lib/site-packages/arcgis/geometry/functions.py
39,682
3.515625
4
""" Functions which take geometric types as parameters and return geometric type results. """ import arcgis.env # https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer. def areas_and_lengths(polygons, length_unit, area_unit, ...
fdd4ae4830014b1b0523eacb288483b6f6dc8c31
MatheusIshiyama/Sudoku-API
/src/services/sudoku/valid_Numbers.py
2,605
4.3125
4
from random import sample def invalid_row_numbers(matrix: list, row: int, column_length: int) -> list: # receives a [matrix] and a reference [row] # return a list of invalid numbers in the row. invalid_numbers = list() for column in range(column_length): # matrix[row][column] != 0 means that ...
fd4fcb75956f7d12200c923eeedf10773830b1a9
adashtoyan/numpy-mnist-classifier
/classifier/nn.py
7,911
3.890625
4
import pickle from typing import List, Tuple import numpy as np from . import activations class NeuralNetwork(): """Deep neural network using batch training. Example:: >>> model = NeuralNetwork([784, 30, 10]) >>> model.train(training_data) >>> model.test(test_data) .. note:: ...
180cda553d9f955a107e239dbdb85dc95410cdcc
WisTiCeJEnT/204111-2021-TA
/Lab 07x: Repetition I (extra)/05 Count Vowel.py
286
3.796875
4
# NOT USING STRING.count() s = input('Enter a string: ') vo = 'aeiou' no_of_vo = 0 d = {v: 0 for v in vo} for c in s: if c in vo: d[c] += 1 no_of_vo += 1 for v in vo: print(f"There are {d[v]} {v}'s.") print(f'There are {len(s)-no_of_vo} non-vowels characters.')
f264de16e07c4e44e3ac3032b38ac44a95f5fcf6
0alan0/Examples
/TaiChi.py
2,771
3.75
4
import turtle r = 400 #半径 a =50 #边距 b = 14 #字体大小 x,y = 0,-r turtle.setup(width=1200,height=1200, startx=500, starty=0) turtle.penup() turtle.goto(x,y) turtle.pendown() turtle.begin_fill() turtle.fillcolor('white') turtle.circle(r,-180) turtle.circle(r/2,-180) turtle.circle(-r/2,-180) turtle.end_fi...
11b35163432609cda937aec7064572508a416e06
algorithm2020/Algorithm_CEK
/06_Stack과Queue/백준/10828_스택.py
1,654
3.84375
4
import sys class Stack: #비어있는 스택 def __init__(self): self.stack=[] self._top=-1 def push(self, val): #val을 stack에 넣는다. self.stack.append(val) self._top+=1 # 맨위에 있는 정수를 출력 def top(self): #스택이 비어있다. if self.empty()==1: ...
a0036df1e7c0d813c43bd087a2226b3c10a97dcc
niwza/PythonSummerfield
/chap01/average1_ans.py
610
3.96875
4
numbers = [] total = 0 lowest = None highest = None while True: num = input("enter a number or Enter to finish: ") if not num: break try: i = int(num) if lowest is None or i < lowest: lowest = i if highest is None or i > highest: highest = i n...
6bc427081575807a867a5e0353969c50d719e211
xiaojinghu/Leetcode
/Leetcode0106_Recursion&Hashmap.py
1,390
3.734375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def build(self, inorder, inStart, inEnd, postorder, postStart, postEnd, indexMap): """ :type inorder: Lis...
4669dcaa51b4239d5ff548cfd4623615715deac7
T0N1R/Maquina-Turing
/maquina/automata.py
3,525
3.546875
4
""" Logica matematica Proyecto Final - Maquina de Turing 20/11/2019 Gustavo de Leon #17085 Antonio Reyes #17273 """ f = open("MT1.txt") cinta_inicial = "" for line in f: cinta_inicial = cinta_inicial + line def separar_zonas(cinta): global contador contador = 0 global separaci...
56d4b1c0acc94a04fb84021e7ef02f469bcfe3cb
marineam/pycde
/pycde/textui.py
823
3.5
4
# """Text User Interface""" import sys class TextUI(object): def choose(self, name, items, fmt=str): if len(items) == 1: print "Found %s: %s" % (name, fmt(items[0])) return items[0] else: print '%ss:' % name for i, item in enumerate(items): ...
6276dd412a56ad4452b1acefce53b0605cdf3ef1
reisthi/SimplePython
/evenorodd.py
425
4.25
4
""" This tests if a number is even or odd""" print("***************") print("EVEN or ODD?") print("***************") def evenoddtest(): number = int(input("Type a number: ")) remainder = number % 2 result = str(number) if remainder == 1: print(result + " is odd.") else: print(res...
3714c6711965c550226509ba4558b4825f480756
raviteja1117/sumanth_ketharaju
/keyword_variable.py
156
3.71875
4
def person(name, **data): print(name) for i,j in data.items(): print(i, j) person("sunil",age=21, city="nellore",mob= "98488671452")
e860bb0f46bc24c9f4b3bcdcd7df0fc228e80349
nikhiilll/Data-Structures-and-Algorithms-Prep
/Arrays/GeeksforGeeks/ArrayPairSum.py
606
4.21875
4
import array """ The array can be sorted at the start if not sorted and then this method can be used. """ def find_pair_sum(arr, sum): n = len(arr) left_ptr = 0 right_ptr = n - 1 while left_ptr < right_ptr: if arr[left_ptr] + arr[right_ptr] > sum: right_ptr -= 1 elif arr[left...
6cdfc0849816ac192410c7bcd3ecf43c2dcadc78
O-Huslin/RSA-Encrytion-and-Database
/Sockets/Starter/PaillierClientSocket.py
5,029
3.9375
4
# Client to implement simplified 'secure' electronic voting algorithm # and send votes to a server # Author: # Last modified: 2020-10-07 # Version: 0.1.1 #!/usr/bin/python3 import socket import random import math import sys class NumTheory: @staticmethod def expMod(b,n,m): """Co...
f01342d67e3b41d818fdc27e9c6399de588bff87
alineat/web-scraping
/33.funcao-compile-character-class.py
1,333
4
4
import re # módulo regular expression # Expressão é compilada em bytecode e executada por um mecanismo de combinação escrito em C # Usada para combinar caracteres, encontrar tags ou dados em uma árvore sintática # Por ex. a expressão "abc" está na string "abcdef" # Exceção: metacaracteres não dão "match" # Lista de M...
87e2503f1b69762e97395d1158495209bb27b1b1
cmrad/Mini-Python-Programs
/madLibsGame.py
8,943
4.5625
5
''' Let’s build an old, popular game: Mad Libs. We’ll start by getting input from the user, just like in a real Mad Libs game, and use the user’s responses in our story. The starting version of this game has nothing to do with lists, but once we build the base game, we’ll modify it to use lists. ''' # MadLib (ve...
250f423e2e829cfb393d748bdd6e372fa9938c65
dharunsri/Python_Journey
/User_Input.py
742
4.25
4
# To get input from user # Method 1 x = int(input("Enter the 1st number ")) # input() gets input from user y = int(input("Enter the 2nd number ")) z = x+y print(z) # Method 2 [passing arguments from cmd] """ import sys a = int(sys.argv[1]) # argv - argument passes from the user. ...
1612856b713552f32defccb865ee87d14b022aeb
21eleven/leetcode-solutions
/python/1305_all_elements_in_two_binary_search_trees/bfs_n_sort.py
1,201
3.9375
4
""" 1305. All Elements in Two Binary Search Trees Medium Given two binary search trees root1 and root2. Return a list containing all the integers from both trees sorted in ascending order. Example 1: Input: root1 = [2,1,4], root2 = [1,0,3] Output: [0,1,1,2,3,4] Example 2: Input: root1 = [0,-10,10], root2 = [5,...
cca18a959fd5280d4fe815eb7fb04bbcdbff59a3
hectorsum/python-exercises
/Sem01/formulario.py
1,679
3.8125
4
import tkinter as tk from tkinter import ttk #from tkinter.ttk import * window = tk.Tk()#creando el formulario window.title("Sistemas Inteligentes")# colocandole un titulo window.geometry('500x200')# dandole dimension al formulario lbl1 = tk.Label(window,text="Ingrese primer valor: ")#creando un etiqueta lbl1....
47ac9eea5e11dd2f5d5e59c088fdbd09605e37ee
BrandonDotson65/LeetCode
/plusOne.py
749
4.03125
4
# You are given a large integer represented as an integer array digits, where # each digits[i] is the ith digit of the integer. The digits are ordered from # most significant to least significant in left-to-right order. The large integer # does not contain any leading 0's. # Increment the large integer by one and r...
d37a20f3c7d7298431deca22b793b2d6ca2b01e4
liweicai990/learnpython
/Code/Basic/Basic07.py
778
4.09375
4
''' 功能:计算一元二次方程的实数根 重点:多分支结构if...elif...else...的用法 作者:薛景 最后修改于:2019/05/25 ''' a,b,c = input("请输入一元二次方程的系数a、b、c,用空格分开:").split() a,b,c = float(a),float(b),float(c) d = b**2 - (4 * a * c) # 两个星号“**”表示幂运算,即“b**2”等价于“b*b” if d<0: print("方程没有实数根") elif d>0: x1 = (-b + d**0.5)/(2 * a) x2 = (-b - d**0.5)/(2...
744f89ef0ea85bc653bc050d6efd1384217fc543
bingx1/leetcode-solutions
/medium/46.py
747
3.71875
4
class Solution: """ Level0: [] level1: [1] [2] [3] level2: [1,2] [1,3] [2,1] [2,3] [3,1] [3,2] level3: [1,2,3] [1,3,2] [2,1,3][2,3,1] [3,1,2][3,2,1] """ def permute(self, nums: List[int]) -> List[List[int]]: ...
034628f2fa35b422caf812e58f66577e5086fbd3
NachikethP/LOOPS
/posint.py
158
3.71875
4
list=eval(input("Input:")) count=0 print("Output:",end=" ") while count<len(list): if list[count]>0: print(list[count],end=" ") count=count+1
17ce688c53d80bbaf1b70204e5401a4f777e899a
BansiddhaBirajdar/python
/assignment21/ass21Q1.py
669
4.1875
4
'''1. Accept N numbers from user and return difference between summation of even elements and summation of odd elements. Input : N : 6 Elements : 85 66 3 80 93 88 Output : 53 (234 - 181)''' def diff(l): even=0 odd=0 for i in range(len(l)): if(l[i]%2==0): even+=l[i] else: ...
575f8109d9c44edc63db3dcb1385acde17aff878
atbba3000/python-learning
/remainder.py
170
4.15625
4
a=int(input("enter the 1st digit")) b=int(input("enter the 2nd digit")) quotient=a//b remainder=a%b print("quotient is:",quotient) print("remainder is:",remainder)
5c5d41f8e78601f80c552a73bc77777fb69e377b
hot-graphs/hot-plots-gtk
/batch.py
2,167
3.609375
4
#!/usr/bin/env python3 import click from data_source import get_temperature_data from data_source import plot_temperature_data @click.command() @click.option("--altitude", default="", help="Select a comma-separated temperature range like \"200,300\"") @click.option("--greenery", default="", help="Select a comma-separ...
d05cfbecab6b0b581be6bca68b49b04e803259ff
keinen-lab/design-pattern-python
/FactoryMethodPattern.py
1,077
3.828125
4
class Pizza: HAM_MUSHROOM_PIZZA_TYPE = 0 DELUXE_PIZZA_TYPE = 1 SEAFOOD_PIZZA_TYPE = 2 def __init__(self, price): self.__price = price def getPrice(self): return self.__price class HamAndMushroomPizza(Pizza): def __init__(self): super().__init__(8.50) class DeluxePiz...
e43bb5a7481a409719f4e631542bea027813ce12
songjy6565/alg-py
/programmers/level4/A.17685.py
1,639
3.546875
4
def solution(words): answer = 0 words = sorted(words) length = len(words) target = 'dummy' index = 0 while True: #print(index, length, answer, words) if length <= 1: if target == words[0][0]: answer += 2 return answer answer...
9e15e5e76d325b2328a8e94b873408ec25e4dce7
gurmeetkhehra/python-practice
/IfConditionPizza.py
1,144
3.859375
4
# pizza_topping = ['Olive', 'Mushroom', 'Tomato', 'Cheese', 'Pineapple'] # if 'Olive' in pizza_topping: # print('Adding Olive') # if 'Mushroom' in pizza_topping: # print('Adding Mushroom') # if 'Tomato' in pizza_topping: # print('Adding Tomato') # if 'Cheese' in pizza_topping: # print('Adding Cheese') #...
f049637b7e58176677963ea36f5b4857bc2a3dcb
zVelto/Python-Basico
/aula22/aula22.py
552
4.03125
4
# texto = 'Python' # # for letra in texto: # print(letra) # for numero in range(20, 10, -2): # print(numero) # # for numero in range(0, 100, 8): # print(numero) # for n in range(100): # if n % 8 == 0: # print(n) # continue - pula para o próximo laço # break - termina o laço texto = 'python' ...
a831bbe132c084e7949875490f7b80e3f19616db
sneharnair/Competitive-Coding-1
/Problem1_missing_number_in_sorted.py
4,183
3.921875
4
# APPROACH:1 BRUTE FORCE SOLUTION # Time Complexity : O(n^2) - n is the length of nums # Space Complexity : O(n) - n is the size of set same as the length of nums # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : None # Your code here along with comments explaining your app...
79600d48b98302005c454310b459f38748fe019a
Edyta2801/Python-kurs-infoshareacademy
/code/Day_9/samochod.py
812
3.578125
4
class Samochod(object): '''Definiuje atrybuty i metody samochodu''' def __init__(self, marka, kolor): '''Konstruktor, tworzy nowe instancje''' self.producent = marka self.kolor = kolor self.czy_jedzie = None self.silnik = None def zatrab(self, intensywnosc): ...
abe59f6662114fb011d1a351502b904aa72d443a
cravo123/LeetCode
/Algorithms/0034 Find First and Last Position of Element in Sorted Array.py
1,208
3.703125
4
import bisect # Solution 1, implement bisect functions class Solution: def lower_bound(self, nums, target): i, j = 0, len(nums) - 1 while i < j: m = (i + j) // 2 if nums[m] < target: i = m + 1 else: j = m return i ...
23040b54237942ab7555e1ecb9695633b608d08b
rodrigobn/Python
/Lista de exercicio 2 (print, input, tipos primitivos)/ex18.py
289
3.65625
4
#18. Tendo como dados de entrada a altura de uma pessoa, construa um algoritmo # que calcule seu peso ideal, usando a seguinte fórmula: (72.7*altura) – 58. altura = float(input("Altura em m = ")) pesoIdeal = (72.7 * altura) - 58 print("O seu peso ideal é: {:.2f}".format(pesoIdeal))
f02907f738abb86f7e9e72d522180aaaf4e25ff6
cloudsecuritylabs/learningpython3
/ch1/aksforage1.py
371
4.1875
4
print('How old are you?', end=' ') age = input() print('How tall are you?', end=' ') height = input() print("what is your weight?", end=' ') weight = input() # Print using format print('You are {} years old, {} inches tall and you weight {} lbs'.format(age, height, weight)) # Print using f print(f'You are {age} years...
ae4f2935775b02d388ab3840d84511d777ffed36
WeikangChen/algorithm
/lintcode/180_binary-representation/binary-representation.py
1,438
3.640625
4
# coding:utf-8 ''' @Copyright:LintCode @Author: chenweikang @Problem: http://www.lintcode.com/problem/binary-representation @Language: Python @Datetime: 16-07-09 14:04 ''' class Solution: #@param n: Given a decimal number that is passed in as a string #@return: A string def binaryRepresentation(self,...
80c25ea7a717874557d0d3365588b167a8e25fa3
AnchanaK24/python
/Day11.py
575
3.96875
4
#ex1 l1 = [1, 2, 3] l2 = [4, 5, 6] l = list(zip(l1, l2)) print(l) #ex2 from itertools import zip_longest numbers=[1,2,3,4,5,6,7,8] letters=['a','b','c','d','e','f','g','h'] longest=range(1,9) zipped=zip_longest(numbers,letters,longest,fillvalue='?') l=list (zipped) print(l) #ex3 a=[6,8,5,7,2,3,4,1] a.sort() print(a) ...
d98c9cc6acac6fb41d1b086a5b18943cab0e4b88
NITIN-ME/Python-Algorithms
/arraysum.py
481
3.59375
4
def summer(arr, start, end): if(start == end): return arr[start] elif(start >= end): return 0 else: mid = (start + end)//2 return summer(arr, start, mid) + summer(arr, mid + 1, end) def basic(arr): sum = 0 for i in arr: sum += i return sum def tailrec(arr, n): if(n < 0): return 0 else: return ar...
70f2450b01140a2f7273fe990f146b8d6a766a21
johndrew/AirplaneBoardingSimulator
/models/passenger.py
3,859
3.5
4
import uuid from random import uniform from constants import time_to_pass_one_row as walking_speeds, \ time_to_load_carry_on as loading_speeds, \ time_to_install_in_seat as seating_speeds class Passenger(): def __init__(self, env, seat, airplane): """ Represents a passenger boarding the a...
dde62d382e4cb1ba9ab4176ecadeab31e9b8063c
shahzorHossain/Diversity-Search-Engine
/q3.py
681
3.53125
4
def my_map(func,iterable): if func is None: return list(iterable) else: return [func(i) for i in iterable] def my_reduce(func, iterable, start=None): iterator = iter(iterable) if start is None: try: start = iterator.next() except StopIteration: raise TypeError("my_reduce() of empty sequence with no ...
eb02c0abb17f0cea900344f8e81af40052414c64
vishwanathsavai/Python
/brackets.py
1,189
3.78125
4
from itertools import permutations def check(unique): str1=[] final=[] for i in unique: flag = 0 str1.extend([char for char in i]) print(str1) for j in range(0,len(str1)): if (str1[j]=='('): flag+=1 else: flag-=1 ...
c22b6a46f7451be28b5b739ef36642fb9a5ee3ec
SenthilKumar009/100DaysOfCode-DataScience
/Python/Pattern/rightTraingle.py
324
4
4
line = int(input("Enter the total line to print:")) #for x in range(1,line+1): # print('* '*(x)) ''' for i in range(0, line+1): for j in range(0, line-i+1): print(' '*(j), end='') print('*'*(i)) ''' for i in range(0,line+1): for j in range(0, line-i): print(' ', end='') print('*'*...
e8caeb6eb6abea43082f05b8744fe7284ba7f561
lxconfig/UbuntuCode_bak
/algorithm/牛客网/58-对称的二叉树.py
2,627
3.703125
4
""" 请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。 """ class TreeLinkNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSymmetrical(self, pRoot): """求出原二叉树的前序遍历,及镜像二叉树的前序遍历 如果相等则说明是对称二叉树 ...
ff092c1a6e3f7d5bd60497653c340729c2d8460b
nitin2149kumar/INFYTQ-Modules
/Data Structure/Day-4/Assignment-18.py
721
3.984375
4
#DSA-Assgn-18 def find_unknown_words(text,vocabulary): #Remove pass and write your logic here l=[] status=0 text_list=text.split(" ") for each_text in text_list: if each_text not in vocabulary: if "." in each_text: each_text=each_text.replace(".","") ...
2964cdc77617298fe7142df2827435c716e9f891
Safat11/Admin
/25. Guessing Game.py
619
4.15625
4
import random guessNumber = int(input("Enter your guess between 1 to 5 : ")) randomNumber = random.randint(1,5) if guessNumber == randomNumber : print("You have won") else : print("you have lost") print("Random number was : ",randomNumber) ### # To be continue : for X in range(n,n) : from random impo...
6d9916e8566cee1733aaa5e10c14d95778f60d7b
dudnicp/compilateur_deca
/src/test/script/stack_overflow_generator.py
444
3.609375
4
#!usr/bin/python3 def main(): with open("test_stack_overflow.deca", 'w') as test_file: test_file.write("// @result Error: Stack overflow\n") test_file.write("{\n") for char1 in range(97, 123): for char2 in range(97, 123): for char3 in range(97, 123): ...
a59a44609827c0b29c219e7911b6ba8ef1b3fecf
amberrevans/pythonclass
/chapter 4 and 5 programs/temp_celcius.py
792
4.3125
4
#amber evans #9/15/20 #program 4-2 #This program assists a technician in the process #of checking a substances temperature. #named constant to represent the maximum temperature Max_temp = 102.5 #get the substances temperature temperature= float(input('Enter the substances Celsius temperature: ')) #as long as necessa...
4f2d4502ccf135f30f311c5fd24f0e9029031763
ManuelLoraRoman/Apuntes-1-ASIR
/LM/PYTHON/Ejercicios alternativas/Ejercicio 14.py
1,529
3.859375
4
#La asociación de vinicultores tiene como política fijar un precio inicial al kilo de uva, la cual se clasifica en tipos A y B, y además en tamaños 1 y 2. #Cuando se realiza la venta del producto, ésta es de un solo tipo y tamaño, #se requiere determinar cuánto recibirá un productor por la uva que entrega en un emb...
462d4299d7d74c4ef910666f324a1d19c5383d0a
gurkaran97/Offline-Dictionary-attack-tool
/run.py
501
3.9375
4
import hashlib hashed_word = input('Enter the hashed word: ') pass_file = input('Enter the password file: ') try: passfile = open(pass_file, "r") except: print("No file found, please check again") for word in passfile: enc_word = word.encode() passfile_hashes = hashlib.md5(enc_word.strip()).hex...
4ff8f497ab114e2ba35e6800f0337dec3c434c4d
ProgFuncionalReactivaoct19-feb20/clase03-vysery98
/ejercicio1.py
376
3.890625
4
""" @vysery98 Dado un conjunto de palabras, filtrar todas aquellas que sean palíndromas Palabras: "oro", "pais", "ojo", "oso", "radar", "sol", "seres" """ conjPalabras = ["oro", "pais", "ojo", "oso", "radar", "sol", "seres"] # reversed similar a map, poner: "".join palindromas = filter(lambda x: x == "".join(...
78f8f95ca65d6ea231e88e1fdb822f169dba31bc
billkabb/learn_python
/MIT/L11_problem_4.py
1,524
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 5 17:26:13 2016 @author: billkabb """ class Coordinate(object): def __init__(self,x,y): self.x = x self.y = y def getX(self): # Getter method for a Coordinate object's x coordinate. # Getter methods are better practice than just a...
55efa6a24697a6710f6de7baf605a382ac2316f3
bupthl/Python
/Python从菜鸟到高手/chapter7/demo7.11.py
1,146
4.3125
4
''' --------《Python从菜鸟到高手》源代码------------ 欧瑞科技版权所有 作者:李宁 如有任何技术问题,请加QQ技术讨论群:264268059 或关注“极客起源”订阅号或“欧瑞科技”服务号或扫码关注订阅号和服务号,二维码在源代码根目录 如果QQ群已满,请访问https://geekori.com,在右侧查看最新的QQ群,同时可以扫码关注公众号 “欧瑞学院”是欧瑞科技旗下在线IT教育学院,包含大量IT前沿视频课程, 请访问http://geekori.com/edu或关注前面提到的订阅号和服务号,进入移动版的欧瑞学院 “极客题库”是欧瑞科技旗下在线题库,请扫描源代码根目录中的小程序码安装“极客...
f45b13cd1cdaf8bed6458c8bf9d9d27449692bf3
huseyinyilmaz/datastructures
/python/mergesort.py
2,609
3.90625
4
""" Destructive merge sort algorithm. Implements top down scheme """ import unittest from hypothesis import given from hypothesis import settings # from hypothesis import Verbosity from hypothesis.strategies import integers from hypothesis.strategies import lists from hypothesis.strategies import text def merge(xs, y...
c88c26c524764cc71d73b0f16347905d064ef266
73fc/912_project
/5 操作系统/实验/ucore/ucore_lab/related_info/lab7/semaphore_condition/thr-ex7.py
1,828
3.84375
4
#coding=utf-8 import threading import random import time class SemaphoreThread(threading.Thread): """classusing semaphore""" availableTables=['A','B','C','D','E'] def __init__(self,threadName,semaphore): """initialize thread""" threading.Thread.__init__(s...
38e670253d7e28f9dd96ab285c36cc45df1f80b2
rudyekoprasetya/belajar-python
/3 percabangan/Main.py
251
3.71875
4
nilai = input('Masukan nilai ') # if float(a) >= 75: # print('Selamat Anda Lulus') # else: # print('Maaf Anda Belum Lulus') if float(nilai) > 85: print('Nilai Anda A') elif float(nilai) >= 75: print('Nilai Anda B') else: print('Nilai Anda C')
00644387e1193de60582ab41c1d9106c82e0a166
mingsalt/START_UP_PYTHON
/6st/hw3.py
227
3.78125
4
#hw3 숫자의 약수 구하기 & 숫자 분류하기 num = int(input("숫자를 입력하세요 : ")) list_1=[] for i in range(1,num): if num%i==0 : list_1.append(i) print(f"{num}의 약수 :{list_1[0:]}")