blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8716699ba69ed9b8e5f9f3229d02cca9fc74453c
Joseph-Lux/Project-Euler-1
/Problem36.py
1,458
3.671875
4
# 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, in either base, # may not include leading zeros.) from stack import Stack def isPalind...
2f8cd0bb3a5e0b80659e3d1fb71749295372b44e
bhowmiks/Path_optimization_using_Simulated_Annealing
/simulated_annealing.py
3,247
3.625
4
import TSP_Model import json import numpy.random as random # see numpy.random module import matplotlib.pyplot as plt import matplotlib.image as mpimg """Read input data and define helper functions for visualization.""" # Map services and data available from U.S. Geological Survey, National Geospatial Program. ma...
7b66b11c962d131116a54369b3dea5c9393138e4
EarthSquirrel/squeaky-squirrel-programs
/pdf-image/rotate_pdf.py
1,510
3.859375
4
# https://www.geeksforgeeks.org/working-with-pdf-files-in-python/ import PyPDF2 def PDFrotate(origFileName, newFileName, rotation): # creating a pdf File object of original pdf pdfFileObj = open(origFileName, 'rb') # creating a pdf Reader object pdfReader = PyPDF2.PdfFileReader(pdfFileObj) # cre...
e5edc181ee5a3965ec5c5c54b0487018f4d8135f
Hudaiguo/pytorch_learn
/torch_learning6_variable.py
2,562
3.640625
4
# -*- coding: utf-8 -*- """ @Time: 2020/6/4 10:08 @Author: Hudaiguo @python version: 3.5.2 """ #注:tensor不能反向传播,variable可以反向传播。 # 在torch中的Variable就是一个存放会变化的值的地理位置。里面的值会不停发生变化,就像一个装鸡蛋的篮子,鸡蛋数会不断发生变化。那谁是里面的鸡蛋呢,自然就是torch的Tensor了 import torch from torch.autograd import Variable # torch 中 Variable 模块 tensor = torch.Floa...
951f627b5be42af4c391897b1fa25bfa2925ec15
shaileshoptimizeq/Hackerrank-Problems
/library_fine.py
2,471
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 10 03:36:28 2015 Library Fine Problem Statement: The Head Librarian at a library wants you to make a program that calculates the fine for returning the book after the return date. You are given the actual and the expected return dates. Calculate the fine as follows: If t...
092e33afc7bd9c3db671a388f8b3692476ee3a27
ifedavid/GA-for-QAP
/Main.py
2,874
3.546875
4
import random from GeneratePopulation import Generate_Initial_Population from Mutation import Mutation_Function from Crossover import Crossover_Function from Selection import Selection_Function from Fitness import Cost_Function from utils import * import sys # genetic rep of solution chromosome = [1, 2, 3, 4, 5] # w...
7bcf9fc032658451663bb45bd29ba53deafe7674
wassen1/dbwebb-python
/kmom10/try1/exam.py
3,206
4.28125
4
#!/usr/bin/env python3 """ Write your code in this file. Fill out the defined functions with your solutions. You are free to write additional functions and modules as you see fit. """ def analyze_text(): """ Analyses the text for spaces, letters and specials """ import analyze_functions as an whil...
cc037aa9f5e078b7af55fd480978e5568dfe558b
wassen1/dbwebb-python
/kmom02/flow/while_true.py
777
4.03125
4
#!/usr/bin/env python3 """ Checking ammount of apples with while loop """ while True: user_input = input("Skriv in antal äpplen (eller q för avslut): ") if user_input == "q": print("Du är nu klar med att äta äpplen.") print("Hej då!") break else: try: number_of_a...
b440237ef1172ccb222c12d7ff362049901af55d
Octaith/euler
/euler040.py
653
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021... It can be seen that the 12th digit of the fractional part is 1. If dn represents the nth digit of the fractional part, find the value of the follo...
436033070876b5274f60aa621c6dc8337fc9d598
Octaith/euler
/euler099.py
1,025
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Comparing two numbers written in index form like 2^11 and 3^7 is not difficult, as any calculator would confirm that 211 = 2048 < 37 = 2187. However, confirming that 632382^518061 > 519432^525806 would be much more difficult, as both numbers contain over three million ...
ac54698a3be150b179b543e5f8a89ddf157c3f47
Octaith/euler
/euler050.py
1,133
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contain...
a523caa3d82e72c2f8d2cbf7a76504b7df4515dc
Octaith/euler
/euler020.py
471
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! ''' import time start = time.clock() def fact(n...
3d9a187785e53fbc038c235255db8c2cfe2c2ea4
Octaith/euler
/euler006.py
670
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' The sum of the squares of the first ten natural numbers is, 1² + 2² + ... + 10² = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)² = 55² = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and t...
78b0446263e4980ec42d5a577ea0a075b6e9275c
Octaith/euler
/euler029.py
723
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 2^2=4, 2^3=8, 2^4=16, 2^5=32 3^2=9, 3^3=27, 3^4=81, 3^5=243 4^2=16, 4^3=64, 4^4=256, 4^5=1024 5^2=25, 5^3=125, 5^4=625, 5^5=3125 If they are then placed in numerical order, with any repeats removed, w...
45fc6d6101121fa933333a236f42f088aaeede93
Octaith/euler
/euler034.py
531
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included. ''' import time import math start = time.clock() fac...
d409fea338c5d3d658cd6beffe709d2a03ad5763
maybemanolo/deeps
/churn_modeling/one_sample.py
1,221
3.671875
4
def one_sample(): import pandas as pd import numpy as np from preprocessing import preprocessing data = pd.read_csv("Churn_Modelling.csv") pre = preprocessing(data) scaler = pre[-1] geo = input("Geography: ") score = int(input("Credit Score:")) gender = input("Gender (m/f): ") age = int(input("Age: ")) ...
c4cbe163c8712b4ad647db2071984746583ad176
Nutpapat/Python_Lab
/py/letterfreq.py
382
3.71875
4
"""LetterFrequency""" def main(): """Frequency letter""" text = input().lower() dct = {} lst = [] for i in text: if i.isalpha(): dct[i] = text.count(i) for keys in dct: var = dct[keys] lst.append(var) lst.sort(reverse=True) for values in dct: ...
1016a8af85a47d654547755ddf1a3a973063081f
Nutpapat/Python_Lab
/py/RuleofThree.py
581
3.734375
4
#NUTPAPAT YOUYOUNG 60070024 """RuleofThree""" def main(): """This is Show Program Compare weight and price""" number_of_sizes = int(input()) bestprice = 1 bestweight = 1 for _ in range(number_of_sizes): price = float(input()) weight = float(input()) if weight/price > bestweig...
7ca35307b3e47ac9766cda3b13ebf845b5c0343d
Nutpapat/Python_Lab
/py/O21.py
146
3.765625
4
"""SUM""" def main(): """SUM""" num_n = int(input()) num = 0 for i in range(1, num_n + 1): num += i print(num) main()
6c0dbd7f2e6fd28efdcdc39cbcab00843f78e760
Nutpapat/Python_Lab
/py/029.py
520
3.765625
4
"""029""" def main(): """Triathlon""" num = int(input()) swim = 0 cycling = 0 run = 0 for _ in range(num): swim2 = float(input()) cycling2 = float(input()) run2 = float(input()) for _ in range(25600): swim += swim2 for _ in range(746): ...
be5422c5e4083d38ed5b6ee0c2359dd44acb70ec
Nutpapat/Python_Lab
/py/WeightStation.py
787
4
4
#NUTPAPAT YOUYOUNG 60070024 """PlanCDEFGHIJKLMNOPQRSTUVWXYZ""" def main(): """This is Show Program Check A sequence number three ascending and descending""" choose = input() number_1 = (float(input())) number_2 = (float(input())) number_3 = (float(input())) if: if number_1 < number_2 or ...
4bb051328ebef2ce524fc65fbdc69cbfa386f305
Nutpapat/Python_Lab
/py/Divide3Or5.py
239
4.21875
4
"""Divide3Or5""" def main(): """This is Show Program Find the sum of integers.""" number = int(input()) count = 0 for i in range(1, number+1): if i%3 == 0 or i%5 == 0: count += i print(count) main()
bc51d08501ebbecf5fb441acfba4c1a259a8488b
Nutpapat/Python_Lab
/py/H3.py
483
3.671875
4
"""What""" def main(): """What!!!""" alp = input() num = int(input()) print(' '*9+alp) print(' '*8+alp, alp) print(' '*7+alp, num, alp) print(' '*6+alp, str(abs(num-1))*3, alp) print(' '*5+alp, str(abs(num-2))*5, alp) print(' '*4+alp, str(abs(num-3))*7, alp) print(' '*3+alp, str(...
4ab01b294d881b6bb0ce54c2d613775454d51a99
Nutpapat/Python_Lab
/psit/PSIT/memory_fibo/fibo.py
289
4
4
"""Fibonacci_Memory""" dict1 = {0:0, 1:1} def fibonacci_mem(num): """Input number and checking by dictionnary""" if num in dict1: return dict1[num] res = fibonacci_mem(num-1) + fibonacci_mem(num-2) dict1[num] = res return res print(fibonacci_mem(int(input())))
d6ac3f87625b80bcda0fe96c8207076c07e5a936
Nutpapat/Python_Lab
/psit/PSIT/one two/OneTwo.py
256
3.796875
4
"""OneTwo Problem""" def one_two(number): """Return Sn number""" if number == 1: return str(1) elif number == 2: return 2 else: return str(one_two(number - 1)) + str(one_two(number - 2)) print(one_two(int(input())))
697f1d53fe0ee7a4d9b180e3645ef13c464b1de0
Nutpapat/Python_Lab
/psit/PSIT/direction/direction.py
1,259
4.03125
4
"""FourDirection Problem""" def direction(string): """Print Direction from input""" for loop in range(5): for word in string: if word == "U": up_direction(loop) elif word == "D": down_direction(loop) elif word == "L": le...
8402caff1ca14de439e9f3a4922c4b58e58acbb7
Nutpapat/Python_Lab
/psit/PSIT/flattern/flattern.py
383
3.875
4
"""Flatten problem""" import json def flatten_recursive(inlist): """Return flatten list from inlist.""" outlist = [] for item in inlist: if isinstance(item, list): outlist.extend(flatten_recursive(item)) else: outlist.append(item) outlist.sort(reverse=True) ...
f3ac6da8c7e63ebb81035fcb8fef24a122ec08e6
Nutpapat/Python_Lab
/py/Sequence XI.py
812
3.59375
4
"""Sequence XI""" def main(): """Sequence XI""" num = int(input()) num2 = 1 num_c = 2*num-2 num_3 = 0 for i in range(1, num+1): for j in range(1, i+1): print("%02d" %j, end=" ") for i in range(num2, num2+1): print(("%02d " %i)*num_c, end="") num2 +...
35a0f770905b0d6ee9a2b70f9d30e963ae5abf1a
Nutpapat/Python_Lab
/psit/PSIT/circle/circle.py
797
4
4
"""CircularPrime Problem""" def is_prime(number): """Return True if number is prime, false otherwise""" for num in range(2, int(number**0.5)+1): if number % num == 0: return False return True def circle_str(number): """switch char in string""" number = str(number) for num i...
5123c51998e6973176523bd207ea7e4aa6577451
Nutpapat/Python_Lab
/py/beachthedoor.py
442
3.59375
4
"""BreachTheDoor""" def main(): """cut word""" text = input()+" " wordchk = "" keep = "" alpha = "abcdefghijklmnopqrstuvwxyz" big = alpha.upper() check = alpha+big for i in text: if i in check: wordchk += i else: if len(wordchk) > 6: ...
255d87fd34047dba3896f3a5a09f53a9dc119347
gurbthebruin/CS-35L
/assignment6/ranfd.py
182
3.53125
4
import random import string length = 100 s = "q" while length > 0 : s += random.choice(string.ascii_letters + string.digits) s += " " s += '\n' length = length - 1 print(s)
b0e5d553ff1976b3ccc25f35eaacf748eb8b9cbc
ilmoi/stanford_algos
/Course2_Week4.py
864
3.546875
4
# sum must be between -10 and 10, inclusive # only distinct elems Test_A = [3,5,7,5,4,20] def count_matches(A): """Algo to count matches using hash tables. Implemented as per lecture slides. See algo1slides / Part 14.""" hash_table = {} for i in A: hash_table[i] = 0 print(hash_table) ...
c5e63e9fbe244b7ef2c464735a2ca123f5067771
ilmoi/stanford_algos
/Course1_Week2.py
8,486
4.4375
4
import json import random import math from copy import deepcopy import timeit def count_inversions(L): """Counts number of inversions in a number array. Implemented as per lecture slides. See algo1slides / Part 3.""" inversion_counter = 0 def count(L): if len(L) <= 1: return L ...
a7bacf4506f023e11d2303e6b667e56de37d4396
Linda-Stadter/AdventOfCode2020
/Day 3/solution.py
772
3.59375
4
input_path = "input.txt" def read_input(): with open(input_path, "r") as input_file: input_lines = input_file.readlines() input_lines.append("\n") input_lines = [x.strip() for x in input_lines] return input_lines def check_trees(slope_x, slope_y): trees = 0 pos_x...
20e00231953f7eb466caceba822fcdfeaffab1ab
pratikms/HackerRank
/Python/02. Basic Data Types/003. Nested Lists.py
561
3.828125
4
if __name__ == '__main__': students = [] for _ in range(int(input())): name = input() score = float(input()) students.append([name, score]) students.sort(key=lambda student: student[1]) students = list(filter(lambda student: student[1] != students[0][1], students)) try: ...
bf83638d344db62fc76d7bc927982df2ab33ff01
samullrich/crawl_project
/crawlIR.py
889
3.5
4
from ../crawler import QueueADT class Crawler: def __init__(self): pass def crawl(self,url,npages): # Take a url # Request the page using the requests library # http://docs.python-requests.org/en/master/ # Go through and find the links # BeautifulSoup Doc: htt...
187b04e67966cbb40d244bdbaf310b0ac60978c8
EvidenceN/Data-Structures
/stack/stack.py
2,382
4.375
4
""" A stack is a data structure whose primary purpose is to store and return elements in Last In First Out order. Data is added to tail, and taken from tail * Should have the methods: `push`, `pop`, and `len`. * `push` adds an item to the top of the stack. * `pop` removes and returns the element at the top of ...
6affde4038cf7e76170b04898f6dee720733f6ee
Lucass96/Python-Faculdade
/Python-LP/aula03/Exercicio02ApostilaAula03.py
477
3.6875
4
#a) se idade e maior que 60 idade = int(input('Qual a sua idade: ')) if (idade > 60): print('Voce tem direito aos beneficios.') #b) se dano e maior que 10 e escudo e igual a 0 dano = int(input('Quanto e o seu dano: ')) if (dano > 10): print('Voce esta morto!') #c) se pelo menos uma das variaveis booleanas n...
cae53060059793439a715460a59dd93f0209ae4d
Lucass96/Python-Faculdade
/Python-LP/aula02/VariaveisETipos.py
392
3.65625
4
# Variaveis, dados e seus tipos nota = 8.5 disciplina = 'Logica de Programacao e Algoritmos' print(nota) print(disciplina) print('Disciplina: ', disciplina,'. Nota:', nota) # Variavel logica a = 1 # a recebe 1 b = 5 # b recebe 5 resposta = a == b print(resposta) resposta = a != b print(resposta) # Variavel S...
ea772a9c1bd2226a2c33e02f562940d46ff07c79
Lucass96/Python-Faculdade
/Python-LP/Trabalho/Exercicio04.py
829
3.84375
4
from operator import itemgetter #Programa principal #FAZENDO PARA QUE AS INFORMACOES SEJAM INSERIDAS NO DICIONARIO VIA TECLADO codigo = {} lista = [] while True: terminar = int(input('Digite o codigo: ')) if terminar == 0: print('Encerrando o programa..') break #O programa encerra quando o us...
b5d4cde5b4ab99b13b78a2efaa6434a180e98ab7
Lucass96/Python-Faculdade
/Python-LP/aula04/Exercicio01ApostilaAula04.py
420
3.9375
4
#FOR #a) sequencia de prints com inteiros de 3 ate 12, com incluso 12 for i in range(3, 13, 1): print(i) #b) inteiros de 0 ate 9, excluindo 9, com passo de 2 for i in range(0, 9, 2): print(i) # while #a) sequencia de prints com inteiros de 3 ate 12, com incluso 12 i = 3 while (i < 13): print(i) i += ...
51e7e9f2a11dc5bbdc3aa41cdee1d3bcb66a8c1c
pierrel/document-labeling
/training/dataprep/codecs/word_codec.py
708
3.59375
4
import codecs class WordCodec(codecs.Codec): """ Encodes a unique string to a unique number """ def __init__(self): self.counter: int = 0 self.encode_map: dict = {} self.decode_map: dict = {} def encode(self, input: str, errors='strict') -> int: self.addWord(inp...
5a8fb6073a9e801cef1e8ec75b0096dc2a31847c
SerjVankovich/Algorithms
/huffman_algorithm.py
5,224
3.6875
4
class HuffmanTree: def __init__(self, value=None, priority=0): self.value = value self.priority = priority self.right = None self.left = None def set_right_and_left(self, right, left): self.right = right self.left = left def walk_to_encode(self, codes, acc="...
fc4b8088ff7f852bb26b953a6809fa50f68c26a3
bluefinch83/FE595_SKLearnAssignment
/Part2.py
914
4
4
''' Name: Part 1 for the SKLearn Assignment for FE Intro: This file should use K-means and the Iris or Wine data set to create a graph that visually displays how the total squared distance decreases as the number of clusters increases. Author: William Long Date : 11/22/2019 ''' from sklearn.datasets import load_iris ...
8b5040a4b231d192bddcb54036f9d4aa0cbdc225
kittylon/UVa
/pailander/462.py
2,867
3.671875
4
# suppose a function called main() and # all the operations are performed from sys import stdin POINTABLE = ['A', 'K', 'Q', 'J'] ACE = ('A', 4) KING = ('K', 3) QUEEN = ('Q', 2) JACK = ('J', 1) def main(): for line in stdin: hand = list((line.strip().split())) get_points(hand) def get_points(han...
2cc818f209631711cb243f06de2229de30c97f2d
lilblue2225/encryption-program
/fileEncrypt.py
3,273
4.5625
5
from cryptography.fernet import Fernet #this function takes a file of your choice and encrypts it's contents then #outputs it to a file, with the option of saving the key to a file as well. def encryptFile(): print ('Enter file name: ') fileName = input() #user enters name of file to be encrypted ...
ede4bd488509af4c61cd8395031236fbf245923c
kenanblackerby/Challenges
/AddArrayedNums.py
1,365
3.65625
4
# Given 2 numbers as a list of single digit nodes, add the 2 numbers and return as a list of digits # linked list node class Node(object): def __init__(self, x): self.val = x self.next = None def addTwoNumsRecur(l1, l2, c=0): if l1==None and l2==None: if c: return Node...
40d5e2959e45a49b8958fbe3e91fbc78939b26da
wanghaihui/Sharp
/python/liaoxuefeng.py
570
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from method import my_abs from method import my_add a = 100 if a >= 0: print(a) else: print(-a) print('''line1 line2 line3 ''') print(r'''hello,\n world''') s3 = r'Hello, "Bart"' s4 = r'''Hello, Lisa!''' print s3 print s4 print('%2d-%02d' % (3, 1)) print('%....
e7d74991d5a53a01cfd0900ead45e02c27566293
37996/exerciciospython
/alugueldecarro.py
253
3.671875
4
d = int(input('Quantos dias o carro ficou alugado? ')) c = 60 * d km = int(input('Quantos km o carro rodou? ')) ct = (km * 0.15) + c print(" O carro ficou alugado por : {} dias e custou {} + 0,15 por Km que totalizou {}".format(d, c, ct)) print("===")
8de4227172f6ccc66c71e9259642c8a998c13f61
vishnuaero/Python-Scripts
/spongebob_meme.py
647
4.09375
4
#My name is Vishnu->mY nAmE iS vIsHnU def spongebob_meme(string): a='' b="" d="..!#$!" e="" #c="" for i in range(len(string)): #print(string[i]) if i%2==0: b=b+string[i].lower() #letters at even positioned are lower cased #print(b) ...
3294005e6f308de276f7da6c165e6b0e2c2e7eea
aravindanath/PythonAdvCourse
/day1/RegEx-1.py
225
4.09375
4
""" REGular Expression (RegEx) is a used to search the sequeance of char in String. """ import re pattern = '^a....s$' stat = "abacus" result= re.match(pattern,stat) if result: print("Sucess") else: print("fail")
b40b0d8e00efa38fd02e1cebd1cd4b3755d67e64
GitError/python-lib
/Learn/Others/lab0.py
320
3.65625
4
#!/usr/bin/python3 def add(n1, n2): return n1 + n2 def sub(n1, n2): return n1 - n2 def mul(n1, n2): return n1 * n2 def div(n1, n2): if(n2 == 0): return "error, zero is invalid" else: return n1 / n2 print(add(11,20292)) print(sub(22,878)) print(mul(11,22)) print(div(1,0))
e36386252bd76a95a540494e584939f93b61eeba
GitError/python-lib
/Learn/DataCamp/cleaning_data.py
5,495
3.578125
4
""" Diagnose data for cleaning code snippets """ import glob import matplotlib.pyplot as plt import numpy as np import pandas as pd # -------------------------------- # Inspecting pandas DataFrame # -------------------------------- df = pd.read_csv('http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransaction...
035ab9e1afe1f7b302e2799cd329f48bfa2cd433
bobby569/passwd-generator
/passwd-gen.py
1,634
4.125
4
import random import string from typing import Set DIGITS = string.digits LETTERS = string.ascii_letters PUNCTUATIONS = string.punctuation def get_punc() -> Set[str]: use_punc = input('Would you like to include punctuation? Enter y for yes: ') if use_punc != 'y': return set() customize_punc = in...
ba9ae66380be8689d388e870fc852d595aa9dcea
dcc668/PyDemo1.2
/简单算法/二分查找.py
418
3.921875
4
#! /usr/bin/env python #ecoding=utf-8 def binarySearch(li,key): left,right=0,len(li)-1 while left<=right: mid=(left+right)//2 if key<li[mid]: right=mid-1 elif key==li[mid]: return True else: left=mid+1 return False if __name__=="__main__...
1cfd6032c4687ef4c5d9e9add0c84081f196b2bb
dcc668/PyDemo1.2
/简单算法/快速排序.py
349
3.859375
4
#! /usr/bin/env python #ecoding=utf-8 def quickSort(li): if len(li)<=0: return [] mid=li[0] left=quickSort([x for x in li[1:] if x<mid]) right=quickSort([y for y in li[1:] if y>=mid]) return left+[mid]+right if __name__=="__main__": li=[123,44,55,32,2,5,333,66,543,786,99,95] soLi=...
25608325c37b59fcb6390f38c506172971aaa824
Flipside0411/pythonclass
/InsertList.py
1,562
4
4
class intSet(object): ''' An intSet is a set of ntegers The value is represented by a list of ints, self.vals. Each int in the set occurs in self.vals exactly onece. ''' def __init__(self): ''' :return: Create an empy set of integers ''' self.vals = [] def insert...
96cdfc56cf3592bdfee67a17aa997229f81d6519
kaiaiz/python3
/Python 2 函数(参数).py
4,006
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math print(abs(100)) print(abs(-100)) print(max(1, 2)) print(max(2, 3, 1, -5)) print(int("123")) print(int(12.34)) print(str("1.23")) print(str(100)) print(bool(1)) print(bool("")) n1 = 255 n2 = 1000 print(str(n1)) print(str(hex(n1))) print(str(hex(n2))) #位置参数 d...
2013c1f7a47b1aee0c5b39cf3f3b5296be94dcdc
kaiaiz/python3
/Python 22 异步IO.py
4,870
4.03125
4
#!/usr/bin/python # -*- coding: utf-8 -*- __author__ = 'hina' def A(): print('1') print('2') print('3') def B(): print('x') print('y') print('z') # 像多线程,但协程的特点在于是一个线程执行 # 最大的优势就是协程极高的执行效率。因为子程序切换不是线程切换,而是由程序自身控制, # 因此,没有线程切换的开销,和多线程比,线程数量越多,协程的性能优势就越明显。 # 第二大优势就是不需要多线程的锁机制, # 因为只有一个线程,也不存在同时写...
a86b3b674a9a35e3e4c43d9d0fd8b5b650e32fa9
UB-Mannheim/akf-dbTools
/dblib/refGetter.py
3,226
3.546875
4
###################### INFORMATIONS ############################# # It gets the referenz values, reads all years which # are bind to it and pretty prints the data into the table. # Program: **akf-refGetter** # Info: **Python 3.6** # Author: **Jan Kamlah** # Date: **14.11.2017** #########...
5b5ac7e46b69926527cc347d418dcd26db678295
spectraise/PythonFinalTask
/rss_reader/components/feed.py
3,040
3.609375
4
"""This module contains a class that represent a feed""" import json from pygments import highlight from pygments.formatters.terminal import TerminalFormatter from pygments.lexers.data import JsonLexer from components.news import News class Feed: """This class represents a feed""" def __init__(self, sourc...
f650d6078b901e434d3eeff5677127e85d7e0a4c
bd2x/PyFlaskandREST
/Section2_Refresher/Lesson19_coding_ex.py
553
4.0625
4
def who_do_you_know(): # Ask for a list of people they know known_people = [] known_people = input("Enter a list of people you know: ") return known_people def ask_user(): # Ask user for a name name = input("Enter the name of a person: ") return name # see if the name is in the known ...
d4ad0b612311b47b476deab34009da6459a47459
SOFIAVM/python
/Preu a pagar_2.py
552
3.53125
4
#coding:utf-8 #Autora: Sofía #Preu a pagar_2.py #Tenim: edat, sexe, (H/D), cabells (rossa, morena, pelroja). #- Els jubilats no paguen. #- Els homes no jubilats paguen 1€. #- Les dones no jubilades rosses no paguen, les altres paguen 0,15€ edad = int(input("Escribe tu edad: ")) if ( edad <=5) or (edad >= 65 ): pri...
a687dee39476ac389daa8116d0a2feb1fdaec982
Fredkiss3/kge
/kge/utils/classproperty.py
2,938
3.515625
4
""" To use simply copy ClassPropertyMeta and classproperty into your project """ class ClassPropertyMeta(type): def __setattr__(self, key, value): obj = self.__dict__.get(key, None) if type(obj) is classproperty: return obj.__set__(self, value) return super().__setatt...
4df0a4c6de8590d845c8f86a7feaac38129a1322
chuju320/python_study
/项目/游戏剧情.py
588
3.734375
4
#-*-coding:utf-8-*- ''' 故事主角:A、B、C 主线:A和B是男女朋友,C插足,B努力争取,多年后(分支条件) 1.A、B在一起 2.A、C在一起 3.A、B、C都没有在一起 ...(结局不限) 故事主线依靠对话控制并支线发展 ''' class Person(object): '''角色类''' def __init__(self,name,sex,age,money,makings): self.name = name self.sex = sex self.age = age self.mon...
d4928033cf3e2a7da7d9ea49d2d2ca59188fe7bf
chuju320/python_study
/学习/2-filter.py
774
3.828125
4
#-*-coding:utf-8-*- '''Python内建的filter()函数用于过滤序列。 和map()类似,filter()也接收一个函数和一个序列。和map()不同的时,filter()把传入的函数依次作用于每个元素, 然后根据返回值是True还是False决定保留还是丢弃该元素。''' def is_pdd(n): return n % 2 == 1 print filter(is_pdd,[1,2,3,4,5,6,7,8,9]) #[1, 3, 5, 7, 9] def not_empty(n): return n.strip() print filter(not_empty,['1 ...
f3ba42d343e488a156870fae002f9e8892877c5b
liu1073811240/License-plate-recognition
/test_files/letters.py
356
3.59375
4
letters = [chr(x + ord('A')) for x in range(26) if not chr(x + ord('A')) in ['I', 'O']] a = [chr(x + ord('A')) for x in range(26)] print(a) # ['A', 'B', 'C', 'D',...] print(ord('A')) # 65 print(letters) digits = ['{}'.format(x + 1) for x in range(9)] + ['0'] print(digits) # ['1', '2', '3', '4', '5', '6', '7', '8'...
f157b46f094ce74b381522599f8cedb2096aeecc
adriacabeza/ComplexAlgorithms
/2-Linear-Programming/energy_values/energy_values.py
2,011
3.796875
4
# python3 class Equation: def __init__(self, a, b): self.a = a self.b = b class Position: def __init__(self, row, column): self.column = column self.row = row def select_pivot(pivot, a, used_rows): while used_rows[pivot.row] or a[pivot.row][pivot.column] == 0: pivot.row += 1 if pivot.row == len(a): ...
7db58420b15dd28fc2bf739d24180d74d0256016
Antimouse12/GB_Python
/Tasks/lesson_3/3_2.py
548
4.125
4
keys = ('name', 'last_name', 'year_of_birth', 'city', 'email', 'phone_number') details = {} for key in keys: info = input(f'введите информацию о пользователе - {key} : ') details[key] = info print(details) def user_info(**details): return ' '.join(details.values()) # не могу понять как распаковать словар...
1b9ab71e613c9727190ebd41d5ccfbcd855d6daa
IshanGoyal/Epinoma
/venv/bin/dataProcessing.py
921
3.6875
4
''' Filename: dataProcessing.py Objective: Add the excel data file into a Pandas dataframe and remove the excess columns Input: Need to specify path to excel file Output: Creates processed dataframe and stores in memory using Pickle package ''' import pandas as pd import pickle from pandas import ExcelWriter from pa...
9eea40421575aabbb29a84bb378f0ee3f6227b2f
GorillaSeven/checkiopro
/mission/home/bird_language.py
1,288
3.703125
4
# -*- coding: utf-8 -*-# """ #------------------------------------------------------------------------------- # Name: bird_language # Description: # Author: ZengJiangDong # Date: 2019/7/18 #------------------------------------------------------------------------------- """ import re VOWELS = "...
7f221118f75e4c0d387b87c40db958fbc228dd0f
GorillaSeven/checkiopro
/mission/elementary/between_markers.py
994
4.25
4
# -*- coding: utf-8 -*-# """ #------------------------------------------------------------------------------- # Name: between_markers # Description: # Author: ZengJiangDong # Date: 2019/7/19 #------------------------------------------------------------------------------- """ def between_marker...
e8700258e860ba45f3b7494a8bec7c141ad68254
vuquanh/Assignment_05
/CDInventory.py
3,113
3.53125
4
#------------------------------------------# # Title: CDInventory.py # Desc: Starter Script for Assignment 05 # Change Log: (Who, When, What) # DBiesinger, 2030-Jan-01, Created File # AnhVu, 2021-Aug-06, Added Code #------------------------------------------# # Declare variables strChoice = '' # User input ...
9badcaa30c695f693d88370cf26f03f0319dae28
Witziger/Walkthru-Python
/Walkthru_12/walkthru12.py
1,304
3.671875
4
#Python 中有一個內建的功能叫做socket,它用來連接網絡,和追溯Python program中的資料 import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect(('data.pr4e.org', 80)) cmd = 'GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n'.encode() mysock.send(cmd) while True: data = mysock.recv(512) if (len(data) <...
8bf1a16f4250bbfe71577e7d686ae55ff7bb07d9
ares5221/Data-Structures-and-Algorithms
/04数组/09集合的所有子集及子集和数N-sum问题/GetAllSubSet.py
1,521
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 求解一个集合的所有子集 """ def PowerSetsRecursive1(items): """Use recursive call to return all subsets of items, include empty set""" if len(items) == 0: return [[]] subsets = [] first_elt = items[0] # first element rest_list = items[1:] # Strategy...
cabcc463a16ea2f6b77e51d0ad34132837d8c3c5
ares5221/Data-Structures-and-Algorithms
/02栈和队列/03cycle_queue.py
1,678
4.09375
4
# coding = utf-8 class CycleQueue(object): """实现循环队列""" def __init__(self, maxsize, front=0, rear=0): '''循环队列有空间大小限制''' self.maxsize = maxsize self.items = [None] * self.maxsize self.front = 0 self.rear = 0 def inQueue(self, data): '''入队列(头出尾进)''' i...
660db2e2327ca29abc9b3f40ec0a5549d8cb0632
ares5221/Data-Structures-and-Algorithms
/07排序/10radixSort.py
1,437
3.5625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ import math def RadixSort(ls): def getbit(x, i): # 返回x的第i位(从右向左,个位为0)数值 y = x // pow(10, i) z = y % 10 return z def CountSort(ls): n = len(ls) num = max(ls) count = [0] * (num + 1) for i in range(0, n): ...
7254170fa649b8cc99f65f9edd02bdc3a0a5fe2e
ares5221/Data-Structures-and-Algorithms
/02栈和队列/02queue_linklist.py
2,133
3.765625
4
# coding = utf-8 class QNode(object): """docstring for QNode""" def __init__(self, val, next=None): self.val = val self.next = None class Queue(object): """链表创建队列""" def __init__(self, front=None, rear=None): '''使用链表创建队列,front指头,rear指尾的后一个''' self.front = front ...
d67e73b51e562a2c22a017d6716780c06f04adb9
ares5221/Data-Structures-and-Algorithms
/09概率组合数学/05skipListPro.py
2,843
3.765625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ ## # Example of Skip List source code for c ## import random import sys minint = 0 maxint = 65535 class Node(object): def __init__(self, key=minint, value=None, level=1): self.key = key self.value = value self.level = level self.right =...
a46335b5b6f502fcc7e822db577e70829ddb93cb
ares5221/Data-Structures-and-Algorithms
/09概率组合数学/02RandomPos/02triangleRandomPro.py
698
3.515625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ import matplotlib.pyplot as plt import random, math x_values = [] y_values = [] A = [0, 1] B = [3, 1] C = [1, 2] for i in range(10000): t = random.random() s = random.random() a = 1 - math.sqrt(t) b = (1 - s) * math.sqrt(t) c = s * math.sqrt(t) xx =...
eab0ada521a7e3b67d63423b6bbbb988f50cdc16
ares5221/Data-Structures-and-Algorithms
/01线性表/01LinkList.py
5,359
4
4
# coding=utf-8 class LNode(object): ''' This is the node of linklist ''' def __init__(self, data, pnext=None): self.data = data self.pnext = pnext class LinkList(object): ''' This is a class of linklist , there some operators about linklist ''' ''' LinkList 与 Lnode不是同一种类,LinkList.head...
1d3581318ca727aa75b91f699597b6fe98210eb0
ares5221/Data-Structures-and-Algorithms
/01线性表/mergeLList.py
2,403
3.5625
4
# coding=utf-8 import time class Node(object): """docstring for Node""" def __init__(self, val, pnext=None): self.val = val self.pnext = pnext class LinkList(object): """docstring for LinkList""" def __init__(self, head=None, length=0): self.head = head self.length ...
5405699b8db5a4d0887542473a8db42ca69029f9
BottCode/IQPuzzlerSolver
/View/view.py
7,279
4.125
4
""" Example program to show using an array to back a grid on-screen. Sample Python/PG Programs Simpson College Computer Science http://programarcadegames.com/ http://simpson.edu/computer-science/ Explanation video: http://youtu.be/mdTeqiWyFnc """ import pygame as PG from CSPSolver.CSPSolver import CSPSolver fro...
23060759544e4d2ebadd90a53cb9eab6e7f2e605
sunadruey/hkes_test
/day_test04/test_001.py
95
3.71875
4
x=-1 if x>1: y=3*x-2 else: if x>=-1: y=x+2 else: y=5*x+3 print(y)
9feb01f9979d3190e77e7c057dd08a749f5ae4b4
mtanti/where-image
/experiments/where_image/lib/dates.py
467
3.640625
4
################################################################# def format_duration(seconds): remainder = seconds (hours, remainder) = divmod(remainder, 60*60) (minutes, remainder) = divmod(remainder, 60) if hours > 0: return '{:>2}h:{:>2}m:{:>2}s'.format(hours,minutes,remainder) ...
07f15a19fe8ab318f24c02938678ff5bf4f2f755
dikshit22/PathaPadha-Python-DS-P-1
/class4.py
2,164
4.15625
4
#Program to input an element and search whether it exists in the list or not #along with its position. print("#Program-1") l = [1, 3.5, "HELLO", True, 3+4j, 'a'] for j in range(1, 13): srch = eval(input("Enter the element to search:\t")) for i in range(0, len(l)): if srch == l[i]: pr...
f6fa876d174948d0aa897260e9af99d38d0ac56d
dikshit22/PathaPadha-Python-DS-P-1
/class2.py
1,611
4.25
4
#Program to find the greatest number out of 3 numbers using nested if print('#Program to find the greatest number out of 3 numbers') print('Enter three numbers:') n1, n2, n3 = int(input('n1 = ')), int(input('n2 = ')), int(input('n3 = ')) if(n1 > n2): if(n1 > n3): print('/tThe greatest number is', n1) ...
a421d563615fcb3412b07546db94b8d9f69c62e0
Ariel-F-G/Actividad-2-
/triangulo.py
246
3.84375
4
class triangulo: print("Ingrese la base en centimetros") base1= int(input()) print("Ahora ingrese la altura en centimetros") altura= int(input()) print("El area del triangulo es: ") print(((base1*altura)/2),"centimetros")
aedffabeeead65898a034cf6e77a6d6f89619eaa
vcaptainv/Painting
/lsystem.py
1,842
3.53125
4
#Yusheng Hu #L SYSTEM #VERSION 2 import sys class Lsystem: #filename is optional, default is none def __init__(self, filename=None): self.base='' self.rules=[] # if the filename variable is not equal to None if filename !=None: self.read(filename) def getBase(self): return self.base def setBa...
f3e7f82dae9f60e5b8a02057887d90209e52d1fe
ichibanjune/Data-Driven-Development-with-Python
/MinxuanZhao_Assign1.py
2,089
4.25
4
''' Created on Sep. 3rd, by Minxuan Zhao Homework assignment 1 This program takes in the school start time and the students' assigned stop number, and return the stop timing, how long it takes to school, and the busfare. ''' # create constant variables wholetrip = 45 #the length for the whole trip is 45 minu...
d60c29351c6fe028bc05c87a71b6211d16a2cd4f
yonatankehat/-computersProject_Yonatankehat-
/main.py
9,281
3.75
4
# Project 2018-9 Tel-Aviv University # The code is divided into 2 parts. The First part has all the function that appear in the main function which is 'linear fit'. # The second part is the main function 'linear fit'. That function uses all the functions from the first part. # Part 1: ############################...
6257316f6e4499c71fa830af44b87fdf089cdf8d
tarees01/pythonfun
/hw4solution.py
4,363
3.53125
4
# CS 115 Homework 4 # Daniel Vinakovsky # 21 September 2013 # I pledge my honor that I have abided by the Stevens Honor System. def giveChange(amount,coins): '''Returns the least number of coins and each coin's value needed to construct a certain amount of change''' if (amount==0): return [0,[]] elif (coins==[]...
45477d9b4dff43518a9637310dad5a5b7bfd1e4c
tarees01/pythonfun
/lab8sol.py
2,035
3.984375
4
def combs(n): '''Returns a list of all lists of n bits, in binary numerical order. In other words, finds + returns all of the combinations you can make with n bits''' if n==1: return [[0],[1]] else: var = combs(n-1) return map(lambda item: [0]+item, var) + map(lambda item: [1]+item, var) def func0(x,y...
15da8beaf6d89dd012d321865ffb19ed5e4f88b2
tarees01/pythonfun
/lab4sol.py
377
3.578125
4
def giveChange(amount,coins): if (coins==[]): return float("inf") else: if (amount-coins[0] > 0): useIt = 1 + giveChange(amount-coins[0],coins) loseIt = giveChange(amount,coins[1:]) return min(useIt,loseIt) elif (amount-coins[0] < 0): return giveChange(amount,coins[1:]) elif (amount-coin...
787440a49d8b33c2fba23aef3eb98cebd2645fe5
tarees01/pythonfun
/hw2.py
1,311
3.828125
4
#CS 115 Homework 2 #Daniel Vinakovsky #5 September 2013 #I pledge my honor that I have abided by the Stevens Honor System # Implement the following functions using map and reduce. # You will probably need to write additional functions to help. # Even if you are familiar with recursion and for/while loops, # do not us...
0cd4f81baea4b43356e9f7810c5e46e1e095a953
GreenALan/DocNote
/web/docnote/uploads/6.py
2,534
3.546875
4
# coding=utf-8 info=[] keywordList={"语文":0,"数学":1,"英语":2,"物理":3,"化学":4} class student: sid=0 name='' socore=[0]*5 sum=0 avg=0 rank=0 def __init__(self,input): temp=input().split(',') self.sid=int(temp[0]) self.name=temp[1] self.socore=[int(x) for x in temp[2:]] for i in range(0,5):self.sum+=self.socore...
b1a136bb259aba9af249538b2803eafa5fcd3979
ramkishor-hosamane/Coding-Practice
/Training/linked.py
679
4.03125
4
class Node: def __init__(self,val=None): self.data = val self.next = None class Linked_List: def __init__(self): self.head = None def insert(self,val): cur = self.head if cur==None: self.head = Node(val) else: while cur.next!=None: cur = cur.next cur.next = Node(val) def display(self)...
f986ba636c765981f14ccfa9cc6a04b874c3f672
ramkishor-hosamane/Coding-Practice
/Optum Company/8.py
855
4
4
''' 8.Reverse a linked list in groups of size k ''' class Node: def __init__(self,val=None): self.data = val self.next = None class Linked_List: def __init__(self): self.head = None def insert(self,val): cur = self.head if cur==None: self.head = Node(val) else: while cur.next!=None: cur = c...
97a4c3b0c94e32aed67cc043dd22bc35fc56f608
ramkishor-hosamane/Coding-Practice
/Optum Company/2.py
814
4.34375
4
''' 2. Implement queue using two stacks. ''' class Stack: def __init__(self): self.items = [] def get_size(self): return len(self.items) def is_empty(self): return self.get_size()==0 def push(self,val): self.items.append(val) def pop(self): re...
818bc5f27001e8f12368cd78346b846e76692485
zqlbling/week1
/week/w3.py
524
4.0625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' 编写程序,生成一个包含20个随机整数的列表, 然后对其中偶数下标(下标即列表元素的索引)的元素进行降序排列, 奇数下标的元素不变。(提示:使用切片。) ''' import random list1 = [] for i in range(20): num1 = random.choice(range(100)) list1.append(num1) print("长度为:",len(list1)) print("排序前是:",list1) list1[::2] = sorted(list1[::2],revers...