blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
51ea37ffbec00f82af62ecc929f17b7e86c4c504
teohkenxin/BasicSort
/BasicSort.py
1,779
4.375
4
def selection_sort(array): for border in range(0, len(array)): min = border for pointer in range(border+1, len(array)): if array[pointer] < array[min]: min = pointer array[min],array[border] = array[border],array[min] return array def bubble_sort(array): ...
66110c655443f265965a3caa2ab4972d676f08df
RAmruthaVignesh/PythonHacks
/DataStructures/linkedlist.py
4,771
4.1875
4
class node(object): data = None ptr = None class LL(object): head = None def __init__(self): pass def insert(self , position,value): # Insertion when the linked list is empty if self.head == None: mynode = node() mynode.data = value ...
e1d9b202869dfbbd3432409c48fc5d1430df7bec
NoraBkh/foodvisor
/Assignment1/database.py
5,164
3.640625
4
#!usr/bin/python # -*- coding: utf-8 -*- from collections import defaultdict class UniqueDict(dict): ''' a dictionary stucture with specificities: -> node is added ones -> structure: (id_node, (id_parent, list_values)) - id_node: represents node i...
8e9e182882e176ddd32d6f41675978157ae035d0
SymmetricChaos/ClassicCrypto
/NGrams/NGramInformation.py
749
3.703125
4
# http://norvig.com/mayzner.html # Uses Google data ngrams1 = open('1grams.csv', 'r') ngrams2 = open('2grams.csv', 'r') ngrams3 = open('3grams.csv', 'r') ngrams4 = open('4grams.csv', 'r') ngrams5 = open('5grams.csv', 'r') ngrams6 = open('6grams.csv', 'r') ngrams7 = open('7grams.csv', 'r') ngrams8 = open('8grams.csv', '...
62210340aa0f84ea29bbe57f01db3cd5e668775b
kasunramkr/Eduraka
/matplot/matplot.py
320
3.75
4
import matplotlib.pylab as plt x = [1, 3, 6, 9] y1 = [i * 3 for i in x] y2 = [i ** 2 for i in x] plt.plot(x, y1, label="Plot 1") plt.plot(x, y2, label="Plot 2") plt.legend() plt.grid() plt.xlim(1, 9) plt.ylim(1, 81) plt.xlabel("X - Axis") plt.ylabel("Y - Axis") plt.title("My Graph") plt.savefig("plot.png") plt.show()
16b78efc1a0e12dd32642ea4bf60075bc36e7a45
luhpazos/Exercicios-Python
/Pacote download/Desafios/38.Comparando Numeros.py
418
3.953125
4
print('\033[32m=-' * 10) print('COMPARANDO NÚMEROS') print('\033[32m=-\033[m' * 10) n = int(input('''Escolha dois números inteiros para avaliar. Primeiro número:''')) m = int(input('Segundo número:')) if n > m: print('O primeiro valor foi o maior número digitado!') elif m > n: print('O segundo valor foi o maior...
e10eab3b30ff2cb19bcdb3ed67fbfa9e0cab1730
BR49/Optimizing-Route-Navigation-in-London
/visualizations.py
30,466
4.59375
5
"""CSC111 Final Project, DataClasses This python module contains several methods for visualizing the different routes plots with the help of folium library. The list of possible visualizations are: - Plot multiple paths between the start and end junctions ( visualize_multiple_path() ) - Plot a path with certain numb...
19dea2cf58c7759caf4ff5eb2b2c48b961f11898
anilmukkoti/N-Grams
/p1.py
3,672
3.671875
4
import sys import os from collections import OrderedDict import collections #function to genrate 3,5,7 grams respectively from a given file def generator(threeg,fiveg,seveng,filename): sevg = {} for line in open(filename): line = line.rstrip() parts = line.split() le= len(parts) #total numbers in the text file...
6539a31944533ec5f38a454b4b6b52d6956e689f
9838dev/coding
/stack/longest_valid_parenthesis.py
395
3.828125
4
# longest valid parenthesis def longest_valid(s): st=[-1] res=0 for i in range(len(s)): if s[i] == '(': st.append(i) else: if len(st)>0: st.pop() if len(st)>0: res = max(res,i-st[-1]) else: st.ap...
0a251292ae4ac80a6fce824f5a35c1d23319ac75
archerw105/machine-learning
/perceptron.py
1,769
3.65625
4
import numpy as np class Perceptron: def __init__(self, input_num): """ Parameters ---------- input_num: number of input variables for 1-layer neural network Notes ----- 0-th index reserved for bias value """ self.weights = np.zeros(input_nu...
202643e91e884002eeaea357154484831c7c6d0b
eroicaleo/LearningPython
/interview/leet/240_Search_a_2D_Matrix_II.py
3,019
3.578125
4
#!/usr/bin/env python class Solution: def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ self.count = 0 if len(matrix) > 0 and len(matrix[0]) > 0: return self.search2DArray(matrix, target, ...
f3fbb0f8f59c70cf648f688c45addc4447b3a477
nguyenhai31096/nguyentronghai-fundamentals-c4e29
/Session02/homework/Serious_ex04.py
443
4
4
#ex 4a print(20*"* ") #ex 4b n = int(input("enter n: ")) print(n*"* ") #ex 4c for i in range(9): print("X * ", end='') print("X", end='') #ex 4e print() #ex 4d n = int(input("enter n: ")) for i in range(n): print("X * ", end='') print("X", end='') #ex_4f for i in range(3): print(7*"* ", end='') ...
d6a4080867317f34c249c701b6010d1a0634cc67
brunobara/lista1
/exercicio4.py
280
3.59375
4
""" Exercício 4 Escreva um programa que ache e imprima os números divisíveis por 13 e por 19, entre o ano de nascimento da sua mãe e 2727. """ for i in range(1957,2728): if (i % 13 == 0): print(i) elif (i % 19 == 0): print(i) else: pass
6f35a607ec2d8a0abbf3d99f490f9a2ddbbe8951
jokeefe1/Sorting
/src/iterative_sorting/iterative_sorting.py
1,204
3.90625
4
l = [ 8, 4, 2, 6, 7, 0] # TO-DO: implement the Insertion Sort function below def insertion_sort( arr ): for index in range(1, len(arr)): while index > 0 and arr[index] < arr[index -1]: arr[index], arr[index - 1] = arr[index - 1], arr[index] index -= 1 print(arr) ret...
37d979504c21cbf250796c97791e33ed2b323255
JoelWebber/ICTPRG-Python
/Week5 210329/week5quiz1question5.py
258
4.1875
4
inputValue = "" numberList = [] while (inputValue != 'x'): inputValue = input("Please enter numbers. If you enter x you will be shown all the numbers you have entered ") if (inputValue != 'x'): numberList.append(inputValue) print(numberList)
e9c3d8ba0263b88ba6a8092a58e3970338d7dacb
Superbeet/LeetCode
/Word_Search_II.py
1,656
4.03125
4
class TrieNode(object): def __init__(self, val): self.val = val self.children = {} self.is_word = False class Trie: def __init__(self): self.root = TrieNode("") def insert(self, val): node = self.root for letter in val: if letter not...
812374e52769785e9e779046d7f43a7a69a3eacc
nmoore32/Python-Workbook
/6 Dictionaries/exercise146.py
1,450
3.96875
4
## # Creates and displays a random Bingo card (without free space) # from random import randrange NUMS_PER_LETTER = 15 # Creates a random Bingo card # @return a dictionary containing B I N G O as keys and lists of 5 numbers as values def createBingo(): # Create empty dictionary card = {} # Variables to ...
51987c189ca48fc49e7761f5be2cb289ed91fc55
sunbin1993/machine-learning
/MyPython/src/python/hello.py
734
4.4375
4
#!/usr/bin/python3 print("hello world") # 第一个注释 ''' python 动态语言 数据类型:支持 整数(无大小限制)、浮点数(无大小限制 超过一定范围inf)、字符串、布尔值、空值、 变量:变量名必须是大小写英文、数字和_的组合,且不能用数字开头 常量: ''' """ sdfsdf """ if True: print("True") else: print("Flase") ''' 字符串 ''' str='Runoob' print(str) print(str[0:-1]) print(str[0]) print(str[2:5]) ...
637cedc4a95b9e3e2826d1fa7193e69c1cfe62ae
DZykov/Space-Invaders
/Environment.py
23,046
3.8125
4
import random from pygame import * import pygame import math import sys import datetime class Player(sprite.Sprite): """ This is a Player Class which is a subclass of pygame.sprite.Sprite Player Class creates controllable object Attributes: x: An integer represents x coordinate y: An i...
939cd99929188e4251248a229a08d5ce47bd5339
Randyedu/python
/知识点/04-LiaoXueFeng-master/67-SMTP.py
9,830
3.546875
4
''' SMTP发送邮件 SMTP是发送邮件的协议,Python内置对SMTP的支持,可以发送纯文本邮件、HTML邮件以及带附件的邮件。 ''' ''' Python对SMTP支持有smtplib和email两个模块,email负责构造邮件,smtplib负责发送邮件。 ''' from email.mime.text import MIMEText # 构造一个最简单的纯文本邮件: # 第一个参数就是邮件正文 # 第二个参数是MIME的subtype,传入'plain'表示纯文本,最终的MIME就是'text/plain' # 最后一定要用utf-8编码保证多语言兼容性。 msg = MIMEText('hello , sen...
129b8f111c1892590fb2a72df05005545a0d5471
pepsipepsi/nodebox_opengl_python3
/examples/Math/HowCurvesWork.py
1,704
3.78125
4
import os, sys sys.path.insert(0, os.path.join("..","..")) from nodebox.graphics.context import * from nodebox.graphics import * # This boring example demonstrate how curves work, and goes a bit # into the different parameters for drawing curves on screen. import math def draw(canvas): canvas.clear() # Setu...
afc759e8c83496767ae61a3f1d8a27f79c900a58
chfumero/operationsonfractions
/operationsonfractions/__main__.py
684
3.9375
4
import argparse from .expression_eval import expression_eval def main(): parser = argparse.ArgumentParser( description='This program take operations on fractions as an input and produce a fractional result' ) parser.add_argument('expression', metavar='expression', type=str, help='Operation on frac...
523b90dbb397c81affbeb96b55e2d0c81bb648d5
sankeerth/Algorithms
/HashTable/python/leetcode/find_duplicate_file_in_system.py
5,367
4.09375
4
""" 609. Find Duplicate File in System Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order. A group of duplicate files consists of at lea...
e782ce82e6efb40dc24df89b1fe52ead806373aa
Willian-PD/Exercicios-do-Curso-de-programacao-para-leigos-do-basico-ao-avancado
/Exercícios de python/secao-8-parte-6.py
189
3.921875
4
vetor = [1, 2, 3, 4, 5] code = int(input('Digite um código: ')) if(code == 1): print(f'{vetor}\n') elif (code == 2): vetor.reverse() print(f'{vetor}')
c653c37db0c4a55c7e770c35607a6afb7a4afb6f
Ander-H/LeetCode_Ander
/110_Balanced Binary Tree/solution01.py
865
3.921875
4
""" https://leetcode.com/problems/balanced-binary-tree/discuss/35691/The-bottom-up-O(N)-solution-would-be-better first solution the time complexity is O(n^2) """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right =...
3644112cec12a8e8594c9a694b74dd5d76a9b01b
garybergjr/PythonProjects
/GettingStarted/course_examples/while_loops01.py
272
3.765625
4
#for i in [0, 1, 2, 3, 4]: # print("Hello " + str(i)) counter = 0 while counter < 5: print("Hello " + str(counter)) counter = counter + 1 counter = 0 while True: print("Hello " + str(counter)) counter = counter + 1 if counter >= 5: break
8fe438d8d776c8f065db8ee8bc993fdba68a31f7
jschnab/leetcode
/math/count_distinct_numbers.py
891
4.03125
4
""" leetcode 2549: count distinct numbers on board We are given a positive integer n, that is initially placed on a board. Every day, for 1 billion days, we perform the following procedure: 1. For each number x present on the board, we find all numbers i such that 1 <= i <= n and x % i == 1. 2. We plac...
95b972b33538fb8b501dc42edfeb20d34fcb3873
georgedunnery/Spaceship
/spaceship.py
9,215
4.25
4
""" George Dunnery CS 5001 Homework 5 - Programming #2 - MODULE 11/2/2018 """ # Turtle module is necessary for visualization # Random module will help select a random word import turtle import random # Define SHIP to be turtle, since a spaceship is being drawn SHIP = turtle # SECTION 1: Functions coordinate the ga...
ac9d5c265190401c2e11d2b144cbf16961da09a2
snalahi/Python-Basics
/week3_assignment.py
2,114
4.4375
4
# rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) # with every month separated by a comma. Write code to compute the number of months that have more than 3 inches of # rainfall. Store the result in the variable num_rainy_months. In other words, coun...
660b24b3f3c2976548cf1395bccf55b39fde7cb5
ehsansadeghi1/tsp
/Nearest_Neighbor.py
1,701
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import networkx as nx import matplotlib.pyplot as plt # ============================================================================= # This function takes as input a graph g. # The function should return the weight of the nearest neighbor heuristic, # which starts at the ...
1d5a3cd2ea905fe8ef3a9fed41f8de2fa47d80a7
hrushikeshrv/deep-neural-net-1
/deep_neural_net_1.py
15,874
4.09375
4
""" Python script to construct a deep neural network. Needs the architecture of the network, the input data set and the output labels, and a few hyperparameters for you to decide. Call the 'four_layer_logistic()' or the 'five_layer_logistic()' functions to quickly construct a four layer or a five layer neural n...
e3cee24692e97dca3083162fd06db2b3db91abd7
mmariani/meuler
/019/019.py
330
3.828125
4
#!/usr/bin/env python3 import calendar import itertools import operator def run(): # cheating :) sundays = sum(calendar.weekday(year, month, 1) == calendar.SUNDAY for year in range(1901, 2001) for month in range(1, 13)) print(sundays) if __name__ == '__main__': ...
2ef722765eed31aeb226c151b8e4261d6dbe2d2f
douglas-hetfield/CURSOS
/Programacao III/Programas/2019_2/CCT0696_1/EXEMPLO_TK/JANELA_TK_2.py
394
3.828125
4
from tkinter import Tk, Label, Button, StringVar def traduzir(): textoRotulo.set("Alo Mundo") janelaPrincipal = Tk() textoRotulo = StringVar() textoRotulo.set("Hello World") rotulo1 = Label(master=janelaPrincipal,textvariable=textoRotulo) botao1 = Button(master=janelaPrincipal,text="Traduzir",command=...
337636f56d93948521b4af99005900f778b8672e
jadenpadua/new-grad-swe-prep
/bst/level-order-traversal.py
893
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution: def levelOrder(self, root: TreeNode) -> List[List[int]]: if root is None: return [] ...
14a108b48f67d1d195aa2189d2c8e37ae4acf744
ShaimaAnvar/python-challenge
/Q3.py
179
3.859375
4
def product(a): if len(a)==0: return 0 elif len(a)==1: return a[0] else: pro=a[len(a)-1] * a[len(a-2)] print(pro) list=[1,2] product(list)
364365b3011a83a1693397e638cced53af6687ae
sliwkam/Beginning
/6_list_overlap.py
233
3.6875
4
# library use import random # creating random list a = random.sample(range(100), 15) b = random.sample(range(100), 10) c = [] # checking common words for i in b: if i in a: if i not in c: c.append(i) print(c)
9f39388d18193de2f3691905bb5771e1f6539554
mehranaman/Intro-to-computing-data-structures-and-algos-
/Assignments/isbn.py
2,237
3.90625
4
# File: ISBN.py # Description: Algorithm to validate vald ISBN numbers. # Student Name: Naman Mehra # Student UT EID: nm26465 # Course Name: CS 303E # Unique Number: 51850 # Date Created: April 15th, 2017 # Date Last Modified: April 15th, 2017 def is_valid(ISBNno): #Function to check if ISBN is invali...
7525ff5fdaf2ba1a4400a9c2066c0fbd1792ff50
arpitpardesi/Advance-Analytics
/Python/Basics/Day2/ArpitPardesi_59128_Assignment(Day2)/Dictionary/Q21.py
99
3.6875
4
d ={'1':['a','b'], '2':['c','d']} for i in d.get('1'): for j in d.get('2'): print(i,j)
92c5dd51ead269a080f8279ba96d85acc60629a9
sdyz5210/python
/high/lambdaDemo.py
200
3.578125
4
#!/usr/bin/python # -*- coding: utf-8 -*- def f(x): return x*x map1 = map(f,range(1,11)) print map1 #使用匿名函数实现 print '打印匿名函数运行结果',map(lambda x : x*x,range(1,11))
bd35ee6b2f7c89ba71080b544262bb88ae71ede5
AndresMorelos/procesamiento-numerico
/semana9/polynomial_regression.py
460
3.71875
4
import numpy as np import matplotlib.pyplot as plt class Regression: def __init__(self,x,y, degree): self.x = x self.y = y self.degree = degree def polynomial(self, xi): poly_fit = np.poly1d(np.polyfit(self.x,self.y, self.degree)) return poly_fit(18) regression = Reg...
039437b41b48880d95b850c2b7ae11d6552fc6a5
mubaraqqq/electric-utilities-data-analytics
/Data.py
1,986
4.28125
4
import numpy as np # #One dimensional array # a = np.array([1, 2, 3]) # print(type(a)) # print(a.dtype) # #rank or axis # print(a.ndim) # #size attribute for array length # print(a.size) # ##shape attribute for shape # print(a.shape) # #Two dimensional array # b = np.array([[1.3, 2.4], [0.3, 4.1]]) # print(b.dtype) # ...
8645ca56ef57b085987d4c360b18e4ccc8f8f686
JoseGtz/2021_python_selenium
/Module_01/concat_lists.py
114
3.734375
4
list1 = ['hello', 'take'] list2 = ['dear', 'sir'] solution = [] for x in list2: list1.append(x) print(list1)
96e54896ec2064c1593f1b94d6d89dbb4e92785a
mragarg/loop-exercises-python
/square2.py
333
4.0625
4
user_input = input("How big is the square? ") try: user_input = int(user_input) except: pass star_string = "" star_column = "" row = 0 column = 0 while(row < user_input): while(column < user_input): star_column += "*" column += 1 star_string += star_column + "\n" row += 1 print...
2f7bc8be0e9cc763e183f448a90eac1574fc4e4f
HoYaStudy/Python_Study
/playground/Literal.py
2,936
3.765625
4
############################################################################### # @brief Python3 - Literal. # @version v1.0 # @author llChameleoNll <hoya128@gmail.com> # @note # 2017.07.28 - Created. ############################################################################### ''' Integer - Don't start with ...
4c9a89974fe7eb411b453621a7c4da1ad648873e
alvintanjianjia/MIMOS_Geospatial
/Visualizer.py
2,788
3.71875
4
import pandas as pandas from matplotlib import pyplot as pyplot import seaborn as seaborn class Plot: """ Class to handle plot """ def __init__(self, argv_width=15, argv_height=10): """ Size is in inches """ self._figure = pyplot self._width = argv_width ...
eabc78b0d6a4e899a076de2787c8083c2bf5696d
sergeichestakov/InterviewPrep
/longestValidParentheses.py
720
3.703125
4
# Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. class Solution: def longestValidParentheses(self, s: 'str') -> 'int': longest = 0 stack = [] stack.append(-1) for index, char in enume...
26eece00aa97d3c3d1113107f49e32f2c5f84674
MayuriTambe/Programs
/Programs/BasicPython/Colors.py
217
3.9375
4
def FisrtLast(): color_list = ["Red","Green","White" ,"Black"] First=color_list[0] print("The first color is:",First) Last=color_list[-1] print("The Last color is:",Last) return FisrtLast()
f9baedf1583b17447b3ffab0b6ffeb8850d1f983
sculzx007/Python-practice
/与孩子一起学编程/设置球的属性.py
780
4.25
4
class Ball: def bounce(self): if self.direction == "down": self.direction = "up" #这是创建一个类 myBall = Ball() #建立一个类的实例 myBall.direction = "down" myBall.color = "red" myBall.size = "small" #设置了一些属性 print "I just created a ball." print "My ball is ", myBall.size print "My ball ...
5806ac328d2f07a3489de08f3a83e74ab9a99752
Alexis-Matheson/CS362_HW4
/CubeVolume/volume.py
635
4.375
4
#This program calculates the volume of a cube import math def Volume(d): v = d * d * d print("The volume of the cube is %.2f units squared." %v) def main(): dimension = input("Enter the size of one side of a cube: ") try: float(dimension) is_float = True except: is_float ...
05d119e29a76d33d2fed6c844ead1b07e7146214
rayt579/cake
/greedy_algorithms/shuffle_riffle.py
3,768
4.3125
4
''' Write a function to tell us if a full deck of cards shuffled_deck is a single riffle of two other halves half1 and half2 Definition of the Riffle Algorithm ------------------------------------ 1) cut the deck into halves half1 and half2 2) take a random number of cards from top of half1 (can be 0) and throw them i...
1eec9005b1d8ecd3969a33eb4103b695c5c3c371
abdu-zeyad/math-series
/math_series/series.py
537
3.921875
4
def fibonacci(n): # the formula is : Fn= Fn-1 + Fn-2 if n <= 1: if n == 0: return 0 else: return 1 return fibonacci(n-1) + fibonacci(n-2) def lucas(n): if n <= 1: if n == 0: return 2 else: return 1 return lucas(n-1...
87d5c492f448a45c933a82112313c864b435cf3a
sdeva90/Python
/readlineinput.py
287
3.84375
4
# program to understand stdin.readline() function and module system import sys def sillyage(): print("how old are you") age = int(sys.stdin.readline()) if age == 3: print("i'm child") elif age == 40: print("I'm adult") else: print("I'm none")
742b355baefa55bc874e14ad5eb57961ffd8a5ba
ishantk/PythonSep72018
/venv/Session26.py
1,610
4.03125
4
import pandas as pd import matplotlib.pyplot as plt from scipy import stats data = pd.read_csv("advertising.csv") # print(data) X = data["TV"].values Y = data["Sales"].values print(">>>>>>>>>>>>>>>X><<<<<<<<<<<<<<<") print(X) print(">>>>>>>>>>>>>>>>Y<<<<<<<<<<<<<<<") print(Y) print(">>>>>>>>>>>>>>>><<<<<<<<<<<<<<<")...
1dbfb4b3a745f2efacf6fd00de51c392afe8ebbd
knnaraghi/MIT-6.00x
/Problem-Set-2/pay_off_debt_bisection_search.py
697
3.859375
4
balance = 431015 annualInterestRate = 0.15 monthlyInterestRate = annualInterestRate / 12.0 minimumpayment = balance / 12.0 maximumpayment = (balance * (1+ monthlyInterestRate)**12) / 12.0 payment = (minimumpayment + maximumpayment) / 2.0 originalbalance = balance while abs(balance) >= 0.01: balance = originalbalan...
5a7bf067101260fcc1f6e31dae2b25a9fd7533e7
susanmpu/sph_code
/python-programming/learning_python/factorial.py
445
4.09375
4
#!/usr/bin/env python # by Samuel Huckins """ Calculates factorial of the number entered. """ def main(): """ Requests a number, returns its factorial. """ num = int(raw_input("What is the number? ")) fact = 1 for factor in range(num, 1, -1): fact = fact * factor print "The factori...
490e2bbfe898da96aa8e25a4a3505b5ba98176ad
bhushanyadav07/coding-quiz-data-track-
/quiz1.py
646
4.375
4
#In this quiz you're going to do some calculations for a tiler. Two parts of a floor need tiling. One part is 9 tiles wide by 7 tiles long, the other is 5 tiles wide by 7 tiles long. #Tiles come in packages of 6. #1.How many tiles are needed? #2.You buy 17 packages of tiles containing 6 tiles each. How many tiles will ...
0f9b60909d2e5830ff7f2d0d810fe4788b66b8f7
RGMishan/py4e
/mlUdemy/zip.py
521
4.5
4
#zip function myList= [1,2,3] urList= [4,5,6] print(list(zip(myList,urList))) # create a list of tupples # store one one iterable from both the list or itearable # prints out [(1, 4), (2, 5), (3, 6)] myList2= [1,2,3,5,6] urList2= (4,5,6) #doesnot matter if it is list or tupple need to be iterable print(list(zip(my...
df8a83d7afa0b63654dfe1fbdc54a566f2cd7009
pornthipkamrisu/AI
/c1.py
718
3.921875
4
Number = input("Please enter 3 integers : ") num1 = int(Number[0]) num2 = int(Number[2]) num3 = int(Number[4]) if ((num1 > num2) and (num1 > num3) and (num2 > num3)): Max = num1 Min = num3 elif ((num2 > num1) and (num2 > num3) and (num1 > num3)): Max = num2 Min = num3 elif ((num1 > num2) and (...
1c08ddb58a8789f094bc0acd5bd5887ebff6b1fb
learningandgrowing/Data-structures-problems
/satyampwhidden.py
375
3.71875
4
def extractMaximum(ss): num, res = 0, 0 # start traversing the given string for i in range(len(ss)): if ss[i] >= "0" and ss[i] <= "9": num = num * 10 + int(int(ss[i]) - 0) else: res = max(res, num) num = 0 ret...
7bf24bbadb1ef156110b4a206032085c9d4b1863
bluescience/pythonCode3
/rootPwr.py
433
4.0625
4
def rootPwr(num): rt = 0 pwr = 6 while (rt ** pwr) != abs(num): rt += 1 if rt > num-1: # no root is bigger than its num pwr -= 1 rt = 0 if pwr < 0: return("There is no valid solution to this problem.") return("The solution f...
dde19ee648772802b167a904584cabd51923bacb
YuriSpiridonov/CodeWars
/add-commas-to-a-number-1.py
655
3.84375
4
# https://www.codewars.com/kata/add-commas-to-a-number-1/train/python import re def commas(num): num = round(num,3) regex = re.compile(r'(-?\d+)(\.\d+)?') mo = regex.findall(str(num)) lst = list(mo[0][0]) lencount = len(lst)//3 y = 3 returnNumber = str() if len(lst)<=3: returnN...
0c59f38ff69878a7c7dd237d260aec0a23c8dc8c
Priyanka0502/The_Python_Bible
/cinema_simulator.py
780
4.3125
4
films={ "titanic":{"age_limit":16,"Tickets":2}, "fault in our stars":{"age_limit":14,"Tickets":8}, "little women":{"age_limit":12,"Tickets":5}, "avengers":{"age_limit":8,"Tickets":15}, } while True: choice=input("Which film you want to see?").lower() if choice in films: age=int(inp...
d78c0c373d89579bea4e9e6c6dd8ce03218a59cc
SnyderMbishai/python_exercises
/list_comprehension3.py
335
4.28125
4
'''Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function.''' a = [2,6,8,10,11,22] def print_last_and_first(x): print([x[0], x[len(x)-1]]) print_la...
b29a78287c486bec6d57ee5707fd2b46a9ea764b
kannor/angry_search
/prac Unit3/loops_on_list.py
1,117
3.921875
4
list = [1,2,3,4] i = 0 while i < len(list): print list[i] i = i+1 for i in range(len(list)): print list[i] i = i + 1 # sum list def sum_list(list): sum = 0 for i in list :#' or ' range(len(list)) : sum = sum+ i # 'or ' list[i] print 'sum ' , sum sum_list([1,2,3,4,5]) # Measure udacity ''' def mea...
799b40ac45c622807eb9dd8d7ff93322ecc263cd
iamashu/Data-Camp-exercise-PythonTrack
/part6-import-webdata/No11-Pop-quiz-Exploring-your-JSON.py
924
4.375
4
#Pop quiz: Exploring your JSON ''' Load the JSON 'a_movie.json' into a variable, which will be a dictionary. Do so by copying, pasting and executing the following code in the IPython Shell: import json with open("a_movie.json") as json_file: json_data = json.load(json_file) Print the values corresponding to the ke...
2dc2788bfd5e2d71ba73cb067e6d8f0a1585b810
fpavanetti/python_lista_de_exercicios
/aula9_ex023.py
927
4.375
4
''' Crie um programa que leia o nome completo de uma pessoa e mostre: - O nome com todas as letras maiúsculas - O nome com todas minúsculas - Quantas letras ao todo (sem consirar espaços) - Quantas letras tem o primeiro nome ''' n = str(input("Digite seu nome completo: ")) print() print("*" * 40) ...
c0faa0506752612f470a37d11fb0f87acaf8ab55
guiaugusto/data_structures_examples
/Search_Tree/st_python_binary.py
713
4.03125
4
class Node(): def __init__(self, value): self.right = None self.left = None self.value = value def add_node(self): pass def remove_node(self): """ This method have to do this following orders: 1. Have to find the node in Binary Tree 2. If the node was found, it have ...
b6f397d2059104aa23c8394242e357b35dbc8154
ericyishi/HTMLTestRunner_PY3
/test_case/Test_Calc2.py
1,257
3.90625
4
import unittest from Calc import Calc class TestCalc(unittest.TestCase): '''计算器模块2''' def setUp(self): print("测试开始") self.cal = Calc() # 在这里实例化 def test_add(self): '''计算器加法模块2''' self.assertEqual(self.cal.add(1, 2), 3, 'test add1 failed') self.assertNotEquals(sel...
d4c4d13664f28227f9b69e0bf7b166f862abb321
terylll/LeetCode
/TwoPointer/88_mergeSortedArray.py
733
3.9375
4
class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ # Move back to front i = ...
5230aa3a2c3b2b2b53719b1b56d033bc8896f176
algol2302/PythonTricks
/002_functions/fabric_adders.py
197
3.515625
4
def make_adder(n): def add(x): return x + n return add if __name__ == '__main__': plus_3 = make_adder(3) plus_5 = make_adder(5) print(plus_3(3)) print(plus_5(7))
a2aa44a8cb10fc729b324b6927fddb29b18c6637
BrettMcGregor/udemy-colt-steele
/min_max.py
562
3.71875
4
# def extremes(iterable): # return min(iterable), max(iterable) # # # print(extremes([1,2,3,5,4,5])) # print(extremes("alcatrza")) # # # def max_magnitude(num_list): # return max(abs(n) for n in num_list) # # # print(max_magnitude([1,2,3,54,4,5])) # # # def sum_even_values(args): # return sum(x for x in arg...
957fbf7209108eab0bfae3c3a7988952eb6e2a57
NANDHINIR25/GUVI
/codekata/three numbers can form the sides og=f rite angled triangle.py
111
3.65625
4
ip1,ip2,ip3=map(int,input().split()) a=((ip1**2)+(ip2**2)) if((ip3**2)==a): print("yes") else: print("no")
2d379232b526f348d0f3fe14b8d35796dbf80e34
ikemerrixs/Au2018-Py210B
/students/yushus/session08/Circle.py
2,871
4.125
4
#!/usr/bin/env/python3 """ Yushu Song Au2018-Py210B Circle Class Assignment """ from math import pi class Circle: def __init__(self, radius): if radius < 0: raise ValueError('Radius cannot be < 0') self.__radius = radius self.__diameter = 2*self.__radius @property def...
0041655ef07e3861ee98fedc5e8467a7aea98135
crossphd/MIT_Programming_with_Python_6.00._x
/item_order function.py
1,593
3.921875
4
#w = raw_input("Enter any word: ") order = "salad water hamburger salad hamburger" def item_order(order): global salad, water, hamburger salad = 0 water = 0 hamburger = 0 s = order for l in range(len(s)): #salad count if s[l] == "s": if l+1 < len(s) and s...
81049a8d911cbec22f0527292e08f8d169be3d6c
gndit/datastructure
/reverselist.py
909
4.40625
4
#python progame to reverse a linked list class NODE: def __init__(self,data): self.data=data self.next=None class LINKED: def __init__(self): self.head=None def reverse(self): prev=None temp=self.head while (temp is not None): next=temp.next ...
6c89dd46d64b8d5c8b345a4d5d8685ce0b341549
mikem2314/PythonExercises
/TimeDelta.py
436
3.515625
4
#Written to solve https://www.hackerrank.com/challenges/python-time-delta/problem import datetime formatString = "%a %d %b %Y %H:%M:%S %z" testCases = int(input()) for t in range(testCases): t1 = str(input()) t2 = str(input()) formatT1 = datetime.datetime.strptime(t1, formatString) formatT2 = dateti...
ad3e55d120fc073ec0211a26ac45b72cf639a059
chenxu0602/LeetCode
/808.soup-servings.py
2,900
3.75
4
# # @lc app=leetcode id=808 lang=python3 # # [808] Soup Servings # # https://leetcode.com/problems/soup-servings/description/ # # algorithms # Medium (38.04%) # Likes: 102 # Dislikes: 377 # Total Accepted: 6.9K # Total Submissions: 18.1K # Testcase Example: '50' # # There are two types of soup: type A and type B...
eb7baf422562d7e9b7ef952234916f4ad6f117fe
Jordens1/python3-test
/work/python_goon/outer_inner.py
492
3.765625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ def outer(arg): # arg = echo() def inner(): print("*" * 20) arg() # echo 原函数 print("*" * 20) return inner # @outer # # def echo(): # print('欢迎来到') # echo() def echo(): print('欢迎来到') echo = outer(echo) echo() li = ["hello","w...
12d89d0b176551ca93b42fda41bbda6f1249e245
17764591637/jianzhi_offer
/LeetCode/746_minCostClimbingStairs.py
1,878
4
4
''' 数组的每个索引做为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。 每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。 您需要找到达到楼层顶部的最低花费。在开始时,你可以选择从索引为 0 或 1 的元素作为初始阶梯。 示例 1: 输入: cost = [10, 15, 20] 输出: 15 解释: 最低花费是从cost[1]开始,然后走两步即可到阶梯顶,一共花费15。 示例 2: 输入: cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1] 输出: 6 解释: 最低花费方式是从cost[0]开始,逐个经...
a45d7871694012a5064bc07b6e9033f6fcb15457
guilhermeerosa/Python
/Exercicios-CursoEmVideo/ex019.py
335
3.78125
4
#Escolha aleatória de 4 alunos com biblioteca random/choice from random import choice al1 = input('Nome do primeiro aluno? ') al2 = input('Nome do segundo aluno? ') al3 = input('Nome do terceiro aluno? ') al4 = input('Nome do quarto aluno? ') escolha = choice([al1, al2, al3, al4]) print('O aluno escolhido foi: {}!'.for...
85c506a47d6808b6bd9bef106fb00131bdb2931a
frankcollins3/algorithm
/merge_sort.py
218
3.796875
4
def merge_sort(arr): if len(arr) < 3: return array middle = int(len(arr) / 2) left, right = merge_sort(arr[:middle]) merge_sort(arr[middle:]) def merge(left, right): return merge_sort
a49ce0661ee451c3a3205595da62a820c79a6532
zingzheng/LeetCode_py
/106Construct Binary Tree from Inorder and Postorder Traversal.py
772
3.9375
4
##Construct Binary Tree from Inorder and Postorder Traversal ##Given inorder and postorder traversal of a tree, construct the binary tree. ## ##2015年8月13日 21:30:26 AC ##zss # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right ...
7ff279395092baf994281420aae6a628ebe1fd74
noltron000-coursework/data-structures
/source/linkedlist.py
9,835
4.1875
4
#!python class Node(object): def __init__(self, data): ''' Initialize this node with the given data. ''' self.data = data self.next = None def __repr__(self): ''' Return a string representation of this node. ''' return f'Node({self.data})' class LinkedList(object): def __init__(self, iterable...
97075196a97faea1f4e6a72383fbd3d6843ddfc9
JoshRifkin/IS211_Assignment10
/load_pets.py
2,026
3.671875
4
# Assignment 10 # Load Pets # By: Joshua Rifkin import sqlite3 as sql def createDB(db): # Delete tables if they already exist, prepping for creation db.execute("DROP TABLE IF EXISTS person;") db.execute("DROP TABLE IF EXISTS pet;") db.execute("DROP TABLE IF EXISTS person_pet;") # ...
36e513fb316b70cefe529a73b5485076d719e412
chandankuiry/image_processing
/threshold.py
610
3.546875
4
import cv2 import numpy as np img=cv2.imread('image/bookpage.jpg') grayscale=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) retval,threshold=cv2.threshold(grayscale,12,255,cv2.THRESH_BINARY) #now we are using adaptive threshold th=cv2.adaptiveThreshold(grayscale,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,115,1) #otsu t...
67b24cffbb5161454b7e60dc0ae5ad0204c94da5
shlampley/learning
/learn python/testing_args1.py
621
3.8125
4
name = "" age = "" hair_color = "" eye_color = "" height = "" weight = "" def user_input(query): while True: fname = input("What is your {}".format(query)) return fname def out_put(name, age, hair_color, eye_color, weight): print("hello " + name + " you are " + age + " years old, you have " +...
d792bbac99a4649247ffb673779199ff06e3fddc
paweldrzal/python_codecademy
/flat_list.py
239
4.0625
4
#flattening a list n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]] def flatten(lists): results = [] for li in lists: for m in li: results.append(m) return results print flatten(n) #output [1, 2, 3, 4, 5, 6, 7, 8, 9]
b99fe1e4140914e0948bb29af3d557b87f7312d9
shreyassk18/MyPyCharmProject
/Basic Programs/Check SubString.py
318
4.3125
4
#The find() method finds the first occurance of a specified value #find() method returns -1 if string not found str="Welcome to python programming" sub_str="python" check=str.find(sub_str) if (check==-1): print("Substring not present in a string") else: print("String present at position {}".format(check))
8a8b0c0a06c2c307defdbea728683c64b5802ca2
KailashGanesh/Sudoku-solver
/sudoku-GUI.py
7,164
3.6875
4
import pygame, sys from sudokuSolver import * import copy def isBoardSloved(board): ''' parm: (sudoku board array) return: True if no 0 present in board, False if 0 present ''' for i in range(len(board)): if 0 in board[i]: return False elif i == 8: return Tru...
1087b293ded7cebb9454f9491265fd6a63441314
sabrown89/python-practice-problems
/arrays/left_rotation.py
698
4.40625
4
""" A left rotation operation on an array shifts each of the array's elements 1 unit tot he left. For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2]. Given an array of n integers and a number, perform the number of rotations on the array. Return the upd...
d895ece7e7bc69eeca13ca868073fe31d02f45b0
maydaypie/recruiting-exercises
/inventory-allocator/src/inventory_allocator.py
3,173
3.765625
4
import unittest class TestBestShipmentsSolution(unittest.TestCase): def testCase1(self): """ Happy Case, exact inventory match!* Input: { apple: 1 }, [{ name: owd, inventory: { apple: 1 } }] Output: [{ owd: { apple: 1 } }] """ order = { 'apple': 1 } inventor...
8226335e2da6bf5854e36895e6aca6f51b869d27
pouyapanahandeh/python3-ref
/pythonW3/elevenn.py
795
3.890625
4
# classes in python class Employee: x = 5 # empOne is object for class Eployee ==> in Java ==> NameOfClass object = NameOfClass(); empOne = Employee() print(empOne.x) # the __init__() function which is simillar to the Constructor in java class Honda: def __init__(self, name, age): self.name = name self.ag...
a8d2dc248af5c5cbf3d612b1157735408e5dd57d
kamedono/raspi-camera-research
/opencv/python/sort.py
120
3.5625
4
a = [ [1,7,'z'], [3,2,'x'], [1,8,'r'], [2,2,'s'], [1,9,'b'], [2,2,'a'] ] print sorted(a, key=lambda x:x[2])
a155badd160d3e6bf427128cf63e8588515495fd
ICS3U-Programming-LiamC/Unit3-06
/num_guessing_better.py
2,106
4.53125
5
#!/usr/bin/env python3 # Created by: Liam Csiffary # Created on: May 11, 2021 # This program makes a random number and then has the user guess it # The user will get score based on their guess # this is a module that I found to generate random numbers # found on # https://www.programiz.com/python-programming/examples...
344244958127bb958c9beba7325e2d58461952ab
Tudor67/Competitive-Programming
/ProjectEuler/#20_FactorialDigitSum_sol2.py
164
3.59375
4
import math N = 100 N_FACTORIAL = math.factorial(N) digits = [int(digit) for digit in str(N_FACTORIAL)] digits_sum = sum(digits) # 648 print(digits_sum)
055db6590e709e50656570ab24895ab72bb6cc2b
sivilov-d/HackBulgaria
/week2/3-Simple-Algorithms/divisors.py
136
3.953125
4
n = input("Enter number: ") n = int(n) print("Divisors of %s are:" % n) for i in range(1, n): if n % i == 0: print(i)
dd771f5544820211eb7da4825dc9b48584bff1bd
chensi06lj/Python_project
/lec01汇率/current_convert_v1.0.py
370
3.671875
4
""" 作者:陈思 功能:汇率兑换 版本:1.0 日期:19/03/2019 """ # 汇率 USD_VS_RMB = 6.77 # 输入人民币 rmb_str_value = input('请输入人民币(CNY)金额:') # 将字符串转换为数字 rmb_value = eval(rmb_str_value) # 求兑换美元 usd_value = rmb_value / USD_VS_RMB print('美元(USD)金额是:', usd_value)
4df583f6bb75118fa17da28c1d65bd5a1c31e4e4
xuyufan936831611/vo_imu
/kitti_eval/print_trajectory.py
2,282
3.734375
4
import math import numpy as np import matplotlib.pyplot as plt import tensorflow as tf def quat2mat(q): ''' Calculate rotation matrix corresponding to quaternion https://afni.nimh.nih.gov/pub/dist/src/pkundu/meica.libs/nibabel/quaternions.py Parameters ---------- q : 4 element array-like ...
d8503d286783dd3ed5e4ed3f03060f9c5bc1e35f
MCornejoDev/Python
/Variables, ES y Operaciones aritméticas/Ejercicio6.py
401
3.78125
4
#Escriba un programa que pida una cantidad de segundos y que escriba cuántos minutos y segundos son. #1234 segundos son 20 minutos y 34 segundos #120 segundos son 2 min y 0 segundos print("CONVERTIDOR DE SEGUNDOS A MINUTOS") cSegundos = int(input("Escriba una cantidad de segundos: ")) minutos = cSegundos // 60 resto ...
8fdb6f8caf9fef4fd1353ce2e4b6ae2a47346e10
daniel-mcbride/CS1_Files
/Homework/McbrideD_CSCI1470_HW10/McbrideD_CSCI1470_HW10.py
1,946
4.28125
4
#*************** McbrideD_CSCI1470_HW10.py *************** # # Name: Daniel McBride # # Course: CSCI 1470 # # Assignment: Homework #10 # # Algorithm: # Start # #********************************************************** def checkLength(password): if len(password) >= 8: return True else: ...