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 |
|---|---|---|---|---|---|---|
c5bbea915ac4429c36e533b2a9cf6496216142f7 | rdonlan/Long-Live-Limericks | /rank_select.py | 5,009 | 4.03125 | 4 | # imports
import random
from limerick_class_file import syllable_fitness, rhyming_fitness
'''
This method returns the sum of all the ranks for a given population. It iterates through the size of the
population and sums all the index's. The denominator will be used to calculate probabilities for each
individual index.... |
6fe87421f036a7626144832ee207186e14c669e1 | FlorianCassayre/jupyter_notebooks_AL | /Chapitre 1 - Systemes equations lineaires/trash/untitled6.py | 3,163 | 3.8125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 18 15:14:28 2019
@author: jecker
"""
import AL_Fct as al
import numpy as np
import matplotlib.pyplot as plt
import math
print("Entrez le nombre de variables n=")
n=input()
n=al.EnterInt(n)
print("Entrez le nombre d'équations m=")
m=input()
m=al.... |
45e9ae8307acd51aa3b19e9eed3f1d701c8f53e1 | tparmar/python | /HW_codes/caesar.py | 1,756 | 4 | 4 | import string
key = input("Key:")
def caesar(key):
key = int(key)
counter = 0
text = input("plaintext:")
ciphertext = "ciphertext: "
for i in range(len(text)):
if text[i].isalpha() == False:
ciphertext = ciphertext + text[i]
if text[i].islower() == True:
i = o... |
a753cc253d2c6221933be7d45511a818279355ac | tparmar/python | /HW_codes/Mad_libs.py | 266 | 3.71875 | 4 | noun = input("Enter a noun: ")
noun2 = input("Enter another noun: ")
color = input("Enter a color: ")
color2 = input("Enter another color: ")
verb = input("Enter a verb: ")
print(noun + " are " + color)
print(noun2 + " are " + color2)
print("I " + verb + " you")
|
41e1d43d8610181325ef6f860ef01733fe10491c | Kamou01/python-conditional-task | /main.py | 391 | 4.0625 | 4 | # Metro Police Speed System Task
average_speed = float(input("Enter the average speed:"))
speed_used = float(input("Enter the speed used: "))
points = (speed_used - average_speed)//5
if speed_used <= average_speed:
print("OK")
else:
speed_used - average_speed
diff = (speed_used - average_speed) /5
pr... |
98ccdfb2c95d0da8c2e69d86e5d725154e0fc4e1 | FerCremonez/College-2nd-semester | /sem2a1e1.py | 80 | 3.5 | 4 | nome=input('informe seu nome:')
for i in range(len(nome)):
print(nome)
|
f84302218d1d0e8623e283b7c9f070cbc6bed3ca | wangzhixuan/LeetCodeSolution | /src/049.Group Anagram.py | 928 | 3.609375 | 4 | """
Leetcode OJ time: 306ms
"""
class Solution:
# @param strs, a list of strings
# @return a list of strings
def groupAnagrams(self, strs):
dict_of_tuples = {}
for index in range(len(strs)):
string = strs[index]
tmplst = [0] * 26
... |
05f541aef2ce875684cad17404d61f363cd215c4 | wangzhixuan/LeetCodeSolution | /src/Reorder List.py | 948 | 3.78125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return nothing
def reorderList(self, head):
"""
O(N) time cost, O(N) space cost
"""
if head==None:
... |
c399c13d940b34c4725c34248ac1ef74033e1ac3 | wangzhixuan/LeetCodeSolution | /src/Word Ladder.py | 1,230 | 3.59375 | 4 | class Solution:
# @param start, a string
# @param end, a string
# @param dict, a set of string
# @return an integer
def ladderLength(self, start, end, dict):
if start == end:
return 0
dict.add(end)
totalcount = len(dict)
lengthcount = 2
... |
41017e5a3274ba6084c8f93678d4ceaa78f5739c | wangzhixuan/LeetCodeSolution | /src/Minimum Depth of Binary Tree.py | 1,006 | 3.609375 | 4 | # Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return an integer
def minDepth(self, root):
self.mindepth = float("inf")
return sel... |
b54255d8ee176a319c8737851e955df15b007777 | wangzhixuan/LeetCodeSolution | /src/Simplify Path.py | 1,727 | 3.75 | 4 | class Solution:
# @param path, a string
# @return a string
def simplifyPath(self, path):
p = []
new_input = False
one_dot = False
two_dots = False
path += "/"
for letter in path:
if letter not in (".", "/"):
if new_input:
... |
27ae7ca24b86e7ab0ba022175005a3ba7b9b1345 | wangdan377/Test_01 | /智神/UI自动化/py/py00/Test_setttle3/lizhi/4.040_参数表和传入值.py | 133 | 3.734375 | 4 | def power(base,exponent):
result = base ** exponent
print("{}的{}次方等于{}" . format(base,exponent,result))
power(10,2) |
cf6bf6622b8ac6cc3d2396879e3d70ffb0405e14 | wangdan377/Test_01 | /智神/UI自动化/py/py01/stu/try_except.py | 3,286 | 3.875 | 4 | #处理单个异常
"""name = [1,2,3]
try:
name[1] #code 处理语句
except IndexError as e: #遇到报错执行下面的语句
print(e) """
#处理多个异常
"""name = [1, 2, 3]
data = {'a':'b'}
try:
data['a'] #已经出现异常keyError,所以直接跳出来code,跳到keyError下去处理
name[5]
except IndexError as e: #超过索引报错
print(e)
except KeyError as e: #访问字典里... |
1f4d1b56a04d8189a8d62af0775eb55e6d1195dc | wangdan377/Test_01 | /智神/UI自动化/py/py01/Test_setttle3/lizhi/1_内建函数.py | 1,792 | 4.25 | 4 | '''
#内建函数
print('abc'.capitalize()) #把字符串得第一个字母大写
str1= "abc"
print(str1.center(6,"1")) #str.center(width,fillchar) fillchar为填充字符,只能一个字符
str2 = "hello python world"
print(str2.count("o",5,30)) #"str.count(sub, start=0,end=len(string) )
str3 = 'name.py'
suffix = '.py'
print(str3.endswith(str3, 0, 20)) # True
s... |
682825a5f6de6cb96480242cb1b445cb0f47de32 | wangdan377/Test_01 | /优特/自动化脚本/IOT/test_IOT/lizhi/2.060_datatime.py | 500 | 3.609375 | 4 | from datetime import datetime
import time
now = datetime.now()
print(now)
# print('{:.2f} {:.3f} {:.4f}'.format(now.month,now.day,now.year))
print('{:02d} {:03d} {:04d}'.format(now.month,now.day,now.year))
print(time.localtime(time.time()))
print(time.strftime('%Y-%m-%d',time.localtime(time.time())))
print(time.str... |
1fa872c450c1cab1e059ea865d0228596ef7ddbf | snooowman/leecode | /剑指/21 调整数组顺序使奇数位于偶数前面/21.py | 1,365 | 3.78125 | 4 | # -*- coding:utf-8 -*-
# Definition for singly-linked list.
class Solution(object):
def exchange(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
# l1=[]
# l2=[]
# for i in nums:
# if i%2:
# l1.append(i)
# el... |
502af964c616ca5b654f94e20e0a9698f661db80 | snooowman/leecode | /剑指/16 数值的整数次方/16.py | 458 | 3.609375 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
# return x**n
res = 1
if n<0:
n=-n
x=1/x
while n>0:
if n%2:
res = res*x
... |
abd36439d181b55f14bbd775dc11d099e5bd80af | snooowman/leecode | /剑指/12 矩阵中的路径/12.py | 944 | 3.65625 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
def bfs(i,j,k):
print(i,j,k)
if not 0<=i < len(board) or not 0 <= j < len(board[0]) or board[i][j] !=... |
c702ae20514660d39082e4f6ff19bdb8b837bb28 | snooowman/leecode | /剑指/40 最小的k个数/40.py | 316 | 3.578125 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def getLeastNumbers(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype: List[int]
"""
arr.sort()
return arr[0:k]
if __name__ == '__main__':
s=Solution()
print(s.getLeastNumbers([3,2,1], 2)) |
e0fb368352c376d655611ee9eec8a689525a0b54 | snooowman/leecode | /剑指/07 重建二叉树/07.py | 884 | 3.984375 | 4 | # -*- coding:utf-8 -*-
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
preorder = [3,9,20,15,7]
inorder = [9,3,15,20,7]
class Solution(object):
def buildTree(self, preorder, inorder):
"""
... |
dc340d378993732b1e1aae9bd4858f9f665767bf | emilianoNM/TecnicasDeProgramaci-n | /Jose/sistemadegraficacion.py | 5,826 | 3.953125 | 4 | class Main():
atributoDeObjetoGrafico=None
xMax=None
yMax=None
tipoFigura=None
def opcion(self):
print ("Menu: ")
print ("1. Elegir dimensiones de espacio de grafica")
print ("2. Elegir figura de grafica")
print ("3.indicaciones de los atributos")
... |
59fe14c79240793aa66575e0fe9147ff473d2743 | emilianoNM/TecnicasDeProgramaci-n | /AlejandroZapett/escuela.py | 2,241 | 3.703125 | 4 | class Escuela():
nombre=[]
sexo=[]
edad=[]
estatura=[]
peso=[]
numero=None
def menu(self):
print """ 1. Escribir el archivo de datos
2. Leer y procesar los datos
3. Terminar"""
opcion=input("Ingresa una opcion: ")
x=opciones()
if opcion ... |
13cba0bf7a2f7892bab827f275b4062f2de1f1cb | dantegg/pythonLearning | /itertoolsLearn.py | 183 | 3.53125 | 4 | import itertools
naturalNumbers = itertools.count(1)
ns = itertools.takewhile(lambda x : x <= 10, naturalNumbers)
print(list(ns))
for c in itertools.chain('ABC','XYZ'):
print(c) |
1ccbbbfa6039898cc7ba3eeb9935fd8fe67928d7 | dantegg/pythonLearning | /classLearning.py | 236 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Student(object):
def __init__(self, name, score):
self.name = name
self.score = score
def print_score(std):
print('%s: %s' % (std.name, std.score)) |
9629296485bb68e60afc60105a01c512b0864d4c | dantegg/pythonLearning | /decorator.py | 1,367 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import functools_learn
def now():
print('now')
f = now
print(now.__name__)
print(f.__name__)
def log(func):
# wrapper() 函数的参数定义是(*args, **kw),因此,wrapper()函数可以接受任意参数的调用。在wrapper()函数内,首先打印日志,再紧接着调用原始函数
def wrapper(*args, **kw):
print('call %s():' %... |
48108b1d24bc92d1d52af57f50fed1f7e06b45a9 | brivalmar/Project_Euler | /Python/Euler1.py | 202 | 4.125 | 4 | total = 0
endRange = 1000
for x in range(0, endRange):
if x % 3 == 0 or x % 5 == 0:
total = total + x
print "The sum of numbers divisible by 3 and 5 that are less than 1000 is: %d " % total
|
36d231cf5941fd7c5d6ca2e9ef059a07e299ec26 | AkhlakAnsari/FACTORS-OF-NUMBER- | /factors of number usnig for loop.py | 184 | 4.15625 | 4 | #factors of user input number using for loop
x= int(input('ENTER THE NUMBER:'))
print('FACTORS OF',x,'IS:')
for i in range(1,x+1):
if x%i==0:
print(i)
#thanks akhlakansari94@gmail.com |
f277e8286bb5bd9da3a3ae67308832f88e3d1876 | Wa0k/Huffman-Coding-Algorithm | /Huffman_Coding_Algorithm.py | 4,563 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: Utf-8 -*-
"""
Huffman algorithm:
==================
This script allows to compress the text into the text.txt file according to
the Huffman's algorithm, and save the output (i.e. the compressed text) into
the output.txt file.
"""
__author__ = "ONILLON Louis"
__... |
2597e982e30108739b114936cdc0ffc3e92249ac | pbraer/Case-7 | /main.py | 3,660 | 3.546875 | 4 | # Case-study #7
# Developers: Braer P. (70%),
# Kokorina D. (50%),
# Novoselov V. (35%)
print("""Case-study Генератор текста
Разработчики:
Браер П.С., Кокорина Д.Е., Новоселов В.В.
""")
import codecs
text = ''
with codecs.open('input.txt', 'r', encoding='utf-8') as f:
lines = f.... |
06fdf709f700d25d546173440f17de3b3fd1dee0 | strar-buck/algo_implementation | /binary_search.py | 471 | 3.984375 | 4 | def binary_search(list,item):
low=0
high=len(list)-1
found=False
while low<=high and not found:
midpoint=(low+high)//2
print midpoint
print '###############'
if list[midpoint]==item:
found=True
else:
if item > list[midpoint]:
... |
c32b53ebb66cb9f60fabc114b04ae8033bf8adce | AnastasiiaKorosteleva/Python | /homeworks/Fall'15/homework2/task0.py | 697 | 3.828125 | 4 | __author__ = 'anastasiiakorosteleva'
def plural(n, cases):
if n % 10 == 1 and n % 100 != 11:
return cases[0]
elif 2 <= n % 10 <= 4 and (12 > n % 100 or n % 100 > 14):
return cases[1]
else:
return cases[2]
cases = {"утюг": ["утюг", "утюга", "утюгов"],
"ложка": ["ложка", "лож... |
82701d50b4d68d53a60d122b8d563123afff3b49 | esickert/PythonStuff | /PythonPlayground/bottlesOfBeer.py | 314 | 3.765625 | 4 | #for i in range(4,0,-1):
# print str(i) + " bottles of beer on the wall, " + str(i -1) + " Bottles of beer"
i = 0
while i < 4:
#print("heloo")
print (str(i) + " bottles of beer on the wall, " + str(i - 1) + " bottles of beer")
i = i + 1
#while i < 4:
# print ("Hello")
# i = i + 1
|
82f3c7725d6c382ad4b2188f4795cf2b50d302ce | Dreem-Organization/dosed | /dosed/utils/colorize.py | 542 | 3.734375 | 4 | """ Colorize text displayed on terminal. """
color2num = dict(
gray=30,
red=31,
green=32,
yellow=33,
blue=34,
magenta=35,
cyan=36,
white=37,
crimson=38
)
def colorize(string, color, bold=False, highlight=False):
"""
Colorize a string.
This function was originally writ... |
95b014797d6efaa3526a0ed2c529a5b1bcd707b2 | Sneha-BK/Performing-Analysis-of-Meteorological-Data | /DA Project1.py | 8,030 | 3.515625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
#loading the dataset
df = pd.read_csv('weatherHistory.csv')
df.shape
df.dtypes
df['Formatted Date'] = pd.to_datetime(df['Formatted Date'], utc=True)
df['Formatted Date']
df.dtypes
df = df.set_index('Fo... |
5fe06181fdba95454b33308a12db672b0ad0c57d | Shreemay/FP | /8.py | 176 | 3.703125 | 4 | def fibo(i):
if i == 0:
return [1,1]
lst=fibo(i-1)
print lst[0]
return [lst[1],lst[0]+lst[1]]
i=998
fibo(i)
#Highest value for which fibonacci series is printed is 998
|
8d1021bbf9bf19218630993b7ac778067d9040f3 | sungwoncho94/intermediate | /day_10/test.py | 153 | 3.578125 | 4 | test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
temp = test[-7:]
test = test[:-7]
print(temp)
print(test)
# 내가 원하는건 [8, 9, 10]이 나오는 것 |
a217d94134fef361e338ce658643a154ffa428f7 | RuslanBergenov/Udacity-Machine-Learning-Introduction-Nanodegree | /Deep Learning/1 Intro to Neural Networks/16 Quiz Coding Softmax/softmax.py | 602 | 4.0625 | 4 | import numpy as np
import math
# Write a function that takes as input a list of numbers, and returns
# the list of values given by the softmax function.
#https://stackabuse.com/the-python-math-library/
def softmax(L):
e = math.e
total = 0
for num in L:
myExp = e ** num
total = total +... |
f469d191a1f449c1caa8397d9d2480af3644a2b8 | ps-snu/21-book-study | /Week06/yuvin/BRACKETS2/main.py | 784 | 4.03125 | 4 | def is_right(brackets: str) -> bool:
brackets_stack = []
for b in brackets:
if b == "(" or b == "{" or b == "[":
brackets_stack.append(b)
else:
if len(brackets_stack) == 0:
return False
c = brackets_stack.pop(len(brackets_stack) - 1)
... |
6143eb348b3cb6ba6ac1df6eb13ab21c3ccc313f | szendrattila/f0004-orai- | /f0004d.py | 193 | 3.609375 | 4 | messze =input('hány magyar mérföldre van a sárkány barlangja?')
messze =int(messze)
km = messze * 8.35
tengeri = km / 1.85
print(km, 'kilométerre van és', tengeri, 'tengeri mérföldre') |
8d1ab7639173dba673e6726fc4e4343d81c9a82e | Vagelis-Prokopiou/python-challenges | /codingbat.com/Logic-2/lone_sum.py | 520 | 3.90625 | 4 | #!/usr/bin/python3
# @Author: Vagelis Prokopiou
# @Email: drz4007@gmail.com
# @Date: 2016-04-08 21:53:40
# Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum.
# lone_sum(1, 2, 3) → 6
# lone_sum(3, 2, 3) → 2
# lone_sum(3, ... |
3155cb38485c4990e1ebb6b02faecd3c42ea4287 | Vagelis-Prokopiou/python-challenges | /codingbat.com/Logic-2/make_chocolate.py | 877 | 4.03125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Author: Vagelis Prokopiou
# @Email: drz4007@gmail.com
# @Date: 2016-04-02 23:11:39
# We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars... |
1e9678c8d35c7aca75d938ee8e20f5accac7701b | Vagelis-Prokopiou/python-challenges | /codingbat.com/String-2/xyz_there.py | 501 | 3.9375 | 4 | #!/usr/bin/python3
# @Author: Vagelis Prokopiou
# @Email: drz4007@gmail.com
# @Date: 2016-04-02 17:56:21
# Return True if the given string contains an appearance of "xyz" where the xyz is not directly preceeded by a period (.). So "xxyz" counts but "x.xyz" does not.
# xyz_there('abcxyz') → True
# xyz_there('abc.xy... |
fa953151bcd9f30e8b3296380ef365c8cbb9e032 | Vagelis-Prokopiou/python-challenges | /codingbat.com/Logic-2/lucky_sum.py | 802 | 3.8125 | 4 | #!/usr/bin/python3
# @Author: Vagelis Prokopiou
# @Email: drz4007@gmail.com
# @Date: 2016-04-08 22:16:06
# Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not ... |
96d1013baf191fdc17c8e134d7e68886803aa689 | Vagelis-Prokopiou/python-challenges | /codingbat.com/String-2/end_other.py | 719 | 4.125 | 4 | #!/usr/bin/python3
# @Author: Vagelis Prokopiou
# @Email: drz4007@gmail.com
# @Date: 2016-04-02 17:33:14
# @Last Modified time: 2016-04-02 17:55:41
# Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the comput... |
e911a02fc0a955a44cf156203977a976a1bbf5ba | Haowen-Zhong/Python-Learning | /May/May_6_7/02.py | 703 | 3.703125 | 4 | from calculate import *
#在导入的时候会把所有的内容都加载进内存,无论是import 还是 from 的形式都会将模块内容进行加载
'''
导入方式:
1. import module
2. from module import function or class or variable
3. from module import * 该模块中所有内容均导入
如果想限制获取的内容可以在模块中利用__all__=['','',..]来决定使用*可以访问到的内容
'''
#使用模块中的函数 模块名.变量 模块名.函数 模块名.类
list1 = [4,2,3,4,5]
answer = add(*list1)... |
cd30d28c86f297f670283b00daefe319032a2e61 | Haowen-Zhong/Python-Learning | /May/Tkinter/11.py | 685 | 4.125 | 4 | from tkinter import *
root = Tk()
Label(root,text="作品:").grid(row = 0, column = 0)
Label(root,text="作者:").grid(row = 1, column = 0)
e1 = Entry(root)
e2 = Entry(root)
e1.grid(row = 0,column = 1, padx = 10, pady = 5)
e2.grid(row = 1,column = 1, padx = 10, pady=5)
def show():
print("作品:《%s》"%e1.get())
print("作者: %s"%... |
451e1bb4d4d26cbf7c213a700b4bd14895d2b3e0 | sukolekar/Coder | /Array/sequence_validate.py | 1,711 | 3.5 | 4 | '''
Problem: Validate sub-sequence
Method:1
time complex: O(n) || space comp: O(1) ---> where n is the length of the array.
space comp: O(1) ---> beacse we are not going to store any variabel or large amount of data
we are just store two pointer number number so it take constant amt space.
'''
... |
b0136d1a951db568c88661b8c5a8b7418871b963 | Dhruv1956/learning_python | /Chapter1_test/test_2.py | 407 | 3.890625 | 4 | def CreateGuestList():
guestlist=[]
while(True):
print("please enter the name")
name=str(input())
if(name=='done'):
break
guestlist.append(name)
return guestlist
def PrintList(list):
i=0
while(i<len(list)):
print(list[i])
i=i+1
guestlist=... |
141447dea87ce6914b8f9df45fa0af91ce78d53f | NamLH1310/Checkers-AI | /game.py | 2,252 | 3.703125 | 4 | #!/usr/bin/env python3
import pygame
from board import Board
from constants import RED, WHITE, BLUE, SQUARE_SIZE
empty = None
class Game:
def __init__(self, win: pygame.Surface):
self.selected = None
self.board = Board()
self.turn = RED
self.valid_moves = {}
self.win = win... |
4bf07debb2374bbad901b032e721ff5dcffe0024 | MichalMotylinski/PathFinding | /node.py | 740 | 3.734375 | 4 | # Represents a single node from grid
import pygame
class Node:
def __init__(self, obstacle, position_x, position_y):
self.obstacle = obstacle
self.visited = False
self.neighbours = []
self.parent = None
# distance from starting node
self.g_cost = float('inf')
... |
86c9ac52d9efe235224b3939a42e29d6568b196c | MitchellSturba/DuoLenium | /translatorTester.py | 355 | 3.578125 | 4 | #Script to test if the translate library is working
from googletrans import Translator
trans = Translator()
sentence = "Je suis un homme"
#If googletrans is working this will print "I am a man"
translated = trans.translate(sentence)
if translated == 'I am a man':
print(sentence, ': Working correctly')
else:
... |
7f253925d2e64d3bd3b1cfaef1116c71ea083662 | CosignMyCodesign/Python_exercise_1 | /stocks.py | 1,483 | 3.765625 | 4 | stockDict = {
'CK': 'Coke',
'MT': 'Mattress Firm',
'DS': 'Death Star'
}
purchases = [
('CK', 250, '11-sep-2001', 50),
('MT', 400, '4-dec-1978', 40),
('DS', 24, '31-dec-1999', 32)
]
# 1) We want individual output like this:
# I purchased General Electric stock on 10 - sep - 2001 for $4800
#... |
7dc265797fe60a6856af1f020128e38ccd5e9ee8 | Abhilekhnathdas/Search-Algorithms | /BFS.py | 1,723 | 3.8125 | 4 | print("Enter the edges if no edges need to be included write 'done'")
graphmatrix=[]
numtoval=dict({})
valtonum=dict({})
node=0
edges=[]
closed=[]
open=[]
path=""
def bfs(goal,path):
if len(open) != 0:
start = open.pop(0)
print(start)
else:
return [0, "no path"]
if sta... |
31e899e53309041b4cffcde9b3af857e48918d5f | PythonColab/aaditya_dvs_python | /que3.py | 826 | 3.6875 | 4 | fp=open("F:\\curr.txt","r+")
b=float(fp.read())
a=int(input("choose the initial currency in which the amount is curretly exist:\n press\n 1) INR(Rupee)\n 2) USD(American doller \n 3) Euro)"))
if a==1:
c=int(input("convert INR to\n 1) USD 2) Euro"))
elif a==2 :
c=int(input("convert USD to\n 1) INR 2) Euro"))
el... |
02357acf215ff232900d72f099331ae39b363483 | abhijeet65/Codewars | /Python/Sort the odd.py | 284 | 3.53125 | 4 | def sort_array(source_array):
odd_nums = sorted([n for n in source_array if n % 2 == 1]);
odd_inds = [i for i in range(len(source_array)) if source_array[i] % 2 == 1];
for i in range(len(odd_inds)):
source_array[odd_inds[i]] = odd_nums[i];
return source_array; |
8e006bf56350ace13b75f55a023cd8a2ed0860be | abhijeet65/Codewars | /Python/Look and say sequence generator.py | 363 | 3.75 | 4 | from itertools import groupby
def look_and_say(s):
num_cc = [(key, len(list(group))) for key, group in groupby(list(s))];
result = "".join([str(cc) + num for num, cc in num_cc]);
return result;
def look_and_say_sequence(first_element, n):
for i in range(n - 1):
first_element = look_and_sa... |
9cf81983c0be718705b912918dad4cd3a9c4e8aa | divyaprakashdp/DSA-with-Python | /quicksort.py | 470 | 3.9375 | 4 | def quicksort(listToSort):
if len(listToSort) <= 1:
return listToSort
pivot = listToSort[0]
less_than_pivot = []
greater_than_pivot = []
for value in listToSort[1:]:
if value <= pivot:
less_than_pivot.append(value)
else:
greater_than_pivot.append(valu... |
3bbcd1c6f539b634282237cfb659fde50dacce9b | divyaprakashdp/DSA-with-Python | /Practise_Questions/Check_Permutation.py | 521 | 3.859375 | 4 | """
Check Permutation: Given two strings, write a method to decide if one is a permutation of the other.
"""
def check_permutation(strs):
sorted_strs = []
for i in range(len(strs)):
list_Chars = list(strs[i])
list_Chars.sort()
sorted_strs.append("".join(list_Chars))
print(sorted_str... |
dc0aaec53f5565f1396c8cb1907070f4b1f9527d | divyaprakashdp/DSA-with-Python | /merge_sort.py | 1,422 | 4.3125 | 4 | def merge_sort(listToSort):
"""
sorts a list in descending order
Returns a new sordted list
"""
if len(listToSort) <= 1:
return listToSort
leftHalf, rightHalf = split(listToSort)
left = merge_sort(leftHalf)
right = merge_sort(rightHalf)
return merge(left, right)
def split... |
fa451af35c161019c137f14740cd6a314e6c0119 | divyaprakashdp/DSA-with-Python | /Practise_Questions/PairFinder.py | 593 | 4.0625 | 4 | '''
Given an array of distinct integer values, count the number of pairs of integers that
have difference k. For example, given the array {1, 7, 5, 9, 2, 12, 3} and the difference
k = 2, there are four pairs with difference 2: (1, 3), (3, 5), (5, 7), (7, 9)
'''
def pair_finder(input_array):
dict = {}
for i in ... |
98d33b84923dcbde571fae0e88b0f8d6b465c6c6 | Caelan-M/Caelan_Marks_test | /QuestionB.py | 1,656 | 3.90625 | 4 | # The goal of this question is to write a software library that accepts 2 version string
# as input and returns whether one is greater than, equal, or less than the other.
# As an example: “1.2” is greater than “1.1”. Please provide all test cases you could think of.
def version(version1, version2):
if version1 =... |
d7779a1ce34f805f511f33157252b14f32730bd4 | Waqar-107/Codeforces | /A-set/938A.Word Correction.py | 318 | 3.59375 | 4 | # from dust i have come dust i will be
n=int(input())
s=input()
a=['a','e','i','o','u','y']
ch='#'
for i in range(n):
if s[i] not in a:
if ch!='#':
print(ch,end='')
ch='#'
print(s[i],end='')
else:
if ch=='#':
ch=s[i]
if ch!='#':
print(ch)
|
69c9c072ff140c4602d2c8d555b311f90687e24a | GyuWonLee/2018python | /test1.py | 768 | 3.6875 | 4 | import random;
player = input("(가위 바위 보) 중에서 하나를 선택하세요 : ")
number = random.randint(0,2)
if (number == 0):
computer = "가위"
elif (number == 1):
computer = "바위"
else:
computer = "보"
print("사용자 : ",player,"컴퓨터 : ",computer)
if(player == computer):
print("비겼음")
elif(player == "바위"):
if(computer == "보... |
a929a09ca0035685cd2ad666ac29bbf48ab884a9 | GyuWonLee/2018python | /sum2.py | 86 | 3.53125 | 4 | i = 1
sum = 0
while (i <= 10):
sum = sum + i
i = i + 1
print("합계 = ",sum) |
832b1f610fcc476aa174bd849d195b2c57bd95ce | GyuWonLee/2018python | /rect.py | 506 | 4.03125 | 4 | # 사각형을 클래스로 정의한다.
class Rectangle:
count_side = 4
def __init__(self, side=0):
self.side = side
def getArea(self):
return self.side*self.side
# 사각형 객체와 반복횟수를 받아서 변을 증가시키면서 면적을 출력한다.
def printAreas(r, n):
while n >= 1:
print(r.side, "\t", r.getArea())
r.side =... |
3ac7f9ad4272ab14fd27fb7c5a12f59e88f06524 | GyuWonLee/2018python | /assign.py | 1,164 | 3.578125 | 4 | import random
num = random.sample(range(000,999),3)
try_cnt = 0
str_cnt = 0
ball_cnt = 0
print("♡숫자 야구게임♡")
print("-"*10)
print("규칙 : 1에서 9사이 안 겹치는 숫자 3개 입력 : ")
while (str_cnt < 3):
num = input("숫자를 입력하세요 : ")
if(num [0] == num [1] == num[2]):
print("각기 다른 숫자 3개를 입력하세요")
try_cnt += 1
... |
830af5a53f7b765437e307f698d8a369e6441c28 | rekirky/hackerrank-30daysofcode | /day1.py | 459 | 4.0625 | 4 | # Day 1 - Data Types
# Declare second integer, double, and String variables.
# Read and save an integer, double, and String to your variables.
x = int(raw_input())
y = float(raw_input())
z = raw_input()
# Print the sum of both integer variables on a new line.
print(i+x)
# Print the sum of the double variables on a ne... |
b5c10ba5bf0b33539a28881fd120614ac57c8ca8 | gorgenyilmazz/Port-Scanner | /scanner.py | 1,282 | 3.53125 | 4 | #!/bin/python3
import sys
import socket
from datetime import datetime
#Define our Target
if len(sys.argv) == 2:
#Translate hostname to IPv4 (we can give directly host name)
target = socket.gethostbyname(sys.argv[1])
else:
print("Invalid amount of arguments.")
print("Syntax: python3 scanner.py <ip>")
#Add a ban... |
1e9573861ae3554f04dfa172bd80721ab033e2e2 | HappyGummyBear/Pong-Game | /pong_game/main.py | 2,102 | 4.03125 | 4 | from turtle import Turtle, Screen
from paddle import Paddle
from ball import Ball
from scoreboard import Scoreboard
import time
#Create window for the game. Setup size and color
screen = Screen()
screen.setup(width=800, height=600)
screen.bgcolor("black")
screen.title("Pong Game")
screen.listen() #Function ... |
74ef9161527511e88066737d08b32477e704feca | yann021/PythonAN21 | /Jour1/Exo/Tst7.py | 448 | 3.78125 | 4 | ma_list = []
Value = input("saisir une lettre \n ->")
while(Value!="q"):
ma_list.append(Value)
Value = input("saisir une lettre \n ->")
for nbr in ma_list:
c=ma_list.count(nbr)
if c>1:
ma_list.remove(nbr)
print(ma_list)
#ma_list = []
#while (true)
# n = input('Entrer une lettre')
# if n... |
8733a3b59588e1d1a049802b53625cbdf46ee520 | yann021/PythonAN21 | /Jour1/Exo/Tst9.py | 232 | 3.859375 | 4 | value = input("saisir un nombre \n ->")
value = int(value)
i = 1
result = 0
while(i<20):
result = value*i
if (result % 3 == 0):
print("*",result, "*")
print("coucou")
else:
print(result)
i+=1 |
06197c8cbd685a3945cbc8cf589310ca02b7fdfc | yann021/PythonAN21 | /Jour1/Exo/Tst2.py | 180 | 3.625 | 4 | a = 5
b = 6
print( "a vaut "+ str(a))
print( "b vaut "+ str(b))
c = a
a = b
b = c
print( "a vaut maintenant "+ str(a))
print( "b vaut maintenant " +str(b))
# Or
# a, b = b, a
|
cfe15358267692240c1ba645b6281cd6bb1077db | khy724/ITSP_Techinvestors | /senior_cit_fd_scrap.py | 2,732 | 3.765625 | 4 |
from bs4 import BeautifulSoup
import requests
import csv
import pandas as pd
#here we are importing various libraries that we would need to write up the code
def a():
csv_file=open('csv/senior_cit_fd.csv','w')
#creating a csv file
csv_writer=csv.writer(csv_file)
#opening in wriitng format
csv_write... |
843cf77b77dccdd9a2ae08a8271cfb608273411c | khy724/ITSP_Techinvestors | /stock_5.py | 6,187 | 3.59375 | 4 | import pandas as pd
import numpy as np #importing the necessary libraries
def a(day,amount): #taking the input for number of days and amount
Data = pd.read_csv('csv/small_cap.csv', parse_dates=True)
top_5= []
top= []
amount= float(amount)
data= np.array(Data) #converting to an... |
f9b8a258336cb6d5ae7e613405f61a36dd0c0610 | secginelif/python_algoritma2 | /asalsayi.py | 331 | 3.515625 | 4 | sayi = int(input("Sayı Giriniz :"))
list = []
for i in range(2,sayi):
durum = False
for a in range(2,i):
if i % a == 0:
durum = True
break
if not durum:
list.append(i)
for i in list:
print(i)
print("0 ile {} arasında {} tane asal sayı vardır. ".format(sayi,len(li... |
9f0d581974903fb4f242b8f840df30eb7e28bd20 | hellodoksa/django_final | /DJANGO/graph.py | 202 | 3.578125 | 4 | import matplotlib.pyplot as plt
x = [10,20,30,40,50,60,70,80,90]
y = [2 ,3 ,4 ,9 ,2 ,5 ,3 ,4 , 7]
plt.bar(x,y)
plt.title("ages & person")
plt.xlabel("ages")
plt.ylabel("person")
plt.show() |
ec31176cdec6912d4013de2a792c618f5c05a1e4 | uditseven/rock-paper-and-scissor | /rockpaper.py | 502 | 4 | 4 | from random import randint
player=input('rock(r),paper(p) or scissor(s)..??')
print(player,'vs', end='')
chosen=randint(1,3)
#print(chosen)
if chosen ==1:
computer = 'r'
elif chosen ==2:
computer= 'p'
else:
computer= 's'
print(" ",computer)
if player==computer:
print('draw!')
elif player =='r' and computer =='s... |
fd8e22fd8ed9cba5be66d30719468eb7e63b09b8 | Janbolotnr/ch2part1-task9 | /decision9.py | 165 | 4.09375 | 4 | number = int(input("Enter number: "))
i = 1
factorial = 1
while i <= number:
factorial *= i
i += 1
print("Factorial number", number, "equal", factorial)
|
b5cdd85f74b1d76ddef800a99738415396f9f900 | JoTerrance/SGE | /python/08_Lambda.py | 1,222 | 3.5 | 4 | import math
from functools import reduce
l = [1, 2, 3, 4]
def cuadrado(n): return n ** 2
l2 = map(cuadrado, l)
def raiz(n): return math.sqrt(n)
l2 = map(raiz, l)
def es_par(n):
return (n % 2.0 == 0)
l2 = filter(es_par, l)
def sumar(x, y):
sum = x + y
return sum
l2 = reduce(su... |
103d41b3d0776efde86ebcec3aeafef08cf8c72c | mashpolo/leetcode_ans | /200/leetcode257/ans.py | 1,022 | 3.703125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc: 二叉树的所有路径
@author: Luo.lu
@date: 2018-9-28
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def binaryTreePaths(self, root):
"""
:type root: TreeNode
... |
90d6aaa08546f50f9dfcbacbdd05c40e8fc0098d | mashpolo/leetcode_ans | /300/leetcode374/ans.py | 750 | 3.796875 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc: 猜数字大小
@author: Luo.lu
@date: 2018-10-11
"""
def guess(num):
if num > 6:
return -1
if num < 6:
return 1
if num == 6:
return 0
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: ... |
d6eeede6f9a6451573d4b9885854878f79bb5bd0 | mashpolo/leetcode_ans | /100/len_last_world/ans.py | 481 | 3.78125 | 4 | # Write your code here :-)
class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
s = s.replace(' ', ' ')
s_list = s.split(' ')
print(s_list)
while len(s_list) > 0 and s_list[-1] ... |
2551045ec7fe8a8d0c3c18400cee75563f5ea5b3 | mashpolo/leetcode_ans | /100/two_sum_2/ans.py | 831 | 3.59375 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc: 有序数组求指定和的两个数
@author: luluo
@date: 2018-9-4
"""
class Solution:
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
# for (index, x) in enumerate(numbers):
... |
c34b9b28f5058cb9661115d38197e5e856588d0e | mashpolo/leetcode_ans | /100/leetcode30/ans.py | 1,065 | 3.53125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-04-16
"""
class Solution:
def findSubstring(self, s, words):
"""
:type s: str
:type words: List[str]
:rtype: List[int]
"""
if len(words) == 0:
return []
word_len, s_len,... |
667134240639a296d1ddbeae3b4743684fa6542b | mashpolo/leetcode_ans | /500/leetcode506/ans.py | 845 | 3.546875 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2018-11-16
"""
class Solution:
def findRelativeRanks(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""
nums_bak = sorted(nums)
map_rs = {}
for (index, x) in enumerate(nums_b... |
c80a04c059a908f9f9bd59ba80c060884558e300 | mashpolo/leetcode_ans | /900/leetcode925/ans.py | 734 | 3.734375 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-03-09
"""
class Solution:
def isLongPressedName(self, name, typed):
"""
:type name: str
:type typed: str
:rtype: bool
"""
i,j=0,0
n,m = len(name),len(typed)
last =None
... |
64748a7dd7e8f7365979413f08aa883f7062acbd | mashpolo/leetcode_ans | /100/leetcode139/ans.py | 616 | 3.5 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-07-08
"""
class Solution(object):
# 本题回溯法超出时间限制,采用动态回归法
def wordBreak(self, s, wordDict):
"""
:type s: str
:type wordDict: List[str]
:rtype: bool
"""
# 初始化标记列表
flag = [True]+[Fa... |
20fe8c25110d68d540ba5ad3a04129a6d909f162 | mashpolo/leetcode_ans | /100/leetcode68/ans.py | 1,584 | 3.5625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-05-16
"""
class Solution:
def layout(self, words, curlen, maxWidth, last=False):
if len(words) == 1:
return words[0] + ' ' * (maxWidth - len(words[0]))
if last:
r = ' '.join(words)
re... |
407b812b363f9f58cd1a2dd929037a82bb4a315c | mashpolo/leetcode_ans | /600/leetcode682/ans.py | 893 | 3.515625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2018-12-29
"""
class Solution:
def calPoints(self, ops):
"""
:type ops: List[str]
:rtype: int
"""
if not ops:
return 0
res = []
for x in ops:
if x == '+':
... |
5e9883c7caf5a91ac9cb6c0aa07986f1b4f15235 | mashpolo/leetcode_ans | /100/leetcode140/ans.py | 1,149 | 3.828125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-07-10
"""
class Solution(object):
def wordBreak(self, s, wordDict):
"""
:type s: str
:type wordDict: List[str]
:rtype: List[str]
"""
# 借助139,判断是否存在可分的情况,否则特例可能会超时
if not s:
... |
24e4230463288a7f36595feb1d25cc276a4b8c87 | mashpolo/leetcode_ans | /100/leetcode11/ans.py | 432 | 3.6875 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-04-03
"""
class Solution:
def maxArea(self, height: list) -> int:
res = []
for i in range(len(height) - 1):
for y in range(1, len(height)):
res.append((y - i) * min(height[y], height[i]))
... |
0d759c5011c462db93c6eddc74f18c5d326b998f | mashpolo/leetcode_ans | /400/leetcode412/ans.py | 598 | 3.796875 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2018-10-21
"""
class Solution:
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
res = []
for x in range(1, n + 1):
if x % 15 == 0:
res.append("FizzBuzz... |
820f443c8e8d64d4ce68d6241ab7df94480bb44a | mashpolo/leetcode_ans | /200/leetcode283/ans.py | 597 | 3.890625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc: 移动零
@author: Luo.lu
@date: 2018-10-2
"""
class Solution:
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
l = len(nums)
x = n = 0
... |
fb3667db68e40c84e4f31df86a9a63702d215eb0 | mashpolo/leetcode_ans | /100/leetcode77/ans.py | 549 | 3.828125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-05-23
"""
class Solution(object):
def combine(self, n, k):
tmp, ret = [], []
self.dfs(n, k, 1, tmp, ret)
return ret
def dfs(self, n, k, index, tmp, ret):
if len(tmp) == k:
ret.append(tmp... |
c6d35f6222688dac8a470f6987374439ec8cab7f | mashpolo/leetcode_ans | /100/leetcode39/ans.py | 741 | 3.53125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-04-25
"""
class Solution(object):
def combinationSum(self, candidates, target):
tmp, ret = [], []
self.dfs(0, candidates, tmp, ret, target)
return ret
def dfs(self, index, candidates, tmp, ret, target):
... |
a6af9750499a081473c5f20206d6411c46654b94 | mashpolo/leetcode_ans | /800/leetcode821/ans.py | 606 | 3.625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-02-10
"""
class Solution:
def shortestToChar(self, S, C):
"""
:type S: str
:type C: str
:rtype: List[int]
"""
pos = []
for (index, x) in enumerate(S):
if x == C:
... |
2bd3b9bb9d9e2c2f8cb91aa8bddf92d6c8e2fb9c | mashpolo/leetcode_ans | /800/leetcode830/ans.py | 758 | 3.5625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-02-12
"""
class Solution:
def largeGroupPositions(self, S):
"""
:type S: str
:rtype: List[List[int]]
"""
first = end = 0
res = []
flag = None
for (index, x) in enumerate(S... |
09f3887daf01a8794ed95122e5785f5929e6b4d6 | mashpolo/leetcode_ans | /800/leetcode819/ans.py | 868 | 3.71875 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-02-09
"""
import re
class Solution:
def mostCommonWord(self, paragraph, banned):
"""
:type paragraph: str
:type banned: List[str]
:rtype: str
"""
para = re.sub(r"[!|?|'|,|;|\.]", ' ', par... |
2d42a977dd34e29a043a5232348accd6c663ca87 | mashpolo/leetcode_ans | /400/leetcode434/ans.py | 617 | 3.578125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2018-10-26
"""
class Solution(object):
def countSegments(self, s):
"""
:type s: str
:rtype: int
"""
if s.isspace():
return 0
s1 = s.strip()
if len(s1) == 0:
re... |
27e6c78de9ae2f6ff0c91d470bbf175bd9b7e7cc | mashpolo/leetcode_ans | /700/leetcode706/ans.py | 1,235 | 4.125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
@desc:
@author: Luo.lu
@date: 2019-01-09
"""
class MyHashMap:
def __init__(self):
"""
Initialize your data structure here.
"""
self.key = []
self.value = []
def put(self, key, value):
"""
value will always be... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.