blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d8b78254c7d67b8de1bf0d27bdf5df6c60ee7614
chimeddor/cats-and-dogs-classifier
/temp/predict.py
884
3.671875
4
# make a prediction for a new image. from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array from keras.models import load_model # load and prepare the image def load_image(filename): # load the image img = load_img(filename, target_size=(224, 224)) # convert to ar...
395b86c9243f56118bd1a0e0a4e7ebeb0a0d1af6
AnkitMitraOfficial/python_learning
/Python_Section3 - Basic/sets.py
786
4.5625
5
# Introduction # Sets are used to store multiple items in a single variable. # A set is a collection which is both unordered and unindexed. # We create a set by using curly brackets my_set = {1,2,3,4,5,5} print(my_set)# Removes any dublicate value and prints the set print(len(my_set)) # Returns the length of the uni...
c3b6fb7a2a18447d31f5de66321ca997f16a4419
NineSH/leecode
/27 Remove Elemnet.py
1,099
3.921875
4
# Given an array nums and a value val, remove all instances of that value in-place and return the new length. # Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. # The order of elements can be changed. It doesn't matter what you leave beyond ...
f2423a55a4b97d898952b22333bda8485f4c9fa1
tjdgus3160/algorithm
/BOJ/Silver5/줄 세우기.py
235
3.6875
4
# 11536번 import sys input=sys.stdin.readline arr=[input().rstrip('\n') for _ in range(int(input()))] if arr==sorted(arr): print('INCREASING') elif arr==sorted(arr,reverse=True): print('DECREASING') else: print('NEITHER')
f9cca9de6026909d127d0521c3d255e455369258
rrajvanshi1947/python
/leetcode/recursion/fibonacci.py
336
3.546875
4
from functools import lru_cache # fibonacciCache = {} @lru_cache(maxsize = 500) def nthTerm(n): # if n in fibonacciCache: # return fibonacciCache[n] if n in (1, 2): return 1 return nthTerm(n-1) + nthTerm(n-2) # fibonacciCache[n] = value # return value for n in range(1, 1001): p...
d598bfe43e852924c48c4d181d25a1edae619978
tjguk/dojo-board
/test_neighbour_board.py
3,110
3.71875
4
from unittest import TestCase import board class TestBoard(TestCase): def test_neighbours_original(self): b1 = board.Board((3, 3, 3)) neighbour_coord = list(b1.neighbours((0,0,0), include_diagonals=True)) self.assertEqual(7, len(neighbour_coord)) self.assertSetEqual({(0, 1, 0), (1...
89be754f0653bdb85c0daf8bd000ee941a0bfaea
moondemon68/Kuliah-PTI
/H01-16518380/H01-16518380-03.py
2,514
3.65625
4
# NIM/Nama : Morgen Sudyanto # Tanggal : 08/09/2018 # Deskripsi : Mencari siapa pemenang perolehan medali antara Jawa Tengah, Jawa Barat dan DKI Jakarta #KAMUS #t1 : int #t2 : int #t3 : int #b1 : int #b2 : int #b3 : int #j1 : int #j2 : int #j3 : int #t : int #b : int #j : int #st : int #sb : int #sj : int t3=int(inpu...
8f2ca23e793d5205d5f048fa25892e66bc5e6906
dnootana/Python
/concepts/trees/treeLevelOrderPrint.py
1,176
3.8125
4
#!/usr/bin/env python3.8 import collections import BinaryTree as BT import BinarySearchTree as BST import MinHeap as minHeap import MaxHeap as maxHeap def levelOrderPrint(tree): if not tree: return currentcount = 1 nextcount = 0 nodelist = [tree] while len(nodelist) > 0: currentnode = nodelist.pop(0) prin...
7d3c7b3384414ea8a56b9afae5b50116105a8bdb
bryanlaura736/Python
/maths/abs_min.py
646
3.609375
4
from __future__ import annotations from .abs import abs_val def abs_min(x: list[int]) -> int: """ >>> abs_min([0,5,1,11]) 0 >>> abs_min([3,-10,-2]) -2 >>> abs_min([]) Traceback (most recent call last): ... ValueError: abs_min() arg is an empty sequence """ if len(x) ==...
444e77df4c4a227d336048bafaa9e8596c8106e2
15706429303/Python_Algorithm
/testinstance/immedia2/util.py
214
3.609375
4
def lines(file): for line in file:yield line yield '\n' def blocks(file): block = [] for line in lines(file): if line.strip(): block.append(line.strip('\r\n')) return block
8e187e036ef855e34b7a32cc5260a5d0c2aea155
dq-code/leetcode
/314-BinaryTreeVerticalOrderTraversal.py
817
3.78125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None import collections class Solution(object): def verticalOrder(self, root): """ :type root: TreeNode :rtype: List[List[in...
e5ab5fc2668c6debbdb50f2e0940c152ef82a489
dev-nikhilg/gradientDescentAndNormalEquationImpl
/minimise_functions_gradient_descent_and_normal_equation/gradient_descent.py
4,046
4.0625
4
import numpy as np import matplotlib.pyplot as plt from .minimise_function import MinimiseFunction class GradientDescent(MinimiseFunction): def __init__(self, X = None, Y = None): """Gradient descent class to minimise a generic function Attributes: X (n*m feature matrix)...
44ae6214983227e5225464ed107c281d017ea358
chunweiliu/leetcode2
/unique_word_abbreviation.py
1,441
4.0625
4
"""Figure out if a word has a unique abbreviation Example of abbr. - internationalization = i18n Use a counter for the dictionary, return True if the abbrs is less than 2 * The dictionary can have duplicates, such as ['a', 'a'], but 'a' has unique abbr. * The dictionary can have zero w...
7f86ddf67bc12ed9079506f6acbe0f93f964a4da
EruDev/LeetCode_Python
/3.无重复字符的最长子串/无重复字符的最长子串.py
581
3.625
4
# coding: utf-8 def lengthOfLongestSubstring(s): max_len = 0 if len(s) == 0 or len(s) == 1: max_len = len(s) else: for i in range(0, len(s) - 1): for j in range(1, len(s)): if s[j] in s[i:j]: right = j left = i ...
37759578e423c9ec487cf6510364a8ebba1162a9
renaissance-codes/leetcode
/out/production/leetcode/src/leetcode/python3/leetcode268.py
270
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- from typing import List # 使用减法原则 class Solution: def missingNumber(self, nums: List[int]) -> int: sum_x = len(nums) for i, x in enumerate(nums): sum_x += i-x return sum_x
1bef2ff88d340b0e0eb18a23c96c6024b9160965
decordoba/mixed-algorithms
/shortestPathGraph.py
5,973
3.9375
4
#!/usr/bin/env python2 """ Challenge from HackerRank. https://www.hackerrank.com/challenges/ctci-bfs-shortest-reach We have an undirected graph consisting of n nodes where each node is labeled from 1 to n and the edge between any two nodes is always of length 6. Given a node s, calculate the shortest distance from s t...
2605630b3e661d40996ce4267325289aa83c025b
kesch9/Alg_Data_Structur_Python_Homework
/lesson_2/task7.py
555
4.0625
4
# Напишите программу, доказывающую или проверяющую, # что для множества натуральных чисел выполняется # равенство: 1+2+...+n = n(n+1)/2, где n - любое натуральное число. def recur_sum(n): if n <= 1: return n else: return n + recur_sum(n - 1) print("Введите число") n = int(input()) if (recur_sum(...
df422d7e875e33c2232e23429d0ec32e6b0e5639
htingwang/HandsOnAlgoDS
/LeetCode/0061.Rotate-List/Rotate-List.py
897
3.78125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not hea...
0f39eafe1ce39cdcf98f1293b06cd2990b731a20
hongtaozhang1/MyLeetCode
/problem14/longestcommonprefix.py
543
3.5
4
__author__ = 'hongtao' class Solution: def longestCommonPrefix(self, strs): strs.sort(key=len) if len(strs) == 0: return "" for i in range(len(strs[0]), 0, -1): flag = True for j in range(1, len(strs)): if strs[j][0:i] != strs[0][0:i]: ...
0193035a83204b3218b2d5b4b797c923f149afd4
WatchmanGu/BGI-training
/program_files/cds_of_chr13.py
2,583
3.546875
4
# -*- coding: utf-8 -*- import textwrap import time #record start time start = time.clock() #function to reverse sequence def sequence_reverse(string): """ A function to reverse a sequence. e.g. ATCG --> GCTA. Remind: '+', positive, 5'->3';'-', negative, 3'->5'. """ return string[::-1] #func...
19866799bd91e1dccfb6bc5fb1b10ba4f2e26f2b
phantomBJHK/PythonCourses
/1001作业.py
406
3.796875
4
def assesment(mark): if mark >= 90: return 'A' elif mark < 60: return 'C' else: return 'B' while True: mark = input('请输入成绩,或输入Q退出程序:') if mark == 'Q': break try: mark = float(mark) except: print('输入错误,请重新输入!') continue print('您的成...
5fd2b3ce17f9c05c8520ac4b08d5ddacbab90437
lcwspr/Python
/001_study_python/001_python_基础知识/03_int_bool_str/03_str.py
542
3.796875
4
# 字符串的索引与排序 s = 'ABCDEFGHIJKLMN' # 索引 s1 = s[0] print(s1) s2 = s[2] print(s2) # 截取一部分字符串 切片操作,顾头不顾尾 s3 = s[0:4] print(s3) # 倒数第几位 s4 = s[-1] print(s4) s5 = s[-2] print(s5) # 取全部的 s6 = s[0:] s6 = s[:] # 一样的写法 # 也就是第一位默认为0 第二位默认为len(str) print(s6) # 跳着取子串 s[首:尾:步长] sstrip = s[:5:2] print(sstrip) # 倒着取值 sRev...
b7f1682b25229ed6faeed92a4e0248e3e47f7100
arjupoudel/Bitwise-Binary-Addition
/InputNumbers.py
1,100
4.0625
4
def input_numbers1(): while True: try: a = int(input('Enter a number between 0-255: ')) except ValueError: print("You are not allowed to enter string, float or boolean value.") continue else: if a > 255: print("You have entered ...
5105426e5c4d204035ca2e93d1fc21f82cb06a7c
Mr-BYK/Python1
/machineLearning/numpy/numpy1.py
5,676
3.953125
4
import numpy as np """ result = np.array([1,3,5,7,9]) result = np.arange(1,10) result = np.arange(1,100,2) # 1den yüze kadar 2 ser arayla sayı üretir result=np.linspace(0,5,5) # 0 dan 5 e kadar 5 eşit parçaya result=np.random.randint(0,10) result=np.random.randint(1,10,3) # 1 den 10 kadar 3 tane random sayı üret...
14701241b0035e8dcca29c8ff5120a29126437cd
mediassumani/TechInterviewPrep
/InterviewPrepKit/Arrays/super_diagonal_elements.py
591
4.4375
4
# Problem reference : https://www.geeksforgeeks.org/print-all-the-super-diagonal-elements-of-the-given-square-matrix/ def find_diagonal_elements(matrix): # O(n) where n is the length of the matrix diagonal_list = [] row = 0 col = 1 while col < len(matrix): diagonal_list.append(matrix[row][c...
7b5521d256d8d9c651f7d19cd10bd4485a3c4fd8
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/mshsit002/push.py
3,310
3.953125
4
"""Prmomise Mashinini 2 may 2014 push , 2048""" import util def push_up (grid): """merge grid values upwards""" grid_copy=[]#grid_copy empty list grid_copy=util.create_grid(grid_copy) while grid!=grid_copy: grid_copy=util.copy_grid(grid)#this calls util and creates a grid copy ...
5a3578634f3758802228272eadadf52ad435f1b3
RajSuriyan/Assignments
/R_Calci.py
3,956
3.65625
4
from tkinter import * class tkeasy(): def print_text(self,a,r,c,lpos): labelo=Label(root,text=str(a),font=("Helvictica",48)) labelo.grid(row=r,column=c,sticky=lpos) def add(): try: a=int(e1.get()) b=int(e2.get()) c=a+b except: side=Tk(...
e95d51d93ec320fc00d3651ec31ea211f815e1b7
cbondurant/musicmanager
/musicmanager.py
1,456
3.59375
4
#!/usr/bin/env python3 import music_tag import argparse from pathlib import Path def parse_path(path): if not path.is_dir(): dirty = False try: f = music_tag.load_file(path) if 'album' not in f: print(path, "does not have an album name!") nam...
068a365c114322010f7f9d79106de13cb1e01bed
rgkimball/csmm.101x
/w2_search_algos/driver.py
12,188
3.6875
4
""" Submission for Project 1 of Columbia University's AI EdX course (8-puzzle). author: @rgkimball date: 2/9/2021 """ import os import sys import math import time import heapq from collections import deque from multiprocessing import Pool, cpu_count class PuzzleState(object): """The Class that Represent...
563f21a07bd3405c269f8ad2de5e5b98a09d1f67
gabriellaec/desoft-analise-exercicios
/backup/user_266/ch40_2019_04_05_04_11_08_003880.py
124
3.5
4
def fatorial(n): i=0 fatorial=(n-i) i=1 while n!=i: fatorial*=(n-i) i+=1 return fatorial
ee8310de72eed086ae8fb7089241bdef42679fe1
akhil9tiet/Learn_Python_on_the_go
/Python_basics/19. Intro to Classes/13. Overide.py
1,004
3.96875
4
#13. Overide """ Create a new class, PartTimeEmployee, that inherits from Employee. Give your derived class a calculate_wage method that overrides Employee's. It should take self and hours as arguments. Because PartTimeEmployee.calculate_wage overrides Employee.calculate_wage, it still needs to set self.hou...
41a678898b248abbdf91b05143a7499a407c8ed9
eliseuegewarth/uri-exercises
/beginner/1080/1080.py
142
3.734375
4
maior = int(input()) indice = 1 for x in range(2,101): i = int(input()) if i > maior: maior = i indice = x print(maior) print(indice)
7f5a15b18552065a3bd4e1a51c5ca66fef29c029
washing1127/LeetCode
/Solutions/0342/0342.py
265
3.5625
4
# -*- coding:utf-8 -*- # Author: washing # DateTime: 2021/5/31 9:59 # File: 0342.py # Desc: class Solution: def isPowerOfFour(self, n: int) -> bool: c = collections.Counter(bin(n)[3:]) return n >= 1 and c['1'] == 0 and c['0'] % 2 == 0
7019f3a606e6676903c571077befa6cdd2947639
dorgek/aoc2020
/src/day12/shipTwo.py
3,547
3.765625
4
from direction import Direction import re class ShipTwo : def __init__( self, start_position, way_point_position ) : # treat the current position as 0, 0 on a grid self._current_position = start_position self._direction_faceing = Direction.E self._way_point_position = way_poi...
dbcaa508598a8965073b5a7fedc7564a8c73d5ed
dinopriyano/TLX-Toki
/PenemuanPalu.py
107
3.671875
4
inp = input().split(" ") x = int(inp[0]) y = int(inp[1]) if x >= y: print("YES") else: print("NO")
0130984d5bfe5a1d82f61ff5668e4c0c38642f1b
abrade/spoj
/arith/arith.py
2,105
3.84375
4
#!/usr/bin/python import sys def max(first, second): if(first > second): return first else: return second def printSpaces(count): for i in range(0, count): sys.stdout.write(" ") def printValue(value, maxLen): spaces = maxLen - len(value) printSpaces(spaces) print valu...
499e5bbd56bfc8d84db6c65f5eebe25fb84baeed
PMiskew/Year9DesignCS4-PythonPM
/Contest Questions/J12018CCC.py
218
3.828125
4
#Input a = int(input("")) b = int(input("")) c = int(input("")) d = int(input("")) response = "answer" #Process if (a == 8 or a == 9) and (d == 8 or d == 9) and (b == c) response = "ignore" #Output print(response)
e19b707d2baa8ebdb769af6fbe5f00ff7819d565
catVSdog/algorithm_python
/examination_questions/about_link_list.py
565
3.609375
4
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def __repr__(self): return f'{self.data}' def function(node): stack = [] while node: stack.append(node) node = node.next while stack: print(stack.pop()) def ...
02a3b61a6a4d3880fc92d7949ecdebf955eb0a35
YuchinP/TTA-Python
/dataScience/s2v5.py
1,172
4.03125
4
from s2v4 import * def find_max(data_sample, col): temp_list = [] for row in data_sample: price = float(row[col]) temp_list.append(price) return max(temp_list) #print(find_max(data_from_csv[1:], 2)) # we want to find the max for price, so the stuff at the end signifies we want the...
a9cb15abaa9ea5ea4e1320e1626804623becbdc2
YoungsAppWorkshop/coding-practice-archive
/python-practice/CoreySchaferTutorials/03_int_float.py
1,077
4.53125
5
#!/usr/bin/env python3 num_1 = 3 # <class 'int'> num_2 = 3.14 # <class 'float'> print(type(num_1)) print(type(num_2)) # Arithmetic Operators: # Addition: 3 + 2 # Subtraction: 3 - 2 # Multiplication: 3 * 2 # Division: 3 / 2 (in Python 3) # Floor Division: 3 // 2...
5f55cbbcb585017ad7fcab71e9452ac685ee1368
kjhsto/NLP100Q
/05a.py
110
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- st = ["a","bd","c","42"," "] st2 = "".join(st) print(len(st2))
a266bbe5854a18950b5f8aa1ff0b51126790a8c6
mygethub-99/NewMay2015
/tournament.py
3,987
3.515625
4
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 def connect(): """Connect to the PostgreSQL database. Returns a database connection.""" return psycopg2.connect("dbname=tournament") def deleteMatches(): """Remove all the match records from the database....
01903f9ed029b333462b11eb3e719be36399cb72
guohong88/python
/Scrapy/笔记/day.py
9,179
3.671875
4
一、"大数据时代",数据获取的方式: 1. 企业生产的用户数据:大型互联网公司有海量用户,所以他们积累数据有天然的优势。 有数据意识的中小型企业,也开始积累的数据。 2. 数据管理咨询公司:通常这样的公司有很庞大的数据采集团队,一般会通过市场调研、问卷调查、固定的样本检测, 和各行各业的公司进行合作、专家对话(数据积累很多年了,最后得出科研结果)来采集数据。 3. 政府/机构提供的公开数据:政府通过各地政府统计上报的数据进行合并;机构都是权威的第三方网站。 4. 第三方数据平台购买数据:通过各个数据交易平台来购买各行各业需要的数据,根据获取难度不同,价格也会不同。 5. 爬虫...
610951e8f47f6ecb8dd310d4f0bfbbe6fcb9e9e0
Nagendra-Svknska/GCP-DataEngineering
/Week_1/Probability/Prob_P3_Ace.py
192
3.609375
4
s=0 tries=0 for i in range(0,52): if(i<3): tries+=1 if(i!=1): s+=1 print("total no of possible outcomes:",s,"total no of fav outcomes:",tries) print("probability :",tries/s)
f21f454bb8d837557ef0fe9d1d57b6030833ef2c
Albislan/exercicios_python
/mundo3/exerc_tuplas.py
2,329
3.953125
4
from random import randint a = 'Início' b = 'Fim' #os 5 primeiros colocados exercicio 73 #os 4 ultimos da tabela #uma tupla com os times em ordem alfabetica #em que posição esta o chapecoense print(f'{a:*^50}') times = ('Atletico-MG', 'Palmeiras', 'Flamengo', 'Fortaleza', 'Bragantino', 'Corinthians', 'Internac...
a77b21fedc47830648143ad3d5f808bd97b2e492
sophiejohnson26/comp171
/Lab4.py
1,719
4.15625
4
""" Author: Sophie Johnson Purpose: To make an ATM Date: Oct 4, 2017 """ running=True loggedIn= False userBalance=100 while (running): if(not loggedIn): print("You have to log in.") username= input("Enter your username: ") password= input("Enter your password: ") while (username !=...
351ee9f68c7fc74136dbc0361fa95feb7cf30088
hugopenna/PPZ
/lista I questao 09.py
180
3.671875
4
carro_dias = int(input('quantos dias o carro foi alugado')) carro_km = float(input('quantos km você rodou com o carro')) total = carro_dias * 60 + carro_km * 0.15 print (total)
e5f1817dec82e8ed7956d3372019cfeec36dea1f
tuipopenoe/DailyProgrammer
/Challenge129E_Longest_Two_Character_Substring/Challenge129E.py
766
3.796875
4
# Tui Popenoe # Challenge129E.py Longest Two-Character Sub-String import sys def twoCharacterSubString(input): currentLongest = input[:2] currentString = currentLongest if input[0] == input[1]: lastRun = input[:2] else: lastRun = input[1] for element in input[2:]: if elem...
795b0f1b053d4a39c9a0c075815b0bedd0a043ab
vtsartas/ejpython
/ejpy/cursopildoras/practica_listas.py
629
3.71875
4
miLista1=["Pepe","Luis","María","Jose"] print("Índice 2",miLista1[2]) print(miLista1[:]) print("Indice -3",miLista1[-3]) print(miLista1[1:3]) miLista1.append("Antonio") print(miLista1[:]) miLista1.append("Luis") print(miLista1.count("Luis")) miLista1.insert(2,"Sandra") miLista1.extend(["Manuel","Jorge",5,"Ana",True,7...
19bbe6d539ebab4cf4580e4abb978747f31c8164
shaunjayaraj/BackInGame
/learnpython/learnpython/plotting/compoundInterst.py
458
3.8125
4
#! /Users/shaunjayaraj/.pyenv/shims/python import matplotlib.pyplot as plt import numpy as np def plot(arr): plt.figure(1) plt.plot(arr, 'ko') plt.title("Compound interest growth") plt.xlabel("years") plt.ylabel("Principal") plt.show() principal = 100000 interestRate = 0.02 years = 20 value...
2a1cb1c7c8f0fe96515022def59427bcd9a14c8a
chrisxue815/leetcode_python
/problems/test_0131_recursive_backtrack.py
1,270
3.53125
4
import unittest import utils class Solution: def __init__(self): self.s = None self.n = 0 self.combination = [] self.result = [] def partition(self, s): """ :type s: str :rtype: List[List[str]] """ self.s = s self.n = len(s) ...
7f880d9075312c6a97067a8ec1e777bf3e5739d8
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex90.py
303
4.09375
4
'''Question: Write a Python program to create a copy of its own source code. ''' # Python code: print() print((lambda str='print(lambda str=%r: (str %% str))()': (str % str))()) print() '''Output sample: print(lambda str='print(lambda str=%r: (str %% str))()': (str % str))() '''
aef88b40dccf696e425803ddbda5803db37c1329
andriiburka/Web-Development-with-Python
/course3_python_advanced/Advanced EXAM/PRACTICE/2020.02.18 - 18 feb - 300/01_dating_app_ab_100%.py
2,868
3.578125
4
''' 100/100 The diff here is that i reverse 'Males List' at the begin That's why i'm using deque to popleft() first index That make sense.. ''' from collections import deque males = deque(map(int, input().split()[::-1])) females = deque(map(int, input().split())) matches = 0 while males or females: # Below or e...
4ea2e30b456bbfb49c64a911c43c7eb1985d8412
Xlszyp/hello
/使用线程/threading之添加线程.py
373
3.609375
4
#!/usr/bin/python3 #-*-coding:UTF-8-*- import threading def thread_job(): print('This is a thread of %s'%(threading.current_thread())) #print('count thread:',threading.active_count()) def main(): thread=threading.Thread(target=thread_job) #定义/添加线程 thread.start() #让线程开始工作 if __name__...
587c45c1cca05f101d1611bf5abf5cf683d60937
blackver69/Semester-5
/Computer Vision/lab/Session_1.py
749
3.78125
4
languages=['C++','Python','R'] my_list=[1,['red','green','blue'],(10,77),'Yes'] # print(my_list); # print(my_list[1]) # print(my_list[2]) # print(my_list[-2]) # print(my_list[1:4]) # print(my_list[:2]) # N="Yulianto" # M="Pribadi" # O="Karya" # X=N +" " +M+" "+O # print(X) # print(languages) # print(languages[0...
ae7c028cc9314b2cfc69d7838411c92d3e9ed5d0
lucasllimati/python-cursoemvideo
/Desafios/Mundo 2/ex041.py
802
3.984375
4
# EXERCÍCIO 41 # A Confederação Nacional de Natação precisa de um programa que leia o ano de nascimento de um atleta e mostre sua categoria, de acordo com a idade: # Até 9 anos: MIRIM # Até 14 anos: INFANTIL # Até 19 anos: JÚNIOR # Até 25 anos: SÊNIOR # Acima de 25 anos: MASTER from datetime import date anonasc = int...
2cdc5ce6d4f8b267368670bae41fc5bb04eb626c
dxt5754/Python-Labs
/Lab02-master/src/sunstar.py
3,057
4.34375
4
""" CSapx Lab 2: sunstar.py A program that draws a pattern in the turtle window using recursive techniques $ python3 sunstar.py The side length and levels are gotten from standard input. author: Dean Trivisani """ import turtle import math def draw_side(length, level, angle): """ Draws a side of a sunstar...
4e35052ea1675bb51d85f7eb9bd621f8f4576550
franky-codes/Py4E
/Ex2.3.py
157
4.0625
4
hours = input('How many hours did you work?: ') rate = input('What is your hourly rate?: ') pay = float(hours) * float(rate) print('You have earned: $',pay)
b4c3f0ba80f50ff132dfb2bc6aee6f9bc577a860
An421/Challenges
/MinMaxSum.py
487
4.0625
4
def minMaxSum(array): """ Finds the minimum and maximum value when adding 4 out of 5 items in the array Args: array (string): the array written as 5 numbers separated by spaces Returns: The minimum and maximum values separated by a space """ array = array.split() whole = 0 f...
37228cd6018c838786d33309c163551162723708
mxu007/leetcode
/888_Fair_Candy_Swap.py
2,223
3.921875
4
# Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has. # Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have the same total amount of candy. ...
f69d07099494d72f9237d255488b7bd5ae1c2c27
oc0de/pyEPI
/9/6.py
539
3.734375
4
from binary_tree_node import BinaryTreeNode def has_path_sum(tree, remaining_weight): if not tree: return False if not tree.left and not tree.right: return remaining_weight == tree.data return (has_path_sum(tree.left, remaining_weight - tree.data) or has_path_sum(tree.right, remaining_weight - ...
b13d034383541202b9365f08e004973b734c680e
hallzy/DailyInterviewProSolutions
/2019/09-september/08/solution.py
1,792
3.90625
4
# Need a function to ensure that if we are pushing the max value of the stack # onto the stack that the value added is always the largest in the stack # let x be input val, and maxVal be the current maximum # x > maxVal # x - maxVal > 0 # 2x - maxVal > x # If we insert 2x - maxVal instead, then it will always be...
aa9012b96a3533b782ecece4d6083fc7bb0c1b83
vibhore-vg/Learning-Python
/Python/Looping/Advanced/nestedForLoops.py
161
3.765625
4
# Printing pattern n=5 for i in range (1,n+1): for j in range (i,n): print "", for j in range (1,i+1): print j, print '\n'
29618a1c12a4e36729a00c4d74f06878e52058fc
sid-viscous/sqzmom-binance-bot
/bot/wenmoon/Trader.py
9,287
3.578125
4
import os import csv CSV_PATH = "trades.csv" class Trader: """This class handles decision making from the strategy, and places buy/sell orders. Attributes: config (Config): Instance of the Config class - holds settings for the bot. strategy (Strategy): An instance of the strategy class for th...
810816157c0722ec4bfa8c9e9081b46a54f1a026
935375572/git_learning
/08function/practice/cases3.py
943
3.75
4
def city_county(name, guojia): quanming = name + "," + guojia return quanming full_name = city_county(name="南京", guojia="中国") print(full_name) def make_album(name, zhuanjiming, gequshu=""): # 接收歌手的姓名和专辑名 geshou = {"姓名": name, "专辑名":zhuanjiming } if gequshu: geshou["歌曲数"] = gequshu; return ...
79b81d16b7d5f0dfe97aab3d9168f4621969efc3
memory90915yoyo/myNote
/lang/ds/leecode/7-reverse-integer.py
906
4
4
""" Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 """ class Solution: def reverse(self, x: 'int') -> 'int': # int32_max = 2 ** 31 - 1 # int32_min = - 2 ** 31 int32_max =...
b99405d56570ccffea49b9f23782c97c040bda37
DrwIRC/NetworksProject1
/mailClient.py
798
3.640625
4
import smtplib """ Part 2 Project 1 Computer Networks Names: Brendan Malone and Sam Cesario The python scrpit below implements a simple STMP mail client. The code was tested on a cell phone's 4G connection """ serverName = raw_input('Name of SMTP SERVER to Connect to: ') sendFrom = raw_input('Send From: ') sendTo = r...
b1b75d867ca757aa05c5af2e7d863f59e6f8c6dc
r-jw/CorePython
/第1章 正则表达式/1.3.4 使用match()方法匹配字符串.py
315
3.59375
4
import re m = re.match('foo', 'foo') #模式匹配字符串 if m is not None: print(m.group()) print(m) m = re.match('foo', 'bar') if m is not None: print(m.group()) #单行版本的if语句 m = re.match('foo', 'food on the table') print(m.group()) print(re.match('foo', 'food onthe table').group())
c009bd550c20853e0a2905c1252a372b2c7a7fef
thevalzo/Brexit-marketValue
/data/scripts/txt2sql_BING.py
1,567
3.515625
4
# retrive all the data positive_file = "BING_positive_words.txt" negative_file = "BING_negative_words.txt" positive_words = [] negative_words = [] positive_value = 2 negative_value = -2 #fill the positive words list for line in open(positive_file): if line[0] != ";" and line[0] != "\n": line = line.repla...
af9e2e917b3d3a6c038900901a78fdd464742695
hmc-koala-f17/CTCI-Edition-6-Solutions-in-Python
/stack/set_of_stacks.py
1,631
4.125
4
# Stack of Plates: Imagine a (literal) stack of plates. If the stack gets too high, it might topple. # Therefore, in real life, we would likely start a new stack when the previous stack exceeds some # threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be # composed of several stacks ...
29c6344be12b6d6d66afff7886438a1b0f64ae94
atakale7/leetcode
/Python/1.py
638
3.78125
4
""" Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input woud have exactly one solution, and you may not use the same element twice """ class Solution: def twoSum(self, nums, target): mydict = {} for ind,num in enum...
0faafb5f6626e0f75c065f57cad4bade16cddada
drownedout/data_structures_algorithms
/python/algorithms/arrays/largest_continuous_sum.py
684
4.1875
4
from typing import List """ =============== Largest Continuous Sum =============== Find the largest continuous sum within an array """ def largest_continuous_sum(arr: List[int]) -> int: # Check to see if array is length 0 if len(arr) == 0: return 0 # Max sum, current sum are equal to first ele...
680a6f5b0b563855ecc6c9748b8afa3b9a8f2182
shellucas/miniprojects
/guessnumber/number_guess.py
408
3.953125
4
import random low = 1 high = 100 answer = random.randint(low, high + 1) question = 'Guess a number between 1-100: ' tries = 0 guess = 0 while guess != answer: tries += 1 guess = int(input(question)) if guess < answer: print('Too low') if guess > answer: print('Too high') print('Cong...
14d247847a903bc738ebff34d5379e043592d646
disilvestrig/programmi-python
/timecalculator.py
1,447
3.84375
4
print("Benvenuto al calcolatore del tempo") a = int(input("Quale è la quantità da trasformare: 1)secondi 2)minuti 3)ore 4)giorni 5)anni ")) c = int(input("Inserisci quantità ")) if a == 1: b = int(input("In che grandezza vuoi trasformare:"+ " 1)minuti "+ "2)ore"+ " 3)giorni "+ "4)anni ")) if b == 1: print(c...
06024a105709624f19a9980e11b2fd81c7bc04ab
Aasthaengg/IBMdataset
/Python_codes/p02711/s628494349.py
128
3.53125
4
N = str(input()) for i, c in enumerate(list(N)): if c==str(7): print('Yes') break elif i==len(N)-1: print('No')
4cd7565aec193900840894d9834aa90b082e7737
edluffy/pythoncc
/message_names.py
513
3.71875
4
edward = "Hello me" print edward name = "edward lufadeju" print name.lower(), name.upper(), name.title() quote = "Albert Einstein once said, \"A person who never made a mistake never tried anything new.\"" print quote famous_person = "Albert Einstein" snipped_quote = " once said, \"A person who never made a mistake ...
2ddc401d10a19fa413d50233aaf7e5dc637afaa0
AhmedSoliman92/Password-Generator
/Password_Generator.py
1,726
3.890625
4
import string import random Letter=string.ascii_letters Number= string.digits Punctuation= string.punctuation #Determine the password length def password_length(): length= input("Please write the password length: ") return int(length) #Generate the password def password_generator(option,length=11): #gene...
7526d23816a14ce7a77bf4c3b5874b88c329bf95
HyeongbinMun/python
/chapter28/pro.py
198
4
4
with open('words.txt', 'r') as file: words = file.read().split('\n') for word in words: word = word.strip('\n') if list(word) == list(reversed(word)): print(word)
768ed9c1dc22f009df641a68dae81f4bfa112f8b
vamsichitturi472/Python_Practice
/Fun_Ones/Root_Finder.py
680
4.09375
4
from decimal import Decimal if __name__ == "__main__": num = Decimal(input("enter num : ")) root = Decimal(input("enter root : ")) mid_val = 0 if (root == 0): mid_val = 'undefined' else: start = 0 end = num result = 0 mid_val = 0 while (mid_val != ...
b46b2c330d5fc0b5ca8700e71d68c669955bc7cc
SimChoonYee/files_automation
/learn/test_snippets.py
541
3.78125
4
def plus(x): x = x + 1 return x def str_if_None(*args): # y = 10 # x = plus(x) # print(x) # return (y, x if x else "") for arg in args: if arg: return arg else: return "" res, res2 = str_if_None('a') print(res) print(res2) # def myfunc(a, b): # r...
e88e8faa41c0770d3ab3ac9e90f8b945908962c0
ksh0414/cotest
/greedy/greedy2.py
152
3.5625
4
nums = input() ans = 0 if nums[0] == '1' else 1 for x in nums: x = int(x) if x in (0, 1): ans += x else: ans *= x print(ans)
1af07f1e2741135cc7bd9690176043dd949a7acf
Mathesh099/Food-Blog-Backend
/Food Blog Backend/Stage 3.py
1,934
3.8125
4
import sqlite3 conn = sqlite3.connect("food_blog.db") cursor_name = conn.cursor() cursor_name.execute("CREATE TABLE meals(meal_id INTEGER primary key, meal_name TEXT not null unique)") cursor_name.execute("CREATE TABLE ingredients(ingredient_id INTEGER PRIMARY KEY, ingredient_name TEXT NOT NULL UNIQUE)") cursor_name.ex...
2ad077c4c9e4f8b34c2d7feba449e92b9a03bc10
georgelzh/Text-Spell-Checker
/spell_checker.py
3,355
4.03125
4
#!Python 3 # Spelling Checker # It receives the letters of a word and automatically corrects it. # Zhihong Li # 5/26/2019 # import sys, re inFile = sys.argv[1] # dictionary path textFile = sys.argv[2] # textFile path outputFile = sys.argv[3] # output path class Node(object): # create a node...
e5b02ee8fb9c637321146c6c4543a8db3fcda46a
simrit1/asimo
/Chap 5/5.14.11 12 Exercise.py
500
4.15625
4
#Exercise 5.14.11 12 OK def is_rightangled(): while True: a = int(input("Enter a length of a side: ")) b = int(input("Enter a length of a side: ")) c = int(input("Enter a length of a side: ")) if c == (a**2 + b**2)**0.5 or b == (a**2 + c**2)**0.5 or a == (c**2 + b**2)**0.5: ...
599f0869a9a45627d9cf507420e19c4ce3908da7
GeraldineE/Curso-python
/interfaces_graficas/tkinter/main.py
335
3.59375
4
from tkinter import * from tkinter import messagebox # Ventana principal # top = tkinter.Tk() # top.mainloop() # Botones top = Tk() top.geometry("100x100") def helloCallBack(): msg = messagebox.showinfo( "Hello Python", "Hello World") B = Button(top, text = "Hello", command = helloCallBack) B.place(x = 50,y = 50)...
77f248e68084924eef61e7cc15e4dfa561a72dbe
Ytr00m/hacktoberfest2020
/Codigos/InsertionSort.py
248
3.796875
4
def insertion_sort(lista): fim = len(lista) for i in range(1, fim): for k in range(i): if lista[i] < lista[k]: x = lista[i] del lista[i] lista.insert(k, x) return lista
3d2fcaef9c6bc424206fd6364ed18e1851b70f3e
piyush09/LeetCode
/Perfect Squares.py
1,620
3.75
4
""" Algo: Problem is similar to Fibonacci Number problem. Calculate a list of square numbers (i.e. square_nums) that is less than the given number n. dp[n] indicates that the perfect squares count of the given 'n' value Loop from the number 1 to n, to calculate the solution for each number i (i.e. nu...
f5c80d29ff9b0a2b139bea90f080f75614cd934d
Provinm/leetcode
/array/169.majority-element.py
859
3.578125
4
# # @lc app=leetcode id=169 lang=python3 # # [169] Majority Element # # https://leetcode.com/problems/majority-element/description/ # # algorithms # Easy (51.26%) # Total Accepted: 342.5K # Total Submissions: 668.2K # Testcase Example: '[3,2,3]' # # Given an array of size n, find the majority element. The majority ...
33000a8b2f8dd0b45d526e2f5984455c72378329
zzhyzzh/Leetcode
/leetcode-algorithms/728. Self Dividing Numbers/selfDividingNumbers.py
595
3.53125
4
class Solution(object): def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List[int] """ self_list = [] for i in range(left, right + 1): i_str = str(i) if "0" in i_str: continue ...
16593f3b9b3fd86e47147d265e85750bb8e8942c
allenxzy/Data-and-Structures-and-Alogrithms
/python_data/Chapter 1/P/P-1.35.py
450
3.53125
4
#-*-coding: utf-8 -*- """ The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided n, the number of people in the room, is more than 23. This property is not really a paradox, but many people find it surprising. Design a Python program that can te...
c5ba320c8984cf7d035ab73276076a7dc31b1aa3
TheTradingWarrior/DynamicProgramming---Coursera
/knapsack/dp_solver.py
2,543
3.65625
4
##### Dynamic Programming Solver ##### # Has complexity = item_count * capacity #Import modules from collections import namedtuple Item = namedtuple("Item", ['index', 'value', 'weight']) # Implement dynamic programming solution def solve_it(input_data): # parse the input lines = input_data.split('\n') fir...
5647745e5e01ed311690bfc0007700ca81e3c9b6
AmishaManga/PyTorch
/Tutorial_1.py
1,856
3.71875
4
from __future__ import print_function import torch import numpy as np # Construct a 5x3 matrix, uninitialized: x = torch.empty(5, 3) #print(x) # prints a matrix with values that are allocated in memory at the time # Construct a randomly initialized matrix: x = torch.rand(5, 3) #print(x) # randonly initialized # Co...
a673b69268ad78f8b2e5d29536e3c4803a24a5e9
inxiti/euler
/python/problem25.py
1,241
4.3125
4
#!/usr/bin/env python3 # # Problem 25 # # The Fibonacci sequence is defined by the recurrence relation: # # Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. # # Hence the first 12 terms will be: # # F1 = 1 # F2 = 1 # F3 = 2 # F4 = 3 # F5 = 5 # F6 = 8 # F7 = 13 # F8 = 21 # F9 = 34 # ...
ba87ab536ae45c01d6234e4b35277101b69d73df
madhavGSU/Data_Programming
/Assignment_2/chapter10_09.py
638
4.09375
4
''' Author: Sai Madhav Kasam Data Programming Assignment-1. ''' import math; def mean(lt): total=0; for num in lt: total+=num; avg=total/len(lt); print("The mean is: ", round(avg, 2)); return avg; def deviation(lt): avg=mean(lt); total=0; size=len(lt); for num in lt: total+=math.pow(num-avg, 2);...
63a90ec1a2145052c52b81c9fa050f884350556a
Prasheelsingh/tuts
/Python/Lesson3_if.py
102
3.71875
4
age = 17 if age > 24: print('Adult.') elif age < 12: print('Child.') else: print('Teen.')
8b405ad870af634dccec719bb960ff015bff015d
jandersson/Guess-the-number
/Guess.py
2,113
4.09375
4
__author__ = 'Jonas' #Guess the Number #Mini project 3 import random import simplegui import math secret_number = None player_guess = None max_range = 100 min_range = 0 num_guesses = None guesses_remaining = None def new_game(): """ This function starts a new game, computes a secret number, and computes ...
cb91b86c013bb7f70fcfb39ba37530b9234ec0e8
Kobzol/advent-of-code
/2022/day16.py
5,069
3.625
4
import collections import dataclasses from typing import FrozenSet, Optional, Tuple @dataclasses.dataclass class Valve: name: str flow_rate: int targets: Tuple[str] valves = {} with open("input.txt") as f: for line in f: line = line.strip() line = line[6:] name = line[:line.i...
42b6ac0ed4ff67082c0fa9e4de8ca35dc47af61e
CaoZewei/learnPython
/regularExpression/strongPasswprd.py
625
3.671875
4
import re def passwordCheck(str): if len(str)>= 8: psdRegex1 = re.compile(r'[A-Z]') psdRegex2 = re.compile(r'[a-z]') psdRegex3 = re.compile(r'[0-9]') if psdRegex1.search(str) == None: print("你的密码中没有大写字符!") elif psdRegex2.search(str) == None: ...
c648a11121c20a21f0d791ea78d532b5dfb05663
skwzrd/adventofcode2020
/day06/day06.py
1,203
3.53125
4
from pprint import pprint import re from typing import NamedTuple import os from collections import defaultdict raw_data = """abc a b c ab ac a a a a b""" def part1(raw_data): """For each group, count the number of questions to which anyone answered "yes". What is the sum of those counts?""" gro...
06c7e3935f5bbad0902f9bd371c9fe3a460939e5
InIronClad/python-project-6
/crismon_robert_hw6.py
2,201
4.125
4
#Assignment: (Homework #6 # #Completion Time: (4 hours) #In completing this program, I obtained help or worked with the following: #(Josh Shepherd, Zyante, python.org) from random import * #main function defined here def main(): print("*** Simple Blackjack ***") print("By Robert Crismon") play_gam...