blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
7f17dd1d0b9acc663a17846d838cbd79998bb79b
antoinemadec/test
/python/programming_exercises/q6/q6.py
840
4.21875
4
#!/usr/bin/env python3 print("""https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt Question: Write a program that calculates and prints the value according to the given formula: Q = Square root of [(2 * C * D)/H] Follow...
c1679cb04b4e70b555eaf1c35f5dd7ee8d5927f8
antoinemadec/test
/python/asyncio/coroutines_and_tasks/coroutines.py
1,304
4.40625
4
#!/usr/bin/env python3 import asyncio import time # coroutine async def main(): print('hello') await asyncio.sleep(1) print('world') # coroutine async def say_after(delay, what): await asyncio.sleep(delay) print(what) # coroutine async def main_after(): print(f"started at {time.strftime('%X'...
8b7441422b1b4d979cb4587406749784f71049e6
antoinemadec/test
/advent_of_code/2021/day3/part2/main.py
4,368
3.671875
4
#!/usr/bin/env python3 # --- Part Two --- # Next, you should verify the life support rating, which can be determined by multiplying the oxygen generator rating by the CO2 scrubber rating. # Both the oxygen generator rating and the CO2 scrubber rating are values that can be found in your diagnostic report - finding th...
d057707ccd873e895d2caf5eec45a19e0473da84
antoinemadec/test
/python/codewars/find_the_divisors/find_the_divisors.py
708
4.3125
4
#!/usr/bin/env python3 """ Create a function named divisors/Divisors that takes an integer and returns an array with all of the integer's divisors(except for 1 and the number itself). If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell and Result<Vec<u32>, String>...
81cc9b7d03933d990e1a90129929d1eb78ffb108
antoinemadec/test
/python/cs_dojo/find_mult_in_list/find_mult_in_list.py
526
4.1875
4
#!/bin/env python3 def find_multiple(int_list, multiple): sorted_list = sorted(int_list) n = len(sorted_list) for i in range(0,n): for j in range(i+1,n): x = sorted_list[i] y = sorted_list[j] if x*y == multiple: return (x,y) elif x>mu...
c612b7453607334f31e3a02e3e3c8e70f46ff883
antoinemadec/test
/python/programming_exercises/q1/q1.py
516
4.03125
4
#!/usr/bin/env python3 print("""https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt Question: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both...
ce349e0d877be430c57a4a11990ac1cdf6096847
GreatRaksin/Saturday3pm
/1505_functions_p4/01_functional_programming.py
639
4.25
4
'''Функциональный код отличается тем, что у него отсутствуют побочные эффекты. Он не полагается на данные вне функции и не меняет их. ''' a = 0 def increment1(): '''Вот это НЕ функциональный код''' global a a += 1 def increment2(a): '''А это функциональный''' return a + 1 nums = ['0', '1', '2',...
9ce9cae0ad0c987af279b462faba473185d4d65a
GreatRaksin/Saturday3pm
/2410/task2.py
177
3.609375
4
d = {} m_s = input('ведите строку: ') for symbol in m_s: keys = d.keys() if symbol in keys: d[symbol] += 1 else: d[symbol] = 1 print(d)
dccd7773b922a87a703647f107feb6cecbbea153
GreatRaksin/Saturday3pm
/1505_functions_p4/05_zip_function.py
545
3.765625
4
a = ['one', 'two', 'three', 'four'] b = [1, 2, 3, 4, 5] # (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, None) res = list(zip(b, a)) print(res) cars = ['Audi', 'BMW', 'Mercedes', 'Honda', 'Mazda', 'VW'] men = ['John', 'Noah', 'Sarah', 'Mike', 'Jacob', 'Bob', 'Bill'] cars_of_men = dict(zip(men, cars)) #for ke...
1cbd89b34fc28fdfc949fc7b48b363df817adf71
GreatRaksin/Saturday3pm
/1704_functions_2/02_stars_and_functions.py
844
4.25
4
def multiply(n, n1, n2): print(n * n1 * n2) fruits = ['lemon', 'pear', 'watermelon', 'grape'] # ТАК НЕ НАДО: print(fruits[0], fruits[1], fruits[2], fruits[3]) # НАДО ВОТ ТАК: print(*fruits) def insert_into_list(*numbers): l = [] l.append(numbers) return numbers ''' *args - * позволяет передать фу...
d6aabcb1f4476a9d8dbb13844e29227df4db6426
GreatRaksin/Saturday3pm
/task1.py
428
4.4375
4
''' Создать словарь со странами и их столицами Вывести предложение: {столица} is a capital of {страна}. ''' countries = { 'USA': 'Minsk', 'Brazil': 'Brasilia', 'Belarus': 'Washington', 'Italy': 'Rome', 'Spain': 'Madrid' } for country, capital in countries.items(): print(f'{capital} is a Capital of {coun...
59db75499137557f5948c4fd8defc4d78abec538
GreatRaksin/Saturday3pm
/0105_functions_deep/04_lambda_how_to.py
300
3.8125
4
tuples = [(1, 'd', 'яблоко'), (2, 'b', 'ананас'), (4, 'a', 'банан'), (3, 'c', 'молоко')] print(sorted(tuples)) print(sorted(tuples, key=lambda x: x[2])) print(sorted( range(-5, 6), key=lambda x: x * x )) print(sorted((range(-5, 6))))
9a7380cb1128cf75c8be58bbf2c4174d40ed920f
mengqiwangwmq/Fablix
/script.py
376
3.703125
4
import csv import sys if len(sys.argv) < 2: print("Please input the file name.") else: f=[] Nums=[] for i in range(1,len(sys.argv)): f.append(open(sys.argv[i])) nums = csv.reader(f[i-1]) Nums += list(map(lambda x: int(x[0]), nums)) avg = sum(Nums) / len(Nums) print("The ...
8998c4a05f6317c43a237fd740f045b5b04cbc5c
xiaozhi521/PythonLearn
/venv/Scripts/com/def/DefTest.py
431
3.515625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #import __init__; #__init__.printme("111") Money = 2000 def AddMoney(): # 想改正代码就取消以下注释: global Money Money = Money + 1 print Money AddMoney() print Money import math content = dir(math) print content; print locals() # 返回的是所有能在该函数里访问的命名 print globals() # 返回的是...
34aa31e4c1c628ce803286f17b33d12ecf121326
xiaozhi521/PythonLearn
/venv/Scripts/com/date/DateTest.py
1,247
3.96875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import time; # 引入time模块 current_time = time.time() print current_time #时间间隔是以秒为单位的浮点小数 clock = time.clock() localtime = time.localtime() print localtime # time.struct_time(tm_year=2018, tm_ mon=11, tm_mday=28, tm_hour=9, tm_min=46, tm_sec=59, tm_wday=2, tm_yday=332, tm_...
610fc98daa812d395424ea4b15e6207898390971
pedroinc/hackerhank
/diagonal-difference.py
768
3.90625
4
#!/bin/python3 import sys def sum_list(m_list): m_sum = 0 for item in m_list: m_sum = m_sum + item return m_sum def diagonal_difference(matrix): diagonal_a = [] diagonal_b = [] interval = len(matrix) - 1 counter = 0 for row in matrix: diagonal_a.append(row[counter]...
8abb6ea031bc6704ad7f086b8dc9f2da79210040
pedroinc/hackerhank
/catsandamouse/test_catsandamouse.py
1,494
3.578125
4
#!/bin/python3 import unittest from catsandamouse import CatsAndMouse class TestCatsAndMouse(unittest.TestCase): def test_cat_a_and_cat_b_from_position_1_mouse_escapes(self): cats_and_mouse = CatsAndMouse(cat_a=1, cat_b=1, mouse_c=4) self.assertEqual(cats_and_mouse.get_answer(), 'Mouse C') de...
ca298fbbff9313d62c867a6a8b5cc9e3511d7e05
pedroinc/hackerhank
/staircase.py
280
4.15625
4
#!/bin/python3 import sys def staircase(n): for x in range(1, n + 1): if x < n: remain = n - x print(remain * " " + x * "#") else: print(x * "#") if __name__ == "__main__": n = int(input().strip()) staircase(n)
0a9ca9e3708b317926040565b79182ad3a03bb01
BarsTiger/LazyMath
/NumeralSystemConverter/NumeralSystemConverter.py
1,584
3.921875
4
print("©KOTIKOT, script by BarsTiger") print() print("Please, type only int numbers, str is allowed only in hex") print("To change system, press Ctrl+C or close window and rerun program with new settings") hextonum = { "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, ...
745e6de4ca33b07a7f8f0cdeb273a60d9fa9f173
efecntrk/python_programming
/unit-1/problem6.py
154
3.65625
4
breakfast = ['Wheaties', 'Fruitloops', 'Eggs', 'Toast'] def cereal_times(): for names in breakfast: print(names + 'are yummy!') cereal_times()
f7b1305a7baa9b2e13c21a69f2229ea0a0026a7f
efecntrk/python_programming
/unit-1/problem1.py
219
4.1875
4
''' for i in range(3): print('Hello World ! ') ''' statement = 'Homework is fun!!!' num = 3 #loop to print statement num number of times ''' for i in range(num): print(statement) ''' print(statement * num)
14b215cd4bbf1eba8ad00724c8612941cf234650
efecntrk/python_programming
/unit-1/variables.py
786
4.1875
4
''' #place a name and give a value #integer age = 27 #float gpa = 3.0 #boolean has_kids = True #check the type of a variable print(type(age)) #This function tell what type of data it is print(type(gpa)) print(type(has_kids)) ''' #check if a number is even ''' number = 10 if number % 2 == 0: print('It is even!...
802923170e4f18b607178174853bd27fee48cfe5
DucMyPham/c4t18
/Session8/jumble.py
393
4.09375
4
import random words = ('cake', 'cookie', 'candy', 'pie') word = random.choice(words) correct = word jumble ="" while word: position = random.randrange(len(word)) jumble += word[position] word = word[:position] + word[(position +1):] print("The jumble is: ", jumble) guess = input("Ur guess is: ") if guess ==...
448caf7ff7b96d3cb959c6181973bf03852fca79
DucMyPham/c4t18
/session7/capitalize_name.py
75
3.6875
4
name = input("Enter your name: ") upperName = name.upper() print(upperName)
3cfd26a1913ad3145268abf48374727a7924d9fe
DucMyPham/c4t18
/session7/even_check.py
101
4.21875
4
n = int(input("Enter n: ")) if n%2 !=0: print("Number is odd") else: print("Number is even")
278a909c2c5f20216c709495c3827924de8d5825
ClaushWong/python-projects
/Data Related/dataEncrypt.py
4,421
3.53125
4
text = open("text.txt","a+") name = raw_input("Username : ") pwd = raw_input("Password : ") idx = list(pwd) #ENCRYPR for x in range(len(idx)): #NUMERIC ENCRYPT ( if b % 2 == 0 , then c = 1 ; if b % 2 == 1 , then c = 2 ) if idx[x] == "1": idx[x] = "a1b1c2" elif idx[x] == "2": ...
966866e3e68fdb22b9d45148bee7b4e15ec7a4b7
CH-Miguel/Infijo_Posfijo_Python
/Conversion_Infijo_Posfijo/Metodos.py
3,440
3.890625
4
#Clase con métodos y atributos de una pila. class Metodos: #Listas para definir si el valor a evaluar es un número, letra o operador. letras = list ('ABCDEFGHIJKLMNOPQRSTUVWXYZ') numeros = list ('0123456789') #Atributos de una pila tamaño = 0 #Tamaño máximo de la pila pila = [] t...
42c16066dcf6a37d0ac8e9a20f6a278bf342d0de
CharlesBird/Resources
/coding/py_partterns/behavioral/mediator/inventory.py
2,851
3.765625
4
"""模拟进销存管理""" import abc import random class AbstractCollegue(abc.ABC): def __init__(self, mediator): self.mediator = mediator class Purchase(AbstractCollegue): def buyIBMcomputer(self, num): self.mediator.execute("purchase.buy", num) def refuseBuyIBM(self): print("不再采购ibm电脑...
f48b77414687a701faeceebb4e3ec98421b9ade5
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0209-Minimum-Size-Subarray-Sum.py
861
3.703125
4
""" Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead. Example: Input: s = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: the subarray [4,3] has the minimal length under the problem constraint. ""...
1ee1cc8c9b0b2f0772f03f5ddab2539d579fedee
CharlesBird/Resources
/coding/py_partterns/behavioral/chain/currency.py
1,292
3.8125
4
import abc class Handler(abc.ABC): def __init__(self, successor=None): self._successor = successor def handle(self, request): rs = self._handle(request) if not rs: self._successor.handle(request) @abc.abstractmethod def _handle(self, request): pass clas...
44f3a7888d5feb1ee0f524878390cd4ebfbb6f6f
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0130-Surrounded-Regions.py
3,281
4.125
4
""" Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. Example: X X X X X O O X X X O X X O X X After running your function, the board should be: X X X X X X X X X X X X X O X X Explanation: ...
c1ed881ab55b57bd72e83d13d2d1160cb328efa6
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0019-Remove-Nth-Node-From-End-of-List.py
828
3.875
4
""" Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. """ # Definition for singly-linked list. class ListNode: ...
00ae696eb534c2e31bc0373bcfd1a7b618d20048
CharlesBird/Resources
/coding/py_partterns/behavioral/template/make_car.py
1,091
3.765625
4
import abc class HummerModel(abc.ABC): @abc.abstractmethod def start(self): pass @abc.abstractmethod def stop(self): pass @abc.abstractmethod def alarm(self): pass @abc.abstractmethod def enginBoom(self): pass def run(self): self.start()...
eb7354f374ac6c77a122ee38b0229bc03ef770a6
CharlesBird/Resources
/coding/Algorithm_exercise/SortMethod/shell.py
624
3.53125
4
# 希尔排序 def shellSort(myList): list_len = len(myList) dk = list_len // 2 while dk >= 1: for i in range(dk, list_len): preIndex = i - dk current = myList[i] while preIndex >= 0 and myList[preIndex] > current: myList[preIndex+dk] = myList[preIndex] ...
8f89723e09b7cf434667fcbff0d14aaf6aa46113
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0139-Word-Break.py
3,094
4.09375
4
""" Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Note: The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not...
df7c17eb21be30b6dd929d8ff4b035190569e244
CharlesBird/Resources
/coding/Algorithm_exercise/SortMethod/heap.py
2,137
3.796875
4
# 堆排序 import math # 画树形结构 def printTree(myList): index = 1 depth = math.ceil(math.log2(len(myList))) # 因为补0了,不然应该是math.ceil(math.log2(len(array)+1)) sep = ' ' for i in range(depth): offset = 2 ** i print(sep * (2 ** (depth - i - 1) - 1), end='') line = myList[index:index + offs...
ea03b55d52a9ebf31ccfa03ac14c5b86c4975848
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0322-Coin-Change.py
2,157
3.953125
4
""" You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. Example 1: Input: coins = [1, 2, 5], amount = 11 Out...
fc53747bcaea1083e45e5fccd32cf7e0e0cae589
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0052-N-Queens-II.py
1,054
3.796875
4
""" The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle. Example: Input: 4 Output: 2 Explanation: There are two distinct solutions to the 4-queens puzzle as shown belo...
b3f654665c353ca0192af767791d9ed7375bae64
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0435-Non-overlapping-Intervals.py
1,208
4.34375
4
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals are non-overlapping. Example 2: Input: [[1,2],[1,2],[1,2]...
c07d58ce5cb17d5667e5bfd4780652113aa1df49
CharlesBird/Resources
/coding/py_partterns/structual/composite.py
964
3.828125
4
"""组合模式,部分-整体,tree结构的表现""" class Graphic(object): def render(self): raise NotImplementedError("继承类。") class CompositeGraphic(Graphic): def __init__(self): self.graphics = [] def render(self): for graphic in self.graphics: graphic.render() def add(self, graphic...
28aedd62fdb66cd1acd97dc465368ac7d40b9d0d
CharlesBird/Resources
/MachineLearning/LinearAlgebra/01-Vectors/vector.py
2,232
3.921875
4
class Vector: def __init__(self, lst): self._values = list(lst) @classmethod def zero(cls, dim): """返回一个dim维的零向量""" return cls([0] * dim) def __add__(self, another): """向量加法,返回结果向量""" assert len(self) == len(another), \ "Error in adding. Length of v...
bf2eeed3892c0b287a393c6f0f3a3e46845b6f8c
CharlesBird/Resources
/coding/py_partterns/structual/flyweight.py
806
3.640625
4
"""享元模式, 避免相同对象的创建,减少内存占用""" import weakref class Card(object): _CardPool = weakref.WeakValueDictionary() def __new__(cls, value, suit): obj = Card._CardPool.get(value+suit) if not obj: obj = object.__new__(cls) Card._CardPool[value+suit] = obj obj.value...
d75438ff87239179cca920147af71e2f6efa3f37
CharlesBird/Resources
/coding/Algorithm_exercise/Leetcode/0077-Combinations.py
1,180
3.703125
4
""" Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] """ class Solution: def combine(self, n: int, k: int) -> "List[List[int]]": def dfs(nums, k, path, res): ...
fba0069acab41c4b433d6bba0d7d2aa59e2d7d43
Rydel-16/Practica_LabChalque
/Preg01.py
603
3.78125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 9 17:26:56 2020 @author: Rhisto Zea """ def primos(numero): c=0 if int(numero) < 1: validar = "Numero no valido." return validar elif numero == 2: validar = "No es primo." return validar else: for i...
e40bd786dc259f1ffc2ec40994f05d2b01e3951f
Only6/RPi-GPIOChanger
/main.py
3,089
3.546875
4
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) print("Version: 0.2 (Alpha)") print("Support Raspberry Pi: Zero") pin = 0 stan = "" WybranyJezyk = input("Select language (en/pl)\n") while True: if(WybranyJezyk == "pl" or WybranyJezyk == "PL"): WybranyPin = int(input("Wybierz pin\n")...
f093c81595e0ea6e67bad6f04c8e074922504fb7
rajanmidun/Python
/1 Basic Python/14-Operator in Python.py
446
3.9375
4
a=67 b=556 #arithmetic operators sum=a+b; print(sum) diff=a-b; print(diff) mul=a*b; print(mul) div=a/b; print(div) rem=a%b; print(rem) #Relational Operator print(a==b) print(a>=b) print(a<=b) #assignment operator a=b print(a) a+=10 print(a) b-=3 print(b) b*=3 print(b) a/=4 print...
46afe44c60c244e17c4c3bc0f16865a4d13e29e5
cosmic-byte/fee-calc
/fee_calculator/apps/core/calculator.py
3,152
3.546875
4
from fee_calculator.apps.core import constants class LoanApplication: def __init__(self, tenure: int, loan_amount: float): self.tenure = tenure self.loan_amount = loan_amount self.loan_fee = 0 class FeeCalculator: def __init__(self, application: LoanApplication): self._loan_a...
7344de70306abd5d4869f1ae83d477bb763e9b6c
Fornar/The-Self-Taught-Programmer-The-Definitive-Guide-to-Programming-Profession
/Уроки/Часть III. Введение в инструменты программирования/Глава 17. Практикум.py
943
3.75
4
# Первое задание import re zen = """ Ошибки никогда не должны замалчиваться. Если не замалчиваются явно. Встретив двусмысленность, отбрось искушение угадать. Должен существовать один = и, желательно, только один - очевидный способ сделать это. Хотя поначалу может быть и не очевиден, если вы не голландец. """ print(re.f...
f9a5c3db5c621c7d76c49a7c9556d12eec7ff879
Fornar/The-Self-Taught-Programmer-The-Definitive-Guide-to-Programming-Profession
/Уроки/Часть I. Введение в програмирование/Глава 9. Файлы.py
5,492
4.125
4
# Файлы print("Файлы".upper()) # С помощью Python можно считывать данные из файла и записывать данные в файл. # Основы работы с файлами #================================================================================================================================= # Запись в файлы # Чтобы избезать проблем с работой в...
5528e4865af39c5dc69f6a0848453af69bbf4f16
Fornar/The-Self-Taught-Programmer-The-Definitive-Guide-to-Programming-Profession
/Уроки/Часть I. Введение в програмирование/Глава 5. Пробная программа из списков.py
1,762
4.0625
4
# Пример использования списка на практике for i in range (5): if input("Начать?: ") == "да": favorite_colors = ["чёрный", "сочетания цветов", "синий"] favorite_number = ["27"] for i in range (3): if input("Назови любимый цвет Саши: ") in favorite_colors: print("Мо...
58024409d09db91a54272cccc9ef457def06c8c3
Fornar/The-Self-Taught-Programmer-The-Definitive-Guide-to-Programming-Profession
/Уроки/Часть II. Введение в объектно-ориентированное программирование/Глава 14. Практикум.py
548
4.0625
4
# Первое и второе задание class Square(): square_list = [] def __init__(self, s): self.s = s self.square_list.append(self) def __repr__(self): return "{} на {} на {} на {}".format(self.s, self.s, self.s, self.s) a_square1 = Square(27) a_square2 = Square(10) a_square3 = Squa...
844fdb4f7512190d86156c1adf16d76913611729
venukumarbv/PythonPatternPrinting
/Alphabets/I.py
300
3.75
4
''' * * * * * * * * * * * * * * * ''' for row in range(7): for col in range(5): if row in {0, 6}: print('*', end=' ') elif (row in range(1, 6)) and col == 2: print('*', end=' ') else: print(' ', end= ' ') print()
8889ac20a1c91a9053dee600ec40fe9a484eedbd
venukumarbv/PythonPatternPrinting
/Hallow_Diamond/Top_Half_Hallow_Diamond/1.py
278
3.71875
4
''' 5 * * * * * * * * * ''' n = int(input()) for i in range(n): print(' ' * (n - i - 1) + '* ', end='') # Two spaces if i >= 1: # From Second row onwards print(' ' * (2 * i - 1) + '*', end='') print()
c3d86f3fc8e8b45b92bb08fd790fe5b7eb317045
venukumarbv/PythonPatternPrinting
/Alphabets/G.py
473
3.671875
4
''' * * * * * * * * * * * * * * * * * ''' for row in range(7): for col in range(5): if (row in {0, 6}) and (col in {1, 2, 3}): print('*', end=' ') elif (row in {1, 4, 5}) and (col in {0, 4}): print('*', end=' ') elif row == 2 and col == 0: ...
6075e33610a6c725fb1571a08f8bbb3c610c4b1f
venukumarbv/PythonPatternPrinting
/Alphabets/T.py
287
3.796875
4
''' * * * * * * * * * * * ''' for row in range(7): for col in range(5): if row == 0: print('*', end=' ') elif row in range(1,7) and col == 2: print('*', end=' ') else: print(' ', end=' ') print()
3f8661aba7a8379bb65ca61d7b59bb3039910711
venukumarbv/PythonPatternPrinting
/Left_Half_Diamond/2.py
348
3.546875
4
''' 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 ''' n = int(input()) for i in range(n): print(' '*(n-i-1),end='') for j in range(i+1): print(j+1, end=' ') print() for i in range(n-1): print(' '*(i+1),end='') for j in range(n-i-1): pri...
dc10403cd5efa4ca4e1cd278027fdfad22a959ab
venukumarbv/PythonPatternPrinting
/Alphabets/W.py
408
3.796875
4
''' * * * * * * * * * * * * * * * * * ''' for row in range(7): for col in range(5): if row not in {4, 5} and col in {0, 4}: print('*', end=' ') elif row == 4 and col in {0, 2, 4}: print('*', end=' ') elif row == 5 and col != 2: ...
f94fc675686fdc587ec1b3651e68730e1994e0c3
BaronDaugherty/DailyProgrammer
/Challenge 16/c16_easy.py
981
4.03125
4
''' Daily Programmer Challenge 16 : Easy @author: Baron Daugherty @date: 2015-06-23 @desc: Write a function that takes two strings and removes from the first string any character that appears in the second string. For instance, if the first string is "Daily P...
8bb18b95fd9027d2a6b034be8e661f9cfe15fb84
BaronDaugherty/DailyProgrammer
/Challenge 226/c226_e.py
2,456
4.03125
4
''' Daily Programmer Challenge 226 : Easy @author: Baron Daugherty @date: 2015-09-20 @desc: For today's challenge, you will get a list of fractions which you will add together and produce the resulting fraction, reduced as far as possible. ''' # main drives t...
86f2e607b8f74fa172beaf6a893df66d4ce6c045
BaronDaugherty/DailyProgrammer
/Challenge 27/c27_easy.py
809
4.15625
4
''' Daily Programmer Challenge 27 : Easy @author: Baron Daugherty @date: 2015-07-20 @desc: Write a program that accepts a year as input and outputs the century the year belongs in (e.g. 18th century's year ranges are 1701-1800) and whether or not the year is ...
7adecc048560899c93be77d605fed0e44166aecd
mtl-lan/python-notebook
/class4homework_reach_my_csv_reader.py
862
3.90625
4
# Check if the boston housing dataset file path is really a file. # If it is print "I have a file to process", otherwise print "Boo, no file for me." # Read the boston housing dataset file # Print the dataset line by line # Modify this script by printing each line as a list of values. # Example: The line:abc,cde,efg,1,...
250d57d467c35b49404a444404ad19c6bbc4617e
dmaydan/UNO-and-Miscellaneous-Python-Programs
/DinoHunt.py
6,793
4.125
4
import random class Die: '''Die class''' def __init__(self,sides=6): '''Die(sides) creates a new Die object int sides is the number of sides (default is 6) -or- sides is a list/tuple of sides''' # if an integer, create a die with sides # from 1 to side...
17214acec10bc5e019a26ab192fb09d3c00af0b2
AllenBigBear/Leetcode
/Leetcode20.py
1,550
3.703125
4
class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ if len(s)%2 !=0: #如果元素个数是单数,直接枪毙 return False if not s: #如果是空字符串,返回True return True a={')':'(', '}':'{', ']':'['} #这题的关键,...
f4b51932d5a217808a2b7f2c540d2eac48144cb4
kurneow/data-analysis
/quora/nearby.py
8,077
3.984375
4
# -*- coding: utf-8 -*- """ Created on Jan 09, 2013 @author: Mourad Mourafiq About: This is an attempt to solve the Quora challenge Nearby. """ import math import heapq THRESHOLD = 0.001 SQUARE_SIDE = 10 class Square(object): """ Square is data structure that represents a part of the plane. A square is...
80299497f71886137c9dd115c8466af583c4444c
kurneow/data-analysis
/similarities/jaccard_similarity.py
3,408
3.609375
4
# ------------------------------------------------------------------------------- # Name: jaccard similarity # # Author: mourad mourafiq # ------------------------------------------------------------------------------- from __future__ import division EX_TUP_1 = ('a', 'a', 'a', 'b') EX_TUP_1 = ('a', 'a', ...
c9a46ae2839f3a32cf29d659b8b00c054e84ea5e
kurneow/data-analysis
/algorithmics/flowers.py
604
3.515625
4
def flowers(): nbr_fl, nbr_fr = [int(x) for x in raw_input().split()] prices = [float(x) for x in raw_input().split()] prices.sort() amount = 0 x = 0 while nbr_fl: if nbr_fl <= nbr_fr: amount += sum([(1 + x) * c for c in prices[:nbr_fl]]) nbr_fl = 0 else: ...
33ba72388c47db16e223485777e97dae8e0cbcf2
kurneow/data-analysis
/algorithmics/inverse_function.py
1,413
3.765625
4
# ------------------------------------------------------------------------------- # Name: cryptarithmetic # # Author: mourad mourafiq # ------------------------------------------------------------------------------- from __future__ import division def inverse(f, delta=1 / 1024.): """ given a...
c6d164ea8625660ca5177668fde43c5cc5cf9bc5
DrMichaelWang/Data-Project__Stock-Market-Analysis
/Solution.py
22,829
3.71875
4
# coding: utf-8 # ### Stock Market Analysis # #### Goal: use pandas to get stock information, visualize different aspects of it, analyze the risk of a particular stock based on its performance history, and predict future stock prices using Monte Carlo method # #### Basic Analysis of Stock # In[1]: # questions: #...
4b4a1e3ba12966718bc451747a2510d87a52a136
nherson/kenkensolve
/kenken.py
10,828
3.859375
4
############################################################# # A basic KenKen Puzzle solver (v1.0) # # Used Constraint Satisfaction Problem properties # # using N-ary constraints to solve KenKen puzzles # # # # Great fo...
22de48557aeb58d7ee731b40bfc55e9d3540b73b
drewverlee/Course-Projects
/peak_finding/2dpeak.py
3,067
3.984375
4
""" File : 2dpeak.py Author : Drew Verlee Date : 29.06.13. GitHub : https://github.com/Midnightcoffee/ Description : Program and tests for finding peak in a Matrix, inspired by lecture : http://ocw.mit.edu/courses/electrical-engineering-and-computer- science/6-006-introduction-to-algorit...
892ff4de5112fcb9f241bb128680b44e785c56fb
MichalCab/freebase
/src/binary_search.py
638
3.59375
4
#!/bin/env python #-*- coding: utf-8 -*- __author__ = "Michal Cab <xcabmi00@stud.fit.vutbr.cz>" def binary_search(a, x, lo=0, hi=None, cross_columns=False, col_sep=" ", finding_column=0, return_column=1): if hi is None: hi = len(a) while lo < hi: mid = (lo+hi)//2 midval = a[mid] if cross_columns: ...
27bcea29f77c307d0f0e89c9eda990cd4aef8463
MrDebugger/BSLABS
/semester3/lab6/task2.py
4,808
3.890625
4
# Task 2 class Node: def __init__(self,value): self.data = value self.nextNode = None self.prevNode = None def hasValue(self,value): """Search for value in current Node""" return self.data == value def getData(self): """Returns current node data""" return self.data def setData(self,data): """Re...
8608d455b55f0991324cbb02204fdd0c6d83aeeb
MrDebugger/BSLABS
/semester3/lab10/task1.py
732
4.09375
4
# Task 1 class Queue: # a. Create Empty List def __init__(self): self.list = [] # b. List is Empty or Not def isEmpty(self): return ('Yes','No')[bool(self.list)] # c. Add number at index 0 def enqueue(self,number): if number not in self.list: self.list.insert(0,number) return True return False # d....
ac0cee00f50e0adb624a2d1527b78bdf53f556fc
thatguy0999/PythonCodes
/Python2/Ex58.py
694
3.828125
4
month_30 = ['09','04','06','11'] month_31 = ['01','03','05','07','08','10'] leap_year = False date = input('please enter a date ') y, m, d = date.split('-') d = int(d) y = int(y) m = int(m) if (y%400 == 0) or (y%400 != 0 and y%100 != 0 and y%4 == 0): leap_year = True if (m == 2 and d == 28 and not leap_year) or...
c5be537e0182985ed9bf428aed2f9a1d409ae1eb
thatguy0999/PythonCodes
/Python2/Ex45.py
289
4
4
odd = ['a','c','e','g'] column, row = input('please enter a position on the chess board ') row = int(row) if column in odd: if row%2 == 1: print('black') else: print('white') else: if row%2 == 1: print('white') else: print('black')
17804be887ce906939cd1e20403c6057bfddd765
thatguy0999/PythonCodes
/Python2/Ex51.py
344
4.1875
4
grading = { 'A+':4.0, 'A':4.0, 'A-':3.7, 'B+':3.3, 'B':3.0, 'B-':2.7, 'C+':2.3, 'C':2.0, 'C-':1.7, 'D+':1.3, 'D':1.0, 'F':0.0, } while True: grade = input('please enter a grade ') try: print(grading[grade.capitalize()]) break except: ...
7b2bc1678983f9677f028591f0fd3b63c64e49c8
thatguy0999/PythonCodes
/Python2/Ex07.py
92
3.8125
4
n = int(input('enter a positive integer')) addition_sum = (n*(n+1))/2 print(addition_sum)
b463c597a177d4ebfe9401362e168893f36f2749
thatguy0999/PythonCodes
/Python2/Ex41.py
272
4.09375
4
note, octave = input('please enter a note in a certain octave ') octave = int(octave) music = { 'c':261.63, 'd':293.66, 'e':329.63, 'f':349.23, 'g':392.00, 'a':440.00, 'b':493.88, } print(f'the frequency is {music[note]/(2**(4-octave)):.2f}')
a70f43f725383f5a54b56c5e79b0eaceec87fc65
thatguy0999/PythonCodes
/Python2/Ex25.py
219
4.0625
4
time = int(input('please enter any number of seconds')) days = time//(24*60*60) time %= (24*60*60) hours = time//(60*60) time %= (60*60) mins = time//60 time %= 60 print(f'{days}:{hours:0>2d}:{mins:0>2d}:{time:0>2d}')
cea690fa0e1b466e419337686964839f0334c5af
thatguy0999/PythonCodes
/Python2/Ex73.py
222
4.0625
4
word = input('please enter a word ') new_word = '' word = word.replace(' ','') for i in range(len(word)): new_word += word[-(i+1)] if new_word == word: print('palindrome') else: print('not a palindrome')
601cdefdd8c29852709b3a2bb178160b9d30d0f8
thatguy0999/PythonCodes
/Python2/Ex04.py
223
4.03125
4
width = input('what is the width of the field? (in feet)') length = input('what is the length of the field? (in feet)') area = float(width)*float(length) # 1a = 43,560f^2 area_acres = area/43560 print( area_acres, 'acres')
ae6b40a94660f9b36a4e1954bd176acc098b8ca3
Airman-Discord/Python-calculator
/main.py
530
4.25
4
print("Python Calculator") loop = True while loop == True: first_num = float(input("Enter your first number: ")) operation = input("Enter your operation: ") second_num = float(input("Enter your second number: ")) if operation == "+": print(first_num + second_num) elif operation == "-"...
4f3a69e91211989fa6ebf94d0f35ed7607856d6c
beerus11/codeforces
/96A Football.py
96
3.5625
4
string=raw_input() if "0000000" in string or "1111111" in string: print "YES" else: print "NO"
756a0e1b343942fca6142a23b5dfb694f97661fa
598309453/pythoncircle
/aric/99mul.py
634
3.9375
4
# 打印99乘法表 ''' 1. 首先实现 1*1=1 print(1, "*", 1, "=", 1) 连接用逗号,一些非数字符号用引号引起来 2. 实现 1*1=1 1*2=2 for i in range(1, 3): result= 1*i print(1, "*", i, "=", result) 3. 实现 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 ...... \t : 横向制表符, 使格式对齐 end="": 说明打印后跟空格,即下一个打印接着后面输出。默认是换行,会在下一行输出下一个内容 print(""): 表示换行 ''' # for i in r...
31b1cba4c077263757c8f8964d01c6798a476e12
JobQiu/PrototypicalNetwork
/utils/tf_utils.py
1,881
3.515625
4
import tensorflow as tf def euclidean_distance(a, b): """ firstly expand a's shape to be (N, 1, D) and then tile it to be (N, M, D) by copy a M times and then expand b's shape to be (1, M, D) and then tile it to be (N, M, D) by copying b N times then do the element wise minus and squa...
48c49086f159998fd4e29a9b0d6db3ec3a388aa7
alexmcmillan86/python-projects
/indices_array_sum.py
361
3.671875
4
nums = [2, 7, 11, 15] def two_sum(nums: int, target: List[int]) -> List[int]: seen = {} for i, v in enumerate(nums): remaining = target - v if remaining in seen: return[seen[remaining], i] seen[v] = i return print(seen[v], seen[i]) target = int(input("Ent...
96fb4e1c83c2c41d3e23f26da20a5c36af2383ea
alexmcmillan86/python-projects
/sum_target.py
729
4.125
4
# finding a pair of numbers in a list that sum to a target # test data target = 10 numbers = [ 3, 4, 1, 2, 9 ] # test solution -> 1, 9 can be summed to make 10 # additional test data numbers1 = [ -11, -20, 2, 4, 30 ] numbers2 = [ 1, 2, 9, 8 ] numbers3 = [ 1, 1, 1, 2, 3, 4, 5 ] # function with O(n) def...
600333e214218086e3f62c13f9137be1519accef
vivekkrishna/DSANDALGOS
/loopinll.py
2,450
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 3 16:57:45 2017 Finding if there is a loop and starting point of loop. @author: vc185059 """ class node(): def __init__(self,value): self.value=value self.next=None def createalinkedlist(startnode): wanttoaddnode='1' currentnode=...
beec2bbb79fef38f59c4d40abd74b4d083a951ad
chansen736/sudokudo
/src/sudoku.py
4,799
4.375
4
import math class Sudoku: def __init__(self, size=0, rows=[]): """ Constructs a puzzle of the specified size and given rows. The size is the maximum value the puzzle can take; for example, typical sudoku puzzles have size=9. A value of "0" in a row means "empty". """ ...
4c8dc436484ca5d1d3b03a67a111b9b59409016f
Geometrically/python-projects
/searchsort/searchsort.py
9,130
3.65625
4
import time import random import bisect import sys random.seed() def insertion_sort(vals): for i in range(1, len(vals)): j = i while j > 0 and vals[j - 1] > vals[j]: vals[j], vals[j - 1] = vals[j - 1], vals[j] j -= 1 def bubble_sort(vals): n = len(va...
dee9aa9331fb48a79785e5d32428405bc9206a57
jfzo/est1112-2020
/pregunta0.py
102
3.703125
4
""" x = f(4,6) print("El valor de la suma entre 4 y 6 es", x) """ def f(a, b): s = a + b return s
d4910557198fed371ef22c1c532373903189da6d
zhangshua1/zhangshua1.github.io
/python-test/nj.py
289
4
4
#!/usr/bin/env python3 #_*_coding:utf-8_*_ jiwei = 27 count = 0 while count < 3: name = int(input("name:")) if name == jiwei: print("you win!") break elif name > jiwei: print("you max!") elif name < jiwei: print("you min!") count +=1 else: print("你输错次数太多!")
efaa02bebb57f4dd9cfe526d90f51c4f9dec10e6
nguyenvannhat582/th4
/4.9,10,11,12,13,14.py
536
3.734375
4
#nhập một list từ bàn phím ds=input('nhap chuoi:').split() #cắt list:lấy list nhưng bỏ phần tử đầu và cuối x=ds[0:-1] for c in x: print(c) #thêm phần tử vào list ds.append('abc') for ch in ds: print(ch) #bỏ phần tử khỏi list ds.remove('123') for ch in ds: print(ch) #tì...
af473a4af4fa63eb56c0357206f49dd6105aac32
timbennett/twitter_follower_friends
/process_edges.py
4,250
3.578125
4
''' Generate some intelligence from a list of who a user's followers follow. Usage: python process_edges.py [username] [n] [username]: a user previously examined with get_followers.py and sample_follower_friends.py. [username]_edges must exist. [n]: for output purposes, create a file c...
760f0ffea502e3fc67a90de92f4f35d7a0807315
YakoonCSantos/python-selenium
/while.py
866
3.953125
4
""" print("vamos lá") n1 = int(input("Informe um número! ")) print("") while n1 >= 0: if n1 % 2 == 0: print (str(n1) + " número e par") else: print (str(n1) + " número e impar") n1 = n1 - 1 print("") print("tá fluindo") login = input("Informe o usuário!" ) senha = inpu...
9d55d73b9d76846713e9269021cb93bb0a26e2e9
psiber86/CS7081_AdvAlgorithms
/hw1/doublehornereval.py
1,158
3.59375
4
#!/usr/bin/python import sys a = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] def usage(): print "./doublehornereval <n> <v>" def comp_poly(n, v, a): actualpos = 0 actualneg = 0 for i in range(n, -1, -1): actualpos = actualpos + a[i]*pow(v, i) actualneg = actualneg + a[i]*pow(-v, i) return...
6a13491d53ec42d396fdcf588584afaa2e744b2d
NitirajsinhSolanki/projects
/Sudoku.py
8,136
3.515625
4
def intersection(list1, list2): intersec=[] for x in list1: for y in list2: if x == y: intersec.append(x) return intersec def rowAvailibilty(numbers , avalibilty): row_num=1 for row in numbers: col_num=1 avalible=[1,2,3,4,5,6,7,8,9] ...
735da80a86d482376e860f5e6226bb1d44df534c
Rohantaygi/python
/my learning.py
1,560
3.9375
4
#i am learning from tutorial number 45 lis = ["Bhindi", "Aloo", "Chopsticks", "Gaajar", "Lollypop"] #enumerate function(helps in printing the specific item in list)- for index, item in enumerate(lis): if index%2 == 0: print(f'jarvis please buy {item}') #how args*/kwargs** works(now we can add any name in...
31c5bcd4e76d9e5f2d42852b5519249116a6917a
LoganBe/TestRepo
/jupyterworkflow/data.py
1,039
3.5
4
# load module from urllib.request import urlretrieve import os import pandas as pd URL='https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD' def get_fremont_data(filename = 'Fremont.csv', url = URL, force_download = False): """Download and Cashe Fremont Bike Data Uses pandas to...
9961d7d47a608dc88f06b9a833a89563118e49bd
Aszman/Project_Labyrinth
/DFS_generator/mazeGenerator.py
5,846
3.53125
4
# # 2 2 2 0 1 2 # 1 1 1 1 0 1 2 3 # Współrzędna x: 0 0 0 0 0 Współrzędna y: 0 1 2 3 4 # -1-1-1-1 0 1 2 3 # -2-2-2 ...