blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a0b6f03c24f5d75d37a74a31ec3661a19588e3e8
techsharif/afreen-codes
/python/maria/maria.py
192
3.875
4
while(1): inp = input("Height: ") if inp.isdigit(): inp = int(inp) if 1 <= inp <= 8: break for i in range(1, inp+1): print(" " * (inp - i) + "#" * i)
d013c7cf6d3fbd2d84fb71c471b858289a322cd0
akib20/Fibonacci-value
/tutorial 7 1.py
576
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 1 21:39:16 2019 @author: Akib """ def fibonacci(n): """Recursive fibonacci that remembers previous values""" if n not in fibo_dict: # recursive case, store in the dict fibo_dict[n] = fibonacci(n-1) + fibonacci(n-2) return fibo_d...
d7134d2cb7bfd1b5e34a6e6c2dd638e78ca3760c
gagdiez/MinimalPythonPackage
/phds/cli/flip_text.py
579
4.0625
4
""" Function to flip texts """ from .. import utils def flip_text(input_file, output_file): """ Flips the text of a file Parameters ---------- input_file: string Route to the text_file to read output_file: string Output file to write with the flipped text ...
4b96244a86d615090da7e0ee810daffd5b97885e
RayGit/LINCS
/data_profile - 完全正确/lib/util/sqlite.py
6,502
3.53125
4
''' Basic practical functions for quickly sql command using Created on April 20, 2016 @author: Hong Hao @email: omeganju@gmail.com ''' import sqlite3 import numpy as np def sql_tuple(data_array, warp=True): '''generates a tuple for format printing as a sql query command ''' for i, item in enumerate(data_...
d5fee0cdc323a6feca2f3b7cf95cc59f909bbfab
tsakaloss/pycalculator
/calculator.py
2,930
4.375
4
import sys from lib import operations # Manage the operations def mathing_func(a, b, sign): if sign == '+': return operations.Calculations.plus(a, b) elif sign == '-': return operations.Calculations.minus(a, b) elif sign == '*': return operations.Calculations.multiply(a, b) eli...
3c7d4ca18a172d06caf3965394a8684526f75169
kashishkumar/PythonAutomation
/Separatefiles.py
1,293
3.671875
4
# A program for segregating files into different folders # Given a folder with image and text files, segregate images and text files into two different folders. from glob import glob import os import shutil import sys path = "..." def get_file_paths(path): image_files = glob(path + '/*.tiff') + glob(path + '/*.p...
cdd591ded87b0413c9843bc25db2f0a80907b49d
5kuby/Juggler
/juggler.py
5,761
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 import argparse class JugglerPassGen(object): mapping = {'a': 'a@4A', 'b': 'bB8', 'c': 'cC', 'd': 'dD', 'e': 'e3€&E', 'f': 'fF', 'g': 'gG', 'h': 'hH', 'i': 'i1!I', 'l': 'l|£L', 'm': 'mM', 'n': 'nN', 'p': 'pP', 'q': 'qQ', 'r': 'rR', 's': 's5$S', ...
93fc28c4fdd743331c6d119971c889031fc9d4a9
TestCreator/GenSequence
/distribute/draw.py
5,566
4.03125
4
""" Drawing items from distributions and sequences. Even when drawing from a sequence, we will package the functionality as functions rather than generators. In some cases those functions will really be callable objects. """ import random import sys import os import logging logging.basicConfig(format='%(levelnam...
a7acd9fd0bcb931eca5f94298d204b9a406cfad7
Ritesh-krr/hacktoberfest2020
/TicTacToeProject.py
3,620
3.96875
4
# Copyright 2019 # # Author : Geetansh Atrey # # Python code to make a Tic Tac Toe a.k.a. X and 0s. # import os def drawGrid(gridValues): i=0 j=0 c=0 print("\n\n") for j in range(0,3): for i in range(0,3): if i==1: print("\t\t {0} | {1} | {2} ".format(gridValues...
3c02eaad3e2c62ff6fb0be14d07f1e69fdb53e04
HoangAce/ExerciseCodeforcer
/509A.py
155
3.703125
4
n = int(input()) def elem(row, col): if row == 1 or col == 1: return 1 return elem(row - 1, col) + elem(row, col - 1) print(elem(n,n))
53c3c788447d8847f01dd081d09e40e8a2e80e5a
HoangAce/ExerciseCodeforcer
/1455A.py
122
3.578125
4
t = int(input()) answers = [] for i in range(t): answers.append(len(input())) for answer in answers: print(answer)
eccfea4184a653586d7baed4290eb9128aa9f450
HoangAce/ExerciseCodeforcer
/1176A.py
429
3.578125
4
def main(): q = int(input()) for i in range(q): n = int(input()) count = 0 while n % 2 == 0: count += 1 n = n//2 while n % 3 == 0: count += 2 n = n//3 while n % 5 == 0: count += 3 n = n//5 if ...
d7b1677598c30b4540da30ef5e092142478c1977
HoangAce/ExerciseCodeforcer
/1549A.py
200
3.703125
4
def main(): for i in range(int(input())): P = int(input()) if P % 2 == 0: print(2, P) else: print(2, P - 1) if __name__ == '__main__': main()
6380f2a0832f614458498e9af07db496b1ccba93
HoangAce/ExerciseCodeforcer
/1388A.py
330
3.71875
4
t = int(input()) numbers = [] for i in range(t): numbers.append(int(input())) for number in numbers: if number > 30: print("YES") if number % 2 == 0 and number != 46: print(6,10,15,number - 6 - 10 - 15) else: print(6,10,14,number - 6 - 10 - 14) else: p...
1be353dcee48e73ea733bdbd3000148f2f8d3032
HoangAce/ExerciseCodeforcer
/80A.py
427
3.875
4
def is_prime_basic(number): if number < 2: return False for value in range(2, number): if number % value == 0: return False return True numbers = list(map(int, input().split(" "))) if is_prime_basic(numbers[1]): for num in range(numbers[0] + 1,numbers[1]): if is_prime...
0c3925c9dfd8736a0f5836d2139fdf6d6a259a70
lightdarkx/python-snippets
/LinearSearch.py
513
4.28125
4
# Program to implement linear search in a given array/list def linearSearch(arr,search_item): print(f"search_item: {search_item}") for i in arr: if (i == search_item): return -2,i #print(f"i: {i}") return -1,-1 arr = [1,2,3,4,5] search_item...
0b3f8512092415ca080290520f8541b2e981a509
jacobhammontree/daily_coding_problems
/dcp_373.py
1,291
3.984375
4
""" This problem was asked by Facebook. Given a list of integers L, find the maximum length of a sequence of consecutive numbers that can be formed using elements from L. For example, given L = [5, 2, 99, 3, 4, 1, 100], return 5 as we can build a sequence [1, 2, 3, 4, 5] which has length 5. """ from collections impor...
1f48bfbad0a7b2bfe17eb07780a43177a492f798
DanielPramatarov/Penetration-Testing-Tools
/Python/PythonNmap/PyMap.py
3,223
3.8125
4
import nmap while True: print("""\nWhat do you want to do?\n 1 - Get detailed info about a device 2 - Scan IP for open ports with stealth scan e - Exit the application""") user_input = input("\nEnter your option: ") print() ip = input("\nPlease enter ...
cfbadeba327e37fa3b4a401557e163b50bac350c
5sztuk/5sztuk
/day10.py
2,155
3.59375
4
# import datetime # # class Pizza(): # # stawka_VAT = 23 # __marza = 1.05 ##to jest pole prywatne # # def __init__(self, skladnik_glowny = None): # self.skladnik_glowny = skladnik_glowny # self.rozmiar = '30cm' # self.ciasto = 'cienkie' # self.cena = 100 * Pizza.__marza # # ...
cb6679963999bf83472d5a1a379bf1e61a9adebb
SeokLii/Algorithm
/Greedy/GD-기본.py
1,923
3.515625
4
# 크루스칼 알고리즘 (최소 신장 트리) graph = { 'vertices': ['A', 'B', 'C', 'D', 'E', 'F', 'G'], 'edges': [ (7, 'A', 'B'), (5, 'A', 'D'), (7, 'B', 'A'), (8, 'B', 'C'), (9, 'B', 'D'), (7, 'B', 'E'), (8, 'C', 'B'), (5, 'C', 'E'), (5, 'D', 'A'), (9,...
ab9c10b37a233df7ca385a960af4676559cf1a73
SeokLii/Algorithm
/Other/세 개의 구분자(PR).py
191
3.515625
4
def solution(myStr): return ['EMPTY'] if len(myStr.replace('a', ' ').replace('b',' ').replace('c',' ').split()) == 0 else myStr.replace('a', ' ').replace('b',' ').replace('c',' ').split()
e8b869807cd9a333e42c15faab07abe76858ce7f
doorOfChoice/nlp_study
/utils/io_utils.py
493
3.609375
4
# coding=utf-8 def read_file_as_string(filename): """ 读入文件为字符串 :param filename: :return: """ s = "" with open(filename, 'r') as f: for line in f: s += line return s def read_file_as_list(filename): result = [] with open(filename, 'r') as f: for line ...
8dead87ea8d8a1b52512a7f36728e7539b43b9a1
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day2/28_is_an_bn/tests.py
626
3.515625
4
import solution import unittest class SolutionTest(unittest.TestCase): """Testing Problem 28 - Word from a^nb^n module""" def test_is_an_bn(self): self.assertEqual(True, solution.is_an_bn("")) self.assertEqual(False, solution.is_an_bn("rado")) self.assertEqual(False, solution.is_an_bn(...
b9c7932d3b28fb4e70c00da0337a58e27cc7aad3
SvetlaGeorgieva/HackBulgaria-Programming101
/week2/week2day1/calculator_tests.py
970
3.828125
4
import calculator import unittest class CalculatorTest(unittest.TestCase): """Testing the very simple and trivial calculator module""" def test_add(self): self.assertEqual(5 + 6, calculator.add(5, 6)) def test_minus(self): self.assertEqual(5 - 6, calculator.minus(5, 6)) def test_mult...
034815200df3705e818ad595f2539eb8d850ad73
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day2/31_nth_fib_lists/solution.py
558
3.875
4
def nth_fib_lists(listA, listB, n): if n == 1: return listA if n == 2: return listB if n > 2: a = listA b = listB count = [] for i in range(3, n + 1): count = a + b a = b b = count return count def main(): prin...
64a4024688545aec3a514280f4bc80f8febd0d2c
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day1/14_number_to_list/solution.py
280
3.71875
4
def number_to_list(n): n_str = str(n) n_list = [] for i in n_str: n_list.append(int(i)) return n_list def main(): print (number_to_list(123)) print (number_to_list(99999)) print (number_to_list(123023)) if __name__ == '__main__': main()
c4c90927eadbcadf933cbb8c2ab3fa8048acee20
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day2/34_sudoku_solved/solution.py
2,331
3.5625
4
def check(arr): for key in arr: if(arr[key] != 1): return False else: return True def subgrid(a,b, sudoku): arr_ab = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0} list_ab = [] for i in range(3): for j in range(3): num = sudoku[a+i][b+j] ...
99f03c5edf3ac66e5c0159bde11912283d1db8fc
SvetlaGeorgieva/HackBulgaria-Programming101
/week0/week0day1/11_count_substrings/tests.py
677
3.71875
4
import solution import unittest class SolutionTest(unittest.TestCase): """Testing Problem 11 - Counting substrings module""" def test_count_substrings(self): self.assertEqual(2, solution.count_substrings("This is a test string", "is")) self.assertEqual(2, solution.count_substrings("babababa", ...
fce6046c100aa020544180d107d10a615efdc213
SvetlaGeorgieva/HackBulgaria-Programming101
/week4/week4day1/manage_company.py
3,433
4.40625
4
import sqlite3 conn = sqlite3.connect("employees.db") cursor = conn.cursor() #id INTEGER PRYMARY KEY -> pravi id-tata da se uveli4avat avtomati4no #Global arguments commands = ["list_employees", "monthly_spending", "yearly_spending", "add_employee", "delete_employee", "update_employee", "finish"] # command>list_e...
e9a6d1c8de9290cf452f81f35df46f9ab2f9e48a
Meeds122/Grokking-Algorthms
/4-quicksort/quicksort.py
1,280
4.21875
4
#!/usr/bin/python3 def quickSort(arr): working_array = arr.copy() working_array_length = len(working_array) if working_array_length <= 1: # Empty element or single element case return working_array elif working_array_length == 2: # only 2 elements case if working_array[0...
8776d7a76c98a001d9d2f8acea966e3d5d3654c9
Yash27112006/C111
/studentMarks.py
4,470
3.65625
4
import csv import plotly.graph_objects as go import plotly.figure_factory as ff import statistics import random import pandas as pd df=pd.read_csv("studentMarks.csv") data = df["score"].tolist() # fig = ff.create_distplot([data],["Math score"],show_hist=False) # fig.show() mean = statistics.mean(data) ...
bf63e6d17d3199fde81504a418b9c93485d87b94
apmoore1/target-extraction
/target_extraction/data_types_util.py
1,552
3.546875
4
''' Module that contains helpful classes and methods for `target_extraction.data_types` classes: 1. Span 2. OverLappingTargetsError 3. AnonymisedError 4. OverwriteError ''' from typing import NamedTuple class Span(NamedTuple): ''' Span is a named tuple. It has two fields: 1. start -- An integer that sp...
def9cd930313f4fe0e6f5219f51e25e31ff04788
andrewswellie/Python_Rock_Paper_Scissors
/RockPaperScissors.py
1,537
4.15625
4
# Incorporate the random library import random restart = 1 while restart != "x": print("Let's Play Rock Paper Scissors!!!") options = ["r", "p", "s"] computer_choice = random.choice(options) user_choice = input("You are playing against the computer. His choice is completely random. Make your Choi...
28ce77332f04cf08d18f720e8dbb67493797a25a
SquareRootTwo/AdventOfCode
/2020/day_1/main.py
1,975
3.671875
4
import time as t # Complexity of O(n^2) def task_1 (nums) : length = len(nums) for i in range(length) : for j in range(i + 1, length) : x = nums[i] y = nums[j] if (x + y == 2020) : print (x, " * ", y, " = ", x * y) # Complexity of O(n^3) def task_2 (nums) : length = len(nums) ...
93a999d30bd04a590cc72d766e2318c2d2dcc6f0
Peteliuk/Python_Labs
/lab8_2.py
586
3.984375
4
#!/usr/bin/env python3 import statistics def selection_sort(arrayToSort): a = arrayToSort for i in range(len(a)): #Позначимо найменший елемент idxMin = i for j in range(i+1, len(a)): #лишайєм 1 елемент і йдем на 2 if a[j] < a[idxMin]: #знаходим менший за новий 1 id...
d3c77e649eab7f5a445ec617b299befcefed0634
Peteliuk/Python_Labs
/lab3_1.py
163
4.0625
4
import sys import math print('Enter two numbers, please:') num_1 = float(input('')) num_2 = float(input('')) res = num_1 + num_2 print('Result:',res)
206be617f9040d22f00c198c25a23c48562a7081
Peteliuk/Python_Labs
/lab7_2.py
180
3.96875
4
#/usr/bin/env python3 import sys s = raw_input('Enter da string: ') clean = s.replace(' ','') lower = clean.lower() if(lower == lower[::-1]): print True else: print False
75dc75753de9f6b99764934600d4fcad19c365bf
catlouise/Project-Euler
/001.py
82
3.71875
4
total = 0 for i in range(3, 1000): if i%3==0 or i%5==0: total += i print total
06d8d9cd92bad1e6a3ea0fbddeb0718ee09e35df
johnromanishin/Python
/Old Python Programs/ps2b.py
1,415
3.640625
4
# Problem set 2b # Name: John Romanishin # Collabortors: David Crowl # time: 4:00 # This is one day late. I wish to use one of my late days for this. def canBuy(n, packages): # Creates a function that can be used in further programs "Returns true if that number of nuggets can be purchased" # this is what it te...
368ec147cd5f547160e88580a4c11783f2f79f98
pani-vishal/String-Manipulation-in-Python
/Problem 7.txt
221
4.21875
4
#Program to count no. of letters in a sentence/word sent=input("Enter a sentence: ") sent=sent.lower() count=0 for x in sent: if (x>='a' and x<='z'): count+=1 print("Number of letters: "+str(count))
afa0d3861f350476303935675bd207e08272ce1c
ramalho/propython
/fundamentos/metaprog/atrib_dinamicos.py
814
4.28125
4
#!/usr/bin/env python # coding: utf-8 '''Exemplo de acesso e atribuição dinâmica de atributos de instância. >>> n = Nova() * self.__setattr__('b') >>> print repr(n.a) 1 >>> print repr(n.b) 2 >>> print repr(n.c) * self.__getattr__('c') 'c?' >>> n.a = 10 * self.__setattr__('a...
1f3b7578b43087e77e3452bd2d42b9350ef8a5da
ramalho/propython
/fundamentos/execucao_pergunta.py
1,435
3.75
4
import sys import atexit print '-> 1 inicio' def funcaoA(): print '-> 2 funcao A' return 'resultado A' def funcaoB(): print '-> 3 funcao B' def funcaoC(): print '-> 4 funcao C' return funcaoC funcaoD = lambda:sys.stdout.write('-> 5 funcao D\n') def funcaoE(): print '->...
0bde2b2ea962a5cc5b54d148718bd8633e2b1015
ramalho/propython
/fundamentos/slides/marcoandre/pyMordida0-fontes/py50.py
222
3.75
4
#!/usr/bin/env python #-*- coding:utf-8 -*- total=0 while True: p = raw_input('+') if not p.strip(): break try: total += float(p) except ValueError: print "." print '---------' print total
adc9c9b879ca67d5ea56af727c2430146936a342
ramalho/propython
/fundamentos/slides/marcoandre/pyMordida0-fontes/py58.py
207
3.6875
4
#!/usr/bin/env python #-*- coding:utf-8 -*- def inverter(texto): if len(texto) <= 1: return texto lista = list(texto) lista.reverse() return ''.join(lista) print inverter('python')
52a811e422306a3919e5c06cb3c2c568c2a31160
ramalho/propython
/fundamentos/funcional/curry.py
989
4.40625
4
#!/usr/bin/env python ''' Exemplo da técnica de currying. A função rectFactory é um "curry" que retorna uma função que realiza o serviço de rect fixando um dos parâmetros para que ele não precise ser fornecidos a cada invocação. Em rectFactory2 temos um exemplo que demonstra a mesma técnica implementada com o coma...
4e9d278a621894dd3e3220741b12ffbbd44f11ca
ramalho/propython
/fundamentos/metaprog/getattr.py
1,310
3.59375
4
# coding: utf-8 ''' ----------------------------------------- Exemplos de atributo dinâmico ----------------------------------------- >>> j = Aluno('Juca', 7) >>> j <Juca (7)> >>> print j Juca (7) >>> j.nick 'Ju' ''' def apelido(nome): u''' Devolve um apelido gerado a partir ...
f69b58522442a668ab76ab9d36ecb3c6bf1377de
SmallPotY/PyGame
/贪吃蛇.py
3,201
3.671875
4
# -*- coding:utf-8 -*- import pygame import random class Point: row = 0 col = 0 def __init__(self, row, col): self.row = row self.col = col def copy(self): return Point(row=self.row, col=self.col) # 初始化 pygame.init() W = 800 H = 600 ROW = 60 COL = 80 # 设置大小 标题 size = (W, ...
3610778c17883e5a8aa8648ae63f1c6c50f34ff0
dimarkov/predchange
/model/tasks.py
2,210
3.65625
4
"""This module contains various experimental environments used for testing human behavior.""" from __future__ import division from numpy import zeros, ones from numpy.random import choice, rand class RevLearn(object): """Here we define the environment for the probabilistic reversal learning task """ def ...
41c2219df15942c12ced0b5359ff2ad40c562613
Hank11tibame/tibame_Six-months
/函數4.py
321
3.734375
4
#參數預設值的處理 def interest(interest_type,subject = "敦煌"): """顯示興趣和主題""" print("我的興趣是 " + interest_type) print("在" + interest_type + "中,最喜歡的是 ",subject) print() interest('旅遊') interest('旅遊','台北') interest('閱讀','工具書')
68b752108e638f7ffe4261544c31b9dcf9dd0bc6
shazack/LeetCode-Pythonsolns-
/isValidBST.py
1,208
3.953125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # Time Complexity: O(n) # Auxiliary Space : O(1) if Function Call Stack size is not considered, otherwise O(n) import sys INT_MAX = sys.maxint INT_M...
f7cfc75fa0e1415c524b31603458623e19b9e120
shazack/LeetCode-Pythonsolns-
/mergesortedarrays.py
259
3.78125
4
def merge(nums1,m,nums2,n): while m > 0 and n > 0: print m, n if nums1[m-1]>=nums2[n-1]: nums1[m+n-1] = nums1[m-1] m -=1 else: nums1[m+n-1] = nums2[n-1] n -=1 if n > 0: nums1[:n] = nums2[:n]
3d90e9346f93d2cf211751d2ffc66a0f9c17360e
antonsoo/Popular-Algorithms
/binary-search.py
348
4.0625
4
def binarySearch(array, target): left = 0 right = len(array) - 1 while left <= right: middle = (left + right) // 2 if target == array[middle]: return middle # return the index of the matched num elif target < array[middle]: right = middle - 1 else: # target > array[middle]: left = middle + 1 re...
8a40fa0286e82646e26dd5123ec8ab285361336f
chengl7/IniMotif
/windows.py
11,693
3.765625
4
#!/usr/bin/env python3 # an close_open integer window class, e.g. [0,3) => 0,1,2 class Window: def __init__(self, a=0, b=0): assert a<=b, f'a={a} <= b={b} does not hold.' self.a = a self.b = b def _empty(self): return self.a == self.b def __add__(self, other): ...
21bdc848d2f4c825cfcd5a1161ab13f789c6971b
ddolzhenko/training_algos_2017_03
/intro/merge_sort.py
570
3.9375
4
def merge(u, v): bu, eu = 0, len(u) bv, ev = 0, len(v) result = [] while bu < eu and bv < ev: if u[bu] < v[bv]: result.append(u[bu]) bu += 1 else: result.append(v[bv]) bv += 1 result += u[bu:] result += v[bv:] assert(len(result...
914cc2cd3c70734088ad52a5cbf5ba9da86b970e
hafsaabbas/-saudidevorg
/62 day.py
96
3.546875
4
import camelcase c= camelcase.CamelCase() txt = "loren ipsum dolor sit amet" print (c.hump(txt))
a6e06ecef10a71f137e5e7c6777465f451eace46
hafsaabbas/-saudidevorg
/36 day.py
238
3.75
4
def my1(n): return lambda a:a*n myd=my1(2) print(myd(11)) def my2(n): return lambda a:a*n mydd=my2(3) print(mydd(11)) def my2(n): return lambda a:a*n mydd=my2(3) myd=my1(2) print(mydd(11)) print(myd(11))
c0d5417363db71c14c30a616c788db4103c8349f
hafsaabbas/-saudidevorg
/12 day.py
613
3.609375
4
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> t="please, I Want {} sandwish and {} donuts" >>> print(t.replace("i","we")) please, I Want {} sandwwesh and {} donuts >>> x=5 >>> y=7 >>> ...
663072710d4fd1bd11a7a2bfd32a24228c274b12
hafsaabbas/-saudidevorg
/15 day.py
801
3.828125
4
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> y=["apple","banana","cherry"] >>> print(len(y)) 3 >>> y.append("orange") >>> print(y) ['apple', 'banana', 'cherry', 'orange'] >>> y.inser...
fbb628024270e030a2a1537f6e32a5fca091c029
EstonecOG/12.10.2021
/module1.py
3,075
3.953125
4
def arithmetic(a: float,b:float,c:str): """Lihtne kalkulaator + - liitmine - - lahutamine * - korrutamine / - jagamine :param float a: Esimene arv :param float b: Teine arv :param float c: Aritmeetilene tehing :rtype float: """ if c=="+": r=a+b elif c...
7c7febf76d8f1877561d65ddfd7e3b5e1f87192c
maulanaadil/Interpolasi
/newton/newton.py
648
3.578125
4
import numpy as np import matplotlib.pyplot as plt # Data Nilai X dan Y x = [5.0, 10.0, 15.0, 20.0] y = [40.0, 30.0, 25.0, 40.0] # Data yang dicari xInput = 12.0 n = len(x) - 1 # Selisih Terbagi ST = np.zeros((n + 1, n + 1)) ST[:,0] = y # Penyelesaian for k in range(1, n + 1): for i in range(0, n - k + 1): ...
57c1255a4b0e0b7fbb4dbc54a32aacc4c84c547b
belaidabdellah/PythonRefresherTuto
/conditionspython/conditions.py
524
3.6875
4
# gestion des places de cinema # recolter l'age de la personne "Quel est votre age ?" age = int(input("Quel est votre age ? ")) # si la personne est mineur -> 7€ if age < 18: prix_total = 7 # si la personne est majeur -> 12€ else: prix_total = 12 # ou alors en ternaire # prix_total = (7, 12)[age < 18] # sou...
f91a700285537cbbd9f51fb70d8d7ae0559d1709
jeremymatt/DS2FP
/drop_illogical.py
713
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 25 22:59:05 2019 @author: jmatt """ def drop_illogical(df,var1,var2): """ Drops records from the dataframe df is var1 is greater than var2 For example, if var1 is spending on clothing and var2 is total income it is not logical that var1 is grea...
84ac99ced4b2728cf9f225488a3c3a0c63f8c05f
naufan250/lolxd
/arreglo (2).py
94
3.53125
4
"juan esteban triviño" arreglo=[] x='1' while x!='': x=input() arreglo.append(x) else: print(arreglo)
051d08ec216fff8651d3a096578c7fa38ba875ed
CLAHRCWessex/math6005-python
/Labs/wk1/if_statement_preview.py
1,884
4.6875
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Week 1 Extra Material: If-then statements A short look ahead at conditionals and if statements. We will cover these in detail in week 2. But feel free to have edit the code below to see how it works. In most Python programmes that you write you will be using if...
b184b7d9c15202ba3a3e11107f6fd61bd9f691e2
zhl95/coursera-data-structures-and-algorithms
/algorithmic-toolbox/1-intro-starter-files/fibonacci_huge.py
600
3.671875
4
# Uses python3 import sys def picasa_number_length(m): res = [] while True: if not res: res = [0, 1] res.append((res[len(res)-1] + res[len(res)-2])%m) if res[len(res)-1] == 1 and res[len(res)-2] == 0: break return len(res) - 2 def calc_fib(n): ...
926e7dcda8806a6cdc934a7ef2cd8570dc56ab49
ba-java-instructor-zhukov-82/ma-python-course-module-seven
/labs/work_7_1/work_7_1_3/solution_7_1_3.py
609
3.65625
4
# import all data from Lab 2 from labs.work_7_1.work_7_1_2.solution_7_1_2.buildings import * # Create object for yellow brick with 200 as initial quantity brick = Building('brick', 'yellow', 200) # Create object for red plank with 10 as initial quantity plank = Building('plank', 'red', 10) # Print objects variables p...
fb891b2019d58f1e97d3cb652294f50f9e108e6e
alciomarhollanda/PythonScript
/Recurção_Contagem.py
363
3.765625
4
def contagem(n): print(n) if n== 0: return else: contagem(n-1) def fatorial(n): print(n) if n==0 or n==1: return 1 else: return n* fat(n-1) def fibonaci(n): a, b = 0, 1 while a < n: print(a, end=' ...
c7d99b39a0557d62a59e5607c9620f2bcfcab248
eshanmherath/neural-networks
/perceptron/simple_perceptron_OR_gate.py
2,098
4.15625
4
import numpy as np class Perceptron: def __init__(self, number_of_inputs, learning_rate): self.weights = np.random.rand(1, number_of_inputs + 1)[0] self.learning_rate = learning_rate """A step function where non-negative values are returned by a 1 and negative values are returned by a -1""" ...
13638079a172cc588d8fa4b3b8391301b230d4b8
HanfeiChen/ling575k
/hw1/main.py
696
3.75
4
import argparse from vocabulary import Vocabulary if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("--text_file", type=str, default="/dropbox/20-21/575k/data/toy-reviews.txt") parser.add_argument("--output_file", type=str, default="toy-vocab.txt") parser.add_argument(...
c02c02fd344549fc4cda63bba9ea525cdd30c151
mahinhasan56/python-sqlite
/Extract.py
541
4.3125
4
import sqlite3 with sqlite3.connect("users.db") as db: cursor =db.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS user (userID INTEGER PRIMARY KEY,username VARCHAR(20) NOT NULL, firstname VARCHAR(20) NOT NULL, surname VARCHAR (20) NOT NULL, password VARCHAR(20)NOT NULL );''') cursor.execute("""IN...
7737125c7542777ae0ffbe77c72cdb73d14b1a7b
shikhar-j/Code-Snippets
/inplacequicksort.py
573
4.03125
4
def quicksort(array): inplacesort(array, 0, len(array) - 1) def inplacesort(array, left, right): if len(array) < 2: return array pivot = array[(left + right) / 2] l = left r = right while l <= r: while array[l] < pivot: l += 1 while array[r] > pivot: ...
e347dab6cada8dfd16b370d9f40f3b590b949a2e
tvocoder/learning_python
/python_functional_programming.py
1,191
4.59375
5
# Functional Programming print("---= Functional Programming =---") print("--= Map =--") # Description: Applies function to every item of an iterable and returns a list of the results. # Syntax: map(function,iterable[,...]) # -- function: Required. A function that is used to create a new list. # -- iterable: Required. ...
304598e5e382fad84021f4a95d5a395b957a4456
tvocoder/learning_python
/python_callable_func.py
2,317
4.5
4
print("---= Callables Operators =---") print("-- *(tuple packing) --") # Description: Packs the consecutive function positional arguments into a tuple. # Syntax: def function(*tuple): # -- tuple: A tuple object used for storing the passed in arguments. # All the arguments can be accessed within the function body the s...
ba24202645f4d37ce9aab7e180883fe6f9260737
fletch22/stock-predictor
/utils/random_utils.py
403
3.78125
4
import random def select_random_from_list(the_list: list, number_needed): if len(the_list) < number_needed: raise Exception("The number needed is greater than the size of the list") cloned = the_list.copy() items = [] for i in range(number_needed): list_length = len(cloned) random_num = random.r...
cdd223a49661cf0e9070ebc66127e837ad03bc67
addig/python_practice
/int_anagramcheck.py
575
3.78125
4
def checkAnagram(s1,s2): """ :param s1: string 1 :param s2: string 2 :return: n=boolean """ import re s1 = s1.replace(" ",""). """ s1 = re.sub(" +","",s1).lower() s2 = re.sub(" +","",s2).lower() if len(s1) == len(s2): l1 = set([x for x in s1]) l2 = set([x f...
331a926322bc4093a252a6808ef78a86b774aef1
addig/python_practice
/list_comprehension.py
873
3.515625
4
# if __name__ == '__main__': # n = int(raw_input()) # arr = map(int, raw_input().split()) # arr.sort() # flag = 1 # a = arr.pop() # while (flag == 1): # b = arr.pop() # if (b< a): # flag = 0 # print (b) # else: # a= b # # #print (ma...
f5195d5b823b673e5299d8fffaa5c5181848f0dd
addig/python_practice
/leetcode_palindrome.py
1,065
3.546875
4
class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ def checkPalindrome(ss): ln = len(ss) half = ln /2 mid = ln%2 if mid == 1: if ss[0:half] == ss[half+1:][::-1]: ...
4101cd0f09dafdb48c3d80a90cc77f51f49d1898
FHNW-RW/ip5-metriken-bauwesen
/src/analysis/feature_engineering/general.py
529
3.578125
4
from pandas import DataFrame import src.package.consts def drop_lessthan(df: DataFrame, min_values: int): """ drops usage types with less than specified elements """ df = df.groupby(src.package.consts.NOM_PRIMARY_USAGE).apply(__add_usage_count) df.drop(df[df['object_per_usagetype'] < min_values].index, i...
a95c71ba76141a4746d5b9996ae760bd544da502
Python-aryan/Hacktoberfest2020
/Python/crc.py
1,214
3.828125
4
# Python program to generate CRC codeword from math import log, ceil def CRC(dataword, generator): dword = int(dataword, 2) l_gen = len(generator) # append 0s to dividend dividend = dword << (l_gen - 1) # shft specifies the no. of least significant # bits not being XORed ...
916737d6c227aa54a139a78cec0ce722783c9402
Python-aryan/Hacktoberfest2020
/Python/DisplayCalendar.py
105
3.984375
4
import calendar yy=int(input("Enter year:")) mm=int(input("Enter month:")) print( calendar.month(yy,mm))
0fbdc598ca9dda1aebfee1273c384d9810b32593
Python-aryan/Hacktoberfest2020
/Python/TriangleArea.py
144
4
4
B=int(input("Enter the base length of the triangle")) H=int(input("Enter the height of the triangle")) area = B*H/2 print("The area is ",area)
cd187d5e6e17db7845fbcb692cf2b9e7ce49a1d3
Python-aryan/Hacktoberfest2020
/Python/fibonacci_recursive.py
233
3.890625
4
def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) if __name__ == "__main__": for i in range(10): print('Fibonacci for {} is {}'.format(i, fib(i)))
44a8b21a4c9e2053d2a76a75d7a62433e1546516
Python-aryan/Hacktoberfest2020
/Python/Crossword-Generator.py
1,189
3.8125
4
#!/usr/bin/env python3 import sys [A, B] = sys.stdin.read().split() for letter in A: if letter in B: # x and y values for where the words intersect each other for the first time x = A.index(letter) # x is where B intersect A y = B.index(letter) # y is where A intersects B break ...
52633c588e2a6f1c017773aecf57e5666b5dd2d4
Python-aryan/Hacktoberfest2020
/Python/Fool's_Day_2014.py
279
3.84375
4
def foolsDay(problems): answer = [] for problem in range(problems): total = 0 numbers = raw_input().split() for num in numbers: total += int(num)*int(num) answer.append(str(total)) print(' '.join(answer)) foolsDay(input())
658c711767cba340196597ba6658f855293cf73e
Python-aryan/Hacktoberfest2020
/Python/leap_year.py
253
4.125
4
def leapyear(year): if year % 4 == 0: print("Its a leap year") elif year % 100 == 0: print("Its a leap year") elif year % 400 == 0: print("Its a leap year") else: print("Its not a leap year") year = int(input("Enter a Year")) leapyear(year)
5f959dc8368b61ab68efbaf5faec1a2327dbb537
Python-aryan/Hacktoberfest2020
/Python/quadratic-equation-solver.py
544
4.09375
4
# This python code can be used to solve the quadratic equations, when the values of a, b, c are given as inputs. import cmath; print("Enter 'x' for exit."); n1 = input("Enter value of a: "); if n1 == 'x': exit(); else: n2 = input("Enter value of b: "); n3 = input("Enter value of c: "); num1 = float...
d17d62faaec5fab6a8eebbb41d9011ebd6023420
Python-aryan/Hacktoberfest2020
/Python/the_game_of_loss.py
12,202
3.78125
4
import time import sys import random def printOut(m): l = list(m) for i in range(0, len(l)): print(l[i], end='', flush=True) time.sleep(0.01) print() def house(): # House global cuts global ankle global sprainedWrist inHouse = 1 printOut("\nYou step into the hallway...
a5f063305ea71373959c370edccb50f8a6df87d2
Python-aryan/Hacktoberfest2020
/Python/NumberGuessingGame.py
397
3.984375
4
import random n = random.randint(1,20) guess = 0 count = 0 while guess != n and guess != "exit": guess = input(" Your guess?") if guess == "exit": break guess = int(guess) count += 1 if guess < n: print("Too low!") elif guess > n: print("Too high!") else: ...
2690b3fb0d1b3339f9b29f8c5c81638c0eefb682
Python-aryan/Hacktoberfest2020
/Python/sum of list-elements.py
287
4.25
4
#Calculates the sum of a list of numbers number = int(input("Enter number of elements: ")) elements = [] for i in range(number): x = int(input("Enter {} number: ".format(i+1))) elements.append(x) sum=0 for i in elements: sum=sum+i print("Sum of the list elements is: ",sum)
280cd46ab17dc654e727b2f4380090b585828611
Python-aryan/Hacktoberfest2020
/Python/count prime.py
645
3.96875
4
""" Description: Count the number of prime numbers less than a non-negative number, n. """ class Solution(object): def countPrimes(self, n): """ :type n: int :rtype: int """ t = [True for i in range(n)] i = 2 while i * i < n: if t[i] is False: ...
69d4b8e8a70c524db8adb3b83a13a12e7d7612e3
Python-aryan/Hacktoberfest2020
/Python/greedy_activity_selection.py
2,755
4.0625
4
def interval_scheduling(stimes, ftimes): """Return largest set of mutually compatible activities. This will return a maximum-set subset of activities (numbered from 0 to n - 1) that are mutually compatible. Two activities are mutually compatible if the start time of one activity is not less then the fin...
670336c93bc28640ae409c4f5fcc8f57056dea4b
Python-aryan/Hacktoberfest2020
/Python/mergesort.py
519
3.84375
4
import random def mergesort(x): if len(x) < 20: return sorted(x) r = [] mid = int(len(x) / 2) y = mergesort(x[:mid]) z = mergesort(x[mid:]) i = 0 j = 0 while i < len(y) and j < len(z): if y[i] > z[j]: r.append(z[j]) j += 1 else: ...
c3164036143785ff5d45ee1e59d9509d1c9c27b0
Python-aryan/Hacktoberfest2020
/Python/AreaOfSquare.py
56
3.53125
4
h = float(input("Input length of side: ")) print(h * h)
738730320ac9682073cc228a63ccf43f3ba4a3c0
Jyothi1221/DSP
/sine_wave.py
260
3.578125
4
import matplotlib.pyplot as plot import numpy as m f=input("enter the value") fs=input("enter the value") n=m.arange(0,10,0.25) A=m.sin((2*m.pi*f*n)/fs) plot.plot(n,A) plot.title("sine wave") plot.xlabel("---->time") plot.ylabel("---->Amplitude") plot.show( )
c3c5c55a6f859343c84fcfe6ec02e28edbd0b218
NataTimos/CS50-Python
/mario-more.py
525
3.890625
4
from cs50 import get_int while True: height = get_int("Give me a pyramid's height, please\n") if height >= 1 and height <= 8: break h = height for i in range(h): #first pyramid spaces for k in range (h - i - 1): print(" ", end="") #first pyramid # for j in ...
ee47db8509404d2ca13dc394fe572aa6775b18dc
Mridani-Dwivedi/dictionaries
/invert_dict.py
426
3.828125
4
#histogram of dictionary def f(word): d={} for char in word: if char not in d: d[char]=1 else: d[char]=d[char]+1 #print(d) return d a=f("mridani.dwivedi") print(a) #print item of dictionary def print_f(a): for item in sorted(a): print(item,a[item]) print_f(a) #print dictionary val...
5c87c39d8debf03d084fa307c5e89812611bb067
dyq-w/learn_python
/bankCus.py
758
3.609375
4
import queue #队列对象模块 import threading import time import random q = queue.Queue(5) #创建一个管道对象 #银行业务窗口 def worker(): while True: task = q.get() #从队列对象中取值,计数器加1 print(f'\n第{task}个顾客到窗口办理业务。') t=random.randint(3,6) time.sleep(t) q.task_done() #给队列对象反馈任务完成,计数器减1 print(...
bb62b6e47c6d5606a253690c003d9b72b6aea79e
docljn/python-self-study
/wesleyan_intro/module_3/name_phone.py
925
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 28 15:48:51 2018 @author: DocLJN """ import sys import csv # open the csv file here filename = sys.argv[1] file = open(filename, 'w') while True: nextname = input("Enter a friend's name, press return to end: ") if nextname == "": ...
910ba7384503ead042945e33c9c1c48160d59003
Lxunrui/python-learn
/python-opp/ch3/list_basic.py
360
4.125
4
# 两种数据结构:列表和元组 # 列表的创建 a = [1,2,3,4] # 列表里面的元素的数据类型可以是任意的。例如 b = [1,'asd',2.0,['a','b','c']] print(a) print(b) # 列表元素的访问 print('a[0]=',a[0],a[1]) # b[a:b] a代表第几个 b-a代表到第几位 c = b[1:3] print(c,type(c)) s = 'asdzxc' print(s[1:2],s[-1]) print(b[-1])
8e492b30811ad57dac107825e994b6e30ee24390
ArunJayan/MicrohopeTrainingProgram-ICFOSS
/Python/chapter1/example1.py
253
3.578125
4
# example1.property # This example will print "Hello World " message using 'print' print "Hello World" print "IEEE " print "ICFOSS" print "My Name is %s"%("Arun") #this will show "My Name is Arun" print "%d+%d=%d"%(23,55,23+55) #this will show 23+55=78