blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e1baea651392b13d38563bcf70f1dab2ae704ecd
shaabyn/Exo-TSRS13
/Ex01.py
593
3.875
4
#!/usr/bin/python3 ''' #text = "Je dois faire des sauvegardes régulières de mes fichiers." #print (text*500) ''' ''' pair =[] for a in range (0,1000, 2): pair.append(a) print(pair) impair = [n + 1 for n in pair ] print (impair) ''' ''' def table(nb, max=10): 1 * nb i = 0 ...
7ff700de633d9055af3a40306caa759c7527dd82
unimauro/Curso-PostGrado-Mecatronica-2021
/Clases/Clase_05/sqlite-con-prueba.py
590
3.65625
4
import sqlite3 from sqlite3 import Error def sql_connection(): try: con = sqlite3.connect ('Empresa.db') return con except Error: print(Error) def sql_tabla(con): cursorObj = con.cursor() ## id integer ## nombre text ...
b092eaccad30e3c308c17659a08194c6e9762e4e
shubhamshekhar/SpotPainting
/SpotPainting.py
2,011
3.53125
4
import colorgram from turtle import Turtle, Screen import random class SpotPainting: def __init__(self): self.turtle = Turtle() self.turtle.hideturtle() self.colors = [] self.number_of_colors_to_extract = 20 self.screen_width = 640 self.screen_height = 640 s...
77007fc8400c3ffe879eddcdb0b157e2e543c8e0
Jlo93/twoSum_Looping_Solution_Python
/Leetcode_twoSum.py
3,490
3.546875
4
import numpy as np import time import pyttsx3 from random import randint from random import seed arr1 = [] #initialise an empty array arr2 = [] #initialise an empty array engine = pyttsx3.init() #initialise the pyttsx3 functions gameState = 1 #initialises the loop in code on 1st build #function to create random arr...
5b16acb4182108ae7ffbe549c938c5eba1a72df4
afmejia/Python-for-Everybody
/Course1/assignment3_2.py
287
3.921875
4
# Get data try: hrs = raw_input("Enter Hours: ") h = float(hrs) rate = float(raw_input("Enter rate: ")) except: print 'Error, please enter numeric input' quit() print rate, h if h <= 40: pay = h * rate else: pay = 40 * rate + (h - 40) * 1.5 * rate print pay
dcc3f07460caf6a8eabed4a680b21af300e3758f
FerFabbiano/Algoritmos-I
/functions_test.py
953
3.8125
4
import unittest from functions import mayusculas from functions import minusculas from functions import sumar class TestMayusculasMinusculas(unittest.TestCase): def setUp(self): self.texto = "Hola Mundo!" def tearDown(self): self.texto = "" def test_pasar_a_mayusculas(self): en_...
9bde6408857f734e10c29402708126320c5aad0d
joneygupta/DS-Preparation
/DS-Graphs/pathwith_morethan_K_length.py
2,730
3.75
4
def morethank_K(graph, u,k,key): print (key) if k<=0: return True for v in graph[u]: if key[v] == True: continue if graph[u][v] >= k: return True key[v] = True if (morethank_K(graph,v,k-graph[u][v],key)): return True ...
819b2e698fc3e4015d9bae8b2c56f756a668e71d
JimmyKent/PythonLearning
/com/jimmy/demo/test.py
1,871
3.65625
4
import numpy as np import random import matplotlib.pyplot as plt def gradientDescent(x, y, alpha, numIterations): """ 这部分要结合公式看 :param x: :param y: :param alpha: 步长 :param numIterations: :return: """ xTrans = x.transpose() # transpose 转置 相当于x.T m, n = np.shape(x) # shape 返回x...
0bbbc2212ed072f4178dd18495a6765a297e9601
agrawalshivam66/python
/lab2/q9.py
279
3.875
4
a,b,c=eval(input("Enter the numbers ")) if a==(b+c)/2 : print(a," is the mean of ",b," and ",c) elif b==(a+c)/2: print(b," is the mean of ",a," and ",c) elif c==(a+b)/2: print(c," is the mean of ",a," and ",b) else: print("No number is mean of the other two")
1ee60bbe003c585cbfa57a235c4341980ed83e36
UtkarshTiwariDevs/Number-Guessing-Game-Python
/NumberGuessingGame.py
416
3.984375
4
import random n = random.randint(0, 100) # print(n) while(True): num=int(input("Enter a number between 0 to 100")) if num==n: print("Hurray! You got it right") break elif num>n: print("You entered a greater number") continue elif num<n: print("You entered a small...
0e84ffae4bfda35ffa56cbb0e05ecd89120e02e4
xzguy/LeetCode
/Problem 101 - 200/P179.py
1,134
4.0625
4
from functools import cmp_to_key class LargerNumKey(str): # default less than function for sort (reverse order) def __lt__(x, y): return x+y > y+x class Solution: ''' The key point in this problem is to compare a string A with string B, which number is bigger:A+B or B+A? We can sort th...
681097c8b31ca9397d938f77205e8b298ba1a781
mabrasoto/imageShape
/imageShape_class.py
9,648
3.703125
4
# Taller 2 # Procesamiento de imagenes y visión # Manuela Bravo Soto # IMPORTACIONES import numpy as np # Del módulo numpy import cv2 # Del módulo opencv-python import math # Del módulo math #CLASE imageShape class imageShape: # CONSTRUCTOR # Recibe como parámetros el ancho y el alto de la image...
5eb7701c809069dd66f88e345e185bcfa121075f
AlessandroFMello/EstruturaDeRepeticao
/Exercício006.py
152
3.828125
4
numero = 20 contador = 0 arr = [] while contador < numero: contador += 1 print(contador) arr.append(contador) print(arr) input()
4fb3348d36ae2ec5c3279c705b0c49136244dd89
yasanmaduranga/Pythonlearning
/project_1.py
713
4.25
4
price_product_1 = input("what is the price of product 1? ") quantity_product_1 = input("what will be the quantity of the product 1? ") price_product_2 = input("what is the price of product 2? ") quantity_product_2 = input("what will be the quantity of the product 2? ") price_product_3 = input("what is the price of prod...
197c4818a242195b08acc6d1b6259723fc5184be
mayankvanani/Python_Tutorials
/fibo.py
462
4.0625
4
## fibonacci numbers module def fib(n): ## write fibonacci series upto n a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() def fib2(n): ## reutns fibonacci series upto n result = [] a, b = 0, 1 while a < n: result.append(a) a, b = b, a+b return result if __name__ == "__main__": ...
32ce287af6d3dbc948dab6ffed79538445e98205
ursulenkoirina/courses
/class5/class_5.py
783
4.03125
4
# class Person: # def printer_self(self): # print(self) # if __name__ =="__main__": # p1 = Person() # print('p1: ', p1) # p1.printer_self() # print('\n') # p2 = Person() # print('p2: ',p2) # p2.printer_self() class Person: title = 'All people' def printer_self(self): ...
e64b3d53b52c9c23b9c80a035d1c03c243ac7b30
roccia/leet_code_python
/majority_element.py
525
3.90625
4
# Given an array of size n, find the majority element. # The majority element is the element that appears more than ⌊ n/2 ⌋ times. # # You may assume that the array is non-empty and the majority element # always exist in the array. def majority_element(nums): h = {} for n in nums: if not n in h: ...
03a15f8c2f4d688a1f91fcf02453968d89df0591
wandersonDeve/Curso-em-Video
/Aula 13 - For/ex056 – Analisador completo.py
618
3.84375
4
print('==== ANALISADOR COMPLETO ====') saldo = 0 idade = 0 nome = ('') qtn = 0 for dados in range(1,5): name = str(input('Qual o seu nome: ')).strip() age = int(input('Qual a sua idade: ')) sexo = int(input('''' Qual o seu sexo: [ 1 ] - masculino [ 2 ] - feminino digite: ''')) saldo = saldo ...
24cf765bc3fae418bc8ff3a3a262eda0d4d88cbc
TildenKatz/Tomb-Gordon
/tomb_gordon.py
14,903
3.96875
4
#JB #01/13/19 #Tomb of Gordon the Wise import random import time name = input ("Halt! Only a fool would approach an orc encampment alone. By what name do you call yourself?") print ("Ah. Well, " + name +", your reputation precedes you. For too long have you roamed these hills unchecked. For too long have your kind e...
bb95d68c15a15eaf7c50369983662004f59c70f8
FreshWaterLee/personal_Study
/alogorithm/bubble.py
287
3.96875
4
def bubble(my_list): for st_idx in range(len(my_list)-1): for j in range(1, len(my_list)-st_idx): if(my_list[j]<my_list[j-1]): temp = my_list[j-1] my_list[j-1] = my_list[j] my_list[j] = temp if __name__ == '__main__': list1 = [5,3,1,2,4] bubble(list1) print(list1)
4b65b937552528fcfa579950b6a2fd63985bfca9
macroscopicentric/practice
/algorithms/monkeys.py
1,304
3.515625
4
import string import random import time character_pool = string.lowercase + ' ' iteration = 1 goal_string = 'methinks it is like a weasel' def generate_string(): random_string = ''.join(random.choice(character_pool) for i in range(28)) return random_string def score_string(current_string): score = 0 ...
d930156f419a0e71f7e99c38ba9c3b9ac6eff22d
AceArash/ZTM-Complete-Machine-Learning-and-Data-Science-Zero-to-Mastery
/python/first program/Variables/300_b_f.py
290
3.890625
4
#Built-in Functions + Methods print(len('hello world')) greet = "hellooooo" print(greet[0:len(greet)]) # Methods have . in front of it like .format() automatic tools that can be used by quote = 'to be or not to be' print(quote.capitalize() ) #practice with more methods and function
285346ff87463b46c1494e684da1ecec26b6e5ec
amrgomez/HW1
/SI364W18_HW1.py
5,414
3.671875
4
## HW 1 ## SI 364 W18 ## 1000 points ################################# ## List below here, in a comment/comments, the people you worked with on this assignment AND any resources you used to find code (50 point deduction for not doing so). If none, write "None". #I worked with Kayla Williams ## [PROBLEM 1] - 150 poin...
d1cd23003890fd7ae8c14838d3b1ea239a16310c
tsunami1709/nguyenquyetthang-fundamental-c4e35
/Session5/homework5/Turtle_6.py
452
3.953125
4
from turtle import * def draw_star(x,y,length): penup() setpos(x,y) pendown() left(72) for i in range(5): forward(length) right(144) speed(0) ls = ['blue','red','yellow','orange', 'green','grey'] # color('blue') for i in range(100): import random color(random.choice(ls)) x =...
abaa70fc357fdf0cf38f17385c06e192687e4154
Maryam-Hashemii/html_exercise
/testday01.py
158
3.734375
4
number1 = input ("enter number one!") number2 = input("enter second number") print (type(number1)) print (int(number1)) + (int(number2)) print (type(number2))
acd1a798c7975b017f4b410eda182627e8cb198a
BingLau7/alg
/python-alg/leetcode/array/sort-colors.py
656
3.9375
4
from typing import List class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ i = j = 0 for k in range(len(nums)): v = nums[k] nums[k] = 2 if v < 2: nu...
bebcd02f0a2aa200c23042189501e95f49a2e014
SergioKronemberg/CursoBlueMod1
/aula8/ex5.py
260
3.90625
4
n = int(input("digite um num int: ")) contador = 0 # divisores=[] for i in range(n, 0, -1): if(n % i == 0): # divisores.append(i) print(i) contador += 1 if contador == 2: # if len(divisores)==2 print(n, "é um num primo!")
c50715fa14e66850c9a450d065616085cf3e2f4d
HarshRangwala/Python
/python practice programs/GITpractice10.py
628
3.8125
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 9 15:42:55 2018 @author: Harsh """ ''' Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically. Suppose the following input is supplied to the program: hell...
786c35de8b82f39d4182a263fc0976ad5e03dee8
Qiao-Liang/LeetCode
/LC190.py
534
3.828125
4
class Solution: # @param n, an integer # @return an integer def reverseBits(self, n): temp = 1 bit = 0 res = 0 while temp <= n: temp <<= 1 bit += 1 temp >>= 1 bit -= 1 base = 1 << (31 - bit) while bit >= 0: ...
2123fa364c855a8c00a8f0287c15485e8c58ce9c
simozhou/homework_2
/strings/camel_counter.py
157
3.640625
4
import sys s = input().strip() def camelCounter(s): c = 1 for i in s: if i.isupper(): c+=1 return c print(camelCounter(s))
f13b77644269efb98edfdf6d33d2c6659d6d4de3
mellesies/thomas-core
/thomas/core/models/bn/node.py
4,153
3.78125
4
"""Node.""" from typing import List import sys class Node(object): """Base class for discrete and continuous nodes in a Bayesian Network. In Hugin, discrete nodes can only have other discrete nodes as parents. Continous nodes can have either continuous or discrete nodes as parents. BayesiaLab does a...
64259d8b6822f3d522ca61f8a4e187f022a7813e
AlirezaMojtabavi/Python_Practice
/Advanced/2- object oriented programming/1- Health_plan.py
1,889
3.75
4
from statistics import mean class School : def __init__(self,name): self.name = name age = list() height = list() weight = list() def MeanOfAge(self ,age) : return (float(mean(age))) def MeanOfHeight(self ,height) : return (float(mean(height))) def MeanOfWeig...
12fe25b9756a7bd50272a6ba4381d2123789e11e
Johnny1725/Johnathon
/CSC 131 Program 1 How many zeros.py
1,082
4.40625
4
##Johnathon Terry ##12/10/2019 ##Program 1 How Many Zeros ##Python 2.7 ########################################## from time import time ##this finds the number you want to count to n = input("What is the number do you want to count zeros to?") ##starts timer start = time() ##function that is called upon to ...
caf7f83b8caecdcd2465a0b6b026f708bd224fd1
IanPaulDaniels/Python_CrashCourseBook
/c06 - Dictionaries/aliens.py
507
3.953125
4
# Make empty list aliens = [] # Make 30 aliens for alien_number in range(30): new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'} aliens.append(new_alien) for alien in aliens[0:3]: if alien['color'] == 'green': alien['color'] = 'yelow' alien['speed'] = 'medium' alien['poin...
7fd8829364acec76aa395b6547e0160511d56a53
romulovitor/w3schools-Pandas
/basico/06_Visualizando_Dados.py
437
4.125
4
import pandas as pd df = pd.read_csv('data.csv') # se o número de linhas não for especificado, o head()método retornará as 5 primeiras linhas. print(df.head(5), '\n') # O tail()método retorna os cabeçalhos e um número especificado de linhas, começando da parte inferior. print(df.tail(), '\n') # O objeto DataFrames ...
71c8ac0df66806e8ebaf46f2b38240ad55f783a6
DidiMilikina/DataCamp
/Machine Learning Scientist with Python/16. Introduction to Deep Learning with Keras/03. Improving Your Model Performance/03. Do we need more data?.py
1,878
3.59375
4
''' Do we need more data? It's time to check whether the digits dataset model you built benefits from more training examples! In order to keep code to a minimum, various things are already initialized and ready to use: The model you just built. X_train,y_train,X_test, and y_test. The initial_weights of your model, sa...
5eaefdcc505a549bea14d9821407829889c8088a
Panthck15/learning-python-repo1
/numpy7.py
259
3.5625
4
import numpy as np def one_dim_rand_arr(num_arr,num_ch): sel_lst=[] for i in range(num_ch): sel_ch=np.random.choice(num_arr) sel_lst.append(sel_ch) return sel_lst arr1=np.array([1,2,3,4,5,6,7,8]) print(one_dim_rand_arr(arr1,3))
4c359d89daa0b97a4763fea283738875b038304f
parkjaehyeun/practice-for-coding-test
/Kakao2020-winter-internship/1.py
855
3.875
4
def move_item(board, move): for i in range(len(board)): if board[i][move] != 0: item = board[i][move] board[i][move] = 0 return item return None def remove_sequence_items(moved_list): for i in range(1, len(moved_list)): if moved_list[i - 1] == moved_list...
43a9108cc0f95354361bcbeaff52936953f300fe
shantaladajian/HomeWork1
/Classrooms2.py
1,921
3.796875
4
class Classroom: def __init__(self): self.schedule = [] def isFree(self, start, end, roomID): is_free = True for slot in self.schedule: if end < slot[roomID]["start"] or start > slot[roomID]["end"]: pass else: is_free = False ...
f3127ef40beab8a8076bb5768f1a23200e014d49
s-christian/Schoolwork
/Data Structure and Algorithm Analysis/Programming Assessments/Assessment 2/insertion_sort.py
819
4.1875
4
# Programming Assessment 2 - Problem A1/A2 # # I forget whether this is Insertion or Selection Sort, so I ask # the user for the n'th smallest element regardless def insertion_sort(a): for i in range(0, len(a) - 1): min = a[i] minIndex = i for j in range(i + 1, len(a)): if a[j] <...
17102c9bb9e16398d218c1c8e6358cd77d5247cb
jlavileze/Project-Euler
/042. Coded triangle numbers/42. Coded triangle numbers.py
1,044
3.65625
4
from math import sqrt import re import string #generate a key to map the letters in our strings to letters = string.ascii_uppercase letters_map = {letter: idx for idx, letter in enumerate(string.ascii_uppercase, start=1)} #open the file and parse on quoted values with open('p042_words.txt') as f: words = sorted...
4a675fe20c6a3096c485d6bd9bd4fdeff4cab583
athletejuan/TIL
/Algorithm/BOJ/14_sorting/10814.py
325
3.65625
4
N = int(input()) users = [] ages = [] for _ in range(N): users.append(input().split()) for user in users: if not ages or int(user[0]) not in ages: ages.append(int(user[0])) ages = sorted(ages) for age in ages: for user in users: if age == int(user[0]): print(str(age) + ' ' + use...
69e3f128e7fb09e8ed955406b57f35ba2f2d60dc
RhysMurage/alx-higher_level_programming
/0x03-python-data_structures/5-no_c.py
281
3.671875
4
#!/usr/bin/python3 def no_c(my_string): str_list = list(my_string) length = len(str_list) for i in range(0, length): if str_list[i] == 'c' or str_list[i] == 'C': str_list[i] = '' new_str = ''.join([char for char in str_list]) return new_str
40edf727da5568e8947c4821d706e77442acf242
gonzalob24/Learning_Central
/Python_Programming/LinkedLists/main_list.py
3,303
3.625
4
from node import Node from SingleLinkedList import SingleLinkedList def insert_at_head(lst, value): temp_node = Node(value) if lst.head_node is None: lst.head_node = temp_node return temp_node.next_element = lst.head_node lst.head_node = temp_node def insert_at_tail(lst, value): ...
11c5d369b3b3afe439973231f5b57367dc61010a
408824338/work
/python/source/decorate/b.py
552
3.75
4
''' 12-8 装饰器 特性 注解 #对修改是封闭的,对扩展是开放的 ## 如果有100个函数,都要输出时间那怎样处理呢? 方案B 对功能封装,调用输出 ''' import time def f1(): print('this is a function') def f2(): print('this is a function') def decorator(func): def wrapper(): print(time.time()) func() return wrapper f = ...
f332f815f99c412659fb5c2ea55dc55317f3b3ff
mtShaikh/leetcode
/hackerrank/interviewsprepkit/anagram.py
471
3.578125
4
def ana(s): dict = {} count = 0 for i in range(len(s)): for j in range(i + 1, len(s) + 1): list1 = list(s[i:j].strip()) print(list1, dict, count) list1.sort() transf = ''.join(list1) if transf in dict: count += dict[tra...
0c8c6095ae7d9cfe12409304652b1383e108ad98
imsanjoykb/Python-Programming-Problem-Solving
/Exercise-14-List-Remove-Duplicates.py
1,146
4.1875
4
''' Exercise 14: List Remove Duplicates Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates values. Extras:: Write two different functions to do this - one using a loop and constructing a list, and another using sets. Go back a...
b82d49a8bc1e19fb5c571179ae432a140e394773
skuehn1988/TextMining
/Scripts/UniversalScript.py
1,705
3.59375
4
# -*- coding: utf-8 -*- import csv import sys try: input_file = sys.argv[1] output_file = sys.argv[2] except: print("for bash: python UniversalScript.py /Users/username/Desktop/Textming/input.csv /Users/username/Desktop/Textming/ouput.csv ") print("No input_file and output_file provided.") pri...
7a5cf509d506e479db4a0ba53c79ff7201272450
JaberKhanjk/LeetCode
/BinaryTree/Minimum Absolute Difference in BST.py
824
3.78125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def inorder(self,node,arr): if node == None: return se...
bdcf0437d02c826aac13baa92fcfff3453916ac3
Lecoinberber/Python-BCIT-COMP1510
/Labs/Lab10/question1.py
785
3.65625
4
import doctest def eratosthenes(upperbound): """ Returns a list of primes between 0 and the upperbound. :param upperbound: a list :precondition: upperbound must be a list. :postcondition: calculates the primes betwen 0 and the upperbound. :return: a list of desired primes >>> eratosthenes...
e735ae03efd73bf683fc860b371b9bc5a4a79832
sessionsdev/PythonFundamentals
/03_more_datatypes/1_strings/04_04_most_characters.py
579
4.625
5
''' Write a script that takes three strings from the user and prints the one with the most characters. ''' string_1 = input("Enter first string: ") string_2 = input("Enter second string: ") string_3 = input("Enter third string: ") longest = "" if (len(string_1) > len(string_2)) and (len(string_1) > len(string_3)): ...
520fbd9a2ddb4e8561ab29532329bd7bbaa04e88
VittorioYan/Leetcode-Python
/303.py
438
3.53125
4
from typing import List class NumArray: def __init__(self, nums: List[int]): self.dp = [0] for num in nums: self.dp.append(self.dp[-1] + num) def sumRange(self, i: int, j: int) -> int: return self.dp[j+1] - self.dp[i] # Your NumArray object will be instantiated and call...
a575379a87a7410e0b3b20e8a0d436c6d2d579be
wjzz/pyc
/examples/primes/primes.py
413
3.765625
4
limit = 1000000 count = 0 current = 2 while current <= limit: is_prime = 1 if current != 2 and current % 2 == 0: is_prime = 0 candidate = 3 while is_prime == 1 and candidate * candidate <= current: if current % candidate == 0: is_prime = 0 candidate += 1 if is_pri...
bfbb2ad9af484c8bb3f4e6cadf14a62463393116
Aasthaengg/IBMdataset
/Python_codes/p03474/s112922480.py
140
3.5
4
a,b=map(int,input().split()) s=input() s=s.split('-') if len(s)!=2 or len(s[0])!=a or len(s[1])!=b: print('No') exit() print('Yes')
a50ee273bdfbd67bc31727ed9fa6c598ec28ee29
florian-vuillemot/pytheas
/distances/haversine/haversine.py
975
3.9375
4
''' Haversine basic implementation. Calcul distance between 2 GPS points. ''' from math import radians, cos, sin, asin, sqrt # Radius of earth in kilometers. Use 3956 for miles EARTH_RADIUS = 6371 def haversine(lon1: float, lat1: float, lon2: float, lat2: float) -> float: """ Calculate the great circle dista...
f0379df773b5d33865c60733b766c4dd04539234
Afgletras/2020_AED
/Mini-Projeto/Listas Ordenadas/Bubble Sort.py
1,019
3.8125
4
import random import time def bubbleSort(alist): for passnum in range(len(alist)-1, 0, -1): for i in range(passnum): if alist[i] > alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp # #################################### TESTE ...
20d1bb99f42e098c97e06114e6800053d2055317
kestennoam/LeetCode
/LinkedListsBasics/createLinkedList.py
371
3.59375
4
# singly linked list class Node: def __init__(self, val=0, next=None): self.val = val self.next = next class singlyLinkedList: def __init__(self): self.head = Node() self.size = 0 class NodeDouble: def __init__(self, val=0, next=None, prev=None): self.val = val ...
b02098bad01e41c3ed4182931e536c398fe57f9c
suhamida/pythonPractice
/3.3.py
900
3.5625
4
#frequency distribution, bin mean,boundary distribution def equifreq(arr1,m): a=len(arr1) n=int(a/m) for i in range(0,m): arr=[] brr=[] for j in range(i*n,(i+1)*n): if(j>=a): break arr=arr+[arr1[j]] brr=brr+[arr1[j]] ...
c16e2f776ba27c8ecfafb8bff830e46bc8f2728e
sat5297/hacktober-coding
/Linkedlist.py
1,086
3.875
4
class Node: def __init__(self, data = None, next=None): self.data = data self.next = next class LinkedList: def __init__(self): self.head = None def insert(self, data): newNode = Node(data) if(self.head): current = self.head while(current.next): current = c...
c5da24d85dc7f6571a5a87549e3a14c8760f2e12
iversonk/pi_files
/python_practice_scripts/fileencrypt.py
1,253
3.796875
4
#!/usr/bin/python3 #fileencrypt.py import sys #imported to obtain command line arguments import encryptdecrypt as ENC #Define expected inputs ARG_INFILE=1 ARG_OUTFILE=2 ARG_KEY=3 ARG_LENGTH=4 def convertFile(infile,outfile,key): #Convert the key text to an integer try: enc_key=int(key) except Valu...
34da13268dffbf84734c0bbd12e1133976edbb30
m-luck/general_manipulators
/sub_mixer.py
2,557
3.609375
4
import pandas as pd from typing import List def oneHotifyColumns(csvpath:str, newpath:str, colNames:List): ''' Turns columns of choice into categorical binaries per category. ''' chunksize=20000 i=0 for chunk in pd.read_csv(csvpath, chunksize=chunksize): print("Chunk",i) i+=1 ...
fe94b94c128e9e9c48eb047a7bdc7fdde0dadb08
neon-coder/brain-exploder
/asker.py
389
3.9375
4
from random import choice questions = ["Why is the sky blue?: ", "Why is there a face on the moon?: ", "Where are all the dinosaurs: "] question = choice(questions) answer = input(question).strip().lower() while answer != "I don't know": answer = input("tell again?: ").strip().lower...
3fa36321b28e733a4152e8703afd8e2e647d3359
cu-swe4s-fall-2020/python-refresher-jrb07
/print_cases.py
4,851
4.21875
4
""" Uses user defined parameters to extract and return data from .csv files Parameters: file_name: string The path to the CSV file county: string The name of the county to return data for result_column(s): integer(s) or string(s) The zero-based in...
68f58604fbad47407094307a39cb447bf0227341
lonely7yk/LeetCode_py
/LeetCode1000/LeetCode1291SequentialDigits.py
1,469
4.03125
4
""" An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. Example 1: Input: low = 100, high = 300 Output: [123,234] Example 2: Input: low = 1000, high =...
6a7435ce7c921b784194732438d1281dd187a8f8
FYNCH-BIO/dpu
/experiment/template/nbstreamreader.py
997
3.515625
4
from threading import Thread from collections import deque class NonBlockingStreamReader: def __init__(self, stream): ''' stream: the stream to read from. Usually a process' stdout or stderr. ''' self._s = stream self._q = deque() def _populateQueu...
7320bed4862f050107cc83617c6c874c187031f2
1325052669/leetcode
/src/JiuZhangSuanFa/List_Array/36. Reverse Linked List II.py
1,377
3.84375
4
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next class Solution: """ @param head: ListNode head is the ...
e9453aa55ba83af50a2e4fb2363853eaa36bd3a8
lrtao2017/laonanhai
/xinxichaxun/zdcx.py
2,214
3.515625
4
#!/usr/bin/env python #coding:utf-8 "字典和列表应用" import sys contact_dic = {} #将文件生成字典 with open("zidian.txt") as f: for i in f.readlines(): line = i.strip().split() #将行转换成列表,并去掉两端的空格 contact_dic[line[0]]=line[1:] #生成字典 #print contact_dic #查找信息 XZ = 0 for i in range(6): if i == 5: prin...
6596dd260c0d9f88f1c4425695520bbf910835ee
AndrewManko/own_project
/project.py
270
3.515625
4
def simple(x): for i in range(2,x): b = True for j in range(2,i): if i % j == 0: b = False break if b: print(i) with open('input.txt') as f_in: text = int(f_in.read()) simple(text)
15db1a15de90aae40fe4278e8ec8b83ce23f64b8
rossi2018/DataCamp_Exercises
/03Functions_and_packages/exercise4.py
182
3.734375
4
#create list areas areas=[11.25,18.0,20.0,10.75,9.50] #print out the index of the element 20.0 print(areas.index(20.0)) #print out how often 9.50 appears print(areas.count(9.50))
a5a53a83a5aad5c3fa458ddb4101f2f426e2d694
cameronreese/movie-plot
/controller.py
4,788
4.09375
4
__author__ = 'MBA11' import MovieList def create_list_from_file(file) -> list: """function to open a text file and retrieve every line and turn it into an element of a list :param file: :rtype: list""" line_number = 0 new_list = [] file_data = open(file).readlines() while line_number < len...
1101213656130aafc96a890d2744d3e67533c5d2
sudarshan1998/Test_feb_19
/Q_no_12.py
479
3.71875
4
# Create a SquareGeometry class which takes in length as initialize parameter. # Make two methods getArea and getPerimeter inside this class. Which when invoked # returns area and perimeter of each square instance class SquareGeometry: def __init__(self,length): self.length=length def getArea(self): ...
039e897a63b4878d4d8e3e0222fa36e366c058f7
shelly2904/DSA-Practice
/STRINGS/reverse_string.py
509
4.03125
4
class Stack(object): def __init__(self): self.top = -1 self.arr = [] def push(self, key): self.top += 1 self.arr.append(key) def pop(self): if self.top == -1: print "Under flow" return False top_ele = self.arr[self.top] del self.arr[self.top] self.top -= 1 return top_ele def reverse(strin...
03caab6eaf58172a8d4a2230bac8b19bed46e79c
pjomara/SoftwareEngineeringIIProject
/recipe_retrieve.py
2,300
3.78125
4
#! /usr/bin/python '''Compiles recipes from ingredient and recipe databases.''' import sqlite3 def main(): recipe= input("What recipe would you like?- ") recipe_id, title, servSize= id_grabber(recipe) ingredients= get_ingredients(recipe_id) print_recipe(title, servSize, ingredients) print_nutrit...
db64ef811106857da45970820c71adecd63f6fd0
vit-shreyansh-kumar/DailyWorkAtHome
/cls.py
291
3.578125
4
import abc class abc: def my(self): return "shreyansh" @classmethod def mn(cls): return "sinha" @staticmethod def mz(): return "chotu" abc.abstractmethod() def bc(self): pass if __name__ == "__main__": print(abc.mz())
7f147a72e3d28fd0d5f471c670cb686ebbfbca8d
nagagopi19/Python_learning_curve
/GUI designing/widgets/Scale widget/Scale_2.py
613
3.75
4
"""The command parameter of the scale widget executes the given function whenever the slider is moved and passes the new slider value as argument. If the slider is moved very rapidly it will pass the value where the slider stoped.""" import tkinter as tk root = tk.Tk() root.geometry('360x360') # scale_var = tk.IntVa...
defa06219dc82f98c1ac0577025fc95cd1143a58
Hilldrupca/LeetCode
/python/Top Interview Questions - Easy/Strings/locatesubstring.py
814
3.796875
4
class Solution: def strStr(self, haystack: str, needle: str) -> int: ''' Return the index of the first occurence of needle in haystack. Python implementation of C's strstr() and Java's indexOf(). Params: haystack - String to be searched. ...
827e712e62f63635085a047c927ae6edacc20006
setr/cs429
/a2/score.py
5,030
3.828125
4
""" Assignment 2 """ import abc from collections import defaultdict import math import index def idf(term, index): """ Compute the inverse document frequency of a term according to the index. IDF(T) = log10(N / df_t), where N is the total number of documents in the index and df_t is the total number of d...
9090297782c352f5def9a71c3fdb291cafc25adc
ZF-1000/Python_Algos
/Урок 1. Практическое задание/task_5.py
3,425
3.921875
4
""" Задание 5. Пользователь вводит две буквы. Определить, на каких местах алфавита они стоят, и сколько между ними находится букв. Подсказка: Вводим маленькие латинские буквы. Обратите внимание, что ввести можно по алфавиту, например, a,z а можно наоборот - z,a В обоих случаях программа должна вывести корректный резул...
4fed8a58fe37835dde364ad730ce22eb3b836959
alexaugusto23/pyplan-core
/pyplan_core/cubepy/axis.py
5,915
3.890625
4
import numpy as np class Axis(object): """A named sequence of values. Can be used as non-indexable axis in Cube. Name is a string. Values are stored in one-dimensional numpy array. """ def __init__(self, name, values): """Initializes Axis object. :param name: str :param va...
4fc1e31df7fa0d642a3c9706f01564526348baa5
MrViniciusfb/Python-Crash-Course
/Parte 4/Exemplos/players.py
1,216
4.71875
5
#13/07/2021 #Fatiando listas #Já fora aprendido a como acessar elementos específicos e com todo de uma vez #Agora será a hora de aprender como fatiar uma lista e trabalhar com apenas um pedaço dela #Funciona parecido como a função range() #Basta dar ao python o começo e o fim na posição na lista, mas ele ...
49d7530a662ff10e0b45d839f6653318e1730728
LalityaSawant/Python-Projects
/ListMethods/app.py
452
3.96875
4
numbers = [5,6,7,2,5,7,1,3] numbers2 = numbers.copy() numbers3 = numbers numbers.append(20) print(numbers) numbers.insert(1,10) print(numbers) numbers.remove(7) print(numbers) numbers.pop() print(numbers) numbers.index(1) print(numbers) print(50 in numbers) print(numbers.count(5)) numbers.sort() print(numbers) ...
be2e87fbaf25483cca7a6b2185e99d8c527268cc
SunWeiKeS/dataScience
/Data_numpy/example/Math1_forwardLoss.py
879
3.890625
4
import numpy as np import matplotlib.pyplot as plt x_data = [1, 2, 3] y_data = [2, 4, 6] def forward(x): return x * w def loss(x, y): y_pred = forward(x) return (y_pred - y) * (y_pred - y) w_list = [] mse_list = [] for w in np.arange(0.0, 4, 0.1): print(u"w= %s" % w) l_sum...
61e4703498cd08155d427e28e5e6b21d8a0144d8
apena19/exercism
/python/difference-of-squares/difference_of_squares.py
266
4.03125
4
def square_of_sum(number): return sum(range(1, number+1)) ** 2 def sum_of_squares(number): a = 0 for x in range(1, number+1): a += x**2 return a def difference_of_squares(number): return square_of_sum(number) - sum_of_squares(number)
3635ebf5f31e984513adbf60f7726edaf3c079c6
eronning/MenuSignificance
/code/consolidate/consolidate.py
3,311
3.609375
4
import csv from datetime import datetime # author: blnguyen # description: integrates all the data so that it could be used # for machine learning, does this for regressions epoch = datetime.utcfromtimestamp(0) def unit_time_mills(dt): return (dt - epoch).total_seconds() * 1000.0 #Peaktime is a variable che...
5fb178c3cdea1bbc6999f5f4409ed5624fd9807a
escofresco/makeschool_cs_trees_sorting
/Code/sorting_iterative.py
4,622
4.25
4
#!python from collections import namedtuple def is_sorted(items): """Return a boolean indicating whether given items are in sorted order. Running time: O(n) Every item has to be compared to guaratee that it's sorted. Memory usage: Θ(1) The number of variables doesn't change with the...
fbc9974c7b2b0e4deb76ad300fee57d689f5e41d
JenilVirani/demo
/RegForm.py
1,540
3.59375
4
from flask import * app = Flask(__name__) @app.route('/') def Register1(): return render_template("Registrationform.html") @app.route('/login', methods=['POST', 'GET']) def Register(): if request.method == "POST": fname = request.form["fn"] lname = request.form["ln"] ...
ea77d13b6b2a92a3ad3bc8f250409a70afa6ae92
dizzyspell/selfcare
/v2/selfcare.py
194
3.5
4
from bot import Bot bot = Bot(raw_input("Gimme a name! : ")) bot.say("What is your name?") user = User(raw_input("You:")) bot.meet(user) while True: bot.turn() user.turn()
6b009520b932875321a59dfe80a67c8712d595d9
seansweeney/esri2open
/Install/esri2open/topojson/utils.py
577
3.5
4
def point_compare(a, b): if is_point(a) and is_point(b): return a[0] - b[0] or a[1] - b[1] #def is_point(p): # try: # float(p[0]), float(p[1]) # except (TypeError, IndexError): # return False is_point = lambda x : isinstance(x,list) and len(x)==2 class Strut(list): def __init__(self,...
615e1cc54d8e28445f89eec17ad3a7d1d4bcf202
BenDataAnalyst/Practice-Coding-Questions
/leetcode/55-Medium-Jump-Game/answer.py
1,429
3.625
4
#!/usr/bin/python3 #------------------------------------------------------------------------------ # Brute Force O(n^2) #------------------------------------------------------------------------------ class Solution(object): def canJump(self, nums): """ :type nums: List[int] :rtype: bool ...
ce28d3c6cfc6824f7d41fd219de014c4ba6875c5
hahmad4794/pythonprojects
/game.py
190
3.84375
4
# Author: Hassan Ahmad # Contact: hassanghaffar79@gmail.com # A fun little python game name= input("What is your name?") age= input("What is your age?") print("Hi," + name + "!") print("Your age is " + str(age))
c1006236573f1514cdd0fb574a49a10e7697df7d
tkj5008/Luminar_Python_Programs
/Python_Collections/tuple/demo.py
228
3.71875
4
# tupx=1,2,3,46,5,7,1,2,"hello",(1,2,3) # print(tupx) # print(type(tupx)) #immutable #keeps order #support duplicate elements #heterogeneous #nesting possible tupx=1,2,3,46,5,7,1,2,"hello",(1,2,3) for i in tupx: print(i)
f093026ab4c73ffdd457b63d2827b4fda5ed396f
TheEversBot/LearningParade
/ctof2.py
371
3.75
4
print 'Fredwaretek C to F converter 2\n' print '--------\n' inp=raw_input('Please enter a temperature in C\n') name=raw_input('Please enter your name\n') try: ftemp=float(inp) cel=(ftemp*1.8)+32 text=' degrees farenheiht. Thanks' print cel,text,name except: print 'please enter a number' print '---...
dca725cf05057bac372b22550cf614838bae61ab
mindgitrwx/pyrobot3
/general/boids.py
5,076
3.515625
4
# Boid experiments # D.S. Blank from random import random import math from time import sleep version = "0.0" class Board: def __init__(self, width, height, title = "Boids"): """ A board for boids to explore """ from tkinter import Tk, Canvas, Toplevel self.colors = ["white", "black", "red...
323dbff743015d85e673a789e0be48ed5fe2bd4e
yangbaoxi/dataProcessing
/python/字典(对象)/合并字典/update.py
409
4.0625
4
# update() 函数把字典参数 dict2 的 key/value(键/值) 对更新到字典 dict 里 # dict.update(dict2) # 参数 # dict2 -- 添加到指定字典dict里的字典。 Object = { "name": "Tom", "age": 18, "other": "其他" } Object2 = { "like": "篮球" } Object.update(Object2) print(Object) # {'name': 'Tom', 'age': 18, 'other': '其他', 'lik...
8056ee8da4e1eb4de0774fcc2facc5b57e6bd0d7
VVictorWang/AlgorithmLearn
/quick_sort.py
517
3.890625
4
def quick_sort(array): if len(array) <= 1: return array else: selected_index = (int)((len(array) - 1) / 2) selected = array[selected_index] left = [i for i in array if i <= selected] left.remove(selected) right = [i for i in array if i > selected] return q...
37c2270207c025b82d847a568630e5769f775e36
skulumani/MAE3145
/Homework/HW3/prob6.py
922
3.5625
4
"""Solve problem 6 """ import numpy as np from astro import constants mu = constants.earth.mu alt = 120 a = constants.earth.radius + alt vc = np.sqrt(mu / a) vesc = np.sqrt(2) * vc print("Circular velocity at {} km : {} km/sec".format(a, vc)) print("Escape velocity at {} km : {} km/sec".format(a, vesc)) print("Delt...
a5e7b0053e7d16e3ca63ada27f0b277db4d86392
smw11/CS112-Spring2012
/hw06/prissybot.py
3,256
4.59375
5
#!/usr/bin/env python #User inputs name to which prissybot refers to the user as their entered name print "Enter your name: " name=raw_input() print "Prissybot: Hello there, "+name+"." #Colon is added so user's name appears before he/she types name2=name+": " #Here the user can enter anything, preferably a greeting,...
eacc7fc171a7d4e6dd963857c80a91a661a969c2
EmmetRice/Machine_Learning_Quant_Repository
/DownloadDatafile/src/DownloadURL.py
1,470
4.3125
4
def downloadURL (filepath, URL): # download URL and store to Local path as a general binary file # python library urllib is used # def downloadURL (filepath, URL): '''Function to download URL''' from urllib import request #or import urllib.request import urllib.error #https://docs.pyt...
6fe25c427179667df3d2d10519852c85184ddd47
Yanl05/LeetCode
/thirty-six.py
796
3.609375
4
class Solution: def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ raw = [{}, {}, {}, {}, {}, {}, {}, {}, {}] col = [{}, {}, {}, {}, {}, {}, {}, {}, {}] cell = [{}, {}, {}, {}, {}, {}, {}, {}, {}] for i in range(9): ...
304a7fe0f1e759e01410d5f2d082b6fc975d52cd
carolynfischer/various_python_scripts
/is_lucky.py
695
4.25
4
""" Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half. Given a ticket number n, determine if it's lucky or not. Example For n = 1230, the output should be isLucky(n) = true; For n = 23901...