blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
59e94cf4a775652c936b9042e728b3b3cd199c4f
dawbit/-SEM3-JS
/python/126.py
196
3.578125
4
class Circle(object): def __init__(self,x0,y0,r): self.x0, self.y0, self.r = x0, y0, r def area(self): return 3.14*self.r**2 def cir(self): return 2*3.14*self.r
da66e64aae5152ae0aedf847e8f8ae4912d6e812
robertjpang/Count9-Python
/main.py
2,242
3.8125
4
import math from tkinter.constants import LEFT from pickle import FALSE #global gIterations = 0 recursiveCount = 0 def NaiveCount(Max, Digit): TotalCount = 0; iterationCalc = 0 for x in range(0, int(n)+1,1): num = x; while (num > 0): iterationCalc = iterationCalc + 1 ...
e228c24738ef09d7f5a781f6d05ee3305f065b1f
CariusLars/YBH2020
/Categorizing/Utils.py
1,938
3.53125
4
"""Utility functions""" from difflib import SequenceMatcher import itertools import math import time import re def str_to_words(in_string): words = re.split(' |\n|\\.|/', in_string) # Split the words, delete punctiation and delete words that are actually only punctuation # We ignore upper/lower case w...
3f5648e58959c22b90db1659e402faffbc4f1429
dianatalpos/Fundamentals-of-Programming
/students/model/Grade.py
1,158
3.875
4
class Grade: def __init__(self, grade_id, student, discipline, grade): ''' in: discipline_id, student_id - integers grade - float ''' self.__discipline = discipline self.__student = student self.__grade = grade self.__grad...
be5ea165b1af8d661a0ddb882128b4aa9b173e8e
Joseph-Lin-163/Interview-Practice
/chapter1.py
8,020
4.0625
4
# Check if string has all unique characters. What if cannot use additional data structures? def isUnique(s): # Naive solution: Check each character across all other characters # BigO: O(n^2) unique = 1 for idx, letter in enumerate(s): # range returns [] when range(10,10) or range(11,10) ...
50f9b7f2809fc56202cc151639267d47e01efbc4
duncanmichel/Programming-Problem-Solutions
/LeetCode/MajorityElement.py
1,276
3.953125
4
""" Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Example 1: Input: [3,2,3] Output: 3 Example 2: Input: [2,2,1,1,1,2,2] Output: 2 """ class Sol...
c8223b4e39199429c4dd31802473f5f245dde6a2
Echowwlwz123/learn7
/浦发机试题/IntNum.py
1,031
3.8125
4
# -*- coding: utf-8 -*- # @Time : 2021/5/14 21:28 # @Author : WANGWEILI # @FileName: IntNum.py # @Software: PyCharm # 找出正整数中偶数,并输出相加后的数 import random def IntNum(a): sum = 0 i = 0 while a > 0: i = a % 10 if i % 2 == 0: sum += i a /= 10 a = int(a) return s...
1fcee854eaaed8e17501301c1f904d834831b97c
Koshai/TicTacToe
/test_EndGameConditions.py
2,010
3.515625
4
import unittest from EndGameConditions import EndGameConditions class EndGameTest(unittest.TestCase): # Testing multiple game over conditions def test_game_over_one(self): board = ["0", "1", "2", "3", "4", "5", "6", "7", "8"] game_end = EndGameConditions().game_is_over("X", "O", board) ...
5855d5e9dd3c7f6e43b73bc55d69da704fa1ccff
Samrfgh/Project-Euler
/Problem 46.py
656
3.9375
4
import math def is_prime(x): if x == 1: return False for i in range(2,int(math.sqrt(x)) +1): if x % i == 0: return False return True def list_of_primes(x): plist = [] for i in range(2,x): if is_prime(i): plist.append(i) return plist def composite...
662937e766bc10c5a08b60dc33dad0c6eb4dcfa4
a289237642/myLeetCode
/Python3/70. 爬楼梯 copy.py
1,276
3.796875
4
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入: 3 输出: 3 解释: 有三种方法可以爬到楼顶。 1. 1 阶 + 1 阶 + 1 阶 2. 1 阶 + 2 阶 3. 2 阶 + 1 阶 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/climbing-stairs 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注...
b7880b2acbbac3dd6cc0b18f7a493bc43e658ec1
marymhu/Project_Euler
/euler_06.py
728
4.0625
4
""" Sum square difference https://projecteuler.net/problem=6 """ def sum_square(max_term): """ Sum of the squares of the first max_term natural numbers """ sum_sq = 0 for i in range(1, max_term+1): sum_sq += i * i return sum_sq def square_sum(max_term): """ Square of the sum ...
a1198a6ce9a47b29d2cf0299e46b9e15dc5dd05d
k-schmidt/Insight_Data_Engineering_Coding_Challenge
/tests/test_trie.py
2,259
3.65625
4
""" Test Trie and Node Kyle Schmidt Insight Data Engineering Coding Challenge """ import unittest from src.pkg.trie import Node, Trie class TestTrie(unittest.TestCase): @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass def setUp(self): se...
534055f1776ab1e93635acf2dc76c28288e7aa91
IanTheDrummer/lpthw
/Rooms.py
8,713
3.984375
4
from sys import exit from random import randint class Room(object): def enter(self): print "Blah blah blah." exit(0) class Startup(Room): def enter(self): print "Welcome to The Dark Corridor! Would you like instructions? Y or N?" answer = raw_input("> ").lower() if answer == "y": print "The Dar...
b7bc08a8cd1e8ac6d02e5e4962113b3d67e96312
agamblin/assignment08
/fv.py
787
3.875
4
class FutureValueCalculator(): presentValue = None annualInterestRate = None numberOfYears = None def __init__(self, presentValue, annualInterestRate, numberOfYears): self.presentValue = presentValue self.annualInterestRate = annualInterestRate self.numberOfYears = numberOfYears...
431cf402fe51a2fc128f82123ecf0e231ffea821
ssgantayat/Datastructures-in-Python
/Revision/ReversePolish.py
897
3.71875
4
class Solution(): def evalRPN(self, tokens): if len(tokens) == 1: return int(tokens[0]) elif len(tokens) == 0: return 0 else: OPERANDS = [] OPERATORS = ['+', '-', '*', '/'] for i in tokens: if i not in OPERATORS: OPERANDS.append(int(i)) else: no1 = OPERANDS.pop() no2 ...
fb98ff3bad353a5b25f0569904cdec9022160d24
ctucker02/CircuitPython
/Led_button_switch.py
1,845
3.53125
4
import time import board from digitalio import DigitalInOut, Direction, Pull from lcd.lcd import LCD from lcd.i2c_pcf8574_interface import I2CPCF8574Interface from lcd.lcd import CursorMode lcd = LCD(I2CPCF8574Interface(0x27), num_rows=2, num_cols=16) button = DigitalInOut(board.D2) #make button pin button.directi...
765550f62421711e52230aa009dcaef8d74ea411
avisek-3524/Python-
/einstein equation.py
149
4.25
4
'''calculating e=mc^2''' m=float(input('enter the mass: ')) c=float(input('enter the velocity: ')) e=m*c*c print('the value of energy E is: '+str(e))
fe644bbbd8c2fe3a57e1bcce187d7ea014da0cd1
l202173005/prak-ASD
/modul3.py
4,896
3.53125
4
#1 a = [[6,9],[8,4]] b = [[7,2],[5,5]] #A def cekMate(matrix): jumlah = len(matrix) hasil = "" for x in matrix: for i in x: assert isinstance(i, int),"Must Integer" return True #B def Ukuran(matrix): return("Matrix size = "+str(len(matrix))+" x "+str(len(matrix[0]))) #...
f51e528ea8d5a94e12135b98ddd9f044ce413dff
csmdoficial/aulas-python
/curso/venv/bin/exercicios/exx005.py
105
3.703125
4
n1 = (float(input('Digite um numero;'))) n2=n1-1 n3=n1+1 print("Anterior {}; Posterior {}".format(n2,n3))
aa62d830cfe4851024544d1926daddba228e5c76
JoaoZati/ListaDeExerciciosPythonPro
/ExerciciosComString/Ex_12.py
1,431
3.78125
4
#%% 12 - Valide e Corrija o telefone import sys """ Valida e corrige número de telefone. Faça um programa que leia um número de telefone, e corrija o número no caso deste conter somente 7 dígitos, acrescentando o '3' na frente. O usuário pode informar o número com ou sem o traço separador. Valida e corrige número...
88e01c746f5ae8bbeb554e77c0a7ac3f7fd0934a
joshiue/holberton-system_engineering-devops
/0x15-api/0-gather_data_from_an_API.py
1,194
3.578125
4
#!/usr/bin/python3 ''' module to print data from an api ''' import requests import sys def gather_data(): ''' gathers data from the api ''' try: userid = sys.argv[1] except: print('Usage: ./0-gather_data_from_an_API.py <employee ID>') return userurl = 'https://jsonplaceholder....
86561c0875e3a33f62a40f45d56d8911fc156dba
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex053.py
360
3.578125
4
n = str(input('Digite um frase sem acentos: ')).upper().strip() nb = n.split() na = ''.join(nb) i = len(na) s = [] # s = na [::-1] for c in range(i-1, -1, -1): s += [na[c:c+1]] s = ''.join(s).strip() print(f'{na} invertido fica: {s}.') if na == s: print(f'A frase: "{n}", é um palíndromo.') else: print(f'A f...
7ec2435159235737c4dad9e4e75cafaffbb07f3d
LucasGVallejos/Master-en-MachineLearning-y-RedesNeuronales
/02-Numpy/11-PruebasDeVelocidad.py
838
3.875
4
#Prueba de Velocidad #Descubriremos que los arrays son mas rapidos que las listas import numpy as np from timeit import Timer from numpy import arange size = 1000000 timeits = 1000 #Vamos a realizar operaciones de tamaño 1000000, 1000 veces nd_array = arange(size) a_list = list(range(size)) print("Dado el siguiente ...
19237218f2be39e37f548156636bca740899ab40
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/schcha027/question2.py
680
4.03125
4
cost=eval(input("Enter the cost (in cents):\n")) money=0; while(cost>money): money=money+eval(input("Deposit a coin or note (in cents):\n")) change=money-cost twentyfive=0 tencent=0 fivecent=0 onecent=0 dollar=change//100 twentyfive=change%100//25 tencent=change%100%25//10 fivecent=chang...
57be89cdff29e6269488ce75603b0e6f56873861
ar95314/codekata_hun
/dig_sum_pal.py
94
3.53125
4
n=input() s=0 for i in n: s+=int(i) p=str(s) if p==p[::-1]: print("YES") else: print("NO")
a08e52736245207864ecdcbf4475abf25861cae0
donghankim/Algorithms-with-Python
/Recursion/tower_of_hanoi.py
835
4.03125
4
# return the number of moves it takes to solve tower of hanoi given number of disks # check this link for more details https://www.geeksforgeeks.org/c-program-for-tower-of-hanoi/ global moves moves = 0 def tower_moves(n: int) -> int: global moves if n == 1: moves += 1 return else: ...
8ed6e965dbd04a7603ca850b94cfa0bf8b00cd94
nuria/study
/misc/five-problems/problem2.py
751
4
4
#!/usr/local/bin/python ''' Write a function that combines two lists by alternatingly taking elements. For example: given the two lists [a, b, c] and [1, 2, 3], the function should return [a, 1, b, 2, c, 3] Invoque like: python problem2.py '1 2 3' 'a b c ' ''' import sys def mix(long_list, short_list): result =...
1b856d5b66bae0fa0cf41dc21d991e1020dd164d
AniketArora/oefProgramming
/mauritsOefeningen/week1/oef6.py
274
3.546875
4
b = float(input('Geef de basis van de driehoek op: ')) h = float(input('Geef de hoogte van de driehoek op: ')) opp = round(b*h/2, 2) #round(getal, aantal) limiteert het aantal getallen na de komma tot een gekozen aantal print ('De oppervlakte bedraagt ' + str(opp))
f6d41dc042fc73219e43d09898b10c043b953e5a
mburakergenc/Essential-Algorithms-Python
/Queues/ExtraQueues.py
999
4.5
4
class Queue: """ Queue Example using the power of Lists """ def __init__(self): self.items = [] def __str__(self): return str(self.items) def isEmpty(self): """ Check if the Queue is empty :return: """ return self.items == [] def enq...
de5925e2e77dceda3fa211fdda79069085ccc9a9
XOR-XNOR/Artificial-Intelligence
/minimax.py
1,240
3.625
4
import math class MINIMAX: def __init__(self,node,text): self.node = node self.text = text self.map = {} with open(text) as file: for line in file: a = line.split() key = a[0] value = a[1:] self.map[key] = ...
41f2a2d95d562efb6badf1fde010f6646c5fbe5d
ananeke/Studia
/OOP_python_laborki/zadanie_3_prostokat.py
693
3.578125
4
class Prostokat: def __init__(self, bokA, bokB): self.bokA = bokA self.bokB = bokB def pole(self): self.wynik = self.bokA*self.bokB return self.wynik p_1 = Prostokat(3,2) #print(p_1.bokA) #print("Pole 1 prostokata ", p_1.pole()) p_2 = Prostokat(12,1) #p...
14298107dcd184b3e6d5dfac4359288bbfe86984
Bertram-Liu/Note
/NOTE/02_PythonBase/day20/code/mylist2.py
506
3.90625
4
# 此示例示意复合赋值算术运算符的重载 class MyList: def __init__(self, iterable=()): self.data = [x for x in iterable] def __repr__(self): return "MyList(%s)" % self.data def __mul__(self, rhs): print("__mul__") L = self.data * rhs return MyList(L) def __imul__(self, rhs):...
57d7c9014e8e326b197a0b704a3eebea6e8caa32
RetamalVictor/Victor_portfolio
/Football_analytics/1LoadInData.py
2,255
3.59375
4
#Load in Statsbomb competition and match data #This is a library for loading json files. import json my_path = 'C:/Users/victo/Desktop/Datascience/Projects/Football/SoccermaticsForPython-master/Wyscout/' #Load the competition file with open(my_path + 'Statsbomb/data/competitions.json') as f: competitions = json.l...
92326d1e3ac6cdf8a5c1b9e9bb8089ea031f8618
suyash248/ds_algo
/DynamicProgramming/waysToReachAtPostionInMatrix.py
845
3.9375
4
from Array import empty_2d_array """ [ 0 1 2 3 4 0 [ 1, 1, 1, 1, 1 ] 1 [ 1, 2, 3, 4, 5 ] 2 [ 1, 3, 6, 10, 15] 3 [ 1, 4, 10, 20, 35] ] """ # https://www.youtube.com/watch?v=Z9XWbqxyn3E def ways_to_reach_position(rows, cols, position=(0, 0)): table = empty_2d_array(rows, cols, fil...
1fd721707c39bb0cc337bae5dc4b8c97422b8da8
davidth4ever2/ai
/driver.py
5,976
3.625
4
import sys, copy from collections import deque class SimpleNode: action = None direction = None parentNodeState = None currentNodeState = None class Node: floor = None door = None state = None parent = None isLeaf = False maxdoor = None maxfloor = None canMoveUp = Fals...
d3d2e764781514a8b776a24daa11585267df5bc4
jabes-christian/Curso-Python
/Python-Exercícios&Aulas/Ex019 - Sorteando um Itém e uma Ordem na Lista.py
483
3.59375
4
import random a1 = input('Primeiro Aluno: ') a2 = input('Segundo Aluno: ') a3 = input('Terceiro Aluno: ') a4 = input('Quarto Aluno: ') list = [a1, a2, a3, a4] sort = random.choice(list) print('O aluno escolhido foi {}'.format(sort)) print('-'*20) from random import shuffle n1 = input('Primeiro Aluno: ') n2 = input('Seg...
f05f4beb6f52a2e513a13ccc9386e2bf73ef6600
iyan9/wee
/Version4.py
13,231
3.5
4
''' 1. 第二個按鈕功能寫完了 - 點擊後,隨機一個顏色的所有色塊會全部消掉 2. 修改了一些小bug - 不會再有色塊吊出螢幕了 - 還有一些我忘了 ''' import random from collections import deque import pygame from pygame.locals import MOUSEBUTTONUP, QUIT Color = { 1: (0, 206, 209), 2: (179, 153, 255), 3: (255, 128, 191), 4: (255, 253, 208), 5: (77, 128, ...
ddf1084e62f6583f435f6c7e109ea113b8868758
wait1ess/Leetcode
/Triangle.py
1,305
3.53125
4
# 将一个二维数组排列成金字塔的形状,找到一条从塔顶到塔底的路径,使路径上的 # 所有点的和最小,从上一层到下一层只能挑相邻的两个点中的一个。 # 把triangle二维数组转化: # 把每一行的数列都左对齐 # 上一行到下一行就两个选择,横坐标不变或加一 class Solution(object): def minimumTotal(self, triangle): n = len(triangle) dp = triangle[-1] # 创建与金字塔底层同样长度的dp数组,记录状态,初始化为底层元素 # dp[i...
6d30df129c112af23d934c304d9dbb9a1d22b8a1
Pablodias147/Python3-Curso
/PycharmProjects/exercícios/ex095.py
1,343
3.59375
4
time = list() dados = dict() partidas = list() while True: dados.clear() dados["nome"] = str(input("Nome: ")) tot = dados["partidas"] = int(input(f"Quantas partidas {dados['nome']} jogou? ")) partidas.clear() for c in range(dados["partidas"]): partidas.append(int(input(f"Quantos gols no {c ...
743596cca60df61dffee48071b03659aef591f4c
IshratEpsi16/Digital_Electronic_Store
/tech_product.py
849
3.90625
4
class Tech: #class variable total_products = 0 discount = 0.5 #creating def __init__(self,name,price,weight,color): self.name = name self.price = price self.weight = weight self.color = color Tech.total_products = Tech.total_products + 1 #creating all the...
67e4830236e2b87d7edac40398ba9af0a1770789
Vovanuch/python-basics-1
/happy_pythoning_cource/Part_2/2.5.2.Metres_from_santimetres/2.5.2.metres_from_santimetres.py
701
3.78125
4
''' Расстояние в метрах Напишите программу, которая находит полное число метров по заданному числу сантиметров. Формат входных данных На вход программе подаётся натуральное число – количество сантиметров. Формат выходных данных Программа должна вывести одно число – полное число метров. Sample Input 1: 345 Sample ...
7130c83f6676d12238e7845140587115e0c22b0f
Momentum-Team-10/python-word-frequency-TrentHurlbut
/word_frequency.py
3,163
4
4
import string STOP_WORDS = [ "a", "an", "and", "are", "as", "at", "be", "by", "for", "from", "has", "he", "i", "in", "is", "it", "its", "of", "on", "that", "the", "to", "were", "will", "with", ] """Two packages importe...
59897eb7c3cf60d9d20fc49550f9cdc244776abf
urchaug/python-scripts
/startree2.py
465
3.625
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 31 00:15:14 2018 @author: Urchaug """ height = eval(input("enter the height of tree: ")) row=0 while row < height: count = 0 while count < height - row: print(end=" ") count += 1 count = 0 while count < 1*row + 1: p...
263d250049ca39e6422e244f15a5c2eb196e7b75
NemboKid/text-analyzer
/analyzer.py
3,330
3.75
4
""" All functions """ from collections import Counter import re global_dict = {} standard_textfile = "phil.txt" def open_file(): """ Opens file """ global standard_textfile open(standard_textfile, "r") return standard_textfile random = 0 def lines(): """ Counts number of lines "...
57c6b07d5f475063ae90962cf1db6105e2fd8903
VolodymyrVolodymyrovych/Vovan
/HW4/HW_1.4.4.py
161
3.65625
4
a = [] n = 1 while n != 0: n = int(input("0 for exit another count for continue: ")) b = input("Write some words:") a.append(b) print(a) print(a)
431e110df47c189fd5460392af82061f18906940
nashfleet/codefights
/arcade/intro/level12/spiralNumbers.py
705
3.765625
4
""" Construct a square matrix with a size N × N containing integers from 1 to N * N in a spiral order, starting from top-left and in clockwise direction. """ def spiralNumbers(n): a = [[0 for x in range(n)] for y in range(n)] b = 0 position = (0, 0) dir = [ (0, 1), (1, 0), (0, ...
337866402a7fa458de3076f20291b064522df90d
chum-ch/python
/game/ex-game3.py
1,288
4.03125
4
import tkinter as tk import random root = tk.Tk() root.geometry("600x600") canvas = tk.Canvas(root) oval3 = "" ball_move_down3 = True move_x3 = 5 move_y3 = 5 # create a oval with the middle position def draw_a_oval3(x, y, size): global oval3 x1 = x - size y1 = y - size x2 = x + size y2 = y + size ...
37d0407fb9c51ec9f7c4006d3bfddc152ab9dcc2
xavierbox/MSCAI
/AIPropgrammingCourse/Unit2Ants/MyBotImproved1.py
14,968
3.796875
4
#!/usr/bin/env python from ants import * from Graph import GraphNode from Graph import Graph, RectGrid import random import time class AntNode(): """ Holds the information of a node. Such as its location, parent and the direction from parent to this node. todo: move all the fields to @property ...
34ca4ac61fb7d234dac851112936ed027cfd370e
ShyZhou/LeetCode-Python
/300.py
1,334
3.96875
4
# Longest Increasing Subsequence """ Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may be more than one LIS combination, it ...
07e62f2ce7807de010457273e785bb4dc46ac90d
yutoo89/python_programing
/basic_grammar/function_define.py
1,731
4.21875
4
# 関数の定義と実行(任意の名前とパレンテシス) def say_something(): print('hi') say_something() # 戻り値のある関数 def get_something(): s = 'hi' return s result = get_something() print(result) # 引数の定義 def what_is_this(color): if color == 'red': return 'tomato' elif color == 'green': return 'green papper' e...
57fb5401c00e9c5a88f88a7f5bf3bd45e16d52b2
Srbigotes33y/Programacion
/Python/Aprendizaje/Condiociones anidadas/Taller Condiciones2/Ejercicio_1.py
936
3.953125
4
# Realice el siguiente programa e indique que hace. # Declaracíon de variables EdadJuan=int(input("Indique la edad de Juan: ")) EdadMario=int(input("Indique la edad de Mario: ")) EdadPedro=int(input("Indique la edad de Pedro: ")) # Determinar quiénes son contemporáneos # Los 3 if EdadJuan == EdadMario and EdadMario=...
9f17eed7563af64594b35ec913b5b60f0ed9f11f
zyj16602159899/lemon_class
/class_1116/object_04.py
541
4.0625
4
#!usr/bin/env python #-*- coding:utf-8 -*- #超继承 # super(子类的名称,self) class MathMethod: def __init__(self,a,b): self.a = a self.b = b def add(self): print(self.a + self.b) def sub(self): return self.a + self.b class MathMethod_01(MathMethod): def divide(self): ...
7c8e517b323bd04b3a800a341f1fab6b3e21596a
gwcahill/CodeEval
/happy_numbers/happy_num.py
1,759
4.15625
4
''' Created on Jan 29, 2015 A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not...
1d8dbbeef401512bfae927be07f9c26ff9dcd7dc
vdpham326/Python
/Control_Flow/python_functions.py
209
3.546875
4
def over_budget(budget, food_bill, electricity_bill, internet_bill, rent): total_bill = food_bill + electricity_bill + internet_bill + rent if budget < total_bill: return True else: return False
3596fbb2755eb4155167c86d0007dac998dd2ccc
jenni22jennifer1999/jennipython
/gas.py
770
3.59375
4
#!/usr/bin/env python import sys import RPi.GPIO as GPIO import time # Pin Setup def setup(): GPIO.setmode(GPIO.BOARD) # GPIO Numbering of Pins GPIO.setup(19, GPIO.OUT) # Set pin number 19 as output GPIO.output(19, GPIO.LOW) # Set 19 to LOW to turn off the gas def loop(): while True: pri...
1ba807b5a530d1b0addcf60a6fa90d606de96ef2
JRBCode/Python
/TKinter/d_input/tk_2.py
889
3.78125
4
# # tk_2.py # @author bulbasaur # @description # @created 2019-07-23T18:13:40.785Z+08:00 # @last-modified 2019-07-23T18:36:53.007Z+08:00 # from tkinter import * root = Tk() Label(root, text="作品:").grid(row=0, column=0) Label(root, text="作者:").grid(row=1, column=0) e1 = Entry(root) e2 = Entry(root) e1.grid(row=0, c...
039ed5f53faf66644e65b107368d8642c556e833
darigas/BFDjango_2018
/Week_1/CodingBat/List-1/first_last6.py
111
3.5625
4
def first_last6(nums): if nums[0] is 6 or nums[len(nums) - 1] is 6: return True else: return False
a5081d8892921fcf0caa460f7a200f893540ff3c
mewxz029/SplitData
/test.py
1,772
3.53125
4
import pandas as pd import csv dataframe = pd.read_excel ('75 Material_Type 03.xlsx', sheet_name='75 Material_Type 03') material_des = dataframe['Material_Description'].tolist() x = ['A','B','C','D','A'] y = ['AAA','C','D','BBB'] def compare(x,y): for i in range(len(x)): for j in range(len(y)): ...
6fb20b2b50493ca5c55a6d3aa2b69c996486381f
eunjungchoi/algorithm
/matrix/994_rotting_oranges.py
2,504
3.78125
4
# In a given grid, each cell can have one of three values: # # the value 0 representing an empty cell; # the value 1 representing a fresh orange; # the value 2 representing a rotten orange. # Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. # # Return the minimum numb...
25cd1c2bb4b36133679da455c16baa83cfe34d33
oleberdal/project-euler
/problems_0-99/problems_0-9/problem_3/largest_prime_factor.py
838
3.671875
4
""" Author: Berdal, Ole Created: 25.09.2018 Edited: 27.03.2019 Version: Python 3.6.7 https://projecteuler.net/problem=3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? """ import time start_time = time.time() def prime_factors(number, start=3): for d...
7941943695cf2d0c7ae1551f481d39758b4ed156
irekpi/lekcje
/python-mid/zmienne_i_kod/3.typ_logiczny.py
777
3.65625
4
options = ['load data', 'export data', 'analyze&predict'] choice = 'x' def display_options(list1): print(['{}. {}'.format((i+1), options[i]) for i in range(len(options))]) choice = input('podaj wartosc ') return choice while choice: choice = display_options(options) if choice != '': pri...
0f15f7c8232f2878e1c325bf2a25b38393b7f921
llelupe/DeepLearning-from-Scratch
/3. 신경망/3.2.3.code.py
267
3.734375
4
import numpy as np import matplotlib.pylab as plt def step_function(x): return np.array(x>0,dtype=np.int) x=np.arange(-5.0,5.0,0.1) # -5.0~5.0 범위 0.1 단위 배열 생성 y=step_function(x) plt.plot(x,y) plt.ylim(-0.1,1.1) # y축의 범위 지정 plt.show()
4ad58fc399e04a0310efec2827573525ae944a6c
Programacion-oct19-feb20/practica04-alexander-jm11
/AlexanderJimenez/Ejercicio_python/ejercicio5.py
411
3.640625
4
""" @autor: alexander-jm11 nombre: ejercicio5.py descripcion: ... """ # System.out.println("Ingrese su nombre") # nombre = entrada.nextLine() nombre = input("Ingrese su nombre") edad = input("Ingrese su edad: \n") nota1 = input("Ingrese el valor de su nota 1: ") nota2 = input("Ingrese el valor de su nota 2: ") suma =...
3e9ce273cb3966c2578c9bbed26f9717dfce3bc2
minhajh/bme547ci-mhuss93
/tachycardia.py
2,242
4.34375
4
def simplify_string(s): """ Removes trailing punctuation and whitespace from single word string and converts to lower case :param s: single word string :return: lowercase string with trailing punctuation and whitespace removed """ from string import punctuation simplified_string = s.replace...
144831c15f70c4e046f167fd862f471aec08a483
pooja-pichad/ifelse
/kkko.py
313
4
4
n = int(input("Please enter the amount of rows: ")) i = 0 while(i <= n): spaces = n -i j = 0 while(j <=spaces): #j is defined a space counter print(" ", end='') j =j +1 stars = 2*i-1 while(stars > 0): print("*", end='') stars =stars-1 print() i=i+1
1dcacd494c13ac3042ac8941e80dbed2068c4241
EnzoEsper/pybots
/mybot4.py
1,224
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # THIS BOTS TWEETS OUT RANDOM ITEMS FROM A CSV FILE # Housekeeping: do not edit import tweepy, time, csv from random import randint from credentials import * auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET) api =...
8fbc8d55fb3f10fbdb2043df23e71cabd89f2e44
xytxytxyt/unlucky_numbers
/unlucky_numbers_test.py
2,459
3.546875
4
import unittest import unlucky_numbers class TestUnluckyNumbers(unittest.TestCase): test_unlucky_numbers = { 3: 'test unlucky number three', 5: 'test unlucky number five', } def test_contains_unlucky_number(self): self.assertTrue(unlucky_numbers.contains_unlucky_number(3, self.tes...
e6015b8024ddcf74c47650c87fb5545a994c9613
inisoye/First_Exploration
/Assignment 5/Assignment5_Code3_Function_WordReverser.py
522
4.59375
5
# Assignment Q3: Write a program to print the reversed form of a string input by a user. def reverseWord(input_string): '''Reverse an inputted string.''' reversed_string = input_string[::-1] print(input_string[::]) output = f'\nThe reverse of your input is {reversed_string}' print(output) #...
47a34248d578b8c0d643c1090e1c65eff414f13f
xKaco/Final_Exam
/Problem2/temp_parser.py
936
3.65625
4
import math import sys def main(): SUM = 0; ## sum of temperatures AMOUNT = 0; ## AMOUNT of tempteratures NUM = 0; ## number temperature = eval(sys.argv[1]) file = open('sensor_temp.txt', 'r') for line in file.read().split('\n')[2:-1]: ##reads the l...
6c5554fb81ccde9e761b061f743efff899727ade
fcdennis/CursoPython
/mundo3/parte2/parteB/ex086.py
272
3.796875
4
matriz = [[], [], []] for l in range(0, 3): for c in range(0, 3): matriz[l].append(int(input(f'Digite um valor para [{l}, {c}]: '))) print('-=' * 30) for i in range(0, 3): for j in range(0, 3): print(f'[{matriz[i][j]:^5}]', end=' ') print('')
08a0485d10029a1d07cc4c791a3ef38155bc3708
yoonho0922/Algorithm
/boj/stepbystep/recursive_func/p10870_피보나치.py
158
3.5
4
N = int(input()) def sol(depth): if depth==0: return 0 elif depth==1: return 1 return sol(depth-1) + sol(depth-2) print(sol(N))
f3e756e9c940be0ca6a307c591ff624861d40729
monikawojcik/modele_analiza_systemow
/lab2.py
2,920
4.09375
4
import math #0 Use alternative way of reading inputs - using library (0.5p) from cs50 import get_int from cs50 import get_float #1 Perimeter & field of circles with given radius X for the first circle & Y for the second one. (1p) print("-+"*40, "task 1") def perimeter(r): return 2*math.pi*r def field(r): re...
6df4758668f88d997bc406782cdcc654826303c7
b2aksoy/smallProjects
/hangman.py
1,144
3.90625
4
def hangman(): word = input("Player 1, enter a word: ") guessed = False guessedLetters = [] wordShown = list("-"*len(word)) wrongGuesses = 0 while guessed != True and wrongGuesses < 10: print(''.join(wordShown)) print("Guessed letters:", guessedLetters) guess = input("Pla...
fc76f31c4aad4dda91135c9cff3930586131876b
shekhar316/Cyber-Security_Assignments_CSE_3rdSem
/Assignment_02/Solution_02.py
523
4.125
4
# Write a function that checks whether a number is in a given range (inclusive of high and low). def check_range(num, low, high): flag = 0 for i in range(low, high + 1): if i == num: flag = 1 if flag == 1: print("Number exist in given range") else: print("Number doe...
578630090daaff4d9d105a826bd85063fd501a19
rsthecoder/Class4-PythonModule-Week7
/Find Email.py
509
4.4375
4
''' Kerim Sak Write a program that list according to email addresses without email domains in a text. Example: Input: The advencements in biomarine studies franky@google.com with the investments necessary and Davos sinatra123@yahoo.com. Then New Yorker article on wind farms... Output : franky sinatr...
66362f34cd0e320aa4241cb4665b1375cfe8e7c3
lllinx/leetcode
/217_Contains_Duplicate.py
486
4.09375
4
""" Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,2,3,4] Output: false Example 3: Input:...
32784a55fea2b553b63370aaadbcb950641c29e2
cyberosa/image_processing
/one_boxes.py
1,616
3.765625
4
#!/usr/bin/env python3 import numpy as np import sys def test_function(): print("testing function") np.random.seed(42) im = np.random.random_integers(200,300,[5,5,1]) # A 5X5 array print("array before") print(im) print("shape {}".format(im.shape)) bo = [(2,1,4,3)] om = fill_with_ones(...
adfcb459a02c02827620b721954d115e79149523
daniellic9/pythonStudy
/binaryDiv5.py
800
4.03125
4
#Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence. #Example: #0100,0011,1010,1001 #Then the output should be: #1010 #Notes: Assume the...
946d22bde3b7a2e83d9caa587b7d14e104d8e25c
songzy12/LeetCode
/python/List.py
374
3.796875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def initList(vals): dummy=ListNode(0) tmp=dummy for x in vals: tmp.next=ListNode(x) tmp=tmp.next return dummy.next def printList(head): while head!=None: ...
618caaf9a471f010419482094aac1abd6fda9a3c
MinnieSmith/CITS1401
/Lab3/replaceNumber.py
224
3.734375
4
def replaceNumber(string, substring, newsubstring): s = string.lower() t = substring.lower() u = newsubstring.lower() print(s.replace(t, u)) replaceNumber("Ten is ten is TEN is TeN", "Ten", "ten(10)")
d5f6de133f06f60974856395e2b207f8a7664ad2
Hartorn/thc-net
/thc-net/src/thc_net/safe_label_encoder.py
1,486
3.578125
4
import numpy as np from sklearn.preprocessing import LabelEncoder UNKNOWN_VALUE = ["Unkn0wnV@lue"] class SafeLabelEncoder(LabelEncoder): """ Safe label encoder, encoding every unknown value as Unkn0wnV@lue. """ def fit(self, y): """ Fit the label encoder, by casting the numpy array a...
bf422a4896da74e875f32b8174d293d39bcf3bfd
aiden0z/snippets
/leetcode/030_substring_with_concatenation_of_all_words.py
3,984
3.796875
4
""" Substring with Concatenation of All Words You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. Example 1: s = "barfoothefoofarma...
d8d8dfda826d2a357f04ef69a855ab9577a0df53
AlKoAl/-10
/7.py
636
4.125
4
# Задача № 2. # Напишите программу вычисляющую произведение двух целых чисел. # В программе гарантируется, что числа - целые. В программе запрещается использовать операцию *(умножить) a = int(input()) c = a b = int(input()) v = b res = int(0) import math a = math.fabs(a) b = math.fabs(b) while (b > 0): ...
5e989535b5178ea7fd325de073c28bd5908c6fd2
neuxxm/leetcode
/problems/437/test.py
718
3.703125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None #15:31-16:44 def dfs(x, y, s, z): s += x.val if x.left: dfs(x.left, y, s, z) if x.right: dfs(x.right, y, s, z) if s ==...
73dbc34722a910d21bc3f9941f4425e440e1f881
dragospanzari/Python
/program_with_numbers.py
3,072
4.25
4
# variable = input() #String # integer = int(input()) #Integer # floating_point = float(input()) #Float # the average amount of money per month money = int(input("How much money do you spend per month: ")) # the number of miles per piece of money n_miles = 2 # earned mi...
ed4e87241e71a4956dd28268f46f17611ac52c43
RajatPrakash/Python_Journey
/regular expression_search.py
187
4
4
import re #imorting for regular expression user = input("enter the string") result = re.search(r'\w\w\w', user) print(result.group()) result = re.findall(r'w\w\w\w',user) print(result)
56c7ddec8f5b1d61a608f992cbf39d54106b6a92
THAMIZHP/python-programing
/Lv1 total calculation based on discount for greater than 1000.py
150
3.734375
4
#n is the quantity n=int(input()) t=n*100 d=t/10 T=t-d if(t>1000): print(T,'is the total cost') else: print(t,'is the total cost')
a5472be5497a6a7707baff2486f75a20197568c5
avoss19/Module-9
/9.3.3/Fin.py
711
3.609375
4
# Engineering 2 9.3.3 # Imports python projects (calc, Euler1, Euler6, Euler17) # Created by Andrew Voss # spacer sp = "-" * 40 # choose project print sp x = raw_input("""What task do you want to preform? 1. Calculator 2. Euler 1 3. Euler 6 4. Euler 17 5. What is a Euler? %s > """ % sp) # Import and run chosen proje...
236978c9673ef68431bfb7de959418f3f2beac97
IndujaE/icta_7
/python/function.py
1,018
4.125
4
# def display(): # print("helloworld!!") # display() # def add(x,y): # z=x+y # print(z) # add(3,5) # a=int(input("enter num1 : ")) # b=int(input("enter num2 : ")) # def add(): # c=a+b # print("addition : ",c) # def sub(): # c=a-b # print("subtraction : ",c) # def mul(): # c=a*b # ...
4170906f1e20f8111153214e88b0982a2016c4f0
xpy1992/LeetCodeSolutions
/273 Integer to English Word.py
1,263
3.65625
4
''' Integer to English Words https://leetcode.com/problems/integer-to-english-words/ ''' lessThan20 = ["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"]; tens = ["","","Twenty","Thirty","Forty","Fifty","...
31f1e9ae79a879ad036234e7de339c70263813f0
maxvalencik/pythonExercises
/words.py
279
4.25
4
def print_upper_words(words, must_start_with): """For a list of words, print out each word on a separate line, but in all uppercase.""" for word in words: for letter in must_start_with: if word[0] == letter: print(word.upper(), '\n')
667b9e6faa59da39d8f10ec6620e7cbc8958b796
XuanX111/Stanford-University
/course1/week1/insertion sort.py
367
3.8125
4
# insertion sort input = raw_input('Enter any two integer number separated by space') input_list = input.split() input_num = [float(a) for a in input_list] n = len(input_num) for j in xrange(1,n): key = input_num[j] i = j-1 while i>=0 and input_num[i]>key: input_num[i+1] = input_num[i] i =...
830ff735094eebe3c2c0395ea6d4c7809757485d
oliveirasWell/java-comment-parser
/commentParser/abstract/Scanner.py
1,849
3.640625
4
class Scanner: def __init__(self, file_path, special_characteres_list): self.actual_line = 0 self.actual_token = "" self.actual_position = -1 self.file_path = file_path file = open(file_path) tokens = [] for line in file: line_of_loop = line ...
b8e2ac22ce97b3f526df76ee352fb6118929f668
anooprh/leetcode-python
/algorithm/a557_Reverse_Words_In_A_String_III.py
407
3.53125
4
import os class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ return ' '.join(map(lambda x : x[::-1], s.split(' '))) if __name__ == "__main__": print("Running", os.path.basename(__file__), end=' ') assert Solution().reverseWords("Let...
5c8b0fb7225f35103d352918965cd82a16130e83
harsha-kadekar/Chitralochana
/Chitralochana_app2/tests/test_userModel.py
1,818
3.59375
4
###################################################################################### # Name: test_userModel.py # Description: This file has unit tests that will test the user database and class # References: - # Date: 1/30/2017 ###################################################################################### im...
22965dc4c8f94265dfbc11773901e37a2c206eb3
anuthms/luminarpythonproject
/language fundamentls/pythonstring.py
161
3.75
4
name=("luluminar technolabtt") #words=name.split(",") #print(words) #print(name.upper()) name=name.lstrip("lu") print("name=",name) #name=name.rstrip("tt") #print("name=",name)
5d0a532cd4b1b3ce0e344e864f8db2c4fb5e04c6
PeterL64/UCDDataAnalytics
/8_Introduction_To_Data_Visualization_With_Seaborn/2_Visualizing_Two_Quantitative_Variables/1_Creating_Subplots_With_Col_And_Row.py
710
4.0625
4
# Creating Subplots with Col and Row # relplot() stands for Relational Plot, i.e. plots that are related to one another. # Change to use relplot() instead of scatterplot() # sns.scatterplot(x="absences", y="G3", data=student_data) sns.relplot(x="absences", y="G3", data=student_data, kind='scatter') # Modify the code...
c3ad77cbe106034563e798d823c35e1083586901
YukiYoshimatsu/updated-hub
/tkinter2.py
7,238
4.15625
4
from Tkinter import * window = Tk() def your_hub(wind): wind.withdraw() hub = Tk() hub.title("Central Hub") hub.geometry('300x300') lbl = Label(hub, text="Please select a lesson to learn") lbl.grid(column=0, row=3) btn = Button(hub, text="1", bg="green", fg="blue", command=lambda: next_...
f9c76a1df304e5d559203917a169998d13de0337
christophchamp/xtof-devops
/src/python/underlines.py
866
4.125
4
#!/usr/bin/env python # SEE: http://www.lleess.com/ class A(object): def __method(self): print "I'm a method in A" def method(self): self.__method() class B(A): def __method(self): print "I'm a method in B" a = A() a.method() b = B() b.method() class CrazyNumber(object): ...
0fe194f03388534f3ad55a0a02f396dc4cd1d9ab
YutingYao/leetcode-2
/Arrays/three_sum.py
3,473
3.796875
4
""" Three Sum. (3Sum) Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. The solution set must not contain duplicate triplets. """ from typing import List class Solution: def threeSum(self, nums: List...