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
baabaa7e4f622dd093abba2b2fdb1b1f36b87edf
dagorret/curso_python
/expresiones_regulares.py
1,827
3.640625
4
import re cadena = "Vamos a aprender expresiones regulares en Python. Python es un lenguaje de sintaxis sencillo" texto_buscar = "Python" print(re.search("aprender", cadena)) if re.search(texto_buscar, cadena) is not None: print("Está") else: print("No está") texto_encontrdo = re.search(texto_buscar, caden...
6a8ef2ae827a7eda66957e88c95b03547115ee79
dagorret/curso_python
/bbdd_2.py
786
3.765625
4
import sqlite3 mi_conexion = sqlite3.connect("base3.db") cursor = mi_conexion.cursor() #cursor.execute("CREATE TABLE producto (nombre_articulo VARCHAR(50), precio INTERGER, seccion VARCHAR(20))") # cursor.execute("INSERT INTO producto VALUES('Balón', 15, 'Deportes')") # varios_productos = [ # ("Camiseta", 10, "...
27fa3e2f7445bd20e87c1cc54af7189be4c8cd0a
dagorret/curso_python
/modulos/modulo_vehiculos.py
1,548
3.78125
4
class Vehiculo(): def __init__(self, marca, modelo): self.marca = marca self.modelo = modelo self.en_marcha = False self.acelerar = False self.frenar = False def arrancar(self): self.en_marcha = True def acelerar(self): self.acelerar = True def...
278e2cd5e16c25a7d10221f533a0094ee82bc87d
Shadder2k0210/Douban
/test/testUrllib.py
2,477
3.734375
4
import urllib.request ''' # 获取一个get请求 response = urllib.request.urlopen("http://www.baidu.com") # urlopen对一个网址进行解析,返回给response print(response.read().decode("utf-8")) # 使用read()对封装起来的数据进行读取,decode("utf-8")转化成中文格式 ''' ''' # 获取一个post请求(httpbin.org):模拟用户真实登录时使用 import urllib.parse # 用于解析 data = bytes(urllib.parse.urle...
b86f0865dbad3330669cfb2fd317e988ed3c513f
xandhiller/pythonTutorials
/oop/closures.py
700
4.03125
4
# def outer_func(): # message = 'Hi' # # def inner_func(): # print(message) # # return inner_func # # my_func = outer_func() # # print(my_func) # # My func has been assigned inner_func, as you can see if you run the line below. # print(my_func.__name__) # Going to tweak the function, so recopying i...
34b635354da1a433f5a0ebc96a481141bf48f1be
Neeraj-Chhabra/Class_practice
/task2.py
454
4.125
4
def square_root(a): z=1 x=a/2 while(z==1): y = (x + (a/x)) / 2 if (abs(y-x) < 0.0000001): print(x) z=2 return(x) else: x=y # print("new value not final", x) # print(y) def test_square_root(a): return(math.sqrt(a)) root=int(input("enter the number for the squareroot")) import math d=square_...
43a335ed2b75669b0edd4b8aba6cfae6f242d1ab
orenlivne/euler
/euler/problem001.py
1,478
3.984375
4
''' ============================================================ http://projecteuler.net/problem=1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Created on Feb 19, 2013 @author...
22df80224e9c941ee382110faf5fe8a164b7f8e8
orenlivne/euler
/rosalind/pcov/rosalind_pcov.py
1,772
3.75
4
''' ============================================================ http://rosalind.info/problems/pcov A circular string is a string that does not have an initial or terminal element; instead, the string is viewed as a necklace of symbols. We can represent a circular string as a string enclosed in parentheses. For exampl...
c191101ace7fd816686817cc2796fe47b60c05e2
orenlivne/euler
/euler/problem113.py
1,150
3.84375
4
''' ============================================================ http://projecteuler.net/problem=113 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing...
3af6d87f9693ab9cf336096354d523052872dc7c
orenlivne/euler
/euler/problem024.py
1,426
3.609375
4
''' ============================================================ http://projecteuler.net/problem=24 A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographi...
8f98e73be9890a344886c8674e0d63071e9d158c
orenlivne/euler
/euler/problem059.py
3,359
3.8125
4
''' ============================================================ http://projecteuler.net/problem=59 Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107. ...
ba20456c810467f10d52ad79612670ee4adb2efd
orenlivne/euler
/thread/multiprocess4.py
1,013
3.609375
4
''' ============================================================ http://stackoverflow.com/questions/4413821/multiprocessing-pool-example Created on Mar 6, 2013 @author: Oren Livne <livne@uchicago.edu> ============================================================ ''' from multiprocessing import Pool from time import tim...
157620b39c92d70f5e47ae32610afdd8502a27c0
orenlivne/euler
/rosalind/maj/rosalind_maj.py
1,069
3.8125
4
''' ============================================================ http://rosalind.info/problems/maj An array A[1..n] is said to have a majority element if more than half of its entries are the same. Given: A positive integer k<=20, a positive integer n<=104, and k arrays of size n containing positive integers not exce...
1bac883b636862718a55f2614b29d6ef7881f507
orenlivne/euler
/rosalind/rna/rosalind_rna.py
526
3.625
4
#!/usr/bin/env python ''' ============================================================ http://rosalind.info/problems/rna/ Given: A DNA string t having length at most 1000 nt. Return: The transcribed RNA string of t. ============================================================ ''' from rosalind.rosutil import read_str...
394fff8ca5e8c885fec3326baaa1b9859ca2aefc
orenlivne/euler
/euler/problem085.py
1,345
3.6875
4
''' ============================================================ http://projecteuler.net/problem=85 By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles: Although there exists no rectangular grid that contains exactly two million rectangles, find the area of the gr...
7dd432b4d68ea92d634c136a2558a493300e0fc6
orenlivne/euler
/rosalind/sims/rosalind_sims.py
1,893
3.609375
4
''' ============================================================ http://rosalind.info/problems/sims Given a string s and a motif t, an alignment of a substring of s against all of t is called a fitting alignment. Our aim is to find a substring s' of s that maximizes an alignment score with respect to t. Note that mor...
f99a1f4e078a8e8e74466231a7ee6126b66fdec4
orenlivne/euler
/ober-examples/extract_rows2.py
1,913
3.859375
4
#!/usr/bin/env python ''' ============================================================ Extract a subset of rows from a file whose numbers are read from an index file. Created on Jun 28, 2012 Tab-delimited, stdin support on July 2, 2012 @author: Oren Livne <livne@uchicago.edu> ==========================================...
cc4ef51c5b41c307cabda9dc984c2cfd1e6e80dd
orenlivne/euler
/checkio/checkio_waterjars.py
5,866
4.125
4
''' ============================================================ You stand by the edge of a lake with two empty jars. You notice that both of the jars have a volume. You can fill each jar with water from the lake, pour water from one jar to the other or pour water back into lake. You should measure the volume of water ...
017c4b87dbcfd19a6a05fbd497778528ec25c191
orenlivne/euler
/euler/problem036.py
2,184
3.53125
4
''' ============================================================ http://projecteuler.net/problem=36 The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that the palindromic number, ...
e7484dd0b0843367a3f252f8184bf1d053a6eb14
orenlivne/euler
/euler/problem297.py
1,644
3.546875
4
''' ============================================================ http://projecteuler.net/problem=297 Each new term in the Fibonacci sequence is generated by adding the previous two terms. Starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89. Every positive integer can be uniquely writt...
13e4ebe963267ea900c75a0a7bcd06e6b7133a8e
orenlivne/euler
/rosalind/nkew/rosalind_nkew.py
2,031
3.53125
4
''' ============================================================ http://rosalind.info/problems/nkew In a weighted tree, each edge is assigned a (usually positive) number, called its weight. The distance between two nodes in a weighted tree becomes the sum of the weights along the unique path connecting the nodes. To ...
ae7755d6f372500d053c37eb23826e7ee1c9549a
orenlivne/euler
/algorithms/concurrent.py
3,295
3.671875
4
''' ============================================================ Demo of concurrency using multiprocessing. ============================================================ ''' import sys, time, random from multiprocessing import Manager, Process def produce(identifier, buf, lock, num_items): lock.acquire() sys.st...
6ad35adf49c817490d51cc13e4fa878056755d1b
orenlivne/euler
/rosalind/full/rosalind_full.py
1,797
3.8125
4
''' ============================================================ http://rosalind.info/problems/full Say that we have a string s containing t as an internal substring, so that there exist nonempty substrings s1 and s2 of s such that s can be written as s1ts2. A t-prefix contains all of s1 and none of s2; likewise, a t-...
823f8065cff778f517585110821d7779de61262f
orenlivne/euler
/euler/problem083.py
3,824
3.671875
4
''' ============================================================ http://projecteuler.net/problem=83 OTE: This problem is a significantly more challenging version of Problem 81. In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by moving left, right, up, and down, is indicated in ...
6eda6c17dfc6d5c011a84a3902a7099178b5a0e7
orenlivne/euler
/algorithms/riddler_random_houses.py
2,974
4
4
''' The misanthropes are coming. Suppose there is a row of some number, N, of houses in a new, initially empty development. Misanthropes are moving into the development one at a time and selecting a house at random from those that have nobody in them and nobody living next door. They keep on coming until no acceptable ...
72ec7a0939420d56ffd01c275f281ffc70894b01
orenlivne/euler
/euler/problem073.py
1,796
3.75
4
''' ============================================================ http://projecteuler.net/problem=73 Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called a reduced proper fraction. If we list the set of reduced proper fractions for d 8 in ascending order of size, we get:...
d66224e0e2ad7b3c5fd04bf83d5ec47a359a3b9a
orenlivne/euler
/rosalind/sexl/rosalind_sexl.py
1,599
4.03125
4
''' ============================================================ http://rosalind.info/problems/sexl The conditional probability of an event A given another event B, written Pr(A|B), is equal to Pr(A and B) divided by Pr(B). Note that if A and B are independent, then Pr(A and B) must be equal to Pr(A)xPr(B), which res...
003341a60ba1757f431a78c02ebd44cf9d8d2fbb
orenlivne/euler
/rosalind/sort/rosalind_sort_graph.py
4,866
3.984375
4
''' ============================================================ http://rosalind.info/problems/sort A reversal of a permutation can be encoded by the two indices at the endpoints of the interval that it inverts; for example, the reversal that transforms (4,1,2,6,3,5) into (4,1,3,6,2,5) is encoded by [3,5]. A collecti...
e342aeba399d172bd165305281424a5e95ed7948
orenlivne/euler
/rosalind/aspc/rosalind_aspc.py
931
3.71875
4
''' ============================================================ http://rosalind.info/problems/aspc In "Counting Subsets", we saw that the total number of subsets of a set S containing n elements is equal to 2n. However, if we intend to count the total number of subsets of S having a fixed size k, then we use the com...
889978e066392aaf1de6fcb178f22e1d9f44f007
orenlivne/euler
/rosalind/sort/rosalind_sort.py
3,561
4.09375
4
''' ============================================================ http://rosalind.info/problems/sort A reversal of a permutation can be encoded by the two indices at the endpoints of the interval that it inverts; for example, the reversal that transforms (4,1,2,6,3,5) into (4,1,3,6,2,5) is encoded by [3,5]. A collecti...
9ce6840e49be7c1cceb123c4ed6c6cba273ec99a
orenlivne/euler
/euler/problem158.py
3,159
3.8125
4
''' ============================================================ http://projecteuler.net/problem=158 Taking three different letters from the 26 letters of the alphabet, character strings of length three can be formed. Examples are 'abc', 'hat' and 'zyx'. When we study these three examples we see that for 'abc' two cha...
bec45309121a94713a587bff02b5f153a71d5c16
orenlivne/euler
/rosalind/indc/rosalind_indc.py
1,673
4
4
''' ============================================================ http://rosalind.info/problems/indc Consider a collection of coin flips. One of the most natural questions we can ask is if we flip acoin 92 times, what is the probability of obtaining 51 "heads", vs. 27 "heads", vs. 92 "heads"? Each coin flip can be mod...
71edbc023ff08f2858274d0d5b11587c350f9d0e
orenlivne/euler
/euler/problem112.py
1,663
3.796875
4
''' ============================================================ http://projecteuler.net/problem=112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing ...
1fb0fe51ce7abc99b9f217338667cb5df83e980e
orenlivne/euler
/euler/problem129.py
2,382
3.5
4
''' ============================================================ http://projecteuler.net/problem=129 A number consisting entirely of ones is called a repunit. We shall define R(k) to be a repunit of length k; for example, R(6) = 111111. Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there...
d540967008be0ab9d3d6443e03d17cddb3185f94
orenlivne/euler
/euler/problem173.py
1,138
3.859375
4
''' ============================================================ http://projecteuler.net/problem=173 Problem 173 We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can form two d...
b7dfb9435d6a8988061a7dd386541eea55834fc7
orenlivne/euler
/thread/compute_threaded.py
1,013
3.921875
4
#!/usr/bin/env python '''Sum up the first 100000000 numbers. Time the speed-up of using multithreading.''' import threading, time, numpy as np class SumThread(threading.Thread): def __init__(self, a, b): threading.Thread.__init__(self) self.a = a self.b = b self.s = 0 def run(s...
ac814c1754bc72360b2c8ba6d757de88a549038e
orenlivne/euler
/yoni/tennis.py
3,274
3.59375
4
'''Nick has a terrible sleep schedule. He randomly picks a time between 4 AM and 6 AM to fall asleep, and wakes up at a random time between 11 AM and 1 PM of the same day. What is the probability that Nick gets between 6 and 7 hours of sleep?''' import random, numpy as np, matplotlib.pyplot as P def toss(p): '''R...
279d87ccd5d2df01a01da97ca4cbbf29a48d8dc0
orenlivne/euler
/euler/problem109.py
3,039
3.671875
4
''' ============================================================ http://projecteuler.net/problem=109 In the game of darts a player throws three darts at a target board which is split into twenty equal sized sections numbered one to twenty. (cf. website for figure) The score of a dart is determined by the number of t...
2dc68acdca7bfe4f757c33c6beca2982d0586312
orenlivne/euler
/rosalind/1g/rosalind_1g.py
679
3.734375
4
''' ============================================================ http://rosalind.info/problems/1g Find the most frequent k-mers with mismatches in a string. Given: A string Text as well as integers k and d. Return: All most frequent k-mers with up to d mismatches in Text. ============================================...
4afffdb445999571065f4eccdacf203c94cfb87f
orenlivne/euler
/rosalind/iev/rosalind_iev.py
1,997
3.578125
4
''' ============================================================ http://rosalind.info/problems/iev The Need for Averagesclick to expand Problem For a random variable X taking integer values between 1 and n, the expected value of X is E(X)=SUM nk=1kxPr(X=k). The expected value offers us a way of taking the long-term ...
d03e7c261d4ba9ab4ab51e19f46ea04e1f9c8f8e
orenlivne/euler
/euler/problem037.py
1,876
3.625
4
''' ============================================================ http://projecteuler.net/problem=37 The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to...
f5e365e062a91c9d49f9e04b13c323f97fc4e606
orenlivne/euler
/rosalind/1f/rosalind_1f.py
786
3.984375
4
''' ============================================================ http://rosalind.info/problems/1f Find all approximate occurrences of a pattern in a string. Given: Two strings Pattern and Text along with an integer d. Return: All positions where Pattern appears in Text with at most d mismatches. ====================...
cd2063fe55b756b6e477227ca77a3be45d976a69
orenlivne/euler
/euler/problem102.py
1,619
3.984375
4
''' ============================================================ http://projecteuler.net/problem=102 Three distinct points are plotted at random on a Cartesian plane, for which -1000 x, y 1000, such that a triangle is formed. Consider the following two triangles: A(-340,495), B(-153,-910), C(835,-947) X(-175,41),...
5d4c8b766a5c7bfe7e9636fc61bbeb2447efbc51
Tyler-Wafkowski/Package-Delivery-System
/hash_table.py
2,096
3.8125
4
class HashTable: # O(1) # modified from zybooks hash example def __init__(self, capacity = 10): self.map = [] for i in range(capacity): self.map.append([]) def _get_hash(self, key): buck = int(key) % len(self.map) return buck # O(n) -> a...
c223233b80b681dfe837b1a641ac9d3fba98a021
ypandya614929/COMP-6411-Assignment-1
/server.py
14,369
3.734375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # ----- Program Details ----- # For Initial data read from the file only age field validation is applied. No phone number validation is added. # Program works in Case Sensitive manner. # Server only returns the data/errors all printing related commands are operated by client. ...
b2cdf59fe9fd14012c93ed93b502dc42dc205985
ovr1/test_hw_18
/test5_finish_set/set_igra.py
715
3.75
4
namber_n = [] namber_s = [] namber_sh =[] namber_c = [] def check_set(cards): for card in cards: if card[0] not in namber_n: namber_n.append(card[0]) if card[1] not in namber_s: namber_s.append(card[1]) if card[2] not in namber_sh: namber_sh.append(card[2...
a271ae1c6f22fa69338c19e7ae7a7fe1c9d1a0e1
ddudon/google_it_automation
/Returning Values.py
993
3.96875
4
def triangle_area(base, height): return (base * height) / 2 area1 = triangle_area(5, 4) area2 = triangle_area(7, 3) sum1 = area1 + area2 print("The sum of two areas is:", sum1) print("The sum of two areas is: " + str(sum1)) # Use the get_seconds function to work out the amount of seconds in 2 hours and 30 minut...
9a51fc48d411fccb9b9897fd20efe9b18f755c62
ddudon/google_it_automation
/Common Errors in for Loops.py
364
3.953125
4
def is_valid_user(user): if len(user) > 3: return True else: return False def validate_users(users): for user in users: if is_valid_user(user): print("The username:", user, "is valid.") else: print("The username:", user, "is invalid") validate_user...
0be9b980f3815dfb3a6f8db3f604e3a81ea23c79
viseshrp/Blood_e_Merry
/loginsignup/threadtest.py
1,060
3.875
4
import threading import time class ThreadingExample(object): """ Threading example class The run() method will be started and it will run in the background until the application exits. """ def __init__(self, interval=1): """ Constructor :type interval: int :param interval:...
353ccf83f96fc0997d32d8e15ad9f97ba6f5089a
lcfsluiz/520
/estudo/nascimento.py
312
3.796875
4
#!/usr/bin/python/3 meses = ('janeiro', 'feveiro', 'março', 'abril', 'maio', 'junho', 'julho', 'julho', 'agosto', 'setembro', 'outrubro', 'novembro', 'dezembro') data_nasc = input('Digite sua data de nascimento DD-MM-AAAA: ') indice = int(data_nasc[3:5]) mes = meses[indice] print('você nasceu no mês' ,mes)
cdc94e288eb7008e9a1b5476661bfee79e3e7823
lcfsluiz/520
/Aula5/dog.py
857
3.609375
4
class Dog(): def __init__(self, nome, raca,idade): self.nome = nome self.raca = raca self.idade = idade self.energia = 5 def latir(self): print(self.nome) print('AUauauauau.....') def dormir(self): self.energia = 5 print('ZZZZZZZZZZZ...
37eda14e7c94e09ee759be7bfd95f062dac8cedf
flambuth/checkbook
/checkbook.py
4,257
3.734375
4
#!/usr/local/anaconda3/bin/python import json #there should be a json file in the same directory as this py file with the JSON representation #of the dictionary loaded a few lines down. json_file = 'customers.json' with open(json_file, "r") as f: customers = json.load(f) # the bank of users for testing. 2 dicts ...
b2992db12099350f52521fb7c1d63b8870a5a380
nicKLas-317/python
/tests/passage.py
775
3.71875
4
def f(obj): print(f"Entrée dans f : {id(obj)} = {obj}") obj += "LULU" print(f"Sortie de f : {id(obj)} = {obj}") #Immutable obj = "toto" print(f"Immutable avt passage : {id(obj)} = {obj}") #@1 = toto f(obj) #@1 = toto ...
c9520247814edb07b4c184c4f5f7f050a2addcf1
reywridyll/potential-fiesta
/Message Encrypt and Decrypt.py
3,273
3.65625
4
""" ©owner Rey Created -- 11/22/17 Version 1.1 Application that encrypts and decrypts a message """ # import from tkinter import * from tkinter.ttk import * import random import string #import end // class messageEncrypter(): """Encryter class: window >> Tk() """ ...
f8f5f5374494d6f3b06fda4905fccb403725b8f1
priyapriyam/dictionary_questions
/dict_multiply.py
188
3.703125
4
students={"orange":9,"pineapple":8,"mangoes":7,"apple":3,"grapesh":4} a= (students.values()) print a i=0 multiply=1 while i<len(a): multiply=multiply*a[i] i=i+1 print multiply
e13873c2873537467a674153ba946764cd9523d0
RayNieva/Python
/buggyAddingProgram.py~
308
3.8125
4
#!/usr/bin/env python print('Enter the first number to add:') first=input() print('Enter the second number to add:') second=input() print('Enter the third number to add:') third=input() print('The sum is ' + first + second + third) """ def main(): pass if __name__ == '__main__': main() """
1dcbe5cc7a1e35a3562e6d4545a3d5527fbc00cf
RayNieva/Python
/ex5.py~
707
4.0625
4
#!/usr/bin/env python def main(): my_name='Zed A. Shaw' my_age=35 # not a lie my_height=74 # inches my_weight=180 # lbs my_eyes ='Blue' my_teeth='White' my_hair='Brown' print(f"Lets's talk about {my_name}.") print(f"He's {my_height} inches tall.") print(f"He's {my_weight} pound...
957f9d07d4306d5613e48543d576210f5cb2bc57
RayNieva/Python
/ex7.py~
350
3.578125
4
#!/usr/bin/env python def main(): print("Mary had a little lamb.") print("Its fleesce was white as snow") print("And everywhere that Mary went.") print("." * 10) # what'd that do ? end1 end2 end3 end4 end5 end6 end7 end8 end9 end10 end11 end12 if __nam...
30822abe9cc556240dca0da5ade9f60371c89676
RayNieva/Python
/printTable.py
2,165
4.4375
4
#!/usr/bin/env python """Project Table Printer Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings. For example, the value could look like this:""" ...
71c591fc1972ead0976ad147d617fa9827c373b1
RayNieva/Python
/ex2.py
502
3.96875
4
# A comment, this is so you can read your program later. # Anything after the # is ignored by python. print("I could have code like this.") # and the comment after is ignored # You can also use a comment to "disable" or comment out code: # print("This won't run.") print("This will run.") print('This will run too.')...
76c56f563b41937af38bfa358c36eefe60f5e6ea
slava-sh/delorean.codes
/3-the/scratch/brute2.py
1,059
3.609375
4
import json import random from decode import Decoder def main(): #with open('known.json') as reader: with open('examples.json') as reader: examples = json.load(reader) words = set() for example in examples: codeword = example['codeword'] words.update(codeword.split()) print(...
a188341667a1730a337be27abb5916c98bb80810
HomingYuan/Core-python-programming
/ex1.py
2,874
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 2.1 变量 str='ABC' num=13 num str print str print num print '%s' %str print '%d'%num #2.2 运算 #(a)验证加减乘除 #(b)9 #(c)不一样,运行脚本的话,无返回值 #(d)程序返回9,运行脚本,无返回值 #(e)按下面方法改进 print 1+2*4 #2.3 自己练习即可 #2.4数值和操作符 #(a) str2=raw_input('Enter the str:') print str...
3cb3ed21b2f9a8f64e6cb78e9ad7a224ec6544ba
Delyear/PerfCat-0609
/Test.py
3,413
3.5625
4
from typing import List class Solution: #48 最长不含重复字符的子字符串 def lengthOfLongestSubstring(self, s: str) -> int: if not s: return 0 d = {} length = len(s) tmp = 1 for i in range(0, length): count = 0 for k in range(i, length): ...
8c781de72c71d1dc2051a9edd105a1b9d2008f8a
sim-mautner/cs1010-21t3
/lectures/04-python-in-the-real-world/02-lib-demo/user.py
162
3.703125
4
import calmath if __name__ == '__main__': day = int(input("Enter day: ")) month = int(input("Enter month: ")) print(calmath.days_into_year(month, day))
a885b60da30f43ad0271f9fd1de92498ff57fe35
sim-mautner/cs1010-21t3
/lectures/04-python-in-the-real-world/01-examples/01-tic-tac-toe.py
778
3.578125
4
# Put your imports here # Put your constants here PLAYER_0 = 'X' PLAYER_1 = 'O' BOARD_SIZE = 5 # Functions def print_board(board): for row in board: #print(row) for cell in row: print(cell + ' ', end='') print('\n') def create_board(): board = [] for row in range(BOARD_S...
c5aa7f6e78c6b9a58d8b882426b1bd72b2891b0b
gayathrimaganti/maganti_gayathridevi_spring2017
/Python Assignment-3/Q3_Part_1.py
1,627
3.953125
4
# coding: utf-8 #CRICKET MATCHES ANALYSIS #1.Calculate the average score for each team which host the game and win the game. #2.Remember that if a team hosts a game and wins the game, their score can be innings_1 runs or innings_2 runs. You have to check if the host team won the game, check which innings they played...
e8cfa4c11c4cad81cfe4ada4bb5726389efba4ff
dgoffredo/hackerrank
/non-divisible-subset/count-mods.py
1,852
3.984375
4
"""count-mods This solution is based on the first comment (as of this writing) in the "discussion" section of the problem. The key observation is that the sum of two numbers is divisible by k if and only if the sum of their remainders (mod k) is k or zero. So, since we need find only the _size_ of the larg...
828d3a87fefe9aaf7ca46430cb537200e403a4a3
AChelikani/Codenames
/card.py
1,121
3.9375
4
from enum import Enum class Card(object): ''' Card value class storing codename word, status, and board position. The game deck is composed of cards. ''' def __init__(self, word, position): # Word assigned to this card self.word = word # Status of card # EMPTY, RED...
b8a08640515eb1038bc100307e1cfad211d601b5
ckapoor7/misc-python
/subpalindrome.py
1,492
4.09375
4
"""A naive approach to find a sub-palindrome in a string would be to run three loops to determine our result. Quite obviously, a O(n^3) approach isn't the most efficient way to solve this problem. Here, I attempt to try a more efficient algorithm.""" def grow(text, start, end): """Start with a 0- or 1- le...
b42f06b6b2b377714dbecf07ced8e20145608ead
JECBello/Python-for-Data-Science-and-ML-Coursework
/Recommender Systems/basic_rec_sys.py
2,558
3.625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline sns.set_style('whitegrid') # create dataframe from data colum_names = ['user_id','item_id','rating','timestamp'] df = pd.read_csv('u.data', sep='\t', names = colum_names) movie_titles = pd.read_csv('Movie_I...
aff9cd7b08778fb486c1c3228bfad33ac939f623
alan-haymarket/Algorithms-Leetcode-Python
/ExcelSheetColumnNumber.py
908
3.859375
4
""" # 171. Excel Sheet Column Number # Tags: Math # Difficulty: Easy Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 Credits: Special...
901916fa9f5ef01101d631ba52a33e0e153676f1
kokitrox/python
/actividad 3/ejercicio4.py
458
3.796875
4
## ejercicio 4 ## oscar ely avila lopez ## realizar promedio d en notas n = 0 suma = 0 print("bienvenidos al programa:) ".center(50,"-")) print ("ingresa las notas que deceas, ingrese 1 para detener el programa") cantidad = int(input("ingresa la cantidad de notas que podras:. ")) for i in range(cantidad): n = int...
3a0566092552d47bced3919a9f676afe0e484c48
sudhakumari2/function
/sum of the number.py
245
4.09375
4
def sum(numbers): total = 0 for x in numbers: total += x return total print(sum((8, 2, 3, 0, 7))) def multiply(numbers): total=1 for x in numbers: total*=x return total print(multiply((1,3,4,2,)))
4a17efe7dd98a1fa4193110ba271ff269c0d2d7d
sudhakumari2/function
/atm 2.py
1,503
3.890625
4
def atm(): print("wecome to the ICICI ","\U0001f600") language=int(input("enter a language = ")) if language==1: print("Hindi") elif language==2: print("English") atm() def pin(): chances=0 while chances<3: pin=int(input("enter the pin")) if pin==1234: ...
66f06bb92ae36762ccb81fcf93c0b9f32c582168
sudhakumari2/function
/calculator.py
243
3.96875
4
def calculator(a,operation,b): if operation=='+': c=(a+b) elif operation=='-': c=(a-b) elif operation=='*': c=(a*b) elif operation=='/': c=(a/b) else: print('nothing') return c print(calculator(4,'+',6)) Calculator in function
e35dba6eb5d85d7ba4d59bfa9462ec431b82f658
sudhakumari2/function
/unique_number.py
192
3.546875
4
def unique_num(list): i=0 a=[] while i<len(list): if list[i] not in a: a.append(list[i]) i+=1 return a print(unique_num(list= [1,2,3,3,3,3,4,5]))
3b18ed4336bc13c0113d9e150a79185375dc3fcf
neildegrassepython/Project-Euler
/problem-two.py
400
3.828125
4
# Script to find the sum of all even numbers in the fibonacci sequence # under 4,000,000 fib_seq = [0, 1] # The Sequence fib_sum = 0 # The end goal! while fib_seq[-1] < 4000000: fib_seq.append(fib_seq[-1] + fib_seq[-2]) for i in range(0, len(fib_seq)): if fib_seq[i] % 2 == 0: # If it divides by two with no r...
510fb3a48b8da477c0149de4f7b440d1ecb64796
omiroshn/Belowed42Api
/BibleParser.py
319
3.5
4
class BibleParser(): file = 'bible.txt' bible = [] def readBible(self): with open(self.file) as f: for line1, line2 in zip(f,f): line1.rstrip() line1 += line2 self.bible.append(line1) f.readline() return self.bible
8be93fa079c49539a507f069b416d1bb069fbf92
3vikram/Advanced-Python
/Practice Programs/ReverseList.py
709
3.953125
4
def Reversing(lst): list_length = len(lst)-1 first_index = 0 last_index = list_length while(True): if first_index != last_index and last_index > first_index: temp_memory = lst[first_index] lst[first_index] = lst[last_index] lst[last_index] = temp_memory ...
7891c1a17343c8eeafba4e7d1b870d70786258fd
PashaEagle/Sharaga
/Sharaga_3kurs/Algos/me/labs/labs/lab02_shaker.py
432
3.53125
4
from precompile import * print("*************** BUBBLE++ SORT *****************\n\n") left = 0 right = len(ls) - 1 while left <= right: for i in range(left, right, +1): if ls[i].mark < ls[i + 1].mark: ls[i], ls[i + 1] = ls[i + 1], ls[i] right -= 1 for i in range(right, left, -1): ...
0be01568bbd5b5507f65c17d95a0445fa5ced3f2
fjcrodriguez/USF-MSAN-2016-fcalderonrodriguez
/images/denoise2.py
482
3.671875
4
from filter import * ''' the median of a list given :param list ''' def median(data): sorted_list = sorted(data) idx_len = len(sorted_list) - 1 # length of list in zero index if len(sorted_list) % 2 == 0: first_num = sorted_list[idx_len/2] second_num = sorted_list[idx_len/2 + 1]...
14e39600a1b69d2a1657443e58830f01c200f436
m1cr0naut/Parser
/parser.py
2,171
3.890625
4
# Plotkin, Benjamin # 31st January, 2016 # using Python's regular expressions library import re # my RE patterns could be further refined, this is a simple exercise ### decimal RE pattern ### # can either be a single zero, or any integer with a non-zero leading digit; no # other characters are allowed except leading...
b2f66144e62ca5b743705cd7d49836a43747fc27
anhphuong2510/PythonA9
/test.py
694
3.890625
4
class Person: def __init__(self, name, age, male): print("Class person được khởi tạo!") self.name, self.age, self.male = name, age, male def getName(self): print("Name: %s" %(self.name)) def getAge(self): print("Age: %d" %(self.age)) def getMale(self): ...
47dc6d4adeb72ce9e61d89cc855c0571c72175a4
joleen-tang/university-projects
/Python/DivideConquerMultiplication.py
244
3.96875
4
def binString(string): string=binString.split() for char in string: char=int(char) #Given a string denoting a number in binary def DCMult(string): n=len(string) if n==1: return string d=n//2 u=string[:d]
de803f8c75e5c9f943cca0e9e6b09cdb0cd51e0d
Android4567/Python
/fabonacci.py
377
4.0625
4
firstvalue = 0 secondvalue = 1 num = int(input("Enter a number => ")) if num <= 0: print("not possible") elif num == 1: print(firstvalue) else: print(firstvalue) print(secondvalue) for i in range(2,num): thirdvalue = firstvalue + secondvalue print(thirdvalue) fir...
3652c8584ff038a55900f359bfa651045ca46298
Android4567/Python
/area of triangle.py
166
3.890625
4
# To Calculate the area of triangle heigth = int(input("enter the heigth value")) base = int(input("Enter The base value ")) total = 1/2*base*heigth print(total)
ad1fe8f831423ded2b8ce12f34cfdab4229077bc
karanrajpal14/feature-request-tool
/frt/quiz.py
1,054
3.515625
4
# Solution to quiz 1 message = [104, 116, 116, 112, 115, 58, 47, 47, 101, 110, 103, 105, 110, 101, 101, 114, 105, 110, 103, 45, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 46, 98, 114, 105, 116, 101, 99, 111, 114, 101, 46, 99, 111, 109, 47, 113, 117, 105, 122, 47, 105, 112, 108, 115, 106, 102, 107, 102, 107, 11...
e52f144e95ad627d39e6be83f31a1f6dd3c8685e
jefedeltejas/pythonMasterClass
/sumLoop.py
168
3.9375
4
#sumNums = range(1, 12) sumNums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] total = 0 for num in sumNums: total += num print("Here's yer total sum of nums", total)
cf52d02c6c4871682263f51cb93039cfde246286
watsondeservescredit/assignment2
/ba1k.py
1,351
3.671875
4
def SymbolToNumber(s): if s == 'A': return 0 elif s == 'C': return 1 elif s == 'G': return 2 elif s == 'T': return 3 #recursive function to convert PatterntoNumber def PatterntoNumber(Pattern): if Pattern == "": return 0 symbol = Pattern[-1:] prefix = Pattern[:...
8ce94c6241115b7d52642454bd46d1f6a157d3d6
Sxlly/CWA-Solver
/CWA.py
983
4.0625
4
import time """ Give integer for number of units completed """ num_units = int(input("Number of Units Taken: ")) def CWA(num_units): weight = 0 creds = 0 for ii in range(1, num_units + 1): time.sleep(0.3) unit_mark = int(input("Enter Unit Mark w/o %: ")) print("~~~~~") t...
65a240edef849ffd9d6aaf80663e46d138681e12
menpo/menpo3d
/menpo3d/checks.py
3,728
3.828125
4
import collections import numpy as np def check_max_iters(max_iters, n_scales): r""" Function that checks the value of a `max_iters` parameter defined for multiple scales. It must be `int` or `list` of `int`. Parameters ---------- max_iters : `int` or `list` of `int` The value to chec...
6aca3e626fde3c3d4c26491051a7a51ec05517ce
babyvox0621/catkin_ws
/src/crane_plus_src/src/test_arm_tenkey4.py
2,090
3.625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- import rospy import move_arm_v1 as move_arm class test_arm: def __init__(self): #################### #move_arm呼出し self.arm=move_arm.move_arm() self.arm.x=0.0 self.arm.y=0.2 self.arm.z=0.1 self.arm.wrist_arg=0....
bda88a0672a6f2f3d76e117ff6b4639bcd367d91
zubi16/python_basics
/zubi.py
163
3.546875
4
a=input("enter your name: ") b=input("enter your clg name: ") c=float(input("enter your cgpa: ")) print('i am :',a, 'studying in :',b ,'& i have cgpa of :',c)
33e543fef86463c2fb9b2075d5e5d6572643bae1
viksesh/cspAI
/mp3-code/solve.py
2,056
3.984375
4
import numpy as np def solve(constraints): """ Implement me!!!!!!! This function takes in a set of constraints. The first dimension is the axis to which the constraints refer to. The second dimension is the list of constraints for some axis index pair. The third demsion is a single constraint of t...
272502825ac02b1029b6386dbfa98277626f3653
JrVerbiest/Udacity_Intro_to_Programming_Nanodegree
/Code Your Own Quiz/fill-in-the-blanks.py
1,095
3.75
4
""" Project: fill in the blanks Author: J. Verbiest Last update: 17 December 2017 Note: written in Python 3 """ import myquiz as mq # The quotes quote = [[[" __1__ is like a __2__ of __3__, you never know what you gonna get. \n Forrest __4__"], ['Life','box','chocolates','Gump']], [[" Your __1__ is...
4126e4f84ff5b8dbbf4d87a22a13d5333a302642
FromSaffronCity/rosalind-franklin-challenge
/algorithmic-heights/algorithmic_heights.py
1,601
4.09375
4
def fibonacci_numbers(n): if (n == 1) or (n == 2): return 1 temp_1 = 1 temp_2 = 1 for i in range(3, n+1): temp = temp_2 temp_2 = temp_1+temp_2 temp_1 = temp return temp_2 def insertion_sort(array): number_of_swaps = 0 for i in range(1, len(...
3a781b3915d2dcc83c7fb4d21cfd78d70842e471
edmarques11/Forca-Python
/admin.py
11,787
3.5
4
import lib.util as util temas = [] historico = ['Home', 'Administração'] titulo = "administração do sistema" def listar_palavras(tema, origem='listagem'): palavras = util.carregar_palavras(tema) util.clear() util.cabecalho(titulo, historico) if len(palavras) == 0: print('NÃO HÁ PALAVRAS CADASTRADAS NE...
cd7ce1b61e2223f77e45a8ff3960dcf8114b40fa
european-54/python_algos_gb
/Урок 4. Практическое задание/task_3.py
1,326
4.3125
4
""" Задание 3. Приведен код, формирующий из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Сделайте профилировку каждого алгоритма через cProfile и через timeit Сделайте вывод, какая из трех реализаций эффективнее и почему """ def revers(enter_num, revers_num=0): if enter_num == 0: ...
a86ca92482490d40103e280b3d46d99a51e64c39
webclinic017/trading-13
/src/ibapi/pandas-test.py
429
3.890625
4
import sys import os import pandas as pd print("HW") import pandas as pd # initialise data of lists. data = {'Name': ['Tom', 'nick', 'krish', 'jack'], 'Age': [20, 21, 19, 18]} # Create DataFrame df = pd.DataFrame(data) # Print the output. print(df) def f(x): if int(x) >= 21: y = 'Normal Employ...
47ee9982510d02e4ef7d99346ed379fc6f7b5991
milenalh/MC102
/lab09.py
3,683
3.546875
4
##################################################### # MC102 - Algoritmos e Programação de Computadores # Laboratório 9 - Copa do Mundo de Futebol # Nome: Milena Lumi Hangai # RA: 184654 ##################################################### # Leitura da lista de seleções selecoes = [] dic = {} for i in rang...