max_stars_repo_path
null
max_stars_repo_name
null
max_stars_count
null
id
null
text
string
score
float64
int_score
int64
from
string
blob_id
string
repo_name
string
path
string
length_bytes
int64
null
null
null
null
# #Linear Search # # def LinearSearch(arr,item): # for i in range(len(arr)): # if arr[i] == item: # print(f"{item} is found at {i+1}") # # return # # LinearSearch([3,2,6,2,2,5,4],4) # Binary Search # def BinarySearch(arr,item): # arr = sorted(arr) # low = 0 # high = len(arr) - ...
4
4
smollm
fe8b655215fac25c5e5415abb638dae0f782e3e5
itspratham/Python-tutorial
/Python_Contents/Sample_Programs/search.py
912
null
null
null
null
""" 1 1 2 2 3 3 4 4 5 4 4 3 3 2 2 1 1 """ h = 1 r = 3 u = 2 s = 1 for i in range(1, 5): for j in range(i): print(" ", end=" ") for k in range(1): print(h, end=" ") for j in range(i + r): print(" ", end=" ") ...
3.703125
4
smollm
b25d185dd0f39175cc14594a62532950dab29afc
itspratham/Python-tutorial
/Python_Contents/data_structures/Pattern_Programming/Pattern_numbers/patterns_of_codes/pattern12.py
852
null
null
null
null
# Union and Intersection of two Linked Lists # class Node: # def __init__(self, data): # self.data = data # self.next = None # # # class LinkedList: # def __init__(self): # self.head = None # #self.last = None # # def append(self, data): # if self.head is None: # ...
4.0625
4
smollm
dd1f937c59390685c9a9911fdcb1546b5b83e595
itspratham/Python-tutorial
/Python_Contents/data_structures/linked_list/Union_and_Intersection_of_two_Linked_Lists.py
1,610
null
null
null
null
class MyClass(object): """def __new__(cls): print("Im created") return cls""" def __init__(self): print("Im in __init__") def __add__(self, a): print("Hello You called the + operator") def __sub__(self, other): print("Hello You called the - operator") def...
4.125
4
smollm
8234544289730059047e5c02cfd03077befeb085
itspratham/Python-tutorial
/Python_Contents/Module and Package/foo_bar.py
547
null
null
null
null
# Reverse the array # def reverse_arr(A, start, end): # while start < end: # A[start], A[end] = A[end], A[start] # start += 1 # end -= 1 # return A # # # arr = [2, 4, 5, 8, 9, 1] # print(reverse_arr(arr, 0, 5)) # def reverseList(A, start, end): # while start < end: # A[star...
4.15625
4
smollm
f8cba057074ddd37bfcef0a9453f8b5b1ba5a9ed
itspratham/Python-tutorial
/Python_Contents/final_450/arrays.py
3,489
null
null
null
null
# Variable Length Argument def sum_of_nat_no(*d): print(type(d)) # Tuple is iterable object. So we are making use of loop sum = 0 i = 0 l = len(d) while True: if i < l: sum += d[i] i = i + 1 else: break return sum print(sum_of_nat_no(1)...
3.625
4
smollm
59c8a778d6a5800352624a8a8b58da29f4437865
itspratham/Python-tutorial
/Python_Contents/Pythonfunctions/while.py
447
null
null
null
null
def print_matrix(matt): for i in matt: print(i) def matrixx(matrix, clockwise): mat = matrix if len(mat) <= 1: return "Matrix is empty" while True: if clockwise == 1: top = 0 left = 0 bottom = len(mat) - 1 right = len(mat) - 1 ...
3.984375
4
smollm
f90f93dcb1872ef5ec2329366ac7ae1afc38c75c
itspratham/Python-tutorial
/Python_Contents/data_structures/Array_Rotation/Rotation_of_matrix.py
3,279
null
null
null
null
# Identity Operator # Compares the memory location a = 10 b = 10 c = a is b print(c) c = a is not b print(c) print(int)
3.6875
4
smollm
b489cf1d4ff647e7fe8dfaf4def9889644884c14
itspratham/Python-tutorial
/Python_Contents/PythonVariables/Identity_OPerator.py
125
null
null
null
null
a = 10 print(type(a)) b = 20.45 print(type(b)) st = "Hello Rajesh" print(type(st)) d = 122312343432234324234 print(type(d)) print("Hello world") print("The variable a=" + str(a) + " b=" + str(b) + " c=" + str(st)) print("The variable a={}, b={}, st={},d={}".format(a, b, st, d)) # In Python a = b = c = d = 100 print("a...
3.578125
4
smollm
16e6174fe9696c2bcc87e08bc5f095040a74f38b
itspratham/Python-tutorial
/Python_Contents/FirstProject/SecondPythonProgram.py
479
null
null
null
null
sort = input("Enter the numbers").split() sort = list(map(int, sort)) import time def mysort(sort): timee = time.time() sort1 = [] while len(sort) != 0: minimum = min(sort) sort1.append(minimum) sort.remove(minimum) timees = time.time() print("the time is {}".format(timees ...
3.75
4
smollm
fdb7799cdce7fa96712af36174448a4da79bdf91
itspratham/Python-tutorial
/Python_Contents/data_structures/sorting/my_sort.py
369
null
null
null
null
def Simple_Merge(C): if len(C) > 1: mid = len(C) // 2 A = C[:mid] B = C[mid:] m = len(A) n = len(B) Simple_Merge(A) Simple_Merge(B) i = j = k = 0 while i < m and j < n: if A[i] < B[j]: C[k] = A[i] i =...
3.65625
4
smollm
64a53106508d96ee13f362b3add6054cbc8b71e4
itspratham/Python-tutorial
/Python_Contents/data_structures/Divide_and_conquer/merge_sort.py
823
null
null
null
null
d = { 'a': [7, 9, 10], 'b': (324, 234, 123), 'c': 6 } print(d.items()) print(type(d.items())) for i, j in d.items(): print(i, j)
3.53125
4
smollm
afb43141e928ff590a54374781d1034e298dfb77
itspratham/Python-tutorial
/Python_Contents/data_structures/Gautam_tutor/Time_Complexity/DictionaryAndListTimeComplexity.py
145
null
null
null
null
# Logical Operators # and, or , not a = 10 b = 20 c = 15 d = 20 # And print(a > 2 and b > 2) # a>2 is true and b>2 is true; True and True = True print(a > 2 and b > 100) # a>2 is true and b>100 is false; True and false = False print(a > 200 and b > 2) # a>200 is false and b>2 is true; False and True = False print(...
4.28125
4
smollm
6096ab3003c73f7eac49ceead6a73521ce6de540
itspratham/Python-tutorial
/Python_Contents/Basic_Operations/LogicalOperators.py
1,003
null
null
null
null
# Python program to print all permutations with # duplicates allowed def toString(List): return ''.join(List) # Function to print permutations of string # This function takes three parameters: # 1. String # 2. Starting index of the string # 3. Ending index of the string. def permute(a, l, r): if l == r: ...
4.3125
4
smollm
8b5ddc7a77a2ee9f83b9af01832fdab4a4c68fb8
itspratham/Python-tutorial
/Python_Contents/data_structures/recursion/prg3.py
1,174
null
null
null
null
v=7 for i in range(7): for j in range(i+1): print("*",end="") for h in range(i+v-1): print(" ",end="") for h in range(i+v+1): print("*",end="") for j in range(i): print(" ",end="") for j in range(i): print(" ",end="") for h in range(i+v): print("*"...
3.984375
4
smollm
f3faf7e3cbbe9bb2a54e05d2eaf9be86339da5f3
itspratham/Python-tutorial
/Python_Contents/data_structures/Pattern_Programming/pattern_images/Code/6.py
459
null
null
null
null
str1 = "Hello" str2 = "World" for i in str1: for j in str2: print(j, end="") print(i)
3.875
4
smollm
d92579268a6bc518f5d6c85c6c067c545a126fcc
itspratham/Python-tutorial
/Python_Contents/Python_Loops/Nested For.py
103
null
null
null
null
# Assigning Value to the variable # Assigning the values integer, float, long a = 10 print(a) print(type(a)) b = 2.5564 print(b) print(type(b)) c = 23233585324334 print(c) print(type(c)) # xyz = 10,54,78 x, y, z = 10, 54, 78 print("x = {}, y={} ,z ={}".format(x, y, z)) print("x=" + str(x) + " y=" + str(y) + " z=...
4.03125
4
smollm
b986228d48a6006e126ab919f76112311914663d
itspratham/Python-tutorial
/Python_Contents/PythonVariables/Assigning_Vales_Variable.py
398
null
null
null
null
l = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] # for _ in range(6): # l.append(list(map(int, input().rstrip().split()))) def rotate(l): new_l = [] b = 0 for _ in range(1, 4): temp = [] a = 2 for _ in range(1, 4): temp.append(l[a][b]) a = a - 1 ...
3.546875
4
smollm
344b39750f881bce185834f310159261a8782839
itspratham/Python-tutorial
/Python_Contents/data_structures/Array_Rotation/Array_Rotation_angle_by_gautam.py
782
null
null
null
null
# Context managers """ with open("Student Name.txt" ,"r") as fo: for line in fo.readlines(): print(line) """ s = """Let's go over what we have. Like any class, there's an __init__() method that sets up the object (in our case, setting the file name to open and the mode to open it in). __enter__() opens a...
4.28125
4
smollm
e20ec6aa7055e4dc8e82eb8a304ae1e092dd92fe
itspratham/Python-tutorial
/Python_Contents/WithOpen/withOpen.py
484
null
null
null
null
""" While Condition: while condition: Statement else: statement else: Statements """ i = 0 while i < 3: j = 0 while j < 3: print(j) j = j + 1 i += 1
4.21875
4
smollm
cf9c8a8e9f8f610e4d6d576adf2bccdbd97fdaa6
itspratham/Python-tutorial
/Python_Contents/Python_Loops/NestedLoop.py
205
null
null
null
null
# -*- coding: utf-8 -*- #opérations nombres b=2**3/33#division exacte print(b) b=2**3//3#partie entière print(b) #opérations chaines de caractères phrase="123456789" print(phrase[2:])#on enlève les 2 premiers caractères print(phrase[:6])#on va jusqu'au 6e caractères (donc on enlève les suivants) plusieursMotsSeparé...
3.5
4
smollm
7c6c758e0852cd93b83285974256571111419eae
loicmidy/formation-python
/2_manipulationDonnéesDeBase/manipulationDonnéesDeBase.py
843
null
null
null
null
# Big O complexity # Average = O(log2(log2(n))) # Pessimistic = O(n) def interpolationSearch(arr, arg): left = 0 right = (len(arr) - 1) while left <= right and arr[left] <= arg <= arr[right]: index = left + int(((float(right - left) / (arr[right] - arr[left])) * (arg - arr[left]))) if arr...
3.78125
4
smollm
61cc42bfd5f53c4331c089c800d2411703ca3692
kuzxnia/algoritms
/computer_science/algoritms/search/interpolationsearch.py
480
null
null
null
null
import math def highly_divisible_triangular_number(end=500): def divisor_generator(n): large_divisors = [] for i in range(1, int(math.sqrt(n) + 1)): if n % i == 0: yield i if i * i != n: large_divisors.append(n / i) for diviso...
3.625
4
smollm
441858a437b0c5219da00ecf6fb132b65377637f
kuzxnia/algoritms
/brain_training/programming_challenges/euler/T012.py
657
null
null
null
null
from functools import reduce def number_letter_counts(): def convert_to_words(number): digits = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 's...
3.703125
4
smollm
0df863a4bb1439aae086332ddadd3a74bf94c4e7
kuzxnia/algoritms
/brain_training/programming_challenges/euler/T017.py
1,140
null
null
null
null
""" Building Skills in Object-Oriented Design V4 Extract sample data from Anscombe's Quartet. """ raw = """\ 10.0 8.04 10.0 9.14 10.0 7.46 8.0 6.58 8.0 6.95 8.0 8.14 8.0 6.77 8.0 5.76 13.0 7.58 13.0 8.74 13.0 12.74 8.0 7.71 9.0 8.81 9.0 8.77 9.0 7.11 8.0 8.84 11.0 8.33 11.0 9.26 11.0 7.81 8.0 8.47 14.0 9.96 14.0 8.10...
3.703125
4
smollm
b94f078ee83753d097d59542b8e3223c5aaf77b9
slott56/building-skills-oo-design-book
/code/sample_data.py
1,036
null
null
null
null
""" Building Skills in Object-Oriented Design V4 Preface Example """ from collections import defaultdict combo = defaultdict(int) for i in range(1, 7): for j in range(1, 7): roll = i + j combo[roll] += 1 for n in range(2, 13): print(f"{n:2d} {combo[n] / 36:6.2%}")
3.59375
4
smollm
b020a7d1f567f3a290feb6a5fbfc9f83b9a1c37b
slott56/building-skills-oo-design-book
/code/preface.py
292
null
null
null
null
""" Building Skills in Object-Oriented Design V4 Wheel Examples """ from typing import List, Any import random Bin = Any class Wheel_RNG: def __init__(self, bins: List[Bin], rng: random.Random=None) -> None: self.bins = bins self.rng = rng or random.Random() def choose(self) -> Bin: ...
3.984375
4
smollm
1ada01b91afd1e37206b5aa91083d2596318b2e7
slott56/building-skills-oo-design-book
/code/wheel_examples.py
550
null
null
null
null
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def lowestCommonAncestor(self, root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: TreeNode ...
3.671875
4
smollm
c229d98969763c378b1702ee2681d788183c658d
trilliwon/LeetCode
/easy/lowest-common-ancestor-of-a-binary-search-tree.py
1,242
null
null
null
null
import queue class Solution: def mergedNode(self, t1, t2): if t1 != None and t2 != None: return TreeNode(t1.val + t2.val) elif t1 != None and t2 == None: return TreeNode(t1.val) elif t2 != None and t1 == None: return TreeNode(t2.val) else: ...
4.0625
4
smollm
f6edd9264c744632c3182e2b189e7661c25ae721
trilliwon/LeetCode
/easy/merge-two-binary-trees.py
1,514
null
null
null
null
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def maxDepth(self, root): """ :type root: Node :rtype: int """ if root == None: return 0 ...
3.59375
4
smollm
373c9432cc05eba54730ba3e067510c6ccfcbd8b
trilliwon/LeetCode
/easy/maximum-depth-of-n-ary-tree.py
712
null
null
null
null
""" # Definition for a QuadTree node. class Node: def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): self.val = val self.isLeaf = isLeaf self.topLeft = topLeft self.topRight = topRight self.bottomLeft = bottomLeft self.bottomRight = bottomRig...
3.53125
4
smollm
4bd6b19bda270e65ce568f7b0c148ee8d887e871
trilliwon/LeetCode
/easy/construct-quad-tree.py
1,202
null
null
null
null
print("Welcome to the Command Line Interface Calculator! The calculator can do some basic operations.") print("For Addition, Press 1.") print("For Subtraction, Press 2.") print("For Multiplication, Press 3.") print("For Divison, Press 4.") print("For Power, Press 5.") print("For Root Power, Press6") x = int(inpu...
4.375
4
smollm
9b7e4a0cfc7c6764d5d0f1cb694914e8875e0b91
kalakucchum/clipycalc
/Calculator.py
1,458
null
null
null
null
import copy import chess import numpy as np class ChessGame: """ Represents a chess environment where a chess game is played Attributes: :ivar chess.Board board: current board state :ivar Winner winner: winner of the game :ivar boolean resigned: whether non-winner resigned ""...
3.6875
4
smollm
91a8acd8880da807f597d09adfd64e2c863aaaaf
songtoan272/AI-Gambit
/alpha_zero_implementation/chess_env.py
6,505
null
null
null
null
# coding: UTF-8 """输出小于100的最大素数""" # Todo:素数——除了1和它本身以外不再有其他因数 ,且是大于1的自然数 def get_max_prime_num(low: int, high: int): """ 获取范围low~high之间的最大素数 :param low: 范围最小值 :param high: 范围最大值 :return: max_num:int 最大素数 """ assert low < high assert low > 1 for value in range(high, l...
4.03125
4
smollm
dfc63a55294883a07fbaa0bc29a0bd57181dacc0
yujunjiex/20days-SuZhou
/day01/task04.py
901
null
null
null
null
# coding: UTF-8 """ 给定数字 0-9 各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意 0 不能做首位)。 例如:给定两个 0,两个 1,三个 5,一个 8,我们得到的最小的数就是 10015558。 现给定数字,请编写程序输出能够组成的最小的数。 输入格式: 输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0、数字 1、……数字 9 的个数。整数间用一个空格分隔。 10 个数字的总个数不超过 50,且至少拥有 1 个非 0 的数字。 输出格式: 在一行中输出能够组成的最小的数。 输入样例: 2 2 0 0 0 3 0 0...
3.5625
4
smollm
fd21e134f0a4ef5d2a0f50d72edd479ecd48a5fe
yujunjiex/20days-SuZhou
/day03/task05.py
1,842
null
null
null
null
import sys print(sys.argv) print("+"*50) print(len(sys.argv)) ////////////////////////////////////////////////////////////////////////////// """ Eğer, yazdığınız bir programda, programınızın çalıştığı sistemdeki Python’ın çalıştırılabilir dosyasının adını ve yolunu öğrenmeniz gerekirse bu niteliği kullanabilirsi...
3.78125
4
smollm
9cb7508de643d0ca6cc828011129ed20efe2e1eb
emertoglu/sys-Modulu
/sys modulleri.py
1,292
null
null
null
null
# simultaneous assignment a, b = 1, 2 c = (3, 4) d, e = c def my_func(): return 1, 2, 3 tup = my_func x, y, z = my_func() # Handy functions: # .upper() - uppercases a string # .lower() - lowercases a string # .title() - titlecases a string # There is no function to reverse a string. # Maybe you can do it wi...
4.15625
4
smollm
324fa34355ebf49debb13fec414fcb358efc7c7c
un1xer/python-exercises
/tuples.py
1,629
null
null
null
null
# Write a script that takes for a word (or list of words), # removes all of the vowels, and gives the word (or words) back. # For example, if I give the script the word "Treehouse", # I should get back "Trhs". chars = ['A','E','I','O','U','a','e','i','o','u'] def remove_char(char_list): for item in char_list: ...
4.34375
4
smollm
3fe1f461b520b6dd1e9ecdaeedac538ef5f49d1f
un1xer/python-exercises
/vowel.py
677
null
null
null
null
def getMean(l): return(sum(l)/len(l)) from collections import defaultdict def solution(A): avgDict = defaultdict(int) for startPos in range(len(A)-1): if len(A) > 3 and startPos != len(A)-2: if A[startPos+2] <= A[startPos] and A[startPos+2] <= A[startPos+1]: avgDict[sta...
3.625
4
smollm
e4519aec5e6fb7bc219004b8b5b408002ce66b12
tshihui/pypaya
/codility_practices/minAvgSlice.py
693
null
null
null
null
####################### ## Codility Lesson 6 ## ####################### def checkTrio(Atrio): """ To check if 3 numbers satisfy triangle property """ if (Atrio[0] + Atrio[1] > Atrio[2] and Atrio[0] + Atrio[2] > Atrio[1] and Atrio[1] + Atrio[2] > Atrio[0]): return(True) else: return(False) ...
3.96875
4
smollm
858876328061572494f6637adb63780dab112ab9
tshihui/pypaya
/codility_practices/triangle.py
655
null
null
null
null
def lcm(num1, num2): if num1 >= num2: rangenum = num1 else: rangenum = num2 lcm = 1 x = 2 while (x <= rangenum): if num1%x == 0 and num2%x == 0: num1 = num1/x num2 = num2/x lcm = lcm*x if num1%x == 0 and num2%x != 0: num...
3.84375
4
smollm
1939f5da7a2de3f97b569b222f8a476c45d44a61
tshihui/pypaya
/programmingQuestions/LowestCommonMultiple.py
660
null
null
null
null
#-----------------------------------------------------# #------ Simple function to return reverse array ------# #-----------------------------------------------------# def rev(ar): la = len(arr) rarr = [] for i in range(la-1, -1, -1): rarr.append(ar[i]) return(rarr)
4.1875
4
smollm
7d186569200b6b009b1af6d5dd06227938b772e6
tshihui/pypaya
/programmingQuestions/reverseArray.py
311
null
null
null
null
point=input('輸入分數') (point)=int(point) if point>=60: print("恭喜,及格了") else: print('抱歉,不及格')
3.515625
4
smollm
0fa4a507bdf1a1e017a74e1561cca073fdbf070b
Kevin-Lin-1012/Python200803
/day1-4.py
170
null
null
null
null
y = 3 if y < 3: print('é menor que 3') else: print('é maior que 3') numero = 3 if numero > 0: print("é maior que zero") elif numero < 0: print("é menor que zero") elif numero == 0: print("é igual a zero")
4.1875
4
smollm
20f072b579abc14d6780b3bb3e34f9f8b84e2225
goufix-archive/py-exercises
/modulo-1/ifelse.py
232
null
null
null
null
base = float(input("Insira o valor da base triangulo: ")) altura = float(input("Insira o valor da altura do triangulo: ")) print("A area do triangulo e: ",(base * altura)/2)
3.8125
4
smollm
cd8a3b6c78069a903001fa362f0c28fb4fac4f36
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo2/exemplo15.py
175
null
null
null
null
for i in range(11): #a variavel i e nosso contador print("2 x ", i, " = ", 2 * i) #perceba como o i ira mudar em cada repeticao
3.6875
4
smollm
074518993b9aae11af945e1b125bf5dbd7e7b885
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo4/exemplo24.py
133
null
null
null
null
#entrar com a disciplina disciplina = input("Insira sua disciplina: ") #Entrar com a quantidade de alunos da turma quantidade = int(input("Insira o numero de alunos da turma: ")) #a turma e uma lista com tamanho igual a quantidade informada turma = [alunos for alunos in range(quantidade)] #para cada aluno na turma fo...
3.921875
4
smollm
d861f5dfa4b79c83463924d3dd81bbed7542836e
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo5/exemplo49.py
1,951
null
null
null
null
luz = False #luz comeca apagada ascender_luz = input("Gostaria de ascender a luz? [s/n]") if ascender_luz == 's': luz = True if luz == True: #se ascender a luz print("A luz esta acesa") #nos informe que agora a luz esta acesa else: #se nao print("A luz esta apagada") #nos informe que a luz esta apag...
4
4
smollm
77d8ed6c5e5b35ca61ec1e71d4a01444f1833797
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo3/luz2.py
333
null
null
null
null
meus_dados = [] #criamos uma lista vazia nome = input("Insira seu nome: ") #pedimos que o usuario escreva o nome meus_dados.append(nome) #inserimos o nome na lista idade = int(input("Insira sua idade: ")) #pedimos a idade meus_dados.append(idade) #inserimos a idade na lista altura = float(input("Insira sua altura: "...
4.15625
4
smollm
21a12367a27e137db839114f4a7adc0ae9223934
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo5/exemplo33.py
448
null
null
null
null
lado = float(input("Insira o tamanho dos lados do quadrado: ")) area = lado * lado perimetro = lado * 4 print("A area do quadrado e de: ", area) print("O perimetro do quadrado e de: ", perimetro)
3.75
4
smollm
0836af99632805f6441fbc8e661e18671c23dd82
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo2/exemplo14.py
196
null
null
null
null
nome = input("Insira seu nome ") print("Ola ", nome," como esta hoje?")
3.53125
4
smollm
c62a76aaa7cad67fcd9522b0266dab61caf9ea82
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo2/exemplo11.py
72
null
null
null
null
num1 = input("Insira o primeiro numero") num2 = input("Insira o segundo numero") soma = int(num1) + int(num2) print("O resultado da soma e ", soma)
3.828125
4
smollm
4205df69f8f766bbf6b58d7f5ffe28bbb6967aa8
brunolcarli/AlgoritmosELogicaDeProgramacaoComPython
/livro/code/capitulo2/soma.py
148
null
null
null
null
from menu import menu, resources number_of_coffee_choices = ["espresso", "latte", "cappuccino"] ingredient_name = [] ingredient_bank = [] total_money = 0 last_money = 0 for resource in resources: ingredient_bank.append(resources[resource]) ingredient_name.append(resource) ingredient_bank_non_espresso =...
3.53125
4
smollm
6ee77f546f9f532e1f8fff8cfb9f427d52c69b4b
maxts0gt/pythoneveryday
/D15_Coffee_Machine/coffee_machine.py
9,645
null
null
null
null
from enum import Enum from pyspades.game import BETS, IS_NUMERICAL_BET class Player: def __init__(self, id, name): self.id = id # will be text id like discord id self.name = name # User's name to be displayed self.books = [] # list of card lists for each book self.bet = BETS.NONE #...
3.546875
4
smollm
6b34cfde0e82ed6b297706ae06d294f044630d38
lbuckalew/PythonSpades
/pyspades/players.py
3,383
null
null
null
null
import math import random import turtle import numpy def population(populationSz): """ This function will generate population of chromosomes as per populationSz :type populationSz: int """ l1 = [i for i in range(1, populationSz + 1)] random.shuffle(l1) return l1 def selection(total...
4.125
4
smollm
f6804fea61ef08368df86b5677a3ee7bda967f4b
depanker/ml-problems
/n-queen.py
7,138
null
null
null
null
# Author: Areeb Beigh # Created: 10th April 2016 ''' Description: Makes a temporary playlist of the music files in the folder in config.ini [hs-music] and opens it with the default media player ''' import os, configparser, sys # Gets the root directory (Drive letter in case of windows) rootDirectory = os.path.sp...
3.625
4
smollm
50763a7e562a66192727d60efac7ea40b734cba9
joobn72/hacker-scripts
/src/hs-music.py
1,847
null
null
null
null
d=dict(joe=90,peter=80) print(d) d[0]='pns' print(d) print('peter' in d) print(d.get('john',0)) print(d.get('joe',0)) print(d.keys()) print(list(d.keys())) print(d.values()) print(list(d.values())) n=dict([('lpn',10)]) print(n) #multidimensional dictionary m={'pns':[90,80,30],'rns':[50,70,90]} print(m) print(m['rns']) ...
3.953125
4
smollm
461e589e3f3d439a310073ddcf58a858d504d459
pns845/Dictionary_Practice
/dict_aug24.py
540
null
null
null
null
import os import argparse # Parse args parser = argparse.ArgumentParser(description='Join files') parser.add_argument('input', metavar='FI', type=str, help='name of folder with files to be joined') parser.add_argument('--output', '-o', metavar='FO', type=str, help='output file...
3.609375
4
smollm
246a5d2f0c8d2a70cbf66c244fad0433033c8987
pyliaorachel/wiki-chinese-corpus
/join_file.py
825
null
null
null
null
# -*- coding: utf-8 -*- import pandas as pd # CSVファイルの読み込み df = pd.read_csv( "C:/github/sample/python/pandas/basic/artoria.csv", index_col=0) # 合計 sum = df['ATK'].sum() print("sum:", sum) # sum:93566 # 平均 mean = df['ATK'].mean() print("mean:", mean) # mean:10396.2222222 # 中央値 median = df['ATK'].median() print...
3.578125
4
smollm
715f74017b622b9a7b88d92adb487c67fc735de1
nishizumi-lab/sample
/python/pandas/basic/ex9.py
757
null
null
null
null
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt def realtime_graph(x, y): line, = plt.plot(x, y, "ro", label="y=x") # (x,y)のプロット line.set_ydata(y) # y値を更新 plt.title("Graph") # グラフタイトル plt.xlabel("x") # x軸ラベル plt.ylabel("y") # y軸ラベル plt.legend() # 凡例表示 plt.grid() ...
3.71875
4
smollm
3e51d27dde6f01a16eeec55f70d479b42a3380a9
nishizumi-lab/sample
/python/matplotlib/animation/ex2.py
790
null
null
null
null
# -*- coding: utf-8 -*- from sympy import * # a~zまで変数として扱う var("a:z") # 関数f(x)の定義 f = x**2 + 3*x + 2 # 関数にx=1を代入(f(1)の計算) f1 = f.subs([(x, 1)]) print("f(1)="+str(f1)) # f(1)=6
3.671875
4
smollm
3953a75d616431eba4d198129ffb0ff9bc45b839
nishizumi-lab/sample
/python/sympy/01_function/sample02.py
249
null
null
null
null
# -*- coding: utf-8 import numpy as np # 回帰分析(x, y) def fitting(x, f): # xの値を生成 x = np.linspace(1, len(f), len(f)) # フィッティング a1, a2, a3, b = np.polyfit(x, f, 3) # フィッティング関数 fh = a1 * x**3 + a2 * x**2 + a3 * x + b # 勾配を計算 dfh = np.gradient(fh) # 3値化(前日の終値よりプラス:1, 変化なし:0, ...
3.59375
4
smollm
56d0b6f14583d06cb4d60146aa3b108a448db3de
nishizumi-lab/sample
/python/numpy/Stock/Nikkei/polyfit.py
1,452
null
null
null
null
# -*- coding: utf-8 -*- import pandas as pd new_dict1 = {'key1': [11, 12], 'key2': [21, 22], 'key3': [31]} df1 = pd.DataFrame.from_dict(new_dict1, orient='index').T print(df1) """ key1 key2 key3 0 11.0 21.0 31.0 1 12.0 22.0 NaN """ new_dict2 = {} list_key1 = [11, 12] list_key2 = [21, 22] list_key3 = [31] ...
3.53125
4
smollm
2815be6a6a5c5bc778485bad822b98ddee66aa6c
nishizumi-lab/sample
/python/pandas/advance/dict_to_df1.py
547
null
null
null
null
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [4, 5, 6, 7, 8] label_x = ["A", "B", "C", "D", "E"] plt.barh(x, y, align="center") # 中央寄せで棒グラフ作成 plt.yticks(x, label_x) # X軸のラベル plt.show()
3.515625
4
smollm
c71492d5e17e86d3fe99f177112824f408eab4fd
nishizumi-lab/sample
/python/matplotlib/basic/ex5.py
284
null
null
null
null
# -*- coding: utf-8 import urllib.request # url先のHTMLファイルを開く data = urllib.request.urlopen("https://raw.githubusercontent.com/nishizumi-lab/sample/master/python/scraping/00_sample_data/sample01/index.html") # HTMLの取得 html = data.read() html = html.decode('utf-8') # 表示 print(html) # HTMLファイルを閉じる data.c...
3.5
4
smollm
7867bff23d1830ac5c29a08006cb9d41048af899
nishizumi-lab/sample
/python/scraping/00_urlib/sample02.py
778
null
null
null
null
# -*- coding: utf-8 -*- import datetime as dt def main(): date = dt.datetime(2017, 5, 3, 12, 00, 00) date = date + dt.timedelta(days=5, hours=1, minutes=30) print(date) # 2017-05-08 13:30:00 if __name__=='__main__': main()
3.703125
4
smollm
a3c5161c6b4665cc0b8f75997c44c1a4ba088b39
nishizumi-lab/sample
/python/basic/time/datetime/timedelta.py
245
null
null
null
null
# -*- coding: utf-8 -*- import re data = 'abcdefghijklmnabcdefghijklmn' pattern = re.compile(r'd.*?g') # パターン式の定義(dで始まりgで終わる最短の文字列) match_data = pattern.search(data)# パターン式との一致判定 print( match_data.group() ) # 一致したデータを表示 print( matchObj.start() ) # 一致した開始位置を表示 print( matchObj.end() ) # 一致した終了位置を表示 print( matchObj.spa...
3.78125
4
smollm
b56097b8518eae9bf6ff491b55958656f4819b56
nishizumi-lab/sample
/python/basic/re/search.py
491
null
null
null
null
import sys def quick_sort(arr): # 左右2つに分割したデータを格納するリスト left_arr = [] right_arr = [] # 要素数長が1以下なら終了 if len(arr) <= 1: return arr # 先頭要素を軸要素(基準値)に指定 pivot = arr[0] pivot_count = 0 # 左右2つのグループに分割 for ele in arr: if ele < pivot: left_arr.append(ele) ...
4.0625
4
smollm
41d540448c55a5f74be9d03544b1671e2c8eea07
nishizumi-lab/sample
/python/basic/algorithm/sort/quick_sort/quick_sort.py
1,441
null
null
null
null
import random import string import sys SECRET_STRING = "" ALPHABET = string.printable def generateRandomWord(size = 10): return "".join([random.choice(ALPHABET) for i in range(size)]) def compareWords(a, b): assert len(a) == len(b), "As duas strings devem ter o mesmo tamanho! (%d e %d)" % (len(a), len(b)) return ...
3.75
4
smollm
290f5796c1bfe57b5cfd93d753cfe36ec04d84fa
zJoaoP/WordDecoder
/main.py
2,167
null
null
null
null
lista_programadores = ['Rita', 'Mauro', 'Jonas', 'Letícia', 'Juliana', 'Guilherme'] def imprime_maiusculo(programadores): for programador in programadores: print(programador.upper()) imprime_maiusculo(lista_programadores)
3.65625
4
smollm
4f8cd8e4d9913ccb43a4ca4a817dc7ebc98e1526
EmillyLopes/Projetos_python
/imprime_maiusculo.py
236
null
null
null
null
impares= [1, 3, 5, 7, 9] pares = [2, 4, 6, 8, 10] numero_1 =min(impares) numero_2 = max(pares) soma = numero_1 + numero_2 print("A soma entre o menor número ímpar e o maior número par é: " + str(soma))
3.625
4
smollm
a5bf6daac5dd7617333b44b4e48c5b23f5556b89
EmillyLopes/Projetos_python
/somaentren.py
208
null
null
null
null
a1,b1,c1 = input().split() a=float(a1) b=float(b1) c=float(c1) #delta= (b**2)-4*a*c x1 = (-b + (b**2)-4*a*c ** (1 / 2)) / (2 * a) x2 = (-b - (b**2)-4*a*c ** (1 / 2)) / (2 * a) if delta == 0 : #print ("o valor de a deve ser diferente de 0") #elif delta <0: #print("sem raízes reais") #else: print (x1, x2)
3.53125
4
smollm
b64558bd57063cd2ec9833858737fa3a2f03ce7c
EmillyLopes/Projetos_python
/exercicio livrp.py
315
null
null
null
null
''' Homework for Lesson 3 Exercise 6. 6. Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же, но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text. Продолжить работу над заданием. В программу должна попадать строка из слов, разделенных пробелом. Каждое...
4.28125
4
smollm
d34a5c52b42d843a3aa9e6b454d7a894527b50b9
egreenius/ai.python
/Lesson_3/hw_3_6.py
1,582
null
null
null
null
''' Home work for Lesson 6 Exercise 3 3. Реализовать базовый класс Worker (работник), в котором определить атрибуты: name, surname, position (должность), income (доход). Последний атрибут должен быть защищенным и ссылаться на словарь, содержащий элементы: оклад и премия, например, {"wage": wage, "bonus": bonus}. Создат...
4.125
4
smollm
78cbf3e1e8ba790f4b65f9cb87a4fc6d0d70dc18
egreenius/ai.python
/Lesson_6/hw_6_3.py
2,360
null
null
null
null
''' Home work for Lesson 7 Exercise 3 3. Реализовать программу работы с органическими клетками. Необходимо создать класс Клетка. В его конструкторе инициализировать параметр, соответствующий количеству клеток (целое число). В классе должны быть реализованы методы перегрузки арифметических операторов: сложение (__add__(...
4.03125
4
smollm
8bf52c6da5ae0823a28a492bfddcba1513d09967
egreenius/ai.python
/Lesson_7/hw_7_3.py
5,883
null
null
null
null
""" Merge function for 2048 game. http://www.codeskulptor.org/#user39_HoE5rKkqM7_0.py """ def merge(line): """ Function that merges a single row or column in 2048. """ # replace with your code result_list_one = [0 for index in range(len(line))] result_list_index = 0 for inde...
3.53125
4
smollm
1e7f20dade9f7d38cc4d45c8c346f93e069c15b1
apeterson91/fundamentals-of-computing
/Principles of Computing/2048/2048_merge.py
1,079
null
null
null
null
http://www.codeskulptor.org/#user39_MqvJKT77Jh_22.py """ Student code for Word Wrangler game """ import urllib2 import codeskulptor import poc_wrangler_provided as provided from math import floor WORDFILE = "assets_scrabble_words3.txt" # Functions to manipulate ordered word lists def remove_duplicates(list1): ...
3.875
4
smollm
7cad02b34bd65482da3efaf2230b6373b9457631
apeterson91/fundamentals-of-computing
/Principles of Computing/word_wrangler/word_wrangler.py
3,719
null
null
null
null
def Permutation(input_list, partial, used): input_len = len(input_list) if len(partial) == input_len: print(partial) else: for i in range(0, input_len): if not used[i] and not (input_list[i] == input_list[i - 1] and not used[i - 1]): used[i] = True ...
3.65625
4
smollm
aab890378fb0a5a2fca1102a0b1220f988bed7af
kannan5/Algorithms-And-DataStructures
/Recursion/Problems/permutation.py
547
null
null
null
null
# Binary Search Tree class Node: def __init__(self, val=None): self.data = val self.left = None self.right = None class Queue: def __init__(self): self.items = [] def enqueue(self, new_item): self.items.insert(0, new_item) def dequeue(self): if not sel...
4.125
4
smollm
13d0cf0ce4da58d87b574581cf31b94041c2c96d
kannan5/Algorithms-And-DataStructures
/Tries/BinarySearchTrees.py
7,039
null
null
null
null
def findTarget(arr, target): arr.sort() __findTarget(arr, target, [], 0) def __findTarget(arr, target, pair, start): if target == 0: print(pair) return if start == len(arr): return for i in range(start, len(arr)): curr = arr[i] if curr > target: ...
3.8125
4
smollm
ef656803e5b71662a626ff2b5342247d4ad838ef
kannan5/Algorithms-And-DataStructures
/Recursion/Problems/findTarget.py
579
null
null
null
null
# Insertion Sort will take O(N)^2 Time Complexity and O(1) Space Complexity def InsertionSort(input): input_len = len(input) for cur_pos in range(1, input_len): if input[cur_pos - 1] > input[cur_pos]: input[cur_pos], input[cur_pos - 1] = input[cur_pos - 1], input[cur_pos] if (c...
4.1875
4
smollm
eb6a5f580621a34a23582e97e53948fca0f015a2
kannan5/Algorithms-And-DataStructures
/sorting/insertion_sort.py
648
null
null
null
null
""" SUGGESTION : add a search from wikipedia in option 3 ; the user can just ask for a summary from the wikipedia feature! """ import wikiquote, random def do_quote(): while True: quote_list = [] print("\n\nHello wise internet user, so you want to brew some good quotes!" "Choose the...
4
4
smollm
e65a80ffe00d79d9fff76fca2e4e0ea012440903
rjsu26/python-Command-Line-UI
/cli/packages/quote.py
2,668
null
null
null
null
A=["1","2","3"] A.append("4"); def B(C): for figure in C: print("数字是:",C) B(A)
3.546875
4
smollm
a266f0da4ff6921ba2c2b04ba3cc9a2ab3185106
Tiger-C/python
/2/test2.py
90
null
null
null
null
import sys # Get the list of words words = sys.argv[1:] # Sort the list words.sort() # Capitalize first letter for i, w in enumerate(words): words[i] = w.capitalize() # Extract the last word from the list lastWord = words[-1] words = words[:-1] #print lastWord #print words # Join the words sent = ", ".join(words...
4
4
smollm
ea8f20f6293a3f8f4bf9418ff9b635899241b262
johnfrye/SoftwareCarpentryBootcamp
/day1/partA/wordsToSentence.py
362
null
null
null
null
class Solution: def solve(self,s): self.s = s if(self.s[-2 : ] == 'am' and s[ : 2] == '12'): print('00:%s'%self.s[ 3 : 5]) elif(self.s[-2 : ] == 'pm' and s[ : 2] == '12'): print('12:%s'%self.s[ 3 : 5]) elif(self.s[-2 : ] == 'am'): print(self.s[ : 5...
3.578125
4
smollm
c364c1a76e2ccc0edc98b597f1783c8d0afbea6b
Job-Colab/Coding-Preparation
/Day-03/jagadeeshwaran.py
517
null
null
null
null
from turtle import * speed (0) def draw_square(length,colorr): color(colorr) for i in range(4): forward(length) left(90) draw_square(200,"black") mainloop ()
3.8125
4
smollm
97cb14b62f541b2a7bb6d4aa3750bf340f61c4de
DinhQuangBang/Ss5_C4E28
/Turtle1.py
187
null
null
null
null
import numpy as np from nn.init import initialize class Layer: """Base class for all neural network modules. You must implement forward and backward method to inherit this class. All the trainable parameters have to be stored in params and grads to be handled by the optimizer. """ def __init__(...
3.671875
4
smollm
a817d9e827e541b0c2dd699297249bda8071c0ad
jinhee96/test
/nn/layers.py
13,867
null
null
null
null
import sys # this function uses a dictionary to tell us what block a number is in, if we input the index of the tile. def block (a): if a not in range(81): return None blocks = { 1: [0,1, 2,9,10,11,18,19,20], 2:[3,4,5,12,13,14,21,22,23],3:[6,7,8,15,16,17,24,25,26], 4:[27,28,29,36,37,38,45,46,47],5...
4.1875
4
smollm
f9bd33c52355b3f0b7591ad5662f22a07ab3f7c1
assgJones/SudokuSolver
/main.py
2,014
null
null
null
null
# -*- coding: utf-8 -*- def print_sanjiaoxing(): print("*") print("*" * 2) print("*" * 3) print("*" * 4) print("*" * 5) def print_chengfabiao(): i = 1 while i <= 9: j = 1 while j <= i: print("%d*%d=%d" %(i, j, i*j), end=" ") j += 1 print("") ...
3.59375
4
smollm
3b9bf94dd05cf69e05211967873745f061d9e2a6
xingyunsishen/Python_CZ
/31-函数.py
742
null
null
null
null
#-*- coding:utf-8 -*- class Dog(object): __instance = None def __new__(cls, name): if cls.__instance == None: cls.__instance = object.__new__(cls) return cls.__instance else: return cls.__instance def __init__(self, name): self.name = name a ...
3.5625
4
smollm
285f34af99f3325a344e84fef7a5b8bcba2e95ab
xingyunsishen/Python_CZ
/71-只初始化一次对象.py
465
null
null
null
null
#-*- coding:utf-8 -*- ''' #制作文件备份 #1.获取用户输入的文件名 file_name = input("please input file name:") #2. 打开要复制的文件 f_read = open(file_name, 'r') #3.将原文件备份为file_name.bak #方式1 #new_file = file_name + '.bak' #方式2 #new_file = file_name.replace('.', '_bak.', 1)# 这种方法有个缺点:当文件名中包含 #多个'....
3.578125
4
smollm
f82cf74074404fc229e30b53b55e882d00ba91d6
xingyunsishen/Python_CZ
/45-文件操作.py
3,955
null
null
null
null
#-*- coding: utf-8 -*- t = 1 while (t): a = (float(input('\033[0;30;40m input a number between 1 and 100:\033[0m'))) if a > 1 and a < 100 or a == 1 or a == 100: print('\033[0;31;41m Right \033[0m') t = 0 else: print('\033[0;32;42m Sorry!try agin..\033[0m')
3.59375
4
smollm
b0852be4453e1152105a4a40e200124b9f0433fa
xingyunsishen/Python_CZ
/2-10.py
305
null
null
null
null
#-*- coding:utf-8 -*- ''' 1.局部变量只在当前函数生效,出去当前函数不生效; 2.全局变量在所有函数中均可以直接引用 3.全局变量虽可以在函数外部定义,但是一定要在调用函数开始执行前 如以下程序:a,b均可以正常输出,c会报为定义 a = 11 def test(): print('a=%d'%a) print('b=%d'%b) print('c=%d'%c) b = 22 test() c = 33 4.全局变量的优先级要小于局部变量的优先级 a = 100 def test01(): a = 200 print('a=%d' %a) def test02():...
4.15625
4
smollm
6db4f899337bd9c4fc2be268afc07530f4e9b279
xingyunsishen/Python_CZ
/35-变量.py
1,820
null
null
null
null
#-*- coding:utf-8 -*- class Animal: def eat(self): print('\033[0;37;42m ========吃=======\033[0m') def drink(self): print('\033[0;37;43m ========喝=======\033[0m') def sleep(self): print('\033[0;37;44m =======睡========\033[0m') def run(self): print('\033[0;37;45m ======...
3.53125
4
smollm
8ec94b6e3f81138c31d2f98b27daa1884a9a084b
xingyunsishen/Python_CZ
/54-继承.py
992
null
null
null
null
#-*- coding: utf-8 -*- # 获取用户从键盘输入,并计算该数的阶乘 num = int(input('please input a number:')) # result = num * num -1 * num-2 ''' i = 1 result = 1 while i <= num: result *= i i += 1 print(result) ''' def factorial(num): #注意这里的num if num > 1: return num * factorial(num-1) else: return num res...
4.15625
4
smollm
5fecb6498198e185ee0b28b73c8384fbb6847093
xingyunsishen/Python_CZ
/42-函数递归.py
418
null
null
null
null
nom=input() prenom=input() code=input() service="" travail="travail" annee="20"+code[0:2] numero=code[2:6] sexe="Monsieur" pronom="Il" co=code[7] if (code[6]==1): sexe="Madame" travail="travaille" pronom="Elle" if (co=="0"): service="direction" if (co=="1"): service="secretariat" if (co=="...
3.71875
4
smollm
23011a2210fd303b77dd7d9d0c0e7c89b547246b
ayachim/Python
/code&entreprise.py
675
null
null
null
null
#entraienement cycliste #nbjour=21 distance=30 increment=10 cumul=0 #print("nbj : dst : cumul ") for r in range(21): cumul=distance+cumul #print(r+1," ", distance ," ",cumul) if r == 6: print("----------------premiere semaine :" ,cumul," km") sem1=distance if r == 8...
3.796875
4
smollm
1bc2589ada5d013d422f14e36acd665414537994
ayachim/Python
/entr_cycliste.py
695
null
null
null
null
# using scipy from scipy.spatial import distance # Calculate distance using euclid method def euc(a, b): return distance.euclidean(a, b) # OWN CLASSIFIER class pranay(): # Creating our own fit to match the curvature def fit(self, X_test, y_test): self.X_train = X_train self.y_tr...
3.625
4
smollm
8283c4ad2f07f6733464605d19cb4ec1e9509274
pranayjoshi/ML_for_beginners_python
/first_classifier.py
1,876
null
null
null
null
num1 = int(input("base: ")) num2 = int(input("power: ")) num3 = int(input("divisor: ")) result = (num1**num2) % num3 print("result = " + str(result))
4.0625
4
smollm
88a68f1e93304dd9a0bce31575961cefe9bf0532
heretic314/Cryptography_Scripting
/ModFinder.py
157
null
null
null
null
from rectangle import Rectangle, Square, Circle rect_1 = Rectangle(3,4) rect_2 = Rectangle(12,5) print(rect_1.get_width(), rect_1.get_height(), rect_1.get_perimeter() ) print(rect_1.get_area()) print(rect_2.get_area()) square_1 = Square(5) square_2 = Square(10) print(square_1.get_area_square(), square_2.get_area_s...
3.6875
4
smollm
9d58944327545cd2528cbfb855af6c77768d69f8
nook2/LearningSF
/projects/SkillFactory/practice_C1/python_practice/rectangle_2.py
381