blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c96b9b0bff3827243173b551c767d20d7c98b942
morel00/Calculator
/cal.py
1,752
4.21875
4
#!/usr/bin/python3 # *********SUMA*********** def Suma (): Number_one = int(input("Digite el 1st no. de la Suma: ")) Number_two = int(input("Digite el 2nd no. de la Suma: ")) result = Number_one + Number_two print("El resutado es: "+ str(result)+'\n') # *********RESTAS*********** def R...
ecde9bb3582572ab14049fd828a77515ba87ce90
zdsh/leetcode
/20190131/927_Three_Equal_Parts.py
1,114
3.78125
4
""" File: 927_Three_Equal_Parts.py Date: 2019/02/18 16:26:53 """ class Solution(object): def threeEqualParts(self, A): """ :type A: List[int] :rtype: List[int] """ ret = [-1, -1] n = sum([a == 1 for a in A]) if n % 3 != 0: return ret if n =...
3bef10cf6f0aebe86b9e8b6b8b37b36c1aa51154
gaurab123/DataQuest
/06_MachineLearning/03_LinearAlgebraForMachineLearning/03_MatrixAlgebra/06_MatrixInverse.py
1,367
4.25
4
# pages 25 & 26 in the hand written notes for context import numpy as np # Create a function named matrix_inverse_two() that accepts a 2 x 2 matrix, as a NumPy ndarray, and returns the matrix inverse.This function should first calculate the determinant of the matrix. # If the determinant is equal to 0, an er...
a932f34f1cf341877d3b748c01d4bfb3aa8e44d4
shugands/AdventOfCode
/2017/06/reallocate.py
803
3.5
4
def reallocate(banks): cache = max(banks) index = banks.index(cache) banks[index] = 0 length = len(banks) while cache > 0: index += 1 index = index % length banks[index] += 1 cache -= 1 def main(): path = "2017/06/day6.txt" banks = [] with open(path, '...
c87d8b77e0a4d132fc488e8b1ae83bf88f099b67
dr-mohanm/DataScience_Session4Assignment1
/Session_4_Assignment_1.py
3,114
4.40625
4
# coding: utf-8 # In[1]: # 1.1 Write a Python Program(with class concepts) to find the area of the triangle using the below formula. # area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 # Function to take the length of the sides of triangle from user should be defined in the parent class and #function to calculate the area sh...
0e5c19b976c378f4412d77112393ae0c1931ee49
harkevich/testgithub
/Lesson/Lesson10МетодыСтрок.py
1,622
4.21875
4
s = 'hello, world!' #-------- Метод len ----------- #print(len(s)) # подсчет всех символов в строке # -------- Метод capitalize ------------ #print(s.capitalize()) #capitalaze Переводит первый символ строки в верхний регистр, а все остальные в нижний #s2 = s.capitalize() #print(s, s2) #---------- Метод Center ------...
c2e9a85d51b0e2391acc57bb14bffe7878e836d8
jmh9876/p1804_jmh
/1805/python高级/5/3-继承__init__方法.py
730
3.703125
4
class Animal(object): def __init__(self,name,color = "白色"): self.name = name self.color = color def eat(self): print("吃东西") def setColor(self,color): self.color = color def __str__(self): msg = "颜色是%s"%self.color return msg ''' 子类没有init方法...
b32e33432a923dc5d297ed5e8ac96b93ffaab8ae
turkeydonkey/nzmath3
/nzmath/real.py
8,399
3.703125
4
""" real -- real numbers and the real number field. The module real provides arbitrary precision real numbers and their utilities. The functions provided are corresponding to the math standard module. """ import itertools import warnings import nzmath.arith1 as arith1 import nzmath.rational as rational import nzma...
c1d93bebb3b22ca6a6f14f7615f4979b18a6d627
shen-huang/selfteaching-python-camp
/exercises/1901040046/d08/mymodule/stats_word.py
1,791
3.640625
4
#将字符串s按照None的分隔切分为一个字符串组,并清洗字符串元素的标点符号,并统计不同字符是数量,最后以数量降序排列。 def stats_text_en(text): if type(text) == str:#新增类型检查语句 replace_text = text.replace(',','').replace('.','').replace('*','').replace('?','').replace('!','').replace('-','') split_text = replace_text.split() wordcount ...
c295545990ac4da9ff945724d40b1f423e4c5c21
privateHmmmm/leetcode
/146-lru-cache/lru-cache.py
3,115
4.09375
4
# -*- coding:utf-8 -*- # # Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. # # # # get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. # put(key, value) - Set or insert ...
514ec4454f96957a15a76d1076f7c3ed0d7fa36a
JacobChurch-osu/hello-world
/Scripting Projects Assignment 8 Jacob Church/Project 1 Code.py
648
4.03125
4
import math Toler = 0.000001 def newton(x): """ Returns the square root of UserNum """ Estimate = 1.0 while True: Estimate = (Estimate + x / Estimate) / 2 Diff = abs(x - Estimate ** 2) if Diff <= Toler: break return Estimate def main(): """Allows the u...
c02275464ccdb87b488a6ad4d1a669e428d0b5c5
Savan777/simple-imdb-scrapper
/imdbScrape.py
1,417
3.59375
4
__author__ = 'Savan Patel' import urllib2 #need to open and see website data from bs4 import BeautifulSoup #need to parse website data #website url url = 'http://www.imdb.com/search/title?languages=%C2%B7%C2%B7%C2%B7%C2%A0Common%20Languages%C2%A0%C2%B7%C2%B7%C2%B7&release_date=2010-01-01,2017&title_type=feature&user_r...
d3003748f609ac9c62a6d00c3b6fafa399fb9720
torres1-23/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
806
4.46875
4
#!/usr/bin/python3 """This module defines an integer addition function "add_integer(a, b=98)" Usage: "add_integer(...)" return the addition of two arguments, equivalent to using the "+" operator in numbers. """ def add_integer(a, b=98): """Function that adds 2 integers. Args: a (int): first...
6168049840dcf14a90d10e49def2d3f62c414f95
keakaka/python_ch2.2
/comprehension.py
1,024
3.71875
4
results = [] for n in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: result = n * n results.append(result) print(results) # list comprehension results = [n*n for n in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]] print(results) # 문자열 리스트에서 길이가 2 이하인 문자열 List or Set strings = ['a', 'as', 'as', 'bar', 'car', 'dove', 'python'] results =...
8c958b879d798c2784b8aafbaf2cbbe1acc34f92
bryan1292929/Table-Parsing
/src/process_data/extract/traverse_data.py
766
3.515625
4
# File: traverse_data.py # Purpose: Provides functions to traverse tables in xml files and folders. from pathlib import Path from lxml import etree # Returns a collection of xml files in a folder. def files_in_folder(folder): return Path(folder).rglob('*.xml') # Returns an iterator through tables in ...
87ff6924d5cc535fcf3791dbe0a8738f258e8d48
ysantosh/learn-ruby
/misc_program/pi1_check_div.py
314
3.703125
4
#! /usr/bin/env python # from 1..100 if number divisible by 4 and 6 print foursix # if divisible by 4 then print four # if divisible by 6 then print six for x in range (1,101): if x%4==0 and x%6==0: print "%d - foursix" %x elif x % 4 == 0: print "%d - four" %x elif x%6==0: print "%d - six" %x
6572ddc477c6242af4930b4c4c0e32c203b5d851
krenevych/algo
/source/T1_Recurence/L6.py
217
3.609375
4
n = int(input("n = ")) D2 = 5 # 1-й член послідовності D1 = 19 # 2-й член послідовності for k in range(3, n + 1): D1, D2 = 5 * D1 - 6 * D2, D1 print("D_%d = %d" % (n, D1))
bd4d82070b896f9256fbf4d04a9d41a70728f83b
ravinaNG/practice-files
/Reverse_str.py
159
3.734375
4
user = raw_input("Type any string:- ") string = "" count = -1 while(count >= -(len(user))): string = string + user[count] count = count - 1 print string
38512fa504c788c7305737c06406ec8dcec0e4de
hiyoung123/ChineseSegmentation
/src/fmm.py
871
3.609375
4
#!usr/bin/env python #-*- coding:utf-8 -*- from src.base import BaseSegment class FMMSegment(BaseSegment): def __init__(self, file: str = '../data/dict.txt'): super(FMMSegment, self).__init__() self.load_dict(file) def cut(self, sentence: str): if sentence is None or len(sentence) ==...
1b6840af514ab11249cacd9640eb66b466f1557f
toumorokoshi/python-code-challenges
/07/28.py
892
3.90625
4
def all_sliver_users(card_names_by_person): """ given a dictionary of <string, list[string]> pairs, mapping a user to all of the card names that user owns, return a list of all users who own a card with "sliver" in the name. """ z= [] for k,v in card_names_by_person.items(): for ...
1da95b905b5c64e262675d927250286e50541c15
kdog31/eya-ai
/eya_first_run.py
774
3.578125
4
#imports import os import json #database stuff db = open("eyadb", "w") def say(saystr): os.system("say " + str(saystr)) def input(db): say("What should i call you?") name = raw_input("what should i cal you?") print("ok so your name is " + name + ", nice to meet you") say("ok so your name is " + name + ", nice...
7bb3a14d2d5fb231e85f4b4f38681e618026582c
jnau/Jnau-Sample-Scripts
/Python/Other/Hangman.py
4,243
4.25
4
#this program will allow the user to play "hangman" #these are the global variables we wil be using num_wrong = 0 question_marks = "" guess_letters = "" def get_secret_word(): #to obtain the secret word global question_marks while True: question = ("Please enter a word to be guesse...
88dd8ea06aa35e3af232b9a003c87bb775609382
Lanottez/IC_BA_2020
/1st Term/Data_Structure_and_Algorithms/Codes/Exercises/ses08/ses08_extra.py
1,098
3.78125
4
from ses08_data_structures import Graph, Digraph, Queue, QueueNode def create_dfs_graph(): """ Initializes a test graph for DFS """ g = Graph() g.add_edge('John', 'Helena') g.add_edge('John', 'Chris') g.add_edge('Helena', 'Paul') g.add_edge('Chris', 'Paul') g.add_edge('Chris', 'Vic...
9078dd2179869a3a0e25439bc3cad7edd29914bc
biglerd7304/CTI110
/P2HW1_CelsiusConverter_DanielBigler.py
413
4.34375
4
# Celsius to Farenheit Converter # 9-4-18 # CTI-110 P2HW1 - Celsius Fahrenheit Converter # Daniel Bigler # # input is in celsius degrees_celsius = float( input('enter the temperature in Celsius: ')) # Calculate from celsius to fahrenheit degrees_fahrenheit = (degrees_celsius * 1.8) + 32 # Display the ...
9084d7a102ba5f8fcb335d50478eedb265358fcf
richbm10/Visualizacion-de-la-Informacion-PC3
/rewrite.py
1,178
3.515625
4
# Read World Population world_population = open('world_population.csv', 'r') lines = world_population.readlines() # Create Dictionary for Codes of Countries countries = dict() # Set the Country Code for each Country Name for line in lines: words = line.split(",") countries[words[0]] = words[1] ...
8175f544a0329429d3738e86175f3ad9ac8d748a
unclosable/funny-project
/leetcod-problems/2add-two-numbers.py
1,575
3.8125
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: reNode = l1 currentL1 = l1 lastL1 = None currentL2 = l2 ...
f98a65e6b1ccb923b89fcc7e1bc1fc753ac40d48
lazypanda10117/Problem-Collection
/LeetCode/540.py
2,246
3.78125
4
class Solution: LEFT = 0 RIGHT = 1 ODD = 1 EVEN = 0 def giveParity(self, num: int) -> int: return num % 2 def isMiddleSingle(self, nums: List[int]): return nums[0] != nums[1] and nums[1] != nums[2] and nums[2] != nums[0] def getDirection(self, idx: int...
2e303dd5325099609ba6939f309ebdb258d7b342
tgrahamcodes/pyProj
/py.py
1,260
3.90625
4
def encrypt(): lines = [] line = '' fileName = 'test.txt' case = '' listSpecial = [] listUpper = [] # loop through lines in list # and print the entire string with open (fileName) as fh: lines = fh.read().splitlines() print (lines) # print out per le...
fa6e077b39282190ca964b7319b1593c5ade2d64
adamjalred/ExampleProj
/main.py
260
4.09375
4
def multiTwoNumbers(num1, num2): num3 = num1 * num2 return num3 def addTwoNumber(num1, num2): num3 = num1 + num2 return num3 if __name__ == '__main__': answer = addTwoNumber(5, 3) answer2 = multiTwoNumbers(4, 5) print(answer) print(answer2)
e16263677af91f6e593a7d3aa59fe110de65902a
MANakib/Python-Code-sample-
/Loop.py
335
3.75
4
i = 35 Age = input("Age:") if int(Age) < 35: print ("You are too young, You must be at least 35 years old. ") else: print ( "Born in the U.S.?: Yes/No ") Answer = input() if Answer == 'Yes': print ('Years of Residency: ', int(Age)) else: x = int(Age) - i print ('Years of Residen...
b2d919a86620bc1cc0ed1c4fd16d3edd2f9c3fc3
jvanderhorst/web-335
/week-8/vanderhorst_calculator.py
219
3.859375
4
# add function def add(a, b): return a + b # subtract function def subtract(a, b): return a - b # divide function def divide(a, b): return a/b print(add(7,8)) print(subtract(17,5)) print(divide(18,3))
f94a9a725616449585524371108ef952cba14157
to-Remember/TIL
/June 4, 2021/8_변수scope.py
761
3.875
4
# 지역변수(지역구): 함수 내에서 선언. 그 함수 내에서만 사용가능 # 전역변수(전국구): 함수 밖에 선언. 이 파일 내에서 모든 함수에서 사용가능 num=10 #전역변수 def f1(): global num #전역변수로 지정 num=20#전역변수. 전역변수 값 변경 print('f1:', num) def f2(): x = 5#지역변수 num = 15 #변수 정의. 지역변수로 정의 print('f2 x:', x) print('f2 num:', num)#지역변수 def main(): print('mai...
24fe065d675282e5b06194d4e799de1b33dafa66
djsilenceboy/LearnTest
/Python_Test/PyCodePractice/com/djs/learn/LetterCombinationsOfAPhoneNumber.py
1,043
3.71875
4
''' @author: Du Jiang https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/ ''' class Solution: __number_letter_dict = {"0": "", "1": "", "2": "abc", "3": "def", "4": "ghi", "5": "jkl", "6": "mno", "7": "pqrs", "8": "tuv", "9": "wxyz"} def letterCombinat...
ea3702b51fb0d33c59aeda04353c9d698a5a8a74
INKWWW/python_project
/utils/iter_next.py
2,020
4.0625
4
# 容器 '''容器是用来储存元素的一种数据结构,容器将所有数据保存在内存中,Python中典型的容器有:list,set,dict,str等等。 for … in… 这个语句其实做了两件事。第一件事是获得一个可迭代器,即调用了__iter__()函数。 第二件事是循环的过程,循环调用__next__()函数。 对于test这个类来说,它定义了__iter__和__next__函数,所以是一个可迭代的类,也可以说是一个可迭代的对象(Python中一切皆对象)。 ''' print('------容器------') class test(object): """docstring for test""" de...
3239bb290a89aeb6962c20565874d34e46616320
shubhpy/Python-Programs
/FinFout.py
603
3.546875
4
def retrieveFile(): try: bestStudent={} bestStudentStr= "The students ranks are as follows \n" fin = open("student.txt","r") except(IOError),e: print "File not found",e else: for line in fin: name,grade = line.split() bestStudent[grade] = name fin.close() for i in sorted(bestStudent.keys()): ...
d088c3d5890bec181b60e28e791d190ae6615142
Yun-Su/python
/PythonApplication1/PythonApplication1/高级特性之列表生成式.py
386
3.734375
4
print([x * x for x in range(1, 11)]) print([x * x for x in range(1, 11) if x % 2 == 0]) #写列表生成式时,把要生成的元素x * x放到前面, #后面跟for循环,就可以把list创建出来, #for循环后面还可以加上if判断,这样我们就可以筛选出仅偶数的平方: print( [m + n for m in 'ABC' for n in 'XYZ']) #使用两层排列进行组合遍历
e98c15130c0c50a90073b2a7b87e27b0da3be825
Sachinshivamurthy/python_codes
/python/basics,datatypes-no.,string,tuple,dictionary,list,sets/function5.py
179
3.6875
4
def nsum(n): sum=0 if(n<1): return n else: for i in range(1,1+n): sum=sum+i return sum print(nsum(5))
bc2c85a29a1f37ada39ec94249f1869cda300918
serge-m/simplebbox
/simplebbox/_array_processor.py
5,335
3.65625
4
def atleast_2d(x): if x.ndim == 1: return x.reshape(1, *x.shape) return x class ArrayProcessor: def __init__(self, stack_fn): self.stack = stack_fn def x0y0wh_to_x0y0x1y1(self, x0y0wh): """ Converts a bounding box from format (min x, min y, width, height) to ...
d16fae0b18f5a7824e1b24c5846c68118868dc8f
avanover0311/Python
/pythonprojects/ForLoopBasic1.py
431
3.65625
4
#basic for count in range(0,151): print("looping -", count) # mult of 5 for num in range(5,1000000,5): print (num) # counting for num in range(1,100,1): if(num%5): print('Coding') elif (num%10): print('Coding Dojo') #whoa sum = 0 for num in range(0,500000): if(num%2 != 0): sum = sum + num print(sum) #...
5f50efc627190f87846cee6f01773c302b05c973
FernandoUrdapilleta/Python101
/List.py
4,265
4.28125
4
# There are four collection data types in the Python programming language: # List is a collection which is ordered and changeable. Allows duplicate members. # Tuple is a collection which is ordered and unchangeable. Allows duplicate members. # Set is a collection which is unordered and unindexed. No duplicate members....
b6443ad0a045070cddb1c824ff227fe49c9730de
hasanjafri/DailyCodingProblems
/#1320/longest_substring_distinct.py
837
3.8125
4
def longest_substring_with_k_distinct_characters(s, k): char_count = {} max_len = 0 start = 0 for end in range(len(s)): char = s[end] if char not in char_count: char_count[char] = 0 char_count[char] += 1 while len(char_count) > k: char_to_remove ...
73fe7a3b93ba2de72dd95713b215e977a44252fe
Sidney-kang/Unit4-06
/string.py
540
4.125
4
# Created by : Sidney Kang # Created on : 8 Nov. 2017 # Created for : ICS3UR # Daily Assignment - Unit4-06 # This program checks if 2 strings are the same def compare_strings(string_1, string_2): string_1 = string_1.upper() string_2 = string_2.upper() if string_1 == string_2: return True ...
d54adee2f3bdef3fb8bcf6c70ea54032bb3d4fc6
noopurkharche/dataStructuresAndAlgorithms
/wordLadder.py
720
3.78125
4
def ladderLength(beginWord, endWord, wordList): queue = [(beginWord, 1)] visited = set() while queue: word, dist = queue.pop(0) if word == endWord: return dist for i in range(len(word)): for j in 'abcdefghijklmnopqrstuvwxyz': tmp = word[:i...
016c0e3343302f16f7c95c0a2539bd5d373ded48
Shaunwei/Leetcode-python-1
/Array/N-Queens/solveNQueens.py
2,322
3.875
4
#!/usr/bin/python """ N-Queens The n-queens puzzle is the problem of placing n queens on an nXn chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where '...
103ddd98dcbf7d53c617d9cdd5843896bc2223bd
GAurelG/Udacity
/data-analyst-nanodegree/03_Projet_OpenStreetMap/Submission/Script/1_audit.py
6,438
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # In this part, we audit the street names and phones numbers. Function used to # audit both are separated, they share common parts, but for the clarity of # presentation I choose to separate them. # # Street audit: # In France, the street category name ("avenue"...) is the...
b9f398926e39cd5ed7f04d6a759fddc0052d58bf
fredrik-k/project_euler
/p_121_130/p126.py
1,712
3.96875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' PROBLEM 126: The minimum number of cubes to cover every visible face on a cuboid measuring 3 x 2 x 1 is twenty-two. If we then add a second layer to this solid it would require forty-six cubes to cover every visible face, the third layer would require seventy-eight cub...
4ebd1b8e983020aefb6250903ec93298b0bbc9c8
jonbugge4/CSV
/sitka1.py
598
3.609375
4
import csv open_file = open("sitka_weather_07-2018_simple.csv", "r") csv_file = csv.reader(open_file, delimiter= ',') header_row = next(csv_file) print(type(header_row)) for index, column_header in enumerate(header_row): print(index, column_header) high = [] for row in csv_file: high.append(int(row[5])) ...
64355d862201142ddcbb104a3f2dafb62777a447
sandhoefner/sandhoefner.github.io
/odds.py
487
3.703125
4
print("> Give me a number between 0 and 1") pct = input() # print("> I heard " + str(pct)) best_diff = 100 best_pair = [10,1] for i in range(1,11): for j in range(1,11): print str(i) + ".0/" + str(j) diff = abs(float(i)/j - pct) # print(str(i) + "/" + str(j) + " has diff " + str(diff)) if diff < best_diff:...
077b9ff4b07ace8ecc2c416f4255999e3ab4f933
Gurgen99/python_course
/class/patker.py
1,935
3.859375
4
import math class Shape(): def __init__(self): pass def draw_me(self): raise NotImplementedError class D_2(Shape): def draw_my(self): pass def space(self): raise NotImplementedError class D_3(Shape): def draw_me(self): pass def volume(self): ...
34521b8eda6a4172e9eae78c86a80de563f35b9f
juliarowe/Coursework
/ComputationalPhysics/IsingModel/SquareLattice.py
1,670
3.640625
4
import random import copy from Lattice import Lattice class SquareLattice(Lattice): def __init__(self, size, num_dimensions): self.size = size self.num_dimensions = num_dimensions self.data = self.generate_array(num_dimensions) # Generates the internal data structure for the square lat...
bf2707e997a7da003bc7dc3e7c342e8dc63fb8e4
FargoFire/LeetCode_python3
/024# Swap Nodes in Pairs.py
2,098
3.734375
4
# coding:utf-8 """ Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. 题目地址:https://leetcode.com/problems/swap-nodes-in-pairs/ Date: 2019/06/20 By: Fargo Difficulty: Medium """ # Definiti...
eda3d603e83b587a49ad477624b132876a39deb6
tangentspire/Python_Practice
/automate_the_boring_stuff_with_python/Part_1_Python_Programming_Basics/Chapter_2_Flow_Control/collatz.py
428
4.125
4
def get_number(): try: number = int(input("What number would you like to call the collatz function with? > ")) collatz(number) except ValueError: print("You have entered a non-number, please try again.") get_number() def collatz(number): if 0 == (number % 2): number = number // 2 print(number) retur...
caf725bfaa25a3cc9ed51410009b15be9199307e
TechInTech/leetcode
/3.无重复字符的最长子串.py
1,472
3.75
4
# # @lc app=leetcode.cn id=3 lang=python3 # # [3] 无重复字符的最长子串 # # https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/description/ # # algorithms # Medium (30.68%) # Likes: 2154 # Dislikes: 0 # Total Accepted: 174.6K # Total Submissions: 568.9K # Testcase Example: '"abcabcbb"' # # 给定一个...
00c729747b8a5f055ec7d654506508c223693ebd
Jesta398/project
/collections'/list/ddemo3.py
654
3.515625
4
# lst=[10,20,30,40,50,60,70,80,90,100] # sum=0 # for i in lst: # sum=sum+i # print(sum) # # # or method # # lst=[10,20,30,40,50,60,70,80,90,100] # print(sum(lst)) # #max eleemnt # # lst=[10,20,30,40,50,60,70,80,90,100] # # print(max(lst)) # # lst=[10,20,30,40,50,60,70,80,90,100] # for i in lst: # # if(lst[i]<...
21d0afb9703a99bba599f6189b5a4e99f87d7ce2
pavanv27/MyPythonExamples
/TwoSum/1.py
579
3.515625
4
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for x in range(len(nums)-1,-1,-1): for y in range(x): if nums[x]+nums[y]==target: ...
1883b3ed7d2bbbbc0bd73dd48ee685e0772fde62
KarimnC/EjercicioPrueba
/VelPromedio.py
327
3.78125
4
# Autor: Karimn Daniel # Calcular la vel. promedio en un viaje. tiempo = int(input("A ver prro, escribe el tiempo de viaje en horas enteras: ")) distancia = int(input("Shavo, ahora escribe la distancia del viaje en kilómetros enteros: ")) velocidad = distancia/tiempo print("A nu ma, la velocidad es: ", veloc...
b6a439a4ea11249f24d77160afee34e5e1c94aa1
JokerJudge/py111_lab
/Tasks/g1_merge_sort.py
2,363
3.75
4
from typing import Collection, TypeVar _Tt = TypeVar("_Tt") def sort(container: Collection[_Tt]) -> Collection[_Tt]: """ Sort input container with merge sort :param container: container of elements to be sorted :return: container sorted in ascending order """ ''' #мое пока неудавшееся решение part_list = co...
9ce12cbc0d66d593986abfd152e67031607a1ccf
matheusota/VI-and-UCT
/program.py
9,222
3.578125
4
import pdb import math from sys import argv import random ######################################################################## #find the max difference between utilities def difference(values, s): diff = 0 for (i,j) in [(i,j) for i in range(s) for j in range(s)]: if diff < abs(values[0][i][j] - values[1][i][j...
b352562c13ddcbad329f08f03eb0c524176e5a50
rajfal/algos
/fibonacci_last_digit0.py
1,390
4.03125
4
# Uses python3 from timeit import default_timer as timer def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % 10 def get_fibonacci_last_digit_itrn(n)...
6d30d32bf97a33f764b8050da241630bf5e2e7a5
erenkrbl/python_bites
/srednee.py
168
3.515625
4
one = input("Введите первое число ") too = input("Введите второе число ") srednee = ((int(one) + int(too)) // 2) print(srednee)
fc67206793cd483acdbb305f621ab33b8ad63083
rsp-esl/python_examples_learning
/example_set-1/script_ex-1_27.py
1,088
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # Author: Rawat S. (Dept. of Electrical & Computer Engineering, KMUTNB) # Date: 2017-11-17 ############################################################################## from __future__...
4a9fda905ff636ebdaad7aed11681d5dafdfb457
shiningnight93/Baekjoon_Algorithm
/01-05-2021.py
1,944
3.515625
4
''' 01-05-2021 Baekjoon Algorithm 단계별 문제 풀이 - 3단계 언어 - Python ''' # 11021 # 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. temp = [] t = int(input()) for i in range(0, t): temp = input().split( ) a = int(temp[0]) b = int(temp[1]) print('Case #{0:d}: {1:d}'.format(i+1, a+b)) ...
08643d8919cab75dcd6a68709d39da0ee58f551a
elenaborisova/Python-Advanced
/10. Functions Advanced - Exercise/05_function_executor.py
332
3.828125
4
def sum_numbers(num1, num2): return num1 + num2 def multiply_numbers(num1, num2): return num1 * num2 def func_executor(*args): results = [] for arg in args: func, nums = arg results.append(func(*nums)) return results print(func_executor((sum_numbers, (1, 2)), (multiply_number...
866cea4b528466a61b6a5054a4de7990db00cbe6
neutrons/GUI_Tools
/Logging/loggingHelpers.py
2,733
3.875
4
import os def parseLoggingConf(): """ To see this docstring: print parseLoggingConf.__doc__ This function parses a logging.conf file used in support of python logging. USER WARNING: THIS IS VERY FRAGILE CODE!!!! This function expects the logging.conf file to be in a specific format so ...
d1732d71aa7d7f75c8a2160fdda01af645e56ad0
huiyi999/leetcode_python
/Valid Palindrome.py
699
3.890625
4
class Solution: def isPalindrome(self, s: str) -> bool: s2=[x.lower() for x in s if x.isalnum()] for i in range(len(s2)//2): if s2[i]!=s2[len(s2)-1-i]: return False return True def isPalindrome2(self, s: str) -> bool: s=s.lower() n=filter(str...
2965bbeb4ba9fe9ebe50f6aa6b5813030e671324
reddyprasade/Natural-Language-Processing
/Sequencing/sequences.py
863
3.546875
4
# Author:Reddy prasade import tensorflow as tf from tensorflow import keras from tensorflow.keras.preprocessing.text import Tokenizer sentences = ["I love my dog", "I love my cat", "You Love my Dog!", "Do you thing my dog is amazing" ...
42531cd111ee2157ebf4c40c7e897c4c7cf70ba9
adeebshaikh/pythontraining
/python .py
1,172
4.0625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: x=10; if(x<15): print("the number is less than 15"); # In[1]: print(3>=3) # In[8]: x=10; if(x>15): print("hello good morning"); else: print("hello good afternoon"); # In[11]: x=10 y=5 if(x<y): print(x,"is smallest number") else: print(y,"...
887d3ac755a9777cd4feba5526b7bf0f16defd40
JoseALermaIII/python-tutorials
/pythontutorials/Udacity/CS101/Lesson 18 - How Programs Run/Q27-Lookup.py
1,121
3.5625
4
# Define a procedure, # hashtable_lookup(htable,key) # that takes two inputs, a hashtable # and a key (string), # and returns the value associated # with that key. def hashtable_lookup(htable, key): bucket = hashtable_get_bucket(htable, key) for element in bucket: if key in element[0]: r...
253dd09a821ef1c4fe5d9167ad4d3d556a7de474
bregoh/Sorting-Algorithm
/quicksort/quicksort.py
1,423
4.375
4
import math # array = array to be sorted # low = start index of the array # high = end index of the array def quicksort(array, low, high): if low < high: # return the index of the small element partition_value = partition(array, low, high) # recursive method to sort array before and after...
ed424714bf5ea94607c7e959bba3896b756b6e7a
MLoopz/CodeWars
/MostSales/MostSales.py
965
3.96875
4
def top3(products, amounts, prices): listOfProducts=list() listOfAmounts=list() for i in range(0,len(products)): listOfAmounts.append([amounts[i]*prices[i],i]) listOfAmounts.sort(key = sortFirst, reverse=True) for i in range(0,len(products)): listOfProducts.append(products[listOfA...
5529e5fd2a89912cf7fe41c09525e5ed4376bc73
nandoribera/PYTHON
/lista5.py
1,236
4.0625
4
#usr/bin/python3 #Eliminar una plabra de la lista #Crear lista 1 print("¿Cuantas palabras tiene la primera lista?") palabras = input() palabras = int(palabras) frase = "" frase = list(frase) x = 0 while x < palabras: print("Dime la palabra ", x + 1) palabra = input() frase.append(palabra) x = x + 1 print("La l...
08af3cf7c8d6a274eaa87fcea3ea17be899503f9
here0009/LeetCode
/Python/310_MinimumHeightTrees.py
5,720
4.34375
4
""" For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find all the MHTs and return a list of their root ...
76654c745b37420a0ca5a9fa94f2126118543e14
mblasterx/Leetcode
/p21.py
1,364
4.125
4
from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def __str__(self) -> str: returnStr = 'ListNode: ' + str(self.val) while self.next: self = ListNode(self.next) returnStr += '->' + str(self.val)...
f12abd1eca89231dac545ce3f2a5b24d9cb92471
cha63506/Archive-304
/Battleship/ship.py
2,970
4.0625
4
class Fleet(object): """Fleet class object, a dictionary containing name of ships, \ as keys and ship dictionaries as values. Ship dictionary \ contains co-ordinate tuple as keys and ship \ status as values.""" def __init__(self, board): self.fleet = {} self....
8cb410b18cda30ba1c598128ad94c7a40ef05e87
wangshihui/TensorFlow_jcaptcha
/tensorFlow-Jcaptcha/python/test.py
1,690
3.796875
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ ------------------------------------------------------------------------------- Function: 【整理】Python中:self和init__的含义与使用 Verison: 2017-10-10 ------------------------------------------------------------------------------- """ #注:此处全局的变量名,写成name,只是为了演示而用 #...
3665f608624bf46e84323be1d0aad7d5fe8a5a47
TheBjorn98/nummat_p2
/temptest.py
249
3.65625
4
import numpy as np def f(x): return x[0, :]**2 + x[1, :]**3 def df(x): return np.array([x[0, :]**2, x[1, :]**2]) xs = np.array([ [0, 0.0], [1, 1], [1, 2] ]).T print(xs) print(f(xs)) print(df(xs))
3cb060b63c6c26fcd7a72ae2212a6b913cce266f
daguerre33/Ping-with-sonar-effects
/ping_with_sonar_effect.py
1,825
3.53125
4
#!/usr/bin/python3 #Ping with sonar effect. A submarine feeling under the water of net #For realistic experience, please, use headphones! import os import time from tkinter import * window = Tk() window.title("Ping with sonar effect") window.geometry("300x200+30+50") def submit(): host = host_name.get() return ho...
ad025157acda93edfcd4ce987bb2cdfb4c3b1d78
AmanKishore/CodingChallenges
/Cracking the Coding Interview/Trees and Graphs/BSTSequences.py
1,562
4.0625
4
''' BST Sequences: Enumerate all inserrtion sequences that could have led to the given BST. ''' # BST Sequences: A binary search tree was created by traversing through an array from left to right # and inserting each element. Given a binary search tree with distinct elements, print all possible # arrays that could ...
a544e849b7214973407275a44e6c0a5415a18ad1
bpandola/advent-of-code
/2019/day_01.py
1,115
3.875
4
def calculate_fuel_for_mass(mass): return mass // 3 - 2 def calculate_fuel_for_fuel(fuel_mass): fuel_needed = 0 fuel_for_fuel = calculate_fuel_for_mass(fuel_mass) while fuel_for_fuel > 0: fuel_needed += fuel_for_fuel fuel_for_fuel = calculate_fuel_for_mass(fuel_for_fuel) return fue...
98e296669408816d204ecba87a6d76ce446f1964
zyp19/leetcode1
/树/twice.平衡二叉树.py
1,294
3.828125
4
# Definition for a binary tree node. # 6.11做发现问题:左右子树的深度不超过1,为什么要求最大深度呢,我不明白!!!!原来是树的深度(高度)的定义就是树中结点的最大层数!! # 自顶向下 class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isBalanced(self, root: TreeNode) -> bool: if not root: ...
1bcd687428c5be5e835a3fb604772af2be150d0b
rpuneet/The-Game
/Maze.py
2,339
4
4
''' This class is used to store data about the maze. The matrix contains strings which refer to the image in the tile folder. ''' import pygame import json import os class Maze(): def __init__(self , matrix_data_path): ''' Initialises the maze. Loads the maze information from matr...
a672902062bff65815399258a033c9fa33345d52
LittleEndu/Codeforces
/Python/Unsorted/271a_v2.py
258
3.8125
4
# Smallest: # a=int(input())+1 # while len(set(str(a)))<4: # a+=1 # print(a) # Don't use if inside while loop.... # But, trick here was the +1 to input() so it acts as a "do while" loop b=int(input()) while 1: b+=1 if 4==len(set(str(b))):print(b);break
488404e2e9979f74c43d45a4fe9424b1f3b522c9
ZigaHocevar/ugani_stevilo
/course1.py
306
3.78125
4
num = 1 while num < 10: print(num) num = num + 1 num1 = 25 num2 = 38 num3 = 25 print(num1 == num2) print(num1 == num3) odgovor = "da" while odgovor == "da": odgovor = raw_input("Ali zelis biti v zanki? (da/ne)") while True: print("vstop v zanko") break print("nismo vec v zanki")
844bc36ac71c2f4f18e6203aa7d45b3cdb108690
jpl1991/Machine-Learning
/Python/sort2DArray2.py
482
3.765625
4
def sortMatrix(matrix): row_len = len(matrix) col_len = len(matrix[0]) #temp = [0]*(row_len*col_len) temp = [] for rows in matrix: for col in rows: temp.append(col) temp.sort() k = 0 for i in range(0, row_len): for j in range(0, col_len): matrix[i][j] = temp[k] k+=1 return matrix matrix = [[ ...
bd5c56ad04da056a964a797ce8e4f4c466a4f9fc
Zer0xPoint/LeetCode
/lib/search/binary_search.py
417
3.71875
4
def binary_search(items, start_idx, end_idx, target): while start_idx <= end_idx: mid_idx = start_idx + (end_idx - start_idx) // 2 if items[mid_idx] == target: return mid_idx elif items[mid_idx] < target: start_idx = mid_idx + 1 else: end_idx = mid...
720b9bfb66ee3018802c41b4140769a28756332a
bobur554396/PPII2021Spring
/w3/4_Class.py
131
3.8125
4
# class class MyClass: x = 10 b = 'hello' a = MyClass() # a is object of the class print(a.x) print(a.b) a.x = 20 print(a.x)
071ff16dc734dc642a1891276b5f259acbd1fb3c
acarter881/exercismExercises
/collatz-conjecture/collatz_conjecture.py
341
3.890625
4
def collatz(n): if n % 2 == 0: return n // 2 return 3 * n + 1 def steps(number): if number < 1: raise ValueError('Can\'t use a number less than 1') iter = 0 while number != 1: iter += 1 if collatz(number) == 1: break number = collatz(num...
48163fb16dbf855b626d1501e9b8c41f29133010
MaxGosselin/mpltutorial
/2-legendsTitles.py
875
3.90625
4
#%% [markdown] # # 2 - Legends titles and labels # # Following the matplotlib tutorial by sentdex. # # Link: https://www.youtube.com/watch?v=q7Bo_J8x_dw&list=PLQVvvaa0QuDfefDfXb9Yf0la1fPDKluPF #%% import matplotlib.pyplot as plt #%% # Simple plot with labels and titles x = [1,2,3] y = [5,7,4] plt.plot(x,y) plt.x...
4530cc136b7609ce473ed01c6a885eef747963fa
chrimerss/FloodDetectionUsingSAR
/env/lib/python3.6/site-packages/arcgis/learn/_utils/utils.py
576
4
4
def extract_zipfile(filepath, filename, remove=False): """ Function to extract the contents of a zip file Args: filepath: absolute path to the file directory. filename: name of the zip file to be extracted. remove: default=False, removes the original zip file ...
11d03787bed76c939ece41c927f6cee1a71967a7
Ricky-Millar/100-days-of-python
/etchasketchtutrle/main.py
1,818
4
4
import turtle import matplotlib.pyplot as plt import random board = turtle.Screen() board.colormode(255) width = 500 height = 400 startpos = [] turtleholder = {} board.setup(width = width,height = height) height *= 0.9 numofturtles = int(turtle.textinput('who','how many turtles?')) def randomcolor(): color = [] ...
cafef96daeb2f6656a094cde29c2d5908403b001
Fin-M/Basic-Calculator
/Basic Calculator.py
949
4.28125
4
print("\nThis is a Basic Calculator!") first = float(input("\nWhat is your first number?: ")) second = float(input("What is your second number?: ")) operator = input("What do you want to do with the numbers (multiply, divide, add, subtract or power)?: ") if operator == "multiply": print("\nThe answer is:...
18eb03a6ef45c46aa765d647f12086f51cabd29b
HappyRocky/pythonAI
/ABC/powerseries.py
330
4.0625
4
# 计算幂级数: e^x = 1 + x + x^2/2! + ... + x^n/n! (0 < x < 1, n -> 去穷大) import math x = float(input("Input x(0 < x < 1):")) N = int(input("Input N:")) result = 1 unit = 1 for i in range(1, N): unit = unit * x / i result += unit print("result:{}".format(result)) print("accurate e^x = {}".format(math.exp(x)))
3c07a20c591cf80ba8495afbb65e39c4811e84dd
daniel-reich/ubiquitous-fiesta
/K4aKGbfmzgyNNYEcM_11.py
99
3.515625
4
def is_shape_possible(n, angles): return (n-2)*180==sum(angles) and all(x<180 for x in angles)
a5ca84687e3c832d69bc70fa2537d8b6d3ce5035
aesdeef/advent-of-code-2020
/day_11/seat_part_1.py
1,566
3.921875
4
from functools import cached_property class Seat: collection = {} def __init__(self, x, y): """ Initialises the seat and adds it to the collection """ self.x = x self.y = y self.occupied = False self.occupied_new = False Seat.collection[(self.x,...
8f597486d274f380cef6e6b6b90d9e907ea713e2
reddyprasade/A-Criterion-for-Deciding-the-Number-of-Clusters-in-a-Dataset-Based-on-Data-Depth
/Elbow_Method.py
1,039
4.125
4
""" It is the most popular method for determining the optimal number of clusters. The method is based on calculating the Within-Cluster-Sum of Squared Errors (WSS) for different number of clusters (k) and selecting the k for which change in WSS first starts to diminish. The idea behind the elbow method is that the ...
2157648b72090b7ad9a61dbe9a22d7df9eef730e
jokly/Biometric-AccessCode
/DataHandler/Reader.py
2,003
3.515625
4
""" Module for reading input files """ import re import os def read_matrix_files(files_path, n_el, m_com): """Read files and convert to list of float matrixes """ out = [] for f_path in files_path: if os.stat(f_path).st_size != 0: out.append(read_matrix_file(f_path, n_el, m_com)) ...
b0cbb3e8ee17a16bb117c0be8da96e2254d4e1d5
mlumsden001/University-Notes
/INFO1110/functions/max.py
176
3.53125
4
num = [1, 5, 3, 8, 9 ,12, 420] def funct(num): if len(num) > 0: return max(num) elif len(num) == 0: return None num = [] funct(num) print(funct(num))
65ef73724bd75bd6c2ebdac0cff3739ad4c2575a
Anjitha-mundanmani/ERP
/team.py
1,934
3.625
4
import employee as em teams = {} def manage_all_team_menu(): print("\t1.Create Team") print("\t2.Display Team") print("\t3.Manage Team(Particular)") print("\t4.Delete Team") print("\t5.Exit") def create_team(): team_name = input("\tEnter team name ") teams[team_name] = [] def delete_team(): team_name = inp...
b4862f244015e0b36793057f1f66a41e3c2c53d2
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/omrkha003/question1.py
695
4.28125
4
# program with a recursive function to determine if a string is a palindrome # khadeejah omar # 4 May 2014 def palindrome(string) : # base case if string == "" or len(string) == 1: return ("Palindrome!") # recursive step else: if string[0] == string[-1] : ...
b671981e4bb111d373cf91c49ddbb9ac979396dd
hutonahill/python-sjcc
/Evan Project/PythonChat.py
8,338
3.78125
4
def delete(): running = True while running == True: test = raw_input('Runing This Command Will Deleate ALL Posts, And Is Irreversible. Are You Sure You Want To Do This?(y/n): ') if test != 'n'and test != 'y': print "That Is Not A Valid Answer Please Answer 'y' Or 'n'" ...