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 |
|---|---|---|---|---|---|---|
1d7b0eb474b258abc83f30e679910512fbe0f33f | sehammuqil/python- | /day 9.py | 339 | 3.8125 | 4 | age = 36
txt = "my name is john , and i am {}"
print(txt.format(age))
quantity = 3
itemno = 567
price = 49.95
myorder= " i want {} pieces of item {} for {} dollars "
print(myorder.format(quantity,itemno,price))
myorder= " i want {2} pieces of item {1} for {0} dollars "
print(myorder.format(quantity,ite... |
a3cb102f415dfe67c53f3ff697b3d78369b5da11 | sehammuqil/python- | /day18,19.py | 481 | 4.1875 | 4 | #list
student =['sara','nora','hind']
print(student)
#append
student =['sara','nora','hind']
student.append("seham")
print(student)
#insert
student =['sara','nora','hind']
student.insert(2,"seham")
print(student)
#pop
student =['sara','nora','hind']
student.pop(2)
print(student)
#clear
stu... |
ae91ee6ae54b217b4db050fdb6312e1a1ba116b8 | sehammuqil/python- | /day16.py | 572 | 4.34375 | 4 | thistuple = ("apple","banana","cherry")
print(thistuple)
thistuple=()
print(thistuple)
thistuple=(3,)
print(thistuple)
thistuple=(3,1.3,4.1,7)
print(thistuple)
thistuple=("ahmad",1.1,4,"python")
print(thistuple)
thistuple = ("apple","banana","cherry")
print(thistuple[1])
thistupl... |
5bac31f5d187ea3d676b865cce3a6134089a8017 | sehammuqil/python- | /day24.py | 790 | 3.890625 | 4 | thisdict = {
"brabd":"ford",
"model":"mustang",
"year":1964
}
mydict= thisdict.copy()
print(mydict)
mydict=dict(thisdict)
print(mydict)
myfamily = {
"child1": {
"name":"emil",
"year":2004
},
"child2": {
"name":"tobias",
"year":2007
},
... |
a3c003e1a650a398285b3ef5f2383a264af7d4b9 | acedb/toolbox | /toolbox/datetime.py | 1,392 | 3.890625 | 4 | '''Functions dealing with datetime types'''
def round_six_hours(period):
'''Round datetime to closest 6h unit.
Period should be a df column which is already in datetime format.
'''
if period.hour < 6:
period = period.replace(hour = 0)
elif period.hour < 12 :
period = period.replace(hour = 6)
... |
2ac79ffb3fee134375cae0469c39feece2fb1ca1 | CristianCerutti/Sistemi-e-reti | /CreaPoligono.py | 479 | 3.671875 | 4 | #per aggiungere le librerie si schive import {nome libreria}
import turtle #importa la libreria turtle e tutto ciò che contiene
#from turtle import * #importa tutte le classi e si possono usare direttamente col loro nome
nlati = int(input("inserire il numero dei lati: \n"))
alice = turtle.Tur... |
7b4f0817e681d4c375c9c6a55db67aa6b3480f29 | CristianCerutti/Sistemi-e-reti | /es_pile_2.py | 913 | 4.0625 | 4 | def push_(pila, elemento):
pila.append(elemento)
def pop_(pila):
return pila.pop()
def main():
stringa = input("inserire una stringa di parentesi: ")
pila = []
cont = 0
pos = 0
lunghezza = len(stringa)
for _ in range(lunghezza):
if(stringa[pos] == '(' ):
... |
1645420882248e7ffa84200b538f9294884da028 | jmohit13/Algorithms-Data-Structures-Misc-Problems-Python | /data_structures/queue.py | 1,719 | 4.25 | 4 | # Queue Implementation
import unittest
class Queue:
"""
Queue maintain a FIFO ordering property.
FIFO : first-in first-out
"""
def __init__(self):
self.items = []
def enqueue(self,item):
"""
Adds a new item to the rear of the queue.
... |
a1572159f224683bf0ae26bfb969ac84a8411023 | jmohit13/Algorithms-Data-Structures-Misc-Problems-Python | /data_structures/deque.py | 1,909 | 4.03125 | 4 | # Deque
import unittest
class Deque:
"""
A deque, also known as a double-ended queue, is an ordered collection of items similar to the queue.
It has two ends, a front and a rear, and the items remain positioned in the collection.
New items can be added/removed at either the front or the rea... |
984b68c51dc82fa0be17c840c5a68a8599ac1ae7 | xposionn/NN-Perceptron-and-Adaline | /Algorithms/BackPropogation.py | 1,904 | 4.0625 | 4 | import numpy as np
class BackPropogation(object):
"""
This class represents an Perceptron algorithm.
"""
def __init__(self,hiddenSize):
#parameters
self.inputSize = 33
self.outputSize = 2
self.hiddenSize = hiddenSize
#weights
self.W1 = np.ra... |
55ceaf6dd6c2ef6583cdb6f3145cf9567af1c179 | DivyanshiSingh/Python-programs | /phonebook.py | 810 | 3.625 | 4 | from tkinter import *
root=Tk()
root.geometry("300x300")
root.title("PHONEBOOK")
root.configure(bg="red")
a=Entry(width="20",bg="white",fg="blue",font=("bold",30))
l1=Label(width="20",text="Enter name",font=("bold",30))
b1=Button(text="Find",width="20",bg="black",fg="blue",font=("bold",30))
l2=Label(width="20",text="En... |
a15af266be0ac2e87d756305f5627794ef2512f4 | DivyanshiSingh/Python-programs | /runnerup.py | 270 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 31 21:33:49 2019
@author: divyanshisingh
"""
l=[]
ch=1
while ch!=0:
m=int(input("enter the score"))
l.append(m)
ch=int(input("enter your choice<0/1>"))
n=max(l)
l.remove(n)
print(max(l)) |
5fd9a4cc229e2eca7dd11ada601c3ba055fc7807 | Flintstone-xu/crawler | /spider_practise_06_requests.py | 1,113 | 3.640625 | 4 | ##任务:使用request来学习post和get的区别,并且查看cookie和session
import requests
import webbrowser
#get请求
param={'wd':'科比'}#数据结构
request=requests.get('http://www.baidu.com/s',params=param)#传数据
print(request.url)#打印
#webbrowser.open(request.url)#浏览器打开url
#post请求
data={'firstname':'flintstone','lastname':'xu'}
request2=requests.post('... |
3c5f2ee72c7ebd047568d588d170c744c9cb1fd1 | Breen-dev/jeu_rpg_repos | /Environnement.py | 1,154 | 3.875 | 4 | """Classe qui établit les caractéristiques générales d'un environnement type.
Ces caractéristiques seront reprises pour influencer les statistiques et les évênements qui apparaissent."""
class Environnement():
def __init__(self, weather, temperature, daytime, environnement):
self.weather = weather
... |
c2584f5e013396b740dabb6144fb8dc27a4f2b67 | anoopvenugopal/CA1Pg | /StudentRec.py | 3,350 | 3.8125 | 4 | ''' Student record
1. Created a class for studentrec and declare init function
2. wrote the driver code for the program
3. Add display function for viewing the list
4. sorted the list using bubble sort
5. validated the input datas using regular expression
6. created a function for appending data... |
f29d76b7e2da0d18937ebb9e495321d68665ed5b | akshatasawhney/Competitive-Coding-7 | /kSmallestMatrix.py | 752 | 3.578125 | 4 | """
// Time Complexity : O(nlogk),
// Space Complexity : O(k)
// Did this code successfully run on Leetcode : yes
// Any problem you faced while coding this : no
"""
import heapq
class Solution(object):
def kthSmallest(self, matrix, k):
"""
:type matrix: List[List[int]]
:type k: int
... |
9ddcebad74a904da1d3ae9e02714fc1a143ee7ac | A-Dmitriy/DZ_3 | /3.5.py | 1,257 | 4.0625 | 4 | #5. Программа запрашивает у пользователя строку чисел, разделенных пробелом. При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделенных пробелом и снова нажать Enter. Сумма вновь введенных чисел будет добавляться к уже подсчитанной сумме. Но если вместо числа вводится специал... |
38cb4ea6589b038526290390a3d45205f8021bb4 | muondu/eduinox-e-degree | /Section1/Chapter3/3.2.py | 526 | 3.828125 | 4 | #try:
# 3 / 0
#except Exception as e:
# print("Error: %s" % e)
#x = [1,2,3,4,5]
#y = "Cactus"
#try:
# if 3 in x and "u" in y:
# 3 / 0
# print("Yahoo")
#except ZeroDivisionError as e:
# print("Error: %s" % e)
#except ArithmeticError as e:
# print("Dance")
try:
3 / 1
# print("Yahoo")
e... |
5f90242924a0f7710f1b63bd5d43513b0b1343cf | Nimsi123/MathProCore | /src/mathprocore/Question/helpers/imgh.py | 6,858 | 3.65625 | 4 | """
Contains a number of helper functions for dealing with Image objects.
"""
import re, sympy
from .csympy.printing.latex import latex as clatex
from .. import image
from . import exprh
latex_params = {
"order": "none",
"inv_trig_style": "power"
}
def to_sympy(img):
"""Mutates the image such that self.e... |
932007159f1be668e0e285873555aa3ea95ef811 | seankaczanowski/Code-Breaker | /main.py | 3,483 | 3.625 | 4 | '''
Code Breaker 1.0
Developed by Sean Kaczanowski
May 2020
No copyright
Simple Code Guessing Game
- 5 Colour Code
- 8 Colours to Choose From
- Gameboard showing current turn and past turns
- Indicator for how many colours guessed are in the code but not necessarily in the correct order
'''
import random # For word ... |
b6aa06068380435c8254813087e9b0b0e6572461 | Subhash3/CodeChef | /others/compare_two_num.py | 313 | 4.09375 | 4 | #!/usr/bin/env python3
result = list()
for i in range(int(input())) :
numbers = input().split()
if int(numbers[0]) > int(numbers[1]) :
result.append(">")
elif int(numbers[0]) < int(numbers[1]) :
result.append("<")
else :
result.append("=")
for x in result :
print(x)
|
42166bf4aaf652f80d82cc6d723156fa99254771 | Subhash3/CodeChef | /others/n_primes.py | 379 | 3.75 | 4 | #!/usr/bin/env python3
import math
primes = list()
#pcount = 0
fcount = 0
num = 2
#N = 1000000
number = 10**6
#while pcount < N :
while num <= number :
for i in range(2, int(math.sqrt(num))) :
if num % i == 0 :
fcount += 1
break
if fcount == 0 :
primes.append(num)
... |
e141dbd66e1994dd7aa52017ca5ff587e5f7c8cb | Subhash3/CodeChef | /July_Lunch_Time/input.py | 122 | 3.84375 | 4 | #!/usr/bin/python3
import random
N = int(input())
print(1)
print(N)
for i in range(N) :
print(i+1, end=" ")
print()
|
b847a76473e10b929f9df8abedfef63107b06038 | Subhash3/CodeChef | /others/chef_and_wildcard_matching.py | 504 | 3.859375 | 4 | #!/usr/bin/python3
def compare_strings(first, second) :
for i in range(len(first)) :
matched = "No"
if first[i] == '?' or second[i] == '?' or first[i] == second[i] :
matched = "Yes"
else :
matched = "No"
break
return matched
try :
test_cases = in... |
ccabf2d44f90b7f08d731ca42549be109d1af51e | Subhash3/CodeChef | /others/number_tower.py | 141 | 4.0625 | 4 | #!/usr/bin/env python3
numbers = list()
for i in range(int(input())) :
numbers.append(int(input()))
for num in numbers :
print(num)
|
f8da99a0c14d1e046b293dcb8b590bfd39d44b7f | Subhash3/CodeChef | /OCT_LONG/chef_and_star_value_analysis.py | 1,246 | 3.71875 | 4 | #!/usr/bin/python3
try :
T = int(input())
except :
quit()
for testCase in range(T) :
N = int(input())
Arr = list()
num_and_divisible = dict()
even_numbers = list()
length = 0
max_star = None
max_value = None
no_of_even = 0
for n in input().split() :
star = 0
... |
b4bcf5b555dc3524054e1874efe9cada66cbad0d | Subhash3/CodeChef | /ATMOS/div1.py | 489 | 3.75 | 4 | #!/usr/bin/python3
from math import sqrt
try :
T = int(input())
except :
quit()
for testCase in range(T) :
N = int(input())
xor = 0
for divisor in range(2, int(sqrt(N))+1) :
if N % divisor == 0 :
# print(divisor, end=', ')
xor ^= divisor
divisor_2 = in... |
b1c3aa936391066534b7dabc58e97de5177ffe34 | Subhash3/CodeChef | /July_Long_Challenge/parity_again.py.bkup | 1,265 | 3.875 | 4 | #!/usr/bin/python3
def count_bits(num, bit) :
bit = str(bit)
binary = bin(num)[2:]
count = 0
for b in binary :
if b == bit :
count += 1
# print("No of " + str(bit) + "s in " + str(num) + " are: " + str(count))
return count
try :
T = int(input())
except :
quit()
f... |
f112756ee6510bf991a189a115fe25e5bd6c5b7a | Subhash3/CodeChef | /OCT_LONG/missing_number.py | 3,170 | 3.515625 | 4 | #!/usr/bin/python3
MAX_X = 1000000000000
def decimal_to_base(num, base) :
if num == 0 :
return '0'
base_string = ""
current_num = num
while current_num :
mod = current_num % base
current_num = current_num // base
if mod < 10 :
base_string = str(mod) + b... |
b2bfab527a62ad5cdf61e2eedba96b0e85df7056 | Subhash3/CodeChef | /others/chef_and_strings.py | 364 | 3.625 | 4 | #!/usr/bin/env python3
for i in range(int(input())) :
s1 = input()
s2 = input()
minimal = 0
maximal = 0
for l in range(len(s1)) :
if s1[l] == '?' or s2[l] == '?':
maximal += 1
continue
if s1[l] != s2[l] :
minimal += 1
maximal += 1
... |
a077a3a75987133d587df7c6c5a61066838b9c82 | Subhash3/CodeChef | /others/nice.py | 519 | 3.828125 | 4 | #!/usr/bin/env python3
def mod(n) :
if n > 0 :
return n
else :
return -n
for i in range(int(input())) :
ints = input().split()
a = int(ints[0])
b = int(ints[1])
n = int(ints[2])
if n % 2 == 0 :
if mod(a) > mod(b) :
print("1")
elif mod(a) < mod(b)... |
21a00e4bfc27407aae5723f84c9b2e9de7591857 | willreadscott/sockets | /receiver.py | 3,841 | 3.78125 | 4 | #!/usr/bin/env python3
"""
The receivers listens on a channel for packets and forms them into a file,
saving it in the specified location.
Usage:
./receiver.py p_in p_out c_in filename
p_in - the port that the receiver should listen on
p_out - the port that the receiver should send f... |
9b6eada29f71734486995cdd1d328d6c0465892c | timlyo/Year2_programming | /W2_8Queens.py | 4,538 | 4 | 4 | import random
class Week2:
def __init__(self):
self.size = 0
def makeBoard(self, size):
self.size = size
board = []
for i in range(size):
board.append([])
for j in range(size):
board[-1].append(False)
return board
def displayBoard(self, b):
divider = ("+---" * len(b)) + "+"
for row in b:... |
0b6dddb04db9fbc9b74d21bfb83992f36eae8d2d | nischal-sudo/Flask-repo | /Desktop/code/resources/user.py | 920 | 3.578125 | 4 | import sqlite3
from flask_restful import Resource,reqparse#Parser is a compiler that is used to break the data into smaller elements
from models.user import UserModel
class UserRegister(Resource):#new register(Sign upp)
parser = reqparse.RequestParser()
parser.add_argument("username",
type = str,
requi... |
348906ac85caebe2bbe49afa0034b389adee8b3f | MiguelYanes/AI_Labs | /practica3IA/Practica3/alphabeta (2018_05_06 19_48_42 UTC).py | 1,278 | 3.546875 | 4 |
# AlphaBeta Partial Search
infinity = 1.0e400
def terminal_test(state, depth):
return depth <= 0 or state.is_terminal
def max_value(state, player, max_depth, alpha, beta, eval_function):
"""
Completar con el codigo correspondiente a la funcion <max_value> de la
version del algoritmo min... |
da679d0f52076510c87670e8b3edcd79cdb86145 | MiguelYanes/AI_Labs | /practica3IA/Practica3/minimax (2018_05_06 19_48_42 UTC).py | 1,130 | 4 | 4 |
# Minimax Search
infinity = 1.0e400
def terminal_test(state, depth):
return depth <= 0 or state.is_terminal
def max_value(state, player, max_depth):
"""
Completar con el codigo correspondiente a la funcion <max_value> del
algoritmo minimax
"""
return 0
def min_value(state, ... |
583923231f4a5da0c8cf6e6928ac47aadc553623 | hmdhszd/create-and-edit-xlsx-file-with-python-practicing-example | /my program.py | 684 | 3.5625 | 4 | import openpyxl
workbook = openpyxl.load_workbook('example-XLSX-file.xlsx')
print(workbook.get_sheet_names())
sheet = workbook.get_sheet_by_name('Sheet1')
###########################
cell = sheet['B1']
print(cell.value)
print(sheet['B1'].value)
###########################
cell = sheet.cell(row = 2, column = 2... |
0255bf5031a423598d561a6ee9cb6a791af11b71 | gino2010/pythontech | /algorithm/custom_sort.py | 907 | 4 | 4 | #
# author gino
# created on 2018/10/8
# 假设一组数字, 463175892 对其进行解密排序后 615947283
# 解密规则规则,移走第一个数字到末尾,取第二个数字,往复,直到全部取出。取出的数字序列则为结果
# 加密规则,与其逻辑相反
def decrypt(text: str) -> str:
text_list = list(text)
temp_str = ''
while len(text_list) != 0:
text_list.append(text_list.pop(0))
temp_str += text_... |
22d0843e0bd2eb231713fb6f8fb5c714594b0ea8 | haidragon/Python | /Python基础编程/Python-12/加强练习/开枪/开枪-6-拿枪.py | 2,688 | 3.65625 | 4 | class Person(object):
def __init__(self,name):
super(Person,self).__init__()
self.name = name
self.gun = None#保存枪的引用
self.hp = 100
def __str__(self):
if self.gun:
return "%s的血量为%d,他有枪"%(self.name,self.hp)
else:
return "%s的血量为%d,他没有枪"%(self.... |
25b8bf15aa3fecdf8741ea9a7f437c50860c93c5 | haidragon/Python | /Python核心编程/Python-04-系统编程-1/02-多线程/04-多线程使用全局变量.py | 495 | 3.71875 | 4 | from threading import Thread
import time
g_num = 100
def work1():
global g_num
for i in range(3):
g_num += 1
print("---in work1,g_num is %d---"%g_num)
def work2():
global g_num
print("---in work2,g_num is %d---"%g_num)
print("---进程创建之前,g_num is %d---"%g_num)
t1 = Thread(target=work1)
t1... |
5d349c3af7051b75b96807b41102f7e54b083573 | haidragon/Python | /Python基础编程/Python-08/文件/文件读写.py | 278 | 3.515625 | 4 | #1、打开文件
f = open("D:/Personal/Desktop/test.txt","w")
#2、写入数据
f.write("hello world")
#3、关闭文件
f.close()
f = open('D:/Personal/Desktop/test.txt', 'r')
content = f.read(5)
print(content)
print("-"*30)
content = f.read()
print(content)
f.close() |
dcb72ba1322aa085b0851b78b2d3e29f17b2ff99 | haidragon/Python | /Python基础编程/Python-04/items/ItemDemo.py | 813 | 4.28125 | 4 | info = {"name": "laowang", "age": 18}
# 遍历key
for temp in info.keys():
print(temp)
# 遍历value
for temp in info.values():
print(temp)
# 遍历items
#Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。
info_Item = info.items()
print(info_Item)
#打印字典内的数据
#方法一:直接打印元组
for temp in info.items():
print(temp)
'''结果:
(... |
6f6f3332c920fda4a3fc56b5184362f5e8bf13f9 | haidragon/Python | /Python基础编程/Python-03/WhileDemo2.py | 192 | 3.78125 | 4 | i = 2
while i <= 3:
j = 0
while j <= 3:
j += 1
if j == 2:
break
#continue
print("======")
print("i=%dj=%d" % (i, j))
i += 1
|
9b4e92729e98d64c54dc2e77720ad805deecde1b | haidragon/Python | /Python基础编程/Python-09/对象/创建对象.py | 778 | 4.15625 | 4 | #创建一个类
class cat:
#属性
#方法
def __init__(self,a,b):
self.name = a
self.age = b
def __str__(self):
return "--str--"
def eat(self):
print("猫在吃饭")
def drink(self):
print("猫在喝水")
#若需要创建多个对象都调用这个方法,则形参需要都为self
def introduce(self):
print("%s的年龄为%d"... |
fb24306d8a22f9bf18d3099d20197e6ce266a8dd | haidragon/Python | /Python基础编程/Python-11/异常/异常处理.py | 468 | 3.5 | 4 | try:
print("可能产生异常的代码")
except (KeyError,ErrorName-2,ErrorName-3....,ErrorName-n):
print("捕获异常后的处理")
except Exception:
print("如果使用了Exception,name意味着只要上面的except没有捕获到异常,这个except一定会捕获到")
else:
print("没有异常才执行的功能,但凡有一个异常,这条代码永远不会被执行")
finally:
print("无论什么情况下总是会执行的代码")
|
4291b6684d405acf8adf2b9d1d4e4521a1a6c9fc | haidragon/Python | /Python核心编程/Python-02/02-装饰器/09-使用装饰器对有返回值的函数进行装饰.py | 726 | 4 | 4 | #装饰有返回值的函数
def func(functionName):
print("--func--1--")
def func_in(*args,**kwargs):
print("--func_in--1--")
ret = functionName(*args,**kwargs)
print("--func_in--2--")
#装饰有返回值的函数,需要接收返回值之后再将返回值返回即可
return ret
print("--func--2--")
return func_in
@func
... |
0e4f852db6db82a00c24fed1a05e33530139401a | gjwang/testcpp | /find_perfect_hash.py | 1,149 | 3.625 | 4 | data = [ 10, 100, 32, 45, 58, 126, 3, 29, 200, 400, 0 ]
def shift_right(value, shift_value):
"""Shift right that allows for negative values, which shift left
(Python shift operator doesn't allow negative shift values)"""
if shift_value == None:
return 0
if shift_value < 0:
return value ... |
10c46acb72ab0e3edca820607cb35937dfd43995 | rishabhusc/Python-leetcode | /deletenodehreatyerthenk.py | 892 | 3.921875 | 4 | class Node:
def __init__(self,value):
self.value=value
self.next=None
class LinkedList:
def __init__(self):
self.root=None
def append(self,value):
if self.root is None:
self.root=Node(value)
return
cur=self.root
while cur.next:
... |
d9587a607ac4ca80f766c5353e0bae6c94704d9e | rishabhusc/Python-leetcode | /productexecptInd.py | 197 | 3.734375 | 4 | num=[1,2,3,4,5]
output=[1]*len(num)
prod=1
for i in range(len(num)):
output[i]*=prod
prod*=num[i]
prod=1
for i in range(len(num)-1,-1,-1):
output[i]*=prod
prod*=num[i]
print(output) |
7a9e0673900f0d1b170f9e2b46d364c213444fb7 | rishabhusc/Python-leetcode | /longestNonRepetingSubString.py | 631 | 3.5625 | 4 | s="abcddabc"
def funct(s):
ml=0
def helper(s,start):
d=set()
for i in range(start,len(s)):
if s[i] not in d:
d.add(s[i])
else:
return i-start
return len(s)-start
for i in range(len(s)):
ml=max(ml,helper(s,i))
re... |
44db4d9817bfb89f549344d1cea3604aa0bfd0e9 | rishabhusc/Python-leetcode | /picturePlacement.py | 114 | 3.53125 | 4 | arr=[0,1,2,3,4]
placement=[0,1,2,1,2]
ls=[]
for i in range(len(arr)):
ls.insert(placement[i],arr[i])
print(ls) |
2f38aecc516f760db7184abbc5cafec2f5c2bae4 | kirbocannon/aws_scripts | /archive/scrap2.py | 4,328 | 3.90625 | 4 | '''
list = ['caw', 'baw', 'taw',' naw']
print(list[1:])
'''
# my_dict = {"caw": 1, "baw": 2, "law": 3}
#
# new_dict = {k: v * 2 for k,v in my_dict.items()}
#
# print(new_dict)
#
# for k,v in my_dict.items():
# print(k, v)
#
# import itertools
#
# list_1 = ["this", "is", "a", "list"]
# list_2 = ["cat", "dog", "... |
492558471e0c076cee00aae3dfa3e3a75c4df57c | cwallace3/They_Fight_Crime_NLP | /10_Most_Common.py | 1,048 | 3.71875 | 4 | from collections import Counter
from string import punctuation
import nltk
from nltk.corpus import stopwords
def content_text(text):
#Remove common stopwords including "he's" and "she's"
stopwords = set(nltk.corpus.stopwords.words('english'))
stopwords.update(("He's", "She's"))
with... |
46f342b4ee2ee525541c5aeb403e7236e6b2f674 | thalals/Algorithm_Study | /Taewoo/problem_solving/2021.05/2021.05.13/6416.py | 1,251 | 3.71875 | 4 | import sys
input = sys.stdin.readline
def is_tree():
is_root = False
for i in range(1, len(tree)):
if is_root and node_check[i] and len(tree[i]) == 0:
return False
if not is_root and node_check[i] and len(tree[i]) == 0:
is_root = True
if node_check[i] and len(tr... |
fbcfb80a8e5f05033dfa51ed591001334dad16ee | thalals/Algorithm_Study | /Geonil/Algorithms/String/BOJ16171.py | 382 | 3.5 | 4 | # 나는 친구가 적다 (Small) (BOJ 16171)
import sys
In = sys.stdin.readline
def main():
string = In().rstrip()
keyword = In().rstrip()
new_string: str = ''
for c in string:
if c.isdigit():
continue
new_string += c
if keyword in new_string:
print(1)
else:
p... |
7a76e5f031d792ef1e1b6e9dccec3c62ecffdf93 | thalals/Algorithm_Study | /Geonil/problem_solving/week4/BOJ2231.py | 393 | 3.5 | 4 | import sys
In = sys.stdin.readline
def creater(num):
answer = 0
length = len(str(num))
start_num = max(0, num - 9*length)
for i in range(start_num, num):
n = i
for radix in str(i):
n += int(radix)
if n == num:
answer = i
break
return a... |
cc76ad142defb01db64e3f78e749366d42edae28 | thalals/Algorithm_Study | /SaeHyeon/트리2/4256.py | 1,027 | 3.71875 | 4 | # 이진 트리 순회
# 전위 순회와 중위 순회를 통해서 후위 순회를 구하는 문제
import sys
input=sys.stdin.readline
def Postorder(preorder,inorder):
if len(preorder) == 0:
return
elif len(preorder) == 1:
print(preorder[0],end=' ')
return
elif len(preorder) == 2:
print(preorder[1],preorder[0], end= ' ')
... |
28577a9f4431e1f958498037a6de1ac3ba8f0050 | thalals/Algorithm_Study | /Geonil/Algorithms/Tree/BOJ3005.py | 1,319 | 3.703125 | 4 | import sys
In = sys.stdin.readline
class Node:
def __init__(self, key):
self.key = key
self.child = {}
class Trie:
def __init__(self):
self.root = Node(None)
def insert(self, word):
cur = self.root
for c in word:
if c not in cur.child:
... |
992bafa01ffe7954203eab9b62b764d59362e0fd | thalals/Algorithm_Study | /SaeHyeon/2021년 상반기/week7/1920.py | 530 | 3.625 | 4 | import sys
input=sys.stdin.readline
n1=int(input())
li1=sorted(map(int,input().split())) # 찾아야 될 리스트
n2=int(input())
li2=map(int,input().split()) # 찾을 값
def binarySearch(j,li1,left,right):
if left > right:
return 0
mid = (left+right)//2
if j == li1[mid]:
return 1
elif j > li1[mid]:
... |
fba9eef5fe2c2aac66194ec0392db6f38d1e8df9 | thalals/Algorithm_Study | /SaeHyeon/2021년 상반기/week3/1427.py | 123 | 3.640625 | 4 | n=input()
li=[]
for x in n:
li.append(int(x))
li.sort()
li.reverse()
for i in range(len(li)):
print(li[i],end='') |
b0fe7d3992e2fc0f2f7b2731f8ccf3909d849dec | thalals/Algorithm_Study | /Geonil/problem_solving/week14/BOJ11279.py | 543 | 3.515625 | 4 | # 최대 힙
import sys
import heapq
In = sys.stdin.readline
class Heap():
def __init__(self):
self.heap = []
def push(self, num):
heapq.heappush(self.heap, (-num, num))
def pop(self):
if self.heap:
return heapq.heappop(self.heap)[1]
else:
return 0
def... |
e2f44d2a2bd378a31dad1fbf2cc24ef1e5b70b3d | thalals/Algorithm_Study | /Seunghwan/week4/BOJ7568.py | 923 | 3.59375 | 4 | # 입력
# 첫 줄에는 전체 사람의 수 N이 주어진다.
# 그리고 이어지는 N개의 줄에는 각 사람의 몸무게와 키를 나타내는 양의 정수 x와 y가 하나의 공백을 두고 각각 나타난다.
# 출력
# 여러분은 입력에 나열된 사람의 덩치 등수를 구해서 그 순서대로 첫 줄에 출력해야 한다.
# 단, 각 덩치 등수는 공백문자로 분리되어야 한다.
n = int(input()) # n 입력
data_list = [] # 키와 몸무게
for i in range(n): # 입력한 n만큼
x,y = map(int, input().split()) # x,... |
f1f6cf64bde4602c167dfe214ccf0143609ff74e | itzadi22/Basic-python | /regex_metacharacters.py | 267 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 30 22:51:54 2021
\d Digit
\D Non Digit
@author: ASUS
"""
import re
string="#cricket,I love you cricket 10 times"
s1=re.findall("\d+", string)
print(s1)
s2=re.findall("\D+", string)
print(s2)
|
89f16c51799d07983adbe5d78a5cbd92839c3716 | itzadi22/Basic-python | /regex_split.py | 194 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 30 22:02:08 2021
@author: ASUS
"""
import re
string="#movies,I love watching horror,movies"
print(re.split(',', string))
|
fd98c217fe18dc168423ab6311fa1d21d23ad2f0 | itzadi22/Basic-python | /square_of_no.py | 159 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 17 10:18:19 2021
@author: ASUS
square of numbers
"""
a=int(input("enter any number : "))
print(a*a) |
f26aa3f52b6ec268af850fa9c4723829fc3d827f | itzadi22/Basic-python | /string_formatting.py | 229 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 17 18:44:50 2021
@author: ASUS
string formatting
"""
a="name"
b="is"
c="my"
d=c + " " + a + " " + b
print(d)
e="adarsh"
f="my name is {}".format(e)
print(f)
|
1027ce4eccdafefe9f87c849efbd4aa229ff88b5 | itzadi22/Basic-python | /any_power_to_no.py | 187 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 17 10:50:31 2021
@author: ASUS
any power to number
"""
import math
r=int(input("Enter any number"))
a=math.pow(r,10)
print(a)
|
e65b012f7d51a6c7859b0338de5712b107601872 | Sagar2366/SPOJ-Solutions-in-Python | /PALIN.py | 1,073 | 3.8125 | 4 | #!/usr/bin/python
# created by Christian Blades (christian.blades@gmail.com) - Sat Oct 02, 2010
# Solution to http://www.spoj.pl/problems/PALIN/
def getInput():
a = raw_input('number: ')
return int(a)
def isPalindrome(num):
numString = str(num)
start = 0
end = len(numString) - 1
while(start <... |
266615fe9516995bbeffdd10fc206dd847500ae3 | modobit/Python | /condition.py | 287 | 3.828125 | 4 |
temprature = 21
if temprature > 30:
print(" Its hot today")
elif temprature > 20:
print(" Its nice today")
else:
print(" Its Cold")
print("Done")
# Inline messaging with conditional terniatary
age = 22
message = "Eligible" if age >=18 else "Not Eligible"
print(message) |
5c9b96a421e3a49b17b6e64019a10971a1928553 | nayeem56/python-learn | /sent/type conversion.py | 68 | 3.609375 | 4 | dollars=input('Dollars:$')
rupees=int(dollars)*'RS'75
print(rupees)
|
6645a21b2d81032e3d1267d1678862d0d2641a2d | nivetha-ashokkumar/python-basics | /fibonacci.py | 270 | 4.09375 | 4 | number = int(input("Enter positive integer:"))
number1 = 0
number2 = 1
number3 = 2
print(number1)
print(number2)
while number3 < number:
number4 = number1 + number2
print(number4)
number1 = number2
number2 = number4
number3 = number3 + 1
|
55413d521ceee10b6ae22acc3fae9e87e39f0673 | nivetha-ashokkumar/python-basics | /dict_function.py | 531 | 3.75 | 4 | details = {"name" : "nivetha", "age" : 21, "dept" : "CSE"}
print(details)
details = {"name" : "nivetha", "age" : 21, "dept" : "CSE"}
print(len(details))
details = {"name" : "nivetha", "age" : 21, "dept" : "CSE"}
print(details.keys())
details = {"name" : "nivetha", "age" : 21, "dept" : "CSE"}
print(details.values())
... |
58c7422b78870cfe0971e50b37d34320ee748b5b | nivetha-ashokkumar/python-basics | /bubblesort.py | 264 | 4.03125 | 4 | list1 = [20, 10, 25, 15, 30]
print("unsorted list:", list1)
for j in range(len(list1) - 1):
for i in range(len(list1) - 1):
if list1[i] > list1[i + 1]:
list1[i], list1[i + 1] = list1[i + 1],list1[i]
print("sortd list:", list1) |
1a6b2d6da21f7e87c107dd45b2ffeec143c2aef6 | nivetha-ashokkumar/python-basics | /factorial.py | 459 | 4.125 | 4 | def factorial(number1, number2):
temp = number1
number1 = number2
number2 = temp
return number1, number2
number1 = int(input("enter first value:"))
number2 = int(input("enter second vakue:"))
result = factorial(nnumber1, number2)
print("factorial is:", result)
def check(result):
if(result != int... |
eff065312dc4b5f0e125bc5ad9d507c465429312 | luhralive/python | /NeilLi1992/0000/main.py | 813 | 3.71875 | 4 | from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
file_name = raw_input("Please input the image name, including file appendix: ")
try:
img = Image.open("test.jpg")
s = raw_input("Please input the number to display: ")
try:
num = int(s)
img_width = img.size[0]
... |
50c5f524ba1f7305f7582bbddfaf0fb1aa521ae6 | luhralive/python | /Lyndon1994/0006.py | 1,217 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
**第 0006 题:**
你有一个目录,放了你一个月的日记,都是 txt,
为了避免分词的问题,假设内容都是英文,请统计出你认为每篇日记最重要的词。
"""
import os
import re
def findWord(DirPath):
if not os.path.isdir(DirPath):
return
fileList = os.listdir(DirPath)
reObj = re.compile('\b?(\w+)\b?')
for file in fileList:
filePath =... |
c443508ec82b797e3f700aed0ff548fdecf4271a | luhralive/python | /sarikasama/0006/0006.py | 852 | 3.828125 | 4 | #!/usr/bin/env python3
#get the most important word in the text
import os, re
from pprint import pprint
def most_important_word(f):
#get the count of words in the text
res = {}
content = f.read()
tmp = re.split(r"[^a-zA-Z]",content)
for w in tmp:
if not w:
continue
w = ... |
892f861fecd3bcc59244ebd317c6f16fa48642a2 | luhralive/python | /will/0001/app_store.py | 3,117 | 3.8125 | 4 | # 第 0001 题: 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
'''
想法思路:
1. 字符串方式
2. 时间戳方式
3. UUID全局标识符,使用uuid1或者uuid5算法
4. 加密算法
'''
import random, string, time, math, uuid
chars = string.ascii_letters + string.digits
def gen1():
'''
根据26个大小写字母和数字随机选择10个
涉及... |
8a1e5c9a01cdf662d892e06dd1344f44be378593 | luhralive/python | /AK-wang/0001/key_gen_deco.py | 837 | 4.15625 | 4 | #!/usr/bin/env python
# -*-coding:utf-8-*-
# 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
# 使用 Python 如何生成 200 个激活码(或者优惠券)?
import string
import random
KEY_LEN = 20
KEY_ALL = 200
def base_str():
return (string.letters+string.digits)
def key_gen():
keylist = [random.choice(base_str()) for ... |
36d4bb1df1b94b7d8abcac43da7c482453cf0f4c | luhralive/python | /sarikasama/0011/0011.py | 507 | 4.1875 | 4 | #!/usr/bin/env python3
#filter sensitive words in user's input
def filter_sensitive_words(input_word):
s_words = []
with open('filtered_words','r') as f:
line = f.readline()
while line != '':
s_words.append(line.strip())
line = f.readline()
if input_word in s_words:
... |
94b4dad1e310adb29b8ef2199eae53a2b7b54164 | luhralive/python | /LuHR_showcode/x0004.py | 854 | 3.671875 | 4 | #coding:utf-8
#任一个英文的纯文本文件,统计其中的单词出现的个数。
import re
def readFile(file = 'input.txt'):
try:
with open(file,'r',encoding='UTF-8') as f:
txts = f.read()
except BaseException as e:
print(e)
return txts
def getEwordsCount(txts):
words = re.compile('([a-zA-Z]+)')
... |
7f77b4664e7707f2fc6dec3ba66e7e5db64c3b9f | luhralive/python | /Drake-Z/0011/0011.py | 692 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。'
__author__ = 'Drake-Z'
import os
import re
def filter_word(a):
f = open('filtered_words.txt', 'r', encoding = 'utf-8').read()
if a == '':
print('Human Rights ... |
7212075838786e34bae819ce3d7294f9fc1903ef | luhralive/python | /endersodium/0001/0001.py | 870 | 3.609375 | 4 | # coding:utf-8
# Python Requirement:3
# Made by EnderSodium ender@enderself.co
# 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
import random
# Generate alphabetical stuff
def gene_let(code):
randomnum = random.randint(65,90)
temp = chr(randomnum)
return code + temp
# ... |
aa85a1a0bc0d41623d45fd2e1cd99f370153c6a4 | luhralive/python | /pylyria/0004/0004.py | 918 | 3.734375 | 4 | #! /usr/bin/env python
#第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
# Copyright By PyLyria
# CreateTime: 2016-03-01 23:04:58
import re
from string import punctuation
from operator import itemgetter
def remove_punctuation(text):
text = re.sub(r'[{}]+'.format(punctuation), '', text)... |
2863bc17227450b7cec06bb9b5a1787b5ca5db5e | luhralive/python | /renzongxian/0002/0002.py | 1,334 | 3.515625 | 4 | # -*- coding:utf8 -*-
# Source:https://github.com/Show-Me-the-Code/show-me-the-code
# Author:renzongxian
# Date:2014-12-06
# Python 2.7, MySQL-python does not currently support Python 3
"""
第 0002 题:将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型数据库中。
"""
import uuid
import MySQLdb
def generate_key():
key_list = []
... |
74fccaa5a23a7774a114525a834c26e155df6b54 | luhralive/python | /robot527/0004/statistic_words.py | 1,200 | 3.796875 | 4 | #! usr/bin/python3
"""
第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
"""
print('Please input a text file name which in the current working directory.')
print('Usage - example.txt')
file_name = input("@> ")
def deal_punctuation(the_string):
from string import punctuation as punc
punc_list = list(punc)
pun... |
edd3c24bbdcf1af0d963ba26d958a72236a22fe2 | luhralive/python | /AK-wang/A0000/sushu.py | 593 | 3.546875 | 4 | #!/bin/env python
#-*-coding:utf-8-*-
#寻找n以内的素数,看执行时间,例子100000内的素数
import sys
def prime(n):
flag = [1]*(n+2)
flag[1] = 0 # 1 is not prime
flag[n+1] = 1
p=2
while(p<=n):
print p
for i in xrange(2*p,n+1,p):
flag[i] = 0
while 1:
p += 1
if(... |
2c8697bc9d189648ee827974fa2051fc02ada2c5 | luhralive/python | /AK-wang/0012/f_replace.py | 985 | 4.28125 | 4 | #!/usr/bin/env python
# -*-coding:utf-8-*-
# 第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换,
# 例如当用户输入「北京是个好城市」,则变成「**是个好城市」。
def f_words(f_file):
filtered_list = []
with open(f_file, 'r') as f:
for line in f:
filtered_list.append(line.strip())
return filter... |
9f9b01ccd6c9eb277f99f33ad6cb5a7bc3e3111b | luhralive/python | /Matafight/0007/testDir/importantdiary.py | 1,023 | 3.5625 | 4 | #_*_ encoding: utf-8 _*_
import re
class countWord:
def __init__(self):
self.dic={};
self.word="";
def count(self,filename):
self.dic={};
fopen=file(filename,'r');
for lines in fopen.readlines():
words=re.findall(r"\w+",lines);
for items in word... |
a31fcd621eacd25158fe063530c23c9caa0e8955 | luhralive/python | /renzongxian/0012/0012.py | 1,016 | 4.125 | 4 | # Source:https://github.com/Show-Me-the-Code/show-me-the-code
# Author:renzongxian
# Date:2014-12-22
# Python 3.4
"""
第 0012 题: 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换,
例如当用户输入「北京是个好城市」,则变成「**是个好城市」。
"""
def filter_words(words):
# Read filtered words from file named 'filtered_words.txt'... |
04c21f2a42de064d9cf1d6bddc0394d719a7cbea | luhralive/python | /problem 0004/solution for problem 0004.py | 244 | 4 | 4 | def count():
name = raw_input("Enter file:")
if len(name) < 1 : name = "test.txt"
handle = open(name)
count_words=list()
for line in handle:
count_words+=line.split()
return len(count_words)
print count() |
fa48c5a35d00ad72f000ee150fe8208e7aa6d7ae | luhralive/python | /jhgdike/0004/solution.py | 292 | 3.9375 | 4 | # coding: utf-8
import re
from collections import Counter
def word_count(txt):
word_pattern = r'[a-zA-Z-]+'
words = re.findall(word_pattern, txt)
return Counter(words).items()
if __name__ == '__main__':
txt = open('test.txt', 'r').read().lower()
print word_count(txt)
|
4e2a0fc8684813b56dc50d555307ff3af7b770c7 | luhralive/python | /DIYgod/0004/count_word.py | 244 | 3.640625 | 4 | # -*- coding: utf-8 -*-
import re
def count(filepath):
f = open(filepath, 'rb')
s = f.read()
words = re.findall(r'[a-zA-Z0-9]+', s)
return len(words)
if __name__ == '__main__':
num = count('count_test.txt')
print num
|
66e8c164dc795360af7f697ae93311c6971a4e1d | luhralive/python | /renzongxian/0004/0004.py | 829 | 3.78125 | 4 | # Source:https://github.com/Show-Me-the-Code/show-me-the-code
# Author:renzongxian
# Date:2014-12-07
# Python 3.4
"""
第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
"""
import sys
def word_count(file_path):
file_object = open(file_path, 'r')
word_num = 0
for line in file_object:
line_list = line.split()
... |
4afa12e7a27291560d036119d0a885c5176f64f2 | luhralive/python | /asahiSky/0011/test.py | 287 | 3.8125 | 4 | import os
fileName = 'filtered_words.txt'
nameList = open(fileName,'rt')
nameList = nameList.readlines()
print(nameList)
while True:
s = input('What do you want to say:')
if (s+'\n') in nameList:
print('Freedom')
continue
if (s=='exit'):
break
else:
print('Human Rights')
|
4adcefec39176e2bbda3f1e751ccace491dbf441 | luhralive/python | /lwh/2/active_code.py | 666 | 3.875 | 4 | """
做为 Apple Store App 独立开发者,你要搞限时促销,
为你的应用生成激活码(或者优惠券),
使用 Python 如何生成 200 个激活码(或者优惠券)?
激活码格式:
19个字符组成,分成4组,中间用"-"连接起来
必须同时包含大小写字母数字
"""
import random
import string
def generate_active_code():
active_code = []
ascii_ = string.ascii_letters + string.digits
active_code = ["".join([random.choice(ascii_) f... |
1b5004f226e8d8a843a82f6edd21e52ba095f8c9 | luhralive/python | /keysona/0004/0004.py | 557 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: key
# @Date: 2015-11-17 14:15:01
# @Last Modified by: key
# @Last Modified time: 2015-11-17 17:26:46
#--------------------------------
#第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
#--------------------------------
from collections import Counter
def words():
c... |
33e13977e564ba7901ca4bf859eb83ce9a5a5f6c | luhralive/python | /Mr.Lin/0006/0006.py | 794 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: 30987
# @Date: 2015-01-13 11:11:49
# @Last Modified by: 30987
# @Last Modified time: 2015-01-13 17:10:27
import re
def hot_words(file_path):
file = open(file_path,'r')
file_content = file.read()
p = re.compile(r'[\W\d]*')
word_list = p.split(file_... |
2b900915b9b4dc855b14095e86b60b2be1fb40bf | luhralive/python | /yefan/004/004.py | 613 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
python实现任一个英文的纯文本文件,统计其中的单词出现的个数、行数、字符数
"""
file_name = "movie.txt"
line_counts = 0
word_counts = 0
character_counts = 0
with open('C:\Python27\oneday_one\movie.txt', 'r') as f:
for line in f:
words = line.split()
... |
e1c776c9e9b165faed2b3609965c2b6ec758e07f | luhralive/python | /yefan/007/007.py | 1,194 | 3.578125 | 4 | # -*- coding: utf-8 -*-
#list all the files in your path(完整路径名path\**.py)
import os
def get_files(path):
files=os.listdir(path)
files_path=[]
for fi in files:
fi_path= path+'\\' + fi
if os.path.isfile(fi_path):
if fi.split('.')[-1]=='py':
files_path.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.