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
6e690536e0f66b664e0429851826bdb68eeb4507
hirani/pydec
/pydec/pydec/dec/info.py
1,615
3.625
4
""" DEC data structures ============= Docs should follow this format: Scipy 2D sparse matrix module. Original code by Travis Oliphant. Modified and extended by Ed Schofield and Robert Cimrman. There are four available sparse matrix types: (1) csc_matrix: Compressed Sparse Column format (2) csr_matrix: Comp...
f5617054ec164da96fe6c2d4b638c9889060bbf0
hirani/pydec
/pydec/pydec/math/parity.py
2,695
4.15625
4
__all__ = ['relative_parity','permutation_parity'] def relative_parity(A,B): """Relative parity between two lists Parameters ---------- A,B : lists of elements Lists A and B must contain permutations of the same elements. Returns ------- parity : integer ...
013436bd90e2eea1b08a5a1036b5d0bcf27b0eb2
bryan-l-serrano/orps
/createGameTable.py
596
3.53125
4
#!/usr/bin/python import sqlite3 import os conn = sqlite3.connect('/orps/orps.db') print('opened database') cursor = conn.cursor() cursor.execute("DROP TABLE IF EXISTS GAME") sqlCommand = '''CREATE TABLE GAME( gameID CHAR(20) PRIMARY KEY NOT NULL, player1ID CHAR(20) NOT NULL, player2ID CHAR(20) NOT NULL, winPlayer...
928075c697bfcaa849fb2e399858ca45653a3263
t00n/DiscoveryTripToMusic
/src/memoize.py
1,300
3.78125
4
import collections import functools class memoized(object): '''Decorator. Caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated). ''' def tuplize(self, something): if isinstance(something, list) or isinstance...
9a45a3d526d8619fd9b3a9203d316ee80e7bdf37
Zferi/new-project
/Задания евгения евтушенко/lesson 1/second tusk.py
222
3.546875
4
a = int(input("Enter your second: ")) h = str(a // 3600) m = (a // 60) % 60 s = a % 60 if m < 10: m = '0' + str(m) else: m = str(m) if s < 10: s = '0' + str(s) else: s = str(s) print(h + ':' + m + ':' + s)
03514eee4dc6b2a770d4521e6bd79a031ea33714
IulianStave/demosqlpy
/tkint.py
856
3.765625
4
# Tkinter widgets, states from tkinter import * def convert_from_kg(): grams = 1000 * float(e1_value.get()) t1.delete("1.0", END) t1.insert(END, grams) pounds = 2.20462 * float(e1_value.get()) t2.delete("1.0", END) t2.insert(END, pounds) ounces = 35.274 * float(e1_value.get()) t3.dele...
c350c7a32906c9097098cdf949251fa03acbb4c0
panghu-art/Sandwich-pie
/列表推导式小实验.py
158
3.734375
4
list1=[] for x in range(10): for y in range(10): if x % 2 ==0: if y % 2 != 0: list1.append((x,y)) print(list1)
609b238fdd5e689ec20cddb76b4569f15298efef
panghu-art/Sandwich-pie
/字符串中子字符串出现的次数.py
516
3.515625
4
def findstr(str1,str2): '''这是一个寻找字符串中子字符串出现次数的函数''' k=0 if len(str2) != 2: print('不好意思,第二个参数长度必须为2,请重新调用!') else: for b in range(len(str1)): if str1[b]==str2[0]: if str1[b+1]==str2[1]: k += 1 return k print(findstr('fashljkfh...
fbb2a15911d7c8821bc9fd9fa4bd6b9ed0e18fbd
panghu-art/Sandwich-pie
/十进制转化为二进制参数.py
488
3.703125
4
def bind(num): '''这是一个将十进制转化为二进制的函数 if num in(0,1): d=str(num) else: d='' while num not in (0,1): d=(str(num%2))+d num=num//2 d=str(num)+d return(d) print(bind(8))''' y=1 z=[] b='' while y != 0: y=num//2 ...
c9e763d504810d7bc5e305f45c5c519040de90f3
lauraromerosantos/TarefaExtra_Algoritmos_Programacao_I
/tarefa_extra.py
5,611
4.0625
4
agenda = {'ivonei':['1111'], 'maria':['2222'], 'pedro': ['3333'],'aaa':['999991111','999992222','999993333']} def ler_telefone(telefones = []): def entrar_outro_numero(): resposta = input('Entrar outro número? s/n: ') if resposta.upper() == 'S': return True return False """ Na f...
2ef55f75319d760f4fc37ff6512faab00ef15507
Dididoo12/Dominos
/Domino GUI.py
28,682
4.46875
4
# Date: November 14, 2017 # Author: Edward Tang # Purpose: This program is designed to display a set of dominoes with different properties. # Input: Mouse and/or Keyboard # Output: Screen, Console and/or GUI # ========================================================================================== from tkinte...
02da3a9e84fd015751a88d76edc96fc231581ffa
wu-wen-chi/Python-first-midtern
/52.py
255
3.671875
4
n=int(input('輸入n值:')) a={} for i in range(1,n+1): name=input('請輸入姓名:') mail=input('請輸入電子郵件:') a[name]=mail s=input('請輸入要查詢電子郵件的姓名:') if s in a: print('電子郵件帳號為:',a[name])
3aeaabc50c9b318eadfc1414006c36c83ad3cff2
wu-wen-chi/Python-first-midtern
/21.py
459
3.546875
4
n=int(input("輸入查詢組數n為:")) for i in range(1,n+1): a,b=input("帳號 密碼:").split() if a=="123" and b=="456": print("9000") elif a=="456" and b=="789": print("5000") elif a=="789" and b=="888": print("6000") elif a=="336" and b=="558": print("10000") elif a=="775" and b=...
9dfa89305cf8368a3b6ab59f26050b2de56cbc36
wu-wen-chi/Python-first-midtern
/44.py
136
3.671875
4
m=int(input("月:")) d=int(input("日:")) s=(m*2+d)%3 if s==0: print("普通") elif s==1: print("吉") else: print("大吉")
1442f234e5cffc65736b2bf937468d04653c46d1
ashwynh21/rnn
/declarations/memory.py
1,142
3.796875
4
""" We define this class to store the (state, action reward, next) of a particular move """ from collections import deque from typing import List from random import sample from declarations.experience import Experience class Memory: __memory: deque __size: int def __init__(self, batch: int): se...
617951a21854ea31108f421afa9ebd16738c0282
ashwynh21/rnn
/declarations/action.py
646
3.671875
4
""" We define the class Action to allow us to abstract functions into the action made by our models. """ from typing import List import numpy as np from sklearn.preprocessing import MinMaxScaler scalar = MinMaxScaler() class Action(object): probabilities: List[List[List[List[float]]]] random: bool def ...
831bc88da89c2c351ed109ae13eb4ea26393cc0a
Itamar-S/Connect-4
/main.py
16,113
3.6875
4
# Importing the colored function from the termcolor libery for multicolored board # Then importing the choice function from the random libery for the Random player # Finally importing the inf const from the math library for the Alpha Beta Pruning (to economize the maximum and minimum score calculation) from termcolo...
305659ca00c20cd2c345989846a699ebe8db33fc
breitbarth/pys-list
/main.py
1,504
3.59375
4
import requests from bs4 import BeautifulSoup html_link = input("Please enter a CraigsList page: ") page = requests.get(html_link) soup = BeautifulSoup(page.text, 'html.parser') class_list = set() # First we need to get the span tags spanTag = {tag.name for tag in soup.find_all('span')} listOfResults = set() sum = 0...
21dcf23d21a973299992e8c7eae11cae9b455b04
ikisler/udacity-algorithms-projects
/problem_5.py
3,235
3.984375
4
## Represents a single node in the Trie class TrieNode: def __init__(self): ## Initialize this node in the Trie self._is_word = False self._children = {} def set_is_word(self): self._is_word = True def get_is_word(self): return self._is_word def get...
72af6a140f9a896b058998fa1fa65c035104cce4
ebukari/exercism-python-solutions
/solns/atbash_cipher.py
646
3.6875
4
import string import re CIPHERTEXT = 'zyxwvutsrqponmlkjihgfedcba' + string.digits PLAINTEXT = string.ascii_lowercase + string.digits def encode(str_): str_ = re.sub('\W', '', str_).lower() return_str = '' count = 1 for letter in str_: return_str += CIPHERTEXT[PLAINTEXT.index(letter)] # lette...
fb11cc3de9d42cd18037132fdc7fe95b8b06d55c
ngd-b/python-demo
/second.py
2,256
3.6875
4
#!/usr/bin/python # -*- coding:utf-8 -*- print("hello world") # [:] names = list(range(11)) print(names[1:6]) # [::] print(names[1:6:2]) # 判断当前数据是否可以进行迭代 from collections.abc import Iterable print(isinstance(names,Iterable)) # enumerate names = enumerate(names) for k,v in names: print(k,v) # [] nums = [n*n for n...
86cf7138e283cf83d7c9fdd30cb139857468f433
ngd-b/python-demo
/four/four.py
701
3.6875
4
#!/usr/bin/python # -*- coding:utf-8 -*- print("hello world") # print(a) try: print(a) except NameError as e: print("变量未声明,请检查") finally: print("继续执行!") print(2) # logging 记录日志 import logging try: print(10/0) except ZeroDivisionError as e: logging.exception(e) print(0/10) # 自定义错误类型 class Confli...
b7c06bf9cad593102eca103ad43cf8abfbeddb1c
cheriesyb/cp1404practicals
/prac_02/numbering.py
337
3.609375
4
output_file = open("numbers.txt", 'r') number_1 = int(output_file.readline()) number_2 = int(output_file.readline()) print(number_1 + number_2) output_file.close() # extended activity output_file = open("numbers.txt", 'r') total = 0 for line in output_file: number = int(line) total += number print(total) out...
328b35992c50915e95c2ededde477a066cf9a99f
rafaelols/learn-python3-the-hard-way
/ex48/ex48/lexicon.py
351
3.765625
4
WORD_TYPES = { 'north': 'direction', 'south': 'direction', 'east': 'direction', 'west': 'direction', 'go': 'verb', 'kill': 'verb', 'eat': 'verb' } def scan(sentence): words = sentence.split() result = [] for word in words: tuple = (WORD_TYPES[word], word) result....
e3f3da252345a8e54f3e7bff4d6c695d379b5e42
grupy-sanca/dojos
/039/2.py
839
4.53125
5
""" https://www.codewars.com/kata/55960bbb182094bc4800007b Write a function insert_dash(num) / insertDash(num) / InsertDash(int num) that will insert dashes ('-') between each two odd digits in num. For example: if num is 454793 the output should be 4547-9-3. Don't count zero as an odd digit. Note that the number wil...
25869ac8273d09c17f88c59828573e9ba7ba6de4
grupy-sanca/dojos
/027/ex1.py
863
3.609375
4
""" Problema: https://www.urionlinejudge.com.br/judge/pt/problems/view/1234 Entrada: 'This is a dancing sentence' Saída: 'ThIs Is A dAnCiNg SeNtEnCe' Entrada: ' This is a dancing sentence' Saída: ' ThIs Is A dAnCiNg SeNtEnCe' Entrada: aaaaaaaaaaa Saída AaAaAaAaAaA >>> dancing_strin...
d353c66f391a8b05404ee48aafa409e2bcfbe5c0
grupy-sanca/dojos
/011/magic_numbers.py
1,244
3.796875
4
""" Validador de Quadrados Mágicos 3x3 https://www.codewars.com/kata/magic-square-validator/ Recebe da entrada padrão uma matriz de tamanho 3x3... [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> matriz = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> checar_linha([1, 2, 3]) False >>> checar_linha([4, 9, 2]) True >>> transpor(matriz) ...
40081353479ae657ee72bb8f6e37b99be0a5dab8
grupy-sanca/dojos
/036/3.py
1,158
3.515625
4
""" https://www.codewars.com/kata/5aceae374d9fd1266f0000f0 Given two times in hours, minutes, and seconds (ie '15:04:24'), add or subtract them. This is a 24 hour clock. Output should be two digits for all numbers: hours, minutes, seconds (ie '04:02:09'). >>> sum('00:00:00', '00:00:00') '00:00:00' >>> sum('01:02:03'...
7a25ea6ece6b85b2c4e4737cce1a035517207e05
grupy-sanca/dojos
/006/rangeparser.py
964
3.765625
4
""" >>> range_parser('1') [1] >>> range_parser('1,2,3,10,50') [1, 2, 3, 10, 50] >>> range_parser('3-8') [3, 4, 5, 6, 7, 8] >>> range_parser('1,2,3-8') [1, 2, 3, 4, 5, 6, 7, 8] >>> parse_range('1-3') [1, 2, 3] >>> parse_range('1-3:2') [1, 3] >>> range_parser('1-10,14, 20-25:2') [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22...
7d780b6baa6ca0b9149a8265ddd657d2303f9483
grupy-sanca/dojos
/003/sequence.py
669
3.9375
4
""" Um inteiro positivo n é dado. O objetivo do problema é construir a menor sequencia de inteiros que termina com N de acordo com as seguintes regras: 1. o primeiro elemento da sequencia é 1; A[0] = 1 2. os proximos elementos são gerados pela multiplicação do elemento anterior por 2 ou somando 1; A[i] = A[i-1] * 2 ou...
4fd23931962dd3a22a5a168a9a49bc68fd8eadd6
grupy-sanca/dojos
/028/ex2.py
1,416
4.40625
4
""" A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. They are now trying out various combinations of company names and logos based on this condition. Given a string, which is the company name in lowercase letters, your task is to find the...
6592fd4409614e36f71eafb4eb5c0477566876bb
grupy-sanca/dojos
/001/lista.py
2,965
4.0625
4
"""Dojo Grupy Sanca - 27/07/2016 """ class Node: """ >>> Node(1) Node(1) >>> no = Node('abc') >>> no Node('abc') """ next = None def __init__(self, value): self.value = value def __repr__(self): return 'Node({!r})'.format(self.value) class List: """ ...
cdf1b64ca2565e5ed195b57cda9e2a94421665f1
Joseph-L-Hayes/CS188-projects
/P0/speed/quickSort2.py
685
3.9375
4
import time def quickSort(list, pivot=0): if pivot > len(list) - 1: pivot = 0 if len(list) <= 1: return list before = [x for x in list[:pivot]] after = [x for x in list[pivot + 1:]] smaller = [x for x in before if x < list[pivot]] larger = [x for x in before if x >= list[pivo...
1a538c87e392c12466367fb9df19ed7de14eb9ba
lynnanni/Netflix-SDET-project
/Modules/Pages/ComputerPage.py
3,353
3.5625
4
from Modules.Pages.BasePage import Page from Modules.Library.locators import ComputerPageLocators as locators from selenium.webdriver.support.ui import Select import logging class ComputerPage(Page): """ This is the page that appears when a user attempts to add or edit a computer """ logging.basicConfi...
f17e7bc0acc2e97393a392ffb15e96a3f9f805f2
ayust/controlgroup
/examplemr.py
645
4.28125
4
# A mapper function takes one argument, and maps it to something else. def mapper(item): # This example mapper turns the input lines into integers return int(item) # A reducer function takes two arguments, and reduces them to one. # The first argument is the current accumulated value, which starts # out with t...
5eb04f15805f94fe1cd15b17ae4a9e9c165b43d0
hamzahap/HangmanGame
/Hangman.py
10,671
4
4
from random import randint from tkinter import * import tkinter.ttk as ttk from tkinter.ttk import Progressbar from tkinter import messagebox import time import threading # getInfile() # Gets a text file containing words to be chosen by the Hangman program def getInfile(): try: # First, we check for a f...
da9716a7733d7122453c98faf731b588c5616ec6
JanrichVanHeerden/Sandbox
/oddName.py
243
4
4
"""Janrich van Heerden""" name = input("Enter your name") while name == "": name = input("Enter a NAME") char_list = name count = 1 for each in list(char_list): if count % 2 != 0: print(each) count+=1 else: count+=1
67bf9c85fe99964eb25f6da9c5e8a588673e0c38
SvetlanaGruzdeva/Chess-Dictionary-Validator
/chessvalidator.py
5,635
3.65625
4
#! python3 # chessvalidator - checks if provided chess board is valid import logging logging.basicConfig(filename='chessValidatorLog.txt', level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') # TODO: add validation that no cells appear more than 1 time chess_board = {'1h': 'bpawn', '6c': '...
764c2e9915ec8d6f2091214dfc3a32008327c4e6
lacornichon/twitterPredictor
/twitter_collect/tweet_collect_whole.py
3,187
3.59375
4
from twitter_collect.search import collect """ Generate and return a list of string queries for the search Twitter API from the file file_path_num_candidate.txt :param num_candidate: the number of the candidate :param file_path: the path to the keyword and hashtag files :param type: type of the keywo...
03a2a79eef645a244f623d178933899ed849b58f
ktsun2016/top11
/array_1.py
921
3.671875
4
def most_frequent(s): mp={} for i in s: if i in mp: mp[i] += 1 else: mp[i] = 1 max_times=max(mp.values()) for i, j in mp.items(): if j == max_times: return i s=[1,2,3,4,5,1,2,3,1,1] print(most_frequent(s)) def most_frequent(s): mp={} ...
624f4f48e466cd470885dbdca5ac79db422af69b
anarchy-muffin/web-spider
/spider.py
2,979
3.609375
4
import HTMLParser import urllib2 import parser #make class LinkParser that inherits methods from #HTMLParser which is why its passed to LinkParser definition. #This is a function that HTMLParser normally has #but we add functionality to it. def handle_starttag(self, tag, attrs): #looking for the beginning of ...
36444bd3621d0da6aed4b4784e103903b50e873d
Lesikv/python_tasks
/python_practice/nod.py
240
3.890625
4
#usr/bin/env python #coding:utf-8 a = int(input('Введите первое число: ')) b = int(input('Введите второе число: ')) k = a if a < b else b print k while (a % k != 0) or (b % k != 0): k -= 1 print k
88d7bcc2e6596be6ad87fe9a2e27a1217e91088f
Lesikv/python_tasks
/python_practice/diag_matrix.py
495
3.71875
4
#!/usr/bin/env python #coding: utf-8 def diag_matrix(arr): if not arr or len(arr) < 1: return None l_res = len(arr[0]) + len(arr) - 1 res = [[] for i in range(l_res)] i, j = 0, 0 for i in range(len(arr)): while j < len(arr): print 'i = {}, j = {}, res[i+j]...
732a3d33f2420754f245c12e8de68f0ecd40df0e
Lesikv/python_tasks
/python_practice/binary_tree.py
4,705
3.875
4
#!usr/bin/env python #coding: utf-8 from collections import deque class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None # Creating Fisrt Tree root1 = Node(1) root1.left = Node(3) root1.right = Node(2) root1.left.left = Node(5) root1...
81ef8fcf4248d47775972f2b7f7dfe59afb9240a
Lesikv/python_tasks
/python_practice/loops/l_6_1.py
587
3.953125
4
#!/usr/bin/env python #coding: utf-8 ARRAY = [10, 6, 17, 5, 30, 20, 1, 100, 200] def find_max(arr, n): """ Для массива чисел найти первых два числа таких что, которое больше суммы всех предыдущих (если нет таких, что None) """ sum = 0 res = [] #for k in range(n): for i in range(1, len...
41b44b20257c4a5e99ca9af99d7ca7fc7066ed1c
Lesikv/python_tasks
/python_practice/matrix_tranpose.py
654
4.1875
4
#!usr/bin/env python #coding: utf-8 def matrix_transpose(src): """ Given a matrix A, return the transpose of A The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. """ r, c = len(src), len(src[0]) res = [[None] * r for i i...
f21d1ac135f6008ec7acf323c7c075c7ba9577f3
Lesikv/python_tasks
/python_practice/leetcode/list_reverse.py
1,010
3.96875
4
#!usr/bin/env python #coding: utf-8 class Node(object): def __init__(self, val, next=None): self.val = val self.next = next def __repr__(self): if not self.next: return self.val return '{} -> {}'.format(self.val, self.next) def __eq__(self, other): ...
87a5ddc77570672fe77793c828abaf042573619e
an9wer/socket-exp
/a-web-crawler-with-asyncio-coroutines/simple.py
708
3.5625
4
""" By default, socket operations are blocking: when the thread calls a method like connect or recv, it pauses until the operation completes. """ import socket def fetch(url): sock = socket.socket() sock.connect(("kxcd.com", 80)) request = "GET {} HTTP/1.1\r\nHost: xkcd.com\r\n\r\n".format(url) sock....
b79c74407ca0d2547cf55350d985f8e28338fc3d
Oukey/Algoritms
/task_solving/Binary_Search.py
1,060
3.796875
4
# Алгоритм двоичного поиска class BinarySearch: def __init__(self, array): self.array = array self.Left = 0 self.Right = len(array) - 1 self.result = 0 # 0 - поиск, +1 - элемент найден; -1 элемент не найден def Step(self, N): '''Метод выполнения одного шага поиска. Прн...
aaa5d1e8b29c70adf1b77239ebd314cb4fa42c4c
eriksandgren/AdventOfCode2018
/day03/day3.py
1,180
3.515625
4
#!/usr/bin/env python import sys def parseInput(): with open ("input.txt", "r") as myfile: myInput = myfile.read() myInput = myInput.split('\n') return myInput def part1and2(): my_input = parseInput() fabric = {} overriddenClaims = set() allClaims = set() for l in my_input...
92d28d6f3f391537f6903e2bfc196c49cb6aec6d
eriksandgren/AdventOfCode2018
/day01/day1.py
738
3.65625
4
#!/usr/bin/env python import sys def parseInput(): with open ("input.txt", "r") as myfile: myInput = myfile.read() myInput = myInput.split('\n') return myInput def part1(): my_input = parseInput() freq = 0 for l in my_input: if l[0] == '+': freq += int(l[1:]) ...
9990ff41328f7353af5deb036a45f751499f8cf9
jrantunes/URIs-Python-3
/URIs/URI1828.py
1,343
3.53125
4
#Bazinga! n = int(input()) for i in range(n): e1, e2 = input().split() if e1 == e2: print("Caso #{}: De novo!".format(i + 1)) elif e1 == "tesoura": if e2 == "papel" or e2 == "lagarto": print("Caso #{}: Bazinga!".format(i + 1)) elif e2 == "Spock" or e2 == ...
16f2303123e1e653761bcd76b2685dc68b5cb682
jrantunes/URIs-Python-3
/URIs/URI2846.py
510
3.71875
4
# Fibonot def fib(n): if n == 1 or n == 2: return False ant = 1 atual = 2 termo = 0 check = True while True: termo = ant + atual ant = atual atual = termo if termo == n: check = False break elif n < termo: break return check...
b0b1a21a1e1f1087488a7b1f1596ba42f911bb63
jrantunes/URIs-Python-3
/URIs/URI1131.py
569
3.515625
4
#Grenais v_i = 0 v_g = 0 empts = 0 grenais = 0 while True: i, g = list(map(int, input().split())) grenais += 1 if i == g: empts += 1 elif i > g: v_i += 1 else: v_g += 1 if int(input("Novo grenal (1-sim 2-nao)\n")) == 2: break else: ...
dc67a9ee4f146db344f44d0266db9e77c03a8fbe
jrantunes/URIs-Python-3
/URIs/URI2823.py
219
3.609375
4
#Eearliest Deadline First v = int(input()) sum = 0.0 for i in range(v): c, p = input().split() c = float(c) p = float(p) sum += c / p if sum <= 1.0: print("OK") else: print("FAIL")
99a5cfd9f1daa6b6f13678dbb165c2cd30d4fb37
jrantunes/URIs-Python-3
/URIs/URI1158.py
407
3.53125
4
#Sum of Consecutive Odd Numbers III n = int(input()) for i in range(n): valores = input().split() v1 = int(valores[0]) v2 = int(valores[1]) soma = 0 j = 1 while j <= v2: if v1 % 2 != 0: soma = soma + v1 v1 = v1 + 1 j = j + 1 ...
ed9135aa85c66c48840f87ab1ed25960d086d75e
jrantunes/URIs-Python-3
/URIs/URI1045.py
691
3.953125
4
#Triangle Types valores = input().split() v1 = float(valores[0]) v2 = float(valores[1]) v3 = float(valores[2]) nums = [v1, v2, v3] nums.sort() nums.reverse() A = nums[0] B = nums[1] C = nums[2] A_QUAD = A ** 2 BC_QUAD = (B ** 2) + (C ** 2) if A >= B + C: print("NAO FORMA TRIANGULO") ...
992e74a72343c533ddb451d02a06a9e3241e06e1
jrantunes/URIs-Python-3
/URIs/URI1060.py
167
3.8125
4
#Positive Numbers ctr = 0 for i in range(6): n = float(input()) if n > 0: ctr += 1 else: pass print(ctr, "valores positivos")
723bd68463f045dfd0c5238377c1ed5be7319028
jrantunes/URIs-Python-3
/URIs/URI1180.py
256
3.609375
4
#Lowest Number and Position n = int(input()) vetor = [] nums = list(map(int, input().split())) for i in range(n): vetor.insert(i, nums[i]) print("Menor valor: {}".format(min(vetor))) print("Posicao: {}".format(vetor.index(min(vetor))))
a2429afa5815ad974f8333577a17556f1be5744f
jrantunes/URIs-Python-3
/URIs/URI1253.py
402
3.625
4
#Caesar Cipher abc = 'abcdefghijklmnopqrstuvwxyz' rep = int(input()) for x in range(rep): cifrada = ','.join(input()).lower().split(',') n = int(input()) indices = [] for c in cifrada: indices.append(abc.index(c) - n) palavra = [] for i in indices: palavra.append(abc[i]) resu...
c48fb659bcc310e1af9be46ca7f843e104b887fa
jrantunes/URIs-Python-3
/URIs/URI1279.py
733
3.78125
4
#Leap Year or Not Leap Year and … pula_linha = 0 while True: try: ano = int(input()) biss = 0 ordi = 1 if pula_linha: print("") pula_linha = 1 if ano % 4 == 0 and not(ano % 100 == 0) or ano % 400 == 0: ...
03bda825834035b06a91c3d876bc06a2269c229c
jrantunes/URIs-Python-3
/URIs/URI1072.py
277
3.59375
4
#Interval 2 in_interval = [] out_interval = [] for i in range(int(input())): x = int(input()) if x in range(10, 21): in_interval.append(x) else: out_interval.append(x) print("{} in\n{} out".format(len(in_interval), len(out_interval)))
8f2e81c5a6eec3157fa16312286e2e8a1582d007
jrantunes/URIs-Python-3
/URIs/URI1018.py
204
3.625
4
#Banknotes notas = [100, 50, 20, 10, 5, 2, 1] n = int(input()) print(n) for nota in notas: qtde = int(n / nota) print("{} nota(s) de R$ {},00".format(qtde, nota)) n -= qtde * nota
9d78bf9b9817518547a0c7c76a17a731b923f389
jrantunes/URIs-Python-3
/URIs/URI1019.py
177
3.734375
4
#Time Conversion N = int(input()) h = 3600 m = 60 hora = N // h min = N // m minutos = min % m segundos = N % m print("{}:{}:{}".format(hora, minutos, segundos))
c7338bfb436b00654b9a30e84308dfb72bfa29b1
eileencuevas/Graphs
/projects/graph/src/graph.py
3,483
4.03125
4
""" Simple graph implementation """ from queue import Queue from stack import Stack class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" def __init__(self): self.vertices = {} def add_vertex(self, vertex_id): self.vertices[vertex_id] = set() def ...
0f4e686cbbf11bda4e773f725caae54413316c6a
Tonguesten36/PersonalRepo
/TonguestenPasswordUtility/PasswordManager/PasswordManager.py
7,688
3.921875
4
import sqlite3 from time import sleep from pip._vendor.distlib.compat import raw_input # For creating a new database def create_new_database(database): # You can add your own database file if you want, as long as you replace the placeholder file "PasswordDatabase.db" connection = sqlite3.connect(database) ...
7de0c49e2d65108f1c388b51983e5f6e020550b5
LookADonKill/Python
/classes.py
1,015
3.84375
4
nama3 = input("Masukkan nama dari mobil yang ingin anda beli :") brand3 = input("Masukkan merek dari mobil tersebut :") garansi3 = int(input("Masukkan lama garansi yang diinginkan untuk mobil tersebut :")) power3 = int(input("Masukkan banyaknya power yang dimiliki mobil yang diinginkan :")) warna3 = input("Masukkan war...
274ecf7c27a5bb87ea374816a9b6f2fc617d1034
LookADonKill/Python
/Gajikerja.py
320
3.71875
4
print("PAYMENT COMPUTATION FOR EMPLOYEE") print("--------------------------------") angka = 10 def gaji(x,y): if Jam > angka: return(200 + (x * y)) elif Jam < angka: return(x * y) Jam = int(input("Enter work hours :")) Rate = int(input("Enter work rate :")) Hasil = gaji(Jam, Rate) print(Hasil)
aec6d7cc480ea842c5b5ae9cf40eeb4f6690dfc9
kathrintravers/Hackerrank
/if_else_loop.py
310
4.0625
4
#!/usr/bin/env python3 if __name__ == '__main__': n = int(input().strip()) if n%2 != 0: print('weird') elif n%2 == 0 and n in range(2,5): print('not weird') elif n%2 == 0 and n in range (6,21): print('weird') elif n>20 and n%2 == 0: print('not weird')
0f8dc99960194214b89becc254e40d383e68bd45
anubhavcu/python-sandbox-
/lists.py
3,156
4.1875
4
# lists are ordered and mutable sequence , allows duplicate members # lists are also heterogenous (can contain int, float,str type together) import random numbers = [1, 2, 3, 4, 5, 6] # numbers1 = list(1, 2, 3, 4, 5) # will generate an error - as list constructor takes 1 argument only numbers1 = list((1, 2, 3, 4, 5)...
485fd356a2b3da8cd0db30d1d83714ef64d174f2
anubhavcu/python-sandbox-
/conditionals.py
1,765
4.15625
4
x = 50 y = 50 # if-else: <, >, == # if x > y: # print(f'{x} is greater than {y}') # else: # print(f'{x} is smaller than {y}') if x > y: print(f'{x} is greater than {y}') elif x < y: print(f'{x} is smaller than {y}') else: print("Both numbers are equal") # logical operators - and, or, not x = 5 ...
bd63890f1648bf6b2b5e257c939ef5748534df26
gpolaert/cs231n
/assignment1/cs231n/classifiers/softmax.py
4,279
3.953125
4
import numpy as np def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape (D, C) containing weights. - X: A numpy arr...
74abafdf12176b1a10f25c2d687ea19eb4eb6142
AlexanderShulepov/Guillou-Quisquater
/sugar.py
538
3.796875
4
def exgcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = exgcd(b % a, a) return (g, x - (b // a) * y, y) def inverse_of(a, m): g, x, y = exgcd(abs(a), m) if g != 1: raise Exception('Обратного элемента не существует') else: if a > 0: return x ...
87cbc63b1db6b75bb7ea4e539458398ea9944b81
chrisgrimm/fidex_implementation
/instances.py
4,065
3.640625
4
import os, re from typing import List class Instance(object): def __init__(self, all_words : List[str], regex : str): self.all_words = all_words self.regex = regex self.positive_words = [word for word in all_words if re.match(regex, word)] self.negative_words = [word for word in al...
5b468949ae623e6299665ff77feca0857763ead7
benson-w/cf
/codefights/isCryptSolution.py
1,335
3.765625
4
def isCryptSolution(crypt, solution): w1 = crypt[0] w2 = crypt[1] w3 = crypt[2] if (checkFirst(w1, solution) == 1) or (checkFirst(w2, solution) == 1): print("false") return 0 if calculateVal(w1, solution) + calculateVal(w2, solution) == calculateVal(w3, solution): print("tr...
8c1dafca1b0db6b851a178921d01e5625f2fae12
pranavtotla/polygonlite
/polygonlite/Point.py
3,352
3.890625
4
from .Services import dot import math from .config import THRESHOLD class Point: """ Class for Points. A Point p can be accessed in various ways: 1. p[0], p[1] 2. p.x, p.y 3. p['x'], p['y'] """ def __init__(self, *args, **kwargs): if len(args) == 1: self.point = ar...
055abf3d492646cb6c1a38984812814e47dae0cf
HenziKou/Free-Code-Camp
/Python Projects/Budget App/budget.py
4,790
3.65625
4
from typing import List class Category(): def __init__(self, name: str): self.name = name self.ledger = [] def __str__(self): # Using formatted strings: align center, 30 char min, '*' as filler char title = f"{self.name:*^30}" + "\n" items = "" total = "Total: " + str(self.getBalance()) for item in...
c70cbbe6dd0107e74cd408a899dc6bbe77432829
reenadhawan1/coding-dojo-algorithms
/week1/python-fundamentals/selection_sort.py
1,044
4.15625
4
# Selection Sort x = [23,4,12,1,31,14] def selection_sort(my_list): # find the length of the list len_list = len(my_list) # loop through the values for i in range(len_list): # for each pass of the loop set the index of the minimum value min_index = i # compare the current value...
bc064473602c73d97275b8089abe2e6d53cbb59e
Saumonvert/Bootcamp_Python_42AI
/day00/ex04/operations.py
844
3.921875
4
import sys res = sys.argv[1] res2 = sys.argv[2] if len(sys.argv) > 3: print("InputError: too many arguments") elif res.isnumeric() and res2.isnumeric(): arg1 = int(sys.argv[1]) arg2 = int(sys.argv[2]) res1 = arg1 + arg2 sumtxt = "Sum: {}" print(sumtxt.format(res1)) #----------------# res2 = arg1 - arg2 ...
06f2384cd713a2c94b6a0759f1f15f60d482e286
nothingct/BOJ_CodingTest
/소수찾기.py
235
3.71875
4
def isPrime(n): if n < 2 : return False i=2 while i*i <=n : if n % i == 0 : return False i+=1 return True t=int(input()) a=list(map(int,input().split())) cnt=0 for num in a: if isPrime(num) == True: cnt+=1 print(cnt)
5203122ef8d490e781d11968e4573a4d9ad7be11
AgnesHH/RosalindPractices
/iprb.MendelsFirstLaw.py
162
3.640625
4
#!/usr/bin/env python m,n,k=21,15,19 def mendel(m,n,k): S=float(m+n+k)*(m+n+k-1) print (m*(m-1)*0.75 + k*(k-1) + m*n + 2*n*k +2*m*k )/S mendel(m,n,k)
5ecdcd88c08fba99dfa5813145d62dfc6be1b263
yukti99/Computer-Graphics
/LAB-1/dda.py
472
3.71875
4
from graphics import * def dda(p0,p1): win = GraphWin("My Line using DDA", 900, 700) dx = p1[0] - p0[0] dy = p1[1] - p0[1] if (abs(dx) > abs(dy)): steps = abs(dx) else: steps = abs(dy) xi = dx/float(steps) yi = dy/float(steps) x = p0[0] y = p0[1] print(steps) for i in range(0,steps+1): point = ...
0bc16b1cab5b9b6d0508e343b4855361861f5f68
yukti99/Computer-Graphics
/LAB-2/scanFill.py
2,633
3.578125
4
from graphics import * from graphicLibClass import * from polygon1 import * import math xMin = 0 xMax = 0 yMin = 0 yMax = 0 edgeTable = {} vertex = [] activeTable = [] def ScanLineFilling(n,vertex,color,win): ymin = vertex[0][1] ymax = vertex[0][1] print("ymin = ",ymin) print("ymax = ",ymax) # initial x and ...
d1d3b0ac7a6f25c1c0b25114c917d0a5694b0837
Bharadwaja92/DataInterviewQuestions
/Questions/Q1_FradulentRetailAccounts.py
1,681
3.5
4
""""""""" Below is a daily table for an active accounts at Shopify (an online ecommerce, retail platform). The table is called store_account and the columns are: Column Name Data Type Description store_id integer a unique Shopify store id date string date status string Possible values are: [‘open’,...
249cbda74673f28d7cc61e8be86cdfef2b855e2a
Bharadwaja92/DataInterviewQuestions
/Questions/Q_090_SpiralMatrix.py
414
4.4375
4
""""""""" Given a matrix with m x n dimensions, print its elements in spiral form. For example: #Given: a = [ [10, 2, 11], [1, 3, 4], [8, 7, 9] ] #Your function should return: 10, 2, 11, 4, 9, 7, 8, 1, 3 """ def print_spiral(nums): # 10, 2, 11, 4, 9, 7, 8, 1, 3 # 4 Indicators -- row start and end, column s...
8b2af30e0e3e4fc2cfefbd7c7e9a60edc42538c0
Bharadwaja92/DataInterviewQuestions
/Questions/Q_029_AmericanFootballScoring.py
2,046
4.125
4
""""""""" There are a few ways we can score in American Football: 1 point - After scoring a touchdown, the team can choose to score a field goal 2 points - (1) after scoring touchdown, a team can choose to score a conversion, when the team attempts to score a secondary touchdown or (2) an u...
604a4bb01ff02dc0da1ca2ae0ac71e414c5a6afe
Bharadwaja92/DataInterviewQuestions
/Questions/Q_055_CategorizingFoods.py
615
4.25
4
""""""""" You are given the following dataframe and are asked to categorize each food into 1 of 3 categories: meat, fruit, or other. food pounds 0 bacon 4.0 1 STRAWBERRIES 3.5 2 Bacon 7.0 3 STRAWBERRIES 3.0 4 BACON 6.0 5 strawberries 9.0 6 Strawberries 1.0 7 pecans 3.0 Can...
9d464daf8dc0115ae04613794a46455d1586c3db
Bharadwaja92/DataInterviewQuestions
/Utils/Q20_StringDistances.py
2,112
3.84375
4
""""""""" String Distance Algorithms: Hamming: Number of positions with same symbol in both strings. Only defined for strings of equal length. distance(‘abcdd‘,’abbcd‘) = 3 -> Chars at positions 0, 1, 4 Levenshtein: Minimal number of insertions, deletions and replacement...
8d39d540c2a3078ca6fe2a63d3b59ae5cf2f9381
Bharadwaja92/DataInterviewQuestions
/Questions/Q_028_WinningTheLottery.py
807
4.03125
4
""""""""" Suppose you're trying to figure out your chances of winning the lottery. The specific lottery you're interested in has 49 balls, each showing a single number. To win the jackpot you need to match 6 balls to win (note that order does not matter). What is the probability that you can win the jackpot, given y...
047b133a09b61e045788d629c0442aa8f795c729
Bharadwaja92/DataInterviewQuestions
/Questions/Q_060_ChoosingTwoIceCreams.py
865
4.03125
4
""""""""" Suppose you enter an ice cream store. They sell two types of ice cream: soft serve and frozen yogurt. Additionally, there are 10 flavors of soft serve and 13 flavors of frozen yogurt. You're really hungry, so you decide you can order and eat two ice creams before they melt, but are facing some decision fat...
d77e79c943a0364efb0b5a3a600f55ffaf783015
Bharadwaja92/DataInterviewQuestions
/Questions/Q_083_SalesByMarketingChannel.py
596
3.546875
4
""""""""" Given the following data set, can you plot a chart that shows the percent of revenue by marketing source? """ import pandas as pd from matplotlib import pyplot as plt pd.set_option('display.max_colwidth', -1) pd.set_option('float_format', '{:f}'.format) pd.set_option('display.max_columns', 500) pd.set_option...
913a4d4b373a3265b700971b7b22496a0986599d
aliucrazy/dataStrcutTest
/test_2.1.py
934
3.78125
4
""" """ class LinkedList(object): def __init__(self, data, next: LinkedList): # data--->用于存储放数据元素 self.data = data # next 用来存放该元素的后继 self.next = next def sortArray(La: list, Lb: list) -> list: Lc = list() La_index = 0 Lb_index = 0 while La_index <= len(La)-1 and ...
015f6e785a2d2b8f5ebe76197c15b8dd335526cc
code4nisha/python8am
/day4.py
1,594
4.375
4
x = 1/2+3//3+4**2 print(x) # name = 'sophia' # print(name) # print(dir(name)) # print(name.capitalize) # course = "we are learning python" # print(course.title()) # print(course.capitalize()) # learn = "Data type" # print(learn) # learn = "python data types" # print(learn.title()) # data =['ram',123,1.5] # print(...
b2caa326bde5f346910c1001f1bdf44ed74dccd9
code4nisha/python8am
/day3.py
478
3.75
4
# p = 10 # t = 20 # r =5 # SI = p*t*r/100 # print(SI) # p = float(input("Enter p: ")) # t = float(input("Enter t: ")) # r = float(input("Enter r: ")) # result = p * t * r /100 # print(f"Result: {result}") # name = 'sophia' # print('s' in name) # print('z' not in name) # print('y' in name) a = 9 b = 4 add = a...
dae28a56428b2ba61eb6aacc6c4b8809ae182cc4
christine62/intro-to-computer-science-and-programming-using-python
/hangman/isWordGuessed.py
720
4.0625
4
def isWordGuessed(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: boolean, True if all the letters of secretWord are in lettersGuessed; False otherwise ''' # FILL IN YOUR CODE HERE... ...
76d4657cc8a0311f905fb015679df982a3905f67
ChrisAmelia/DataMiningVideoGames
/src/fetchdata.py
3,787
3.71875
4
import urllib.request, json, os from pprint import pprint def fetchAppDetails(appid, write=False): """Returns the fetched data from Steam API. Steam API's format is: https://api.steampowered.com/<interface>/<method>/v<version>/ In this case, it should be: http://store.steampowered.com/api/appdetails/?appid...
3c24d06b8f6c4e4eb380da9c8b7ca94dfee80e51
Mystery01092000/Algorithm_Visualization_tool
/Algorithms_python/BubbleSort.py
466
3.921875
4
from Algorithms_python.Algorithms import Algorithms class BubbleSort(Algorithms): def __init__(self): super().__init__("BubbleSort") def algorithm(self): for i in range(len(self.array)): for j in range(len(self.array)-1-i): if self.array[j] > self.array[j+1]: ...
09dd6f8a8ac0b01029e6f8f817e69ef77128eddb
CatonChen/algorithm023
/Week_07/[130]被围绕的区域.py
3,731
4.03125
4
# 给定一个二维的矩阵,包含 'X' 和 'O'(字母 O)。 # # 找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O' 用 'X' 填充。 # # 示例: # # X X X X # X O O X # X X O X # X O X X # # # 运行你的函数后,矩阵变为: # # X X X X # X X X X # X X X X # X O X X # # # 解释: # # 被围绕的区间不会存在于边界上,换句话说,任何边界上的 'O' 都不会被填充为 'X'。 任何不在边界上,或不与边界上的 'O' 相连的 'O' 最终都会被 # 填充为 'X'。如果两个元素...
b0aee3c461decf2b2a0f005b3e10efde5042a931
CatonChen/algorithm023
/Week_07/[888]公平的糖果棒交换.py
1,605
3.515625
4
# 爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 根糖果棒的大小,B[j] 是鲍勃拥有的第 j 根糖果棒的大小。 # # 因为他们是朋友,所以他们想交换一根糖果棒,这样交换后,他们都有相同的糖果总量。(一个人拥有的糖果总量是他们拥有的糖果棒大小的总和。) # # 返回一个整数数组 ans,其中 ans[0] 是爱丽丝必须交换的糖果棒的大小,ans[1] 是 Bob 必须交换的糖果棒的大小。 # # 如果有多个答案,你可以返回其中任何一个。保证答案存在。 # # # # 示例 1: # # # 输入:A = [1,1], B = [2,2] # 输出:[1,2] # # #...
ac9c9c6015c2bf76e3d68aa52d0bf63e583a0960
CatonChen/algorithm023
/Week_06/[212]单词搜索 II.py
5,241
3.59375
4
# 给定一个 m x n 二维字符网格 board 和一个单词(字符串)列表 words,找出所有同时在二维网格和字典中出现的单词。 # # 单词必须按照字母顺序,通过 相邻的单元格 内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母在一个单词中不允许被重复使 # 用。 # # # # 示例 1: # # # 输入:board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l" # ,"v"]], words = ["oath","pea","eat","rain"] # 输出:["e...