blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5fce1e2595ed7c9c7fb24b8e96de88d84edbe971
UW-ParksidePhysics/Jones-Julia
/4.2_f2c_cml_02.py
375
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 29 16:13:56 2020 @author: julia """ ### Program to convert Farenheit to Celcius via the command line import sys # Command line user input F = int(sys.argv[1]) # 4.2_f2c_cml_[02].py 300 # Function code def T(F): T = (5 / 9) * (F - 32) ret...
44c7c8f2f55257e5cbf9b4f21a5a4f1f87a048ea
yuvalperes/Distributed-computing
/consensus_repeated_majority.py
5,451
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sun June 02 18:05:49 2019 This program implements the repeated majority protocol for distributed computing (population protocol model). There are n nodes, each having an initial belief (a bit in {0, 1}). The goal is that after running some distributed protocol each node ha...
f96c5201ecea49527afcc2bb93eaf384eddd31aa
pallavije/-An-Analysis-of-the-Effect-of-News-Sentiment-on-the-Stock-Market-using-LSTM
/stockPredictions_Without_News.py
3,440
3.640625
4
# Importing the libraries import matplotlib.pyplot as plt import pandas as pd import numpy as np from sklearn.preprocessing import MinMaxScaler from sklearn.model_selection import train_test_split from keras.models import Sequential from keras.layers import Dense, LSTM, Dropout # loading dataset dataset = pd.read_c...
297c6e0a12304e5487609c3f792d8d33dfdd2a75
Adiboy3112/KOSS-TEACHING-TASK
/Koss_codes/Context Managet tutorial code/class_contextmanager.py
723
3.84375
4
class open_file(): def __init__(self,filename, mode):#will take the parameters to open file self.filename=filename self.mode = mode self.file = open(self.filename,self.mode) print("your file has been opened!") #file opened def __enter__(self):...
57b85d6d1fd74764abb6c050da06652cdaaf24dd
proleaders/python_problem_solving
/Minimum Distances.py
1,217
4.0625
4
#!/bin/python3 import math import os import random import re import sys # Complete the minimumDistances function below. def minimumDistances(a): li = [] # nested loop is applied to find out the the matching pair of elements in the given array for i in range(len(a)): for j in range(len(a)): ...
a755bf44d79525affb7c53c13d367878cdd3819c
stoneeve415/LintCode
/_56_k_sum.py
5,223
3.65625
4
""" @title: 56 57 58,K个数之和 @author: evestone """ ''' 2-sum ''' # 使用hash表 # 2-sum def two_sum(arr, target): hash = {} for i, item in enumerate(arr): if target-item in hash: return [hash[target-item], i] hash[item] = i return [-1, -1] # 遍历即可 # 2-sum class TreeNode: def __in...
2da242c99607b5007458aa04fcae524c871a94b7
Dheebhika/Python-beginner
/day_2/parameters.py
231
3.640625
4
def with_default_parameters(number1=10, number2=10): if number1 != number2: return number1 + number2 else: return (number1 + number2) * 2 print(with_default_parameters()) print(with_default_parameters(2))
d9146a29ae5785023096c03d44a9188271d17419
NTR1407/python
/Prueba/ordenamiento.py
216
3.671875
4
def ordenamiento(lista): z = [] for i in lista: z.append(''.join(sorted(i,key=str.upper))) return z print(ordenamiento(lista = ["Hola","soy","el","candidato","al","cargo","Data Expert"]))
30872f86a64ea320710460c5f9967c65d92fe727
EMIAOZANG/assignment4
/lw1582/answer8.py
204
3.671875
4
#!/usr/bin/env python d = {'first' : [2,1],'second' : [2,3],'third' : [3,4]} a = d['first'] d['first'] = d['third'] d['third'] = a d["third"].sort() d['fourth'] = d['second'] del d['second'] print d
a5d9f3b74fbe6142295a57668edc4fdbb6d567d0
CowsSayOink/Euler
/Euler36.py
403
3.78125
4
def conv(x): """ Converts from binary to decimal""" return int(x[2:]) def ispal(x): a=str(x) b=len(a) for c in range((b//2)+1): if a[c]!=a[-1-c]: return False return True total=0 for a in range(1000000): if ispal(a)and ispal(conv(bin(a))): ...
0ed0bf532065c01e8ca4f7a9cbb8527e26f57ae1
robert/programming-feedback-for-advanced-beginners
/editions/1-2-tic-tac-toe/original.py
10,771
3.984375
4
## This code is made available under the Creative Commons Zero 1.0 License (https://creativecommons.org/publicdomain/zero/1.0) # -*- coding: utf-8 -*- """ Created on Tue Oct 29 10:40:33 2019 """ from random import randint class Board: """ Class defining a tic-tac-toe board and associated methods """ ...
eb4d5b1f85c330dbdb68e8785a4333656069cb9b
danielmoralesp/python-basics
/basics-2/binary_search.py
777
4
4
# -*- coding: utf-8 -*- def binary_search(numbers, number_to_find, low, high): if low > high: return False mid = (low + high) // 2 if numbers[mid] == number_to_find: return True elif numbers[mid] > number_to_find: return binary_search(numbers, number_to_find, low, mid - 1) ...
b70686b6a8dc48f2c1a5b7e5fd47bfabf5ddc36c
Masum148/php
/Python-If-Else.txt
391
3.734375
4
#!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': a = int(input().strip()) if (a%2==0): if(a>=2 and a<=5): print("Not Weird") elif(a>=6 and a<=20 ): print("Weird") elif(a>20): p...
08330146e994f6d55272b41892f22d932e013014
VamsiKumarK/Practice
/_00_Assignment_Programs/_02_Functions/_03_Factorial.py
555
4.125
4
''' Created on Nov 20, 2019 @author: Vamsi ''' ''' finding factorial of a given number using while loop ''' num = 5 def factorial(n): num = 1 while n >= 1: num = num * n n = n - 1 return num print('The factorial of given number: ', factorial(num)) print("_____________________________...
2b69c039afdef2acd5cac18328278a6ff2c767cd
chetan2469/git
/pythonDemos/skicit.py
549
3.546875
4
# load the iris dataset as an example from sklearn.datasets import load_iris iris = load_iris() # store the feature matrix (X) and response vector (y) X = iris.data y = iris.target # store the feature and target names feature_names = iris.feature_names target_names = iris.target_names # printing features and target ...
0ab9e5d178d189ae5cae448a1d491dce5b804cc6
syurskyi/Python_Topics
/115_testing/_exercises/exercises/The_Ultimate_Python_Unit_Testing_Course/Section 9 Testing Efficiency/fourth_project.py
429
3.546875
4
# """ # the FibonacciSequence class has two methods that are able to compute the Fibonacci Sequence. # """ # f____ ma.. _______ sqrt # # # c_ FibonacciSequence # # ___ recursive_method n # __ ? __ 0 # r_ 0 # ____ ? __ 1 # r_ 1 # e___ # r_ ?(? - 1) + ?(? -...
7ade6fe5b01f92fd24adf8c3d451700dfbb2e445
wangha43/learnpythonthehardway
/ex24.py
893
3.71875
4
print "Let's practice everything." print "You\'d need to know \'bout escapes with \\ that do \n newline and \t tabs." poem = """ \t The lovely world with logic so firmly planted can not discern \n the needs of lovely nor comprehend passion from intuition and requires an explanation \n\t\t where there is none """ pri...
fe25237f837fe32df590ac3ad461d7df6190965f
mrtn-c/DHSolo
/EJERCICIOS/String/ej3.py
741
4.125
4
'''modificar el programa para que reciba dos números enteros que permitandefinir el comienzo y el fin de caracteres a extraer del string original''' str = input("Ingrese una frase ") cond = True pos1 = 0 pos2 = 0 while (cond): pos1 = int(input("Escoga un numero, esta sera la posicion comienzo del string: ")) ...
30c9bca193f0be87507330d811ef7b8120954aec
ParulProgrammingHub/assignment-1-Dhruvil12345
/program1.py
208
4.28125
4
length = float(input("ENTER THE LENGTH:")) breadth = float(input("ENTER THE BREADTH:")) perimeter = (2*breadth)+(2*length) area = length*breadth print ("PERIMETER = "+"",perimeter) print ("AREA = "+"",area)
17311a91568745564287fab293fe070df630323b
gordonmannen/The-Tech-Academy-Course-Work
/Python/Python In A Day - Richard Wagstaff - Py2.7/Chap7 Going Loopy.py
486
4.4375
4
# Start counter at 0 counter = 0 # While 'counter' is less than or equal to 5, # run the loop while counter < 5: # Show counter value print counter # Shortcut to increase counter by 1 counter = counter + 1 # can shortcut above to counter += 1 # Run loop in range 0 - 5 # Counter changes automatica...
d333b0264f1b2c0a88168bffe9a994f910887ca5
marcoportela/python
/exercicio02_marco_07.py
971
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 13 19:26:36 2014 7. Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam...
0c7f4faed3c125af1e379025c60f7708e1e58eab
forbearing/mypython
/1_python/4_字符串.py
4,834
4.21875
4
1:概念: 1:以单引号或双引号扩起来的任意文本 2:字符串是不可变的 2:字符串运算 str1 = "Hello Linux" str2 = "Hello Python" str3 = str1 + str3 3:输出重复字符串 str4 = "hello" print(str4 * 3) 4:字符串索引下标,访问某一字符 str5 = "Hello Python" print(str5[4]) 5:字符串截取 str1 = "Hello linux, Hello python" print(str1[2:7]) ...
3dfa25519b2ef21b856a425e0605562373a14716
NaraJulia/programacao-orientada-a-objetos
/listas/lista-de-exercicio-05/Questao08.py
102
3.625
4
QUESTAO 08 def digitos(n): s = str(n) return len(s) n = int(input()) func = digitos(n) print(func)
31e4d3826757422b1fb7eff333e5b58d13995fc0
prashantstha1717/python-assignment-II
/7.py
692
4.28125
4
# 7. Create a list of tuples of first name, last name, and age for your friends and colleagues. # If you don't know the age, put in None. Calculate the average age, skipping over any None values. # Print out each name, followed by old or young if they are above or below the average age. peoples = [('Ram', 'Karki', 50)...
77f8727007b837834cef787bce83311a5e70d01f
TimBeishuizen/GraduationFilesGithub
/Data Mining Seminar/SkinDiseaseTPOT/PipelineFinder/PipelineSelection.py
1,586
3.515625
4
from tpot import TPOTClassifier from sklearn.model_selection import train_test_split from DataExtraction import DataExtraction as DE import os def select_pipeline_tpot(data_name, train_size, max_opt_time, n_gen, pop_size): """ Selects the best pipeline with tpot and exports its file :param data_name: Name of...
440feafc08c87e90d26469d6062d07d28fa96c37
Abisha0415/hello-world
/coding_practice_2020_11_27.py
960
3.71875
4
print("Excercise 1") # from 385 to 493 by 9 i = 385 while i <= 493: print(i) i += 9 print("Excercise 2") # from 429 to 625 by 7 i = 429 while i <= 625: print(i) i += 7 print("Excercise 3") # from -11 to 781 by 18 i = -11 while i <= 781: print(i) i += 18 print("Excercise 4") # from 54 ...
b5cab2f922dca484635733620c6fc1ecff940621
DevAhmed-py/Pirple.py
/Fizz Buzz Assignment/Fizz Buzz.py
265
3.796875
4
for i in range(1,101,1): if i%15 == 0: print("FizzBuzz") elif i%3 == 0: print("Fizz") elif i%5 == 0: print("Buzz") elif i>1 and i%i == 0 and i%2 == 1: print("Prime") else: print(i)
fe61a5957079fbf7389198b6e18265efa4bacc54
bradgoldstein/algo
/python/merge_sort.py
1,147
4.03125
4
# Merge Sort sorting alogrithm # # See p.30-37 in CLRS 3rd ed. # # Author: Bradley Goldstein # Merges two contiguous, sorted sublists, A[p...q] and A[q+1...r] so that # A[p...r] is now sorted. Uses temporary arrays of size O(len(A)). # # Args: # A: a list containing values to be merged # p: start index of first list...
60cb014adb3a1ad1d68f6f2f28dc0b15886d560d
MerreM/SNscraper
/demo.py
1,545
3.71875
4
#!/usr/bin/env python from multiprocessing import Process, JoinableQueue # Messy, but acceptable config. NUMBER_OF_CONSUMERS = 2 def put_in_numbers(queue): """ The producer method, if you passed in another argument, like... a url this could run your scraping. """ for i in range(100): queue...
1fc3626d250c01d9f79292f1ab6fac61f5816c9e
HarshitaMBharadwaj/HarshitaMBharadwaj
/assignment2prob2.py
360
4.03125
4
#Read three integers from the keyboard a,b,c, d and those values in the following order. #max > mid1 > mid2 > min a=int(input("a=")) b=int(input("b=")) c=int(input("c=")) d=int(input("d=")) list_1=[a,b,c,d] e=max(list_1) list_1.remove(e) f=max(list_1) list_1.remove(f) g=max(list_1) list_1.remove(g) h=min...
1b6810c6a56c6f61c7f8712997da0b02cc5ee9fb
octsama/leetcodeex
/226-InvertBinaryTree.py
1,336
3.84375
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if root is None: return None if ro...
8993b23934f1c8ed01228a5a96a7eb4fee0a0861
NUS-Projects-Amir/CS3243-Project-1
/Old Code Versions/bfs_1_1.py
3,516
3.8125
4
class Puzzle(object): def __init__(self, init_state, goal_state): # you may add more attributes if you think is useful self.init_state = init_state self.goal_state = goal_state self.visited_states=[init_state] def solve(self): #TODO # implement your search algori...
66a64580f5767d42e75be049915dd2e4bcc2d9e3
xiaole0310/leetcode
/648. Replace Words/Python/Solution.py
1,390
3.71875
4
class Solution: def replaceWords(self, dict, sentence): """ :type dict: List[str] :type sentence: str :rtype: str """ class TrieNode: def __init__(self, val): self.val = val self.children = [None] * 26 self....
379d24b9475d657f0119c902b525703696df3150
jelena-vk-itt/jvk-tudt-notes
/swd1-pt/res/files/python/pbl_solutions/pbl4.py
2,589
3.703125
4
from random import * currentUniqueCode = 2 items = [[1, "bread", 1.5, 10], [2, "milk", 2.0, 8]] option = 0 while option != 5: print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") print("-----------------------------------------") print(" Groceries at Your Fingertips ") pr...
b381574abaa9d5701d17c986af6df0f7b21f086c
ahmedAli21/reservation2
/reservation.py
1,627
3.921875
4
hotels = [] # defin a list for hotels customers = [] # define a list for customers reservations = [] # defin a list for reservations # first functions to add hotels and it's data & information def add_hotel(number,hotel_name,city,total_rooms,empty_rooms): hotels.append([number,hotel_name,city,total_rooms,e...
2100568bb0f2b4dde27f2dfb1db9680d379b6ef4
dhermes/project-euler
/python/complete/no046.py
859
3.921875
4
#!/usr/bin/env python # What is the smallest odd composite n that can't be written n = p + 2k^2 # for some prime p and some integer k? from python.decorators import euler_timer from python.functions import is_power from python.functions import sieve def is_possible(n, primes): if n % 2 == 0 or n in primes: ...
a011bdd2a0f34804f9c4440c515b52727bb7f81a
Vishnumenon359/bookyourMovieProject
/movie.py
4,019
3.984375
4
#!/usr/bin/env python3 import sys import copy class Movie(): def __init__(self,rows=0, seats=0): self.rows = rows self.seats = seats self.total_seats = self.rows*self.seats self.seat_matrix = [None] * self.rows self.total_bookings = 0 self.current_income = 0 def...
5612382e2b6efadd9cdb0d0da98e0991ec709f48
brillantescene/Coding_Test
/LeetCode/Graph/combinations.py
989
3.546875
4
class Solution: def combine(self, n: int, k: int) -> List[List[int]]: def dfs(level, start): if level == k: result.append(res[:]) return for i in range(start, n+1): res[level] = i dfs(level+1, i+1) res = [0] * k...
65ec11a38a95295dfc22111efae65c0232c94b63
ge1016/python_work
/practice.py
466
4.03125
4
#coding:utf-8 filename = 'txt_files\pi_digits.txt' with open(filename) as file_object: lines = file_object.readlines() # жȡ洢һlist pi_string = '' for line in lines: pi_string += line.strip() #ȥߵĿհ print(pi_string) print(len(pi_string)) birthday = input('Enter your birthday: ') #жǷpi if birthday in pi_string: print...
ebd55cfcea4c383d6b0a7fc3cb5362bd6da7472d
dwiel/boring
/boring.py
799
3.921875
4
import itertools import random symbol = "*" format = "{x} {symbol} {y}" x_low = 2 x_high = 9 y_low = 1 y_high = 12 x = set(range(x_low, x_high + 1)) y = set(range(y_low, y_high + 1)) problems = itertools.product(x, y) problems = list(problems) problems = [(x, y, eval(format.format(x=x, y=y, symbol=symbol))) for x, y...
0b540c58bd45a56d78808e92bdbe7f8b403f95c6
akbarbelif/Python
/Python_29-5-2019/Basic Python/Rev_string.py
489
4.03125
4
#Enter First_Name def FirstName(): s=True First=input('What is your FirstName ') if not First: s=False return First #Enter Last_Name def LastName(): s=True Last=input('What is your LastName ') if not Last: s=False return Last #Reverse_Name def Revname(Rev_string): R...
ce66a9f5e09027ecc6784ffd9e8e810ee8145422
YingheSun/algorithms
/sort/E1_BubbleSort.py
390
3.796875
4
# coding:utf-8 import random def bubbleSort(nums): for i in range(len(nums)-1): # 这个循环负责设置冒泡排序进行的次数 for j in range(len(nums)-i-1): # j为列表下标 if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j] return nums nums = [random.randint(1,9999) for i in range(1000)] ...
db97ad39dc4c39620b3285751f375d4c75fd167a
himu999/Python_oop
/H.inheritance/c.inheritance.py
1,092
4.15625
4
class Vehicle: """Base class for all vehicles""" def __init__(self, name, manufacturer, color): self.name = name self.color = color self.manufacturer = manufacturer def drive(self): print("Driving", self.manufacturer, self.name) def turn(self, direction): print...
43a2d4a82c8526499af7745c45b7046096d55101
rahulsaini/Python-Basics
/decorators1.py
738
4.59375
5
# a decorator is a function that takes another function and # extends the behavior of the latter function without explicitly modifying it. #Decorators provide a simple syntax for calling higher-order functions. # function that does at least one of the following: #----takes one or more functions as arguments (i.e. proc...
4bb3d23ac5cafb2832a87b1d13365105138bfe22
artbohr/codewars-algorithms-in-python
/7-kyu/alien-accent.py
543
4.0625
4
def convert(st): return st.replace('o','u').replace('a','o') ''' The Story: Aliens from Kepler 27b have immigrated to Earth! They have learned English and go to our stores, eat our food, dress like us, ride Ubers, use Google, etc. However, they speak English a little differently. Can you write a program that conve...
777a933a45b485f838267a4dc1b57e549908cd3c
polyglotm/coding-dojo
/coding-challange/codewars/7kyu/2019-xx-xx~2020-01-18/alphabetical-addition.py
411
3.859375
4
# https://www.codewars.com/kata/alphabetical-addition def add_letters(*letters): return chr((sum([ord(x) - 96 for x in letters or 'z']) - 1) % 26 + 97) print(add_letters('a', 'b', 'c')) # = 'f' print(add_letters('a', 'b')) # = 'c' print(add_letters('z')) # = 'z' print(add_letters('z', 'a')) # = 'a' print(add_let...
8838115b635a88f2cf3fdc4743f23981febfac6a
patrick-du/Notes
/Courses & Books/Grokking Algorithms/quick_sort.py
2,325
3.9375
4
# Divide-and-conquer (D&C) is a recursive algorithm # To solve a problem using D&C: # - Figure out base case # - Divide or decrease problem until it becomes the base case # Exercise 4.1: Recursive Implementation of Sum Function def recursive_sum(arr): if arr == []: return 0 return arr[0] + recursiv...
8cb1f2c6b1d6f883004b3cf4c0ff2869c2d33956
Runpython-IntroProgramming/tests
/exemplars/fizzbuzz.py
604
4.21875
4
maxn = int(input("How many numbers shall we print? ")) fizzn = int(input("For multiples of what number shall we print 'Fizz'? ")) buzzn = int(input("For multiples of what number shall we print 'Buzz'? ")) for n in range(1,maxn+1): fizzmultiple = not n % fizzn # % calculates remainder of division - zero if n is mult...
dd82d081e320be168c80ac4ae11655569f7ede3d
noobcakes33/Ladder11
/59A_word.py
219
3.984375
4
word = input() upper = lower = 0 for i in range(len(word)): if word[i].islower(): lower += 1 else: upper += 1 if lower < upper: word = word.upper() else: word = word.lower() print(word)
348d903e40495932fdc441e4278d2bd01e94cb47
MagicianQi/CrackingCoding
/2.Linked Lists/2.4.py
1,764
4.34375
4
# -*- coding: utf-8 -*- """ Question 2.4: Partition: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. if x is contained within the list, the values of x only need to be after the elements less tha...
0b949cf655f35d6aa158cb219d861567268b4971
spratt/physics.py
/physics.py
3,196
4.25
4
#!/usr/bin/env python3 """physics.py Written by Simon Pratt Inspired by: http://gafferongames.com/game-physics/integration-basics/ """ class Coord: """A pair of coordinates x,y >>> origin = Coord() >>> origin.x 0 >>> origin.y 0 """ def __init__(self, x = 0, y = 0): """Initiali...
dfe5fb30f1e51e8596c6915d25cef5be91f89af0
elsoroka/StanfordAA222Project
/data/datacruncher_hack_write_real_schedule.py
3,181
3.796875
4
# File created: 05/18/2020 # Tested on : Python 3.7.4 # Author : Emiko Soroka # Unittests : None # Description : # Quick hack to ingest JSON data and spit out CSV files, will extend later # How to use : Run file. Enter input JSON file when prompted and output CSV file name when prompted. import json def par...
97699af056047b831ac1701a65dfb75cbdd741ba
Elyalya/BlockChainNEKA
/crypto/sertif_center.py
700
3.640625
4
def check_publickey(public_key): database=read_file() for i in range(len(database)): if(database[i]==public_key): return False def check_write(public_key): database=read_file() for i in range(len(database)): if(database[i]==public_key): return False write_to_f...
03b6282095ac46d8bccb7e1b63529dd029676147
tanmayee2000/python_practice
/pattern2.py
167
3.5
4
import string ls = list(string.ascii_lowercase) n = 5 for i in range(1,n+1): print('\n''a', end='') for j in range(1,i): print('-'+ls[j], end='')
e78a681103e2a0644ab1ad8c9859aef1b43062ab
Jgoschke86/Jay
/Classes/py3interm/EXAMPLES/with_ex.py
507
3.578125
4
#!/usr/bin/python3 import sys class Thing(object): def __init__(self,magic_word='poof'): self.magic_word = magic_word def __enter__(self): print("Entering context") return self def __exit__(self,objtype,value,traceback): print("Exiting context") print(...
a535c66d601c1cd8389db7a41a78edd1c2d002d4
edibusl/stocks-predict
/main.py
5,196
3.578125
4
import os import math import datetime import random import pandas as pd import numpy as np from matplotlib import pyplot as plt import matplotlib.dates as dates from pylab import rcParams from sklearn.preprocessing import MinMaxScaler from sklearn.model_selection import train_test_split from sklearn.linear_model import...
987fda3d9e92d5b8946625cc91646b49c0831fc8
qrzhang/Codility
/Codility/solution3.py
1,300
3.875
4
def solution(A): """ :param A: array, An array consisting of N integers :return: int, the number of identical pairs of indices """ # A is an empty array or single element array if len(A) < 2: return 0 # First, calculate the frequency of identical elements in a given array dicA...
aa982e05118414cacaf8396b1760b4afd84e87c5
behrouzmadahian/python
/python-Interview/2-arrays/29-unsortedPiece.py
682
4.1875
4
''' Given an unsorted array arr[0..n-1] of size n, find the minimum length subarray arr[s..e] such that sorting this subarray makes the whole array sorted. Example: [10, 12, 20, 30, 25, 40, 32, 31, 35, 50, 60], your program should be able to find that the sub array lies between the indexes 3 and 8. ''' d...
4f465838eb634c3e774d2ebf9251f24ee84e9992
MaartenAmbergen/TICT-V1PROG-15-Maarten-Ambergen-
/Les03/pe3_3.py
235
3.84375
4
Leeftijd=eval(input('Hoe oud ben je? ')) Paspoort=input('Ben je in heb bezit van een Nederlands paspoort? ') if Leeftijd >17 and Paspoort=='ja': print('Gefeliciteerd, je mag stemmen!') else: print('Helaas, je mag niet stemmen')
ca517489ef1bdde74081fdb368125cfa74832a28
Keitling/algorithms
/python/Searching/DepthFirstSearch/dfs_grid.py
2,135
3.875
4
# This python file uses the following encoding: utf-8 """ Depth-first search algorithm implemented in a grid. Like a breath-first search, but uses a stack instead of a queue. The algorithm: while boundary is not empty: current_cell ← pop boundary for all neighbor_cell of current_cell: if neighbor_c...
e2733bd552345ab3961aefd9bfd18234fa1ef823
y840512/Python-002
/week08/test2.py
389
4.15625
4
# 作业二: # 自定义一个 python 函数,实现 map() 函数的功能。 #1 def seq(x): return x * x list=(1,2,5,10) rst_list=map(seq,list) for i in rst_list: print (i) print ('#1 end','#'*20) #2 def seq(x,y): return x + y # list1=(1,2,5,10) list1=(5,) list2=(3,2,5,10,12) rst_list1=map(seq,list1,list2) for i in rst_list1: print...
346c25932947a40e20684f91bf9ab58d9105e382
rokzidarn/KerasDLTutorials
/text_processing.py
2,096
3.921875
4
# TEXT PROCESSING import numpy as np from keras.preprocessing.text import Tokenizer # text -> sequence data (words) # examples: document classification, sentiment analysis, question answering # pattern recognition applied to words, sentences and paragraphs # tokenization # text vectorizing transforms text in...
749d08a959a27a6261354cb4b9ca205ea66e4df0
RaghavJindal2000/Python
/basics/Python/PYTHON --------/function/calculator_function,py.py
709
3.953125
4
def add(x,y): sum=x+y print(a," + ",b," = ",sum) def sub(x,y): s=x-y print(a," - ",b," = ",s) def mul(x,y): m=x*y print(a," * ",b," = ",m) def div(x,y): d=x/y print(a," / ",b," = ",d) def floor_div(x,y): d=x//y print(a," // ",b," = ",d) a=int(input("Enter First Number : ")) b=int...
aa0061fc4a7949a0722621c0bfab39e584f66783
Wang-Yann/LeetCodeMe
/python/CodingInterviews_2/03_shu-zu-zhong-zhong-fu-de-shu-zi-lcof.py
1,689
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Rocky Wayne # @Created : 2020-04-22 23:13:31 # @Last Modified : 2020-04-22 23:13:31 # @Mail : lostlorder@gamil.com # @Version : alpha-1.0 # 找出数组中重复的数字。 # # # 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复...
7b9514993c36280a29c89f65b348f2616bb97a06
OrianaLombardi/Python-
/fundamentos/listas.py
1,270
4.5
4
nombres=["Juan", "Karla", "Ricardo", "Maria"] print(nombres) #Conocer el largo de la lista print(len(nombres)) #el elemento 0 print(nombres[0]) #navegacion inversa print(nombres[-1]) print(nombres[-2]) #Imprimir rango print(nombres[0:2]) #sin incluir el indice 2 #Imrpimir los elementos de inicio hasta el indici pr...
79419121d8256ec451863036e4aded831fbfdc04
19klowe0/SimpleSort
/ReverseSort.py
459
4.03125
4
# creating the file with the names in it names = list() file = open('SortMe.txt') #looping through the array of words to append for name in file: #remove whitespace name = name.strip() words = name.split() for word in words: names.append(name) file.close() #first sort the results by character...
380feb3aeecc0f0e5948daeb106899da806be199
tatyskya/Python
/hometask_5.py
3,027
3.875
4
# Task 1 Создать программно файл в текстовом формате, записать # в него построчно данные, вводимые пользователем. my_file = open('test.txt', 'w') line = input('Введите текст \n') while line: my_file.writelines(line) line = input('Введите текст \n') if not line: break my_file.close() my_f...
03e0a651f756347bb2ebe813e5b519ac9901245b
msweetland/InterviewPrep
/TADM_3/22.py
2,951
3.71875
4
from inspect import isfunction class LinkedNode(object): def __init__(self, item, next_node=None): self.item = item self.next = next_node def get_data(self): return self.item def get_next(self): return self.next def set_next(self, new_next): self.next = new_next class BinaryNode(object...
165c4bd1ded1b405853f312a4237e8f523ad4421
nkanungo/session12_epfi
/calculator/sigmoid_module.py
533
4.125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 27 16:30:27 2020 @author: Nihar Kanungo """ import math __all__ = ['sigmoid'] def sigmoid(x): ''' Calculates the Sigmoid of the given value FInd out the derivative of the Sigmoid of the given value ''' print(f'the value of sigmoid for given input ...
de6e38c0722d0804b212e37b27c86e6d68192109
daili0015/Download_Picture
/FileRobotClass.py
1,600
3.625
4
# 文件操作类 import os class FileRobot(): def __init__(self): pass #文件夹的名字不能含有的特殊符号,windows下的限定 def get_format_filename(self,input_filename): # for s in ['?', '*', '<', '>', '\★', '!', '/','!']: while s in input_filename: input_filename = input_filename.strip().replace(s, '') return input_filen...
5792deb658444689a27392d92338b04f168e5155
rahulcode22/Data-structures
/Math/Prime-Sum.py
474
3.84375
4
'''' Given an even number ( greater than 2 ), return two prime numbers whose sum will be equal to given number. ''' class Solution: def primesum(self, n): for i in xrange(2, n): if self.is_prime(i) and self.is_prime(n - i): return i, n - i def is_prime(self, n): if n...
1c2cb89251736146a4b178e9d6b27f1025181f20
kusano/codevs2
/gentable.py
2,795
3.671875
4
# coding: utf-8 # テーブルを生成 def pspin(W,H,T,S,N,P): print "const int Field<%d,%d,%d,%d,%d,%d>::pspin[4][%d] = "%(W,H+T,T,S,N,P,T*T) print "{" P = [[0]*T for t in range(T)] i = 0 for y in range(T): for x in range(T): P[y][x] = i i += 1 for r in range(4):...
b46c5623fb3c1c9d35d81cba6f67c3f4e405c10c
akhilanair14/Weather_Widget
/WeatherApp.py
4,177
3.90625
4
import tkinter as tk from tkinter import font # Font Library import requests # Library to send request to API from PIL import Image, ImageTk # Pillow libraries for Pictures import datetime # Date time Library for Sunrise and Sunset Conversion app = tk.Tk() ...
6fde0ca84dc1058efc7cc2ce29ad24b63705db88
jrmcglynn/WAR_simulation
/WAR.py
11,121
3.515625
4
from random import seed from random import shuffle from random import sample import numpy as np import pandas as pd class War(object): ''' Class built to simulate the card game War: https://en.wikipedia.org/wiki/War_(card_game) Includes settings to control the way discards are handled. Param...
6c568b74df3449df5ba6e42e462dac94694f6c84
slowrunner/Carl
/Examples/thread_exceptions/main_exception.py
2,763
3.734375
4
#!/usr/bin/env python3 # One Thread, exception in main """ If main() does not not catch exception and then wait for thread to finish with a join(), then main will exit, then thread continues on until done 22:11:30: Main : before creating thread 22:11:30: Main : before running thread 22:11:30: Thread 1: sta...
72ce9638c773c7e6b6971bc662a205f7d25a7325
nibbletobits/nibbletobits
/python/day15_csv_dictonary_use.py
2,112
4.21875
4
# ******************************************** # Program Name: Day 15, hw # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: 7 26, 2021 # Purpose: program calculates tax + total cost of menu item's # Modules used: .csv # Input Variables: (1-5) # Output: print statements for purpose. # ***************...
2e31092b271eaa95955c0c8b1f627e5ec6c594f5
traplordpanda/pythonUMBC
/python/pythonlabs/examples/collections/list_loops.py
320
4.03125
4
#!/usr/bin/env python3 numbers = [10, 20, 30, 40, 50] # Looping by element for number in numbers: print(number, end="\t") print() # Looping by index and # updating list's values at the same time for index in range(len(numbers)): numbers[index] *= 10 for number in numbers: print(number, end="\t") print()
7755647a3bff01a3d65829130a9db69c41756ff3
aaroncymor/coding-bat-python-exercises
/List-1/make_ends.py
291
4.03125
4
""" Given an array of ints, return new array length 2 containing the first and last elements from the original array. The original array will be length 1 or more. """ def make_ends(nums): new_nums = [] if nums > 1: new_nums.append(nums[0]) new_nums.append(nums[-1]) return new_nums
9f94cb8945d2b144b9c444e923db62fe7259aa94
jgschmitz/Python-Snips
/getVowels.py
235
3.96875
4
#This method gets vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) found in a string. def get_vowels(string): return [each for each in string if each in 'aeiou'] get_vowels('foobar') # ['o', 'o', 'a'] get_vowels('gym') # []
e6094c3521a70bbff1e48262002da1ec9c9e8569
vlcruvi/python-exercises
/initials_7_strings.py
278
4.03125
4
def initials(whole_name): result = "" initial = True for letter in whole_name: if initial: result += letter initial = False elif letter == " ": initial = True return print(result) initials("Vinicius Cruvinel")
8736bacba9a51c064500aaf5a32948694ef16f64
zjcalo/repository
/paned windows.py
588
3.6875
4
from tkinter import * from tkinter import ttk root = Tk() root.title('Paned Menu') root.geometry("400x400") # Panels panel_1 = PanedWindow(bd=4, relief="raised", bg="red") panel_1.pack(fill=BOTH, expand=1) left_label = Label(panel_1, text="Left Panel") panel_1.add(left_label) # Create a second panel panel_2 ...
ce7ccf14229e3b626b90f73bb1de5c510d2eeac7
edwintcloud/algorithmPractice
/LeetCode/Google/Top Ten/3 - K Empty Slots/solution.py
2,261
3.640625
4
def k_empty_slots(flowers, k): '''@param flowers: list of positions for each day the flowers will bloom @param k: integer representing the required distance between two bloomed flowers in which no flowers have bloomed @return: day satisfying k''' #...
3fd90b68177a73693487e68b2ff8d1db8fa9c871
Peritract/text_adventure
/text_adventure/tools/output_functions.py
471
3.8125
4
"""Functions that deal with displaying information on the console.""" import os import sys from time import sleep def display(message, delay=0.05): """Displays text as though it was being written.""" for char in message + "\n": sys.stdout.write(char) sys.stdout.flush() sleep(delay) ...
ed07ace8d8b0b763d01bc7b1fa8cb520ce00882d
krothleder/shopping_list.py
/conditionals.py
309
3.828125
4
# my_name = "Timea" # pair_name = "Marla" # if my_name > pair_name: # print "my name is greater!" # elif pair_name > my_name: # print "their name is greater!" # else: # print "our names are equal" date = 21 if date >= 15: print "We're halfway there!" if date <= 14: print "The month is still young."
22342ad3050791903079ca3bc74a0af9387d0925
pi7807pa/super-funicular
/test.py
145
3.640625
4
def input(): a=raw_input("enter a") b=raw_input("enter b") return a, b def area(): int a,int b = input(); print(a, b) c=a*b;
c43896293aa6adf4ce774bc96e1f209b98972e3d
ZazAndres/Ejercicios_Taller_Lab24
/punto5.py
574
3.921875
4
from typing import Sized cond="si" def frecuencia(numero,digito): cantidad=0 while numero !=0: ultDigito=numero%10 if ultDigito==digito: cantidad+=1 numero=numero//10 return cantidad while cond=="si": num=int(input("ingrese un numero: ")) un_digito...
328442a52454712f117fb2038ec86001266d3eb3
eytanohana/Machine-Learning-Implementations
/app/ml_pages/k_means.py
2,983
4.0625
4
import numpy as np import streamlit as st from skimage import io from PIL import Image from .src.kmeans import kmeans, display_image def run(): st.markdown(''' # K-Means K-Means is an algorithm for grouping similar data into K predefined groups. In this app we'll use K-Means to compress an image using...
fe521db176675e8b2771d738ac1ce55adcd47aa2
EraSilv/day2
/dzz/dz9.py
922
3.921875
4
fruits1 = { 'apple', 'cherry', 'banana', 'lemon', 'watermelon', 'coconut', 'salt' } fruits2 = { 'melon', 'potato', 'tomato', 'banana', 'carrot', 'lemon' } print(fruits1.intersection(fruits2)) #--------------------------------------------------------------------------------- fruits1 = { 'apple', 'cherry', 'banana', 'l...
d471926913c0a9574d2fad457421e68160fbe016
mikebestoso/portfolio
/Alien Invasion/alien/bullet.py
6,270
4.25
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): """A class to manage bullets fired from the ship""" def __init__(self, ai_game): """Create a bullet object at the ships current location""" super().__init__() self.screen = ai_game.screen self.settings = ai_game.settings self.color = se...
ccf80d4a90fc7f9b7e78ddf5165a203b1c7c21fc
heeewo/Algorithm
/search/Sequential_search/Sequentual_serach_python.py
286
3.828125
4
def SequentialSearch(nlist, item): pos = 0 found = False while pos < len(nlist) and not found: if nlist[pos] == item: found = True else: pos = pos + 1 return found nlist = [4, 2, 9, 7, 1, 3] print(SequentialSearch(nlist, 3))
67b9d28a296cc5bd34af2dcb72208d0cdd9c6bb1
ArmandoRuiz2019/Python
/Selectivos/Selectivos03.py
402
3.625
4
nom="" sue=0 bon=0 nom=input("Ingrese su nombre:") sue=int(input("Ingrese su sueldo:")) tser=int(input("Tiempo de Servicio:")) if tser>=1 and tser<=3: bon=sue*0.02 #print("La Bonificacion de:"+ nom + "es:"+str(bon)) elif tser>=4 and tser<=5: bon=sue*0.03 #print("La Bonificacion de:"+ nom + "es:"+st...
3f5067553c1a79cad752de92a44e754cd766c70b
jubbynox/redcaza
/RedCaza/src/mediasearch/jsonpickle/pickler.py
4,017
3.53125
4
# -*- coding: utf-8 -*- # # Copyright (C) 2008 John Paulett (john -at- 7oars.com) # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. import util class Pickler(object): """Converts a Python object to a JSON represent...
7c033e6ea087f5ce359b4191ed726cd49b7ac9b0
mehtank/dinoparmfish
/players/randomPlayer/player.py
2,050
3.53125
4
import random from ..engine import card class Player: def output(self, s): if not self.debug: return print "Player " + repr(self.index) + ": ", print s def __init__(self, debug=False): self.debug = debug def setup(self, index, handSizes, hand): self.index = index self.numPlayers =...
3730a2944636ab364765a6db5206cd8b47143a63
aakritisingh/Algorithm-Toolbox
/week 3/covering_segments.py
928
3.953125
4
# Uses python3 import sys from collections import namedtuple Segment = namedtuple('Segment', 'start end') def getEnd(segment): return segment[1] def inSegment(point,segment): if point <= segment[1] and point >= segment[0]: return True return False def optimal_points(segments): points = [] ...
cbb1958de3e9834d07c2c0842b224b42736d413d
dunossauro/GECA
/ROT13/rot13.py
275
3.953125
4
#!/usr/bin/python 3 import string def cripto(frase): alfabeto = string.ascii_uppercase saida = "" for letra in frase: busca = alfabeto.find(letra)+13 modulo = busca % 26 saida += str(alfabeto[modulo]) print(saida) input("\n\nPressione Enter para continuar")
fb2815234532e1aa7407254068bc5de00ac9b677
PyLamGR/PyLam-Edu
/Workshops/11.03.2018 - Python. The Basics - Volume 2 -/Python Codes/3. Επαναληψη - Δομή Επιλογής-Επανάληψης, Λίστες/10_nested_loops2.py
212
3.578125
4
counter = 0 for i in range(10): for j in range(10): if i > j: counter +=1 print(counter) # Τι τιμή πιστεύετε θα έχει ο counter οταν τελειώσει το πρόγραμμα;
f86682c3b0f4b858e0f9a7365eb68c1ca18934e6
thenerdpoint60/PythonCodes
/palindrome.py
241
3.921875
4
def isPalindrome(a): i=0 j=len(a)-1 while(i<j and a[i]==a[j]): i+=1 j-=1 if(i<j): print("Not a palindrome") return 0 else: print("palindrome") return 1
baa6008cf762a91b866753c7b66ba5a622dadd7d
Lamia7/MacGyver_game
/item.py
1,071
3.796875
4
#! /usr/bin/env python3 # coding: utf-8 """ Item module that contains the Item class """ import random from config import SPRITE_SIZE import pygame class Item: def __init__(self, my_map, img): """Constructor that initializes the items""" self.img = pygame.image.load(img).convert() ...
51a8f51fc63b1162cd09febf78f9c922eceba62b
yyyuaaaan/pythonfirst
/crk/1.6.py
704
3.53125
4
""" __author__ = 'anyu' Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place? 0(N2) """ def matrixro(ma): N= len(ma) ma = zip(*ma) # transpose matrix, very interesting, aij = aji, #ther ways to...
92c0602e6efa75b3eb1371e668fb3c5fa9128b70
HuangYukun/columbia_cs_deep_learning_1
/ecbm4040/features/pca.py
1,955
3.53125
4
import time import numpy as np from numpy.linalg import eigh def pca_naive(X, K): """ PCA -- naive version Inputs: - X: (float) A numpy array of shape (N, D) where N is the number of samples, D is the number of features - K: (int) indicates the number of features you are going to keep aft...