max_stars_repo_path
null
max_stars_repo_name
null
max_stars_count
null
id
null
text
string
score
float64
int_score
int64
from
string
blob_id
string
repo_name
string
path
string
length_bytes
int64
null
null
null
null
import re # https://www.codewars.com/kata/5235c913397cbf2508000048/train/python # что-то придумать с дробными и отрицательными числами # не работает нормально с отрицательными и дробными '[\/\+\*\-\(\)]' # all operators '\(.+\)' # expression in brackets '\d+ [\/\*] \d+' # expression for mult and div '\d+ [\+\-] \d+' ...
3.78125
4
smollm
a541dca44a8a474fc87a73b4393fdcad4a639912
HarIgo23/codewars
/calculator v 1.py
3,253
null
null
null
null
def mean(num_list): assert type(num_list) == list if len(num_list) == 0: raise Exception("don't pass in empty lists!") else: return sum(num_list)/len(num_list)
3.625
4
smollm
1e7392a134c5632667b9daa7d85423d231b315b0
aroepe/mean
/mean.py
180
null
null
null
null
import unittest # returns product of all items in the list beginning at 'fromIndex' def get_all_products(L, fromIndex): product = 1 for i in range(fromIndex, len(L)): product = product * L[i] return product def get_product_of_integers_before_index(L): product_of_integers_before_index = [] ...
3.9375
4
smollm
a04f278310a23e5c9cf8147d7fff5bc81cd38ace
c42-arun/coding-challenges-python
/src/product_of_items_except_index/working_solution.py
3,098
null
null
null
null
prices = [15,10, 7, 8, 5, 11, 12, 9, 7] profits = [] # copy of original array so O(2n) space # here we are seeing for each price (buy price) the maximum price # that occurs after (sell price) # Space complexity: O(2n) ~ O(n) - as we make a copy of the list as profits list with n-1 items # Time complexity: O(n) - onl...
4.0625
4
smollm
c9a2496a757cffac4b44fdfde52c9c7c47f863cf
c42-arun/coding-challenges-python
/src/apple-stocks/solution_1.py
1,057
null
null
null
null
def selection_sort(A): ''' Sort the given array using the selection sort strategy. Result of the exercise 2.2-3 CLRS 3ed. ''' for i in range(0, len(A) - 1): min = i for j in range(i + 1, len(A)): # pay attention in this line when counting its running time if...
4.125
4
smollm
f24fa8c36bd30d65617349f0437eebd24336a9d7
rodrigoadfaria/playground
/algorithms/selection_sort.py
585
null
null
null
null
def merge(A, B, m, n): ''' Merge two arrays A and B of size m and n, respectively ''' C = [None] * (m + n) i = 0 j = 0 k = 0 while i < m and j < n: if A[i] <= B[j]: C[k] = A[i] i = i+1 else: C[k] = B[j] ...
4
4
smollm
cada0e2a4f59ae7067be7d95b9aba72ff42f3c07
rodrigoadfaria/playground
/algorithms/kway_merge.py
1,606
null
null
null
null
def order_letters(A, i, j): while i != j: if A[i] == 'B': aux = A[j] A[j] = A[i] A[i] = aux j = j - 1 elif A[j] == 'A': aux = A[i] A[i] = A[j] A[j] = aux i = i + 1 ...
3.875
4
smollm
94ac39a412bf554b61e8f067957abcf3eb05f29f
rodrigoadfaria/playground
/algorithms/order_letters.py
1,347
null
null
null
null
from heapq import heappush, heappop, heapify import itertools class Queue: def __init__(self): self.q = [] def enqueue(self, element): self.q.append(element) def dequeue(self): return self.q.pop(0) def is_empty(self): return len(self.q) == 0 def front(self): return self.q[0] class DisjointSets: d...
3.578125
4
smollm
b62cec14d61539331da1c26caa28a5a480f7e307
rodrigoadfaria/playground
/algorithms/graph/datastructure.py
1,880
null
null
null
null
# list test_list = ['aaa', 'bbb', 'ccc'] print('init', test_list) test_list.append('ddd') print('append', test_list) test_list.insert(2, '222') print('insert', test_list) test_list.pop() print('pop', test_list) print('len', len(test_list)) print('index -1', test_list[-1]) # tuple single_tuple = ('aaa',) print('single ...
3.84375
4
smollm
1fa445b04b6c06c123361e1a1d9e824f6e29a0ae
leopen-hu/python-web-demo
/base-demo/python-base/list-and-tuple.py
720
null
null
null
null
import functools print('to 16', int('A2', base=16)) def int16(x, base=16): return int(x, base) int16_2 = functools.partial(int, base=16) print('to 16', int('A2', base=16)) print('to 16 int16', int16('A2')) print('to 16 int16_2', int16_2('A2'))
3.625
4
smollm
d8df5903dbffcab0766474581e5817305163494e
leopen-hu/python-web-demo
/base-demo/functional-programming/partical-function.py
255
null
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # encode and decode str1 = '中文-English' print(str1) b = str1.encode('utf-8') print(b) print(b.decode('utf-8')) # string print with variable print('%d + %d = %d' % (1, 2, 3)) print('{0} + {1} = {2}'.format(1, 2, 3))
4.125
4
smollm
a43794b1bc551b868547fe29d035bff458fc3dd8
leopen-hu/python-web-demo
/base-demo/python-base/str-and-coding.py
268
null
null
null
null
# error and exceptions # syntax error: # a=2 print(a) # type error: # b= 2+'4' # module not found error: # import hhh # name error: # b=3 # c=d # file not found error: # f=open('2.docx') # value error: # a= [1,2,3] # a.remove(5) # index error: # a[6] # key error: # my={'name':'Andrew'} # my['age'] # exception ...
3.671875
4
smollm
682e338a54927404762b0f61da9c989f189440f8
Andrew7891-kip/python_for_intermediates
/exceptions.py
719
null
null
null
null
# Importa a biblioteca para socket import socket # Defini o ip do host ip = raw_input('digite o ip de conexao: ') # Porta que o Servidor fica escutando port = 7000 # Armazena o ip e a porta para a conexao addr = ((ip,port)) # Armazena na variavel tcp. AF.NET defini a conexao IPV4 e SOCK_STREAM defini a conexao TCP clie...
3.578125
4
smollm
01f80eabf74b65317e48163dc3f3feecce3a33a9
txsilva/labRedes
/IRCPython/servidorresponde/clientSiteAlisson.py
855
null
null
null
null
def sum_digits(num): num = str(num) digitSum = 0 for i in num: digitSum += int(i) return digitSum n = int(input()) while 1: if n%sum_digits(n)==0: print(n) break else: n+=1
3.765625
4
smollm
3d05e21243e3b32293774e85e3503c35a32f4a2e
nigelandrewquinn/Kattis
/harshadnumbers.py
217
null
null
null
null
hs = set() max = 0 for i in range(int(input())): n = int(input()) if max < n: max = n hs.add(n) if len(hs) == max: print('good job') else: for i in range(1,max): if i not in hs: print(i)
3.609375
4
smollm
186c17e2e1491ade8afa1c55eab27fa239fc8053
nigelandrewquinn/Kattis
/missingnumbers.py
246
null
null
null
null
max = 0 count = 1 for i in range(int(input())): x = int(input()) if x < max: count+=1 max = x print(count)
3.578125
4
smollm
81b03687563627b927f3561445698b05288d48ad
nigelandrewquinn/Kattis
/kafkaesque.py
142
null
null
null
null
#!/usr/bin/python3 """Number of lines """ def number_of_lines(filename=""): """Returns the number of lines of a text file""" line_count = 0 with open(filename) as a_file: for line in a_file: line_count += 1 return line_count
4
4
smollm
43448a37df7c5fed5d1153f6e89e23bb022b7ce2
johnconnor77/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
263
null
null
null
null
# -*- coding: utf-8 -*- """ Archivo para la conexion con BD SQLITE """ import sys try: import sqlite3 except: print("No existe SQLITE3") sys.exit(1) class Conector: #constructor def __init__(self,nombre): print("Clase conector creada") self.cursor = sqlite3.connect(nombr...
3.9375
4
smollm
cc4b81c2a049124b68f57b0a8a6ad5062b486913
rubdev/viajes-python
/GestionViajes/src/BBDD.py
2,168
null
null
null
null
classmates = {'Tony': ' cool but smells', 'Emma': ' sits behind me', 'Lucy': ' asks too many questions'} #print(classmates) #print(classmates['Emma']) for k,v in classmates.items(): print("Key = "+ k + ": Value: " +v)
3.953125
4
smollm
a874c42cb5d0818a1e5bbe1d1a86d8a46d2227d2
burnettk/origin
/Python/BuckysCodeExamples/Dictionary.py
224
null
null
null
null
import pandas as pd import numpy as np from matplotlib import pyplot as plt from sklearn.model_selection import train_test_split #initialize the weights and bias def initializeWeightsAndBias(m): w = np.zeros((m,1)) b = 0 return w , b def sigmoid(X): return 1/(1 + np.exp(- X)) def propo...
3.53125
4
smollm
3eb454bcea360e79d291e37097e51f5f8c2b2cd4
deBilla/elite
/pattern_recognition/logistic_regression_bank_data.py
2,977
null
null
null
null
n=input("Enter input:") if(n=='lol'): print("laughing out loud") if(n=='rofl'): print("rolling on the floor laughing") if(n=='lmk'): print("let me know") if(n=='smh'):m print("shaking my head")
3.609375
4
smollm
4ac9df66ab87a7d66c7e6399b9b2717f26613812
292023-lts/292023-lts-292023-daily-practice
/second_day/if_sol1.py
209
null
null
null
null
# 곱셈 계층의 구현 class MulLayer: def __init__(self): self.x = None self.y = None def forward(self, x, y): self.x = x self.y = y return x * y def backward(self, dout): dx = dout * self.y dy = dout * self.x return dx, dy # 덧셈 계층...
4.15625
4
smollm
42cdbb92e50eaf50511a6f3114e825256f5bf4fd
jamesDLCV/deepLearningNotes
/88_backward.py
1,515
null
null
null
null
def recursivefactorial(x): if x == 1 or x == 0: return 1 else : a = recursivefactorial(x-1) * x return a while True: n = int(input("수를 입력하세요: ")) if n <= -1: break answer = recursivefactorial(n) print(n,"! = ",answer)
4.0625
4
smollm
421a303a74adb4b3060b750f7fe16fbadce3356f
sw2-team/sw2-team
/third_homework/assignment4.py
252
null
null
null
null
''' The views are the handlers that respond to requests from web browsers or other clients. In Flask handlers are written as Python functions. Each view function is mapped to one or more request URLs. ''' from flask import render_template, flash, redirect from app import app from .forms import LoginForm @app.route('/'...
3.53125
4
smollm
fcf3993f5fefd760679b44650aa88395caeab2d4
luigimascolo/microblog
/app/views.py
1,369
null
null
null
null
#1부터 100까지 출력 result=[i for i in range(1,101)] print(result) #학급의 평균 점수 a = [70, 60, 55, 75, 95, 90, 80, 80, 85, 100] result=0 for i in a: result=result+i print(result) print(result/len(a)) ################################ numbers = [1, 2, 3, 4, 5] result = [] for n in numbers: if n % 2 == 1: resu...
3.6875
4
smollm
5b3ad0edc081604debb24f78a74dcd194390203a
parkseohui/git
/ex08.py
490
null
null
null
null
#0~9까지의 문자로 된 숫자를 입력 받았을 때, 이 입력 값이 0~9까지의 숫자가 #각각 한 번 씩만 사용된 것인지 확인하는 함수를 구하시오. #입력: 103192319 같은 숫자여러개 #출력: true or false/"중복있음","중복없음" #고려할거: 1.숫자를 입력받기 2.같은숫자가 두개이상 있는가? num=input("숫자를입력하세요") num1=list(num) num2=set(num) if len(num1)!=len(num2): print("중복이있습니당.") else: print("중복없음")
3.90625
4
smollm
24f3def69a43842857238de4914032e3ee9157db
parkseohui/git
/istheretwice.py
527
null
null
null
null
list1=[3,1,2,4,5] def mergesort(li): # 재귀함수 n=len(li) if n==1: #리스트의 크기가 1이되면 리스트를 반환하고 끝냄 return li mid=n//2 #중간값, 그룹을 나눔 sg=mergesort(li[:mid]) #중간값을 기준으로 작은그룹 lg=mergesort(li[mid:]) #큰그룹 result=[] #최종반환할 리스트임 while sg and lg: #두개의 리스트에 원소가 존재할때만 돌아감 if sg[0]<lg[0]: #sg...
3.890625
4
smollm
112d19dc903c59b20c3a8ca14d1ce0ac977c8fe0
parkseohui/git
/merge_sort.py
967
null
null
null
null
#statements starting with # are comments and will not be executed, included by programmer to convey how code works to the reader #defining a function that takes total text and pattern to be searched as inputs and returns the number of occurences of pattern in text #len function gives the length of a string #text[i:i...
4.40625
4
smollm
245ed0d046b0df150cf5467ca089de87bb2fb5a8
SREEHARI1994/Bioinformatics_specialization
/pattern_count.py
1,027
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Sat Sep 3 15:03:12 2016 @author: chi-chu tschang """ for variable in range(20): if variable % 4 == 0: print(variable) if variable % 16 == 0: print('Foo!')
3.875
4
smollm
f2ff97b13abc0a323792391079bc0e7bc63fb683
chichutschang/6.00.1x-2T2016
/Week 1/Exercise 5.3.py
220
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Sat Sep 3 14:53:57 2016 @author: chi-chu tschang """ end = 6 num = 0 total = 0 for num in range(0, end): num += 1 total += num print (total)
3.8125
4
smollm
9099cf8c892c97facc5b0b20d3dc5dd3dd508d50
chichutschang/6.00.1x-2T2016
/Week 1/Exercise for exercise 3.py
194
null
null
null
null
balance = 3329 annualInterestRate = 0.02 month = 0 lowestPayment = 0 unpaidBalance = balance interest = 0 while balance >= 0: lowestPayment += 10 for month in range(12): balance -= (lowestPayment) interest = ((annualInterestRate / 12) * balance) balance += interest if...
3.921875
4
smollm
327d23e9355317fe76fb16aa1486c3d5467b6991
chichutschang/6.00.1x-2T2016
/Week 2/Problem 2.py
424
null
null
null
null
low = 0 high = 100 mid = int((low + high) /2) print ("Please think of a number between " + str(low) + " and " + str(high)+ "!") print ("Is your secret number " + str(mid) + " ?") var = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed ...
4.09375
4
smollm
1d61fdf0891c3b18e5b82c796198761c65cfcf1d
chichutschang/6.00.1x-2T2016
/Week 2/Exercise guess my number.py
1,471
null
null
null
null
#balance = 4213 #annualInterestRate = 0.2 #monthlyPaymentRate = 0.04 monthlyUnpaidBalance = balance totalPayment = 0 month = 0 for month in range(12): month += 1 minimumMonthlyPayment = balance * monthlyPaymentRate totalPayment += minimumMonthlyPayment monthlyUnpaidBalanc...
3.8125
4
smollm
de7775da3c1a9b6f5a7f1add6d717892167a0cd9
chichutschang/6.00.1x-2T2016
/Week 2/Problem 1.py
567
null
null
null
null
s = 'azcbobobegghakl' needle = "bob" count = 0 #you're ignoring the variable that's there. enumerate() allows you to iterate over the positions and characters of the string but we're not using the characters. Hence, we're only iterating over each of the positions in the string. You can also write for i, c in enume...
4.15625
4
smollm
64245736c447bd04a434c769f4c16422b12da74c
chichutschang/6.00.1x-2T2016
/Week 1/Problem Set 2.py
570
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Sun Oct 30 14:16:16 2016 @author: chi-chu tschang """ def general_poly (L): """ L, a list of numbers (n0, n1, n2, ... nk) Returns a function, which when applied to a value x, returns the value n0 * x^k + n1 * x^(k-1) + ... nk * x^0 """ #YOUR CODE HERE...
3.578125
4
smollm
b2b3988ff45c994d8aa7e2a83d4122b243390064
chichutschang/6.00.1x-2T2016
/Final Exam/Final Exam Problem 7.py
494
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Tue Sep 6 22:13:06 2016 @author: chi-chu tschang """ num = 3 if num < 0: isNeg = True num = abs(num) else: isNeg = False result = '' if num == 0: result = '0' while num > 0: result = str(num%2) + result num = num // 2 if isNeg: ...
3.828125
4
smollm
34a9f618688c8441163013a98ed9d2ba665f03d3
chichutschang/6.00.1x-2T2016
/Week 5/Floats and Fractions.py
358
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Sat Sep 3 15:01:03 2016 @author: chi-chu tschang """ num = 10 for num in range(5): print(num) print(num)
3.6875
4
smollm
5f48c0197bfbef19b655d4c3b4e63dd8ceb8f7ae
chichutschang/6.00.1x-2T2016
/Week 1/Exercise 5.1.py
149
null
null
null
null
import tkinter as tk # 使用Tkinter前需要先导入 import time def sd(): #实例化窗口 windowsd = tk.Tk() # 给窗口的可视化起名字 windowsd.title('开始运动') # 设定窗口的大小(长 * 宽) windowsd.geometry('1280x720') #定义函数 ##时间 def gettime(): # 获取当前时间并转为字符串 timestr = time.strftime("%H:%M:%S") # 重新设置标签文本 lb.configure...
3.5
4
smollm
427fc42ba6cd8de1dda410099a55f6e3ca5d7b29
saturn-lab/IHIP-2020S
/IHIP-1/深蹲.py
1,342
null
null
null
null
#coding: utf-8 ''' Atividade 2: Elaborar um programa que lê 3 valores a,b,c e verifica se eles formam ou não um triângulo. Supor que os valores lidos são inteiros e positivos. Caso os valores formem um triângulo, calcular e escrever a área deste triângulo. Se não formam triângulo escrever os valores lidos. (Se a &gt; ...
4.15625
4
smollm
bb1d8dc36939a0e81dad3b96b84c4bf10655d96e
LucasGuimar/Atividade---Linguagem-de-Programa-o-Python
/02.py
687
null
null
null
null
# -*- coding: utf-8 -*- import math def sockerkaka(antal): egg = str(int(math.ceil((antal*3.0/4))))+" ägg\n" sugar = str(antal*3.0/4)+" dl sugar\n" vanilla = str(antal*2.0/4)+" tbs vanilla\n" bakingsoda = str(antal*2.0/4)+" tbs bakingsoda\n" flour = str(antal*3.0/4)+" dl flour\n" butter = str(a...
3.734375
4
smollm
256fb3ebde98c578e73076e6c6f9910ceaa9b53d
97marcar/ltu1
/labb1.py
558
null
null
null
null
# -*- coding: utf-8 -*- def summa(n): if n > 9: rest = n % 10 div = n // 10 return(summa(div)+rest) else: return n print(summa(123456789)) def summa2(n): total = 0 while n > 0: rest = n % 10 div = n // 10 total += rest n = div return...
3.5625
4
smollm
6240591ffc953197efeef720bb83367f2ba166bc
97marcar/ltu1
/labb2-3.py
353
null
null
null
null
import array def leftRotate(arr, d, n): for i in range(d): leftRotatebyOne(arr, n) def leftRotatebyOne(arr, n): temp = arr[0] for i in range(n-1): arr[i] = arr[i+1] arr[n-1] = temp def printArray(arr): for i in arr: print(i) arr = array.array('i',[1,2,3,4,5]) leftRotate(a...
3.96875
4
smollm
232bcde41c808b56a3b1d7328adbbdbdd1f06b08
mr-shubhamsinghal/Data-Structure
/array_rotation_method_1.py
353
null
null
null
null
import os contas = { '0001-02':{ 'senha':'1234', 'nome':'Pedro Souza', 'valor':10, 'admin':False }, '0002-03' :{ 'senha':'5678', 'nome':'Souza Pedro', 'valor':20, 'admin':False }, '1111-11' :{ 'senha':'123456', 'nome':'...
3.53125
4
smollm
ee241ea81f0906530008cc303f54fe16b1e431be
pedroSouzaJunior/iniciando-com-python
/pratica/main_old.py
2,582
null
null
null
null
import random def burbuja(lista): n = len(lista) for i in range(n): for j in range(n-i-1): # 0(n) * 0(n) = o(n**2) if lista[j] > lista[j+1]: lista[j], lista[j+1] = lista[j+1], lista[j] return lista if __name__ == "__main__": n = int(input('Cuantos ...
3.8125
4
smollm
abbf3496bc5326ade640145de6e1d76cf2422b4d
Byhako/python
/poo/ordenamiento_burbuja.py
458
null
null
null
null
import numpy as np def f(x): return -3*x*x+5 def df (x,h): return (1/(2*h))*(f(x+h) - f(x-h)) x = 2 h = 0.01 print(f(x+h)) print(f(x-h)) print(df(x,h))
3.921875
4
smollm
9f099fc4822e99520363baaf7af66a9e1d1ff52b
Byhako/python
/scripts/metodos/dif_num.py
160
null
null
null
null
import math from time import time inicio=time() print('%1s\n' %('NUMEROS PRIMOS')) """ Teorema de wilson: si p es primo cumple: (p-1)!=-1(mod(p)) podemos escribir esto como: (p-1)! % p=p-1 """ #generamos los Z primeros primos Z=10 primos=[] a=1 p=1 while a<Z+1: <<<<<<< HEAD p=p+1 s=0 for...
3.546875
4
smollm
04d194247f515993b3203dd81a42bf6f880034f4
Byhako/python
/scripts/numeros_primos.py
2,074
null
null
null
null
from math import pi #========================================================== # BASICO class Moto: nRuedas = '2' # variable de clase def __init__(self, marca, modelo, color): self.marca = marca # variable de instancia self.modelo = modelo self.color = color print('Constructor ejecutado') ...
3.890625
4
smollm
c2f65f6ebbac4505925cf2c724c187c0daec3cdd
Byhako/python
/clases/clase1.py
4,237
null
null
null
null
""" Batalla naval. Ruben E Acosta 2016-02-27 """ import random tablero = [] T=8 for x in range(0,T): tablero.append(["O"] * T) def print_tablero(tablero): for fila in tablero: print (" ".join(fila)) print ("Juguemos as la batalla naval!\n") print_tablero(tablero) #******************...
3.890625
4
smollm
e3971f1725079ebb004919ef06f2475277e81342
Byhako/python
/scripts/batalla_naval.py
2,404
null
null
null
null
import unittest def suma(a, b): return a + b class CajaNegra(unittest.TestCase): def test_suma_dos_positivos(self): num_1 = 10 num_2 = 5 resultado = suma(num_1, num_2) self.assertEqual(resultado, 15) def test_suma_dos_negativos(self): num_1 = -2 num_2 = -...
3.6875
4
smollm
1704601f22c2ae00d38c3e705923fb00b150dfd0
Byhako/python
/scripts/cajaNegra.py
451
null
null
null
null
import math def get_prime_factors(number): prime_factors = [] while number % 2 == 0: prime_factors.append(2) number = number / 2 for i in range(3, int(math.sqrt(number)) + 1, 2): while number % i == 0: prime_factors.append(int(i)) number = number / i ...
3.75
4
smollm
185a01ecf150feb5b54e7c2dca2bc4a35fd1c8d7
namedai01/CodeATTT
/Prime.py
623
null
null
null
null
def build_index_grid(rows, columns): s='' r=[] for i in range(0,rows): for j in range(0,columns): if i==0 and j==0: s+="[" if j==0: s+="[" s+="'"+str(i)+","+str(j)+"'" if (j!=(columns-1)): s+="," if j==(columns-1) and i!=(rows-1): s+="]" if j==(columns-...
3.828125
4
smollm
52446343854f39597a17dd1f6638d51b3017d7d8
vamshi99k/python-programs
/buildindexrows - Copy.py
546
null
null
null
null
def is_leapyear(year): if ((year%400==0 or year%4==0) and (year%100!=0)): return True else: return False year=int(input()) l=[] while len(l)<15: if is_leapyear(year): l.append(year) year=year+1 print(l)
3.828125
4
smollm
233e60e6dd07bc871fe666c7a95bbf61ceb1f566
vamshi99k/python-programs
/next15leapyears - Copy.py
229
null
null
null
null
people = 3 apple = 20 if people < apple/5: print('신나는 사과 파티! 배 터지게 먹자') if apple % people > 0 : print('사과 수가 맞지 않아') if people > apple: print('사람이 너무 많다') if True: print("조건식이 True이면 실행됩니다.") if False: print("조건식이 False이면 실행되지 않습니다.")
3.96875
4
smollm
f514dcfc21e6efc603d9f1efc7787435d24a0b85
SeonMoon-Lee/pythonStudy
/if.py
369
null
null
null
null
list1 = ["가위","바위","보"] list2 = [2,3,5,61,3,5,7] print(list1) print(list2) print(list1[0]) print(list1[1]) print(list1[2]) list1[0] = "꽝" print(list1[0]) print(list1[-1]) print(list1[-3]) list2.append(16) #값 추가 print(list2) list3 = list2+[16] # 리스트 + 리스트 print(list3) n = 12 ownership = n in list3 #값 존재 유...
3.6875
4
smollm
eb4e5889b3ce3be3c2f87b2bf79e5f51b41db6e1
SeonMoon-Lee/pythonStudy
/list.py
545
null
null
null
null
import math ca=float(input("Cateto adyacente: ")) co=float(input("Cateto opuesto: ")) h=math.sqrt((ca**2)+(co**2)) sen=co/h cos=ca/h tan=co/ca print("Seno", sen) print("Coseno", cos) print("tangente", tan) print("Fin")
3.890625
4
smollm
3b57fea90cca577c88124b03907acbd47f7e9dd2
systchem/primer-repositorio
/trigonometria.py
218
null
null
null
null
# 切片 [:]开头默认0,结尾默认位置-1 abc ="Python" print (abc[1:2]) print (abc[2:6:2]) # 删除两端空白 love_python =' Hello,Python ' print('删除字符串两端的空白',love_python.strip())
3.8125
4
smollm
51a10eddec38d48978c6bc5ebd2c618f031d15ac
LiuHH2018/pycharm_2019
/python_d_001.py
210
null
null
null
null
# Recibe dos numeros desde la consola # Convierte los números a variables enteras # Realiza la operación a = b+c con las variables enteras # Realiza la misma operación con las variables string # Imprime los resultados para ambas operaciones var_1 = input("Dame un numero: ") var_2 = input("Dame otro numero: ") num_1 =...
3.890625
4
smollm
4e113f23728b87078d7a7868fd890b328fa97609
Gaminhbirol/BEDU_Python
/Reto_01.1.py
459
null
null
null
null
""" This package provides a graph class that implements the Dijkstra algorithm. The Dijkstra code was lifted from code.activestate.com/recipes/119466-dijkstras-algorithm-for-shortest-paths/ posted by David Eppstein (http://www.ics.uci.edu/~eppstein/) """ import heapq class PriorityQueue(object): """ A prio...
3.953125
4
smollm
ba6ebccbd5857628e16e9922522d125f7e3db7ff
parthdoshi/seniordesign
/src/graph.py
7,550
null
null
null
null
from tkinter import * import time # Window Setup root = Tk() # Timer Variables time_sec = StringVar() sec = 0 # Timer Start def start(): while 1: time.sleep(10) sec = sec + 10 time_sec.set(sec) start() # Timer Setup Button(root, fg='blue', text='S...
3.640625
4
smollm
09734eeaa61eecc4ef371bc063d2ca3bb6922e9d
TigraSonya/classExample
/timefunct.py
391
null
null
null
null
cost_espr = [250, 0, 16, 1, -4] cost_latt = [350, 75, 20, 1, -7] cost_capp = [200, 100, 12, 1, -6] materials = ["water", "milk", "coffee beans", "disposable cups", "money"] class CoffeeMachine: def __init__(self, water, milk, beans, cups, money): self.water = water self.milk = milk self.cup...
3.890625
4
smollm
3170bdf375e1be8574c67446da56ea9681dcdc48
UnderKitten/Python-Coffee-Machine
/main.py
2,738
null
null
null
null
import random class Coin: # class definition begining here def __init__(self) : #initializing variables self. sideup = 'Heads ' def toss (self) : if random.randint(0, 1) == 0: self. sideup = ' Heads ' else : self. sideup = 'Tails ' def get...
3.953125
4
smollm
af5bb624a474f313e145d49d4f1a40b5c103cbb6
karuppaiya/Python
/classex.py
591
null
null
null
null
sequence = input() total_seq = [int(sequence[0])] for i in range(1, len(sequence)): total_seq.append(int(total_seq[i - 1]) + int(sequence[i])) print(total_seq)
3.515625
4
smollm
0b5b5f07a88dcb1bd6929108dba36f73d928d63e
Tydroneous/Rock-Paper-Scissors
/Problems/Running total/main.py
165
null
null
null
null
from numbers import * from math import * import numpy as np def as_vector( value ): if isinstance( value, Number ): return np.array( [cos( value ), sin( value )] ) else: norm = np.dot( value, value )**0.5 if norm != 0: return value / norm else: return np.array( [1., 0] ) def as_angle( ...
3.578125
4
smollm
be986286e90429dad041436a2c58a74676ad08c5
srl-freiburg/momo
/python/momo/angle.py
1,136
null
null
null
null
# -*- coding:utf-8 -*- from threading import Condition import threading # 条件变量,用于复杂的线程间的同步 # 通过condition完成读诗 class Xiaoai(threading.Thread): def __init__(self, cond): super(Xiaoai, self).__init__(name="小爱") self.cond = cond def run(self): with self.cond: self.cond.wait() ...
3.703125
4
smollm
362364c426ae47ef0475b31df6777b2ac482d874
1160287301/python_study
/高级编程/多线程/thread_condintion.py
2,313
null
null
null
null
# -*- coding:utf-8 -*- ''' Maps or Dict: 键值对,python内部采用hash实现 ''' class Map: def __init__(self): self._entryList = list() def __len__(self): return len(self._entryList) def __contains__(self, item): ndx = self._findPosition(item) return ndx is not None def add(self, k...
3.578125
4
smollm
200c8f31e2c6e7cd8ee4d64d7750ae82c397f160
1160287301/python_study
/数据结构和算法/数据结构/maps.py
453
null
null
null
null
# -*- coding:utf-8 -*- dict1 = { 'key1': {'1': 1}, 'key2': {'2': 2}, } # clear # print(dict1.clear()) # copy 浅拷贝 嵌套的数据不会拷贝 # # dict2 = dict1.copy() # dict2['key1']['1'] = 11 # print(dict1) # 深拷贝 import copy dict3 = copy.deepcopy(dict1) dict3['key1']['1'] = 11 print(dict1) # formkeys new_dict = dict.fromk...
4.03125
4
smollm
d754bfda61d281d64d6c8182a6c746d80e01ff4b
1160287301/python_study
/高级编程/深入set和dict/dict_method.py
573
null
null
null
null
def get_y_vals(data): """ Takes user input to extract table data in list form. Length of inclusive start and exclusive end MUST be 6 (i.e. start: 6, end: 11, row: 1). :param """ start = int(input("Y value start(inclusive): ")) end = int(input("Y value end(exclusive): ")) row = int...
4
4
smollm
4517e40dfeddebabacda26d371b7389dae834382
ecruzandres/StudentProjectCogs18
/Functions.py
1,398
null
null
null
null
def mean_absolute_difference(user_rating_dict, predict_rating_dict): """ This function helps to calculate the mean absolute difference on the predicted and observed data and prints it """ total_diff = 0.0 count = 0 for user in user_rating_dict.iterkeys(): # iterate through...
3.84375
4
smollm
4403645f18e9e38d26103d06d50bf6047657b947
anirudhkm/data-mining-course
/hw1/5/5_a/data_process.py
2,410
null
null
null
null
def chaine(ch): Majiscule="" for i in range(len(ch)): if (ord(ch[i] )>= 97 and ord(ch[i] )<= 122): k =ord(ch[i]) - 32 Majiscule = Majiscule+chr(k) else: Majiscule=Majiscule+ch[i] return (Majiscule) ch = input() print(chaine(ch))
3.53125
4
smollm
2d44a7945575c2f82bf38a01e1cf14329f1cc376
Abdellatifkraiem/Test-technique
/test_technique/Sujet1.py
305
null
null
null
null
count = 1 def shuffle(x): if x >= n: return "" elif x == n-1: return names[x]+"\n" return names[x]+"\n" + shuffle(x+2) + names[x+1]+"\n" while True: n = int(input()) if n == 0: break names = [] for x in range(n): names.append(input()) print("SET", coun...
3.59375
4
smollm
34f5fe6c2f3f3203b82fa045731f26b8a727430b
Mamithi/open-katis-challenges
/symmetricorder.py
367
null
null
null
null
name = list(input()) new_name = name[0] let = name[0] for i in range(1, len(name)): if name[i] != let: new_name += name[i] let = name[i] print(new_name)
3.515625
4
smollm
8c0bfa7c380ec407c26b52b163452c01739fdf67
Mamithi/open-katis-challenges
/apaxiaaans.py
183
null
null
null
null
moves = input() ball = 1 for move in moves: if move == "A": if ball == 1: ball = 2 elif ball == 2: ball = 1 elif ball == 3: ball = 3 elif move == "B": if ball == 1: ball = 1 elif ball == 2: ball = 3 elif b...
3.671875
4
smollm
cd369a64972550c14d51319a0849da78ee3c6c13
Mamithi/open-katis-challenges
/trik.py
513
null
null
null
null
msg = input() lower_count = 0 upper_count = 0 whitespace = 0 symbols = 0 for i in msg: if i.isalpha() and i.islower(): lower_count += 1 elif i.isalpha() and i.isupper(): upper_count += 1 elif i == '_': whitespace += 1 else: symbols += 1 print("{:.16f}".format(whitespac...
3.84375
4
smollm
8756e4da7ee1de8d9d4339d5e2a684f511235e73
Mamithi/open-katis-challenges
/alphabetspam.py
476
null
null
null
null
''' Created on May 12, 2020 @author: basudeb ''' import Graph as G def main(): n = int(input("Enter the no. of vertices: ")) g = G.Graph(n) g.Create_graph() u, v = input("Enter the end vertices").split(" ") g.Add_edges(u, v) if __name__ == "__main__": main()
4
4
smollm
fb588f15f56a2fbf561350d00b57b5c786d57c0e
Basudeb96/Python
/Graph/driver.py
289
null
null
null
null
import DocNode # docList is a linked list that represents a term # frequency list for a term. class docList(object): # Constructor creates a docList whose # head points to a newly-created docNode. # This docNode is created with given docID. def __init__(self, docID): self.head = DocNode.d...
4.1875
4
smollm
22b06971d672e183fad892ddff5c4deafd243ccf
JohnStevensonWSU/Ranking
/DocList.py
2,365
null
null
null
null
# -*- coding: utf-8 -*- from unicorns.Location import Location import json class Unicorn: ''' A simple class representing a unicorn. ''' id = 0 name = "" description = "" reportedBy = "" spottedWhere = Location() spottedWhen = 0 image = "" def __init__(self): ...
3.5
4
smollm
67d8d807c774f8c39010382de794ab3a3698d238
koddas/unicorns2
/server-python/src/unicorns/Unicorn.py
1,960
null
null
null
null
from FileIOClass import FileIO name = input('What file do you want to open? ') openmode = input('How do you want to open the file? (Read/Write/Append etc.) ') my_file = FileIO(name, openmode) print(my_file.perform_operation())
3.6875
4
smollm
e362edabd7c1f239fb75a07bb80a66af653deb84
MattMackreth/NorthwindDatabasePythonWithHomework
/UsingFileIO.py
228
null
null
null
null
# 递归案例:树形结构的遍历 # 模拟文件搜索:对C盘ATTO文件夹下的所有文件进行检索 import os def findFile(file_Path): listRs = os.listdir(file_Path) #得到该路径下的文件夹 for fileItem in listRs: full_Path = os.path.join(file_Path,fileItem) #获取完整的文件路径 if os.path.isdir(full_Path): #判断是否是文件夹 findFile(full_Path) #如果是一个文件夹再次去递归搜索 ...
3.921875
4
smollm
d02ea55991046b9a2917f1e8305ada5832ebba38
yy02/test
/Python/Python学习笔记/文件检索.py
555
null
null
null
null
hrs = input("Enter Hours:") rate = input("Enter Rate:") try: h = float(hrs) r = float(rate) except: print("please,enter valid number") quit() if ( h <= 40 ): print( h * r) else: print(r * 40 + (r * 1.5) * (h - 40))
3.953125
4
smollm
0b64d3a7ccdcdc2b81513bed01d7c60120dfc8ad
Tharunsai-0512/Coursera
/Assignments/Programming for Everybody (Getting Started with Python)/assignment3_1.py
233
null
null
null
null
for x in range(0, 3): for y in range(3): print('#', end='') print() for x in range(1, 10, 2): for y in range(1, 10, 2): print(x * y, '\t', end='') print() word_array = ['A', 'BB', 'CCC'] for w in word_array: print(w, len(w)) # While loop with else condition w = 0 while w < 2 **...
4.03125
4
smollm
95a90a4c3cc568294f5ca7d47a12ea3f665b945f
FlorianDe/python-playground
/basics/loopy.py
406
null
null
null
null
def alpha_beta_search(gameState, player_id, depth): """ Return the move along a branch of the game tree that has the best possible value. A move is a pair of coordinates in (column, row) order corresponding to a legal move for the searching player. You can ignore the special case of calling th...
3.625
4
smollm
814de2819449ba416f29a11b4eb45cbac08e18f6
shubhoghosal/Udacity-Adversarial-Search-Project
/alpha_beta_search.py
2,475
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Wed Oct 9 14:11:36 2019 @author: XieJie """ from texttable import Texttable def print_table(df): #data=[{"name":"Amay","age":20,"result":80}, # {"name":"Tom","age":32,"result":90}] #df=pd.DataFrame(data,columns=['name','age','result']) tb=Texttable(...
3.671875
4
smollm
a65c4347e93a5893a7362566db11a9dadbcd9686
jayaston/mypyworks
/StatLedger/module/printtable.py
732
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Thu Sep 13 22:11:39 2018 @author: Coal1 """ def Nim(matchsticks,move_limit,k): # It is important to understand HOW we reach our conclusions and what our return values mean. # Nim() searches the state of the NEXT move # Ergo, if we make the next move impossible to win...
3.625
4
smollm
41436bd0d00b637f48070d50347abb91ad6c16cf
DrFaustie/Misc
/Nim.py
2,325
null
null
null
null
Intro Final Project completed # Use this to try out anything you like. Use print to display your answer # when you press the "Test Run" button. # Use the "Reset" button to reset the screen example_input="John is connected to Bryant, Debra, Walter.\ John likes to play The Movie: The Game, The Legend of Corgi, Dinosau...
4.125
4
smollm
07e730979a42c41ee34649a258ed1c27912eebc0
stefankaehler/Udacity_Intro
/Intro Final Project completed.py
7,232
null
null
null
null
No1 = input("(1/10) Noun=") No2 = input("(2/10) Adjective=") No3 = input("(3/10) Verb ending in s=") No4 = input("(4/10) PluNoun=") No5 = input("(5/10) Action ending in s=") No6 = input("(6/10) Verb ending in ing=") No7 = input("(7/10) Verb=") No8 = input("(8/10) Place=") No9 = input("(9/10) Action ending in ing=") No1...
3.640625
4
smollm
93ce8e9903b278f7a52228db1b5326e9f7706808
EddyCSE/CSE
/notes/Eduardo Sanchez - Mad Lib.py
567
null
null
null
null
import random r = (random.randint(0, 10)) guesses_left = 5 playing = True print("Guess a number from 1 to 10") while guesses_left > 0 and playing: guess = int(input("Guess=")) if guess > r: print("Lower") guesses_left -= 1 elif guess < r: print("Greater") guesses_left -= 1 ...
4.03125
4
smollm
67beecbbbd02f2a9dc2857f551063d90e9c4cbca
EddyCSE/CSE
/notes/Eduardo Sanchez - Guess Game.py
382
null
null
null
null
#正規表現で電話番号を探す import re #正規表現を設定する phone_num_regex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') #設定した正規表現を使って電話番号だけを抽出する mo = phone_num_regex.search('私の電話番号は415-555-4242ですわよ.Cell 421-223-1234') print('search') print(mo.group()) #検索し,パターンマッチした奴を全部抽出する mo1 = phone_num_regex.findall('私の電話番号は415-555-4242ですわよ.Cell 421-223-12...
3.5625
4
smollm
49bc36736a757a0b17aef1f5bce450fc13f1313c
kenpos/LearnPython
/正規表現とか色々/findallMethod.py
555
null
null
null
null
''' Input: a List of integers as well as an integer `k` representing the size of the sliding window Returns: a List of integers ''' def sliding_window_max(nums, k): # Your code here slide = [] numbers = [] current_max = 0 check_num = 0 for i in range(len(nums)): if nums[i] > current_max...
4.15625
4
smollm
9bb77ad6049526db10eebd6243735389cf888d8c
ashwin-swamy/cs-module-project-algorithms
/sliding_window_max/sliding_window_max.py
886
null
null
null
null
import copy class Literal: """An literal consists of - its symbol - whether it is a positive literal "True" and "False" are positive literals """ def __init__(self, positive = None, symbol = None): try: assert(isinstance(positive, bool)) self.p = positive except: print("'positive' is not a b...
3.875
4
smollm
da17b176e60119fde7840ef641e19268e93cd56b
thyton/pyPL
/literal.py
1,622
null
null
null
null
# use + to concatenate strings together import threading import time def task(): print("This is the task!") threads = [] for i in range(10): t = threading.Thread(target=task) threads.append(t) t.start() def worker(): print(threading.current_thread().getName(), 'Starting') ...
3.53125
4
smollm
4e6a62d714e127d15d5573095b3d18904fa29ec6
yooshxyz/ITP
/feb3.py
773
null
null
null
null
# we learned variables first # then conditionals and iterations. # class.function(parameters) def main(): numtimes = int(input("How many times do you want to be repeated?")) simpleOperators.sayHello(numtimes) # go to corresponding function and these values equal those variables. IF NAME IS MENTION...
4.0625
4
smollm
93eda10ab4185ff74906289e185500b5a07877ec
yooshxyz/ITP
/Feb20_PartOne.py
1,316
null
null
null
null
import math import numpy as np from sklearn.datasets import make_classification from sklearn.linear_model import LogisticRegression import matplotlib.pyplot as plt LEARNING_RATE = 0.2 def logistic(theta, x): # log logistic theta = theta.reshape(len(theta), 1) x = x.reshape(len(x), 1) z = theta.T.dot(x...
3.53125
4
smollm
fe8e85e1a8fdadc5609fa50b6b8f3acec56880db
nicovaras/ml-python-scripts
/multi_logistic_regression.py
2,336
null
null
null
null
field = [[" "] * 3 for i in range(3)] def show(): print() print(f" | 0 | 1 | 2 |") print("----------------") for i, row in enumerate(field): row_str = f" {i} | {' | '.join(row)} | " print(row_str) print("----------------") def ask(): while True: cords = input(" ...
3.734375
4
smollm
6406759202bd18552793f84f6b75ba8427e4ff51
OlgaTaykova/SF-B5-Taykova
/TaykovaB5.py
2,096
null
null
null
null
# import libraries import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats # number of data points n = 1000 # number of histogram bins k = 40 # generate log-normal distribution data = np.exp(np.random.randn(n)/2) # one way to show a histogram plt.hist(data, k) plt.xlabel('Value') plt.ylabel(...
3.578125
4
smollm
2ca1df06688613d175a514a2bdf3aa17cce53831
AlexNedyalkov/StatisticsPython
/Descriptive_statistics/histograms.py
596
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Sat Sep 12 13:19:41 2020 @author: 91842 """ n = int(input()) if n>1: print(0.5) else: print(1.0)
3.59375
4
smollm
f7fe44ae72d230217bf5e4ac5244121f36e140c4
Saptarshi-prog/LeetCode-problems-code
/1227. Airplane Seat Assignment Probability.py
156
null
null
null
null
# Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. # Example 1: # Input: [0,1] # Output: 2 # Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1. # Example 2: # Input: [0,1,0] # Output: 2 # Explanation: [0, 1] (or [1, 0]) is a longest ...
3.90625
4
smollm
4d09cb90d586f346f7716fc11e1ad0b4812a9fb3
NishadKumar/leetcode-30-day-challenge
/contiguous-subarray.py
985
null
null
null
null
# You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: # direction can be 0 (for left shift) or 1 (for right shift). # amount is the amount by which string s is to be shifted. # A left shift by 1 means remove the first character of s and append it to...
3.984375
4
smollm
85c5aabdcd69e72e9ab5e7f8ac3f08c05620018e
NishadKumar/leetcode-30-day-challenge
/perform-string-shifts.py
1,809
null
null
null
null
import datetime def printTimeStamp(name): print('Автор програми: ' + name) print('Час компіляції: ' + str(datetime.datetime.now())) a = int(input("Введіть вартість замовлення: ")) b = a / 100 * 14 c = a / 100 * 18 f = a + b + c template = '{:.' + str(2) + 'f}' print(template.format(f)) printTimeStamp(...
3.8125
4
smollm
65cd6b22c8d229fbb7a68a8a106129daab21623a
DarynaZlochevska/Practic
/1 день/6.py
404
null
null
null
null
# new_file=open('linebyline_read.txt','x') def file_read(fname): content_array = [] with open(fname) as f: #Content_list is the list that contains the read lines. for line in f: content_array.append(line) print(content_array) f...
3.671875
4
smollm
b30a950efff042fd174f4982f7cc2d540248efc5
preeti28dec/File-in-python
/file_read line by line.py
352
null
null
null
null
print("ATIF MOIN") print("1900300100051") print("Enter the number .....") x=int(input('number=')) s=0 while (x!=0): n = x%10 s=s+n x=int(x/10) print(int(s))
3.609375
4
smollm
c2ce51fc9cd404ef7634f5a03bd13267fecdf18b
Atifmoin19/Sig-Python
/Module 4/q2.py
168