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 |
|---|---|---|---|---|---|---|
6aa0e3b5d6b3058779cf5b4a6ddff15eb6a5d2b1 | MaNull94/codewars | /6 kyu/kebabize.py | 780 | 3.609375 | 4 | # https://www.codewars.com/kata/57f8ff867a28db569e000c4a/train/python
# my solution
def kebabize(string):
#remove digits from string
tmp = ''.join([char for char in string if not char.isdigit()])
result = []
word_start_index = 0
word_end_index = 0
for i in range(1, len(tmp)):
if tmp[i]... |
4bce5f49c82972c9e7dadd48794bcc545e25095b | miketwo/euler | /p7.py | 704 | 4.1875 | 4 | #!/usr/bin/env python
'''
By listing the first six prime numbers:
2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?
'''
from math import sqrt, ceil
def prime_generator():
yield 2
yield 3
num = 3
while True:
num += 2
if is_prime(num):
... |
66e0d3fc8776b9008e5179021acef9e63ca7592e | g-quest/rap_lib | /mad_lib.py | 4,956 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Mad Lib for 'Big Poppa' by The Notorious B.I.G. (1994)
G-Rated version
"""
def main():
print('\nWelcome to the Notorious B.I.G. Rap Lib!\n\n'
'You will be prompted to enter various names and words to produce your very own version of his hit song, "Juicy".')
play = input('Ar... |
3c4b2186823c0195814afa59010dfa68753674c7 | sooriyan1994/Python-codes | /map_feature.py | 338 | 3.875 | 4 | def mapFeature(X1, X2):
import numpy as np
degree = int(raw_input('Enter the polynomial degree : '))
n = np.ones([len(X1),1])
for i in range(1, degree+1) :
for j in range(i+1):
n = np.hstack((n,(X1**(i-j)*X2**j).reshape([len(X1),1])))
return n
... |
a093a5681ae110b044fcbf786bb134e3a81ee83d | sooriyan1994/Python-codes | /ex1_test.py | 2,733 | 3.890625 | 4 | #importing libraries for plotting and matrix operations
#import matplotlib.pyplot as plt
import numpy as np
from linear_reg_cost_fn import cost_fn
from gradient_descent import gradient_descent
from feature_normalize import feature
#Opening the data file and reading data
with open('ex1data1.txt') as fl:
V ... |
c8111b281867e5cdb7a3a20e6d8069231129d308 | sercandenoglu/ExerciseWithPython | /Determinat_Calculate.py | 2,981 | 3.875 | 4 | import copy
def GetMatrix():
#get matrix from user
print("If you want to exit, please write \"exit\"")
print("You can split with ',' each value")
print("Please enter each row")
matrix = []
counter = 1
while True:
row = input(f"Enter {counter}. row: ")
if row == ... |
3863128dde977726ef1d864a44fdfa7f393583a0 | Pilasande/template_unsu | /recommenders/collaborative_based.py | 9,002 | 3.515625 | 4 | """
Collaborative-based filtering for item recommendation.
Author: Explore Data Science Academy.
Note:
---------------------------------------------------------------------
Please follow the instructions provided within the README.md file
located within the root of this repository fo... |
d1f103ccd9fe53fb75c9b40bdc6cfb69228b752e | karan18205/PythonProblems | /Day1.py | 8,767 | 4.375 | 4 | print('Starting Here')
## Program 1
# Write a function that stutters a word as if someone is struggling to read it. The first two letters are repeated twice
# with an ellipsis ... and space after each, and then the word is pronounced with a question mark ?.
#
# Examples
# stutter("incredible") ➞ "in... in... incredib... |
eb3cdb50dabbdd3c2493a8dc06ddb9e75f4a195e | zhouyou123/-algorithm015 | /Week_01/week_01.py | 3,134 | 3.640625 | 4 | # day 1 爬楼梯
#本质上就是求斐波拉契数列
def jump_steps(n):
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return b
# 动态规划 (目前还不太能理解,什么是动态规划)
def jump_steps_v1(n):
a, b, c = 0, 1, 0
for i in range(n):
c = a + b
a = b
b = c
return b
# day 2 加一
def plus_one(nums: List[int])... |
d5477412e9b554097a6849c41276c444c1b84580 | cooleo/python_programming | /05_exceptions.py | 1,077 | 3.890625 | 4 | while True:
try:
x = int(input('Please enter a number'))
break
except ValueError:
print('Opps!, That was no valid number. Try again!')
while True:
try:
x = int(input('Please input a number'))
break
except (RunTimeError, TypeError, NameError):
pass
class D(C):
pass
for cls in [A... |
9e84eeb486846d437d69a8d08c717240cbb462a5 | TejaswitaW/Advanced_Python_Concept | /RegEx12.py | 260 | 4.125 | 4 | #use of function fullmatch in regular expression
import re
s=input("Enter string to be matched")
m=re.fullmatch(s,"abc")
if(m!=None):
print("Complete match found for the string:",m.start(),m.end())
else:
print("No complete match found for the string")
|
02ec37d7d9f283a74e0015c2066d496c2952c61f | TejaswitaW/Advanced_Python_Concept | /RegEx11.py | 334 | 4.09375 | 4 | #use of function match in regular expression
import re
s=input("Enter string to be matched")
m=re.match(s,"My name tejaswita wakhure")
if(m!=None):
print("Match is available at the begining of the string")
print("Index is {}and end at {}".format(m.start(),m.end()))
else:
print("Match is not avilable at the ... |
03f914ee534f50bfff73a5212de0c7e569ee8b38 | TejaswitaW/Advanced_Python_Concept | /OOP11.py | 750 | 3.84375 | 4 | #use of has-A relationshhip
class Car:
def __init__(self,model,price,name):
self.model=model
self.price=price
self.name=name
def getinfo(self):
print("Car model is: ",self.model)
print("Car Model name is: ",self.name)
print("Car price is: ",self.price)
class Emp:
... |
cd22536d0a4d701c70c8d19c8217bc2233973c25 | TejaswitaW/Advanced_Python_Concept | /RegEx16.py | 259 | 4.09375 | 4 | #use of function replacement in regular expression
#subn
import re
s=input("Enter string to be replaced")
t=input("Enter target string")
u=re.subn("\d",s,t)
print("The result of the operation is: ",u[0])
print("The number of replacement happened are: ",u[1])
|
443c8253f74cb9660262ef7929f9d8e65a11d4d3 | TejaswitaW/Advanced_Python_Concept | /Generator2.py | 167 | 3.75 | 4 | #use of generator with for loop
def mygen():
yield("A")
yield("B")
yield("C")
yield("D")
yield("E")
yield("F")
for i in mygen():
print(i)
|
aa4804d2a19435b061d58c5855bee819aee31751 | TejaswitaW/Advanced_Python_Concept | /RegEx23.py | 232 | 4.5 | 4 | #Regular expression to find valid mobile number
import re
n=input("Enter mobile number")
v=re.search("^+91",n)
if v!=None:
print("It is a valid mobile number in India")
else:
print("It is not valid mobile number in India")
|
d139c57f5add5f8be6008fad651ea3eca04e4c39 | TejaswitaW/Advanced_Python_Concept | /ExceptionElse.py | 385 | 4.15625 | 4 | #Exception with else block
#else block is executed only when there is no exception in try block
try:
print("I am try block,No exception occured")
except:
print("I am except block executed when there is exception in try block")
else:
print("I am else block,executed when there is no exception in try block")
f... |
2a45eec16b6ee708f60cf27a0977d3fe872cc553 | brainaulia/dumbways | /3.py | 268 | 3.609375 | 4 | # input: ccbabaccffpgkkklll
# output: cbafpgkl
def saring_duplikat(kata):
nodupe=''
for i in kata:
if i not in nodupe:
nodupe+=i
return nodupe
kata='ccbabaccffpgkkklll'
print("input:",kata)
print("output:",saring_duplikat(kata))
|
8f24b45405f70f91fb5622136a1ab5a403ef5035 | 4597veronica/Projectos_python | /Plantillas/Plantilla1.py | 1,768 | 3.734375 | 4 | # coding:utf-8
from random import randint
saldo=100
sortir=False
minima=10
while sortir== False:
print"¿Cuanto quieres apostar?"
print"Apuesta minima 10€"
sortir3=False
while sortir3==False:
apuesta=input("Introduce tu apuesta ")
if apuesta==-1:
sortir3=True
else:
if apuesta>=10 and apuesta<=saldo:
... |
7999b695d7cbb7cc6100a854bbddfc95c163d1ac | 4597veronica/Projectos_python | /Otros/lista.py | 1,899 | 3.84375 | 4 | #coding:utf-8
"""En este codigo haremos que el usuario introduzca los dias de la semana
Además podra consultarlos borarlos y modificarlos. """
######################VARIABLES#####################################
sortir=False
dias_semana = []
######################MENU##############################################
d... |
3e161a18b9a6cfb9fc34432d7d74a108999eaeea | 4597veronica/Projectos_python | /for/3.contar-pares_1.py | 99 | 3.96875 | 4 | #coding: utf8
contar=input("Introduce un numero")
for i in range(contar)
if i%2==0:
print i
|
83e9d04e119457e0baa7c8310ee60c00e11f98ae | lumc-python/introduction-nynkeoosterhof | /Exercise3_monday.py | 328 | 3.921875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 18 15:09:34 2017
@author: nynkeoosterhof
"""
list = range(1,101)
for i in list:
if ((i % 3) == 0) & ((i % 5) == 0):
print 'FizzBuzz'
elif i % 3 == 0:
print 'Fizz'
elif i % 5 == 0:
print 'Buzz'
else:
... |
4fb5cf17c5776b55d1cb765dc7a8f589cb8e8c9b | Vk-Demon/vk-code | /ckstring14.py | 361 | 3.75 | 4 | oddev=input() #swap the even and odd characters
odd,ev="",""
for i in range(0,len(oddev)):
if(i%2==0):
ev=ev+oddev[i]
else:
odd=odd+oddev[i]
if(len(oddev)%2==0):
for i in range(0,int(len(oddev)/2)):
print(odd[i]+ev[i],end="")
else:
for i in range(0,int(len(oddev)/2)):
print(odd[... |
fd7ff90cf3b506ac4b94d9451cb78364e517f8dd | Vk-Demon/vk-code | /ckmatrix8.py | 853 | 4.0625 | 4 | def prime(p): # Mr. Prime is a coder who loves solving problems which involve the mention of the word ‘prime’. He recently came across a puzzle in which he had to find sum of elements which are located at positions whose row+column index value is a prime number. After finding the sum, he had to check whether the sum o... |
a3d8614bf1a0174f638b61dfa60a36637bd8a5d4 | Vk-Demon/vk-code | /ckarray23.py | 342 | 3.609375 | 4 | nnum=int(input()) # You are provided with an array in which all elements are repeated thrice except one which is repeated twice.Your task is to print that number.
lte=[int(i) for i in input().split()]
for i in range(0,nnum):
cq=0
for j in range(0,nnum):
if(lte[i]==lte[j]):
cq=cq+1
if not(cq==3):
pr... |
dd3d0dc10ae54bb16df36cdc6c8d4ef20e5ef148 | Vk-Demon/vk-code | /ckcompany5.py | 463 | 3.546875 | 4 | nnum=int(input()) # Given a number N followed by an array of N integers, replace every element with the greatest element on the right side(to that element) in the array. Replace last element with 0 as there no element on the right side of it.
lt=[int(i) for i in input().split()]
k=0
lt[0]=max(lt)
for i in range(1,nnum-... |
d8f48173674ed83b5ad948077c2a2574a875ee6b | Vk-Demon/vk-code | /ckstring27.py | 386 | 3.96875 | 4 | nst=input() # John cena wants to learn alphabet ordering. He was given a task of ordering of alphabets within a word in a given string. Write a program to help john to order the words.
s,lt="",[]
for i in range(0,len(nst)):
if(nst[i]!=" "):
s=s+nst[i]
else:
lt.append(''.join(sorted(s)))
s=""
lt.append('... |
202c25b36c6f831f4e4d63039423a9fe8a6414a0 | Vk-Demon/vk-code | /ckbegs219.py | 85 | 3.546875 | 4 | fnum=int(input())
facnum=1
for i in range(1,fnum+1):
facnum=facnum*i
print(facnum)
|
ed4db8473e18694bf49d911dcb51e4b2e1da9369 | Vk-Demon/vk-code | /ckcompany2.py | 386 | 3.71875 | 4 | nnum=int(input()) # Given a number n followed by n numbers. Find the numbers which are equal to their index value and print them in sorted order. If no such numbers are present print '-1' without quotes.
lt=[int(i) for i in input().split()]
qt,cn=[],0
for i in range(0,nnum):
if(lt[i]==i):
qt.append(lt[i])
cn=... |
5307a7c22bee74773374eb7459fb10f1d4f33c75 | Vk-Demon/vk-code | /cksorting1.py | 267 | 3.59375 | 4 | n,k=input().split() #Given 2 numbers N,K and an array of N integers, find if the element K exists in the array
n,k=int(n),int(k)
lt=[int(i) for i in input().split()]
c=0
for i in range(0,n):
if(lt[i]==k):
c=c+1
if(c==1):
print("yes")
else:
print("no")
|
42192ec45911cef6770fa81a2e6e374ae2956efa | Vk-Demon/vk-code | /ckalgorithm6.py | 439 | 3.734375 | 4 | nnum=int(input()) # Given a number N and an array of N integers, sort the array in increasing order and print the original indices of the elements present in sorted array.
lt=[int(i) for i in input().split()]
ilt=[i+1 for i in range(0,nnum)]
for i in range(0,nnum-1):
for j in range(i+1,nnum):
if(lt[i]>lt[j]... |
73a5d537c77e864762f76df95b275de8556f94f0 | Vk-Demon/vk-code | /ckmaths17.py | 254 | 3.59375 | 4 | def ncatalan(n): # Given a number N, print the first N Catalan numbers
if(n<=1):
return 1
ncn=0
for i in range(n):
ncn += ncatalan(i) * ncatalan(n-i-1)
return ncn
nnum=int(input())
for n in range(0,nnum+1):
print(ncatalan(n),end=" ")
|
4addc1cc171a60cf5c48f844bf42df2e1eb946f1 | Vk-Demon/vk-code | /ckmaths31.py | 461 | 3.734375 | 4 | def fact(n): # Rohan’s teacher wants to teach him about permuting the numbers.He is given an assignment,in which he is given a number,His task is to print the sum of all permutations that can be made up using those digits.
if(n==0):
return 1
else:
return (n*fact(n-1))
nnum=int(input())
lsb,m,c=0,nnum,0
whi... |
3267d625909212d8cc5e50d618e1f49afcdb518d | Vk-Demon/vk-code | /ckstring3.py | 160 | 4.03125 | 4 | nst=input().split() # Given a string/sentence change it to camelcase.
for i in range(0,len(nst)):
nst[i]=nst[i].capitalize()
for i in nst:
print(i,end="")
|
b57131dee1241d6a6c34eaef752940ba907eeda3 | Vk-Demon/vk-code | /ckbegs11.py | 110 | 3.921875 | 4 | numx=int(input())
if(numx > 0):
print("Positive")
elif(numx < 0):
print("Negative")
else:
print("Zero")
|
19ee424b1c826247598b74f2ef82620de8af8d5d | Vk-Demon/vk-code | /ckcompany29.py | 349 | 3.640625 | 4 | nnum,knum=input().split() # Given 2 numbers N and K followed by N numbers find if there exists a pair of numbers such that it adds upto K.
nnum,knum=int(nnum),int(knum)
lt=[int(i) for i in input().split()]
c=0
for i in range(0,nnum-1):
for j in range(i+1,nnum):
if(lt[i]+lt[j]==knum):
c=c+1
if(c>0):
print... |
7b73ec172c16b56345a0d157af1fe530dd0b3dd4 | Vk-Demon/vk-code | /ckmaths35.py | 284 | 3.765625 | 4 | def sumofap(a,d,n): # Given 3 numbers A,B,C find the sum of Arithmetic Series with a=A, d=B and n=C.
st=0
i=0
while(i<n):
st=st+a
a=a+d
i=i+1
return(st)
anum,dnum,nnum=input().split()
anum,dnum,nnum=int(anum),int(dnum),int(nnum)
print(sumofap(anum,dnum,nnum))
|
41deaf219c201896fd5a6e5293a99abb26a04637 | Vk-Demon/vk-code | /ckmaths26.py | 723 | 3.5 | 4 | nnum=int(input()) #
lt,c,bc=[1 for i in range(nnum)],2,0
while(c<=nnum):
p=c
for i in range(c,nnum+1):
if(p<=nnum):
if(lt[p-1]==0):
lt[p-1]=1
else:
lt[p-1]=0
p=p+c
c=c+1
for i in range(0,len(lt)):
if(lt[i]==1):
bc=bc+1
print(bc)
'''A man has n buckets. He travel... |
f5a52ca09aa36c6d5095ae2c3b314e6c51f51f2b | Vk-Demon/vk-code | /ckbegs213.py | 129 | 3.71875 | 4 | prnum=int(input())
cp=0
for i in range(1,prnum+1):
if(prnum%i==0):
cp=cp+1
if(cp==2):
print("yes")
else:
print("no")
|
71a69c0a0bf1e487a5643f4fce0879ece00ab960 | Vk-Demon/vk-code | /ckmaths29.py | 146 | 3.8125 | 4 | nnum=int(input()) # Given a number N,print the reverse of the number N.
st=0
while(nnum>0):
rt=nnum%10
st=st*10+rt
nnum=nnum//10
print(st)
|
5631f375de6b50feb9e57f6af440bdd314886eaa | Vk-Demon/vk-code | /ckarray12.py | 316 | 3.5 | 4 | nnum=int(input()) # Given a number N followed by N numbers. Find the smallest number and largest number and print both the indices(1 based indexing)
ltnum=[int(i) for i in input().split()]
a,b=min(ltnum),max(ltnum)
for i in range(0,nnum):
if(ltnum[i]==a):
k=i+1
elif(ltnum[i]==b):
l=i+1
print(k,l)
|
2e0dcb8f88f5b2c436960e03baf37abbd550bd56 | Vk-Demon/vk-code | /ckalgorithm4.py | 509 | 3.8125 | 4 | def binary(lt,k): # Given 2 numbers N,K followed by a sorted array of N elements, search and tell if an element K is present.(Do it in logN time complexity)
beg=0
end=len(lt)-1
found=0
while(beg<=end and not found):
mid=(beg+end)//2
if(lt[mid]==k):
found=1
else:
if(k<lt[mid]):
end=mid-1
else:
... |
1857f30e8ad1b813de184566f30f3044ba4a5e72 | Vk-Demon/vk-code | /ckcompany18.py | 546 | 3.8125 | 4 | def divide(n1,n2): # Divide two given integers A and B without using multiplication, division and mod operator. If it is overflow, return MAX_INT.
if (n1 == 0): return 0
if (n2 == 0): return INT_MAX
ngr = 0
if (n1 < 0):
n1 = - n1
if (n2 < 0):
n2= -n2
else:
ngr = True
elif... |
fc7fa9764c3e2da1633e8c9c61d1a8f96a7dc081 | gin-yz/python-advanced-programmar | /asynicio_learn/gather_wait.py | 1,075 | 3.53125 | 4 | """
gather可以分组
"""
import asyncio
from random import randint
from functools import partial
from time import time
async def other(i):
print('start{0}'.format(i))
await asyncio.sleep(abs(randint(0, 10) - i))
print('end{0}'.format(i))
return 'return code{0}'.format(i)
# 运行完成之后会调函数
def callBack(index, ... |
49f17c4602005da529fc3c7b2ecfd55a8f6579ce | gin-yz/python-advanced-programmar | /Process_learn/process_QueueWithPool.py | 841 | 3.59375 | 4 | # 使用pool时,要使用Manager中的pool,不然报错
from multiprocessing import Manager, Pool
import os
from time import sleep
def fuc_w(num, queue):
print('start {0}:{1}'.format(num, os.getpid()))
for i in range(5):
queue.put(i)
sleep(1)
print('finish %s' % num)
def fuc_r(num, queue):
print('start {0}:{1}'... |
f20787fcdf75a8f6870ea7b808c8ed7f0cf1d17d | gin-yz/python-advanced-programmar | /Thread_learn/thread_condition.py | 1,171 | 3.78125 | 4 | """
条件变量,用于复杂的线程间同步,完成协同,两种方法都可以
"""
from threading import Condition, Thread
class TianMao(Thread):
def __init__(self, cond):
super().__init__(name='天猫精灵')
self.cond = cond
def run(self):
with self.cond:
self.cond.wait()
print('{}:在'.format(self.name))
... |
890109f7335e625a6263aa21e3d813d7d7da0a3f | tententgc/program_sheetroom_jarnten | /ep1.py | 237 | 3.609375 | 4 | a = 5
b="Hello"
c =5.8
d= True
e = False
a = 10
print('tenten' + b)
# x,y,z = 10,20,30
# x=y=z=30
# print(x,y,z)
# # print(type(a))
# # print(type(b))
# # print(type(c))
# # print(type(d))
# # print(type(e))
# int str float booleans
|
b9102f491291de2432bdf0ab9093224f0844b124 | laalaguer/py-functional | /indexofany.py | 704 | 3.84375 | 4 | # Given a string, and another char set.
# Find the accurance of char in the string, log the positions.
def indexOfAny(str, char_list):
positions = []
# warning: below will create an acutal list, but will be gc immediately.
[ positions.append(idx) for idx, each in enumerate(str) if each in char_list ]
return positi... |
85da50e172bf91d117820dfc1c3407f705e51438 | kevin-d-mcewan/ClassExamples | /Chap8_StringsDeepLook/OtherSearchFxAccessingMatch.py | 3,624 | 4.78125 | 5 | import re
'''Earlier we used the fullmatch function to determine whether an
entire string matched a regular expression. There are several other
searching functions. Here, we discuss the search, match, findall and
finditer functions, and show how to access the matching substrings.'''
'''Function search looks in a s... |
e596dcba37980e424f4b79957b2752640bd325c4 | jafar-shodiq/pythonexercises1 | /d14q52-customexception.py | 268 | 3.5 | 4 | class CustomException(Exception):
'''
There is an error!!!
'''
pass
def __init__(self, message):
self.message = message
pass
my_error = CustomException('There is an error in your code, dunno what it is though')
print(my_error) |
d5d12eeb5b6b359a18afe28d587227a14fca93f3 | jafar-shodiq/pythonexercises1 | /d15q52-emailcompany.py | 143 | 3.640625 | 4 | import re
my_input = input('Enter your email: ')
pattern = r'(\w+)@(\w+)\.(com)'
answer = re.match(pattern, my_input)
print(answer.group(2))
|
102f54b41f1ef8d94038f2d6efa2539257258df7 | jafar-shodiq/pythonexercises1 | /d15q55-whitespace.py | 107 | 3.546875 | 4 | import re
my_input = input('Input: ')
pattern = r'\d'
answer = re.findall(pattern, my_input)
print(answer) |
789b0a94460d45870dfcb72b6fa34e66ea4721e0 | jafar-shodiq/pythonexercises1 | /d10q37-squaretpl.py | 117 | 3.734375 | 4 | def fn():
my_list=[]
for i in range(1, 21):
my_list.append(i**2)
print(tuple(my_list))
fn() |
946e4b074cc8c753f9b293f820b6edcedd5c7575 | gilbert-noriega-ii/managing-financial-data-in-python | /aggregating.py | 7,137 | 3.75 | 4 | # Inspect nyse using .info().
# With broadcasting and .div(), create a new column market_cap_m that contains the market capitalization in million USD.
# Omit the column 'Market Capitalization' with .drop().
# Apply the .groupby() method to nyse, using 'Sector' as the column to group your data by.
# Calculate the median... |
4016405b99169659ff9a933bdb5e911d7cdc53bc | koomi/projects | /copyfile/copyfile.py | 563 | 3.59375 | 4 | # -*- coding: utf-8 -*-
#!/usr/bin/python
#Filename:copyfile.py
import os,shutil
def mycopy(srcpath,dstpath):
if not os.path.exists(srcpath):
print ("srcpath not exist!")
if not os.path.exists(dstpath):
print ("dstpath not exist!")
for root,dirs,files in os.walk(srcpath,True):
for ea... |
148eb8c219f58dfe093c6cadb4fa573917af5ada | veso266/nitrome.com | /games/Flipside/Tools/GetLevels.py | 2,295 | 3.546875 | 4 | import os #to be able to create directory and work with files
def Py2():
import hashlib #To create out MD5
import urllib2 #import URLlib library for python2
import time #we need to sleep :)
class Python2():
global Directory #make this accessible from everywhere
Directory = "levels" #our DIR name
if not... |
6675dd6f027569085164b06bd00ac212cb9e3a2e | albonkey/BreakoutGamePython | /breakout_game.py | 9,816 | 3.53125 | 4 | from tkinter import *
import time
#Class which helps to make the block objects. Parameters(x,y,width,height,life)
class Block:
def __init__(self,x,y,w,h,life):
self.id = id
self.x = x
self.y = y
self.w = w
self.h = h
self.life = life
#Class to set up the blocks.
cla... |
eaa798c82807c4a5c4bd01cb591624ada65a4c28 | sharryhong/python | /02-datetime02.py | 413 | 3.609375 | 4 | import datetime
hundred = datetime.timedelta(days = 100)
today = datetime.datetime.now().date()
hundred_days = today + hundred
print("오늘 사귀면 {}일에 우리 100일이야.ㅋㅋ".format(hundred_days))
hundred_after = datetime.datetime.now().replace(hour = 9, minute = 0, second = 0) + datetime.timedelta(days = 100)
print("{}/{}/{}".f... |
83371d73600d733da1c87144d872669cfd47cf5d | ninotsiklauri/Test | /N2.py | 487 | 3.640625 | 4 | n = int(input("შემოიტანეთ თანხა თეთრებში: "))
def minNumOfCoins(n, coins):
nums = [float('inf') for x in range (n+1)]
nums[0] = 0
for coin in coins:
for amount in range (len(nums)):
if coin <= amount:
nums[amount] = min(nums[amount], 1 + nums[amount - coin])
... |
dcd62520ddbf6dceb6f3842349bddcb158f729db | dafnemus/python-curso-udemy | /Unidad_6/while_1.py | 567 | 3.578125 | 4 | # pylint: disable=missing-docstring
# Consideraciones con las itercaiones. Ejemplos:
# No se cumple la condicion. Imprime: end while
VALUE = 0
while VALUE > 1:
VALUE *= 2
print(f'value {VALUE}')
print('end while')
print()
# OJO: ciclo infinito. Uso del break para terminarlo.
VALUE = 2
while VALUE > 1:
VA... |
d482a6771a78775979a498bf43ccf64002a763aa | dafnemus/python-curso-udemy | /Unidad_3/leccion_1.py | 584 | 3.828125 | 4 | # pylint: disable=missing-docstring
nombre = input('Hola, Cuál es tu nombre?: ')
print(f'Hola {nombre}') # formato 1
print('Hola', end=' ') # formato 2
print(nombre)
# conversión de horas a segundos.
horas = int(input('Ingrese cantidad de Horas: '))
UN_SEGUNDO = 3600
segundos_totales = horas * UN_SEGUNDO
print(f'se... |
8f8c017d20dac3f8e5dc3d25ca98cf952833ef98 | dafnemus/python-curso-udemy | /Unidad_3/leccion_2.py | 460 | 3.921875 | 4 | # pylint: disable=missing-docstring
# determinar si un numero es par o no.
numero = int(input('Ingrese un número: '))
if numero % 2 == 0:
print(f'Es par {numero}')
else:
print(f'Es impar {numero}')
# determinar si es letra, digito o simbolo
caracter = input('ingrese un caracter: ')
if caracter.isalpha():
... |
f9d5fff03846fcaefe00ab3a0571933cf587c353 | pkreddy/Python_Projects | /leetcode/Rotate Image.py | 501 | 3.78125 | 4 | import numpy as np
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
l = len(matrix)
a = np.array(matrix).transpose()
a = np.rot90(matrix,3)
... |
728966bf6731c145ec9dc34b321b456c323ff4be | cynthiakellogg/web-scraping-challenge | /Missions_to_Mars/scrape_mars.py | 3,767 | 3.546875 | 4 | from splinter import Browser
from bs4 import BeautifulSoup
import pandas as pd
import requests
import time
def init_browser():
# @NOTE: Replace the path with your actual path to the chromedriver
executable_path = {"executable_path": "/usr/local/bin/chromedriver"}
return Browser("chrome", **executable_path,... |
d1095ec0950b4ded8702096b7d0e839ff55f9a53 | Sargazi77/Project3 | /artwork_ui.py | 2,422 | 3.75 | 4 | import artwork_db as artwork_db
from artists_artworks import Artists, Artworks
# Create an error exception
class ArtworkDataError(Exception):
pass
# Gets the user inputs
def add_artist_user_input():
name = input('Enter the name of the artist: ')
email = input('Enter the email of the artist: ')
ar... |
3ccbc656a21416775e612755c9c4105c2b3c560c | amberGithb/q1-q4 | /q1.py | 113 | 3.71875 | 4 | # Q1
nums = [1,2,3,4]
def sum_Func(nums):
return [sum(nums) - item for item in nums]
print (sum_Func(nums)) |
00901c4c228a2f957a3c9df1394636a864a200d8 | mayotama106/Python-test | /aifas/test.py | 189 | 3.71875 | 4 | from tkinter import*
root = Tk()
#text
mylabel = Label(root, text="hello world")
#put into the screen
#1 mylabel.pack()<- dont fix element
mylabel.grid(row=0, column=0)
root.mainloop() |
6f7a1f93dfccd5a04d414eba8e415dca4218ec5e | jan-verm/Max_inter_point_distance | /checksolution.py | 1,564 | 3.546875 | 4 | '''
Python scripts that plots solution
INPUT is two arguments : filename of polygon information and solution
for example: python3 checksolution.py vierkant.txt solution.txt
'''
import sys
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
polygonfile = sys.argv[1]
s... |
c0a10945e20bb5aa9f8dae0912b0b0b2a3fe4cab | ALPHAMARIOX/mario_kart_randomizer | /mkdd_randomizer.py | 1,458 | 3.5625 | 4 | import random
char = ['Mario', 'Luigi', 'Peach', 'Daisy', 'Yoshi', 'Birdo', 'Waluigi', 'Baby Mario', 'Baby Luigi', 'Koopa Troopa', 'Koopa Paratroopa', 'Diddy Kong', 'Bowser Jr.', 'Toad',
'Toadette', 'Donkey Kong', 'Bowser', 'Wario', 'King Boo', 'Petey Piranha']
vehicle_s = ['Goo-Goo Buggy', 'Rattle Buggy... |
1dcd1c852137076385a854977f309c721c8916ac | chenygdlut/Algorithm_practice | /层次遍历建树.py | 1,167 | 3.6875 | 4 | '''给定二叉树层次遍历序列,构建二叉树'''
List=[1,2,3,4,'#','#','#','#',5,'#','#','#','#','#','#','#','#',6]
# print(len(List))
class TreeNode:
def __init__(self,val):
self.val=val
self.left=None
self.right=None
def build(i):
if i>=len(List):
return None
if List[i]=='#':
return None
... |
fb709e563afffa19fc1cc868619bd7796d0b3899 | chenygdlut/Algorithm_practice | /动态规划/找零钱.py | 995 | 3.515625 | 4 | '''
LC 322
给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。
'''
def coinchange1(coins,amount):
dp=[float('inf') for i in range(amount+1)]
dp[0]=0
for i in range(1,amount+1):
for c in coins:
if i>=c:
dp[i]=min(dp[i],dp[i-c]+1)
if dp[am... |
f48a90175a5e8e870d8cdb5f66d8c9fd41b3d944 | chenygdlut/Algorithm_practice | /动态规划/最长回文子串.py | 654 | 3.65625 | 4 | '''
LC 5
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。
'''
def longestPalindrome(s):
n=len(s)
ans=s[0]
maxlen=1
dp=[[False for i in range(n)] for j in range(n)]
for i in range(n-2,-1,-1):
dp[i][i]=True
for j in range(i+1,n):
if s[i]==s[j]:
if i+1==j:
... |
25a4f5851233b431860f9976712792c35fe7ef37 | baidoosik/ProblemSolving | /Codility/frog_river_one.py | 702 | 3.828125 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import unittest
from typing import List
def solution(X: int, A: List[int]) -> int:
# write your code in Python 3.6
a_dict, a_sum = {}, 0
expected = sum([i for i in range(X + 1)])
for idx, num in enumerate(A):
... |
002914420294bea6c28f6a4b88e826d31338dcda | baidoosik/ProblemSolving | /sort/insertion_sort.py | 528 | 3.71875 | 4 | import random
def insertion_sort(array: list):
array_length = len(array)
for i in range(1, array_length):
for j in range(i, 0, -1):
if array[j-1] > array[j]:
array[j-1], array[j] = array[j], array[j-1]
else:
break
def test_pass():
test_set ... |
32623fa1d60c8a445508b6e5485f9c72c7ab8f3f | baidoosik/ProblemSolving | /BOJ/problem_1026.py | 878 | 3.578125 | 4 | from typing import List
def merge_sort(a: List[int]):
if len(a) > 1:
mid = len(a) // 2
left = a[:mid]
right = a[mid:]
merge_sort(left)
merge_sort(right)
i, j, k = 0, 0, 0
while i < len(left) and j < len(right):
if left[i] >= right[j]:
... |
6807f69e6b4d1280be28c7efe27000e686e130f4 | baidoosik/ProblemSolving | /Codility/cyclic_rotation.py | 430 | 3.796875 | 4 | import unittest
from typing import List
def solution(A:List[int], K: int)->List[int]:
a_length = len(A)
if K > a_length and a_length != 0:
K = K % len(A)
return A[a_length-K:] + A[:a_length-K]
class TestCase(unittest.TestCase):
def test(self):
input_list = [1, 2, 3, 4, 5]
inp... |
08d15b4bf3a84b4e0176e44da3d2063dc1e331ab | CalMcCormick/Python-Projects | /Finished/BlackJack.py | 4,619 | 3.859375 | 4 | ## As part of the 100 days of code, I will be making a simple version of blacjack to play in the terminal
import random
# Creating deck in a visual way
suits = [" of Clubs", " of Diamonds", " of Hearts", " of Spades"]
card_names = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
cards = []
for card i... |
4d167d27cc17e92f45fe0898ad4aa1bb16f75700 | BUUPE/HubCourseSelector | /algo.py | 6,747 | 3.515625 | 4 | from collections import deque
import time
import sys
import random
from vector_operations import vector_sub, non_pos, all_subvectors_of
from download_problems import read_problem
# Input: the credit_maxes and vectors of the vector problem
# Return: A function that takes as input zero arguments and returns a set of co... |
8478d2475e3df9b8039f471b8893508b55ac3a23 | beruic/path-generators | /path_generators.py | 5,773 | 3.703125 | 4 | import os
from typing import Set, List, Iterable, Callable, Generator
def directory_file_generator(directory: str, yield_extensions: Set[str] = None) -> Generator[str, None, None]:
"""
Generator to traverse the root directory recursively and yield files filtering on the given extensions, if any.
:param di... |
8784f56f872cea6ffab7517f482296ea9904a1b4 | SerdarKuliev/proj1 | /4/4-1.py | 622 | 4.15625 | 4 | #Реализовать скрипт, в котором должна быть предусмотрена функция расчета заработной платы сотрудника.
#В расчете необходимо использовать формулу: (выработка в часах*ставка в час) + премия.
#Для выполнения расчета для конкретных значений необходимо запускать скрипт с параметрами.
import my_func
print(str(my_func.my_f(in... |
1fcdfe329f1dfe122ec70ed61825ec7ba8957a36 | SerdarKuliev/proj1 | /6/6-3.py | 424 | 3.578125 | 4 | class Worker:
name = "Sergey"
surname = "Frolov"
position = "manager"
income = {"wage": int(wage), "bonus": int(bonus)}
class Position(Worker):
get_full_name = Worker.name + Worker.surname
get_total_income = (Worker.wage: input(": ") + Worker.bonus: input(": "))
def start(self):
pr... |
57f541234da83f773c5e138adedb2caf20cfceb3 | SerdarKuliev/proj1 | /2/2-1.py | 1,320 | 4.125 | 4 | #1. Создать список и заполнить его элементами различных типов данных. Реализовать скрипт проверки типа данных каждого элемента.
#Использовать функцию type() для проверки типа. Элементы списка можно не запрашивать у пользователя, а указать явно, в программе.
my_list = [34, None, 3.14, "Yo!", [1,2,67], 8*5, '8*5', True,... |
f199f56cb781171d81b502d4f92d5ca7f8e149ba | SerdarKuliev/proj1 | /1/2.py | 275 | 3.90625 | 4 | time= input("Введите число, в секундах, и я переведу его в часы.")
time = int(time)
htime = time//3600
mtime = time//60-htime*60
stime = time%60
print('{0:02}:{1:02}:{2:02}'.format((htime), (mtime), (stime)))
print("Не за что!")
|
12069614d5f488122bd8551d319dca81dd6f24fc | SerdarKuliev/proj1 | /7/7-3.py | 832 | 3.65625 | 4 | class Cell:
def __init__(self, W):
self.W = int(W)
def __str__(self):
return f'Result {self.W * "*"}'
def __add__(self, other):
return Cell(self.W + other.W)
def __sub__(self, other):
return self.W - other.W if (self.W - other.W) > 0 else print('minus')
def __mul... |
0bc6c828b992e85a24e0f301cedf804ea4288eac | SagePadawan/digitalcrafts-exercises | /user_square.py | 80 | 3.734375 | 4 | n = int(input("How big is the square? "))
for a in range(n):
print ("*" * n) |
999c44103b92c46e2a22e7bb96063540632a10d3 | manishad119/pythons | /langurburja.py | 1,190 | 3.578125 | 4 | DICES=["spade","club","langur","diamond","burja","heart"]
from Crypto.Random import random
class LangurBurjaGame:
def __init__(self):
"Initialize the game and roll the dice"
self.bets={}
self.dices=[random.choice(DICES) for _any in range(6)]
self.dicenum=dict([(dice,self.dices.coun... |
db4b3a1e6fa21b6293f5330e512b90829d3192f0 | slippingjimmies/DnDAppFiles | /create_compendiums.py | 5,933 | 3.65625 | 4 | """Create compendiums by combining the XML
Run this file from the root directory (the place where this file resides)
$ python create_compendiums.py
This will update the XML files in the Compendiums directory.
"""
from xml.etree import ElementTree
from glob import glob
import argparse
def formatCompendiumFilena... |
9d3b83e6a87a2d244fe0579bb5eec0e1bf8242ff | Samih754/randomstuff | /Python/tests/name_is_thing.py | 234 | 3.609375 | 4 | def checkMyValues(*args):
for each in args:
if isinstance(each, str) == True:
print(a["b"])
a = {}
b = input("Choose some1: ")
a[b] = "Gaspi is Age: 12y Height: 4.7feet Weight: 150lbs"
print(a[b])
|
6c7681acb37e2e75bd89264a5695310c983f5f8e | Samih754/randomstuff | /Python/fun/pythagore.theorie.py | 875 | 3.84375 | 4 | a = input('Calcul hyp (1) ou autre (2): ')
try:
a = float(a)
except:
print('put a number')
exit()
if 1 == (a):
x = input("AB=?: " )
y = input("BC=?: ")
try:
x = float(x)
except:
print('put a number')
exit()
try:
y = float(y)
except:
... |
bcc20d4a09dff46a2679d60777b5510de20fb137 | bertrandmoulard/software_engineering_group_learning | /arrays.py | 2,298 | 3.921875 | 4 | # Given a list of signed integers, return true if the sum of any two integers is 0
# Brute force would to be look at each pair of integer elements and see if sum is 0 but the complexity is O(n^2)
# def sum2(arr):
# # Looping through arrary with index and the value
# for i_index, i in enumerate(arr):
# ... |
13145c8d90d36f5915ce4ddca79d74f1142b91e9 | abecus/Queues | /pyqueues/heap.py | 1,338 | 3.65625 | 4 | def heapify(arr: list, *, i: int=None) -> None:
def helper(i):
# goes from parent to the child (down)
"""
comparing children and spawing parent to min of children if exist,
and doing same on swapped parent node
"""
while i<nTillLastRow:
ch1 = 2*i +1
try:
if arr[ch1]>arr[ch1+1]: ch1 += 1
exce... |
95b23e7e297549586cd8ecfd56d52c3fc59a501a | ellelang/MyLeetcode | /algo/Easy/009_Palindrome.py | 611 | 3.84375 | 4 | _author_ = 'Elle'
_project_ = 'leetcode'
# https://leetcode.com/problems/palindrome-number/
# Determine whether an integer is a palindrome. Do this without extra space.
# Check equivalence of first and last characters, moving inwards.
# Time - O(n)
# Space - O(1)
def isPalindrome(x):
num = 0
a = abs(x)
... |
1f4069a21af18b88a7ddf117162036d212f2135c | lfarnsworth/GIS_Python | /Coding_Challenges/Challenge2/2-List_Overlap.py | 1,133 | 4.375 | 4 | # 2. List overlap
# Using these lists:
#
# list_a = ['dog', 'cat', 'rabbit', 'hamster', 'gerbil']
# list_b = ['dog', 'hamster', 'snake']
# Determine which items are present in both lists.
# Determine which items do not overlap in the lists.
# #Determine which items overlap in the lists:
def intersection(list_a, list_b... |
7a6943e9a6c4430ab2585ea8facb359ceacf99da | beanboye911/learning | /class2/equation.py | 251 | 3.96875 | 4 |
print("this is a tool to solve quadratic equations. ")
a = float(input("pls type. "))
b = float(input("pls type second. "))
c = float(input("pls type threed. "))
print("your equation is %gx^2+%gx+%g=0" %(a, b, c))
print("solution to equasions is: ")
|
f3928c1b4bb1721bd64fe3b55c2b56d775d87482 | sushreesatapathy/day2-python | /string.py | 306 | 4.09375 | 4 | str = 'Hello world'
print(str)
print(str[0])
print(str[2:5])
print(str[2:])
print(str[:5])
print(str[0::2])
print(str * 2)
print(str[-1])
print(str + "TEST")
print('H' in str)
print('f'in str)
print("My name is {} and id is {}.".format('Sushree',31))
print("My name is %s and id is %d." % ('Sushree',31))
|
798e538dd63333fa7396c1d42a3ca7fce1b71f3c | dikers/data-structure-and-algorithm | /python/graph/FindBridges.py | 1,706 | 3.515625 | 4 | from graph.Graph import Graph
class Edge:
v = 0
w = 0
def __init__(self, v: int , w: int):
self.v = v
self.w = w
def __str__(self):
return "v: {} w: {} ".format(self.v, self.w)
class FindBridges:
def __init__(self, G: Graph):
self._order = []
self._low ... |
63a4511e88b43232a8383a1d86ed4fa9f5a895a2 | dikers/data-structure-and-algorithm | /python/trie/Trie.py | 1,318 | 3.71875 | 4 | """
LeetCode 208
"""
class Node:
def __init__(self, is_word=False):
self.is_word = is_word
self.next = dict()
class Trie:
def __init__(self):
self.root = Node()
self.size = 0
def get_size(self):
return self.size
def add(self, word: str):
cur ... |
1666888c83c61e4d92dfb7f88c5cc7436e8aa544 | dikers/data-structure-and-algorithm | /python/graph_bfs/USSSPath.py | 1,592 | 3.515625 | 4 | """
Unweighted Single Source Shortest Path
无权图单源最短路径
"""
from graph.Graph import Graph
from collections import deque
class USSSPath:
def __init__(self, G: Graph, s: int):
self.G = G
self._s = s
self._visited = [False] * G.get_v()
self._pre = [-1] * G.get_v()
self._dis =... |
81f5472d8e305f7968f5e4af6553aae267e085c3 | dikers/data-structure-and-algorithm | /python/graph_directed/CC.py | 1,707 | 4 | 4 | from graph_directed.Graph import Graph
"""
联通分量, 分成几个独立的子图
"""
class CC:
def __init__(self, G: Graph):
# self._order = []
# assert not G.directed, " CC only works in undirected graph."
self.G = G
self.visited = [-1] * G.get_v()
self.cccount = 0 #联通分量
for v in ra... |
461d2a186e2b4839503affa980b02c5f7bbccf54 | dikers/data-structure-and-algorithm | /python/graph/GraphDFS.py | 1,027 | 3.609375 | 4 | from graph.Graph import Graph
class GraphDFS:
def __init__(self, G: Graph):
self._order = []
self._pre = []
self._post = []
self.G = G
self.visited = [False] * G.get_v()
self.cccount = 0 #联通分量
for v in range(G.get_v()):
if not self.visited[v]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.