blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
dfc1ca77079f4a880dd8a1a4ee136a9e54a4a59c | jinggz/entity-aspect-linking-toolkit | /src/nlp_preprocessing.py | 1,029 | 3.59375 | 4 | import nltk
nltk.download('stopwords')
nltk.download('punkt')
nltk.download('wordnet')
from nltk.corpus import stopwords
from nltk import word_tokenize
import string
from nltk.stem.wordnet import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
punct = set(string.punctuation)
stop_word_list = set(stopwords.words('en... |
62173179b82185eeff452692c79fedbc91437b37 | teknofage/SPD1.4-leetcode | /leet1431.py | 747 | 3.75 | 4 | class Solution:
def kidsWithCandies(self, candies, extraCandies):
candies = [2,3,5,1,3]
extraCandies = 3
# return kid with largest stash of candy = fat_bastard
# loop through list of kids with candy
# for each kid in list,
# if the sum of what they already have + extraCandies >=... |
3e8aa69c5938765bc9423fcbf0a4dcd177e73db0 | AleksandraPrzybylska/Snake-Game | /utils.py | 4,260 | 3.84375 | 4 | import random
import heapq as pq
import heapq
###### Random seed - comment this line to randomize food
# random.seed(10)
######
def check_neighbors(x1_change, y1_change, snake_block):
if (x1_change > 0) and (y1_change == 0):
x1_change = 0
y1_change = snake_block
elif (x1_change == 0) and (y1_... |
90685549708d16ca7dd6468bc15a1cc33bb35918 | tommyshere/ctci | /1-4_palindrome_permutation.py | 928 | 4.03125 | 4 | # Given a string, check if it is a permutation of a palindrome
# Input: "Tact Coa"
# Output: True (permutations: 'taco cat', 'atco cta', etc.)
# can the words be rearrange to create a palindrome?
# what is a palindrome?
# same letters front and back
# same count of letters
# aa aba aaa abba abcba abccba
# 2 2,1 3 2... |
5d6c46ebf6db8ad4fe9c087671f5adb85ceec0ac | robbiesri/advent-of-code-2018 | /solutions/d2p1.py | 585 | 3.5625 | 4 | #!/usr/bin/env python3
import commonAOC
from collections import Counter
import string
inputDataFile = commonAOC.loadInputData("d2.txt")
total2count = 0
total3count = 0
for line in inputDataFile:
count2 = False
count3 = False
counter = Counter(line)
for k in string.ascii_lowercase:
lett... |
27e6736983e101b8cf7d064d74bb6962062fa762 | cminnera/Cryptography | /week3.py | 1,389 | 3.6875 | 4 | # Clare Minnerath
# Week 3 Cryptography assignment
# hash video authentication
from Crypto.Hash import SHA256
import binascii
def create_test_file():
rawhex1 = b'\x11'*1024
rawhex2 = b'\x22'*1024
rawhex3 = b'\x33'*1024
rawhex4 = b'\x44'*773
e1 = open('b1','wb')
e2 = open('b2','wb')
e3 = op... |
188b8d76e3944e28432f518092795a9f49624946 | iewaij/ml-assignment | /2_Kernels/bank_mkt.py | 8,850 | 3.90625 | 4 | import pandas as pd
def import_dataset(filename):
"""
Import the dataset from the path.
Parameters
----------
filename : str
filename with path
Returns
-------
data : DataFrame
Examples
--------
bank_mkt = import_dataset("BankMarketing.csv")
""... |
26b5b5061db9a8d7724bf54b36e6db6afd492bb8 | Mudit-Nahata/mypython | /string_split.py | 291 | 3.6875 | 4 | def string_split():
string="a=b;c=d;e=f;g=h"
split1=string.split(";")
split2=[]
for i in split1:
convertor1=str(i)
convertor2=convertor1.split("=")
convertor2=tuple(convertor2)
split2.append(convertor2)
return split2
print(string_split())
|
5191d61515cc9b1942cc8da25924c3195c5a4aee | amit/kachara | /consume_mem.py | 252 | 3.671875 | 4 | #!/usr/bin/env python
import time
consume=2 # Size of RAM in GB
snooze=10 # How long to sleep in seconds
print("Eating %s GB ..." % consume)
str1="@"*1024*1024*1024*consume
print("sleeping %s seconds ..." % snooze)
time.sleep(snooze)
print("All Done")
|
355a865bb3ad8a542086e94f7b3d769c74e97cf3 | leige133/test_python | /test_program | 1,413 | 3.953125 | 4 | #!/usr/bin/env python
#-*-coding:utf-8-*-
#coding:utf-8
"""
author by wanglei
Created on April 21, 2016
"""
print __name__
print __file__
print __doc__
"""
def show(*args): #将参数以列表形式传入函数中
for item in args:
print item
if __name__ == '__main__':
show('wl','zc',123,('w',5))
"""
"""
def show(**args): ... |
99092ece360bac7c6e3bd924208d859ebe673639 | achicha/py_samples | /codeforces/231A.py | 765 | 3.859375 | 4 | """
Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest.
Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1,
then Petya is sure about the problem's solution, otherwise he isn't sure.
The second numbe... |
790242a7074e61d0bd571b7c65f2251b37f4e6c1 | namonai/UebungSS19 | /Session5/cl_uebungss19_jr.py | 795 | 3.515625 | 4 | #!/usr/bin/python3
import matplotlib.pyplot as plt
from numpy.random import rand
import pandas
# Funktion CreateData
def createData(data_points, filename):
if data_points < 5:
data_points = data_points * 5
# als Erinnerung: rand(zeilen, spalten)
x = rand(data_points, 2)
df = pandas.DataFrame(data=x, columns=['x'... |
eaf81fec64e2f2c7e4a1cc09b1f4a2d512fd71ff | yxu1998/miscellaneous-stuffs | /hw8_skel.py | 13,532 | 4.09375 | 4 | # hw8_skel.py
# Matt Querdasi
class Node(object):
"""
Represents a singly-linked node
"""
def __init__(self, value, next_node):
self.value = value
self.next = next_node
class LinkedList(object):
"""
Represents a singly-linked list
"""
def __init__(self):
self.he... |
acfd6191021f32549e0c8cca3989101b816b1f17 | yxu1998/miscellaneous-stuffs | /lab5_skel.py | 7,258 | 4.375 | 4 | # lab_skel.py
# October 3, 2018
"""
Part I: warm up exercises. Complete the functions below
"""
def sum_list(xs):
"""
xs: list, a list of integers
returns: int, sum of all elements in xs
precondition: none (if list is empty, 0 should be returned)
"""
pass
acc=0
for char in xs:
... |
dad97fd210d3b6491734b7adc3f42f8925b640a5 | byteridge/ML-Byteridge | /Santhan/ASSIGNEMENT 1/stringnmultiplychars.py | 394 | 3.84375 | 4 |
def stringMultiply(str):
res = ''
# increment by 2 over iterations
for i in range(0, len(str), 2):
# casting every second charcter
num = int(str[i+1])
# adding up char n times to result
for j in range(num):
res += str[i]
return sorted(res)
# test 1
print... |
36d2a4aa96460215721c2d346f034f2a7c6b46d1 | marissa-graham/cs673 | /corpus.py | 10,118 | 3.515625 | 4 | #!python3
import string
import numpy as np
from scipy import sparse
import os
import phonetic
from phonetic import Word
class WordCorpus:
"""
Calculate the transition probabilities for a given corpus of text and
use the distribution to generate options for new text.
Attributes:
dictionary :... |
d6a2e7781f1d97b296f15990abefb720fdb04258 | lihip94/countingPolyominos | /gui.py | 470 | 3.734375 | 4 | from tkinter import *
from counting_polyominos import counting_poly
root = Tk()
e = Entry(root, width=50)
e.pack()
def click():
num = e.get()
fixed_num = counting_poly({(0, 0)}, set(), [], int(num)) - counting_poly({(0, 0)}, set(), [], int(num)-1)
label1 = Label(root, text="fixed("+str(num)+") = " + str... |
b1cb1ad578bb76f3dd42bb64f8b72811b411658b | aybidi/Algorithmic-Sprint | /Element of Programming Interview in Python/Strings/look_and_say.py | 562 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 9 19:21:00 2019
@author: abdullah
"""
def look_and_say(n):
'''
time complexity ~ O(n x 2^n)
'''
def next_number(s):
result, i = [], 0
while i < len(s):
count = 1
while i + 1 < len(s) and ... |
eb9612315e24e7c5dcac2c0208c99fd5dec6a891 | aybidi/Algorithmic-Sprint | /Element of Programming Interview in Python/InterviewQs.py | 4,080 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 22 14:22:13 2019
@author: macbook
"""
def add_pair(values, target):
val_comp = {}
for value in range(len(values)):
val_comp[values[value]] = value
for value in values:
diff = target - value
if diff in val_comp:
... |
edc5beae0fbf7f7406b535dbda33c843bd95e761 | aybidi/Algorithmic-Sprint | /Element of Programming Interview in Python/Recursion/generate_btrees.py | 939 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 6 20:18:28 2019
@author: abdullah
"""
class BinaryTreeNode:
def __init__(self, value, left, right):
self.value = value
self.left = left
self.right = right
def generate_binary_trees(num_nodes):
"""
input: nu... |
e76998550d5a5ff9d2f2eee8f7440b5689d1d066 | aybidi/Algorithmic-Sprint | /Element of Programming Interview in Python/Recursion/generate_power_set.py | 789 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 6 20:06:57 2019
@author: abdullah
"""
def generate_power_set(input_set):
"""
input: a set
output: power set of the input set (all subsets of the input set)
time complexity ~ O(n x 2^n)
space complexit... |
0970f57aa338249ee6466c1dadadeee769acf7c6 | MurphyStudebaker/intro-to-python | /1-Basics.py | 2,086 | 4.34375 | 4 | """
PYTHON BASICS PRACTICE
Author: Murphy Studebaker
Week of 09/02/2019
--- Non-Code Content ---
WRITING & RUNNING PROGRAMS
Python programs are simply text files
The .py extension tells the computer to interperet it as Python code
Programs are run from the terminal, which is a low level interaction with the c... |
d1324a79ae30418d5722f22782283d05cd738c23 | IfDougelseSa/cursoPython | /exercicios_secao5/22.py | 370 | 3.921875 | 4 | # aposentadoria
idade = int(input("Digite sua idade : "))
tempo_servico = int(input("Digite o tempo de serviço: "))
if idade > 65:
print(f'Você já pode aposentar!!')
elif tempo_servico > 30:
print(f'Você já pode aposentar!!')
elif tempo_servico > 25 and idade > 60:
print(f'Você já pode aposentar!!')
else:... |
a663237f9a4f7c5099c4e65201bbd4e7a4fefe8a | IfDougelseSa/cursoPython | /exercicios_secao6/5.py | 143 | 3.96875 | 4 | # Soma de dez valores
soma = 0
for values in range(11):
num = int(input("Digite o numero: "))
soma = soma + num
print(f'{soma}')
|
9a3ccf577884d3afbade517373e20d4540420a6f | IfDougelseSa/cursoPython | /exercicios_secao6/10.py | 164 | 3.671875 | 4 | #soma dos 50 primeiros numeros pares
par = 0
soma = 0
for values in range(50):
par = par + 2
print(par)
soma = soma + par
print(soma)
print(soma)
|
226d02ec4ae29ebeb6a19115101a65750e43ae04 | IfDougelseSa/cursoPython | /exercicios_secao5/20.py | 485 | 4.03125 | 4 | # determinando um triângulo
a = int(input("Digite o valor do lado a: "))
b = int(input("Digite o valor do lado b: "))
c = int(input("Digite o valor do lado c: "))
if (a + b) > c and (a + c) > b and (b + c) > a:
if a == b and a == c:
print(f'Triângulo equilátero')
elif a == b or a == c or b == c:
... |
4e529878318541826bf0323176a9b35dda63f56d | IfDougelseSa/cursoPython | /exercicios_seccao4/6.py | 205 | 4 | 4 | # Conversor de temperatura celsius para fahrenheit
celsius = float(input("Digite a temperatura em Celsius: "))
fahrenheit = celsius * (9 / 5) + 32
print(f'A temperatura em fahrenheit é {fahrenheit}')
|
3d876bd8dd7e98da0b2227478dce4fb5c77fc0a2 | IfDougelseSa/cursoPython | /deque.py | 477 | 3.953125 | 4 | """
Módulo Collections - Deque
Podemos dizer que o deck é uma lista de alta perfomamce.
# Import
from collections import deque
# Criandp deques
deq = deque('geek')
print(deq)
#Adicionando elementos no deque
deq.append('y') #
print(deq)
deq.appendleft('k')
print(deq) # Adiciona no comeco da lista.
# Remover el... |
6bf090c2ef148b96404539238a5425a055c57f6a | IfDougelseSa/cursoPython | /exercicios_seccao4/53.py | 319 | 3.671875 | 4 | # Custo para cercar o terreno
c = float(input("Digite o comprimento do terreno: "))
l = float(input("Digite a largura do terreno: "))
preco_metro = float(input("Digite o preço da tela: "))
diametro = c + l
custo_total = diametro * preco_metro
print(f'O custo total para cercar seu terreno é {custo_total} reais.')
|
874769f6eddcea51823c926e4b520e6cc0bbcf89 | IfDougelseSa/cursoPython | /exercicios_seccao4/46.py | 266 | 4.125 | 4 | # Digitos invertidos
num = int(input('Digite o numero com 3 digitos: '))
primeiro_numero = num % 10
resto = num // 10
segundo_numero = resto % 10
resto = resto //10
terceiro_numero = resto % 10
print(f'{primeiro_numero}{segundo_numero}{terceiro_numero}')
|
7ea222e7fee925a91e1e9cd3781545759e1f44c6 | IfDougelseSa/cursoPython | /exercicios_seccao4/47.py | 307 | 4.1875 | 4 | # Numero por linha
x = int(input("Digite o numero: "))
quarto_numero = x % 10
resto = x // 10
terceiro_numero = resto % 10
resto = resto // 10
segundo_numero = resto % 10
resto = resto // 10
primeiro_numero = resto % 10
print(f'{primeiro_numero}\n{segundo_numero}\n{terceiro_numero}\n{quarto_numero}')
|
7097f9cf932ac4aa674dcbf40c2e13f24c1d103e | IfDougelseSa/cursoPython | /exercicios_secao5/8.py | 276 | 4.03125 | 4 | # média com notas válidas
nota1 = float(input("Digite a nota 1: "))
nota2 = float(input("Digite a nota 2: "))
if (0 <= nota1 <= 10) and (0 <= nota2 <= 10):
media = (nota1 + nota2) / 2
print(f'A sua média é {media}.')
else:
print(f'Valor da nota inválido.')
|
badce90cf518f3c4be864c8f37f93f25c01a9283 | IfDougelseSa/cursoPython | /test.py | 491 | 3.890625 | 4 | for letras in "Persistência é um dom!":
if letras == 'a':
print(f'Mais uma vogal: {letras}\n')
elif letras == 'e':
print(f'Mais uma vogal: {letras}\n')
elif letras == 'i':
print(f'Mais uma vogal: {letras}\n')
elif letras == 'o':
print(f'Mais uma vogal: {letras}\n')
el... |
248feea895eb5a8e78b5a7de999ef50bdb1bfd4d | IfDougelseSa/cursoPython | /exercicios_secao5/23.py | 225 | 3.78125 | 4 | # ano bissexto
ano = int(input("Digite o ano: "))
if (ano % 400) == 0:
print(f'Ano bissexto.')
elif (ano % 4 == 0) and (ano % 100) != 0:
print(f'Ano bissexto.')
else:
print(f'O ano digitado não é bissexto.')
|
a958de7cc8511d475f0f2731ff8cf669b09df96c | IfDougelseSa/cursoPython | /exercicios_seccao4/1.py | 56 | 3.5625 | 4 | x = int(input('Digite um numero inteiro: '))
print(x)
|
a1985b72d397408ac12f513d65be334965d34b6a | IfDougelseSa/cursoPython | /exercicios_seccao4/51.py | 156 | 4.0625 | 4 | # coordernadas
import math
x = float(input("Digite o valor de x: "))
y = float(input("Digite o valor de y: "))
r = math.sqrt(x ** 2 + y ** 2)
print(r)
|
044cb61a7d188d6661848b84e286f393d5d91b82 | andyhuzhill/ProjectEuler | /problem7.py | 529 | 3.59375 | 4 | #!/usr/bin/env python
# *-* encoding: utf-8 *-*
#
# =============================================
# author: Andy Scout
# homepage: http://andyhuzhill.github.com
#
# description:
#
# =============================================
prime = []
prime.append(2)
n = 1
p = 3
while n < 10001:
for i in prime... |
b59405cb66a726ee2bc19b86fadd0ac85f996c25 | Joana84/Python-learning | /list_comprehentions.py | 550 | 3.5625 | 4 | l = [1, 2, 3, 4, 5]
even = [x for x in l if x % 2 == 0]
print(even)
g = lambda x: x**2
print(g(4))
print(dir(l))
class Person():
def __init__(self, name, surname):
self.name = name
self.surname = surname
def __str__(self):
return self.name + " " + self.surname
def get_name(self):... |
105a662f929dabe1f536a58b4d233f89ca2cdbe1 | sudoabhinav/competitive | /codechef/practice problems/cutting-recipe.py | 393 | 3.546875 | 4 | # https://www.codechef.com/problems/RECIPE
def find_gcd(x, y):
while(y):
x, y = y, x % y
return x
n = int(raw_input().strip())
for i in xrange(n):
li = map(int, raw_input().strip().split())
li = li[1:]
result = li[0]
for i in xrange(len(li)):
result = find_gcd(li[i], result)
... |
f721cd2800a98b3e5eec010e698bb4e07f0d8de2 | sudoabhinav/competitive | /hackerrank/week-of-code-36/acid-naming.py | 544 | 4.15625 | 4 | # https://www.hackerrank.com/contests/w36/challenges/acid-naming
def acidNaming(acid_name):
first_char = acid_name[:5]
last_char = acid_name[(len(acid_name) - 2):]
if first_char == "hydro" and last_char == "ic":
return "non-metal acid"
elif last_char == "ic":
return "polyatomic acid"
... |
c08fe37650a23b1cb70f936b919184f7a01e08d7 | sudoabhinav/competitive | /codechef/journey begins/frequent-winner.py | 388 | 3.734375 | 4 | # https://www.codechef.com/JOBE2018/problems/FRW
from collections import defaultdict
a = int(raw_input().strip())
n = raw_input().strip().split()
dict_names = defaultdict()
for item in set(n):
dict_names.setdefault(item, n.count(item))
max_val = max(dict_names.values())
names = [key for key, value in dict_names.i... |
0790f3bdde034ed1cc7aba38292bf3fba6409465 | sudoabhinav/competitive | /hackerrank/algorithms/warmup/compare-the-triplets.py | 443 | 3.59375 | 4 | #https://www.hackerrank.com/challenges/compare-the-triplets
a0, a1, a2 = raw_input().strip().split(' ')
a0, a1, a2 = [int(a0), int(a1), int(a2)]
b0, b1, b2 = raw_input().strip().split(' ')
b0, b1, b2 = [int(b0), int(b1), int(b2)]
count = 0
count1 = 0
if a0 > b0:
count += 1
elif a0 < b0:
count1 += 1
if a1 > b1:... |
a3c3790812f74749f601c0075b115fbe2a296ca1 | sudoabhinav/competitive | /hackerrank/algorithms/strings/pangrams.py | 232 | 4.125 | 4 | # https://www.hackerrank.com/challenges/pangrams
from string import ascii_lowercase
s = raw_input().strip().lower()
if len([item for item in ascii_lowercase if item in s]) == 26:
print "pangram"
else:
print "not pangram"
|
5c47bc674218773c7c083f96532f64efc2f49c03 | iliyahoo/perfecto | /3/parser.py | 961 | 3.546875 | 4 | #!/usr/bin/env python
from BeautifulSoup import BeautifulSoup
import urllib2
import json
import sys
from json2html import *
def url_parse(url):
# sys.setdefaultencoding() does not exist, here!
reload(sys) # Reload does the trick!
sys.setdefaultencoding('UTF8')
# grab the page
url = urllib2.url... |
2e5477d1a7840074b59fb0f655685ce90352c4c1 | alexaoh/meeting | /quadrature/trapezoidQuad.py | 802 | 3.71875 | 4 | #Composite trapezoid quadrature implementation
def trapezoid(f,a,b,n):
'''
Input:
f: Function to integrate
a: Beginning point
b: End point
n: Number of intervals.
Output:
Numerical approximation to the integral
'''
assert(b > a)
h = float(b-a)/n
result = (f(a) + f(b... |
0a22ab2537a658d377bdd61143b662c7dac9c56e | gansterhuang/- | /时序神经网络模型/序列学习研究/GRU网络学习序列.py | 8,099 | 3.671875 | 4 | import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import Series_generator as sg
import matplotlib.pyplot as plt
import copy
#定义训练集样本数量
data_number=500
x1=sg.series_2()
#定义标准化矩阵的函数
def standardization(data):
mu = np.mean(data, axis=... |
b090f5b4253f0a2318f124b6a6b94ae8992a50a9 | zhaofeng555/python2-test | /pytest/hjg/spe.py | 177 | 3.6875 | 4 | #!/usr/bin/python
print 'abc'+'xyz'
print 'abc'.__add__('xyz')
print (1.8).__mul__(2.0)
print len([1,2,3])
print [1,2,3].__len__()
li=[1,2,3,4,4,5,6]
print(li.__getitem__(3))
|
3d4e601737b5c07cdb33a1f1773b454dfc1c17c5 | zhaofeng555/python2-test | /pytest/hjg/str.py | 233 | 3.9375 | 4 | #!/usr/bin/python
name='hello world'
if name.startswith('hel'):
print 'yes, the string starts with "hel"'
if 'o' in name:
print 'yes, it contains "o"'
delimiter="hehe"
mylist=['aa', 'bb', 'cc', 'dd']
print delimiter.join(mylist)
|
17f06f032b23c1e29fe9bd6dfcff5bbc14024ca3 | zhaofeng555/python2-test | /pytest/hjg/9x9.py | 159 | 3.546875 | 4 | #coding:utf-8
for i in range(1, 9):
for j in range(1, i+1):
print i,'*',j,'=',(i*j),
print ''
else:
print '九九乘法表完事' |
dfd5901190b3715f8b3727b9600518bed7b29a36 | jdalichau/classlabs | /letter_removal.py | 982 | 4.1875 | 4 | #CNT 336 Spring 2018
#Jaosn Dalichau
#jdalichau@gmail.com
#help with .replace syntax found it the book 'how to think like a computer scientist' interactive edition
#This code is designed to take an input name and remove vowels of any case
n = input('Enter your full name: ') #input statement for a persons full ... |
a9c972ff3829d7dd690221bc001b89dcf73e642f | AkulinaSaint/Python-code-examples | /05_easy.py | 2,055 | 3.921875 | 4 | # Задача-1:
# Напишите скрипт, создающий директории dir_1 - dir_9 в папке,
# из которой запущен данный скрипт.
# И второй скрипт, удаляющий эти папки.
import os
import sys
import shutil
print(sys.argv)
def make_a_lot_of_dir():
if not sys.argv[1]:
print('Вы забыли передать первый параметр add_dirs')
... |
4fba8865f46597abff778e63bccf77de1b190fb9 | SMAshhar/Temp-Ashhar1 | /HTML CSS/my-smarter-site/Testing.py | 969 | 3.84375 | 4 | class Navi():
def __init__(self, x, y):
self.x = x
self.y = y
def newPos(self, x1, y1):
self.x = x1
self.y = y1
dot = Navi(0,3)
import numpy as np
a = [[0,0,0,1,0,0,0,0,0,0],
[0,1,1,1,1,1,1,1,1,0],
[0,1,0,0,0,0,1,0,1,0],
[0,1,1,1,0,1,1,0,1,... |
6373adb8318ea1a23b4a1f5a45babfa27756862d | bdarrenn/LR3_CPE106L | /POSTLAB_PROGRAMS_UMLS/PROJECT_2/student.py | 2,386 | 3.9375 | 4 | import random
class Student(object):
"""Represents a student."""
def __init__(self, name, number):
"""All scores are initially 0."""
self.name = name
self.scores = []
for count in range(number):
self.scores.append(0)
def getName(self):
"""Returns the st... |
a877ed0d8f74dc61e1e490642788ac021cc23722 | bandisri/python | /guessthenumber.py | 726 | 3.84375 | 4 | import random
import math
def main():
print("Hit 'E' to exit")
gussedNumber = input("Guess Number between 1 - 100: ")
while gussedNumber.upper() != 'E':
if gussedNumber.isdigit() and ( int(gussedNumber) > 0 and int(gussedNumber) <= 100 ):
generatedNumber = random.randint(1,10)
... |
2ba9e7c3dba0e5eed7cf3ca843938c5fc4021650 | sripadaraj/pro_programs | /python/forloops/sort.py | 152 | 3.515625 | 4 | a=[1,2,33,23,4,5,6,8]
print a
for i in range(0,len(a)):
for j in range(i+1,len(a)):
if a[i]>=a[j] :
a[i],a[j]=a[j],a[i]
print a
|
6ad233abf66a03c2690d6450f9a54f56d83048ed | sripadaraj/pro_programs | /python/starters/biggest_smallest.py | 1,015 | 4.1875 | 4 | print "The program to print smallest and biggest among three numbers"
print "_____________________________________________________________"
a=input("enter the first number")
b=input("enter the second number")
c=input("enter the third number")
d=input("enter the fourth number")
if a==b==c==d :
print "all are equ... |
54ec15a92464e0c90249e38b73ffa6b4bcf9295d | sripadaraj/pro_programs | /python/forloops/vowels1.py | 159 | 3.5625 | 4 | s1= raw_input("enter a string check how many vowels does it have")
d={"a":0,"e":0,"i":0,"o":0,"u":0}
for i in s1 :
if i in d:
d[i]=d[i]+1
print d
|
833100e3910b92bf1f55a0bb4a3653bd952ad6bb | sripadaraj/pro_programs | /python/forloops/count_string2.py | 209 | 3.984375 | 4 | #def char_frequency(str1):
str1=raw_input("enter the string")
dict1 = {}
for n in str1:
if n in dict1:
dict1[n] += 1
else:
dict1[n] = 1
print dict1
#print(char_frequency('google.com'))
|
23bd889858bf051c633b4e72ad04f209fdf85006 | JuanbiB/Rotation-Optimization-WoW | /classes.py | 3,435 | 3.5625 | 4 | import random
"""Juan Bautista Berretta & Jack Reynolds 2016
Reinforcement Learning Project """
GCD = 1.5
""" Ability class to encapsulate the the functionality of
different abilities. """
class Ability:
def __init__(self, name, damage, cd, cost):
self.name = name
self.damage =... |
b6bd22d9d207e9cd75d3f06e4e9e43d3b80af360 | Shijie97/python-programing | /ch04/8-function(3).py | 685 | 4.1875 | 4 | # !user/bin/python
# -*- coding: UTF-8 -*-
def func(a, b = 2, c = "hello"): # 默认参数一定是从最后一个开始往左连续存在的
print(a, b, c)
func(2, 100) # 覆盖了b = 2
i =5
def f(arg = i):
print(i)
i = 6
f() # 6
# 在一段程序中,默认值只被赋值一次,如果参数中存在可变数据结构,会进行迭代
def ff(a, L = []):
L.append(a)
return L
print(ff(1)) # [1]
... |
3e0adfb7a5611c6095186c900e830d5ce6f8d001 | Shijie97/python-programing | /ch05/8-loop tricks.py | 675 | 3.6875 | 4 | # !user/bin/python
# -*- coding: UTF-8 -*-
# 字典遍历
dic = {x : x ** 2 for x in range(10)}
for k, v in dic.items():
print(k, v)
# 数组遍历
lst = list(range(10))
for i, e in enumerate(lst):
print(i, e)
# zip打包
lst1 = [chr(x) for x in range(97, 97 + 26)]
lst2 = list(range(97, 97 + 26))
for c, n in zip... |
5dec35884f68e244093f09a30121f04bb9c52aba | Shijie97/python-programing | /ch04/7-function(2).py | 369 | 3.859375 | 4 | # !user/bin/python
# -*- coding: UTF-8 -*-
def fib2(n):
"""定义一个斐波那契数列,不打印,返回一个list"""
lst = []
a, b = 1, 1
while(a <= n):
lst.append(a)
a, b = b, a + b
return lst
f = fib2(100)
print(f) # [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
print(type(f)) # <class 'list'>
print (1 i... |
01edc69712cc340ab98aab6edef608483102deda | Shijie97/python-programing | /ch05/2-list(2).py | 499 | 4.125 | 4 | # !user/bin/python
# -*- coding: UTF-8 -*-
from collections import deque
lst = [100, 1, 2, 3, 2]
# 列表当做stack使用
lst.append(5) # push
print(lst)
lst.pop() # pop
print(lst)
# 列表当做queue用
queue = deque(lst)
print(queue)
queue.append(5) # 入队 deque([0, 1, 2, 3, 2])
print(type(queue)) # <class 'collections.d... |
c4f942aae920b00d89c010e7c98adf7ab665a19b | sundarcsk/hello | /flightdetails.py | 613 | 3.546875 | 4 | inpp="Sundar:1234567890:Delhi,Raman:234567890:Mumbai"
result=""
if(',' in inpp):
strinpp=inpp.split(',')
dummy=0
# print(str(strinpp))
for i in strinpp:
sum=0
dummy+=1
coloninpp=i.split(':')
# print(coloninpp)
for num in coloninpp[1]:
sum+=... |
56fe0d6a863dc1d1cb5479ec2fded1d298eeb561 | Fastwriter/Pyth | /Daulet Demeuov t1/A.py | 335 | 3.65625 | 4 | #STUDENT: Daulet Demeuov
#GROUP: EN1-C-04
#TASK: Task1 problem A
#Description: Read five-digit number; find sum and product of digits.
while True:
a = str(input('Enter number '))
b = int(a[0])+int(a[1])+int(a[2])+int(a[3])+int(a[4])
c = int(a[0])*int(a[1])*int(a[2])*int(a[3])*int(a[4])
print('Sum:',b)
... |
57441b841c695d0b2c4318b00bcd80a2a03a219c | Fastwriter/Pyth | /__pycache__/sss.py | 903 | 3.90625 | 4 | import math
class triangle:
def __init__(self, a=0, b=0, c=0):
self.a=a
self.b=b
self.c=c
def __str__(self):
if(self.a==self.b==self.c):
k='Equal'
elif(self.a==self.b!=self.c or self.a==self.c!=self.b or self.b==self.c!=self.a):
k='Isos'
el... |
7c5cc01a65c131ed91a9aae1547e8e6980ffac3a | Fastwriter/Pyth | /Питон ост/C.py | 163 | 3.640625 | 4 | def func():
A=input('write the number')
B=input('write the number')
A=int(A)
B=int(B)
C=int(A+B)
D=int(A*B)
print('sum',C,'product',A)
|
adb90cf16198b6628d8ebc30412adcd4be2ec480 | Fastwriter/Pyth | /Питон ост/C1.py | 119 | 3.890625 | 4 | def func():
a=int(input('Value:'))
if(a<0):
print('Maximum is ',a)
else:while True
|
df905a595e5480a0b8b8af53f55d4c8397499a52 | Fastwriter/Pyth | /Питон ост/circle.py | 292 | 3.953125 | 4 | def func():
import math
A=input('X1')
B=input('Y1')
C=input('X2')
D=input('Y2')
E=input('R')
A=int(A)
B=int(B)
C=int(C)
D=int(D)
E=int(E)
F=float(((C-A)**2+(D-B)**2)**0.5)
if(F<E):
print('inside')
else:
print('outside')
|
ac3b5b6cb12a4b4f66104f7d3ea9242a261ac277 | Fastwriter/Pyth | /Питон ост/recursion/n.py | 84 | 3.578125 | 4 | def pan(a):
if(a<0):
return
else:
print(a)
pan(a-1)
|
9bc028e47d9e102d4c87ed14377a193653e68b28 | Fastwriter/Pyth | /Питон ост/grade.py | 212 | 3.625 | 4 | def grade(a):
if(100>=a>=90):
print("A")
elif(89>=a>=75):
print("B")
elif(74>=a>=60):
print("C")
elif(59>=a>=50):
print("D")
elif(49>=a>=0):
print("F")
|
2ead845f157ed118e0333c47decc884456cfbe1d | Fastwriter/Pyth | /02.11.16/5.py | 138 | 3.515625 | 4 | def tran(e,r):
d={}
c=len(e)
for i in e:
d[i]=list()
for i in range(c):
d[e[i]].append(r[i])
print(d)
|
eac86ec920a1100221c52806bf21bcad3e06ed4b | thuongtran1210/Buoi1 | /Bai5.py | 169 | 3.59375 | 4 | print("Nhập số gồm hai chữ số: ",end='')
a=int(input())
chuc=a//10
donvi=a%10
print("Hàng chục là: ",str(chuc))
print("Hàng đơn vị là: ",str(donvi))
|
005f8facc445d02847d4ec59de367642982741e2 | paucarre/Expression | /tests/test_gen.py | 2,821 | 3.765625 | 4 | """
This file is just to explore how generators works
"""
from typing import Generator
import pytest
# from hypothesis import given, strategies as st
def test_generator_with_single_empty_yield():
def fn():
yield
gen = fn()
value = next(gen)
assert value is None
def test_generator_with_sin... |
0a913794075bb24d0b683692b640ff007ae6c200 | paucarre/Expression | /tests/test_choice.py | 676 | 3.578125 | 4 | from expression import Choice, Choice1of2, Choice2, Choice2of2, match
def test_choice_choice1of2():
xs: Choice2[int, str] = Choice1of2(42)
assert isinstance(xs, Choice)
assert isinstance(xs, Choice2)
with match(xs) as case:
for x in Choice1of2.match(case):
assert x == 42
... |
e183ac98fe31cee46d4a8ec4d97fe0c6ff29a752 | potatoHVAC/leet-code-solutions | /1290-Convert-Binary-Num.py | 2,302 | 3.9375 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
"""
Psudocode:
FOR SINGLY-LINKED LIST TRAVERSAL
Go to first ListNode
Append ListNode.value to binary number list
Go to second ListNode
Append ListNode.value to binar... |
e75a405199bd9ffcc9e9ed35f6db998c705d9934 | de-nuke/prir_tsp | /ga_functions.py | 2,614 | 3.546875 | 4 | import random
def distance(p1, p2):
return ((p1[0] - p2[0])*(p1[0]-p2[0]) + (p1[1] - p2[1]) * (p1[1] -p2[1]))**(1/2)
def path_distance(path, cities):
dist = 0
for i in range(1, len(path)):
dist += distance(cities[path[i-1]], cities[path[i]])
return dist
def reproduce(population, cities):
... |
ba2e076ef77275add34ec9be6d65fbf09d7834f2 | deckardmehdy/coursera | /Course2/Week4/phoneBook.py | 618 | 3.890625 | 4 | # python3
### START OF PROGRAM ###
n = int(input())
# Create an empty dictionary
phoneBook = {}
for i in range(n):
request = [str(x) for x in input().split()]
if request[0] == "add": # add
phoneBook[request[1]] = request[2]
elif request[0] == "find": # find
number = r... |
dddda83ba6a039d30ef4ff0da2e264dd933aa582 | deckardmehdy/coursera | /Course4/Week1/constructTrie.py | 2,529 | 3.953125 | 4 | # Runs using Python 3
import queue
def nextNode(trie,currentNode,letter):
# See how many letters are in the node's adjanency list
nextNodes = len(trie[str(currentNode)][1])
# If there are none, then return None
if nextNodes == 0:
return None
# If there are some, loop through and retur... |
92e14ec8324f5affbbdd48b38209d666dae8c70f | deckardmehdy/coursera | /Course4/Week4/knuth_morris_pratt.py | 835 | 3.578125 | 4 | # Runs using Python 3
def computePrefixFunction(P):
s = [0] * len(P)
border = 0
for i in range(1,len(P)):
while (border > 0) and (P[i] != P[border]):
border = s[border-1]
if P[i] == P[border]:
border += 1
else:
border = 0
s[i] = border
... |
8ccd7e7add949ccd48dc9f14c445bce91921c773 | deckardmehdy/coursera | /Course4/Week1/suffixTree.py | 9,174 | 3.953125 | 4 | # Runs using Python 3
class SuffixTree:
class Node:
# Node constructor:
def __init__(self,starting_index,length):
self.starting_index = starting_index
self.length = length
self.children = []
self.marker = None
# Suffix Tree constructor:
def _... |
3da4a7809e976185f86615502b92bedef571a016 | deckardmehdy/coursera | /Course4/Week1/patternMatching_notcompressed.py | 4,350 | 3.875 | 4 | # Runs using Python 3
import queue
def nextNode(trie,currentNode,letter):
# See how many letters are in the node's adjanency list
nextNodes = len(trie[str(currentNode)][1])
# If there are none, then return None
if nextNodes == 0:
return None
# If there are some, loop through and return... |
bc94e388d71357616cc2934e80fabf8f20c9b77f | PythonScriptPlusPlus/olimp | /PythonScriptPlusPlus/questions/question6.py | 247 | 3.671875 | 4 | n = int(input())
if n <= 2:
print('NONE')
quit()
if n == 5:
print(0,1)
quit()
three = 0
four = n // 4
n = n % 4
if n == 2:
four -= 1
three = 2
n = 0
elif n == 1:
four -= 2
three = 3
elif n == 3:
three = 1
print(str(three)+'\n'+str(four)) |
6246edd8b7431de8f9230077cd26fdaac8a14733 | yunko006/CodeWars | /6-kyu/DeleteOccurence.py | 269 | 3.8125 | 4 | """
EXAMPLES:
delete_nth ([1,1,1,1],2) # return [1,1]
delete_nth ([20,37,20,21],1) # return [20,37,21]
"""
def delete_nth(order, max_e):
simple = list()
for i in order:
if simple.count(i) < max_e:
simple.append(i)
return simple
|
78b8f148a5404d3522e7b9944f810095793c4411 | aquibjamal/hackerrank_solutions | /write_a_function.py | 323 | 4.25 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 21:41:35 2019
@author: aquib
"""
def is_leap(year):
leap = False
# Write your logic here
if year%4==0:
leap=True
if year%100==0:
leap=False
if year%400==0:
leap=True
return lea... |
441dc9bb62c96f4f840e1e60ccfcf74029a94510 | aquibjamal/hackerrank_solutions | /dealing_with_complex_nums.py | 1,406 | 3.90625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 02:43:36 2019
@author: aquib
"""
class Complex(object):
def __init__(self, real, imaginary):
self.real=real
self.imaginary=imaginary
def __add__(self, no):
return Complex(self.real+no.real, self.imaginary+no.im... |
3334f3a28d9a1942ac493ca144715daf08b9571d | aquibjamal/hackerrank_solutions | /default_arguments.py | 257 | 4.03125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 02:43:22 2019
@author: aquib
"""
def print_from_stream(n, stream=None):
if stream is None:
stream=EvenStream()
for _ in range(n):
print(stream.get_next())
|
e18c1a47c8a7ff364ae3659d931515ac8cda8665 | aquibjamal/hackerrank_solutions | /set_difference.py | 333 | 3.65625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 21:54:10 2019
@author: aquib
"""
# Enter your code here. Read input from STDIN. Print output to STDOUT
num_e=int(input())
roll_e=set(map(int,input().split()))
num_f=int(input())
roll_f=set(map(int,input().split()))
diff=roll_e-roll_f
print(len(d... |
2e6fccc9f51c820442ab496cb419f28436f5318e | aquibjamal/hackerrank_solutions | /set_union.py | 503 | 3.9375 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 21:52:43 2019
@author: aquib
"""
# Enter your code here. Read input from STDIN. Print output to STDOUT
#read in number of English subscribers
num_e=int(input())
#read roll number of English subscribers
roll_e=list(map(int, input().split()))
#re... |
52015723ceb6e40f5c5b88529992d7370acc4c7d | aquibjamal/hackerrank_solutions | /valid_credit_card_numbers.py | 541 | 3.75 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 22:12:23 2019
@author: aquib
"""
# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
valid_structure = r"[456]\d{3}(-?\d{4}){3}$"
no_four_repeats = r"((\d)-?(?!(-?\2){3})){16}"
filters=valid_structure, no_four_repeat... |
09e6cca73ea7ae36d09efa8eaf971f35013b2fc8 | aquibjamal/hackerrank_solutions | /string_validators.py | 357 | 3.671875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 22:23:14 2019
@author: aquib
"""
if __name__ == '__main__':
s = input()
print(any([c.isalnum() for c in s]))
print(any([c.isalpha() for c in s]))
print(any([c.isdigit() for c in s]))
print(any([c.islower() for c in s]))
p... |
dbb4d38bd6e816c3ee40d996bb92da0bdbb6b23b | aquibjamal/hackerrank_solutions | /check_strict_superset.py | 429 | 3.671875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 22:09:07 2019
@author: aquib
"""
# Enter your code here. Read input from STDIN. Print output to STDOUT
setA=set(map(int,input().split()))
cond=[]
numB=int(input())
for _ in range(numB):
setB=set(map(int,input().split()))
cond1=all([b in ... |
ad28c75360b09d06d4e7e52fe1267699b1c506dc | fpierin/mac5711 | /heapSort.py | 763 | 3.75 | 4 | #!/usr/bin/env python
#
# Author: Felipe Pierin
# Author: Viviane Bonadia
from compare import cmp
def heapsortCmp(c, A):
def heapify(c, A):
start = (len(A) -2) / 2
while (start >= 0):
fixdown(c, A, start, len(A) - 1)
start -= 1
def fixdown(c, A, start, end):
root = start
while root * 2 + 1 <= end... |
e8cff56a53e29a80d047e999918b43deff019c3e | sauravsapkota/HackerRank | /Practice/Algorithms/Implementation/Beautiful Days at the Movies.py | 713 | 4.15625 | 4 | #!/bin/python3
import os
# Python Program to Reverse a Number using While loop
def reverse(num):
rev = 0
while (num > 0):
rem = num % 10
rev = (rev * 10) + rem
num = num // 10
return rev
# Complete the beautifulDays function below.
def beautifulDays(i, j, k):
count = 0
... |
1561be5165baa902c1a5bb0ef4d74be14e957a8c | sauravsapkota/HackerRank | /Practice/Algorithms/Implementation/Append and Delete.py | 756 | 3.609375 | 4 | #!/bin/python3
import os
# Complete the appendAndDelete function below.
def appendAndDelete(s, t, k):
common_length = 0
for i, j in zip(s, t):
if i == j:
common_length += 1
else:
break
# CASE A
if ((len(s) + len(t) - 2 * common_length) > k):
return "N... |
96d4e5f4c03d746833b3934f36e0286394eb5c50 | SHINE1607/coding | /problems/introductory/number_spiral.py | 648 | 3.5625 | 4 | def number_spiral(ind1, ind2):
diagnol = 0
if ind1 == ind2:
print(ind2*(ind2-1) + 1)
return
if ind1 < ind2:
diagnol = ind2*(ind2-1) + 1
if ind2%2 == 0:
print(diagnol - (ind2 - ind1))
else:
print(diagnol + (ind2 - ind1))
elif ind1 > i... |
41e077188841e53d91f0e0bb30facdf111be3646 | SHINE1607/coding | /DSA/sorting/merge_sort.py | 1,482 | 3.8125 | 4 |
import random
def merge(left, right):
global swaps
left_pointer = 0
right_pointer = 0
res = []
if left == None:
return right
if right == None:
return left
while left_pointer < len(left) and right_pointer < len(right):
if left[left_pointer] < right[right_pointer... |
26252a6dc20ee7b8e12fa8d91036123df4030b4e | SHINE1607/coding | /DSA/sorting/bubble_sort.py | 1,298 | 3.90625 | 4 | # possibly the themost brute force approoach we can think of
# steps
# > we select the last element as i
# > we iterate j from to i - 1
# > replace the largest element with ith position
# like that imoves from n -1 to 1
# 20 3 11 5 7 2
# first iteration for i
# j i
# 20 3 11 5 7 2
# j i
# 3 20 1... |
7b8f09db39753b23760cdefc34da9cfa9e6ea729 | SHINE1607/coding | /problems/introductory/repetitions.py | 408 | 3.859375 | 4 |
def repetitions(string):
longest = 1
curr_long = [string[0]]
for i in range(1, len(string)):
if string[i] == string[i - 1]:
curr_long.append(string[i])
else:
if len(curr_long) > longest:
longest = len(curr_long)
curr_long = [... |
73e778301805644bbaa5f570f01498aa07c5cdf2 | SHINE1607/coding | /problems/introductory/chessboard_and_queens.py | 2,322 | 3.5 | 4 | ans = 0
def queens_rec(q_no, taken, taken_clone, diff_arr, main_board):
global ans
# print(taken_clone)
if q_no == 2:
ans += 1
# print(taken , taken_clone)
for i in range(8): # loop for the chess board
for j in range(8):
if main_board[i][j] != ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.