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
7f3bbd5174b9d6bbb5f36022b5095274c068615e
kaiogama18/Introduction-to-Machine-Learning
/classifica_busca.py
3,594
3.671875
4
# -*- coding: UTF-8 -*- from collections import Counter import pandas as pd df = pd.read_csv('busca.csv') #0 e 1 #df = pd.read_csv('buscas2.csv') #0 e 1 X_df = df[['home','busca','logado']] #Recebe um Array de coluna Y_df = df['comprou'] #Devolver a tabela busca em dummies - perguntas sim não #Xdummies_df = pd.get_du...
b5711734b3a6887ec9d97d7475be37d88f80ab44
1751660300/lanqiaobei
/基础练习/12.py
205
3.5
4
# -*- coding:utf-8 -*- for i in range(32): s = bin(i)[2:] for j in range(5 - len(s)): s = "0" + s print(s) # 问题:进制转换 # bin()二进制 oct()八进制 hex()十六进制
5a821cf368d6aac40b3e13a7ee6d3f9e3b73df24
miked49er/com.mikedeiters.learningpython
/12 Classes/classes.py
1,625
4.1875
4
#!/usr/bin/python3 # classes.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC class Animal: def talk(self):print('I have something to say') def walk(self):print("Hey I'm walking here") def clothes(self):pr...
b04b5b3e959bb4467a28267e9abc37458956cfcd
AlphaLawless/Exercises
/python/100 exercicios em Python/exercicios/python005.py
184
4.1875
4
numero = int(input('Digite um número: ')) sucessor = numero + 1 antecessor = numero - 1 print('O sucessor do {} é {} e o antecessor é {}'.format( numero, sucessor, antecessor))
2b4a0a8318de101ecd4c4649ccd5f4b69f3f8268
AlphaLawless/Exercises
/python/100 exercicios em Python/exercicios/python002.py
235
3.96875
4
nome = input('Qual é o seu nome? ') print('Muito prazer,', nome, 'e boas vindas ao VSCode!') # um jeito mais fácil de fazer isso é esse => nome = input('Qual é o seu nome? ') print('Muito prazer em te conhecer {}!'.format(nome))
37da780a8dc15bffae4c92532e4c9232dae2c8e9
AlphaLawless/Exercises
/python/100 exercicios em Python/exercicios/python007.py
202
3.984375
4
nota1 = float(input('Digite a primeira nota: ')) nota2 = float(input('Digite a segunda nota: ')) media = (nota1 + nota2) / 2 print('A media entre {} e {} é igual a {:.3f}'.format(nota1, nota2, media))
89ea87ea7fc8dfd53e329552ff64ee2e8bc05ba5
Mvianna10/grav
/grav.py
5,925
3.78125
4
#! /usr/bin/env python """ This script implements a basic sprite that can move in all 8 directions. -Written by Sean J. McKiernan 'Mekire' """ import os import sys import pygame as pg CAPTION = "Mova com ASDW, pule com Espaço" SCREEN_SIZE = (500, 500) TRANSPARENT = (0, 0, 0, 0) G = 0.05 AX = 0.1 AY = 0.1 BOUNCE...
d3d53d2ae93cb2ad28a8edcbe348b89d7f20982a
LiBReShiNn/algorithm-practice
/python/codewars/take_a_ten_minute_walk.py
957
3.578125
4
# 약속에 10분 일찍 도착해서 잠시 산책하려 한다. 걷기 앱이 있어서 한 블럭을 지날때마다 걸어야 하는 방향을 알려준다. 한 블럭을 걷는데 1분씩 걸린다. 정확히 10분만에 시작점으로 다시 돌아오게 하는 방향을 알려주면 True, 시작점에 돌아오지 못하면 False를 반환하는 함수를 생성하라. # 비어있는 배열이나, 명확한 방위 (n, s, e, w)가 들어있지 않은 배열은 받지 않는다. from collections import Counter def isValidWalk(walk): direction = {'n': 0, 's': 0, 'e': 0, ...
3acd620b3684893ab9df98cbabf0dc72615aa655
LiBReShiNn/algorithm-practice
/python/codewars/unary_function_chainer.py
441
3.75
4
# 고차함수를 연결한 단항 함수를 생성하려고 한다. # chained([a,b,c,d])(input) # Should yield the same result as d(c(b(a(input)))) def chained(functions): def infunc(x): for func in functions: x = func(x) return x return infunc def f1(x): return x*2 def f2(x): return x+2 def f3(x): return x**2 ...
149afd2f7ebeb9f3af40398fc634ee371b57551d
AntonioLoFu/SSIIPAI2
/src/diffieTools.py
515
3.734375
4
import random #FUNCION PARA GENERAR PRIMOS ALEATORIOS def generaPrimoAleatorio(min, max): primes = [i for i in range(min,max) if is_prime(i)] n = random.choice(primes) return n def is_prime(n): if n == 2 or n == 3: return True if n < 2 or n%2 == 0: return False if n < 9: retur...
4eeb17693c62ffc921a1bed9a19d9abc0b7d16a1
Danushka96/DSA-Assignment-02
/Question02/process.py
3,960
4.125
4
#Start of Implementing Queue class Queue: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def enqueue(self, item): self.items.append(item) def dequeue(self): return self.items.pop(0) def size(self): return len...
eb56368a0e7210763dcfe6422d07e593f7a1ca18
chaejung-50/hackathon
/getWeather.py
1,235
3.640625
4
import requests import json def api_response(loc): #loc = input("Where are you from?\n").lower() key = "bf3c1639ec81c85a49257898b778d0d2" response = requests.get(f"https://api.openweathermap.org/data/2.5/weather?q={loc.capitalize()}&units=imperial&appid={key}") if (response.status_code == 404)...
06f055db77a4bfb640199ce3b31cc37af9f3a069
Tonyopt57/Machine_Learning_Model
/Artificial Neural Networks/ann.py
3,318
3.625
4
# Artificial Neural Network # Installing Theano # pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git # Installing Tensorflow # Install Tensorflow from the website: https://www.tensorflow.org/versions/r0.12/get_started/os_setup.html # Installing Keras # pip install --upgrade keras # Part 1 - Data...
c9d3d3c5ca0931c7253172b35dbbf72e5792e53b
gpsg/Python_with_Exercism
/robot-name/robot_name2.py
956
3.90625
4
from random import choice, shuffle, seed from string import ascii_uppercase, digits AVAILABLE_NAMES = [''.join([a, b, c, d, e]) for a in ascii_uppercase for b in ascii_uppercase for c in digits for d in digits for e in digit...
769a6233003eb0d29180326226a4f55ae8f3b2bc
gpsg/Python_with_Exercism
/armstrong-numbers/armstrong_numbers.py
146
3.640625
4
def is_armstrong_number(number): digits, power = str(number), len(str(number)) return sum([pow(int(i), power) for i in digits]) == number
7d6e84349dcb9c8ca76a35192e1bbbc5a6301142
TheRockStarDBA/PythonClass01
/program/python_0050_flow_control_nested_for_loop.py
1,158
4.1875
4
''' Requirement: There are 4 numbers: 1/2/3/4. List out all 3 digits numbers using these 4 numbers. You cannot use the same number twice in the 3 digits numbers. ''' #Step 1) How to generate 1 digit number? for i in range(1,5): print(i, end=' ') print('\n-------------------------------------') #Step 2) How to ge...
51fd5e25e86aaff6b765fb15fe97b5e863a82b80
TheRockStarDBA/PythonClass01
/program/python_0051_practice_flow_control_loop_for_draw_triangle.py
3,327
3.890625
4
''' Right triangle 1 1st line: 1 '*' 2nd line: 2 '*' .. 10th line: 10 '*' ''' for line_number in range(10): # 0 -9 print('*' * (line_number + 1)) print('\n\n -------------------------------- \n\n') ''' Right triangle 2 1st line: 9 ' ' + 1 '*' 2nd line: 8 ' ' + 2 '*' ... 10th line: 0 ' ' + 10 '*' Summary: Loop...
ad3979824471e652f79e74cf93ca18366b922436
TheRockStarDBA/PythonClass01
/program/python_0020_flow_control_if.py
1,262
4.28125
4
# Every python program we've seen so far is sequential exection. # Code is executed strictly line after line, from top to bottom. # Flow Control can help you skip over some lines of the code. # if statement today = input("What day is today?") print('I get up at 7 am.') print('I have my breakfast at 8 am.') # IMP...
e9fcd04639d97eef36e0891c5a4e8ad7513bd9c1
TheRockStarDBA/PythonClass01
/program/python_0048_practice_number_guessing_name.py
1,575
4.40625
4
''' Requirement: Build a Number guessing game, in which the user selects a range, for example: 1, 100. And your program will generate some random number in the range, for example: 42. And the user needs to guess the number. If his answer is 50, then you need to tell him. “Try Again! You guessed too high” If his answer...
45d32d880019054cbcc22f71c5cf0b62bc605ecf
TheRockStarDBA/PythonClass01
/program/python_0006_data_type_str.py
613
4.15625
4
# str - 字符串 str1 = "Hello Python!" str2 = 'I am str value, "surrounded" by single quote.' str3 = "I am another str value, 'surrounded' by doulbe quotes." print('variable str1 type is:', type(str1), 'str1=', str1) print('variable str2 type is:', type(str2), 'str2=', str2) print('variable str3 type is:', type(str3), '...
caf77761eb946bc292c8f0c9802bc0bfd75160a4
TheRockStarDBA/PythonClass01
/program/python_0031_practice_input_if_elif_else_bmi_calculator.py
1,132
4.53125
5
# Requirement: get input from the user about height in meters and weight in kg. # Calculate his bmi based on this formula: # bmi = weight / (height ** 2) # Print information based on user's bmi value # bmi in (0, 16) : You are severely underweight # bmi in [16, 18.5) : You are underweight # bmi in [18.5, 25) :...
e9a945d21935f5bb2e66d9323eeb5e26b5a97ec6
TheRockStarDBA/PythonClass01
/program/python_0039_library_random.py
1,221
4.5625
5
# IMPORTANT !!! ---------------------------------- # Import the random module into your python file # ------------------------------------------------ import random # IMPORTANT !!! ---------------------------------- # random.randint(1, 10) is composed of 4 parts. # # 1) random : module name # 2) . ...
9c77fbb402439c9e1e002015a687ba08f77277e5
t16h05008/SysDynPy
/sysdynpy/parameter.py
1,320
3.734375
4
from sysdynpy.systemelement import SystemElement class Parameter(SystemElement): """Stores fixed values. Parameters don't have input elements. That means, the value of a parameter, once set, will not change during the simulation. """ def __init__(self, name, value, system, var_name): """...
c63bc5c81659a0375e1a33d254eb5e473b9a852d
gitdamilare/MachineLearning_CNN
/ClasifferCNN.py
5,115
3.828125
4
#!/usr/bin/env python # coding: utf-8 # CNN classifier training # Train a CNN classifier with two convolutional layers of filter size 3x3 (followed # by relu and max-pooling with 2x2 kernels), and two fully-connected layers of # equal size L. This classifier should be trainable on each of the 4 classification # proble...
90a14469919d079028135a061a41cce291267f8c
douglasryanadams/advent_of_code
/2020_05.py
1,987
3.78125
4
#!/usr/local/bin/python from unittest import TestCase import sys def answer_one(): highest = 0 with open('2020_05_input.txt', 'r') as f: line = f.readline() while line: line = line.rstrip() seat = find_seat(line) if seat > highest: highest = ...
3b642f44a18b2f6c55761faf0213a87914278179
eminetuba/9.Hafta-Odevler
/1.soru.py
496
3.625
4
teksayi=lambda sayi:sayi%2!=0 ciftsayi=lambda sayi:sayi%2==0 uc= lambda sayi:sayi%3==0 bes=lambda sayi:sayi%5==0 def sayikontrol(sayi): if bes(sayi): print(sayi, "besin katidir.") if uc(sayi): print(sayi,"ucun katidir. " ) if ciftsayi(sayi): print(sayi," cift sayidir. ") if teksayi(sayi): print...
cf0dca018b8a8e99cc7130dd211eba957132bfd7
Hussain-Khozema/Simple-Tic-Tac-Toe
/tic tac toe.py
4,488
4.0625
4
def dispalyInstructions(): print("Use the numbers indicated in each space to make your mark") print(' | | ') print(' 7 | 8 | 9 ') print(' | | ') print('-----------------') print(' | | ') print(' 4 | 5 | 6 ') print(' | | ...
c9277e63353ae6ae58552ed01408dc06909ed034
irfan0808/python_areta
/UtsPython.py
621
3.515625
4
ini_dictionary={ 'Nama ' :'Budi Santoso', 'Kelas' :'12.4A', 'No hp' :'081298889299'} for ini in ini_dictionary: print ini,':',ini_dictionary[ini] print "\n" absen = int(input("Masukan Nilai Absen : ")) tugas = int(input("Masukan Nilai Tugas : ")) uts ...
76a61db1b8df1ae1b16afaaef0e0ba681f7049f1
ivanimera/Graduate-School-Coding-Samples
/Python4DataScienceAssignments/Unit4Assignment2/lookup.py
855
3.75
4
#Unit 4 Assignment 2 # #Author: Ivan Mera # #A program that cleans, sorts, and searches for numbers in a file import mysearch #import library infile = "rands.txt" #call out file nums = open(infile, 'r') #open file data = nums.read() # add file to list nums.close ...
149e81cb41b70c159d1a893b9386946270fb5fee
lbai94/Cryptography-I
/hw4_Padding_Oracle_Attack/padding_oracle.py
4,639
3.6875
4
import urllib2 import sys """"Padding oracle attact to a website built for practice. The data which we what to decryt should be embeded in the URL, it is AES CBC encrypted. In CBC, the last k bytes of the former block Xor right guessing bytes of a block Xor k*chr(k) will form a valid byte and get a certain response ...
ef406a2ec250a93236f58d047c81df5a8d60970e
jaydaro/python_exercises
/python_exercises/exercise_1_array.py
2,420
4.0625
4
__author__ = 'jay' ''' This is a little program that will ask the user for some numbers, then manipulate them and print the result. ''' # this function creates an array of the users numbers, def numbers_for_fun(): # declare vars here number_array = [] i = 0 t = 1 sum_int = 0 product_int = 1 ...
4262a72b93d0508521e49cfb4ce9bd5005c44e70
TimButters/Coursera-Regression
/Week1/linear_regression.py
2,261
3.75
4
#!/usr/bin/python import numpy as np import pandas def simple_linear_regression(input_feature, output): X = np.array([np.ones(len(input_feature)), input_feature]).transpose() XTX = np.dot(X.transpose(), X) intercept, slope = np.dot(np.dot(np.linalg.inv(XTX), X.transpose()), output) return intercept, ...
89d3d4ba267d9d859a62801ff845d676d0778e7e
omidcc/leetcode
/4. Median of Two Sorted Arrays/median.py
351
3.515625
4
def findMedianSortedArrays(nums1, nums2): mergedArray = nums1 + nums2 i = 0 mergedArray.sort() n = len(mergedArray) median = 0.0 if n % 2: median = mergedArray[int(n/2)] else: median = (mergedArray[(int(n/2))-1] + mergedArray[int(n/2)])/2.0 return median print(findMedia...
39c6c16abb1c845b63bba2c82c1e32c17f1b8edb
cwinton/RoundRobinScheduler
/ClassBasedScheduler.py
994
3.546875
4
''' Created on Jun 2, 2014 @author: coreywinton ''' from scheduleClass import ScheduleClass def find_home_away_pair (schedule, home_start, away_start): for home_iter in range(max_teams): home = (home_start + home_iter) % max_teams for away_iter in range(max_teams): away = (away_start +...
45200028ca41b714860276c76c4411970d9de1de
dpribula/DKT-DSC
/student_data.py
1,520
3.703125
4
import csv import os def read_data_from_csv_file(file_path,file_name,file_type,student_id=1): rows = [] with open(file_path, "r") as csvfile: reader = csv.reader(csvfile, delimiter=',') for row in reader: rows.append(row) new_file_path = "./new/{}_{}.csv".format(file_nam...
99db15b1fe270a9a3f157df024b056b981ccdb34
sureshcth/repo
/python/pYNITTE/in.py
200
4.1875
4
num1 = input("Enter the First Num : "); num2 = input("Enter the Second Num: "); print "Before : num1 = ", num1, "num2 = ", num2 num1, num2 = num2, num1 print "After : num1 = ", num1, "num2 = ", num2
69e352f00305a443c516b296d2c9f786702a8e78
sureshcth/repo
/python/hello_world.py
248
3.78125
4
#!/usr/bin/python class console: def write(text): #print(text, end="") print text def main(): message = str("Hello World") message_letters = list(message) for i in message_letters: console.write(i) if __name__ == "__main__": main()
fb33e3dd347ac0f157862720703168cf2499fb31
sureshcth/repo
/python/chain_comp.py
204
3.625
4
#!/usr/bin/python ''' One can chain comparison operators in Python answer= 1<x<10 is executable in Python. ''' i = 5; ans = 1 < i < 10 print(ans) ans = 10 > i <= 9 print(ans) ans = 5 == i print(ans)
35526d52d763ff263db492dd7c9fc430f42e6317
ope079/qa-python-exercises
/exercises/functions.py
411
3.734375
4
def grades(name, homework, assessment, final_exam): mark = int((homework + assessment + final_exam)/1.75) grade = " " if mark < 40: grade = "F" elif mark < 50: grade = "E" elif mark < 60: grade = "D" elif mark < 70: grade = "C" elif mark < 80: grade =...
84fd89c5a4bd4626cbaa09289997c870f4b27502
ope079/qa-python-exercises
/exercises/grade_calculator.py
442
3.875
4
def grade_calc(maths, chemistry, physics): percentage = int((maths + chemistry + physics)/3) mark = "" if percentage < 40: mark = "You Failed" elif percentage < 50: mark = "D" elif percentage < 60: mark = "C" elif percentage < 70: mark = "B" else: mar...
7a156a7e512fd837b50fa6185b7eef0331f7a24a
jirby425/Prep
/HackerRank/IntroArrs/CountAs.py
599
3.53125
4
import math import os import random import re import sys # Complete the repeatedString function below. def repeatedString(s, n): a_in_str = s.count("a") count = 0 mult = n // len(s) if mult == 0: count = (s[:n]).count("a") else: remainder = n % len(s) count = (a_in_str...
fac3c1d5175f6fa064d596aad961664ea63f683f
jirby425/Prep
/Moderate/WordCount.py
112
3.53125
4
#for word in book: # word = word.lower() # d[word] = (d[words] + 1) d = {} d["hello"] = 5 print (d["hello"])
258deb1b4990ab4fe910a0e03e820edbcd2d1c8d
LungFun/3d-LDA
/src/data/all/trans_info.py
223
3.515625
4
import sys with open(sys.argv[1]) as fp: for line in fp: line = line.strip() if ':' not in line: print line else: print ' '.join([i.split(':')[0] for i in line.split()])
1a8364fc753b03569bf51e6515c550f1205ed694
JackClair/DjangoTutorial
/Python/trail.py
75
3.8125
4
print("Hii") a = "This is mumbai is Dellhi" print("the value of a is :",a)
422f6664466e0191014d2961539889fcc806d712
jsperezsalazar2001/SADA_ANALYTICS
/SADA_ANALYTICS/public/python/hermite.py
2,828
3.515625
4
""" Created on Tue Nov 11 This program finds the interpolation polynomial using the Hermite interpolation method Parameters ---------- Array XX: array of the x points and the f(x) points Array Z: array of the f'(x) size: size of the arrays Returns ------- coefficient: Plotter coefficients plotter: Plotters @author: Ces...
ab6809eb8914153cc4a1f6007ac52e62a5b29e14
jsperezsalazar2001/SADA_ANALYTICS
/SADA_ANALYTICS/public/python/neville_method.py
2,051
3.65625
4
""" Created on Nov 10 This program interpolates using Neville's method Parameters ---------- vector: x vector: y point (float): x_inter : Value to interpolate Prints: y_inter: Interpolated value Q: Coefficients matrix This code does not support operations with imaginary numbers @author: Yhoan Alejandro Guzman Garcia...
b22ee283e630c61df2aa2a2862d3d0722083d94f
JordonZ90/WeightConversions
/weight.py
660
3.9375
4
def pounds_to_stone(pounds): stone = pounds / 14 return stone def stone_to_pounds(stone): pounds = stone * 14 return pounds def pounds_to_kilograms(pounds): kilograms = pounds * 0.45359237 return kilograms def kilograms_to_pounds(kilograms): pounds = kilograms * 2.2046 return pound...
587e9f60c46a7db78e6e1f78885eb0b405f16239
Alamin11/JavaScript-and-Python
/lecture02/sequeces.py
652
4.15625
4
from typing import OrderedDict, Sequence # Mutable and Ordered # Mutable means can be changed the Sequence # Orderd means can not be changed the sequence because order matters #string = oredered name = "Farjana" print(name[0]) print(name[6]) print(name) #Lists=mutable and ordered listName = ["Farjana", "Toma", "Nuntu...
3b36939dec7b6907df6f62feab5fd024322036fd
johnywalves/PyStudies
/CodeWars/VowelCount.py
665
4.03125
4
""" Vowel Count Return the number (count) of vowels in the given string. We will consider a, e, i, o, and u as vowels for this Kata. The input string will only consist of lower case letters and/or spaces. """ getCount lambda i: len([l for l in i if l in 'aeiou']) def getCount(input): return len(list(filter(lamb...
71cdaa322abe4a1f266d5ce9704c11f3a759892c
alisaffak/GlobalAIHubPythonHomework
/proje.py
2,720
4.1875
4
student_name = "Ali".upper() student_surname = "Şaffak".upper() all_courses = ["Calculus","Lineer Algebra","Computer Science","DSP","Embeded Systems"] selected_courses = set() student_grades = {} def select_courses(): j = 1 for i in all_courses: print("{}-{}".format(j,i)) j +=1 ...
45613fb3aacb10a35dd3bbc534871b8941a53f51
elementh11/data-structures-implementations
/algorithms/quick_sort.py
670
4.09375
4
def quicksort(arr, left, right): ''' Implementation of the quicksort algoritm ''' if left >= right: return pivot = arr[(left + right)/2] index = partition(arr, left, right, pivot) quicksort(arr, left, index - 1) quicksort(arr, index, right) def partition(arr, left, right...
224f1cb5e79f927af38bffa0629d03d0eddbfe86
Surgeom/geekbrains
/algoritms/dz2/1.py
858
4.25
4
def calcul(): operation = input('Введите операцию (+, -, *, / или 0 для выхода):') if operation == "0": return 'bye' elif operation == "-" or operation == '+' or operation == '*' or operation == '/': num1 = int(input('Введите первое число')) num2 = int(input('Введите второе число')) ...
bf234c14e84bccd24e60ef225a30c96e0eb9d670
Surgeom/geekbrains
/L5/2.py
590
3.625
4
with open('first.txt', 'a') as file: while True: txt_to_write = input('введите стр для записи в файл') if txt_to_write: file.write(txt_to_write + '\n') else: break with open('first.txt', 'r') as file: arr_of_str = file.readlines() count_lines = len(arr_of_str...
4a02dc147d4573a657e152774befbb32f3b5e57b
Surgeom/geekbrains
/L8/4.py
1,575
3.5625
4
of1 = [] of2 = [] of3 = [] class WarehouseOfEquip: def __init__(self, *args): self.dict_of_equip = {'printer': [], 'scanner': [], 'xerox': []} self.company_parts = {'Office1': of1, 'Office2': of2, 'Office3': of3} self.equip = [*args] def get_new_eq(self): for x in self.equip: ...
71be83c77ab5477e6a414fa6a39a9d9c9dc621f6
Surgeom/geekbrains
/L4/4.py
99
3.546875
4
arr = [2, 2, 2, 7, 23, 1, 44, 44, 3, 2, 10, 7, 4, 11] print([x for x in arr if arr.count(x) == 1])
e3ff240361b92ab23abe3953a8d8ce20118c63ff
Surgeom/geekbrains
/les3/4.py
356
3.921875
4
def my_func(x, y): # return x**y res = 1 for i in range(abs(y)): res *= x return 1 / res num1 = float(input('действительное положительное число =')) num2 = int(input('целое отрицательное число = ')) if num2 < 0: print(my_func(num1, num2)) else: print('wrong input')
6a8f962aebd5ddd10742d907de30819d82ae5d1e
LaRenegaws/wiki_crawl
/lru_cache.py
2,955
4.125
4
import datetime class Cache: """ Basic LRU cache that is made using a dictionary The value stores a date field that is used to maintain the elements in the cache Date field is used to compare expire an element in the cache Persisted field is a boolean that determines whether it can be deleted """ def __...
0411e36a6d6971e4e9cc6e64ce2ef60377134563
NickGreiner/Kattis-Challenges
/pot.py
368
3.609375
4
import math numberOfAddends = int(input()) numberList = list() powerList = list() outputX = 0 for x in range(0, numberOfAddends): inputNumberStr = input() powerList.append(int(inputNumberStr[-1])) numberList.append((int(inputNumberStr[:-1]))) for i in range(0, len(numberList)): outputX = outputX + p...
1bbf75468d3961ae8e1ff106032c395d783a72ca
NickGreiner/Kattis-Challenges
/oddities.py
264
3.796875
4
# Nick Greiner # https://github.com/NickGreiner # Python 3.7 numberOfTests = int(input()) for x in range(0, numberOfTests): testInt = int(input()) if abs(testInt) % 2: print(str(testInt) + " is odd") else: print(str(testInt) + " is even")
282580cde5e853fc8bb7a0862a7b38589ad9725d
sshiraz/python_projects
/test/test_case_gen2.py
1,695
3.609375
4
import random def get_test_input(_min, _max, max_list_len, _type): test_list = list() test_item = list() test_list.append(list()) rand = 0 prime = 0 prime_n = 0 prev_prime = 0 next_prime = 0 # Random number test case for i in range(max_list_len + 1): rand = random.ran...
d48e8ab275f265be7d8b3ab340d003ca72f660ff
Ankur800/AI-Mafia---Machine-Learning
/Linear Regression/linear_regression.py
1,744
3.78125
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt # Get the training data dfx = pd.read_csv("/home/ankur/PycharmProjects/Data/linearX.csv") dfy = pd.read_csv("/home/ankur/PycharmProjects/Data/linearY.csv") dfx = dfx.values dfy = dfy.values x = dfx.reshape((-1,)) y = dfy.reshape((-1,)) x = (x - ...
770901dc56707532b24aa54387557df1b71fd255
jalexhurt/MLP
/mlp.py
15,801
3.5
4
# Multilayer Perceptron algorithm # implemented using backpropagation # @author James Hurt, 2017 import pandas as pd import argparse import os from pprint import pprint from random import random import math # my files from graph import * from calculations import * from constants import * def init(): """ Initi...
2a62d617276d960899b8acc15205ce12c86657a8
sebbele/advent-of-code-2019
/01-1.py
203
3.8125
4
#!/usr/bin/env python import input_day_one def fuelReq(mass): fuel = ( mass // 3 ) - 2 return fuel result = [] for i in input_day_one.input: result.append(fuelReq(i)) print(sum(result))
ebe8fe7b7fc7ef5d34a1bd5f37d75946f1488b55
raghsgit/python
/lynda/pattern.py
195
3.671875
4
import re def main(): name="raghvendra sharma" match =re.search('sharma',name) if match: print(match.group(),end='') else: print("not matched") if __name__=='__main__':main()
9ec2cfa7932338b245286784ce3b072887937bd5
duke79/compro
/src/python/codechef/JAN19B/HP18.py
310
3.71875
4
T = input() T = int(T) for i in range(T): try: N, a, b = input().split(" ") N = int(N) a = int(a) b = int(b) A = input() if (N % a) >= b or N < a: print("ALICE") else: print("BOB") except ValueError as e: pass
74808fffc09a46729907bee228a3be1fce16f6ad
s6fikass/semanticweblab2020-2021
/Code/Example Based explanations of a trained ML-model for RDF and Tabular data/ExampleBasedExplanations.py
2,153
3.59375
4
from KNNTabular import KNNTabular from KNN_RDF import KnnAndClusters from ProtoDashRDFImage import ProtoDash from pandas import read_csv class ExampleBasedExplanations: """ This class helps the user to understand and explain the behaviour of a machine learning model, by returning instances of the dataset...
f17f7281aa1d5b9e136e106816e47e8aad948f32
jbishop45/IoT_Projects
/betterTL.py
1,400
3.578125
4
import RPi.GPIO as GPIO # import RPi.GPIO module import random from time import sleep # lets us have a delay GPIO.setwarnings(False) # Ignore warning GPIO.setmode(GPIO.BCM) # choose BCM or BOARD GPIO.setup(17, GPIO.OUT) GPIO.setup(27, GPIO.OUT) GPIO.setup(22, GPIO.OUT) GPIO.setup...
56f5b5c4c32b21314261232513d4951e3e518a8d
jeanmobayed/fingo-python-test
/Part 1/main.py
1,140
3.5
4
#!/usr/bin/env python #coding=utf-8 import sys import os from input_parser import InputParser from file_handler import FileHandler DEFAULT_ANSWER = "I have no idea what you are talking about" def start_process(input_file, output_file): handler = FileHandler(input_file, output_file) info = handler.read_file...
cb6e09b2e0a14b39d37799aeea1d7fe29bbd08d5
zzooeexx/BlackJackGame
/bj.py
9,453
3.859375
4
import display import os import time class Card(): # Class Card: one card with rank, suite, number and point def __init__(self, suite, number): """ :param self: one card with rank, suite and point :param suite: int num 0-3 :param number: int num [0, 1, ..., 9, 10, 11, 12], repr...
88c9cfd6d9f8b255b6f1efd822369cfbcc611833
DanielKenji/46exercises
/vowel.py
285
4.03125
4
# Return True if a vowel is given, otherwise, return False def vowel(character): if len(character) == 1 and character in 'aeiou': return True else: return False if __name__ == "__main__": character = input('Type a character: ') print(vowel(character))
7f73f9405b2e855d6fa19eefae9dfb8714da06a3
ritikkr/HackerRank-Solution
/Interview Preparation Kit/Sock Merchant.py
1,154
3.515625
4
#!/bin/python3 import math import os import random import re import sys # Complete the sockMerchant function below. def sockMerchant(n, ar): if(n<1 or n>100): sys.exit() for i in range(0,len(ar)): if(ar[i]<1 or ar[i]>100): sys.exit() count=[x for x in range(0,101)] #print(...
6e1b7f3d3f7edcde922e5fbb225a8fd98288d222
ritikkr/HackerRank-Solution
/Python/Find a string.py
254
3.65625
4
def count_substring(string, sub_string): if(len(string)<1 or len(string)>200): exit() count=0 l=len(sub_string) for i in range(0,len(string)): if(string[i:i+l]==sub_string): count=count+1 return count
67bd243bfe5ff1629b8167e86dd5f0baa701abad
ritikkr/HackerRank-Solution
/Python/39/Find the Runner-Up Score.py
497
3.53125
4
import array as arra import sys n = int(input()) arr = map(int, input().split()) numbers_array = arra.array('i', arr) list2=sorted(numbers_array) for i in range(0,len(list2)): if((n<2 or n>10 ) and (list2[i]<(-100) or n>100)): sys.exit() else: #print(list2) max_number=max(list2) ...
448aa1aead420c84febe08b1d5dcecff30b28d85
canlasd/Python-Projects
/Assignment3.py
450
4.1875
4
wind=eval(input("Enter Wind Speed")) if wind>=74 and wind <=95: print ("This is a category 1 hurricane") elif wind<=96 and wind <=110: print ("This is a category 2 hurricane") elif wind<=111 and wind <=130: print ("This is a category 3 hurricane") elif wind<=131 and wind <=155: ...
889aef14a6ae52d66a34cd96484dca9f50093b7f
canlasd/Python-Projects
/Lesson6_part2.py
430
4
4
from Lesson6 import Time """ # First Time object myTime1 = Time() # myTime1.print_time() myTime1.set_time(1, 2, 3) # Second Time object myTime2 = Time() myTime2.set_time(12, 0, 0) print ("My two time objects are now storing:") myTime1.print_time() myTime2.print_time() print(myTime1.__class__) """ myTime=Time()...
974b1c62f643c85dfcdaf4b7853eb877f124c1e9
canlasd/Python-Projects
/Assignment2.py
143
3.671875
4
value=input("Please enter phrase: ") start=eval(input("enter starting number")) end=eval(input("enter end number")) print(value[start:end+1])
a948a80685a9177de796b86db40e6f49d957a120
komal-kharche/python-test
/list3.py
110
3.625
4
num = [1,2,3,4,5,6,7,8,9] print num[2:7] print num[2:] print num[:2] print num[1::] print num[3::5]
acfa5b9461198cb4a9f35cf7445f7a30435bf8f4
QuantumWarlock/BBW
/scripts/collision_box.py
6,893
3.578125
4
# -*- coding: utf-8 -*- """ Created: Apr 2020 Classy Interacting Bouncing Balls in a box! @author: Ryan Clement (RRCC) """ import random import math as m import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation ### Ball Class: class Ball: """ Class for bouncing ...
482b7d2e897b8ec806472a58099bb097e722cc17
mdeehan/Assessment-6
/WOF.py
7,010
3.859375
4
#Here is my player class to help display the three players in the game. class gamePlayers: def __init__(self, name): self.name = name self.money = 0 def totalMoney(self, total): self.money = self.money + total def bankrupt(self): self.money = 0 def person(self): r...
63114c7c063d18756984c9c24d2d20debc915ebe
ChangYuTeng/ai108b
/homework/HWSV_pbm/HWSV_pbm.py
3,389
3.78125
4
# initial data obj = ["Human", "Wolf", "Sheep", "Kale"] # Obviously, these are objects. (Kale : 甘藍菜 status = [False, False, False, False] # This is all initial status of the former objects. htySta = [status] # This variable could help recording which step we've gone to. sl...
b2461bd6bea2a648796bdef105f281a2d27fd2da
preesha410/DNA-string-Complement_and_GC_content
/REVERSE COMPLEMENT PROGRAM.py
224
3.578125
4
dna= ("attatagtatg") a=0 t=0 g=0 c=0 for i in dna: if i=="a": a=a+c elif i=="t": t=t+g elif i=="c": c=c+a elif i=="g": g=g+t else: pass return dna
b38edcac1a37b87a36cb9749ca253e2dabddf6b2
adnam/playground
/nearest-pairs/sorted_pairs.py
4,178
4.4375
4
""" Find closest pairs of a list of coordinates """ from itertools import combinations def squaredist(coords): """Calculate the square of the distance between a coordinate pair coords = ((X1, Y1), (X2, Y2)) """ return pow(coords[0][0]-coords[1][0], 2) + pow(coords[0][1]-coords[1][1], 2) def dist(P1, ...
f081a842c4af90ff60ac5efd0404cc4833e130b7
sakshigavali1998/python_programms
/5th.py
115
3.78125
4
s = input("enter words:") lst = s.split(",") print(lst) lst.sort() print("after sorted:") print(','.join(lst))
4007c4df78660bf55fee24a48bc440d3983249fa
sakshigavali1998/python_programms
/10.py
188
3.59375
4
str = input("enter sentence:") c1 = 0 c2 = 0 for i in str: if(i.isdigit()): c1 = c1+1 print(c1) for j in str: if(j.isupper()): c2 = c2+1 print(c2)
191b1ff2c3fb6949583ec24f2434becc9182f679
jane-lind/PaperScripts_OpenAccess
/BacterialGenomeMiningPaper2016/ReduceCountmatrixV2.py
7,415
3.90625
4
#!/usr/bin/python2.7 -w """ DESCRIPTION: The program reduces the count_matrices by a predefined average minimum count, that has to be present within each row. 0. Input argument and help program 1. Printing overview of the arguments onto screen 2. Print rows defining shared sets of genes. INPUT FILE FORMATS: I...
8cb436db1dec9bd1f1a13a1a478b0d80f98a44bb
uglyfruitcake/EulerPython
/my_module/generate_even_fibonacci.py
273
3.640625
4
import my_module def generate_even_fibonacci(first_seed, second_seed, max_value): even_fibonacci = [] for i in my_module.generate_fibonacci(first_seed, second_seed, max_value): if i % 2 == 0: even_fibonacci.append(i) return even_fibonacci
72e0da6ca6b44c9e861bb1a37f11ea6386aff5e2
uglyfruitcake/EulerPython
/my_module/largest_product_of_consecutive_integers_in_array.py
429
3.640625
4
def largest_product_of_consecutive_integers_in_array(array, number_of_ints): lower_bound = 0 upper_bound = number_of_ints n = 1 largest_sum = 0 while lower_bound < len(array) - number_of_ints + 1: for i in array[lower_bound:upper_bound]: n *= i if n > largest_sum: ...
20b75e62c93ed01010d5507d7672c0e8c9e9d51b
uglyfruitcake/EulerPython
/my_module/generate_triangular_numbers.py
289
3.578125
4
def generate_triangular_numbers(ceiling): number = 1 triangular_number = 0 triangular_numbers = [] while triangular_number < ceiling: triangular_number += number triangular_numbers.append(triangular_number) number += 1 return triangular_numbers
14d4ea24d5cfc0dd0b9ea1cfd6761677c295ce66
EnedinoAndre/Estrutura-De-Dados-em-Python
/Prova2_estruturaDeDados/Questao4 - Pilha/arqPilha.py
670
3.953125
4
class Pilha(): def __init__(self): self.pilha1 = [] self.pilha2 = [] def getPilha1(self): return self.pilha1 def getPilha2(self): return self.pilha2 def setPilha1(self, elemento): self.pilha1.append(elemento) def copiarPilha(self): pilhaAuxiliar = [...
4ab785360e93b4392df7cb03cd3f79ae23573f37
EnedinoAndre/Estrutura-De-Dados-em-Python
/Aula 8 - dicionario/exercicio_dicionario.py
2,327
3.921875
4
from numpy import double dicionario = {} def cadastrar(chave,nome,divida,telefone,endereco): dicionario[chave] = [nome,divida,telefone,endereco] def atualizar(nome,valor): for item in dicionario.items(): if nome in item[1][0]: item[1][1] = item[1][1] - valor return item[1][1] ...
804f8471327d7b8cfd0b5e5661f6b154092bdef4
Windsooon/LeetCode
/Word Break II.py
792
3.5
4
class Solution: def wordBreak(self, s, wordDict): self.wordDict = wordDict self.dic = {} result = self.recu(s) lst = [] for r in result: lst.append(' '.join(r)) return lst def recu(self, s): if not s: return [[]] elif s in ...
252c66e955830f6f83d552afa3153aebd16cfe6b
Windsooon/LeetCode
/Valid Perfect Square.py
987
3.78125
4
class Solution: def isPerfectSquare(self, num): """ :type num: int :rtype: bool """ # binary search if num == 1: return True # 0 5 left, right = 0, num//2+1 while right - left > 1: # 2 mid = (left+right)//2 ...
fe2436a522288d993141794054c0acf98944e6c1
Windsooon/LeetCode
/Power of Three.py
377
3.703125
4
class Solution: def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ if n <= 0: return False while n: k = n % 3 if k != 0 and n != 1: return False n = n//3 return True s = Solution() pr...
0440011e217cf00fd4b55d20d00b6ab034abcf6d
Windsooon/LeetCode
/Find the Shortest Superstring.py
2,119
3.5625
4
import collections import queue class Solution: def shortestSuperstring(self, A): lst = self.build_graph(A) return self.prim(lst, A) def calculate_distance(self, str1, str2): first = second = 0 for i in range(len(str2)): if str1.startswith(str2[i:]): ...
9a9e8daa67f634dfc5732393231737df6b1ce43d
Windsooon/LeetCode
/Container With Most Water.py
1,480
3.921875
4
''' The graph look like this, We set two points at the first and the last element, then keep compare two value, than move the pointer which own the least value. y | | a2 | | a3 an | a1 | | a5 | | | | | a4 | | | | | | | | .. | -----------------...
cf1fdb3c58d99d16efc1276224e0cf1a755f0e5b
Windsooon/LeetCode
/Simplify Path.py
554
3.71875
4
class Solution(object): def simplifyPath(self, path): stack = [] place = [p for p in path.split('/') if p != '' and p != '.'] for p in place: if p == '..': if stack: stack.pop() else: stack.append(p) return '...
c1b7fb9f359a19693bc1e2d7d979065c7a988ad1
Windsooon/LeetCode
/Next Greater Element I.py
755
3.640625
4
class Solution: def nextGreaterElement(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ if not nums1 or not nums2: return [] dic = {} stack = [] for i in range(len(nums2)): whi...
84a509db31a7a5ba01072deb1094d09804d08dfb
Windsooon/LeetCode
/Length of Last Word.py
592
3.625
4
class Solution: def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ if not s: return 0 count, start, last = 0, False, len(s)-1 while last >= 0: if s[last] == ' ': if start: return count ...
e276da5e01a01666a5a61b9c387544a845e4bf7b
Windsooon/LeetCode
/Toeplitz Matrix.py
787
3.625
4
class Solution: def isToeplitzMatrix(self, matrix): self.seen = set() for i in range(len(matrix)): for j in range(len(matrix[0])): if (i, j) not in self.seen: if not self.check(i, j, matrix): return False return True ...
4014a366a7b4e6745b8ae5a0801c616f9ed3ee1b
Windsooon/LeetCode
/Bracket Match.py
454
3.703125
4
def bracket_match(text): count = 0 lst = [] for t in text: if t == '(': lst.append(t) else: if not lst: count += 1 else: tem = lst.pop() return count+len(lst) assert bracket_match(')') == 1 assert bracket_match('(') ==...