blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
f6dae67f120d4f1b9a677d12445ad851c69b5158
ychang0821/tlg_learning_test
/tuple_practice.py
631
3.765625
4
import time tuple_record = ('eth0', 'AA:BB:CC:DD:11:22', '192.168.0.1', '5060', 'UDP') print(tuple_record) print(tuple_record * 2) print(tuple_record[0:2]) print(tuple_record[1]) records = ['eth0', 'AA:BB:CC:DD:11:22', '192.168.0.1', '5060', 'UDP'] # list is mutable, tuple is immutable #tuple_record. #records. ...
b59ae61f83d2e8b33896251441d9ff3cba8d37ef
Gazizova/smallPythonProgramms
/small_calc_apps/small_calc.py
2,743
4.1875
4
# 1.12 - 2 a = int(input("enter the number")) if ((-15) < a <= 12) or (14 < a < 17) or (a >= 19): print(True) else: print(False) # 1.12 - 3 a = float(input("Input first value")) b = float(input("Input second value")) c = str(input("Input one of operations:'+', '-', '/', 'mod', 'div', 'pow' ")) def calc(): ...
b2f292863698ef4c3c28ff681fa6cf0773ece25f
lozdan/oj
/HakerRank/algorithms/implementation/kangaroo.py
430
3.515625
4
# author: Daniel Lozano # source: HackerRank ( https://www.hackerrank.com ) # problem name: Algorithms: Implementation: Kangaroo # problem url: https://www.hackerrank.com/challenges/kangaroo/problem # date: 8/10/2017 x1, v1, x2, v2 = [int(x) for x in input().split()] if v1 > v2: while x1 < x2: x1 += v1 ...
77bb6e755479e7585c38d0f10a9af609e8903e32
remon/pythonCodes
/Functions/lambda_en.py
116
3.96875
4
#what is the output of this code? gun = lambda x:x*x data = 1 for i in range(1,3): data+=gun(i) print(gun(data))
4042b2b1fd6ef6652ca7cf655e1179c6e89d6144
tashakim/puzzles_python
/assignCookies.py
1,204
3.640625
4
import heapq class Solution: def findContentChildren(self, g, s): """ Purpose: Given greed factor g[i] of each child, returns the max. number of children that are content after distributing cookies of size s[i]. Note: A child is content if they eat a cookie that has size greater tha...
3829f3c7d57756dc054e8af387463262701fe29b
Jriosv/Roya-Prediction-Tree
/primera_interface.py
318
3.53125
4
from tkinter import * raiz = Tk() raiz.title("Calculador de roya") raiz.config(bg="chocolate3") myFrame = Frame() myFrame.pack(fill="both",expand="True") myFrame.config(bg = "tan1") myFrame.config(width="650",height="350") myFrame.config(bd=35) myFrame.config(relief="groove") print("Hola mundo") raiz.mainloop()
43df5de1ebbfd1417292fef82cfbc70c82c4f94c
muyisanshuiliang/python
/wrapper/ernary_expression.py
224
4.0625
4
# res = 条件成立的返回值 if 条件 else 条件不成立的返回值 res = 1111 if 1 > 2 else 2222 print(res) # expression for item1 in iterable1 if condition1 list = [x * x for x in range(3) if x >= 2] print(list)
6d8d0604548f790e7712bf7b61092dea724749cd
MytnikAA/fibonacci
/fib.py
446
4.15625
4
#!/usr/bin/python3 import sys def fibRec(n): if n < 2: return n else: return fibRec(n - 1) + fibRec(n - 2) def fibIter(n): prv = 0; nxt = 1; for i in range(1, n): cur = prv + nxt prv = nxt nxt = cur return nxt n = int(sys.argv[1]) method = sys.argv[2] fibonacci = 0 if method == "i":...
f9b5b176ff1f2fc4b44fadcf1acf72f9a8e4d8bc
Kallehz/Python
/Próf1/FilterAndSum.py
802
3.71875
4
# Write a function filter_sum(lis) that takes a list of integers as an argument. # The function returns a pair (2-tuple). The second element of the tuple are the # elements of the list lis where all the integers smaller than 10 and larger than # 95 have been removed. The first element of the tuple is the sum of the ele...
cea0801b2efcdb817869d44cacab85622a05c87a
bryrodri/Proyecto_python_1_b
/modulos/lista_vacias.py
168
3.765625
4
def is_empty(data_structure): if data_structure: #print("No está vacía") return False else: #print("Está vacía") return True
ed96447d5a704a5e300645ad67ace742199e590f
nataliakusmirek/CS50x---Portfolio
/pset6/mario/mario.py
214
3.890625
4
from cs50 import get_int height = get_int("Height: ") while height > 8 or height < 1: height = get_int("Height: ") # create the spaces for i in range(height): print(" " * (height - i - 1) + "#" * (i + 1))
92655503969fbfd7ea46939131ad19356b6e0ffe
LauraIsCool/Practicals
/agentframework6.py
795
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 17 15:40:22 2019 @author: laurapemberton """ import random class Agent(): def __init__(self, environment): self.x = random.randint(0,99) self.y = random.randint(0,99) self.environment = environment self.st...
f5a96640f2f7f43b1b73a75326be40d410529892
OohGitEm/sql-dice
/flasksql/rolltide.py
358
3.59375
4
import random def roll_dice(num_of_dice, num_of_sides): dice_rolls = {roll+1: 0 for roll in range(num_of_sides)} for i in range(num_of_dice): roll = random.randint(1, num_of_sides) dice_rolls[roll] += 1 return dice_rolls if __name__== "__main__": rolls = roll_dice(1000, 16) print(r...
469bb511f5090cf6919d3935e2dd1245e5935436
nancydemir/Hackerrank
/hackerDay2.py
518
3.6875
4
import math import os import random import re import sys def solve(meal_cost, tip_percent, tax_percent): sub_total = meal_cost * (tax_percent * 1/100) with_tip = meal_cost * (tip_percent * 1/100) total_bill = round(sub_total + meal_cost + with_tip) print(total_bill) def main(): ...
c6ade0ee62489eabf89ec6d9dc1e7fe21f7a0923
jamarflowers/dazn-interview
/2.PYTHON/declarations.py
304
4.0625
4
variable = 89 variableTwo = 0 while variable > variableTwo: variableTwo = variableTwo + 1 print variableTwo if(variableTwo % 3 == 0): print("FIZZ") elif(variableTwo % 5 == 0): print("BUZZ") if variable % 3 == 0 or variableTwo % 5 == 0: print("FIZZBUZZ")
678747ee16eb3fddaeed2381923fa624e0fa2467
carter144/Leetcode-Problems
/problems/994.py
3,197
3.8125
4
""" 994. Rotting Oranges In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the ...
f7c8411d1ca9cf0799481db2690a4b8f2bf895d2
emeric75/uvsq_licence
/BI423/TD1/aire.py
391
3.859375
4
print "Calculer l'aire d'une figure" choix = raw_input("Rectangle(R)/Triangle(T) ? ") if choix == 'R': lo = input("Quelle est sa longueur ? ") la = input("Quelle est sa largeur ? ") print "Aire du rectangle : ", lo*la elif choix == 'T': b = input("Quelle est sa base ? ") h = input("Quelle est sa hauteur ? ") prin...
36a84b11d45324cfab08a36faa9f545dff9da4bb
Mitchell-boop/gaphor
/gaphor/misc/rattr.py
1,227
3.953125
4
"""Recursive attribute access functions.""" def rgetattr(obj, attr): """ Get named attribute from an object, i.e. getattr(obj, 'a.a') is equivalent to ``obj.a.a''. - obj: object - attr: attribute name(s) >>> class A: pass >>> a = A() >>> a.a = A() >>> a.a.a = 1 >>> rgetatt...
1df1fa1dc3b1088127701ed55a50ce33fb44fdb3
tabletenniser/leetcode
/689_maximum_sum_of_3_non_overlapping_subarrays.py
988
4.125
4
''' In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we want to maximize the sum of all 3*k entries. Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answ...
2870fae10418d3e4d0bf8be52d99661d0393cc11
sirajmuneer123/anand_python_problems
/5_chapter/p7.py
521
3.78125
4
''' Write a program split.py, that takes an integer n and a filename as command line arguments and splits the file into multiple small files with each having n lines. ''' import sys def split(n,filename): i=0 n=int(n) f=open(filename) lines=f.read().split('\n') for line in range(0,len(lines),n): new_line=...
10406219e58ea4c4bcfbcb0aa338e9173838ebb9
stefsiekman/aoc2019
/06/first.py
1,440
3.859375
4
import aoc.input from queue import Queue class Planet: def __init__(self, name, parent=None): self.name = name self.parent = parent self.children = [] def create_planet(planets, name): if name in planets: return planets[name] else: p = Planet(name) planets...
8ad2a9c1a03c8b58255c9924d6ca6c46044269b0
wentilin/algorithms-study
/python/interview/回文/回文数.py
1,463
4.3125
4
""" 9. 回文数 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 示例 3: 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 进阶: 你能不将整数转为字符串来解决这个问题吗? """ # 1 class Solution: # 方法:负数或者结尾为0的数字都不是回文;然后对整数后面一半的数字进行颠倒,看是不是和前面一半相同 ...
84da1a824d1b8e8ddd2b70bb0fdff0447d41208e
N02775223/ELSpring2017
/code/logTemperature.py
986
3.625
4
#!/usr/bin/python import os import time import sqlite3 as mydb import sys """ Log Current Time, Temperature in Celsius and Fahrenheit Returns a list [time, tempC, tempF] """ def readTemp(): tempfile = open("/sys/bus/w1/devices/28-00044a3b10ff/w1_slave") tempfile_text = tempfile.read() currentTime=time.st...
e7324e66da8f249f25f3dd8ea857d85a8939df7b
Lennysky/Python
/my_progs/findsymb.py
928
4.25
4
str1 = 'Hello, World! This is me again!' index = str1.find('This') print(index) index = str1.find('again') print(index) #Искать с определенной позиции: index = str1.find('m', str1.find('This'), str1.find('again')) print(index) # Проверить, начинается ли наша строка с этой подстроки yesno = str1.startswith("Hello") ...
7b738f0cb73ecdd57d9ee7d2c2c52cd1cdbb6a56
4Noyis/Python
/Python/Kullanici_Girisi_2.py
790
3.6875
4
print(""" *********************** Kullanıcı Giriş Paneli *********************** """) sys_kullanici= "noyis" sys_sifre="123" Giris_Hakki=3 while True: Id=input("Kullanıcı Adını Girin: ") sifre=input("Sifrenizi girin: ") if(Id != sys_kullanici and sifre==sys_sifre): print("Kulla...
869e11a920196831f11abfed1a447265fb76f703
here0009/LeetCode
/Python/MaximumLevelSumofaBinaryTree.py
1,384
3.953125
4
""" 1161. Maximum Level Sum of a Binary Tree User Accepted:2594 User Tried:2667 Total Accepted:2633 Total Submissions:3626 Difficulty:Medium Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes a...
81d2927ffdef01b7a80d16c3785a0e63e45879c6
rajeshsvv/Lenovo_Back
/1 PYTHON/0 CODECAMP/16 If statement or.py
137
3.9375
4
is_male=False is_tall=False if is_male or is_tall: print("You are male or tall or both") else: print("You neither male or tall")
47a1e0aa86ab54674c468a7430a995a04cc07d1a
maiconsaraiva/estudos_python
/decorators/decoradores.py
2,336
4.09375
4
""" Decoradores (Decorators) O que são? - Decorators são funções; - Decorators envolvem outras funções, e aprimoram seus comportamentos; - Decorators também são exemplos de HOF (Higher Order Functions); - Decorators tem uma sintaxe própria, usando o "@" (Syntax Sugar / Açucar Sintático) - Não confunda Decorators co...
53c5d149f884a8230316602815dee948b03fdee2
kevivforever/pythonWorkspace
/derek banas/exceptions.py
479
3.5
4
import exceptions class Dog: __secret = 2 def main(): #raise Exception('JustDisagreeable') for i in dir(exceptions): print i try: zeroDivision = notHere/0 except (NameError,ZeroDivisionError), e: print "You can't divide by zero" print e else: print...
baa843b91b62162dfdbdd12b3f7cca6b2174be65
SilverMaple/LeetCode
/4.median-of-two-sorted-arrays.py
1,524
3.71875
4
# # @lc app=leetcode id=4 lang=python # # [4] Median of Two Sorted Arrays # # https://leetcode.com/problems/median-of-two-sorted-arrays/description/ # # algorithms # Hard (25.64%) # Total Accepted: 391.3K # Total Submissions: 1.5M # Testcase Example: '[1,3]\n[2]' # # There are two sorted arrays nums1 and nums2 of s...
b3de59228d5c1d0f878536d85c3e7d9b32c5b87d
liuqun/py
/可爱的Python/cdctools.py
197
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import os def ListFileSystemTree(dir): tree = "" for root, dirs, files in os.walk(dir): tree += ("%s;%s;%s\n" % (root, dirs, files)) print(tree)
e7cbd486b090698d66acebf28f5f6725cf5c7d1d
matthewfowles/python-course
/caser.py
631
4.03125
4
#!/usr/bin/python3 # # A Truly Awesome Program # caser.py # # by: Matthew Fowles # # def capital(e) : return e.capitalize(); def titilate(e) : return e.title() def up(e) : return e.upper() def down(e) : return e.lower() def exit(e): return 'Goodbye for now!' matrix = { "capitalize": capital, "tit...
bf3cd4bdac42b8720c0e13a5670e96e68c1e32da
AmilaSamith/snippets
/Python-data-science/for_loop.py
1,162
4.40625
4
# For-loop condition """ for-loop -------------------------------- for (iter) in (iterable): (code to be executed while have iter in iterable) """ for num in [1,2,3,4]: print(num) # range() function """ range(start*,stop,step*) - * optional params """ for num in range(2,10,2): print(...
c0baa889c7c76925973d64d652fbfb3e71ce6eed
Busymeng/MyPython
/ClassNote/08_Set_Student.py
4,723
3.640625
4
################################################################ ## Sets ################################################################ ################################################################ ## Essential ideas about set """ * Two interesting features of a set - You can store only one examp...
81d322872b53934afacb6d5abf7656e57bcae833
chenxu0602/LeetCode
/1862.sum-of-floored-pairs.py
1,506
3.734375
4
# # @lc app=leetcode id=1862 lang=python3 # # [1862] Sum of Floored Pairs # # https://leetcode.com/problems/sum-of-floored-pairs/description/ # # algorithms # Hard (27.19%) # Likes: 188 # Dislikes: 19 # Total Accepted: 4.1K # Total Submissions: 15K # Testcase Example: '[2,5,9]' # # Given an integer array nums, r...
ee627d8ea17043da565e6bc293e511c46e1e9b08
hector-han/leetcode
/dp/prob0122.py
1,402
3.671875
4
""" 122. 买卖股票的最佳时机 II easy 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 输入: [7,1,5,3,6,4] 输出: 7 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5-1 = 4 。   随后,在第 4 天(股票价格 = 3)的时候买入,在第 5 天(股票价格 = 6)的时候卖出, 这笔交易所能获得利润 = 6-3 ...
bd25e46030449c6207dcae1d6cfe5d66210232fc
TehraniZadehAli/Python
/ChangeVars.py
416
4.25
4
#Define a function for changing value of two variables def changevar(a,b): a = a + b #Assign a+b to a b = a - b #Assign a-b to b a = a -b #Assign a-b to a print("a2 is : " ,a) #Printing new value for a print("b2 is : " ,b) #Printing new value for b a = int(input("a")) #Getting numb...
9bf9436abd3c99293b3182acb225f6ed6850f2ac
DT021/data_structures_and_algorithms
/basic_algorithms/euclid_gcd.py
185
3.796875
4
def gcd(a, b): rem = a % b while(rem != 0): a = b b = rem rem = a%b return b print(gcd(20,8)) print(gcd(36,14)) print(gcd(99,11)) print(gcd(173,57))
7287d3c7e9b5724b15b5025eb19a7e5a727b8f55
johnsonjosev/Algorithmic_Toolbox
/Assignment_bootstrap/week3_greedy_algorithms/6_maximum_number_of_prizes/different_summands.py
1,018
4.0625
4
# Uses python3 import sys def total_sum_of_ascending_series(k): # series_sum = 1 + 2 + ... + k = k * ( k + 1) /2 # this must be a integer, so we adopt integer division here. series_sum = k*(k+1)//2 return series_sum def optimal_summands(n): summands = [] #write your code here upper_bo...
094667162c817261f4a96f2b508a73822da979a3
aitutor22/tetris
/test.py
3,242
3.65625
4
from blocks import Block from tetris import * board = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, ...
2f9ab52a9697cb5f363239410062f99d644a7581
Sebas1130/Python_Ejemplos
/proyecto5/node_based_queue.py
1,235
4.03125
4
class TwoWayNode(): def __init__(self,data=None,next=None,previous=None) -> None: self.data = data self.next = next self.previous = previous class Queue: def __init__(self) -> None: self.head = None self.tail = None self.count = 0 def enqueue(self, data)...
fd874e235234ea4374088cca253d328fcca60d5d
ZU3AIR/DCU
/Year2/ca268Labs/Revision/recursive_sum.py
116
3.671875
4
def sumto(a, b): if int(a) == int(b): return a else: return a + (sumto((a + 1), b)) print(sumto(4, 10))
56a0bf355f4259157ca4260be0cef75c4c3c7899
thonyeh/Numerical-analysis-2
/crank-nicolson k=0.001, h=0.1 (r=0.1).py
2,302
3.640625
4
from math import * from time import sleep from Tkinter import * from numpy import * import matplotlib.pyplot as plt def matriz(n,m):#DEFINA LA MATRIZ M=[] for i in range(n): M.append([float(0)]*m) return M def vector(n): #DEFINE EL VECTOR v=[] for i in range(n): v.append(float(0)) ...
8040ab7d28731a80dc03f0fd8b837086b81e5b04
Yang-Jianxing/-
/第三题.py
241
3.78125
4
#第三题 print("根据够的年龄算出您的大概年龄") a = input("请输入您的狗的年龄:") a = float(a) if 0<a<=2: print(a*10.5) elif a>2: print(21+(a-2)*4) elif a<=0: print("您输入的数字有误!")
82989f4ca6425fd1775ce7a351bb8097e28860f6
JSitter/Tweet-Generator
/rearrange.py
260
3.734375
4
import sys from random import randint def randomize_words(words): #create a set words = set() while (len(words) != len(sys.argv)-1): randomNum = randint(1, len(sys.argv)-1) words.add(sys.argv[randomNum]) print(" ".join(words))
67c55f2fb7453b74f7e8422ba5e68af062ea113f
iamyoona/sparta_algorithm
/week_1/homework/02_find_count_to_turn_out_to_all_zero_or_all_one.py
381
3.75
4
input = "011110" def find_count_to_turn_out_to_all_zero_or_all_one(string): temp_array = [string[0]] for i in range(1, len(string)): if string[i] != string[i-1]: temp_array.append(string[i]) result = min(temp_array.count('0'), temp_array.count('1')) return result result = find_...
e066d7dcc822eb7e5cea0c19de70cd536339e4bb
zpoint/Reading-Exercises-Notes
/core_python_programming/8/8-8.py
159
4.0625
4
def Factorial(num): N = 1 for i in range(1,num+1): N *= i return N print Factorial(int(raw_input('Please enter a number to N!:\n')))
d8fe35d411f2414b46368447967b1184ce6c606a
DikshaRai1/FST-M1
/Python/Activities/Activity9.py
584
4.1875
4
#Given a two list of numbers create a new list such that new list should contain only odd numbers from the first list and even numbers from the second list. list1=[1,2,3,4] list2=[6,7,8,9] list3=[] for number in list1: #Adding odd numbers from list1 to list3 if (number%2)!...
e8920df89ecc7c0d3c88874720b87f899ae26256
Thaistav/introduction-to-python
/list_01/exp05.py
174
4.21875
4
#Faça um Programa que converta metros para centímetros. m=float(input('Digite a medidade em metros ')) c=m*100 print('O valor corresponde a {} centimentros'.format(c))
8bfe1acc2011d3966ea68c72c3728a770b7a486d
malachyenglish1/selwood-python
/practice-exercises/exponent.py
163
3.5625
4
b_input = float(input("Enter a base: ")) exp_input = float(input("Enter an exponent: ")) print(f"{b_input} to the power of {exp_input} = ", b_input ** exp_input)
c6ea18bc92a31d272a07c6015536adcd46a7d555
tommaso1311/sNNake
/src/food.py
195
3.546875
4
import numpy as np class food: def __init__(self): """ Class used to create food Attributes ---------- position : array position of food """ self.position = np.array([0, 0])
1d4b3a95d87ed91c06f8c5f01c3d26faf7735c0d
lishuchen/Algorithms
/lintcode/96_Partition_List.py
849
4.15625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The first node of linked list. @param x: an integer @return: a ListNode ""...
85c46d8edef63c48b396d47ae09bcb5f657b78d6
gomesfilipe/curso-em-video-python
/ex014.py
144
3.90625
4
celsius = float(input('Temperatura em °C ')) farenheit = 9 * celsius / 5 + 32 print('Temperatura em farenheit: {:.2f} °F'. format(farenheit))
598de55612f90f476e8cdbb631942995067e9387
aastronautss/programming-exercises
/210-small-problems/easy_2.py
2,589
3.8125
4
import random import re import math from functools import reduce # Ddaaiillyy ddoouubbllee def crunch(string): new_string = '' for idx, char in enumerate(string): if idx == 0 or char != string[idx - 1]: new_string += char return new_string # Bannerizer def print_in_box(string): l...
60271a82d5bcf3aecbd82eec5fb651ed460bee26
chuanyedadiao/Python-Practice
/course/11/test_cities.py
432
3.71875
4
import unittest from city_functions import city_combine class CityTestCase(unittest.TestCase): def test_city_country(self): city_nation = city_combine('changde','china') self.assertEqual(city_nation,'Changde,China') def test_city_country_population(self): city_nation = city_combine('ch...
2363650a0a177b169836645dbba27c189bb474c5
synerjay/arithmetic-formatter
/arithmetic_arranger.py
2,493
3.890625
4
import re # import regex for checks # Input is arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]) # Output is # 32 3801 45 123 # + 698 - 2 + 43 + 49 # ----- ------ ---- ----- def arithmetic_arranger(problems, solve = False): #First make variables to m...
b9da0f24d9a23354c8fad9083653decd344c2b76
RRoundTable/CPPS
/DP/Combination_Sum_III.py
1,688
3.8125
4
''' link: https://leetcode.com/problems/combination-sum-iii/ Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number is used at most once. Return a list of all possible valid combinations. The list must not contain the same c...
6c50549858a7433dad4f2294958d2f9a0f5f01be
lichengchengchloe/leetcodePracticePy
/ReverseInteger.py
744
3.828125
4
# -*- coding: UTF-8 -*- # https://leetcode-cn.com/problems/reverse-integer/ def reverse(x): """ :type x: int :rtype: int """ res = 0 while x!=0: # Python3 的取模运算在 x 为负数时也会返回 [0, 9) 以内的结果,因此这里需要进行特殊判断 tmp = x%10 if x<0 and tmp>0: tmp = tmp-10 # 同理,Pytho...
eba3269d3ccf99ab63199764671f57a18f7928b2
elsayed-issa/2021-task1
/evaluation/evallib.py
666
3.59375
4
"""Evaluation functions for sequence models.""" from typing import Iterator, List, Tuple Labels = List[str] def wer(correct: int, incorrect: int) -> float: """Computes WER.""" return 100 * incorrect / (correct + incorrect) def tsv_reader(path: str) -> Iterator[Tuple[Labels, Labels]]: """Reads pairs o...
8825e74e03b84d848a79074066116d004816825d
CMSTrackerDPG/TkDQMDoctor
/utilities/luminosity.py
894
3.515625
4
from decimal import Decimal from utilities.manip import strip_trailing_zeros def format_integrated_luminosity(int_luminosity): """ Example: >>> format_integrated_luminosity(Decimal("0.000000266922")) '0.267 µb⁻¹' >>> format_integrated_luminosity(Decimal("1.12345678901234567890")) '1.123 pb⁻¹'...
ffd6cdd51431b4cbf79a0be1e24b73e717cb633f
fredmorcos/attic
/Projects/PlantMaker/archive/20100420/plant.py
3,587
3.734375
4
""" This module provides the Plant and Machine classes. CraneMoveTime is the time a crane takes from one Machine to another in the Plant. """ from xml.dom import minidom from extra import * CraneMoveTime = 1 class Machine(object): """ Provides the implementation of a Machine in a Plant. """ def __init__(self, na...
4e24ecda8559a40f93c55ac55a4f9a8993db81e9
sai-byui/NEO2D
/pathfinder.py
9,070
3.8125
4
from agent import Agent class Pathfinder(Agent): """uses the A* path finding algorithm to determine the red_ai_pilot's movement""" def __init__(self): """sets up path finding variables for use in the A* algorithm""" super(Pathfinder, self).__init__("pathfinder") # nodes which we know ...
48fa7cb8660abf6d164d4f0978001b235c847f78
hg-pyun/hello-python
/02-2 문자열 자료형.py
1,199
4.0625
4
# 파이썬에서는 ', ", ''', """을 사용해서 문자열을 나타낼 수 있음 food = "Python's favorte food is perl" print(food); multiLine = ''' This is linebreak You use this! ''' print(multiLine) # 문자열 더하기 head = "Python" tail = " is Fun!" print(head + tail) # 문자열 곱하기 multiple = "multi" print(multiple*2) # 문자열 곱하기 응용 print("=" * 50) print("My Pr...
bf43cf9839f2fe09ed5cefe2b2b9e4a41edd1b0e
arjun-krishna1/leetcode-grind
/groupAnagrams.py
2,770
3.796875
4
class Solution(object): ''' GIVEN INPUT strs: array of strings OUTPUT group the anagrams together anagram: word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once BRUTE FORCE iterate th...
bfcaf30207c01a7fbad2fa11e2cad9296131bdaa
noozip2241993/learning-python
/csulb-is-640/deitel-text/exercises/ch05/ex517.py
3,651
4.34375
4
''' 5.17 (Filter/Map Performance) With regard to the following code: numbers = [10, 3, 7, 1, 9, 4, 2, 8, 5, 6] list(map(lambda x: x ** 2, filter(lambda x: x % 2 != 0, numbers))) a) How many times does the filter operation call its lambda argument? b) How many times does the map operation call its l...
bf95241d5175ada9f398c26d93fe563652a447a8
kwappa/gothe_python
/Chapter07/human_sato.py
477
3.78125
4
class Human: age = 0 # 年齢 lastname = '' # 名前 firstname = '' # 苗字 height = 0.0 # 身長 weight = 0.0 # 体重 sato = Human() sato.age = 35 sato.lastname = '佐藤' sato.firstname = '次郎' sato.height = 174.1 sato.weight = ...
d7c75e35deab8a720d8de756e625041f22d34fd7
ujjwalkar0/Python-Socket-Programming
/Tutorial/server1.py
1,032
3.75
4
import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #AF_INET = ipv4, Stock_stream = tcp s.bind((socket.gethostname(),1235)) # 1234 --> PORT Number ## The bind() method of Python's socket class assigns an IP address and a port number to a socket instance. The bind() method is used when a socket needs t...
0f3407d8461151023a3bf78c1148a484b5f55192
arnoldvaz27/PythonAssignments
/Piazza/NextDayofDate.py
891
3.953125
4
""" Question - Write a Python program to get next day of a given date. """ # Code - year = int(input("Input a year: ")) if year % 400 == 0: leap_year = True elif year % 100 == 0: leap_year = False elif year % 4 == 0: leap_year = True else: leap_year = False month = int(input("Input a month [1-12]...
de5ca7e7069eb50ad8846f48a6070cfed2eecef3
sungly/nrf
/node.py
1,125
3.53125
4
from random import * from math import * ''' Tree Node - each node has an associated weight Author: Ly Sung Date: March 23rd 2019 ''' class Node(): value = -1 parent = None index = 999999 def __init__(self, parent = None, left = None, right = None, bla=0): self.left = left self.rig...
d5c12a078af891af91004f18db2de312af187714
Podakov4/pyCharm
/module_8/lesson_2.py
334
4.03125
4
# Задача 2. Сумма нечетных num_stop = int(input('Подсчет суммы закончится на числе: ')) num_summ = 0 for number in range(1, num_stop // 2 * 2 + num_stop % 2 + 1, 2): print(number) num_summ += number print('Сумма всех нечетных чисел равна:', num_summ)
0399957e7b0fb0f5e415abe42f1148a3d439538a
MauroEBordon/anfamaf2020
/codigos/lab1ej4.py
295
3.65625
4
# Este código se ejecuta desde linea de comandos con 'python lib1ej4.py' # Debido a que 0.1 no puede ser representado como una suma finita de potencias de 2, # nunca se cumplira la condicion del while y vamos a tener que frenarlo con Ctrl + C x = 0 while x != 10: x = x + 0.1 print(x)
5ca1369c482ac04d7fe1944359d2bb7270e4b918
TheodorUngureanu/Advent-of-Code
/2020/day19/day19.py
1,665
3.53125
4
#day 19 # run with python3 import regex from itertools import count def parseRules(rules): rules = rules.splitlines() rulesDictionary = {} for rule in rules: number, values = rule.split(': ') rulesDictionary[number] = values return rulesDictionary def build_regex(ruleKey, pa...
49b5fc21afd64116bd950165263e3bad98937eb2
GustavSvensson3600/decTree
/node.py
843
3.703125
4
class Node: pass class TreeNode(Node): def __init__(self, attribute, label): self.attribute = attribute self.label = label self.children = list() def add_child(self, child): self.children.append(child) def print_deep(self, depth, parent): print (" " * depth)...
a573c107124feb823b59b50d7651c4064e3640f7
kieda/ForcePhysicsSimulator
/PhysicsOld/src/event.py
1,111
3.5
4
import sys import numpy as np class Event: CollisionType, ZeroVelocityType, BoundaryCrossingType = range(3) class Collision: def __init__(self, timeIn, pointIn, manifoldIn): self.type = Event.CollisionType self.time = timeIn self.point = pointIn self.manifold = manifoldIn...
8f248eab9a4360990f9f47e0ce7fe60a0d18725b
sunchigg/JrML
/80_00 • Flask/request.py
454
3.625
4
# -*- coding: utf-8 -*- """可於local端輸入以下: http://127.0.0.1:5000/index?name=test&age=666 Output:hello Flask. ur name=test and age=666 """ from flask import Flask, request app = Flask(__name__) @app.route("/index", methods=["GET", "POST"]) def index(): name = request.args.get("name") age = request.args.get("age...
d03c192c7da76ca2facac8ecb8cc17f6b5f49712
zhanghcqm/python_test
/random/随机红包.py
218
3.609375
4
import random def red_packet(total,num): for i in range(num-1): per=random.uniform(0.01,total/2) total=total- per print('%.2f'% per) else: print('%.2f'% total) red_packet(10,5)
63dbc66eba77b4c61937c408a9ba8520535bca05
helgefmi/moggio
/moggio/state.py
7,987
3.578125
4
import moggio.util as util import moggio.defines as defs import moggio.cache as cache """Includes the State class.""" class State: """Represents the state of a position on the chess board. This class has the variables: pieces - Set of bitboards representing the pieces position on the board....
daf58a32eb3db63105ae3c2bd1f1f6f2d612d4a0
liwb27/leetcode
/786. K-th Smallest Prime Fraction.py
1,955
3.78125
4
# A sorted list A contains 1, plus some number of primes. Then, for every p < q in the list, we consider the fraction p/q. # What is the K-th smallest fraction considered? Return your answer as an array of ints, where answer[0] = p and answer[1] = q. # Examples: # Input: A = [1, 2, 3, 5], K = 3 # Output: [2, 5] # E...
b37ab90d42a85981aca3ee67dea7f9ec73a03de5
NickYxy/LeetCode
/Algorithms/100_Same Tree.py
1,266
3.90625
4
__author__ = 'nickyuan' ''' Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. ''' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # ...
cef652417f12b2fec166bdef44c33c4100549894
Sreenuraj/SoftwareTestingWithPython
/Refresher/decorator.py
800
3.546875
4
import functools def my_decorator(func): @functools.wraps(func) def functions_that_run_func(): print('In decorator') func() print('After the decorator') return functions_that_run_func @my_decorator def my_function(): print('in my function') # my_function() def decorator_wi...
69671cc5d5468d1acc905a7d28f1776110a03e90
h1iba1/PYTHON
/ARRAY/1_array.py
456
4.34375
4
#数组在python里叫列表 #一些简单特性 print(['hi']*4) print(3 in [1,2,3])#元素是否在列表中 #迭代 for x in [1,2,3]: print(x,end=" ") #确定数组长度 print(len([1,2,3])) #python 列表截取与拼接 L=['Google', 'Runoob', 'Taobao'] print(L[2])#输出第三个元素 print(L[-2])#输出从右边起,倒数第二个元素 print(L[1:])#输出第一个元素后面的元素 print(L.append('taobo')) print(L)
045187e7b97053a75dd654aea99e8ac283322d84
JohnDoddy/python_challenges
/6_binary_search.py
701
4.3125
4
# implementing binary search # by John Doddy # our data set data = [1, 2, 3, 4, 5, 6] target_value = int(input("What's the target value: ")) # the binary search algorithm def binary_search(data, target_value): minimum = data[0] maximum = len(data) - 1 while minimum <= maximum: midium = int(maximum...
104eddcf8d98d1ab3458924a50a56e7438323874
camargo800/Python-projetos-PyCharm
/PythonExercicios/ex081.py
841
4.0625
4
#Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, mostre: #A) Quantos números foram digitados. #B) A lista de valores, ordenada de forma decrescente. #C) Se o valor 5 foi digitado e está ou não na lista. valores = [] while True: valores.append(int(input('Digite um número: '))) r...
ed5f9295bef6da71a48bbd7198867c53ccb842a7
DaianaMicena/fiap-exercicios-python
/Exercicios_Python/exercicio27.py
179
3.6875
4
n = str(input('Informe seu nome completo')).strip() nome = n.split() print(f'O primeiro nome é {(nome[0])}') #ultimo = (nome[-1]) print(f'Seu ultimo nome é {(nome[-1])}')
b00314e1ea7bceef4174bfdc00423051bca3d907
Dex4n/algoritmos-python
/02.py
4,689
4.28125
4
'''4) Escreva uma TAD que implemente uma lista circular ordenada duplamente encadeada que armazena em cada nó uma chave inteira e um nome. As seguintes operações abaixo devem ser definidas: a)Buscar um nome dado o valor da chave; b) Inserir um novo elemento na lista mantendo a ordem; c) Remover um elemento da lista; d)...
7cdac124184fe6f1567843292535f0e20eb3ed61
roflmaostc/Euler-Problems
/055.py
1,620
4.03125
4
#!/usr/bin/env python """ If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. Although no one has proved it yet, it is ...
ca619f2d77ec2c0054f66016dd1aec9b20e4b621
cyct123/LeetCode_Solutions
/378.kth-smallest-element-in-a-sorted-matrix.py
1,025
3.640625
4
# # @lc app=leetcode id=378 lang=python3 # # [378] Kth Smallest Element in a Sorted Matrix # # https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/ # # algorithms # Medium (52.05%) # Likes: 1980 # Dislikes: 114 # Total Accepted: 167.2K # Total Submissions: 315.9K # Testcase Example: ...
d93933ccbf53934ee07a5fc5f0d7979ff5804651
ElenaSat/Python2021
/Leccion02/EjercicioRectangulo.py
187
3.75
4
alto= int(input("Proporciona el alto: ")) ancho= int(input("Proporciona el ancho: ")) area=alto*ancho perimetro=(alto + ancho) * 2 print(f'Area: {area}') print(f'Perímetro: {perimetro}')
8e23b9c8fa5c9d7c5f42a5f2999c5df3f7c34d4b
CodeWithSamar/ALL-IN-ONE-CALCULATOR-BY-CodeWithSamar
/@CodewithSamar Calculator.py
2,701
4.25
4
# ALL-IN-ONE-CALCULATOR-BY-CodeWithSamar This is a calculator which will you to do mathematical calculations import math import random import time print("Welcome to one of the most trusted calculator @codewithsamar calculator") def add(number1, number2): return number1 + number2 def subtract(number1, number2): ...
f2ec97f2f9bff634f745e7d77b4f03c71efee974
jannylund/advent-of-code-19
/day04.py
1,362
3.609375
4
from collections import Counter from timeit import default_timer as timer from utils.time import get_time # Check that we are not decreasing. def check_increasing(digit): last = None for i in str(digit): if last is not None and i < last: return False last = i return True # C...
d1194290ac002ed792fb46dca214449090da1a76
Aasthaengg/IBMdataset
/Python_codes/p03631/s140947534.py
48
3.59375
4
s=input() print('Yes' if s[0]==s[-1] else 'No')
5a1ff9503d292698f65de8d6071971d2d1f4a992
bansal6498/ForskTechnologyAssignments
/fizzbuzz.py
863
4.03125
4
# -*- coding: utf-8 -*- """ Created on Thu May 14 14:45:56 2020 @author: bansa """ """ Code Challenge Name: Fizz Buzz Filename: fizzbuzz.py Problem Statement: Write a Python program which iterates the integers from 1 to 50(included). For multiples of three print "Fizz" instead ...
6775fa5fe6219ed370fe6184c812b3329017274c
TT-Bone/guanabara-python
/Exercícios/076.py
1,863
4.09375
4
''' Crie um programa que tenha uma tupla única com nomes de produtos e seus respectivos preços, na sequência. No final, mostre uma listagem de preços organizando os dados em forma tabular. ''' tupla = ('Panquecas', 5.50, 'Waffles', 4.30, 'Ovos e Bacon', 6.30, 'Linguiça e BatataRosti', 7.40, 'Omelete', 4.40, 'Cheese Bur...
536dfab0c6aaaa057f98b0b6fd3c4733533e95bc
TemurKhabibullaev/NewRepForCrapsGame
/Craps.py
1,974
4.09375
4
# Temur Khabibullaev # 10/21/2019 import random import time print('ENTER your balance:') balance = int(input('> ')) print("Good! Let's start! Place how much you bet!") bet = int(input('> ')) total_amount = balance - bet def start(): # Balance print(''' Welcome to Craps Game! The Dice will be rolled!''') ...
308a965ff995e99631be35bf3e1ff59a4efbf147
WasimAlgahlani/Hangman-Game
/main.py
1,039
3.71875
4
import random from pic import hang from words import words lives = 6 chosen_word = random.choice(words) word_len = len(chosen_word) display = [] end = False for _ in range(word_len): display.append("_") print(f"{' '.join(display)}") while not end: letter = input("Guess a letter: ").lower() if...
376b50fd32555c4aea2d914549c475d58ce15c1b
getState/nklcb_algorithm
/Assignment4/BinaryTree_node.py
2,811
4.03125
4
from queue import Queue class Node: def __init__(self, value, left, right): self.value = value self.left = left self.right = right class BinaryTree: def __init__(self, array): node_list = [Node(value, None, None) for value in array] for ind, node in enumerate(node_list)...
d859f935df804211b7214923f9eb534187a8918a
beunick13/cars
/main.py
1,607
4
4
# Программа, которая определяет марку автомобиля q1 = input('Автомобиль из Европы? ') if q1.lower() == 'да': q2 = input('Автомобиль из Германии? ') if q2.lower() == 'да': q3 = input('У автомобиля цветной логотип? ') if q3.lower() == 'да': print('BMW') else: q4 = ...
5722f877782f75048a41796e209cb86c0783805e
Hoan1028/IS340
/IS340_HW10/IS340_HW10_4.py
313
3.96875
4
#Demonstrate the FillInQuestion class from questions import FillInQuestion #create the question and expected answer q = FillInQuestion() q.setText("The inventor of Python was _Guido van Rossum_") #Display the question and obtain user's response q.display() response = input("Your answer: ") print(q.checkAnswer(response...
49cbe43bb29116981d7912b86d48923c9c37a32e
timemerry/fifa19PlayerData
/bestplayer.py
216
3.515625
4
# -*- coding: utf-8 -*- import pandas as pd import numpy as np data = pd.read_csv('data.csv') print (data.loc[[11200,11201,11206,11226,11239],['Name','Age','Overall','Potential','Value']]) #print (data.loc[11206])
1d8525b1c3f22bb2c0bd6b15c7c37f1ada62d28f
Oscar-Oliveira/Python-3
/11_Iterators/B_Iterator.py
757
3.53125
4
""" Iterator """ class RangeAZ: def __init__(self, max): if isinstance(max, int) and 0 < max <= 26: self.current = 65 self.max = self.current + max else: raise ValueError("max parameter must be in [1..26].") def __iter__(self): return self d...