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
12b70d04af612d519bbfa698f6e5b7013505fff0
chauhanjatin10/thepythonway
/reverse_shell/server.py
1,012
3.59375
4
import socket import sys def socket_create(): try: global host global port global s host = '' port = 9998 s =socket.socket() except socket.error as message: print("Socket createion error " + str(message)) def socket_bind(): try: print("Binding to port:" + str(port)) s.bind((host,port)) s.listen...
73a0951c2bc246e75cfe8d77451b5f8b6295f0e7
S213B/crypto
/my_rand.py
689
3.578125
4
import random import string # [start, end) def my_rand(end, start = 0): num = int(random.random() * (end - start)) return num + start def my_rand_str(len): r = '' for i in range(len): while True: c = chr(my_rand(128)) if c in string.printable: r += c ...
500535a2d9b0ae58f23164c66e88fc944fd226c1
ZoesZhou/pythoncode
/2018-4-30/内建结构2.py
1,692
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/5/7 下午 08:42 # @Author : Zoe # @Site : # @File : 内建结构2.py # @Software: PyCharm # def a(n): # n[2] = 300 # print(n) # return # # # def b(n): # n += 100 # print(n) # return # # # an = [1, 2, 3, 4, 5, 6] # bn = 9 # print(an) ...
321288351ef597f7002e0ea0506cab99c2ed4e68
annaduraiviki/python_api
/py/Test_files/re_example.py
627
3.90625
4
import re #name =raw_input("enter input") name=" dfg jsdgf" get_name = name.replace(" ","") if "," in get_name: name_split= get_name.split(',') if len(name_split[0]) == 1: print str(name_split[0]+name_split[1][0]+"*").upper() elif len(name_split[0]) == 2: print str(name_split[0][0:2]+name_...
d265ab770037d33b66f244c8aa2a45e10c528010
annaduraiviki/python_api
/py/Test_files/testAppendPop.py
669
3.96875
4
elements=[22,34,56,77,11,1,6,2,34,123,56,345,23,657,854,45,111] odd=[] even=[] print elements while len(elements)>0: element=elements.pop() if (element %2==0): even.append(element) print even else: odd.append(element) print odd print "count",elements.cou...
d3f3237c98866e99aca923e493b41ed7f6b90e74
argus100-bit/tome
/argus eatery billing.py
18,295
3.734375
4
from tkinter import * import random class Bill_App: def __init__(self, root): self.root = root self.root.geometry("1300x700+0+0") self.root.maxsize(width=1280, height=700) self.root.minsize(width=1280, height=700) self.root.title("Billing Software") # =...
359fdacaa32f651f7bdd0130f6c2fa9e5d0cce7f
nonari/simpleDecipher
/simpledecipher/patterns.py
1,266
3.59375
4
import importlib from typing import Dict, List # Class for handling word patterns class Patterns: def __init__(self, dict_name: str): dict_dir = 'lib.' + dict_name self._patterns = importlib.import_module(dict_dir).allPatterns # Returns a list of matching words for a given word def matc...
138a9a4e93ce11823fbb29543087fd5a16d9064b
barsuk2/data_analytics
/matplot_.py
364
3.953125
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0,10,50) y = x**2 print(x) plt.title('Линейная зависимость x = y') # заголовок plt.xlabel('x') # ось абсцисс plt.ylabel('y') # ось ординат plt.legend # ось ординат plt.grid() # установить сетку plt.plot(x,y,'o--') plt.show()
c8620a27ce3d5de53744aa220cf21834cf701c3b
helbertsandoval/calculadoras-en-python
/calculadora 9.py
460
3.640625
4
# Calcular la aceleracion # Declaracion de variables aceleracion,velocidad_final,velocidaad_inicial,tiempo=0.0,0.0,0.0,0.0 # Asignacion de valores velocidad_final= 30 velocidaad_inicial=10 tiempo=2 # Calculos aceleracion=(velocidad_final-velocidaad_inicial/tiempo) # Mostrar calculos print ("aceleracio...
a078dd3cb0778edae55d61ff1df38a94cd402575
aerain/pysololearn
/Hello.py
310
3.84375
4
print('This is My First program') print('Hi!') 2 + 2 print('2 + 2') print(2 + 2) print(2 * (3 + 4)) print (20 // 6) print (1.25 % 0.5) print (20 % 6) print("String Hello World!") str = """ \\n 회피를 위해서 사용합니다. 큰따옴표 3개를 이어붙인뒤 사용할 수 있습니다.""" print(str)
e8f698566070fd9155e8370af6b35140dc6069c1
gui42/Alura
/Python-Basic/strings/regex.py
410
3.5625
4
import re email = [] email.append("Meu numero é 99582144") email.append("fale comigo em 9940-5070") email.append("9951-2813 é meu numero") email.append("99940-5070 é meu novo celular") email.append("1234-0000 , 12345-0123, e 0000-0000") lista = [] padrao = "[0-9]{4,5}[-]*[0-9]{4}" for x in range(0,len(email)): lis...
3b0cf9d684b3b6c02b9fad9165f2df2904cdf20c
thomaswhyyou/python_examples
/indentation_behavior.py
298
4.53125
5
# Example 1. numbers = [1, 2, 3] letters = ["a", "b", "c"] print("\nExample 1:") for n in numbers: print(n) for l in letters: print(l) # Example 2. numbers = [1, 2, 3] letters = ["a", "b", "c"] print("\nExample 2:") for n in numbers: print(n) for l in letters: print(l)
06847f901d5bd6cc6d680604acc9368512581aec
BBTK-2020-2021-Dersleri/Python
/Ders3-27.11.2020/Sorular/Example3.py
341
3.8125
4
num=int(input("Enter number: ")) digit=0 temp=num while(temp>0): basamakSayisi=temp%10 digit=digit+1 temp=temp//10 lastDigit = num % 10 firstDigit = (num // pow(10, digit-1)) swap= lastDigit swap = swap *pow(10,digit-1) swap =swap + num % (pow(10, digit-1)) swap =swap- lastDigit swap = swap+f...
112f8e1b9d70c997dd099d79d7307eee58a040e3
BBTK-2020-2021-Dersleri/Python
/Ders2-13.11.2020/Ödev_çözümleri/Example1-find_greatest_number/Example1.py
453
4
4
a=int(input("Enter a number: ")) b=int(input("Enter a number: ")) c=int(input("Enter a number: ")) if(a>b): if(a>c): max=a print("First one is the greatest. Number is:",max) else: max=c print("Third one is the greatest. Number is:",max) else: if(b>c): max=b pr...
bee1cc7b8d6c5f3b36dbbb7c54575814215ab408
BBTK-2020-2021-Dersleri/Python
/Ders5-11.12.2020/Example6-uniqueElementsinList.py
196
3.859375
4
list1=[1,1,2,2,3,1,4,5,6] unique=[] def uniqueNumber(liste): for i in liste: if i not in unique: unique.append(i) return unique print(uniqueNumber(list1))
6e61b1bcf9ae6bb4fd0817f8e68fa62ffcbdb22d
BBTK-2020-2021-Dersleri/Python
/Ders5-11.12.2020/Example4-isLeapYear.py
428
4.0625
4
year = int(input("Enter a year: ")) def isLeapYear(year): if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: return True else: return False else: return True else: return False if(isLeapYe...
bb2b0bfb99940ca2f24a396243e1c731dc048bd2
isharajan/simple-programming-problems
/nestedlist.py
201
3.953125
4
l = [] for i in range(3): l1 = [] name = raw_input("enter the name:") score = float(raw_input("enter the score:")) l1.append(name) l1.append(score) l.append(l1) print(l)
81c99421ee956db7ea5d0a805d180f1ed55f480a
isharajan/simple-programming-problems
/listmiddle.py
100
3.5
4
def middle(a): l =len(a) return a[1:l-1] a=[20,30,50,60,90,100] res = middle(a) print(res)
ab9ee11d880d62937e294a2f85fe535d1426e0d9
isharajan/simple-programming-problems
/str_methods.py
126
3.734375
4
w1 = "AppLe" w2 = "oRaNge" word = w1+w2 print(word) word1 = word.upper() print(word1) word2 = word.lower() print(word2)
b8f69da4b33584bfc0648f9b1df2d8a2800864b4
RutaleIvanPaul/testgitandela
/two.py
408
3.890625
4
''' print("testing raw input") #raw_input("\nPress Enter to exit") print "jknfklsdfsdfsd"+\ "dksjfnjklanfjnasd" ''' def takeAge(): try: YOB=int(raw_input("Enter Year Of Birth:\n")) print "Hi",name,",you're",2018-YOB,"yrs old." raw_input("\nPress Enter to exit") except: print "Wro...
33d6150069217733d70a18f96d0841da897a0891
RutaleIvanPaul/testgitandela
/oop1.py
1,185
3.96875
4
class One(object): def __init__(self,name,age=0): self.__name = name self.__age = age def setName(self,name): self.__name = name def setAge(self,age): self.__age = age def getName(self): return self.__name def getAge(self): return self.__age ...
3ff4d1c91366a7eaca119e201e7a581a6b6ee0c0
tokenHalfie/ICTPRG-Python
/1n.py
157
3.671875
4
def number(z): y=0 for x in range(z+1): y+=x return y i = input("Please enter a number: ") i=int(i) print (number(i)) print (number(55))
67eb00a0bd41612883caed3e8dccbb7602517bd6
tokenHalfie/ICTPRG-Python
/sum.py
96
3.8125
4
j = input("Please enter a number ") j = int(j) k = 0 for i in range(j+1): k+=i print (k)
59baa7a7c832afcc37555099aad6156c47f707af
tryspidy/python-list-Ri1AXN
/main.py
371
3.9375
4
# Create list List = list() List = [] List = [0, "any data type can be added to list", 25.12, ("Even tuples"), {"Dictionaries": "can also be added"}, ["can", "be nested"]] # Accessing items List[1] # 0 List[-1] # ["can", "be nested"] # Operations List.append(4) # adds 4 to end List.pop(n=-1) # remo...
78c9601068a2333caaf73e9a15d462da3c629ed8
ChicoUA/CSLP_work3
/CSLP_work3_python/Bitstream.py
3,674
3.625
4
import math import os class Bitstream: def __init__(self, filename): self.bitstream = [] self.filename = filename self.file = None self.padding_last_byte = 0 self.file_size = 0 self.bytes_read = 0 def read_one_bit(self): # or is it to get a bit from the bitstr...
7225aa091523c6eb390bbe32ce18c7f55bea464b
jdh7/AdventofCode2020
/Day 5/Day5-pt2.py
990
3.578125
4
# ======= AoC Day 5 ======= import fileinput import math import re # I have 888 tickets, must be a big plane! tickets = [line.strip() for line in fileinput.input()] # Go through the tickets and change the row and column until we find the seat. seatID = 0 seats = [] for ticket in tickets: r = [0, 127] col =...
e2c19f729aad147a7e1afe1d64ad460a545b3301
jdh7/AdventofCode2020
/Day 5/Day5-pt1.py
854
3.59375
4
# ======= AoC Day 5 ======= import fileinput import math import re # I have 888 tickets, must be a big plane! tickets = [line.strip() for line in fileinput.input()] # Go through the tickets and change the row and column until we find the seat. seatID = 0 for ticket in tickets: r = [0, 127] col = [0, 7] ...
96d4bc88ebc26b87946d7fdcb878421eb1669d77
LucienVen/python_learning
/part3/SingleLinkedList.py
5,120
4.125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # 单链表类的实现 # 定义简单的节点类 class LNode: def __init__(self, elem, next_=None): # elem 表元素域 # next 下一结点链接域(next_避免与标准函数next重名) self.elem = elem self.next = next_ # 自定义异常 class LinkedListUnderflow(ValueError): pass # LList类的定义、初始化函数与简单操...
dd37dfdb73c77dc4cbacd57bf754b6b9b6c131ac
LucienVen/python_learning
/algorithm/insertionSort.py
752
4.3125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # 插入排序 def insertion_sort(list): for index in range(1, len(list)): current_value = list[index] position = index while position > 0 and list[position - 1] > current_value: print '比较项>>> list[position]: {} -- current_value: {}'.format(l...
56953ac93c96c6e9e4ee17b962fd7ae92515d9f3
DistortedTopaz152/Python-2020-Progects-4-5
/firstGUI/password_program.py
2,196
3.640625
4
from tkinter import * from tkinter import font as font class App(Frame): usernames = ["dyson"] passwords = ["password"] def __init__(self, master): super(App, self).__init__(master) self.grid() self.create_widgets() self.trys = 0 def create_widgets(self): self....
c821ba13bd66cd4e37c2fefa802845e801efa300
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/2_oop/hw2/account.py
844
3.765625
4
from magic_account import Account class AccountNew(Account): def __init__(self, owner, amount=0, bank_name=''): self.bankName = bank_name super().__init__(owner, amount) def __add__(self, other): if self.owner == other.owner: return AccountNew(self.owner, self.balance + ot...
2d7e422ea72d88532daa5cf353c8e8dd4c2436d7
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/l_4_iterators_generators/HW_4_yuliia/Advanced_functions/advanced_functions.py
378
3.734375
4
from functools import reduce # map example def create_dict(x, y): result = {x: y} return result a = map(create_dict, [1, 2, 3], [4, 5, 6]) print(a.__next__()) # filter example b = filter(lambda n: n*n > 0, [1, 2, 3, 0]) # reduce example c = reduce(lambda m, l: m*l, [1, 2, 3]) # zip example d = zip(['red'...
82135a844b744ab27312fa21428e2ccaac8248ed
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/l_6_software_engineering/hw6-valentyn/AbstractFactoryMain.py
2,182
4.03125
4
from abc import abstractmethod, ABC class Chair(ABC): @abstractmethod def get_price(self): pass class Table(ABC): @abstractmethod def get_view(self): pass @abstractmethod def get_price_with_tax(self, collaborator: Chair): pass class OfficeChair(C...
5ebb5b66f27d7495b11a0842dd2a8ff78ca963eb
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/1_functions/HW_yuliia/recursion.py
334
4.09375
4
#example 1 def recursion_ex1(x): if x==0: return x else: print(x) return recursion_ex1(x-1) recursion_ex1(5) #example 2 def recursion_ex2(a,b): if a<=b: return print(f'Value {a} less then {b}') else: print(a,b) return recursion_ex2(a-1,b+1) recursion_ex...
93f1f6107d386d0ecd5c195253eab46ddf37e18c
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/1_functions/hw/closures.py
362
3.609375
4
b1 = 6 def f11(a): print(a) print(b1) def f2(): c = a + b1 return c * 3 return f2() print(f11(3)) a = 5 def function(): global a print(a) a = 10 print(a) function() print(a) def f1(): a = 1 b = 2 def f2(): nonlocal a a += b ...
2b25fba87e4fd78db5fb6e7276db52a9237def03
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/1_functions/hw/comprehensions.py
241
3.953125
4
print({x for x in range(-9, 10)}) print({x: x ** 3 for x in range(5)}) input_list = [1, 2, 3, 4, 4, 5, 6, 7, 7] list_using_comp = [var for var in input_list if var % 2 == 0] print("Output List using list comprehensions:", list_using_comp)
702699fa57b03d8ce52e6ef68edc93cdc3aee80b
YuriiKhomych/ITEA-advanced
/Shimanskiy_Homework/args_kwargs_recurtion.py
780
3.640625
4
def found_letter(*args): for i in args: try: if i == 0: d = args.count(i) except UnboundLocalError: pass else: if i == 1: d = args.count(i) return d print(found_letter(1, 2, 2, 1, 3, 4, 6, 1)) def find_value(**kw...
ed9a7cced51bfd90f1935e65360bdf3dd25b2308
YuriiKhomych/ITEA-advanced
/Yurii_Khomych/l_3_oop/functors_2.py
1,188
3.5
4
import operator class SortKey: def __init__(self, *attribute_names): self.attribute_names = attribute_names def __call__(self, instance): values = [] for attribute_name in self.attribute_names: values.append(getattr(instance, attribute_name)) return values class...
3b02d55047340699a9838162add260a17a5848db
OmarMuhammedAli/ProblemSolving
/SheetA/Uncommon occurence.py
266
3.921875
4
def longest_uncommon_ocuurence(a, b): if len(a) != len(b): return max(len(a), len(b)) else: if a != b: return len(a) else: return -1 def main(): print(longest_uncommon_ocuurence(input(), input())) if __name__ == "__main__": main()
8c026747067f3169fa00ca6400234ae70460a2bb
SindyPin/Introducao-Python3
/URI/1067.py
78
3.640625
4
x= int(input()) for i in range(1,x+1): if i%2 !=0: print("%d" % i)
626be9ebebc79c6ecf30ffd95fcbf767391de8b9
SindyPin/Introducao-Python3
/URI/1064.py
210
3.71875
4
cont=0 contPositivo=0 soma=0 while cont<6: val = float(input()) if val >0: contPositivo +=1; soma +=val cont +=1 print("%d valores positivos" % contPositivo) print("%.1f" % (soma/contPositivo))
4e3769b220d7d9d8c4b970d2db5b797966e25eef
vandorjw/AdventOfCode
/day3.py
1,032
3.75
4
#!/usr/bin/env python from inputs import day3 as instructions robot_instruction = instructions[::2] santa_instruction = instructions[1::2] if robot_instruction == santa_instruction: print("You did it wrong dummy!") def vistited_houses(instructions): visited = [] origin = (0, 0) for i in instructions...
f40bb1ced22004a7322d9ba462ecd821f85a366e
louisrosenblum/Python
/October/Program 3/pokedex.py
2,341
3.640625
4
# --------------------------------------- # CSCI 127, Joy and Beauty of Data # Program 3: Pokedex # Your Name(, Your Partner's Name) # Last Modified: # --------------------------------------- # A brief overview of the program. # --------------------------------------- # Your solution goes here ... # ----------------...
903a77f3ac5a0433f0261150fb6f23cb351963c4
louisrosenblum/Python
/September/Week 4/test3.py
768
3.96875
4
sentence = input(": ") x = 6 z = 5 def count_vowels_recursive(sentence): the_sum = 0 if sentence == "": return the_sum elif sentence[0] == "a": the_sum = the_sum + 1 + count_vowels_recursive(sentence[1:]) elif sentence[0] == "e": the_sum = the_sum + 1 + count_vowels_recursive(s...
1be4e6dc6ffd567826a8e6677fff011be3c89428
ShiranthaKellum/Find-The-Runner-Up-Mark
/findTheRunnerUpMark.py
851
3.890625
4
# This program finds the runne-up (the second large mark from a det of marks) # Explanation is in the readme file n = int (input ("Number of elements = ")) list = [] # a list of store marks newlist = [] # another ...
0ba62503fc97664b42222ab000ebe77c7a286d8f
m-sterling/Advent-of-Code-2020
/code/day06.py
1,814
3.5625
4
def main(): with open('../inputs/day06', 'r') as f: src = [line.strip() for line in f.read().split('\n')] print(part1(src)) print(part2(src)) def part1(src): total = 0 # groups are read in like passports from day 4, except they're sets group = [] for line in src: if line != ...
79303f09f8d5af1b44686cc9d1b97b5c181be229
AneliyaPPetkova/Programming
/Python/1.PythonIntroduction/7.ChessBoard.py
637
4.0625
4
"""Използвайки цикли, условни оператори и костенурката нарисувайте дъска за шах с черни и бели квадрати. Дъската трябва да е с размери 8 на 8 квадрата. """ import turtle side = 40 for i in range(8): turtle.goto(0, i*-side) turtle.pendown() for j in range(8): if j % 2 == i % 2: turtle...
303dc61ab22c33d78817134b852e8f4826c0d97b
AneliyaPPetkova/Programming
/Python/2.StringsAndDataStructures/1.StringWith10Symbols.py
342
4.125
4
"""Напишете програма, която взима текст от потребителя използвайки input() и ограничава текста до 10 символа и добавя ... накрая """ stringInput = input() if len(stringInput) >= 10: print(stringInput[:10] + "...") else: print(stringInput)
ab4b697ada072459918f2b570ae1ac24a596cbad
AneliyaPPetkova/Programming
/Python/5.ModulesAndTime/2.MostProfitableDate.py
800
3.59375
4
""" Find the most profitable date from a file with data """ from datetime import datetime from datetime import date FILENAME = './CommonResources/sales.csv' sales = {} maxProfit = 0.0 dateWithMaxSales = date.today() with open(FILENAME) as f: for line in f: sale = line.strip().split(",") dayAndTime...
79a7c011b0ed82c278939fef81f60c4be7c88320
ashutoshfolane/PreCourse_1
/Exercise_2.py
2,030
4.34375
4
# Exercise_2 : Implement Stack using Linked List. class Node: # Node of a Linked List def __init__(self, data=0, next=None): self.data = data self.next = next class Stack: def __init__(self): # Head is Null by default self.head = None # Check if stack is empty def ...
a75f93dd25c6dc30f207a06111a6ff348c62c2f0
jchorl/Euler
/p69.py
347
3.75
4
from math import sqrt LIMIT = 1000000 def is_prime(n): if n > 2 and n % 2 == 0: return False for i in range(3, int(sqrt(n)) + 1, 2): if n % i == 0: return False return True prod = 1 for i in range(2, LIMIT): if prod * i > LIMIT: print(prod) break if is_...
6e07ecb20fdcc6107c8650e58a5d65cc2686a878
cmroboticsacademy/CS2N-Raspberry-Pi-Projects
/LightModulatedLED/LEDTest.py
2,240
3.6875
4
#This script will control an LED strip and vary the intensity of the LED #strip based upon the measured ambient light in a room. #Import statements import RPi.GPIO as GPIO import time from gpiozero import LightSensor import sys #Pin assignments for the breadboard signal = 21 offButton = 26 #This tells the Pi to us...
63f986e6fc96219118d35249c2b0e241ddb4ff44
lisadean/DailyCodingProblem
/completed/problem1.py
614
4
4
# Given a list of numbers and a number k, return whether any two numbers from # the list add up to k. # For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17 # Bonus: Can you do this in one pass? input = [10, 15, 3, 7] k = 17 def do_two_numbers_equal_k(num1, num2): return num1 + num2 == k...
04b26614e0e070aebeea55bd9b9e8062f8f3dffa
mmsbrggr/simple-neural-net
/utils/preprocessing.py
2,136
3.578125
4
""" This file is part of a simple toy neural network library. Author: Marcel Moosbrugger This module contains a function which essentially does the same preprocessing of gray-scale images as it's done on the images of the MNIST data set. This helper functions are used to draw our own handwritten d...
e70637bf896dcdfdbef109f78f17448fc020e59f
eliend/quizz
/Quizz informatique V3/Quizz Informatique V3.py
2,906
3.8125
4
# -*-coding:Latin-1 #Premier test du futur programme Python #Variables: y = ("oui") n = ("non") v = 0 d = 0 nb_cnx = 0 nb_question = 2 import os.path from datetime import datetime t = datetime.now() #Les variables "v" et "d" sont là pour une futur version du quizz, ou le programme pourra calcuer...
3c0133cdc322e6dd514e693f319baa869857ee73
amandineldc/git
/exo python.py
1,340
4.25
4
#exo1 : Write a Python program to convert temperatures to and from celsius, fahrenheit. #[ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ] print("---MENU---\n1) °C en °F\n2) °F en °C\nPour quitter tape 0") menu=int(input("Fais un choix :")) if menu == 1: C = int(in...
421b88cad2d8afc99b96ad1da00ce0b629495a65
roni31/Python
/databaseproj.py
3,926
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 7 18:57:56 2021 @author: Ronish """ #student database project by using sql database import sqlite3 import csv import smtplib #libray for sending email #create a database db = sqlite3.connect("DB1.sqlite") #create a table try: db.execute("""creat...
4c2b6cd79422c4edd6c236c077b0b9887821f96a
neerbek/taboo-core
/stat_parser/eval_parser.py
5,965
3.703125
4
""" Parses evaluator from the "Natural Language Processing" course by Michael Collins https://class.coursera.org/nlangp-001/class """ from __future__ import division import re from collections import defaultdict class ParseError(Exception): def __init__(self, value): self.value = value def __str...
db55d9499541dec8cdf78f4f335f81812f205b94
Preonath2838/Bioinformatics_Textbook_Track
/solutions/BA9A.py
1,659
3.859375
4
import sys from Tree_Trie_classes import Trie def TrieConstruction(Pattern_list): trie = Trie() for Pattern in Pattern_list: currentNode = trie.root for currentSymbol in Pattern: # if there is an outgoing edge from currentNode with label currentSymbol, # change current...
e9653d8a72d9f7d276c2b0cc60c3e6ff13c807a9
Preonath2838/Bioinformatics_Textbook_Track
/solutions/BA7A.py
2,181
4.09375
4
import sys import queue class Node: def __init__(self, label): self.label = label self.linked_nodes = set() class Tree: def __init__(self): self.nodes_dict = {} def add_node(self, label): if label in self.nodes_dict: return self.nodes_dict[label] nod...
d06698938e12b01b555c0e9eaafaadfe4a05e833
Preonath2838/Bioinformatics_Textbook_Track
/solutions/BA1D.py
561
3.515625
4
import sys def positions_pattern(text, pattern): k = len(pattern) pos = [] for i in range(len(text) - k + 1): if text[i:i+k] == pattern: pos.append(i) return pos if __name__ == "__main__": ''' Given: Strings Pattern and Genome. Return: All starting positions in Genome...
7846268479efe6a7316d9d4b8e69109880747cc9
Preonath2838/Bioinformatics_Textbook_Track
/solutions/BA2H.py
793
3.765625
4
import sys from BA1G import hamming_dist def distance(pattern, text): k = len(pattern) min_dist = float("Inf") for i in range(len(text) - k + 1): dist = hamming_dist(text[i:i + k], pattern) if dist < min_dist: min_dist = dist return min_dist def DistanceBetweenPatternAndS...
8bbe484d49b608cca6a4af4c6a10771e27e2be78
Preonath2838/Bioinformatics_Textbook_Track
/solutions/BA3L.py
646
3.75
4
import sys from BA3J import StringSpelledByGappedPatterns if __name__ == "__main__": ''' Given: A sequence of (k, d)-mers (a1|b1), ... , (an|bn) such that Suffix(ai|bi) = Prefix(ai+1|bi+1) for all i from 1 to n-1. Return: A string Text where the i-th k-mer in Text is equal to Suffix(ai|bi) for all i ...
47bc6696c37532720b695a67f004dc056ab9ca21
ShmuelTreiger/scrape_silver_data
/data_scraper.py
4,276
3.578125
4
import requests import xlsxwriter from selenium import webdriver from bs4 import BeautifulSoup from time import sleep from unicodedata import normalize #https://stackoverflow.com/questions/20986631/how-can-i-scroll-a-web-page-using-selenium-webdriver-in-python def scroll_to_bottom(driver): SCROLL_PAUSE_TIME = 1 ...
08fbe2a428a0d03474a71dee2407ed81973e90fe
X3NOSIZ/algorithms
/machine_learning/naive_bayes/naive_bays.py
4,352
4.15625
4
import csv ''' So, the way this naive_bays implementation works is as follows: posterior is a function that takes the prior probability of a variable Class being true and the likelihoood of other dependent variables being true and returns the probability of P(Class = True | Observations). That is, this function calcu...
b24445f45fe86face813bb2837c456968f496848
yemao616/Leetnotes
/Array/53. Maximum Subarray.py
857
3.953125
4
# Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. # Example: # Input: [-2,1,-3,4,-1,2,1,-5,4], # Output: 6 # Explanation: [4,-1,2,1] has the largest sum = 6. # Follow up: # If you have figured out the O(n) solution, try coding a...
7043d12362f1961009a3966210ecae124daaf0c7
yemao616/Leetnotes
/Two Pointer/m142. Linked List Cycle II.py
2,311
3.84375
4
# Given a linked list, return the node where the cycle begins. If there is no cycle, return null. # Note: Do not modify the linked list. # Follow up: # Can you solve it without using extra space? # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # ...
2bd11b3558ffc23dcdd0eedc3933c0ef2348aa34
yemao616/Leetnotes
/Two Pointer/m3. Longest Substring Without Repeating Characters.py
1,274
3.859375
4
# Given a string, find the length of the longest substring without repeating characters. # Example 1: # Input: "abcabcbb" # Output: 3 # Explanation: The answer is "abc", with the length of 3. # Example 2: # Input: "bbbbb" # Output: 1 # Explanation: The answer is "b", with the length of 1. # Example 3: # Input: "p...
6686ad3efa4b2036988196c50b0ab6f56c1903f7
debajyoti-ghosh/Learn_Python_The_Hard_Way
/Exe8.py
527
4.125
4
formatter = "{} {} {} {}" #format can take int as argument print(formatter.format(1, 2, 3, 4)) #.format can take string as argument print(formatter.format('one', 'two', 'three', 'four')) #.format can take boolean as argument print(formatter.format(True, False, True, False)) #.format can take variable as argument pr...
8190d7f774dde26fd40bce5d48d35d72c4909bb9
andy1584/my_bot
/for_dict_challenges.py
5,112
3.78125
4
# Задание 1 # Дан список учеников, нужно посчитать количество повторений каждого имени ученика. students = [ {'first_name': 'Вася'}, {'first_name': 'Петя'}, {'first_name': 'Маша'}, {'first_name': 'Маша'}, {'first_name': 'Петя'}, ] names = {name: 0 for name in sorted(list(set(student['first_name'] for student ...
d2d1944803e966461e70a6aba526d98425c5d7ae
Sangram-k-m/test
/module2_StartsWithEndsWith.py
687
3.8125
4
#------------------------------------------------------------------------------- # Name: module2 # Purpose: # # Author: smohapa2 # # Created: 25-08-2015 # Copyright: (c) smohapa2 2015 # Licence: <your licence> #------------------------------------------------------------------------------...
72301ec7c64df86bd3500a01d59262d2037866dd
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/10_EvenFactors/Demo.py
411
4.125
4
''' Write a program which accept number from user and print even factors of that number Input : 24 Output: 2 4 6 8 12 ''' def PrintEvenFactors(no): if(no<0): no = -no; for i in range(2,int(no/2)+1): if(no%i == 0): print("{} ".format(i),end = " "); def main(): no = int(...
06d0f605a29063be41d24cc4de52bfb404075f69
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/5_CheckFirstAndLastBitIsOff/Demo.py
609
3.84375
4
''' Write a program which checks whether first and last bit is On or OFF First bit means bit number 1 and last bit means bit number 32 Input: 2147489625 (10000000000000000001011101011001) Output: True ''' def CheckBit(num,pos1,pos2): mask = 0x00000001; mask1 = mask<<(pos1-1); mask2 = mask<<(pos2-1); if(...
550ba0f284ff481d3e66e346d8cc8a0f4599733c
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/generator5(special_for).py
233
3.84375
4
def my_own_forloop(iterable): iterator = iter(iterable) while True: try: print(iterator) print(next(iterator)*2) except StopIteration: break my_own_forloop([1,2,3,4,5])
664d56d67d2437d0f2bf2c2477daef3bd3fc54d5
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/11_CheckSpecifiedBitStatus/Demo.py
675
3.828125
4
''' Write a program which accept one number and position from user and check whether bit at that position is on or off. If bit is one return TRUE otherwise return FALSE. IP: 11100110000 - 1840 iPos = 5 OP = TRUE iPos = 7 OP = FALSE ''' def CheckBit(num,pos): mask = 1 << (pos - 1); if(num & mask == mask): ...
52e24462640ca0c3013821742a4165f16787d8b8
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/ducktyping1.py
1,125
3.890625
4
class CLanguage: def LearnAndCode(self): print("Learning C Language") class CppLanguage: def LearnAndCode(self): print("Learning Cpp Language") class PythonLanguage: def LearnAndCode(self): print("Learning Python Language") # the type of language is not specified # we expect la...
ee047469e8eade9bcfb3b0f82467f405ad3939a5
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/41_FibonacciSeries/Demo.py
511
3.984375
4
''' Accept number from user and display that number of fabonacci series Input: 10 Output: 0 1 1 2 3 5 8 13 21 34 ''' def DisplayFabonacci(no): first = 0; second = 1; third = 0; print(first,end = " "); print(second,end = " "); for i in range(1,no-1): print(first+second,end = " "); ...
2efe2f8e6d979d2aa76788bf13bc62ac1a9ce9c8
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/16_CountONBits/Demo.py
535
3.796875
4
''' Write a program which accept one number from user and count number of ON (1) bits in it without using % and / operator IP: 00000000000000000000011100110000 - 1840 OP: 5 IP: 11110000000000000000011100111111 - 4026533695 OP: 13 ''' def CountOnBits(num): iCnt = 0; for i in range(1,33): if((num & (1 <<...
ea7d10d28656e04fd57febf221f2edbc29b51134
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/bin_int_function.py
145
3.65625
4
print(5) # print integer number print(bin(5)) # int to binary using bin function print(int("0b101", 2)) # binary to int using int function
8f58249fb653cff0b13f70faab109bea83dbbf70
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/1_CheckBitIsOff/Demo.py
474
3.609375
4
''' Write a program which checks whether 15th bit is On or OFF Input: 21846 (101010101010110) Output: True Input: 70998 (10001010101010110) Output: False ''' def CheckBit(num,pos): mask = 0x00000001; mask = mask<<(pos-1); if(num & mask == mask): return True; else: return False; ...
408babae6f2e8b73ff56eaab659d421628c46cab
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/6 Problems on characters/2_CheckCapital/Demo.py
408
4.15625
4
''' Accept Character from user and check whether it is capital or not (A-Z). Input : F Output : TRUE Input : d Output : FALSE ''' def CheckCapital(ch): if((ch >= 'A') and (ch <= 'Z')): return True; else: return False; def main(): ch = input("Enter character:"); result = False...
d338e08961a3347b578649539a80a199e5b89251
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/operator_overloading5.py
353
3.75
4
class Demo: def __init__(self, x, y): self.i = x self.j = y def __add__(self, other): no1 = self.i + other.i no2 = self.j + other.j return Demo(no1, no2) def main(): obj1 = Demo(10, 20) obj2 = Demo(30, 40) ret = obj1 + obj2 print(ret.i, ret.j) if __...
cbc5c34806a34979c4fc4aa15976e4812a24bacd
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/2 Problems on digits/11_PrintWord_ForDigit/Demo.py
844
4.09375
4
''' Accept single digit number from user and print it into word Input : 9 Output : Nine Input : -3 Output : Three Input : 12 Output : Invalid Number ''' def DisplayWord(ch): if(ch == '1'): print("One"); elif(ch == '2'): print("Two"); elif(ch == '3'): print("Three"); elif...
c3c59745e3de6f17d1f404221048e9ce92aed2e3
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/22_DisplayTable/Demo.py
348
4.125
4
''' Write a program which accept number from user and display its table. Input : 2 Output : 2 4 6 8 10 12 14 16 18 20 ''' def PrintTable(num): if(num == 0): return; for i in range(1,11): print(num*i,end = " "); def main(): no = int(input("Enter number: ")); PrintTable(no); if __name_...
a34af132304c9c37fa2c191da1b337c9e096884d
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/20_DemoOf_if_else_if_else/Demo.py
509
3.96875
4
''' Write a program which accept number from user and if number is less than 50 then print small , if it is greater than 50 and less than 100 then print medium, if it is greater than 100 then print large. Input : 75 Output : Medium ''' def CheckNumber(num): if(num<50): print("Small"); elif((num>=50)...
3f5c832dd706d8b4f4242ece22b14c5c77627814
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/oop6.py
469
3.703125
4
class Player: def __init__(self, name="Anonymous", age=0): #Default Parameters self.name = name self.age = age def Display(self): print(f"My name is: {self.name}") print(f"My age is: {self.age}") def main(): print("The information of object1:") obj1 = Player() ...
dbfbf4021f4a75282aa0ae3735a31779e28be5e7
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/error_handling8.py
373
3.6875
4
def main(): no1 =int(input("Enter first number:")) no2 =int(input("Enter second number:")) try: ans = no1 / no2 except ZeroDivisionError as obj: print("Divide by zero exception" ,obj) except Exception as eobj: print("Exception occurs" ,eobj) else: print("Div...
5e535500d25de5610f643c653e5cbcfff7942f25
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/6 Problems on characters/7_ToggleCase/Demo.py
666
4.09375
4
''' Accept character from user. If character is small display its corresponding capital character, and if it small then display its corresponding capital. In other cases display as it is. Input : Q Output : q Input : m Output : M Input : 4 Output : 4 Input : % Output : % ''' # ord() function converts character to ASCII...
4e220f9d982e51043ef475146d5f8296f1bd9a42
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/2 Problems on digits/6_Count_EvenDigits/Demo.py
466
4.09375
4
''' Write a program which accept number from user and return the count of even digits Input : 2395 Output : 1 Input : 1018 Output : 2 ''' def CountEven(num): iCnt = 0; while(num != 0): if((num%10)%2 == 0): iCnt = iCnt+1; num = int(num/10); return iCnt; def main(): no = int...
346254fdfa49979199652ae16bb6426228ca7229
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/args_kwargs.py
773
3.578125
4
# *args and **kwargs def super_func(*args, **kwargs): # we can actually name these parameters anything we want, # but its a good practice to give the same name only. print(args) print(type(args)) # class tuple print(*args) #print(type(*args)) # gives error ...
eecb4647d63c0ac16f6c22f68dcfa0389b6d4b1e
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/29_CalculateRectangleArea/Demo.py
560
4.09375
4
''' Write a program which accept width & height of rectangle from user and calculate its area. (Area = Width * Height) Input : 5.3 9.78 Output : 51.834 ''' def FindRectangleArea(Width,Height): if((Width <= 0) or (Height <= 0)): print("Invalid dimensions"); return 0; return (Width * Height); d...
ed0560ae60c8e805b00617e540a1525a9ea6814b
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/14_SumOf_NonFactors/Demo.py
432
4
4
''' Write a program which accept number from user and return summation of all its non factors Input : 12 Output : 50 ''' def SumNonFactors(num): if(num<0): num = -num; ans = 0; for i in range(1,num+1): if(num%i != 0): ans = ans + i; return ans; def main(): no = int(inpu...
8b0cc1b3cf4e920a844b2825379e3b0352924d01
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/8 Problems on bits and masking/19_CheckBitStatus_SpecifiedPositions/Demo.py
552
3.859375
4
''' Write a program which accept one number , two positions from user and check whether bit at first or bit at second position is ON or OFF IP: 7984 - 1111100110000 iPos1 = 5 iPos2 = 7 ''' def CheckBitStatus(num,pos1,pos2): if(((num & (1<<(pos1-1))) == (1<<(pos1-1))) or ((num & (1<<(pos2-1))) == (1<<(pos2-1)))): ...
f31b354b73c09c00f6c797bbefd5e89017b93fe2
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/1 Problems on numbers/3_Print_Numbers_ReverseOrder/Demo.py
356
4.15625
4
#Accept a positive number from user and print numbers starting from that number till 1 def DisplayNumbers(no1): if(no1 < 0): print("Number is not positive"); else: for i in range(no1,0,-1): print(i); def main(): no1 = int(input("Enter number: ")); DisplayNumbers(no1); if...
d55d16ce6d0df6640be619d8f7cfd4e70fb84545
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/error_handling7.py
303
3.71875
4
try: no1=int(input("Enter 1st number:")) no2=int(input("Enter 2nd number:")) ans=no1/no2 except Exception as err: print(f"The error occured is: {err}") else: print("The division is:", ans) finally: print("Release all resources") print("End of exception handling application")
82c13f15ca8d6b36f881d57c79954d9c19b4e3a7
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/lambdaa3.py
369
4
4
#lambda function accepts two parameters and return its multiplication. Multiplication=lambda iNo1,iNo2 : iNo1*iNo2 def main(): iValue1=int(input("Enter First number:")) iValue2=int(input("Enter Second number:")) iRet=Multiplication(iValue1,iValue2) print(f"The multiplication of {iValue1} and {iValue2...
5ed1852ba62c00fd9178455ee1438c732bd86cc2
BhuvneshKumarSharma/BhuvneshKumarSharma
/average.py
200
4.25
4
num1=int(input("enter first number\n")) num2=int(input("enter second number\n")) num3=int(input("enter third number\n")) print("The average of three number") avg=((num1)+num2+num3)/3 print(avg)
7a23a315d6a8a7696dd8099e3ee3659001929815
hpzhong/tyd
/python/9x9/n9x9.py
179
3.734375
4
#!/usr/bin/env python3.3 a,b=1,1 while a < 10: while b < 10: if(a>=b): print("%dx%d=%d\t"%(b,a,a*b),end="") b=b+1 b=1 a=a+1 print ("")
758acad88cde19441a9f63992f698933861b4350
xj-yan/LING131FinalProject
/analysis_sklearn.py
8,436
3.5
4
""" <1>use six feature extractors: 1 the raw Count with CountVectorizer from sklearn 2 TF-IDF with TfidfVectorizer from sklearn 3 binary feature: check if each of the most frequent 200 words is in the email with self difined function 4 bigram of words 5 ngram of characters within word bound 6 ngram of characters acors...
ad1f19d49a5f22e1b728c528be7312ebb461086d
bh2smith/advent
/2015/day05/day05.py
874
3.6875
4
def vowel_count(st): return sum([st.count(x) for x in 'aeiou']) def no_subs(st, arr): return not any([a in st for a in arr]) def two_in_row(st): for i in range(len(st) - 1): if st[i] == st[i + 1]: return True return False def nice1(st): bad_subs = ['ab', 'cd', 'pq', 'xy'] ...