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
e3dba1a357315896b8e6c6e79d6811f4ecf2f5eb
chenlongjiu/python-test
/count_of_smaller_number_before_itself.py
1,829
3.53125
4
class STNode: def __init__(self, start, end, max): self.start, self.end, self.max = start, end, max self.left, self.right = None, None class Solution: """ @param A: A list of integer @return: Count the number of element before this element 'ai' is smaller than it and retur...
2d4c6e0cf32ab30fad8c1af85868013f0c3dc964
chenlongjiu/python-test
/maximum_gap.py
1,109
3.625
4
class Solution(object): def maximumGap(self, nums): if len(nums) < 2: return 0 minE, maxE = [float('inf')]*len(nums) , [-float('inf')] * len(nums) maxi, mini = max(nums), min(nums) divisor = float(maxi-mini)/float(len(nums)-1) for ele in nums: index = ...
901158655d0317ae24de8f68eb590d5ac5d01f64
chenlongjiu/python-test
/db(new).py
4,180
3.65625
4
#directly type "python database.py" under file's dir in terminal class database: def __init__(self): self.cur = {} # store (key, value) pair self.val = {} # store (value, counter) pair def set(self, key , value): if (key in self.cur) and (self.cur[key] is not None): self.val[self.cur[key]] -= 1 self.c...
3537179edbf3ca2b5758ad9a26a17ce0f39d9ad6
chenlongjiu/python-test
/2sum_ologn.py
1,564
3.65625
4
class Solution(object): def findEnd(self, start, end, target, numbers): left, right = start+1, end while left + 1 < right: print "loop1" mid = (left+right)/2 if numbers[start] + numbers[mid] > target: right = mid elif numbers[start] + n...
b596c6b8c08f7068a7f01085cb38daec06c65f2a
chenlongjiu/python-test
/palidromeLinkedList.py
1,464
3.9375
4
#Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param {ListNode} head # @return {boolean} def isPalindrome(self, head): #first judge the 1 or 0 node if head is None or head.next is None: ...
fc3c73012972dac3e980352a11044f6efd6088e1
chenlongjiu/python-test
/allPwd.py
439
3.578125
4
class Solution: arr = [] def calBase(self,digit): self.arr.append([]) if digit == 1: for i in range(10): self.arr[digit-1].append(str(i)) print self.arr else: #all the word are combine with the digit -1 self.calBase(digit-1) # now you get all the level below for i in range(10): for x i...
efa056ec08f3358df04e1da1bdef6db73dec39c3
chenlongjiu/python-test
/rotate_image.py
936
4.25
4
''' You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? ''' class Solution(object): def rotate(self, matrix): for row in xrange(len(matrix)): for col in xrange(row,len(matrix)): matrix[row][col], ma...
bda93b05ca170b33c017dabdbf9597acf98542f4
chenlongjiu/python-test
/insert_sort_list.py
1,073
4.09375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def insert(self, D, prenode, cur): prev = D prenode.next = cur.next while prev.next != cur: if prev.val < cur.val and pre...
1313feea7f8dbe75736c0efc6d6f7000372819e5
chenlongjiu/python-test
/valid_sudoku.py
1,060
3.5
4
import math class Solution(object): def isValidSudoku(self, board): #hashtable should work for this row, col, squ = [{} for _ in xrange(9)] ,[{} for _ in xrange(9)], [{} for _ in xrange(9) ] for r in xrange(len(board)): for c in xrange(len(board[0])): if board[r]...
5ffa3121cd9fbd1bcf8623f03d5fa09828c3fdd1
chenlongjiu/python-test
/interleaving_string.py
1,006
3.625
4
class Solution(object): def isInterleave(self, s1, s2, s3): if len(s1) + len(s2) != len(s3): return False if not s1 or not s2: return s1 == s3 or s2 == s3 dp = [[False] * (len(s2)+1) for _ in xrange(len(s1)+1)] dp[0][0] = True if s1 and s1[0]...
2b859b8c3a8580c5fa471979b9dd24d3f8ae14ee
katherine205203/CS50-Labs
/Week 6 (Python)/ProblemSet6 - dna.py
1,650
3.703125
4
from sys import argv, exit import csv import re from collections import OrderedDict if len(argv) != 3: print("Usage: python dna.py data.csv sequence.txt") exit(1) # Open database file and create list of people as dictionaries with open(argv[1], newline="") as database: people = csv.DictReader(dat...
d97a6603edd1c62918cc609d4ecb44ff375e3540
C-MTY-TC1028-031-2113/tarea2-decisiones-marianaa01284638
/assignments/04Cuadrante/src/exercise.py
612
3.84375
4
def main(): # Escribe tu código abajo de esta línea pass grados = int(input("Introduce los grados: ")) if 0 < grados < 90: print('cuadrante 1') elif grados == 180: print('eje') elif grados == 270: print('eje') elif grados == 360: print('eje') elif 90 < ...
0a80872cb57b2b1981a4e2161a47e8dc42b81474
aaronsebastian07/class106
/coffeeVsSleep.py
710
4
4
import plotly.express as px import csv with open("./data/cups of coffee vs hours of sleep.csv") as csv_file: df = csv.DictReader(csv_file) fig = px.scatter(df,x="Coffee in ml", y="sleep in hours", color="week") fig.show() #A correlation of 1 means the two data sets are closely correlated. This will ...
1290224ca58fbf8f17c968dcb9318ce6594845bd
geekysid/Python-Basics
/3. List, Set, Tuple/SetOperations.py
1,967
4.4375
4
print("SET OPERATIONS") setA = {1, 2, 3, 4, 5, 6, 7, 8, 9} setB = {2, 4, 6, 8, 10} setC = {"2", "4", "6", "8"} print(f"SetA : {setA}") print(f"SetB : {setB}") print(f"SetC : {setC}") print() print("==UNION (|)==") # returns every elements in two sets print(f"setA.union(setB): {setA.union(setB)}") pri...
4debf55c34b266031b2c68890e629717f6043d76
geekysid/Python-Basics
/4. Dictionary/Dictionary Challenge Modified 2.py
1,714
4.21875
4
# Modify the program so that the exits is a dictionary rather than a list, with the keys being the numbers of the # locations and the values being dictionaries holding the exits (as they do at present). No change should be needed # to the actual code. locations = {0: "You are sitting in front of a computer learning Py...
df4ef9273575f0cdc54c1fe31b593b3375198a6a
mchretien/courspython
/journee1/justeprix.py
426
3.796875
4
from random import randint print("le juste prix") price = randint(0, 1000) guess = int(input("Devine le prix:-> ")) score = 100 while guess != price: if guess < price: guess = int(input("PLUS, réessaye-> ")) score -= 10 elif guess > price: score -= 10 guess = int(input("MOIN...
fa1bb01c15d5574a9e92fe20033e3eaf183f6d31
Osazz/stack
/stackImplementation.py
3,354
3.953125
4
""" Stack Implementation following Hands-on Data Structure and Algorithms with Python (2nd Edition) by Dr. Basant Agarwal and Benjamin Baka """ class Node(object): def __init__(self, data=None): self.data = data self.next = None class Stack(object): def __init__(self): self.top = N...
0994610127e57858c71e700ed35fe297659a752d
josephwillard/Project-Euler
/prob1.py
147
3.859375
4
def summation(): x = 0 for i in range(1000): if (i%5 == 0) or (i%3 == 0): x = x + i return x print(summmation())
82d243d1b815a8b6082fce699b3e92ca51b917aa
Iwanttobuybighouse/py
/in.py
740
3.71875
4
name = 'steven' result='eve'in name print(result) ############ print(r'%s说:\'哈哈哈!\''%name) filename='picture.png'#0123456789 #-9 -8-7 -6 -5 -4 -3 -2 -1 print(filename[5])#只能获取一个字母 print(filename[0:7])#包前不包后 print(filename[3:7])#截取字符串 print(filename[3:])#表示一直取到字符串末尾 pri...
5710c863c5ff5e6a15a683fea208bba49304313f
Iwanttobuybighouse/py
/yilike_example.py
358
3.765625
4
#单词每个字母都是大写字母 #单词没有连续的字母 word =input('请输入单词:') for i in range(len(word)):#循环单词长度的次数 if word[i]<'A' or word[i]>'Z': print('不喜欢') break else: if i>0 and word[i]==word[i-1]: print('不喜欢') break else: print('喜欢')
e84a0a8fd6ebf16b95894e9cbbd92446c58b60d0
jmshin111/alogrithm-test
/palindrome linked list_dequeue_answer.py
1,201
4.03125
4
# A single node of a singly linked list import collections import timeit from typing import Deque class Node: # constructor def __init__(self, data = None): self.data = data self.next = None # A Linked List class with a single head node class LinkedList: def __init__(self): self.head = None sel...
f2436410e851f6b38629aa9519ed29537816761d
jmshin111/alogrithm-test
/revers String.py
406
3.59375
4
from pythonds.basic.stack import Stack input_str = 'hello' # str = ['h','e','l','l','o'] str_stack = Stack() str_list = list(input_str) print (input_str) for i in range(0, len(str_list), 1): str_pop_zero = str_list.pop(0) print (str_pop_zero) str_stack.push(str_pop_zero) output_str = list() for i in ra...
e75b0ab18452e7da90b5f6c81bc317224eaf24f1
jmshin111/alogrithm-test
/merge two sorted list.py
1,746
4.15625
4
# A single node of a singly linked list import sys import timeit class Node: # constructor def __init__(self, data=None): self.data = data self.next = None # A Linked List class with a single head node class LinkedList: def __init__(self): self.head = None self.end = None...
39c49662bd20245fc2c0fc5f3b55403a7789e8cc
jmshin111/alogrithm-test
/110. Balanced Binary Tree.py
1,139
3.84375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right root = TreeNode(1) root.left = TreeNode(2) class Solution: max_height = -1 min_height = 99999 result = True def isBala...
868cbbb59a41059c7c601777839987d372c12ee0
jmshin111/alogrithm-test
/most_common_word.py
1,309
3.703125
4
paragraph = "Bob hit a ball, the hit BALL flew after it was hit" banned = ["hit"] def str_validation_check(input_str, banned_str): # change all string to lowercase input_str = input_str.lower() # remove , input_str = input_str.replace(',', "") for index_banned in banned_str: print('index...
ddec866d8a4bb6be9f43abeec988a9fca030f873
jmshin111/alogrithm-test
/241. Different Ways to Add Parentheses.py
1,547
3.765625
4
from typing import List input = "1+1" input = "2*3-4*5" input = "10+5" class Solution: def operationResult(self,a:List,b:List,operator) -> List: result = [] for i in a: for j in b: if(operator =='+'): print(str(i) + " + " + str(j)) ...
a6a1d4257a1dabf6ff6f3ce3f57deb43674285b7
jekin000/Fluent_Python
/ch01_Python_Data_Structure_Magic_Function/deck.py
2,279
3.5
4
########################################## # 1.1 The deck by __getitem__, __len__ ## collections.nametuple, only property,no method's object ## for use __getitem__,__len__, the FrenchDeck get benefit like ### 1. could use python standard method, such as len, ### 2. could use python standard module, such as random.cho...
c5521931ec1f4fa347efc177c60bcc23c5f2332d
naomicht121/belajarpython
/kelas_2b/hanifah.py
4,604
3.546875
4
import csv import sqlite3 import matplotlib.pyplot as plt import requests class hanifah() : def __init__(self, kode, penurunan, hargatotal, umur): self.kode = kode self.penurunan = penurunan self.hargatotal = hargatotal self.umur = umur def travel(self): if (sel...
cadaea97f084736eab62ab81332d837333f33cc4
brainysmurf/pydir
/pydir/compare.py
264
3.5625
4
class compare: def __init__(self, name): self.name = name def __eq__(self, what): return self.name == what.name c = compare('hi') d = compare('hello') e = compare('hi') if c in [d, e]: print('success') else: print('whoa')
34bb86daab93833976c2a24146422a82b6167a66
llf0029/pokemon-scraper-refactoring
/StatisticCalculator.py
1,954
3.65625
4
""" @author: Angus Whitehead """ class StatisticCalculator: def get_min_weight(self, pokedex): return self.calculate_min(self.get_pokemon_weights(pokedex)) def get_max_weight(self, pokedex): return self.calculate_max(self.get_pokemon_weights(pokedex)) def get_avg_weight(self, pokedex): ...
ce7f9d08ae7b567610b60816908a764fe98a0b13
sukantamajhi/Computer_graphics_Lab
/csa.py
3,464
3.53125
4
# Python program to implement Cohen Sutherland algorithm # for line clipping. import matplotlib.pyplot as plt # Defining region codes INSIDE = 0 #0000 LEFT = 1 #0001 RIGHT = 2 #0010 BOTTOM = 4 #0100 TOP = 8 #1000 # Defining x_max,y_max and x_min,y_min for rectangle # Since diagonal points are enough to def...
657a297ccc6dae6e99904de5bf02156f1a6dd1ff
mhmdkhlf/Basic-Aim-Trainer
/aim_trainer.py
5,551
3.734375
4
#imports import time from random import randint from math import sqrt import os import sys import pygame ### functions of what we are displaying ### def screen(NUM_OF_HITS): window.fill(WHITE) if NUM_OF_HITS==-1: TEXT = WORD_FONT.render("PRESS THE TARGET TO START THE ROUND!" , 1 ,BLACK) ...
fc72f01f684e5f1b9dac5daa60f957b47e481e6f
henryxzx/leetcode_python
/728. 自除数/self-dividing-numbers.py
614
3.515625
4
class Solution: def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List[int] """ rList = [] for i in range(left, right + 1): num = i while num > 0: if num % 10 == 0: ...
184b641e074172c190e94375269a734030ff354e
henryxzx/leetcode_python
/922.按奇偶排序数组II/sortArrayByParityII.py
464
3.53125
4
class Solution: def sortArrayByParityII(self, A): """ :type A: List[int] :rtype: List[int] """ even, odd, ans = [], [], [] for i in A: if i % 2 == 0: even.append(i) else: odd.append(i) for i i...
27874801eb139e78d54e74102d6fcd700faee01b
barnolducd/ECI-289I_SP2016_Assignments
/Hwk1_2.py
997
3.671875
4
# Brad Arnold # ECI-289I-001, Spring 2016 # Homework 1.2 (Gradient Descent) # ------------------------------- from __future__ import division import numpy as np import matplotlib.pyplot as plt # Define Matyas Function def f(x): return 0.26*(x[0]**2+x[1]**2)-0.48*x[0]*x[1] # Gradient Normalized def fp(x): fx0 = 0...
439f8e77560fa42094e061ba7c4e1bd71956b8fd
mohdelfariz/distributed-parallel
/Lab5-Assignment3.py
1,284
4.25
4
# Answers for Assignment-3 # Importing mySQL connector import mysql.connector # Initialize database connection properties db_connection = mysql.connector.connect( host="localhost", user="root", passwd="", database="my_first_db" ) # Show newly created database (my_first_db should be on th...
eb9ec14f11b8fb3911177a1fd71c2c3079f7da15
resmony/AlgoritmosEscalonamento
/fila.py
6,235
3.609375
4
import time #APRESENTAÇÃO def apresentacao(): print("-----------------------------") print("SISTEMAS OPERACIONAIS") print("ESCALONAMENTO DE PROCESSOS") print("USANDO PAGINAÇÃO") print("-----------------------------") # ESTRUTURA DO PROCESSO class Process(object): def __i...
bd6a2280d9f0d669d42ef01e0431d49ad7c8ea3f
LeviF1234/chooseAdventure
/Bestiary.py
2,776
3.78125
4
class Enemy: #generic enemy class name = 'Scientist' attack = 'scientificated' def __init__(self,l): #initialize enemy with appropriate stats and level l self.hp = 5*l+5 self.knowledge = 15*l self.immune = 1.5*l-0.5 self.xp = 10*l self.level = l self.power = 1...
8fc6e231e5895cd0a58585b02ab8552bc947d8fd
manoj184/guvi
/reverse.py
108
3.6875
4
mn=(input()) rrr=mn[::-1] if(mn==rrr): print("yes") elif(mn!=rrr): print("no") else: print("invalid")
6f18c9f602ef0e6ad00975f316c0a78109653c47
manoj184/guvi
/bigtosmall.py
117
3.515625
4
yerasi=input() manoj=input() kumar=manoj.split() reddy=''.join(kumar) print(''.join((sorted(reddy,reverse = True))))
bab8599a60787a1378b935f810e3c0554e729166
mikaelacurrier/Data-Structures
/queue/queue.py
438
3.921875
4
class Queue: def __init__(self): # what data structure should we # use to store queue elements? self.storage = [] def enqueue(self, item): return self.storage.append(item) def dequeue(self): if self.storage: return self.storage.pop(0) def len(self): return len(self.storage) #...
9525141312b15b205951df809a04895052f77f9f
jalcajiaox/first-python
/Regular Expressions/ExtractingnNumerosWithREGEXySuma.py
460
3.609375
4
import re fname=input("Enter file name: ") fhand=open(fname) sum_list=[] for line in fhand: if line=="": #foldear las lineas espacio hueco continue x=re.findall('[0-9]+' ,line) #agarrar todos los numeros y agruparlos en lista sum_list+=x sum_num_list=[] for i in sum_list: ...
ccb2b36d43134b5df60e4d343f59176fa540581e
hansputera/belajarpy
/jumlahterus.py
187
3.875
4
def jumlahTerus(input: int): s = str(input) total = 0 for i in s: total += int(i) while(len(str(total)) > 1): total = jumlahTerus(total) return total print(jumlahTerus(12345))
dba74609e1e810ad909e26d1dde66951d219f2ce
caseychen222/Snake
/snake.py
5,401
3.59375
4
import pygame import time import random import sys pygame.init() # variables for colors and dimensions colors = { "board": (153, 153, 85), "black": (0, 0, 0), "white": (255, 255, 255), "yellow": (255, 255, 102), "red": (213, 50, 80), "green": (0, 255, 0), "blue": (50, 153, 2...
b0168a045a67deb3efdf8fe770ef011cd20c3d31
n1az/hill-cipher-py
/main.py
1,083
3.859375
4
keyMatrix = [[0] * 3 for i in range(3)] #vector for the message messageVector = [[0] for i in range(3)] #vector for the cipher cipherMatrix = [[0] for i in range(3)] #key matrix function def getKeyMatrix(key): k = 0 for i in range(3): for j in range(3): keyMatrix[i][j] = ord(key[k]) % 65 k += 1 #e...
5c3662440fd5f9061ea0905b35033703cb948cc9
antThom/Anthony-s-Humanoid-Robotic-Code
/tic-tac-toe/analyzeData.py
1,194
3.84375
4
import csv ''' 1. Get the data from a file 2. Determine which games were wins or loses for the computer 3. For computer loses, find a pattern - Look at where the human plays after the computer makes a move - Determine whether or not the human is an offensive or defensive player - Find an algorithm to use as t...
e6b00adf18195816907f84bc6011d4f5db203711
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Intermedio/Clase 02/PI0204 - PALINDROMOS.py
150
3.8125
4
s=input() sinvert="" for i in range(len(s)): sinvert=sinvert+s[-i-1] if s==sinvert: print("Es palindroma") else: print("No es palindroma")
4ab7c5f287438ab119f167e789660f0f19c9bc9f
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Intermedio/Clase 01/PI0102 - El Club de RUN.py
152
3.625
4
a1=float(input()) suma=0 for i in range(10): a2=float(input()) suma=suma+a2 prom=suma/10 if (prom>a1): print("SUBIO") else: print("BAJO")
93f9fdba1a0dcff35d138908e331651c66a063a2
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Basico/Clase 02/Clase04/PB0402 - Mayor,Menor o Igual.py
220
3.84375
4
n1 = int(input().strip()) n2 = int(input().strip()) if n1 > n2: print("Mayor:", n1, "; Menor:", n2) elif n1 < n2: print("Mayor:", n2, "; Menor:", n1) else: print("Los dos numeros son iguales.")
3fc63b6db90a43a9cf9883d9d8d20ede385ceba5
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Basico/Clase 02/Clase04/PB0416 - Año bisiesto.py
273
3.625
4
fecha = int(input()) if fecha % 400 == 0: print(fecha, "es bisiesto") elif fecha % 100 == 0: print(fecha, "no es bisiesto") elif fecha % 4 == 0: print(fecha, "es bisiesto") else: print(fecha, "no es bisiesto")
a343fcd50292efc34908b4093ed0366311088831
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Intermedio/Clase 03/PI0303 - Multiplicacion.py
148
3.53125
4
def Multiplicacion(lista): n=1 for i in range(len(lista)): n=n*int(lista[i]) return n s=input().split(" ") print(Multiplicacion(s))
17126ba175d8f32cc04d12a76a7bb61d063c99e0
RUN-tic/Soluciones-HackerRanks-RUN-2019
/Python Intermedio/Clase 03/PI0301 - Maximo.py
216
3.609375
4
n=input() n=n.split(" ") def Maximo2(a,b): if a > b: return a return b def Maximo3(a,b,c): return Maximo2(a,Maximo2(b,c)) print("El maximo numero es",Maximo3(int(n[0]),int(n[1]),int(n[2])))
65044230dfd11659dfec44d30d200a1b18e3fa29
Skolekode/Introduksjon
/Skolekoding/introduksjon/1_5utskrift.py
465
3.59375
4
""" Vi har allerede gjort flere utskrifter. Da er det på tide å lære seg om hvordan håndtere ulik utskrift. Av og til skriver vi ut tekststrenger og noen ganger variabler. Reflekter over hva utskriften blir før du prøver dem ut. Når du kopierer og kjører, hvilke utprinter overrasket deg og hvorfor? a = "Hei" b = 5 c ...
d5c6f6abdbcd1a901ab1fdfe5a8f107fe0a351c1
LonelyRider-cs/linguistic_shared_tasks
/task1/test.py
124
3.765625
4
txt = "hello" print(txt[1:]) pair = ("Z", "5") print(txt[-1]) print(txt[:-1]) print(pair[0]+txt[1:]) print(pair[1]+txt[1:])
bc17148b3b7359b302acf8a125fedce47781a8a5
RajeevPrakashAD1/python_projects
/turtle project/main.py
1,344
3.6875
4
from turtle import Turtle,Screen import turtle myturtle = Turtle() turtle.colormode(255) # myturtle.shape("turtle") # myturtle.forward(100) # myturtle.right(90) # myturtle.forward(100) # myturtle.right(90) # myturtle.forward(100) # myturtle.right(90) # myturtle.forward(100) # # i=0 # while i < 10: # myturtle.pendow...
4bb306f3389783fd7826dd2249517da88decabdd
RajeevPrakashAD1/python_projects
/snake game projet/food.py
4,201
3.640625
4
from turtle import Turtle, Screen import turtle import time import random import sys score = 0 print("welcome to snake game") screen = Screen() screen.bgcolor("black") screen.title(" SNAKE GAME") screen.setup(500, 500) x = [-40, -20, 0] l = [] p = 3 for i in range(p): tim2 = Turtle() tim2.shape("square")...
453d4cfd55465b4793848e9ba7935aff0592dde1
gopikris83/gopi_projects
/GlobalVariables.py
401
4.25
4
# -------- Defining variables outside of the function (Using global variables) ---------------- x = "Awesome" def myfunc(): print (" Python is "+x) myfunc() # ---------- Defining variables inside of the function (Using local variables) -------------------------- x = "Awesome" def myfunc(): x...
0bb52dc2bb63d956040484a849939c4694b1ffa0
danielbmx/Oving-2-Sanntidsprogrammering
/pythonthreads2.py
625
3.734375
4
from threading import Thread, Lock i = 0 lock = Lock() def incrementor(): global i for x in range(0, 1000000): lock.acquire() i += 1 lock.release() def decrementor(): global i for x in range(0, 1000000): lock.acquire() i -= 1 lock.rel...
07c316740d12e1696356fea2dfef3d0e224e5193
ShalomVanunu/SelfPy
/Targil5.3.5.py
342
4.15625
4
def distance(num1, num2, num3): num1_num2 = abs(num2-num1) num3_num2 = abs(num3-num2) # print(num3_num2) # print(num1_num2) if (num1_num2 == 1 and num3_num2 > 2 ): return True else: return False print('distance(1, 2, 10)') print(distance(1, 2, 10)) print('distance(4, 5, 3)') prin...
e0274f445b7162a420ae54e4758a66f610b6a2a9
ShalomVanunu/SelfPy
/Targil7.2.6.py
1,230
4.09375
4
def task_list(my_str): list_names = list(my_str.split(",")) number_choosen = 0 while number_choosen < 10: number_choosen = int(input('Please enter number :')) if number_choosen == 1: print(list_names) elif number_choosen == 2: print(len(list_names)) ...
5ef0f0affe3c301061f62b83edf7236d8ca12ba3
ShalomVanunu/SelfPy
/Targil2.3.3.py
282
3.5625
4
number_blocks = input('Enter three digits (each digit for one pig):') pig1 = (int(number_blocks)//100) pig2 = (int(number_blocks)//10%10) pig3= (int(number_blocks)%10) print(pig1+pig2+pig3) print((pig1+pig2+pig3)//3) print((pig1+pig2+pig3)%3) print(bool((pig1+pig2+pig3)%3) == 0)
85fa0da795f8130c75bbdb6695fae9319234c74f
ShalomVanunu/SelfPy
/Targil7.3.1.py
640
4.21875
4
def show_hidden_word(secret_word, old_letters_guessed): hidden_word = [] for letter in secret_word: if letter not in old_letters_guessed: hidden_word.append(' _') else: hidden_word.append(letter) return ' '.join(hidden_word) def main(): # Call the function func ...
adbe86cc0515fd03c14b389a712b1a98ae223a23
ShalomVanunu/SelfPy
/Targil4.2.2.py
193
4.15625
4
sentence = input('Enter a word: ') reverse_sentence = sentence [::-1] if (reverse_sentence.upper().replace(" ","") == sentence.upper().replace(" ","")): print('OK') else: print('NOT')
31a9f8f7931508d0d997f217694f9ec22b883c31
hitarthsolanki/ADV-C172-USER-DATABASE
/database.py
1,045
3.625
4
from tkinter import * root=Tk() root.geometry("500x500") label_user=Label(root,text="User Name : ") label_user.place(relx=0.3,rely=0.2,anchor=CENTER) Entry_Name=Entry() Entry_Name.place(relx=0.6,rely=0.2,anchor=CENTER) label_email=Label(root,text="User Name : ") label_email.place(relx=0.3,rely=0.3,anchor=CE...
bc378d15a1088eb0244458970ff2cd3bea8ede63
BioComSoftware/Biocom_code
/lib/functions/inputf.py
4,624
4.03125
4
def check_str_format(match_pattern, type="s"): """ check_str_format(match_pattern[type="s/r"]) input_pattern = Required pattern for input type = Pattern is in the form of a (s)tring or a (r)egex pattern Prompts the user for input in the format of <input_aattern>. Is based...
768449ebddfffe3fedc3fa7cd141b56a26a0d7a3
PedroPossato/lab2-sd
/servidor.py
2,095
3.546875
4
import socket HOST = '' # '' possibilita acessar qualquer endereco alcancavel da maquina local PORTA = 5000 # porta onde chegarao as mensagens para essa aplicacao # cria um socket para comunicacao sock = socket.socket() # valores default: socket.AF_INET, socket.SOCK_STREAM # vincula a interface e porta...
8f4b6a25ac839d3b1c249e3138b37d328e31bc9b
andymule/aoc2019
/test3.py
5,310
3.953125
4
from random import randint import keyboard, sys, os, time ######### global variables we'll be using all over the places ####### me = '☻' posX = randint(1,11) posY = randint(1,5) elusive_love = '♥' lovePosX = randint(1,11) lovePosY = randint(1,5) money = '$' moneyPosX = randint(1,11) moneyPosY = randint(1,5...
6dab92485a28291d853c9e5f4f1e4a30b15d09bf
sofiayazbek/Lista-5
/5b.py
369
3.953125
4
texto = "nome=Robson,email=robson.luz@fae.edu;nome=Joao,email=joao@email.com" registros = texto.split(";") print(f"Usuários cadastrados: {len(registros)}") print("====================") for registro in registros: campos = registro.split(",") for campo in campos: valores = campo.split("=") print(f"{valores...
014d6727c6f026e458d32151c50ff8e9c78524ec
kariato/foobar
/guard_game/solution.py
196
3.734375
4
def answer(number): while len(str(number)) > 1: newNumber = 0 for digit in list(str(number)): newNumber += int(digit) number = newNumber return number
893e2195116108da647ea936ac2b2ab8f71082ed
onimenotsuki/Curso-Python-
/Jose/scr/problema_01.py
385
3.796875
4
multiplos_3 = [] multiplos_5 = [] def multiplo(valor, multiplo): resto = valor % multiplo if resto == 0: return True else: return False for i in range(1, 1001): if multiplo(i, 3): multiplos_3.append(i) if multiplo(i, 5): multiplos_5.append(i) print("Multiplos de 3: "...
bdce4bcd4ad36f7918e44a7ff7881de98bdcae8f
Gavin-McCormick/watttime
/thermo/radiotherm/fields.py
3,769
3.859375
4
import json from . import validate class Field(object): """ Instances of this class act as descriptors on the Thermostat class. They define a piece of data from the API that can be accessed with GET and optionally with POST. """ def __init__(self, url, name, human_value_map=None, post_url=None...
7c320e74035aa99c65b7f94f9f2dcbbf4b33106d
sievetech/codingdojo
/20130307_python_suspeito/suspeito.py
1,013
3.8125
4
SUSPEITO = "Donald Duck Knuth" LOCAL = "Tokio" ARMA = "Trebuchet" TEORIA_CORRETA = (SUSPEITO, LOCAL, ARMA) LISTA_SUSPEITOS = [ "Charles B. Abbage", "Donald Duck Knuth", "Ada L. Ovelace", "Alan T. Uring", "Ivar J. Acobson", "Ras Mus Ler Dorf",] LISTA_ARMAS = [ "Peixeira", "DynaTAC 80...
dea1c721bcf1844366e5b57b83a8921d52a722c4
factabulous/matgrindr
/location_test.py
2,920
3.53125
4
#!/usr/bin/env python3 import unittest import location class LocationTest(unittest.TestCase): def test_change_system(self): loc = location.Location() loc.change_system("Sol", (1, 2, 3)) self.assertTrue(loc.is_changed()) self.assertTrue(loc.has_system()) self.assertFalse(lo...
518de8f884cc6e55120d8b78a98daaba27db062c
deficts/hackerrank-solutions
/PythonDataStructures/Sets.py
356
4.0625
4
MySet={1,2,3} MySet2={1,2,9} #Agregar objeto en set MySet.add(4) MySet.add(1)#Ignora este comando por que ya esta en el set print(MySet) #MySet - MySet2 print(MySet-MySet2) #Mostrar todos los objetos print(MySet|MySet2) #Mostrar todos los objetos que comparten print(MySet&MySet2) #Mostrar objetos que no se compar...
c23b5e18a881d02083b06c9e0cca83197c62e928
deficts/hackerrank-solutions
/PythonDataStructures/Lists.py
489
4.21875
4
MyList=[1,2,4,5] #Agregar algo al final MyList.append("hola") print(MyList) #Agregar algo en un cierto índice MyList.insert(1,"mundo") print(MyList) #Remover un objeto pasado MyList.remove("mundo") print(MyList) #Regresar y quitar un objeto de un indice o el ultimo MyList.pop() MyList.pop(0) print(MyList) #Quitar ...
f07233a8125021cbc7ebec3b5f65cdbfef94bb7a
PugnaBogdan/Graph_Algorithms
/algoritmicaGrafelor1/rootedTree.py
1,681
3.59375
4
class RootedTree: def __init__(self, root): self.root = root self.children = {} self.children[self.root] = [] self.parent = {} self.parent[self.root] = None def addChild(self, parent, child): ''' Preconditions: parent - existing node of the tree ...
ee6c8337b6029379f9bd3149b48bc4366f8a5723
rbozzini/python-repo
/examples/array_sum_functional_imperative.py
392
3.875
4
import functools my_list = [1, 2, 3, 4, 5] def add_it(x, y): print("add_it(" + str(x) + ", " + str(y) + ")") return (x + y) # https://docs.python.org/3/library/functools.html # Functional: sum = functools.reduce(add_it, my_list) print(sum) # Lambda: sum = functools.reduce(lambda x, y: x + y, my_list) prin...
8396f31c1063f6dfd94e5dac7fd25c53e4c9e0c4
DataAcctLisa/chapter-4-python-exercises
/learning python one day exercises ch4.py
6,548
4.21875
4
# chapter 4 # question 1 name1 = 'Jamie' print(name1) name2 = 'Aaron'.upper() print(name2) message = 'The names are %s and %s.' %(name1, name2) print(message) # output should be # Jamie # Aaron # The names are Jamie and AARON lang1 = 'Python' lang2 = 'Java' lang3 = 'C#' message1 = 'The most...
3f7a7ca2e6c52ff2f3649f508679da634b872478
Luini/nlp100
/chapter2/15.py
290
3.5625
4
# diff <(python3 15.py 3) <(tail -n 3 hightemp.txt) import sys N = int(sys.argv[1]) input = open("hightemp.txt", "r") lines = input.readlines() input.close() lineCount = len(lines) if N > lineCount: N = lineCount for i in range(lineCount-N, lineCount): print(lines[i], end='')
7661cf1f67c35f05610b27eb14c0614c3d0a9469
Aman-am/Machine-Learning-ud120
/datasets_questions/explore_enron_data.py
2,148
3.640625
4
#!/usr/bin/python """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features associated with that pers...
e65c2135625c668523ea865f75bc320b2cdab043
gr8tech/pirple.thinkific.com
/Python/Homework3/main.py
931
4.1875
4
''' Python Homework Assignment 3 Course: Python is Easy @ pirple Author: Moosa Email: gr8tech01@gmail.com `If` statements; Comparison of numbers ''' def number_match(num1, num2, num3): ''' Functions checks if 2 or more of the given numbers are equal Args: num1, num2, num3 num1, num2, num3 can be an Integer or ...
a5e9673e30b2bdc443666afd59a38e6c8b8396d5
shinohe/flask-manga-viewer
/db/insertDb.py
2,544
3.53125
4
# -*- coding: utf-8 -*- import sqlite3 from datetime import datetime dbname = 'db/database.db' def findBooks(id): conn = sqlite3.connect(dbname, timeout=10) c = conn.cursor() select_sql = 'select * from books where id = ?' bookParam = (int(id),) c.execute(select_sql, bookParam) for row in c: book = row co...
fbc4c72d145f853991cda9bba427f33de8ab8d08
jagadeeshindala/python
/Project.py
850
4.28125
4
#Rock paper scissors game with computer import random #Function def game(a,b): if(a == b): return None if(a=="r"): if(b=="s"): return False else: return True if(a=="s"): if(b=="p"): return False else: return True if(a=="p"): if(b=="w"): return False else: return...
f88b6f9b2ea750143aa273aaa7fa88249cba1c8c
hujiangyi/workspace_python
/mathgame/utils/TimerThread.py
593
3.609375
4
from threading import * import time class TimerThread(Thread): def __init__(self,label): Thread.__init__(self) self.label = label self.stop = False self.count = 0 def stop(self): self.stop = True def run(self): while not self.stop: tmp = self.coun...
d9cf3356eeec6ca0c38c60fadc69b756deb49b2f
ArtemCHM/SF_FPW-13_C1.8-C-1.10
/SF_C1.8-1.10/1.10.1.py
499
3.96875
4
class Rectangle: def __init__(self,x,y,width,height): self.x = x self.y = y self.width = width self.height = height def __str__(self): return f' x = {self.x} \n y = {self.y} \n width = {self.width} \n height = {self.height}' rectangle = Rectangle(5,10,50,100...
1582966887ebcfcec8a2ddb74e0823cb7b72c95e
Chethan64/PESU-IO-SUMMER
/coding_assignment_module1/5.py
212
4.25
4
st = input("Enter a string: ") n = len(st) flag = 0 for i in st: if not i.isdigit(): flag = 1 if(flag): print("The string is not numeric") else: print("The string is numeric")
963bd98a081a8fe6abd4ae643b41a7e7b63104dd
uden28/lapyh03
/latihan2.py
528
3.78125
4
def perulangan(): print(" ") max=0 while True : a=int(input("Masukan Bilangan = ")) if max < a: max = a if a==0: print(" ") print("Bilangan Terbear =" ,max) print(" ") print("Terimakasih Telah Menggunakan Program Ini") print(" ") print("DILARANG MENG COPY PROGRAM INI") PRINT(" ") ...
573426fd988ab4b68a93a2dbf514309c6aeff236
maolinwang8023/machineLearing
/Perceptron.py
988
3.703125
4
import numpy as np # 感知机原始形式 class Perceptron: def __init__(self, length): self.w = np.ones(length - 1, dtype=np.float32) self.b = 0 self.learning_rate = 0.1 # 模型 def sign(self, x, w, b): y = np.dot(x, w) + b return y # 算法 策略 def fit(self, x_train, y_train...
b1763b939881556b204228492a181420bc4b1709
tomki1/chat-system
/chatserve.py
2,935
3.78125
4
# Author: Kimberly Tom # Project 1: TCP Chat Program # Description: server side code for chat program written in Python # This is a chat system using TCP sockets that works for a pair of users, one being the client and one being the server. # Once chatserve is running on a port number, chatclient can connect to it ...
b024cf8229c1ea31c1299d283b52375d0c11ec10
Abdelmuttalib/Python-Practice-Challenges
/Birthday Cake Candles Challenge/birthDayCakeCandles.py
815
4.15625
4
####### SOLUTION CODE ######## def birthdayCakeCandles(candles): ## initializing an integer to hold the value of the highest value highest = 0 ## count of highest to calculate how many the highest value is found in the array count_of_highest = 0 ## iterate over the array to determine the high...
067c383afe1a81e2b864b2f8d274c2e7768ed190
shreyashg027/Leetcode-Problem
/Data Structure/Stacks.py
504
4.125
4
class Stack: def __init__(self): self.stack = [] def push(self, data): if data not in self.stack: self.stack.append(data) def peek(self): return self.stack[len(self.stack)-1] def remove(self): if len(self.stack) <= 0: return 'No element in the s...
b59c46d4c5935cc1f07c20fe8d9add6a4ba5ade6
shreyashg027/Leetcode-Problem
/interview/twilio.py
449
3.546875
4
class Solution: def missingWords(self, s,t): ans = [] a = s.split(' ') b = t.split(' ') j = 0 for i in range(len(a)): if j == len(b): ans.append(a[i]) elif a[i] != b[j]: ans.append(a[i]) else: ...
58de4c95a1881be4106389affa0c39aa14742edf
shreyashg027/Leetcode-Problem
/50 common Questions/5. Implement strStr().py
231
3.515625
4
import re class Solution: def strStr(self, haystack, needle): m = re.search(needle, haystack) if m: return m.start() return -1 test = Solution() ans = test.strStr('hello', 'k') print(ans)
188358c55ddfb7da61a2b59200a859efb816420c
ReemSS/PPO
/Rollout.py
4,082
3.53125
4
import numpy as np class Rollout: """ Rollout class saves the relevant data, when an agent performs an action in the environment, changes occur in the environment and the agent receive these changes as observations and rewards. In this class, the advantages and the discounted rewards ...
3959704879b54d8f9b470c31a98cea5d5631fc2e
MasonYue/python
/Automated Puzze Solving Program/puzzle_tools.py
7,039
3.71875
4
""" Some functions for working with puzzles """ from puzzle import Puzzle from collections import deque # set higher recursion limit # which is needed in PuzzleNode.__str__ # uncomment the next two lines on a unix platform, say CDF # import resource # resource.setrlimit(resource.RLIMIT_STACK, (2**29, -1)) import sys sy...
bb083b0e0bb2bde0037c10e90fd966a0c7a700da
danielemsilva/python-demos
/square_area.py
142
4.1875
4
# Calculate the area of a square side = int(raw_input("Enter the side of the square: ")) area = side * side print "The square area is", area
ef1bb0fd584bdc94496cb47a2c344f8677c94b9e
DiamondShardCoder/first_game
/infloop_while.py
136
4.09375
4
i = 0 while True: i += 1 if i % 2 == 0: print(i, 'Even') else: print(i, 'Odd') print('Done with loop')
cca2024725219e7d04954e61b84b0df18dd317ed
MaferMazu/FuncionSeguroConTDD
/test.py
1,156
3.5
4
import unittest import datetime from Person import Person def personGenerator(genre,year,quot): date = datetime.datetime(year, 1, 1) p=Person("Nombre",genre,date,quot) return p class TestPension(unittest.TestCase): #Primer caso de prueba: #Hombre con 750 cotizaciones def testPensionMale750Quot(self): p=perso...
5af6f8e99fdb6e0a1278c34e8aacffb31bb73893
mollha/AI-Search
/AI search algorithms/SimulatedAnnealing.py
10,222
3.8125
4
import random import math #<- - - - - - - - - - - - - - READ IN DATA - - - - - - - - - - - - - - - - -> with open('NEWAISearchfile012.txt') as cityFile: dataString = cityFile.read() #reads the file and stores as a string in the variable dataString index = dataString.find('SIZE')+7 ...
e57ad95e1b90aef4a2a4fef33c66fcd3c1440717
LuckyLan/Kaggle
/CCF Production Quality Prediction/transforms.py
8,296
3.515625
4
import numpy as np import pandas as pd from collections import defaultdict def to_category_fit(values): ''' This function takes a group of values as input and returns a dictionary, whose keys are original values ''' codebook = {} count = 0 for i in values: if i not in codebook.keys(): ...