blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
10a7cad63b552f327964f4ffc5e92549b7aa804b
nakarumanchi/ADG
/Python-Crash-Course/Day-1/Functions.py
266
3.828125
4
def computepay(h,r): pay = 0.0 if h <= 40: pay = h*r return pay pay = 40*r h -= 40 pay += (h*1.5*r) return pay hrs = float(input("Enter Hours:")) rph = float(input("Enter rate per hour:")) p = computepay(hrs,rph) print(p)
e5da1559f3efb723a57b64e5e9d344d73015b064
JackBeale/210CT-Coursework
/TestCombine.py
565
3.578125
4
Final = {3: {4}, 4: {3, 5}, 5: {4, 6}, 6: {5}} class Subset(): def __init__ (self,v,w): self.v = v self.w = w def IsPath (v,w): Combine = {} Combine.update(v) Combine.update(w) if (Combine == Final): print("IS A PATH") ...
e37bd32f3a7692b162e3d4ea9a5d7d3b1a304dc6
booji/Exercism
/python/simple-cipher/simple_cipher.py
1,756
3.515625
4
import secrets from collections import deque import string class Cipher(object): def __init__(self, key=None): if key == None: self.key = ''.join([secrets.choice(string.ascii_lowercase) for i in range(100)]) else: self.key = key def encode(self, text): result = ...
2558d5de00fab7c2cc8364157615c5b16f9a80ff
InformationDS/learning_python_tests
/019.0.py
374
3.640625
4
def panduan(sentence): i = 1 length = len(sentence) last = length - 1 length //= 2 for each in range(length): if sentence[each] != sentence[last]: i = 0 last -= 1 return i temp = input('请输入一句话:') if panduan(temp): print('是回文联!') else: ...
5cf64533eca60fe9437b9405a349fc39a06c7f6a
jwshumaker/ProjectEuler
/Problem_14.py
3,089
4
4
''' Created on Apr 12, 2014 @author: JWShumaker ProjectEuler.net Problem ID 14 The following iterative sequence is defined for the set of positive integers: n -> n/2 (n is even) n -> 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 ...
8ee0daca4d3e502d5790487dd5c4c7138acf5f2a
joonyi/ProjectEuler
/prob34.py
304
3.828125
4
def factorial(n): fac = 1 while n > 0: fac *= n n -= 1 return fac def CuriousNum(n): sum = 0 while n > 0: digit = n % 10 sum += factorial(digit) n //= 10 return sum n = [i for i in range(3,100000) if CuriousNum(i) == i] print(n, sum(n))
2e5624b7286ba6919d533264099ca2001618594a
jinurajk/PythonProject
/List.py
627
3.921875
4
list1 = [1,2,3,4,"jhj"] print (list1) list1[2] = 100 print (list1) del list1[2] print (list1) print ("Length of list" ,len(list1)) print ("Membership of 3 is list " ,3 in list1) print ("Membership of 2 is list " ,2 in list1) list2 = [23,45,65, 3,45,65,22] print ("Maximum value :" ,max(list2)) print ("Minimum va...
e37ddf1143ec638f7b392f3169804256fc7650ee
jxthng/cpy5python
/Practical 03/q5_compute_series.py
411
3.671875
4
# Filename: q5_compute_series.py # Author: Thng Jing Xiong # Created: 20130221 # Description: Program to compute a required series # main # Define (m) def m(i): a = 0 b = 0 c = 1 d = 3 while c <= (2*i - 1): a = (1 / c) - (1 / d) b = b + a c = c + 4 d = d + 4 ...
577529db4db03d723a85d7a8f34169f55c325a93
ekeilty17/Project_Euler
/P014.py
1,193
3.90625
4
def Collatz(n): count = 1 out = "" while n != 1: out += str(n) + " -> " if n % 2 == 0: n = n // 2 else: n = 3*n + 1 count += 1 out += "1" #print(out) return count def Collatz_memoized(n, Chains): if n == 1: Chains[1] = 1 if...
4a93eafa5ea5db17abb53f623fecb39f3c9ad99a
jeanbarcellos/curso.python.guanabara
/pythonexercicios/ex013.py
325
3.625
4
# Faça um algoritmo que leia o salário de um funcionario e mostre seu novo salário com 15% de aumento salario = float(input('Qual é o salário do funcionário? R$ ')) novo = salario + (salario * 15 / 100) print('Um funcionário que ganha R${:.2f}, com 15% de aumento, passará a receber R$ {:.2f}'.format(salario, novo))
2b31050f63141f059151ef90a3bba9c3f89a4508
king-phyte/aoc2020
/Day 20/part_1.py
6,402
3.578125
4
""" --- Day 20: Jurassic Jigsaw --- The high-speed train leaves the forest and quickly carries you south. You can even see a desert in the distance! Since you have some spare time, you might as well see if there was anything interesting in the image the Mythical Information Bureau satellite captured. After decoding t...
9e34c85d7ef0a23b2ee916f5217f0c0798e3fb1b
sandy19332/python0716a
/D08/高階函式2.py
265
3.59375
4
def add(x): return x + 1 def sub(y): return y - 1 def operator(func,n): if(n<200 ): n =200 return func(n) if __name__ =='__main__': print(operator(add,50)) print(operator(add,260)) print(operator(sub,70)) print(operator(sub,700))
1518afe2552dc46c9da3f5d042f501978b67112a
PRaut/python-basics
/math.py
356
3.84375
4
#!/bin/python3 #Math print(50 + 50) #add print(50 - 50) #subs print(50 * 50) #mul print(50 / 50) #divide print(50 + 50 * 50 - 50 / 50) #PEMDAS print(50 % 2) #modulo print(50 ** 2) #exponents print(50 / 6) # returns quotient with decimal output i.e 8.333333333333334 # To get no leftovers in quotient use // pr...
ca1dae1825a33882b446da09f4f356982bf543f9
escaduto/PostgreSQL-mini-project
/src/prog_journal/database.py
551
3.921875
4
import sqlite3 connection = sqlite3.connect("data.db") def create_table(): with connection: connection.execute( "CREATE TABLE IF NOT EXISTS entries (content TEXT, date TEXT);" ) def add_entry(entry_content, entry_date): with connection: connection.execute( ...
c7a1275fc7e235f5a86d2fa7baf017b8214f9511
ngladkoff/2020FDI
/Simulacro2doParcial.py
4,432
3.921875
4
# Simulacro 2do Parcial import random maximo = 20 def menu(): print('1- Cantidad Productos Bazar') print('2- Modificar Precio Producto') print('3- Promedio Precio de Categoría') print('4- Producto menor stock Alimentos') print('5- Productos mas caros por categoría') print('9-Salir') return...
3e692acabd9ab4c093bd8687145dbc91c7db7411
aaayushg/Machine_Learning_Analysis
/BackpropagationNN.py
4,889
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Libraries needed to run the tool import numpy as np import pandas as pd from sklearn.neural_network import MLPRegressor from sklearn.neural_network import MLPClassifier from sklearn import preprocessing #to normalize the values from sklearn.model_selection import train_t...
0c334a4d4d7e1b9f87bff8e5cae541febf1b4859
moontasirabtahee/Problem-Solving
/Leetcode/1 Two Sum.py
726
3.609375
4
from typing import List class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: # we are taking an object and storing the number that are already checked. # We are using object to search checked numbers in O(1) time iterated_values = {} for i, num in enumerate(...
2f53f9d754b7530b3a3c13e3404990d158dfa136
alhanoufN97/Python
/W6L34.py
375
3.5625
4
def Fun1(x) : r=1 for y in x : print(y*r) r+=1 def Fun2(D) : if D <= 10 : return True else : return False def Fun3(f) : if (f<0) : res = f+Fun3(f+1) print (res) else : res =0 return res x = [ " java " , "C++ " , " Pyth...
d67c217c19b58b72dd42f4873fc0b860f41f98df
xCrypt0r/Baekjoon
/src/2/2061.py
368
3.59375
4
""" 2061. 좋은 암호 작성자: xCrypt0r 언어: Python 3 사용 메모리: 29,088 KB 소요 시간: 312 ms 해결 날짜: 2020년 12월 1일 """ def main(): K, L = map(int, input().split()) for i in range(2, L): if K % i == 0: print('BAD', i) break; else: print('GOOD') if __name__ == '__main__': main()
973894cc96deb20e5eae48b8bc95ee5a11d6b6bb
sandeeppal1991/D05
/HW05_ex00_logics.py
2,742
4.625
5
#!/usr/bin/env python3 # HW05_ex00_logics.py ############################################################################## def even_odd(): """ Print even or odd: Takes one integer from user accepts only non-word numerals must validate Determines if even or odd Prin...
6c8d1db1f5fffeade588ff13091048119a427538
Aldairtiyna/Python-for-Data-Science
/SET-1/CODE/PROG_5.py
298
3.84375
4
# Python program to split array and move first # part to end. def splitArr(a, n, k): b = a[:k] return (a[k::]+b[::]) # main arr = [12, 10, 5, 6, 52, 36] n = len(arr) position = len(arr)//2 arr = splitArr(arr, n, position) for i in range(0, n): print(arr[i], end = ' ')
a0cc181229a05165658ffc7c23340de6e23fb743
nash-sanshi/test
/pytest/mypython/greaterinput.py
224
3.53125
4
''' Created on 2021年1月14日 @author: 张磊 ''' prompt = "If you tell us who you are, we can personalize the message you see." prompt += "\nWhat is you first name?" name = input(prompt) print("\n\tHello," + name + '!')
eb0dd610ae755914749325172879595bd0e626c0
edyta555/Bioinformatics
/1_python_molecular_modeling/zad1/forcefields.py
2,800
3.65625
4
import math import numpy as np def dist(vec1, vec2): return math.sqrt(sum(coor ** 2 for coor in vec1 - vec2)) class Wall: def __init__(self, f, L, dim): """Creates a double wall. Args: f: The toughness of the wall. L: The distance from zero to the wall. ...
d10f2302a0467d21b1c40dcf94bb54b877539a33
poturnak/Python_practice
/0_Basics/5_Lists.py
3,556
4.4375
4
#! /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 # =================================================================================================== # +++++++++ Lists +++++++++ # list + list1 - for concatenation you can just add lists # list[1] - extract item from the list using the index; index sta...
c770debff3bdf638c0335a4ac857b9da156d21ff
alortimor/python_tricks
/numpy/fancy_indexing_take.py
911
3.890625
4
#!/usr/bin/pyhton3 """ file: fancy_indexing_take.py Fancy indexing is a technique that involves masking a list of indicies over an array to output an array of the slots that the indicies match. For example, given the following array [77, 4, 3, 81, 27] and a list of indicies [2, 4], the resulting array would be [3, 27 ...
31264a8318fa92d19fcb8a78ef67ddc014a187b2
clevercoderjoy/python_practice_questions
/sort_0_1.py
1,525
4.1875
4
# Sort 0 1 # You have been given an integer array/list(ARR) of size N that contains only integers, 0 and 1. # Write a function to sort this array/list. # Think of a solution which scans the array/list only once and don't require use of an extra array/list. # Note: # You need to change in the given array/list itself. H...
e057719044b304ab0a6bf50c0977520366b3ada9
juniorOliveira28/topicos_especias_3_ano
/3_trimestre/exercícios/lista_1/ex14.py
1,131
3.875
4
""" 14 - Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 7.5% para o Imposto de Renda, 8% para o INSS e 1% para o sindicato. Faça um programa que nos dê: salário bruto. quanto pagou d...
30e2d52b78ffb4c1fc3e893316aed2bfc276ed62
vikramborana/bmsitopen
/Manpreet/string.py
248
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 25 11:27:21 2019 @author: root """ string="" x=open("text.txt","w+") while True: y=input() if y == "-1": break string=string+y x.write(string) x.close()
e00e848cb144cb9ae54046be861b9b9993736413
yao62995/geeks_for_codes
/geeks_for_geeks/test_array_algo.py
721
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # author: yao62995<yao_62995@163.com> from generator import ListGenerator, LinkedListGenerator import array_algo lg = ListGenerator() llg = LinkedListGenerator() def generate_list(num=1, _print=False): list_set = [lg.generate_list() for _ in xrange(num)] if _pri...
ac7f507d94260b5f0c676a687dabf8b1ef068ca5
Neeraj-kaushik/Geeksforgeeks
/Love_Babbar_Array/kth_smallest element.py
204
3.65625
4
def smallest_element(k, li): li = sorted(li) print(li[k-1]) t = int(input()) while t != 0: k = int(input()) li = [int(x) for x in input().split()] smallest_element(k, li) t -= 1
cef818c11df7ba050e986f2505904c1eccea5637
cravo123/LeetCode
/Algorithms/0426 Convert Binary Search Tree to Sorted Doubly Linked List.py
1,699
4.03125
4
""" # Definition for a Node. class Node: def __init__(self, val, left, right): self.val = val self.left = left self.right = right """ # Solution 1, recursion, similar to recursion version of # reversing a linked list. We return head and tail at the # same time. class Solution: def dfs(...
d06021027330d484c7f94554df16f80bfdbc4f9c
PavelDT/Test
/loop.py
484
3.6875
4
n = 100 total_sum = 0 counter = 1 def add_total_up(some_number): global total_sum total_sum = total_sum + some_number print("total sum sofar " + str(total_sum)) #global scope indentation defines local variables #(how something is defined and what the function does) while counter <= n: counter += 1 ...
56aec22bc84730a4694774795b4981c596f89193
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc065/A/4138372.py
340
3.65625
4
S = input() given = ['dream', 'dreamer', 'erase', 'eraser'] while True: if len(S) == 0: break judge = [S.endswith(i) for i in given] if True in judge: index = judge.index(True) length = len(given[index]) S = S[:-length] else: print('NO') qu...
5dd4673cc480a9cfc7934331e27a3fa47197758c
joohoyo/LeetCode
/python3/easy/E27.py
1,006
3.8125
4
# 27. Remove Element # https://leetcode.com/problems/remove-element/ # 15:52 ~ 16:01 (9min) import unittest from typing import List class Solution: def removeElement(self, nums: List[int], val: int) -> int: head = 0 for i in range(len(nums)): if nums[i] != val: nums[h...
36e4555e1671d4477106cd9f52d8183618288d78
infinite-Joy/programming-languages
/python-projects/algo_and_ds/find_celebrity_in2pass.py
1,183
3.625
4
""" Given a function KNOWS(A,B), which returns 1 if A knows B (and not necessarily the other way around) and 0 if A does not know B. A Celebrity is one who does not know anyone, and one who is known by everybody. For a list of N people, find all celebrities in linear time. basically what i can do is that make an in...
3e718bcfe4e55dde2b2b7face488d06cc5bfc901
kevinshenyang07/Data-Structures-and-Algorithms
/algorithms/google/seti/shortest_cycle_in_graph.py
726
3.859375
4
# given a target node in a directed graph, find the shortest cycle including this node # return the whole path def shortest_cycle_path(node): if not node: return [] parents = {} # visited set / mapping of parents queue = collections.deque(node.neighbors) while queue: u = queue.popleft() ...
49a0c3b19e301ab8ec808e2e819756ceb1727d87
actionjacks/myPy
/lesson-1-dataTypes/loop.py
2,807
3.703125
4
import random from random import randint mylisy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] for num in mylisy: if num % 2 == 0: print(num) else: print(f'Odd nuber: {num}') ################################# myList = [(1, 2), (3, 4), (5, 6), (7, 8)] for i in myList: print(i) for (a, b) in myList: ...
1604460a745f683a05c14f8fd16ca60b4ddc44ae
heitorchang/learn-code
/battles/tourneys/20170604_1915.py
1,484
3.859375
4
def easyAssignmentProblem(skills): pass def strangeCode(s, e): lastProdA = False result = "" while s < e-1: s += 1 e -= 1 if not lastProdA: result += "a" lastProdA = True else: result += "b" lastProdA = False return res...
81860e38b26f0ab67d147c7236cff35f5d185fd0
marcelcosme/URI
/PYTHON/1075(accepted).py
86
3.515625
4
x = int(input()) for i in range (2, 10001): if i%x==2: print(i)
2f1d9531cdbe3f8717003f9d9fb91e58a64643a4
embehnan/Project1
/206project1.py
4,931
3.734375
4
import os import filecmp def getData(file): #Input: file name #Ouput: return a list of dictionary objects where #the keys will come from the first row in the data. #Note: The column headings will not change from the #test cases below, but the the data itself will #change (contents and size) in the different test #cas...
a15852af4e0409554f238541d73b1cf1895b2fa5
gagande90/Simple-Gui-Programs-Python
/Simple/3_default_entry.py
579
3.734375
4
import tkinter as tk from tkinter import ttk gui = tk.Tk() ttk.Label(gui, text="Hello Label").\ grid(row=0, column=0) ttk.Button(gui, text="Click Me!").\ grid(row=0, column=1) ...
aa6f8393cf0c67dd81653b34280ce788881621bb
Mohamed3on/Coding-problems
/mergesort.py
610
4.125
4
def mergesort(array): n = len(array) half = round(n / 2) if n == 1: return array else: left = mergesort(array[:half]) right = mergesort(array[half:]) return merge(left, right) def merge(left, right): array = [] while left and right: if left[0] < right[0]: ...
97c6262eacfe31f30496283b0b1107eff6d70ba8
williamieong/Quiz-Program-Python
/quiz.py
2,662
3.84375
4
class Quiz(): def __init__(self,name,num_questions): self.name = name self.num_questions = num_questions self.questions = [] def __str__(self): s = self.name s += ' with ' + str(self.num_questions) + ' questions.' + '\n' for i in range(self.num_questions): ...
ffbe5f82a162f4cd9e03f8049cce991f722e2a95
rain-zhao/leetcode
/py/Task160.py
2,070
3.734375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def nextItm(self, x): self.next = ListNode(x) return self.next class Solution: # hash def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:...
a4145162078e5c78f53fa6d9802d3584a6012401
fieldsfarmer/coding_problems
/generator_eg.py
1,454
3.984375
4
#generator, decrator, closure #oo class #xrange vs range #a generator function is one with keyword: yeild import math # def isPrime(a): # if a > 1: # if a == 2: # return True # if a%2 == 0: # return False # for p in range(3, (int)(math.sqrt(a)+1), 2): # if a%p == 0: # return False # return True...
aa83d3197951facaa03237fe59b5e7e51edadef0
tonym01/pi-python01
/encoder_01.py
1,779
3.734375
4
#!/usr/bin/env python2.7 from __future__ import print_function def bin(x): return ''.join(x & (1 << i) and '1' or '0' for i in range(7,-1,-1)) # "bitwise and" operation or the inbut number when compared with 1 after shifting left by i bits def encoder_dir(currpins, prevpins, pinAnum, pinBnum): """ calc...
ee98dfa6169bc0af57a1f7143d1780d8dd1f2036
laksh10-stan/DSA-Python-
/6.12_inordr_succ_in_inordr_threaded_bin_tree.py
659
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 1 15:26:35 2019 @author: laksh """ ''' To find inorder successor of a given node without using a stack, assume that the node for which we want to find the inorder successor is P. Strategy: If P has a no right subtree, then return the light child of P. If P has right subt...
675e40e69b8f7d5c8fa1563ac76e8431d4ace652
bassboink/Miscellaneous
/circles.py
1,779
4.25
4
import sys ''' Test values: 6 0 0 3 5 0 2 0 0 3 0 0 2 0 0 3 10 10 1 0 0 3 2 0 1 0 0 3 3 0 1 0 0 3 1 0 1 ''' #Function that calculates the squared distances used in determining outside disjointness or touching from the outside def square_distances_outside(xa, ya, ra, xb, yb, rb): sq_dist = (xa-xb)*...
530c197c9b01eb7f6e152fc2a0cd63bc2f57406b
ushankax/python_brain_games
/brain_games/engine.py
1,147
4.03125
4
import prompt LVL_NUMBERS = 3 def run(module): # Welcome to the game text: print('\nWelcome to the Brain Games!') module.welcome() # Asking name and printing the greet: name = prompt.string('May i have your name: ') print('Hello, {}!\n'.format(name)) # Template for incorrect text: ...
cec7f67c72311f30f6076afb6a8fd61e9335ee40
inggan/Baekjoon_Online_Judge
/2443.py
191
3.875
4
N = int(input()) minus = 1 for Repeat in range(0, N): for rep in range(0, Repeat): print(" ",end = "") for repeat in range(0, 2 * N - minus): print("*",end = "") minus += 2 print("")
e725e4b3b245b951b0a5df792a25988daa55f9ec
StevenSigil/cryptography-fernet-python
/fernet_crpytography.py
1,317
3.515625
4
from cryptography.fernet import Fernet, InvalidToken class Cryptography: def __init__(self, file='secret.key'): self.file = file self.key = self.get_create_key() def get_create_key(self): """Loads a key from a file or creates a new key and saves that key to a new file.""" try:...
0f75d2e098876ac952e037967151f1c410a5f197
AlexSchumi/Algorithms
/DFS/31. Next Permutation.py
1,396
3.875
4
class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ """ This is my first implementation of nextpermutation by swaping numbers in nums!!! Incorrect Time compl...
ba26bd0682ff72ab01bef4bd8501cfaecb7a6fd5
Mister-Corn/Intro-Python
/src/dicts.py
580
4.25
4
# Make an array of dictionaries. Each dictionary should have keys: # # lat: the latitude # lon: the longitude # name: the waypoint name # # Make up three entries of various values. waypoints = [ { "lat": 34.049968, "lon": -118.2393978, "name": 'Far Bar' }, { "lat": 34.094600, "lon": -117.7217...
805a6dea0f280c12029171a3e91c2bbbdd637ba3
RicardoMandujano/examplespy
/conditionifelifelse.py
371
3.8125
4
#Nested if condition #if elif else variable = 1000 if variable < 2000: print("menor de 2000") if variable == 1500: print("La cual es 1500") elif variable == 1000: print("La cual es 1000") elif variable == 500: print("La cual es 500") elif variable < 50: print("Es menor 50") e...
9520fc4754bc112a423123de7db24685d36e8126
sci2pro/pl1c
/week3/exceptions.py
1,169
3.828125
4
import os import sys def main(): # NameError: variable doesn't exist # print(s) # ValueError # print(int('s')) # TypeError # print('s' + 1) # SyntaxError # def lsdkjfldkj() # print(1 + 2) # IndexError l = list(range(10)) # l[14] # catching exceptions try: ...
4f9a5a73a047bb0a168f1afa8b534b35e72e95fc
clipklop/PYT8-frii
/lesson7/list_comperhension.py
283
3.609375
4
lst_comp = [ j for v in range(2, 5) for i in range(2, v) for j in range(i * 2, 10, i) ] print(lst_comp) for v in range(2, 5): # -> (2, 3, 4) for i in range(2, v): # -> (), (2), (2, 3) -> (4, 6) for j in range(i * 2, 10, i): print(j)
113d526f5786876a39bbd7dc8735fa75056dc4b3
gakkistyle/comp9021
/Practice_1 solution/mean_median_standard_deviation.py
1,571
4.09375
4
""" prompts the user for a strictly positive integer, nb_of_elements, generates a list of nb_of_elements random integers between - 50 and 50, prints out the list, computes the mean, the median and the standard deviation in two ways, that is,using or not the functions from the statistics module, and prints them...
28f22e3cb19d1549ed2db0d5ac156d54b5e89f04
hackerbot/python-the-next-level-intermediate
/ch60-61.recursionFibonacci.py
237
3.71875
4
# # def foo(n): # # if n == 1: # # return n # # else: # # foo(n-1) # # # 1, 1, 2, 3, 5, 8, 13, 21, 34... etc # def Fib(n): if n == 1 or n == 2: return 1 return Fib(n-1) + Fib(n-2) print(Fib(5))
1a67095a558c59dad7f75841d82d1d76615dfdb8
daniel-reich/turbo-robot
/EWZqYT4QGMYotfQTu_15.py
2,044
3.953125
4
""" Tap code is a way to communicate messages via a series of taps (or knocks) for each letter in the message. Letters are arranged in a 5x5 _polybius square_ , with the letter "K" being moved to the space with "C". 1 2 3 4 5 1 A B C\K D E 2 F G H I J 3 L M N O P 4 Q R S ...
c423efd0a77455bbd39769286ea26f9c58925ba4
ArthurBrito1/MY-SCRIPTS-PYTHON
/Desafios/desafio36.py
505
3.96875
4
valor = float(input('Digite o valor da casa em R$:')) salário = float(input('Digite o seu salario em R$:')) anos = int(input('Em quantos anos voçê quer pagar essa casa?')) prestação = valor/(anos*12) if prestação <= salário*30/100: print('EMPRESTIMO CONCEDIDO! \nPagará R${:.2f} por mês.'.format(prestação)) el...
c1f8540f0ff227a684466f5df2a1d8abc27181a8
sayaka71/Python
/Practice/pra_7.py
994
3.828125
4
# Python入門 # 例外情報を取り出す (p.252) # 例外インスタンスの取得 try: x = 1/0 except ZeroDivisionError as instance_z: print(instance_z) # トレースバックの表示 import sys import traceback try: f = open("temp.txt", "r") except IOError: error_type, error_value, traceback_ = sys.exc_info() tb_list = traceback.format_tb(traceback_)...
afa72b6cab93f910a7fff6c42fb3655e362684a3
GorillaBackpacks/max_int.verkefni
/Documents/HR/Forritun/Python/max_int.py
74
3.546875
4
num_int = int(input("Input a number: ")) print("The maximum is", max_int)
7cafc0356301b96505e5f57c2cfab529384dbe38
roger6blog/LeetCode
/SourceCode/Python/Problem/00388.Longest_Absolute_File_Path.py
6,317
4.0625
4
''' Level: Medium Tag: [Stack] Suppose we have a file system that stores both files and directories. An example of one system is represented in the following picture: "../../../Material/mdir.jpeg" Here, we have dir as the only directory in the root. dir contains two subdirectories, subdir1 and subdir2. subdir1...
2b234e4a4d981486e977d36181b6913a2178fbb2
pqnguyen/CompetitiveProgramming
/platforms/leetcode/FindBottomLeftTreeValue.py
677
3.8125
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 findBottomLeftValue(self, root: TreeNode) -> int: visited = {} self.findBottomLeftValueUtil(root, 1, visited) ...
6746567b08130c114253738133b4eb9b2b91e7e2
jacekkalbarczyk/PyloveOrg
/Lekcja 16.01.2018 - 30 - powtórka/Z2.py
570
4.09375
4
""" Napisz algorytm, który na wejście przyjmie listę zawierającą tylko stringi i integery. Zwróci listą zawierającą tylko powtarzające się wartości, nie zmieniając ich kolejności. Przykład: [1, 2, 3, 1, 3] 1 i 3 nie są unikalne, więc wynikiem będzie [1, 3, 1, 3]. """ def non_unique_list(list_in = []): list_out =[...
c8a6222b6f714c0631e1191ed7fc73fd955d414d
ANTsX/ANTsPyNet
/antspynet/architectures/create_vgg_model.py
11,222
3.671875
4
from tensorflow.keras.models import Model from tensorflow.keras.layers import (Input, Flatten, Dense, Conv2D, Conv2DTranspose, MaxPooling2D, ZeroPadding2D, Conv3D, Conv3DTranspose, MaxPooling3D, ZeroPadding3D) def ...
427efedaf1b6046fdf1a7a9b3291899388bd16af
limsarang/Programming-python-
/python_수행평가2_할일기_2409 송주연,2417 임사랑/work.py
1,039
3.640625
4
from worklist import Worklist class Workmenu: def __init__(self, worklist): self.work_list = worklist def show_workmenu(self): # 맨 위는 해야 할 일 띄워줌 print() # 할 일 메뉴 print('1. 완료한 일 체크') print('2. 할 일 추가') print('3. 할 일 삭제') print('4. 뒤로가기') ...
d93a6007b5773b269e58dcc1873c6f4f6bf71efa
tuxitop/python_exercises
/Series 1/6_gamer_farzad.py
4,694
4.0625
4
#! /usr/bin/python # Filename: 6_gamer_farzad.py # Description: Solution to <Series 1 - Problem 6> # Author: Ali Mousavi <ali.mousavi@gmail.com> # Instructor: Mr. Ali Rezaee # Date: 2018/10/25 import sys def multiply_matrix(first_matrix, second_matrix): """Multiplies two matrices Keyword arg...
86ffd3b875939ec3e13030bcccd0dc9bdece1bf5
tonycolucci/AVC_Project
/src/score_model.py
1,040
3.5625
4
# Imports import logging import yaml import pickle import pandas as pd def generate_score(model, input): """ Generates a score for given input data from a logistic regression model Args: model (sklearn model object): A logistic regression model input (:py:class:`pandas.DataFrame`): DataFrame c...
30e6222417283a459879ec0161bfa4f3fdb6a6e4
JoseManuelMS97/SistemasGestionEmpresarial
/Python/EjerciciosBasicos/Ejercicio3.py
264
4
4
nombre = input("¿Cuál es tu nombre? ") apellido1 = input("¿Y tu primer apellido? ") apellido2 = input("¿Y tu segundo apellido? ") print('Te llamas: '+nombre, apellido1, apellido2) print('En las listas aparecerías como: '+apellido1, apellido2,', '+ nombre)
abd1ed0c3076bc95f7ff2aee41146e9a98247815
kacou12/les_scripts_cours
/structure/structure4.py
496
3.84375
4
X = {"a","b","c","d"} Y = {"s","b","d"} print(X) print(Y) if "c"in X: print("c appartient") if "a" in Y: print("a appartient") X_Y= X-Y #suppression des elements repetitifs et garde reste du premier et pas du second print(X_Y) Y_X = Y-X print(Y_X) #suppression des elements repetitifs et garde res...
cea7d2b1d4155e102759acf4364d738e4849290f
lldaniel23ll/python
/Prueba1.py
492
3.9375
4
#este lenguaje es genial print("Hola que tal en python\nMi nombre es Daniel") cadena="hola 'Daniel'" print(cadena) print(type(cadena)) valor=True print(valor) print(type(valor)) #Este codigo es para ver el tipo de variable es (type(variable)) n=1 print(n) print(type(n)) n1=25 n2=7.7 resultado=n1+n2 print("el resulta...
3a8bb3bd7e84cacbc609b28e71ac39b3cde1fa9b
Kaushik8511/Competitive-Programming
/Codevita/Prime fibonacci.py
1,161
3.546875
4
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def find_prime(left,right): start,end = 0,len(prime)-1 while start<=end and prime[start]<left:start+=1 while end>=start and prime[end]>right:end-=1 return prime[start:end+1] def isPrime(n): ...
b915e06a11d7866fb27bc5ef3adf7d2cb2826d8c
Bhalut/holbertonschool-higher_level_programming
/0x06-python-classes/1-square.py
384
3.59375
4
#!/usr/bin/python3 """ 1-square.py Square class with private attribute size """ class Square(): """Square Class Class with private attribute size """ def __init__(self, size): """__init__ Contructor Contructor of class Square Args: size (integer): privete a...
6221b2368ca31343c3a3f1d83af63d279f23c60b
WilliamGusmanov/PythonWorkshop
/Codes/whileloop1.py
538
4.0625
4
# *********************************** # string1.pr # CCAM Workshop - 2017 # Written by Arjang Fahim # # *********************************** """ This program calculates the sum of numbers [1 .. n] n is given as input """ my_input = input ("Please enter an integer larger than 0:") n = int(my_input) i...
a0a0a2b0f983292dba0c1cc80ef3cf4fa786c946
adnanhanif793/Python-Codes
/Basic/com/introduction/__init__.py
471
3.546875
4
#from builtins import int age=2 weight=61.25 city="Switzerland" print(int(weight)) st="Adnan" if ('na' in st): print('successfull') else: print("Failed") #for i in range(1,15): # print(i) w='Welcome all of you' for i in w: print(i) count=0 while cou...
0d81a2fb33d3eb11b5a8a8a71e471141fde63324
rbpope/AulasPythonMundo2
/Exercícios/ex073.py
739
3.875
4
classificacao = ('Internacional', 'Flamengo', 'Atlético - MG', 'Fluminense', 'São Paulo', 'Santos', 'Palmeiras', 'Fortaleza', 'Grêmio', 'Ceará', 'Atlético - GO', 'Sport', 'Corinthians', 'Bahia', 'RB Bragantino', 'Botafogo', 'Vasco', 'Athletico', 'Coritiba', 'Goias') pr...
4bd7169529c3a008ee0c715aee5d60122b5092ee
caev03/MISO4101TallerKataSimple
/Calculadora.py
687
3.78125
4
__author__ = 'caev03' class Calculadora: def procesar(self, cadena): if(len(cadena) == 0): return [0,"","",""] elif(len(cadena) == 1): valor = int(cadena) return [1, valor, valor, valor] elif(len(cadena) == 3): valorU = int(cadena[0]) valorD = int(cadena[2]) return [2,min(valorU,valorD),max(v...
84f0096a41116c0c61164e495b1edf9cbafd7fba
julzhk/codekata
/find_dup.py
758
3.890625
4
""" Implement a function to identify duplicate numbers in a list using a set todo: use Counter """ def find_dup(arr): seen = set() for i in arr: if i not in seen: seen.add(i) else: return i import unittest class TestFirst(unittest.TestCase): def test_first(self)...
cfca298c8ca16b728527f85db3d062772db261d5
qdree/Python_scripts
/closures/closeres_ex.py
360
3.6875
4
def sort_priority(values, group): found = [False] def helper(x): # nonlocal found if x in group: found[0] = True return (0,x) return (1,x) values.sort(key=helper) return found[0] nums = [5,2,1,6,8,2,12,4,3,7] group = {2,3,5,12} sort_result = sort_priori...
1d700e8a9dd84756084a1be6c21347519c722a20
Tchadingo42/Pyhton_Introduction
/part_5/class2.py
564
3.71875
4
#car_nbr attribut de class class Car: nbr = 0 def __init__(self, brand, speed, turbo): self.brand = brand self.speed = speed self.turbo = turbo Car.nbr += 1 print("Launch Program ...\n") car = Car("Jaguar", 240, True) print("This {} can go until {} klm h and there is turbo {} t...
7a7fe0dd0e9f7a14ef8952562c85969155f5cec3
appym/hacker_rank_playground
/geometricDist2.py
308
3.859375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT numerator, denominator = [int(x) for x in raw_input().split()] fail = 1.0 * numerator/denominator number = int(raw_input().strip()) success = 1 - fail # ** is power of operator ans_1 = 1 - success ** number print'{:0.3f}'.format(ans_1)
c84783ee866147516e07cd58bff2fd1f341550cc
thiago-ximenes/curso-python
/pythonexercicios/sistema.py
710
3.796875
4
from modulos import funcoes_sistema from time import sleep while op != 3: funcoes_sistema.menu() op = int(input('Sua opção: ')) if op == 1: try: open('dados.txt', 'r') except: print('Não existe dados para mostrar.') else: leitura = open('dados...
8ce7abb276b841911aec39c1ebf63697b7a999f9
elhamsyahrianputra/Pemrograman-Terstruktur
/Chapter 09/Chapter08_Pyhton Project_No.03.py
323
3.734375
4
def bintang(n): if n%2 == 0: print("Input yang dimasukkan harus berupa huruf ganjil") else: n = (n+1) // 2 for i in range(1, n): pola1 = ((i*2)-1) * "*" print(pola1.center(20)) for i in range(n, 0, -1): pola2 = ((i*2)-1) * "*" print(pola2.center(20)) print("") bintang(7) bintang(5) bintang(4) ...
40ecd15c79036616c5bb6456528edd3e4bec9c78
Ta-Ye/CodeTest
/Programmers/Summer Winter Coding/숫자 게임.py
178
3.515625
4
def solution(A, B): A.sort() B.sort() answer=0 while A and B: if B[-1]>A[-1]: answer+=1 B.pop() A.pop() return answer
9bba680489ef988f79af401edf163a43fae00eb2
ChanikaRuchini/SigmaLaw-PBSA-Final
/process_input.py
3,337
3.515625
4
import re import csv import string import pandas as pd def remove_punct(text): table = str.maketrans("", "", string.punctuation) return text.translate(table) def find_nth(sent, aspect, n): count = 0 words = sent.split(' ') for j in range(len(words)): if words[j] == aspect: coun...
8b8646e08200fadceba199552bc121bc618a6689
brianchiang-tw/Introducing_Python
/Ch_7_Mangle Data Like a Pro/demo_of_string_output_alignment.py
1,811
3.546875
4
n = 42 f = -7.03 s = 'string cheese' # 42 -7.030000 string cheese print('%d %f %s'% (n, f, s) ) # align to the right # 42 -7.030000 string cheese print('%10d %10f %10s'%(n, f, s) ) # align to the right with sign # +42 -7.030000 string cheese print('%+10d %+10f %+10s'%(n, f, s) ) # align to the left #...
6077e6b55a358f3bb9925d6545b9f4fbc73c0c16
wfhsiao/datastructures
/python/AEE0386-code/Chapter 05/Fib.py
766
4.125
4
# 利用遞迴方式計算費氏數列 # File Name: Fib.py # Version def Fibonacci(n): if n == 0 or n == 1: # 第0項與第1項為1 return 1 else: return Fibonacci(n - 1) + Fibonacci(n - 2) def main(): # 主函數 ch = '' n = 0 print('-----Fibonacci numbers Using Recursive-----') while True: try: ...
3b1205d5c6222a525a6dd2b3dfec19130c4541f2
C1ARKGABLE/piLabs
/2_blink.py
709
3.765625
4
import RPi.GPIO as GPIO import time led0 = 7 led1 = 11 led2 = 13 # Create a list of leds # Set GPIO numbering mode and define input pin GPIO.setmode(GPIO.BOARD) # For each LED in our list of LEDs for ledX in leds: # Set LEDs mode to output GPIO.setup(ledX, GPIO.OUT) # Set led to low(0V) for clean start ...
02d4fb37eba0d86b4d83b25c771ea91a004252cf
spd94/Marvellous_Infosystem_Python_ML_Assignments
/Marvellous_Infosystem_Assignment_1/Assingment1_6.py
193
3.75
4
def pos_neg(n): if(n>0): print("Output : Positive Number",end=" ") elif(n<0): print("Output : Negative Number",end=" ") else:print("Output : Zero",end=" ") x=int(input("Input :")) pos_neg(x)
875adce6b3a0ec2c6164738cd8b554663890c2a1
TotallyNotAB0t/2048_Game_Website
/Game/DeuxMilleQuaranteHuitDeDURAND.py
12,510
3.53125
4
#Bibliothèques graphique (natives avec python 3) from tkinter import * from tkinter.messagebox import * import copy #On veux cette bibliothèque pour pouvoir deepcopy notre grille. #Bibliothèque de l'aléa (native avec python 3) #Pour appeler un nombre entier au hasard entre a et b #on fait poetiquement : randint...
73a894f7aaf9b7172b3ad76234b21e0c068bbbf1
prekshabutani17/DP-10
/BurstBalloon.py
1,320
3.703125
4
""" Time Complexity : O(n^3) where n is the length of nums Space Complexity : O(n^2) where n is the length of nums Did this code successfully run on Leetcode : Yes Any problem you faced while coding this : No """ class Solution: def maxCoins(self, nums: List[int]) -> int: if len(nums) == 0: retu...
7a745be810dcaae673d57bb1914a675e9a7a219e
Neil-Do/HUS-Python
/Python 100 Problem/Problem12.py
218
4.0625
4
def stringUpper(): print("Chuong trinh chuyen mot chuoi ky tu dau vao thanh dang in hoa (UPPER STRING).") s = input("Moi nhap chuoi: ") while s: print(s.upper()) s = input() stringUpper()
846028e3858a59e2ae48b5165779fc22ce12aa04
id-gue/practice-django
/python/explain_decorators.py
727
3.75
4
""" decorators decocators add functionality to our function is function, takes a function, returns a function @transaction.atomic @login_required """ # write my own decorator def bold(my_function): def inner(*args, **kwargs): return '<b>' + my_function(*args, **kwargs) + '</b>' return inner # use...
ba85f5df553a4fcafca627ea01b141bc8f7e605b
Ran-oops/pydastructure
/code_/sort_code/binary_search.py
573
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 递归实现: 最优时间复杂度是O(1) 最坏时间复杂度是O(logn) """ def binary_search(alist, item): """二分查找""" n = len(alist) if n > 0: mid = n // 2 if alist[mid] == item: return True elif item < alist[mid]: return binary_search(alist[:m...
2908ddf9222acab11a5ff15db2e974c2cd93c89c
piggy1024/python-learn
/python-course/day-01/code/16.运算符的优先级.py
390
3.859375
4
# 16.运算符的优先级.py a = 1 + 2 * 3 a = 1 or 2 and 3 print(a) # 运算符and 要比 or 高级 # 运算符的优先级可以用优先级的表格来查询 # b在表格位置越靠下越高级 print(1 or 2) print(1 and 2) # 逻辑运算符可以连着使用 result = 1 < 2 < 3 # 相当于1 < 2 and 2 < 3 result = 10 < 20 > 15 # 相当于 10 < 20 and 20 > 15 print(result)
54160448049d20073f798e279513dfb10607e6ad
2vitalik/TUI_2015
/.old/Home works/Konstantin_Ya/Nod_rec.py
186
3.71875
4
__author__ = 'Kostik' a=int(input("a:")) b=int(input("b:")) def nod(a,b): if a < b: a,b=b,a if b==0: return a else: return nod(b,a%b) print(nod(a,b))
99f885230ce97d693d7486d8bb834c1dfb04acc1
hwang-m/leetcode
/Python/221-240/Lowest Common Ancestor of a Binary Search Tree.py
842
3.8125
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 lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': rval = root.val pval = p.va...
77b460b4f7f4d7dfd816fae5e2980e05f392daba
WBourne2048/basicneuralnet
/neuralnetiris.py
2,701
4.15625
4
""" Implementation of a 1 hidden layer NN to classify the iris dataset Note: there is no test/train split in this code so the classification accuracy will be very high as a result of overtraining if the number of iterations is increased """ import sklearn import numpy as np from sklearn import datasets np.random.s...
9c4aea1752223e8e26fb7a794c52f10c8809564d
Zhaisan/PythonDev
/informatics/cycleWhile/c.py
95
3.703125
4
a = int(input()) b = 1 i = 0 while 2**i <=a : print(2**i,end=""+" ") i+=1