blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
092a4a7fc7f26b4218a69ada083dd0fed998c6b6
kogansheina/euler
/p51_100/p55.py
875
3.84375
4
#!/usr/bin/env python """" Lychrel numbers """ def is_palindromic(n): strn = str(n) strr = strn[::-1] if strn == strr: return True return False def reverse(n): strn = str(n) strr = strn[::-1] return int(strr) def main(): n = 1 N = 10000 while n <= 10000: ...
084353fdb601f58d27fcf7cf9adcbb22df2325f2
virus-begin/jobs_entry
/jobs-entry/start.py
2,013
3.5
4
import datetime from db_functions import * def read_data(): print("read_data") res = read_entries() def update_data(): print("update_data") result = read_entries() update_entry = int(input("Enter ID for updating row. ")) # print(result, update_entry) quote = """1. Company_name" 2. "Fol...
8339b3d276ccf0eaccfdad753dd57f02437a4f6f
tobeeeelite/success
/readtxt.py
771
3.609375
4
####简单拼接图片 ##cv读取的图片是(h,w,c) ##实际图片是(w,h,c) import cv2 as cv import numpy as np img1=cv.imread('gs.png',0)#公式 img2=cv.imread('hello1.png',0)#文本 print(img1.shape) h,w=img1.shape h_n,w_s=img2.shape print(w_s) w_n=w if w / h >= w_n / h_n: img_new = cv.resize(img1, (w_n, int(w_n * h / w))) else: img_...
ec8f4a9894f1c27a61a972d219bcef5ea80bbf1c
haomingchan0811/Leetcode
/606. Construct String from Binary Tree.py
1,218
3.78125
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): # # dfs: O(N) time & space # def tree2str(self, t): # """ # :type t: TreeNode # :rtype: ...
19522b5075a2311d7468acfeb8fe98295ad2b0d4
trixtun/Competetive-programming-interview
/Array Rotation.py
621
4.25
4
#Function to left rotate arr[] of size n by d def leftRotate(arr, d, n): for i in range(d): leftRotatebyOne(arr, n) #Function to left Rotate arr[] of size n by 1 def leftRotatebyOne(arr, n): temp = arr[0] for i in range(n-1): arr[i] = arr[i+1] arr[n-1] = temp # u...
df2e3f649cbe69163ca754ddaea5aad8c22fb2b8
suti211/python
/ideabank2/ideabank.py
3,935
3.96875
4
# NOTE: # this code is volatile, and inefficient, because it reads in the whole file # in the memory, then after modifications it's rewriting it. # importing sys lib, to handle cli arguments, and os to reach some # os level file managing functions import sys import os #creating some references ideas = [] highestID ...
32bd867ca5906a64ee286bbfe65773e35eba0460
WindTalker22/Data-Structures
/binary_search_tree/binary_search_tree.py
4,697
4.125
4
from collections import deque """ Binary search trees are a data structure that enforce an ordering over the data they store. That ordering in turn makes it a lot more efficient at searching for a particular piece of data in the tree. This part of the project comprises two days: 1. Implement the methods `insert`, `c...
28774b3e783cf563ebb51bbe810957e36b80ad5b
ElectrifyPowr/mnist_neural_network
/column_count.py
653
3.953125
4
#!/usr/local/bin/python3 # Copyright 2019-03-01 Powr # # All rights reserved # # Author: Powr # #================================================================== """ To check whether you have the correct number of columns in a dataset in a specific row this script takes 2 arguments: 1. the file_name ...
cae86ea944630074e0c620184ae087312430ad59
JiHwonChoi/AlgorithmStudy_QH
/0725_지훤/0725elecBus.py
1,045
3.5625
4
from typing import List def elecbus(power: int,fin: int ,howmany: int,charger :List[int]) -> int : count=0; while(fin>0): start=fin-power #출발점을 찾았을 경우 if(start<=0): break #충전소있나 찾아보기 for i in range(start,fin+1): #충전소 발견 ...
6e0e7cb932d041e3ecb23e4f14845ff8cf1de9cf
iamrishap/PythonBits
/InterviewBits/dp/length-of-longest-subsequence.py
1,658
3.796875
4
""" Given an array of integers, A of length N, find length of longest subsequence which is first increasing then decreasing. Input Format: The first and the only argument contains an integer array, A. Output Format: Return an integer representing the answer as described in the problem statement. Constraints: 1 <= N <= ...
9d607722633a4c9b887e7475dac88ea3a6030b45
suvimanikandan/INTERMEDIATE_PYTHON
/LISTS_COPY_ITEMS.PY
639
4.5
4
#Copy a list #Be careful when copying references. list_org = ["banana", "cherry", "apple"] # this just copies the reference to the list, so be careful list_copy = list_org # now modifying the copy also affects the original list_copy.append(True) print(list_copy) print(list_org) # use copy(), or list(x)...
ca1f7820a321aa8a8d229971068440fa2746a871
leclm/CeV-Python
/PythonDesafios/desafio62.py
841
4.03125
4
''' Melhore o desafio 61, perguntando para o usuário se ele quer mostrar mais alguns termos. O programa encerra quando ele disser que quer mostrar 0 termos. ''' a1 = int(input('Digite o primeiro termo: ')) r = int(input('Digite a razão: ')) c = 1 ac = 0 x = 11 termos = [] ax = 0 novostermos = [] while c < 11:...
d5699761d18b5646814e75e83d493f52fa8c842f
Rishabh-0412/Local_Peak
/Prime_Factor_Test.py
628
3.984375
4
import unittest def factors(number): _factors = [] if number == 2 or number == 3: _factors.append(number) elif number == 4: _factors = [2, 2] return _factors class PrimeFactorsTest(unittest.TestCase): def test_one_has_no_factors(self): self.assertEqual([], factors(1)) ...
5add2dada07e63d4e48f537fd9b98b126f835a62
AdamZhouSE/pythonHomework
/Code/CodeRecords/2738/47937/274163.py
915
3.625
4
from typing import List class Solution: def maximalRectangle(self, matrix: List[List[str]]) -> int: maxarea = 0 dp = [[0] * len(matrix[0]) for _ in range(len(matrix))] for i in range(len(matrix)): for j in range(len(matrix[0])): if matrix[i][j] == '0': continue ...
90fbcf65dceec363f1c00f4593122f53b7899a30
MrBitBucket/reportlab-mirror
/docs/userguide/graph_shapes.py
12,403
3.65625
4
#Copyright ReportLab Europe Ltd. 2000-2017 #see license.txt for license details __version__='3.3.0' from tools.docco.rl_doc_utils import * from reportlab.graphics.shapes import * heading2("Shapes") disc(""" This section describes the concept of shapes and their importance as building blocks for all output generated b...
ed2303a505fefe9d25e301d1dbb33cefd73ea5da
ThallesTorres/Curso_Em_Video_Python
/Curso_Em_Video_Python/ex077.py
830
4.125
4
# Ex: 077- Crie um programa que tenha uma tupla com várias palavras (não usar # acentos). Despois disso, você deve mostrar, para cada palavra, quais são as # suas vogais. print(''' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --Seja bem-vindo! --Exercício 077 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ''') palavras = ('a...
7e5b3c4e143e49b77e077128975a477e907ff290
umahato/pythonDemos
/firstPython/hello.py
917
3.921875
4
''' Y = 20 X = 10 print (type(X)) num = 10>9 print(type(num)) name = "Umesh" print(len(name)) print(name[2]) print(name[2:6]) print(name.upper()) print(name.lower()) mylist = [10,20,30,"Umesh","shilu"] print(mylist) mylist.append(10) print(mylist) mylist.insert(5,100) # insert a value in specific position in a lis...
40ada81bc6526a927a5a9f6f7f71a671c0a15b60
kurtw29/algorithmPractice
/largestNumDiv3.py
3,033
3.96875
4
def answer(l): # your code here if len(l) == 0: return 0 #create largest # from #'s in l #case1 #sum mod 3 == 0 #otherwise: #find a number in the array == reminder (1 or 2) or (4 or 5) or (7 or 8) #find sum of number in array (skip 0,3,6,9)== reminder ...
b2142432c3c5cdf42b157dfa686501be9a0f2127
mshekhar/random-algs
/general/trapping-rain-water-ii.py
1,949
3.53125
4
import heapq class HeapObject(object): def __init__(self, x, y, height): self.x = x self.y = y self.height = height def __cmp__(self, other): return cmp(self.height, other.height) class Solution(object): def trapRainWater(self, heightMap): """ :type heigh...
4a4372c265e10c38a61311474cfdaee38a99067a
salasberryfin/YourSafeSun-2016
/Lab2/Exercise1.py
496
3.578125
4
def todo_manager(): while True: print "1. insert new task\n2. remove a task\n3. show all existing tasks\n4. close the program\n" option = int(raw_input("Your choice: ")) if option == 1: # insert a new task print "Good" elif option == 2: # remove a task print "Do something" elif option == 3: ...
6ad8e34e2a50404fdc3eb6f5970c7ce22f012045
loalberto/Udacity-s-Data-Structures-and-Algorithms-
/Union_and_intersection.py
5,727
3.921875
4
class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class LinkedList: def __init__(self): self.head = None def __str__(self): cur_head = self.head out_string = "" while cur_head:...
1174cdc4c29b2ab2927debe0d9830d10f043fa7c
WinrichSy/LeetCode_Solutions
/Python/GroupAnagrams.py
505
3.71875
4
#Group Anagrams #https://leetcode.com/problems/group-anagrams/ class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: dictionary = {} for i in strs: # print(i) sorted_str = ''.join(sorted(i)) if sorted_str not in dictionary.keys(): ...
514663ac894454ae11634b260109ff7b256020bf
mikaelbaymani/nn
/plugins/fetch.py
1,963
3.703125
4
import sys def fetch( filename ): # Save a reference to the original standard output original_stdout = sys.stdout with open( filename, 'w' ) as a_file: # Change the standard output to the file we created. sys.stdout = a_file print("key,content") print("01,\"Three generation...
6563cc83d9810e2da917cde4ce9606fdcc94c9bc
successgande1/python-inventory-auto
/create-workbook.py
427
3.625
4
#import openpyxl and methods from openpyxl import Workbook #Create new workbook my_excel_file = Workbook() #Create New Worksheet my_excel_sheet = my_excel_file.create_sheet("Inventories") #Create Column Headings for the Worksheet my_excel_sheet["A1"] = "Product No." my_excel_sheet["B1"] = "Inventory" my_excel_shee...
4fe5697ccffcd15f848165f4ac1112d9ce0a43fe
nt27web/statistical-calculator
/Calculator/Division.py
563
3.90625
4
def division(a, b): result = 0 try: if (isinstance(a, int) and isinstance(b, int)) or (isinstance(a, float) and isinstance(b, int)) or ( isinstance(a, int) and isinstance(b, float)): result = round(float(b) / float(a), 9) elif isinstance(a, float) and isinstance(b, fl...
a5c89b9e539e4f550e0725a5e83c44bc03dee6a8
bowhua21/AdvancedCS-code
/Minesweeper.py
4,753
3.96875
4
# creates board def create_board(width, height): board = [] for i in range(height): board.append([]) for x in range(width): board[i].append(None) return board # buries mines on the board import random def bury_mines(board, n): x = 0 while x != n: random1 = ran...
92c7f7a8ef3b95ab337ab4f258ba7fca36bdfb20
rmele/net_tools
/net_tools/lib/mem_dict.py
3,884
3.546875
4
class MemDict: def __init__(self): pass def new(self, num_buckets=256): """Initializes a Map with the given number of buckets.""" aMap = [] for i in range(0, num_buckets): aMap.append([]) return aMap def hash_key(self, aMap, key): """Given a key...
50d72766d203b8a707a3e6553653a988dac5f973
wernicka/learn_python
/original_code/jc_tutorial_challenges/2_query_generator.py
887
4.125
4
# Joe Costlow Tutorial Challenges # QUERY GENERATOR - EASY # Write a function called query_generator(). The function expects to be passed # a list of field names. It then inserts them into the following query, and # returns the string value of the complete query. # query = "Select [fieldnames] from database where ye...
d7aaf5d234e01410ab65f08ae3622166ee286552
codersalman/Technocrats-HacktoberFest
/Python/Email_Sender/Hex2RGB_UI.py
1,652
4.21875
4
''' GUI Program to Convert Hexadecimal code to RGB format Accepted inputs 6 length • # _ _ _ _ _ _ • _ _ _ _ _ _ 3 length • # _ _ _ • _ _ _ For example: #ff22ee = ff22ee = #f2e = f2e ''' import tkinter as tk import tkinter.font as font # color dictionary and main executable function def rgb(): h = { '0...
6f110652603da6868be1c84302dcc9fed9c16c03
sagarmundkar/Python_Programs
/LeapYear.py
203
4.375
4
# To find year is leap year or not. year = int(input("Enter the year:")) if year % 400 == 0 and year % 100 != 0 or year % 4 == 0: print("Year is Leap year!") else: print("Year is not leap year")
f9f92316c7b32c224a6cc0f6af1ecb0eaeb7306b
hvaltchev/UCSC
/python1/hw4/HristoValtchev_Homework4_BONUS.py
1,433
3.953125
4
#!/usr/bin/env python3 #-----------------------------------------------------------------------------------------------# # Hristo Valtchev # Homework #4 BONUS # 3/20/2020 #-----------------------------------------------------------------------------------------------# import random QUARTER_VALUE = .25 DIME_VALUE =...
53412aa49074321e1d45109a912e96a258c1918b
zoecahill1/pands-problem-set
/second.py
771
3.890625
4
# Zoe Cahill - Question 9 - Solution # Imports a function from PCInput to handle user input and errors from PCInput import fileCheck def second(): # file 1 will call fileCheck() and take on the result after it has been verifed as a correct file path file1 = fileCheck("Enter file path: ") # readlines() wil...
575273d525d665c0997138bd0b9fb30d068d4ded
datachomper/pythonchallenge.com
/11/5808.py
389
3.546875
4
import Image img = Image.open("cave.jpg") odd = Image.new("RGBA", (640,480), "#000") even = Image.new("RGBA", (640,480), "#000") xx = yy = 0 for y in range(0, img.size[1]): for x in range(0, img.size[0]): p = img.getpixel((x,y)) if (x+y) % 2 == 0: # Even even.putpixel((xx,yy),p) else: # Odd odd.putpixel(...
998e0c9aa0c1eed6591f40f4497c7b5bcd8163aa
yihonglei/road-of-arch
/thinking-in-python/python/base/17.输入输出.py
779
4.15625
4
""" Python两种输出值的方式: 表达式语句和 print() 函数。 第三种方式是使用文件对象的 write() 方法,标准输出文件可以用 sys.stdout 引用。 如果你希望输出的形式更加多样,可以使用 str.format() 函数来格式化输出值。 如果你希望将输出的值转成字符串,可以使用 repr() 或 str() 函数来实现。 str(): 函数返回一个用户易读的表达形式。 repr(): 产生一个解释器易读的表达形式。 """ # 输出操作 print(123) print(456) # 输入操作 while True: password = input("请输入密码:") if...
5a48ba3db2ff820e8a9bea766ab2b17cffbc5ada
ShaunaB93/CollegeAssignments
/collatz.py
532
4.1875
4
# Shauna Byrne 05.02.18 # Collatz Assessment n = int(input("Please enter an integer: ")) #Requests the user to input a value to test while (n > 0): #loops this code while the value inputted is greater than 0 print (n) if (n == 1): break #Breaks loop if the integer is equal to 1 elif (n % 2 == 0)...
29dc9006dda87d573d4cbaefe0f6fa84f371ad86
stefanocereda/DigitalTechnology
/ese2/code/factorial.py
265
4.125
4
number = int(input("Give me a number: ")) result = 1 for factor in range(1, number+1): result = result * factor print("{}! = {}".format(number, result)) factor = 1 result = 1 while factor <= number: result = result * factor factor = factor + 1
7e3329ac6f9030e74d22300aa73746cf9e7685a5
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/tuple2.py
110
3.6875
4
arr=(10,20,"adi",30.3) print(type(arr)) print(arr) print(arr[2]) for i in range(len(arr)): print(arr[i])
2887a2d99be7377e52c7c0a9df88dc64492beaa8
sebvstianrodrigo/CYPSebastianVL
/libro/problemas_resueltos/capitulo2/problema2_7.py
425
4.03125
4
A = int(input("Introduce un numero entero: ")) B = int(input("Introduce otro numero entero: ")) C = int(input("Introduce otro numero entero: ")) if A < B: if B < C: print(f"Los numeros {A}, {B} y {C} estan en orden creciente") else: print(f"Los numeros {A}, {B} y {C} no estan en orden creciente"...
29548c85af70a3c56952542da2d7d1130416ef64
pu-bioinformatics/python-exercises-Fnyasimi
/Scripts/exercise05_loops.py
854
4.125
4
#! /home/user/anaconda2/envs/bioinf/bin/python #Q1: Create a while loop that starts with x = 0 and increments x until x is equal to 5. Each iteration should print to the console. #Using a for loop x = 0 print(x) for i in range (100): #CK: Using a range of 100 is wasteful -1 if i<=4: i+=1 print(i) p...
40080c8c1139054a4bc3a449c64eed1377ca01e6
florating/hb-lab-0908-markov
/markov.py
4,995
4.1875
4
"""Generate Markov text from text files.""" from random import choice def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. LINK: https://docs.python.org/3/tutori...
e65dbafd82f06c67945cfe2d810ca0a2072cb1b8
chenzhiyuan0713/Leetcode
/Easy/Q7.py
2,025
3.90625
4
''' 给你一个数组candies和一个整数extraCandies,其中candies[i]代表第 i 个孩子拥有的糖果数目。 对每一个孩子,检查是否存在一种方案,将额外的extraCandies个糖果分配给孩子们之后,此孩子有 最多的糖果。注意,允许有多个孩子同时拥有 最多的糖果数目。 示例 1: 输入:candies = [2,3,5,1,3], extraCandies = 3 输出:[true,true,true,false,true] 解释: 孩子 1 有 2 个糖果,如果他得到所有额外的糖果(3个),那么他总共有 5 个糖果,他将成为拥有最多糖果的孩子。 孩子 2 有 3 个糖果,如果他得到至少 2 个额外...
10094c717df49c6faeeafed4a04c34766da8d630
bbhunter/normal.py
/normal.py
4,998
3.796875
4
#!/usr/bin/env python3 import unicodedata as ucd import sys import argparse import re from urllib.parse import quote parser = argparse.ArgumentParser(description = "Find unicode codepoints to use in normalization attacks.") parser.add_argument('-s', '--string', default='', help="""Use this to check if any normalized ...
ff015f3ea57661249e54e7c2b58d495b8abe9306
jcarball/python-programs
/examen.py
437
3.84375
4
i=2 while i >= 0: print("*") i-=2 for n in range(-1, 1): print("%") z=10 y=0 x=z > y or z==y lst=[3,1, -1] lst[-1] = lst[-2] print(lst) vals = [0,1,2] vals[0], vals[1] = vals[1], vals[2] print(vals) nums=[] vals = nums vals.append(1) print(nums) print(vals) nums=[] vals = nums[:] vals.append(1) print(nu...
6eb0d4b379b20303d7d6920dfb3da59ded1f1e3e
shallgrimson/Coursera-Data-Structures-and-Algorithms-Specialization
/Algorithms on Graphs/Week 2/p2_course_order.py
1,082
3.828125
4
''' Problem 3 - Determine an order of courses Use topological ordering of a directed acyclic graph(DAG) ''' import sys #perform depth first search def dfs(adj, used, order, x): used[x] = 1 for neighbour in adj[x]: if used[neighbour] == 0: order, used = dfs(adj, used, order, neighbour) ...
f2e93766e91a4e043fc1082a6a13cd3243b25a80
grzesiekmalek/test
/sample.py
192
4.03125
4
print('hello world!') countries = ['poland', 'germany' , 'US'] for country in countries: print('hello ' + country + '!!!') print('helloo motherfuckers, heueuehueheheeuhueueheuhuheuuh')
31c72a453ab392e00b4cc2a7ad0eb0cb6c179ddf
mcampo2/python-exercises
/chapter_02/exercise_14.py
866
4.375
4
#!/usr/bin/env python3 # (Geometry: area of a triangle) Write a program that prompts the user to enter the # three points (x1, y1), (x2, y2), and (x3, y3) of a triangle and displays its area. # The formula for computing the area of a triangle is: # s = (side1 + side2 + side3) / 2 # area = sqrt(s(s - side1)(s - si...
99e3b8271f3045d64f6b7560e5cb59fa9e8a0402
fearlessfreap24/codingbatsolutions
/Warmup-1/monkey_trouble.py
476
3.75
4
def monkey_trouble(a_smile, b_smile): return (a_smile and b_smile) or (not a_smile and not b_smile) # return true if a and b or not a and not b if __name__ == "__main__": if monkey_trouble(True, True): # True print("true") else: print("false") if monkey_trouble(False, False): # Tru...
03f6efb568e33456e630a711030fae40aa4d57bb
doganmehmet/python
/Learn/LPHW/ex36.py
5,258
4.03125
4
# Designing and Debugging from sys import exit import random print("......................") print("Welcome to Casino Royal...") print("Money talks!") print("......................") print("November 13, 2018,", end = ' ') print("North Cyprus Turkish Republic") print("""You have 52 bucks in your pocket and standin...
262fc691ff9c5b00324849a296bc408f62200389
aryanz-co-in/python-indentation-datatypes-tamil
/data_types/sequence_type/list_type.py
223
3.75
4
# list, tuple, range Sequence Types # List names = ["Ram", "Akbar", "Antony"] # List will allow us to change item names[0] = "Lakshmi" print(names) door_no = [201, 202, 203] # 0 1 2 print(door_no[2])
125307e1f24d0eafc0744870874d2a5973fa38b4
polaum/practice_python
/string_lists.py
310
3.828125
4
def is_polindrom(_str): _str = _str.lower().replace(" ", "") d = 1 for ii in list(range(int(len(_str) / 2))): if _str[ii] == _str[ii - d]: d += 2 continue return False return True str_to_check = input("Your string: ") print(is_polindrom(str_to_check))
f518430d20c8b4acd5f0783b8fcbb6971a8445b3
Bokuto14/mycaptaincodes
/school.py
1,435
4.03125
4
import csv def write_into_csv(info_list): with open('student_info.csv', 'a', newline='') as csv_file: writer=csv.writer(csv_file) if csv_file.tell()==0: writer.writerow(["name", "age" ,"contact number", "E-Mil ID"]) writer.writerow(info_list) ...
bd3c692bc8ebfd21e165916e4ae6f2c12d9bbf1e
jmabf/uri-python
/1116.py
262
3.609375
4
n = int(input()) lista = [ ] i = 0 while i<n: x, y = [int(x) for x in input().split()] if y == 0: lista.append('divisao impossivel') else: divisao = x/y lista.append(divisao) i+=1 for x in lista: print(x)
7a4e7cda7a6816682fc205ea0eb25e7111710b70
arittrosaha/CS_and_Algorithms
/epi_study/14_binary_search_trees/4.py
1,251
4.15625
4
# Compute the LCA in a BST # Prompt: # A program that takes a BST head and two nodes # returns the LCA of the two nodes # LCA for just binary trees are done with postorder traversal which O(n) time complexity # PDF - 218 ; Book - 217 # Time: O(h), where h is the height of the tree. This is because we descend one le...
56860597ed4fccebfec06f46ad2072211f3069ec
RKHamilton95/Python3DungeonCrawler
/userInput.py
2,459
3.953125
4
def userMovementInput(): #Returns Movement Input movementInput = input("Enter UP,DOWN,LEFT or RIGHT: ") movementInput = movementInput.upper() print(movementInput) while movementInput != "UP" and movementInput != "DOWN" and movementInput != "LEFT" and movementInput != "RIGHT": movementInput = inp...
13ec3fdeb4b8942afb4193dd43468bdcda7a43ac
AlvisonHunterArnuero/EinstiegPythonProgrammierung-
/DNA2RNA/dna_to_rna_fn.py
930
3.765625
4
from typing import Optional def dna_to_rna(dna): print(dna.replace("T","U")) age = 12 def saludarAguacate(argName: Optional[str] = None) -> str or None: while True: try: # Crear una referencia a la variable global global age age = int(input("Escriba Edad: ")) ...
5ce2b80a88f3f73b882821b70536d6540680278a
will8211/my_euler_solutions
/euler_41.py
923
4.09375
4
#!/usr/bin/env python3 ''' Pandigital prime Problem 41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? ''' from math import sqrt from iter...
7d390d9eecb8e3f2d7f5059a7ae6bf2860bcd399
jerryjsebastian/leetcode
/1480_RunningSum1DArray/RunningSum1DArray.py
128
3.546875
4
def runningSum(nums): sums = [] summe = 0 for i in nums: summe+=i sums.append(summe) return sums
402825971b07ff86238cbefe03c77b1c7f580f4b
Danielral/numericalAstrophysics
/maximizeLikelihood.py
5,207
3.921875
4
###sort def pivotSort(a,first,last): #sorting first,last,and middle and choosing the middle as the pivot middle = int((first+last+1)/2) pivotNumber = middle if a[first] > a[last]: a[first], a[last] = a[last], a[first] if a[first] > a[middle]: a[first], a[middle] = a[middle], a[first] if a[middle] > ...
50b9cd86e41a83746f2a70263b10335972f81cf4
deek11/practice_python
/PickAWord.py
390
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This script is used a pick a word from a file. """ import random def main(): print pick_a_word() def pick_a_word(): with open('sowpods.txt', 'r') as source_file: words = source_file.readlines() random_num = random.randint(0, len(words)) ret...
6d1b89bd5fae92f5bec01974e5d1af32116c9666
16030IT028/Daily_coding_challenge
/SmartInterviews/SmartInterviews - Basic/039_Narcissistic_Numbers.py
775
3.96875
4
# https://www.hackerrank.com/contests/smart-interviews-basic/challenges/si-basic-narcissistic-numbers/problem """ Given N, check whether it is a Narcissistic number or not. A narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits Input Format Input contains...
1b815bee75a9193babe21dd95226c058f14b06dc
vladshults/python_modules
/job_interview_algs/reverse_with_singledispatch.py
732
3.859375
4
import functools def swap_it(arr): i = 0 j = -1 for _ in range(len(arr)//2): arr[i], arr[j] = arr[j], arr[i] i += 1 j -= 1 return arr @functools.singledispatch def reverse_it(seq): return swap_it(seq) @reverse_it.register(list) def _(arr): return swap_it(arr) @rev...
bc187a38956fc0c34b7ae0d5ef6724e7ab06a6f5
Adark-Amal/Python-for-Everybody
/PYTHON 4 EVERYONE/Programming for Everybody (Getting Started with Python)/WEEK 5/assignment_3.3.py
1,004
4.46875
4
""" 3.3 Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table: Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F If the user enters a va...
ad5464ef51b7102482cc1d1de4dadb7ecadd9562
grwkremilek/exercism-solutions
/python/phone-number/phone_number.py
1,005
3.9375
4
class Phone: def __init__(self, phone_number): self.number = self.format_number(phone_number) self.area_code = self.number[:3] def format_number(self, phone_number): formatted_number = "" for c in phone_number: if c.isdigit(): formatted_numbe...
3fd6324c69d23bdb5a8f3fb2df448de31d0a90f9
rmcllc/pyBankAccount
/oop_chaining_methods.py
1,421
3.796875
4
class User: def __init__(self, name, email): self.name = name self.email = email self.account_balance = 0 def make_deposit(self, deposit_amount): self.account_balance += deposit_amount print( f"Hello, {self.name} Deposit Amount: {deposit_amount} Avai...
cf382d085e5a333d1977bf3e1ecd9ac32e45fc37
RioRocker97/DistractMyselfFrom_Crypto
/Python/type function.py
336
4.0625
4
# type function use to identify what type of given variable suitable for those type of variable print(type(12)) # clearly it INT print(type(12.5)) # FLOAT print(type(-12)) # still INT print(type("ABC")) # str obviously menu = "pizza,soda,grape" print( 'soda' in menu) # IN keyword can be use as IF it in it reture TRUE ...
11a65cbf9ce7713ac93926df910cbfab711fcc78
MyfanwyNixon/orgsites
/mysocietyorg/moin/lib/python2.4/site-packages/MoinMoin/i18n/recode.py
1,076
3.6875
4
#!/usr/bin/env python """ Convert data in encoding src_enc to encoding dst_enc, both specified on command line. Data is read from standard input and written to standard output. Usage: ./recode.py src_enc dst_enc < src > dst Example: # Using non utf-8 editor to edit utf-8 file: # Make a working copy us...
39de0bc9b2c177b9d5c2dccf3eb32d692467a86e
goynese/euler
/5) Smallest Multiple/python/prob5.py
928
3.78125
4
import sys import time # A newer simplified ispalindrome function. def ispalindrome(n): n = str(n) return n == n[::-1] # def largest_palindome_product(str): # n = int(str) # for i in xrange(n,0,-1): # for j in xrange(n,i-1,-1): # print i,j, i*j # if ispalindrome(i*j): ...
789894593c2cca8fe2a3fd94fc891edcb60a3f3e
pallavipsap/leetcode
/153_find_minimum_in_rotated_sorted_array.py
2,523
3.75
4
# Refer 33. Search in Rotated Sorted Array # Done on May 23 2020 # Check both methods for clarity class Solution: def findMin(self, nums: List[int]) -> int: # Time : O(log n) # Space : O(1) # no duplicate elements == so no need to worry for nums[mid] = l , nums[mid] = r ...
f9180010f6cff316dbc786841e27e46a6565ee75
shivam675/Quantum-CERN
/venv/Lib/site-packages/examples/abc/abc.py
747
3.9375
4
#!/usr/bin/python # # What's the minimum value for: # # ABC # ------- # A+B+C # # From http://www.umassd.edu/mathcontest/abc.cfm # from constraint import Problem def solve(): problem = Problem() problem.addVariables("abc", range(1, 10)) problem.getSolutions() minvalue = 999 / (9 * 3)...
c15e937447084f1eda86480cd899cc92512c8d87
andrew-knickman/python-demos
/Knickman_PythonLab02/Knickman_PythonLab2.py
1,915
4.15625
4
#!/usr/bin/env python # coding: utf-8 # In[5]: def celsius_to_fahrenheit(param_float): return param_float * 1.8 + 32.0 print("Convert Celsius to Fahrenheit.") cel_float = float(input("Enter a Celsius temp:")) fah_float = celsius_to_fahrenhei...
2f46fed905f7185de657dbdaff163b831d4c5931
yangyuebfsu/ds_study
/leetcode_practice/205.py
1,067
4.03125
4
*** 205. Isomorphic Strings Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the...
49b0d81cef63f21cde61c8209ba2fb2ee5701805
awanishgit/python-course
/classes.py
1,124
4.3125
4
# A class is like a blueprint for creating objects. A object has properties and methods(functions) # associated with it. Almost everything in python is an Object # Creating class class User: # Constructor def __init__(self, name, email, age): self.name = name self.email = email self.ag...
58647b7160c95a670f32f010947259d04515f706
jeantardelli/wargameRepo
/wargame/designpatterns/pythonic_adapter_foreignunitadaptermulti.py
1,300
3.65625
4
"""python_adapter_foreignunitadaptermulti This method represents an adapter class that will make other game units compatible between themselves. """ class ForeignUnitAdapterMulti: """Generalized adapter class for 'fixing' incompatible interfaces. :arg adaptee: An instance of the 'adaptee' class. For example,...
0c9e0615ab82c4aaf4b2e3100f59bf01d3afa01b
2keen/plural
/Fundamentals/words.py
555
3.5
4
from urllib.request import urlopen def fetch_words(): with urlopen('http://sixty-north.com/c/t.txt') as story: story_words = [] for line in story: line_words = line.decode('utf-8').split() for word in line_words: story_words.append(word) words = '' ...
7e0c3bdb775cabfba95f061fdb0ec1da3e5ad3a0
palpen/algorithmic_toolbox_assignments
/04_dynamic_programming/primitive_calculator.py
3,808
4
4
# Uses python3 """ This problem is similar to the change problem. Suppose n = 6. In dynamic programming problems, instead of solving the problem from right to left () TODO !!! - explain algorithm (look at scratch paper) - implement code that outputs intermediate steps failing test case 11809 correct: 1 3 9 27 81 82 ...
dd81c25bd1f17edc41033a1c4a4c484be729ed4d
kc113/pyprog1
/funcNewton.py
1,550
4
4
#function for Newton's 1D method def funcNewton(f, x, dx = 0.0000001, tol = 0.0000001): """ f - the function f(x) x - initial guess dx - small change to find derivative tol - tolerance to estimate the root returns the root of the given function using Newton's formula. """ df...
92f0b4d03e9ffa860edd7b433b1084b0bb22bf4a
RamSinha/MyCode_Practices
/python_codes/greedyalgorithms/meetingHallScheduling.py
984
3.796875
4
#!/usr/bin/python from queue import PriorityQueue def findMinNumberOfMeetingHalls(meetings): if not meetings: return 0 q = PriorityQueue() meetings.sort(key = lambda x : x[0]) # sort with start time for i in range(len(meetings)): if q.empty(): q.put(meetings[i][1]) ...
b67419383c9235e20f471033039b3561f5ce1b65
dankoga/URIOnlineJudge--Python-3.9
/URI_1078.py
115
3.859375
4
factor = int(input()) for number in range(1, 11): print('{} x {} = {}'.format(number, factor, number * factor))
6b76a7bf0c0dcd2a914d88f955c9b84568aa4cd4
irakowski/PY4E
/02_Data Structures/ex_7_2.py
1,192
4.5
4
"""Exercise 2: Write a program to prompt for a file name, and then read through the file and look for lines of the form: X-DSPAM-Confidence:0.8475 When you encounter a line that starts with "X-DSPAM-Confidence:" pull apart the line to extract the floating-point number on the line. Count these lines and then compute t...
979331787eff3f1579da3c347f7bbe66d08202d7
triquelme/MSc_Bioinformatics_projects
/Algorithmics/factorielle.py
102
3.5625
4
def factorielle(n): if n==1: return 1 return factorielle(n-1)*n print(factorielle(3))
0f60a7e274fb12b97cda968f718807fcc8483510
dadandroid/MPDA20
/python workshop/01_Recap/02_operators.py
230
3.609375
4
#OPERATORS a = 10 b = 15 c = 10 + 15 #addition d = c - 5 #substraction e = 4 * 4 #multiplication f = e / 4 #division g = e ** 2 #exponentiation h = 5 % 2 #modulus (the reminder of a div.) j = (5 * 2) + 1 print j #print type(f)
f2049ef68c73a694178796d7f2f9cc80e3e0211f
17764591637/jianzhi_offer
/剑指offer/19_printMatrix.py
960
3.90625
4
''' 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字, 例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10. 把矩阵分为一个圈一个圈去运算 思路: 从外往里,画一个图看就很明白了 ''' class Solution: # matrix类型为二维列表,需要返回列表 def printMatrix(self, matrix): # write code here res = [] while ma...
f932a0edd2395528cfb1f32ebaf95824be306e04
bentd/think-python
/10.15.9.py
400
3.765625
4
# Chapter 10 Section 15 Exercise 9 import sys from copy import copy def remove_duplicates(t): s = copy(t) index = 0 while index < (len(s)): char = s.pop(index) if char not in s: s[index:index] = [char]; index += 1 return s if __name__ == '__main__': t = [1,...
79292d17048a0398800d4bd0d168130cc556933f
yceline-yu/blogly-celine
/models.py
3,628
3.515625
4
"""Models for Blogly.""" import datetime from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() DEFAULT_IMG = "https://pbs.twimg.com/profile_images/1064544692707172354/LuZuUIkr_400x400.jpg" def connect_db(app): """Connect to database.""" db.app = app db.init_app(app) # class User: # tablename would...
dcf718b5d51c9e98298fdc277bc27768e5e94ad2
enderquestral/Reed-CSCI382
/Dijkstra/dijkstra.py
3,549
3.84375
4
# File: dijkstra.py """ This module implements Dijkstra's algorithm for solving the single-source shortest-path problem. """ #Got help from Jonah Kohn (regarding making frontier iteratable) #Worked a bit with Casey Harris and Jirarong Li # -Hannah from pqueue import PriorityQueue import math # Implementation notes ...
274220f8ccac9d9d2e11ae9d7773997e722f3088
1TDST-PYTHON/slashicorp-team
/cpfValido.py
1,149
3.578125
4
estaValido = False def verificar_cpf(cpf, digitos): if len(cpf) != digitos: return False else: j = ((10 * int(cpf[0])) + (9 * int(cpf[1])) + (8 * int(cpf[2])) + (7 * int(cpf[3])) + (6 * int(cpf[4])) \ + (5 * int(cpf[5])) + (4 * int(cpf[6])) + (3 * int(cpf[7])) + (2 * int(cpf[8]))) ...
e05cdece50a954040236a697bd6887160fdff7ef
niteesh2268/coding-prepation
/leetcode/Problems/1232--Check-If-It-Is-a-Straight-Line-Easy.py
683
3.625
4
class Solution: def getSlope(self, p1, p2): if p2[0] == p1[0]: return 'Eureka' return (p2[1] - p1[1])/(p2[0] - p1[0]) def checkStraightLine(self, coordinates: List[List[int]]) -> bool: slope = self.getSlope(coordinates[0], coordinates[1]) if slope == 'Eureka': ...
2901f030357da12e6fdec067c63445bcaa7e22c5
jschnab/leetcode
/arrays/min_cost_array_eq.py
1,535
3.828125
4
""" leetcode 2448: minimum cost to make array equal We are given two arrays nums and cost consisting each of n positive integers. We can do the following operation any number of times: * increase or decrease any elements of the array nums by 1 The cost of doing one operation on the ith element is cost[i]. Return t...
bb7f22c94e0230842758d6f982a0c3df5d541d53
TrAceX99/SamurAI
/venv/Lib/site-packages/easyAI/AI/StubbornGreedy.py
3,792
3.53125
4
""" 'Stubborn Greedy' algorithm. The number of branches followed would be: N + (N * N * D) where: N is the number of moves per turn D is the depth So, if there are 4 possible moves per turn and the depth is 10, then: 4 + (4 * 4 * 10) = 164 branches followed. Compare this to MiniMax (without alpha...
2c480f72af3b257fe19ab633f9ebc38a1d44ed66
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/allergies/49ec4c0084394155ab1203945261242b.py
611
3.71875
4
class Allergies: _allergyList = ['eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats'] def __init__(self, num): self.allergies = list(bin(num)[2:]) self.allergies.reverse() def is_allergic_to(self, allergy): for i, v in enum...
a41ef8014b05a41906cefdff3c67084469d01dda
ryanmcg86/Euler_Answers
/136_Singleton_difference.py
1,347
3.515625
4
'''The positive integers, x, y, and z, are consecutive terms of an arithmetic progression. Given that n is a positive integer, the equation, x^2 − y^2 − z^2 = n, has exactly one solution when n = 20: 13^2 − 10^2 − 7^2 = 20 In fact there are twenty-five values of n below one hundred for which the equation has a uniqu...
5a84a27ce6a41646022b6086e88453886942ee98
Akasurde/Algorithms
/Dynamic Programming/subset_sum.py
965
3.5625
4
# -*- coding: UTF-8 -*- # Subset sum problem # Recursive implementation def subset_sum(arr, sum_value): n = len(arr) if sum_value == 0: return True if n == 0 and sum_value != 0: return False if arr[n-1] > sum_value: return subset_sum(arr[0:-1], sum_value) else: return subset_sum(arr[0:-1], sum_value...
829f67ebb1fbef67e56fe1adf322f443a7a11553
dianazmihabibi/iTreadmill_miBand2
/relaysample.py
292
3.703125
4
import time start = time.time() print (start) time.sleep(5) elapsed = time.time() - start elapsed = int(elapsed) ##time = (end - start) / 60 ##time = round(time,1) ##data = time.strftime("%H %M %S", time.gmtime(elapsed)) ##print (data) ##data = int(data) ##data = data * 25.5 print (elapsed)
98499afd5085fa5091abc2e112de0f0a6fe3e76b
lrtao2017/pythonqzs3
/app/example/if-elif-else.py
416
3.6875
4
#!/usr/bin/env python __author__ = "lrtao2010" #Fenshu = input("请输入你的分数:") Fenshu = int(input("请输入你的总分数:")) Fenshu_yw = int(input("请输入你的语文分数:")) if Fenshu >= 180: if Fenshu_yw >= 95: print('A+') else: print('A') elif Fenshu >= 160: print('B') elif Fenshu >= 140: print('C') elif Fenshu >...
760f962e85126abfa45a2e5eccd048dbca1fcb44
scchy/Sorting_Visualization
/src/heapsort.py
1,470
3.6875
4
#! python 3.6 # Create Date: 2019-07-29 # Author: Scc_hy # Function: 堆排序 HeapSort # 加载包 from .data import get_data from .data import get_figure2draw def big_endian(ds, root, end): """ 将堆的末端子节点作调整,使得子节点永远小于父节点 :param: ds get_figure2draw :param: root int 开始(list index) :param: end int 结束(li...
4f21935f5713a819d56a6ef1d977355e4c22e3a3
ddolzhenko/traning_algos_2016_06
/ddolzhenko/bst.py
4,591
3.8125
4
import trees from trees import Tree def is_nil(tree): return tree is None def min_node(tree): assert not is_nil(tree) while tree.left: tree = tree.left return tree def max_node(tree): assert not is_nil(tree) while tree.right: tree = tree.right return tree def is_bst(tre...
00b4cbddb87fdb177f48939c40d6fad6ad9f7918
adwanAK/adwan_python_core
/week_02/labs/04_conditionals_loops/Exercise_06.py
198
4.21875
4
# ''' # Using a "while" loop, find the sum of numbers from 1-100. # Print the sum to the console. # ''' x = 1 total = 0 while x <= 100: total = total + x x += x print("total is: ", total)
a9b9b75dcc9f127823ad1ac639a4bf1d578938ed
myt2000/python-yield-practice
/iter_test/chain_test.py
270
4.0625
4
# from itertools import chain def chain(*iterables): # chain('ABC', 'DEF') --> A B C D E F for it in iterables: for element in it: yield element if __name__ == '__main__': a = 'ABC' b = 'DEF' print(list(chain(a,b)))
524dcfc8eca478fd47dbabe289831c2cc89a9005
kevinrue/BiocCheckTools
/checks/line_chars.py
1,881
3.90625
4
#!/usr/bin/python # !/usr/bin/python2.7 # !/usr/bin/python3 import argparse from utils import files def checkLines(list, max_length): """Returns indices of lines where length is above allowance.""" problems = [] for i in range(len(list)): lineLength = len(list[i]) if lineLength > max_len...
5e46d9c3ab8ac92538b80dd64b6408612445d836
j0eTheRipper/smort-calculator
/variables.py
2,595
3.796875
4
from calculator import Calculator class Variables: def __init__(self): self.usr_input = None self.variables = dict() def assign_var(self, usr_input): self.usr_input = usr_input if self.usr_input.count('=') == 1: self.usr_input = self.usr_input.replace(' ', '').spli...