blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5822fe85ee41a6405fafc5d7f65ce7852fd4adbc
yamato1992/at_coder
/virtual_contest/asakatsu0407/a.py
47
3.515625
4
s = list(input()) s[-1] = '5' print(''.join(s))
25aeeacb5b4806194a27c840ed0b84b4136f2f12
yamato1992/at_coder
/abc/abc154/e.py
293
3.703125
4
import itertools N = int(input()) K = int(input()) def factorial(n): if n == 1: return 1 return n * factorial(n -1) ans = 0 num = list(N) n = len(N) - K r = K - 1 if r == 0: ans += num[0] else: ans += num[] ans += (num[0] - 1) ans += 9 * K * (N - 1) print(n)
186333574e82f115175e57614cb974c88fa566c0
yamato1992/at_coder
/abc/abc071/b.py
144
3.578125
4
import string s = set(list(input())) ans = 'None' for c in string.ascii_lowercase: if not c in s: ans = c break print(ans)
4071993a5d74c2dd50cd339f3a12802f55f02b20
yamato1992/at_coder
/abc/abc045/b.py
121
3.6875
4
cards = {i: list(input()) for i in 'abc'} next = 'a' while cards[next]: next = cards[next].pop(0) print(next.upper())
2dcd7e58f22e5828a9cd7abfd815734717a3ed6c
yamato1992/at_coder
/abc/abc070/c.py
239
3.75
4
import fractions from functools import reduce def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(nums): return reduce(lcm_base, nums, 1) N = int(input()) times = [int(input()) for _ in range(N)] print(lcm(times))
62c797da9a79a68253db10c5477b841a1a3d4ac6
yamato1992/at_coder
/other/hitachi_programming_contest_2020/a.py
207
3.515625
4
S = list(input()) for i in range(0, len(S), 2): if i + 1 < len(S): if 'hi' != S[i] + S[i + 1]: print('No') exit() else: print('No') exit() print('Yes')
3899a3c306b5b82e46def12c31a4385a3e17f383
yonatanmk/python_files
/median.py
614
3.921875
4
def median(seq): seq.sort() print (seq) if len(seq) % 2 == 1: print ("Odd number of items") print ("the median position is %s" % (int(len(seq) / 2 + 1))) return seq[int(len(seq) / 2)] else: print ("Even number of items") print ("the median positions are %s and %s"...
275639872e195a018101ce04e80292586afa0d71
gavmcnamara/udacity-technichal-interview
/question2.py
1,292
4.34375
4
# Given a string a, find the longest palindromic # substring contained in a. Your function definition # should look like question2(a), and return a string. def question2(a): # if a has no value there is no runtime errors if a <= "": return a # Create an empty string to store pargest palendrome ...
ae82dafb224dd4a2eb9c1beab0aedc5b5a9de6cb
baxter-cs/AndroidDevelopment
/Python Scripts/double_space/aw.py
521
3.65625
4
#!python2 # This script removes double spaces from any input text file. # Here we open our input with the 'read' attribute not_fixed = open('input file', 'r') # And here we open our output with the 'write' attribute fixed = open('output file', 'w') # We initialize a buffer for holding processed lines temp_fix = "" for...
72615badf5ec6db55fc50c74d44744995293d75d
hosalli2704/pythonexamples
/str_ex_1.py
943
3.546875
4
#str -> class a = 10 b = int(10) c = 'person' d = "Person's" e = '''Person's he c"''' f = """person""" g = 'line1\ line 2' h = """line1 line 2 """ print(g) print(h) i = 'person\`s' # j=r'C:\Users\User\AppData\Local\Programs\Python\Python36-32\str_ex.py' k = 'WEL COME' print(k) print(len(k)) print(k[1]) print(k[1:6]...
9aeaf1340fe0eec01fcffbd181db87f0e5f4be89
JeromeJ/one-line-snake
/one-line-snake-unminified.py
6,512
3.546875
4
(lambda c, t, r: # Same as importing curses, time, random (lambda sc, dirs, **opt: # c.initscreen(), some dict, delay & starting_length ( # This is a "tuple * 0": This will execute (= evaluate) all instructions one after the other sc.nodelay(1), # Allows program to run even if there are no inputs from the pla...
717478203c8c9ddcfe74b5f0847b47d62664b221
biofoolgreen/leetcode
/457_circular_array_loop.py
2,517
3.546875
4
""" 存在一个不含 0 的 环形 数组 nums ,每个 nums[i] 都表示位于下标 i 的角色应该向前或向后移动的下标个数: 如果 nums[i] 是正数,向前 移动 nums[i] 步 如果 nums[i] 是负数,向后 移动 nums[i] 步 因为数组是 环形 的,所以可以假设从最后一个元素向前移动一步会到达第一个元素,而第一个元素向后移动一步会到达最后一个元素。 数组中的 循环 由长度为 k 的下标序列 seq : 遵循上述移动规则将导致重复下标序列 seq[0] -> seq[1] -> ... -> seq[k - 1] -> seq[0] -> ... 所有 nums[s...
77deb14a1d1c6b08e559103d0d3c456e4feb19c1
biofoolgreen/leetcode
/1104_path_in_zigzag_labelled_binary_tree.py
1,117
4.3125
4
""" 在一棵无限的二叉树上,每个节点都有两个子节点,树中的节点 逐行 依次按 “之” 字形进行标记。 如下图所示,在奇数行(即,第一行、第三行、第五行……)中,按从左到右的顺序进行标记; 而偶数行(即,第二行、第四行、第六行……)中,按从右到左的顺序进行标记。 给你树上某一个节点的标号 label,请你返回从根节点到该标号为 label 节点的路径,该路径是由途经的节点标号所组成的。 示例 1: 输入:label = 14 输出:[1,3,4,14] 示例 2: 输入:label = 26 输出:[1,2,6,10,26] 提示: 1 <= label <= 10^6 来源:力扣(LeetC...
f9444c3554b8f9c60038c2cc58cdc5a170c245cf
biofoolgreen/leetcode
/1846_maximum_element_after_decreasing_and_rearranging.py
2,224
3.734375
4
""" 给你一个正整数数组 arr 。请你对 arr 执行一些操作(也可以不进行任何操作),使得数组满足以下条件: arr 中 第一个 元素必须为 1 。 任意相邻两个元素的差的绝对值 小于等于 1 ,也就是说,对于任意的 1 <= i < arr.length (数组下标从 0 开始),都满足 abs(arr[i] - arr[i - 1]) <= 1 。abs(x) 为 x 的绝对值。 你可以执行以下 2 种操作任意次: 减小 arr 中任意元素的值,使其变为一个 更小的正整数 。 重新排列 arr 中的元素,你可以以任意顺序重新排列。 请你返回执行以上操作后,在满足前文所述的条件下,ar...
d2efcfe31998acd5afd2b1cc252c0012b9da6fd9
biofoolgreen/leetcode
/7_reverse_integer.py
938
3.59375
4
''' @Description: Easy @Version: @Author: liguoying@iiotos.com @Date: 2019-10-12 00:18:16 @LastEditTime: 2019-10-12 00:48:35 @LastEditors: ''' from typing import List ### 题目描述 """ 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: ------ 输入: 123 输出: 321 示例 2: ------ 输入: -123 输出: -321 示例 3: ------- 输入: 120 输出: 21 注意: 假设我...
feca4a8ff38699060110762f548176559d995b92
biofoolgreen/leetcode
/213_house_robber_ii.py
2,214
4.125
4
""" 你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都 围成一圈 ,这意味着第一个房屋和最后一个房屋是紧挨着的。同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警 。 给定一个代表每个房屋存放金额的非负整数数组,计算你 在不触动警报装置的情况下 ,能够偷窃到的最高金额。   示例 1: 输入:nums = [2,3,2] 输出:3 解释:你不能先偷窃 1 号房屋(金额 = 2),然后偷窃 3 号房屋(金额 = 2), 因为他们是相邻的。 示例 2: 输入:nums = [1,2,3,1] 输出:4 解释:你可以先偷窃 1 号房屋(金额 = ...
abb85c52d2964e0cf6be453b663769af5aafca46
biofoolgreen/leetcode
/1049_last_stone_weight_ii.py
3,139
3.875
4
""" 有一堆石头,用整数数组 stones 表示。其中 stones[i] 表示第 i 块石头的重量。 每一回合,从中选出任意两块石头,然后将它们一起粉碎。假设石头的重量分别为 x 和 y,且 x <= y。那么粉碎的可能结果如下: 如果 x == y,那么两块石头都会被完全粉碎; 如果 x != y,那么重量为 x 的石头将会完全粉碎,而重量为 y 的石头新重量为 y-x。 最后,最多只会剩下一块 石头。返回此石头 最小的可能重量 。如果没有石头剩下,就返回 0。   示例 1: 输入:stones = [2,7,4,1,8,1] 输出:1 解释: 组合 2 和 4,得到 2,所以数组转化为 [2,7,1,8,1], ...
8934ae26b069aff2fccc9ea3861c29c2c081b08e
JASTYN/pythonmaster
/datastructures/trees/trie/__init__.py
1,557
3.859375
4
from collections import defaultdict from typing import List class TrieNode(object): def __init__(self, char: str): self.char = char self.children = defaultdict(TrieNode) self.is_end = False class Trie(object): def __init__(self): self.root = TrieNode("") def insert(self,...
43c85d18f18f725909559a5d89b42a65b46acb33
chelseadole/data-structures
/src/bubblesort.py
1,337
4.15625
4
"""Implementation of Bubble Sort in Python.""" def bubblesort(lst): """Bubble sorting algorithm.""" if isinstance(lst, list): for i in range(len(lst)): for j in range(len(lst) - 1, i, -1): if lst[j] < lst[j - 1]: lst[j], lst[j - 1] = lst[j - 1], lst[j] ...
d439816559211f77663ae03082e0c76cbe18eff8
LINNOOB/python_learn
/test.py
254
4.1875
4
#!/usr/local/bin/python3 list1 = [1,2,[3,4,[6,7]]] print(list1) def print_item(the_list): if (isinstance(the_list,list)): for m in the_list: print_item(m) else: print(the_list) for i in list1: print_item(i)
d9803458e01d8257ec9a65142f0dcc50bc16525b
RedSnake239036/HomeworkNeuro
/line.py
1,583
3.828125
4
def correct_input(): while True: try: crds1 = (float(input()), float(input()), float(input())) crds2 = (float(input()), float(input()), float(input())) return (crds1, crds2) except: print('Что-то пошло не так') continue #((x1, y1, z1), ...
b8c23e5c754b0f2501e83621fc2c3e93379373a3
tomal123bd/Programming
/Finding_Server_info_GUI.py
2,250
3.875
4
#this programme used to find out server address of any ip and uses tkinter gui #information will be accessed via ip-api.com from tkinter import* import requests from requests import get import socket import xml.etree.ElementTree as ET from tkinter import messagebox count=0 myText=None root=None result=None get_info=Non...
02d157f88a9cc6eeb29a42b08f91422e2728b268
ElisonSherton/Photomosaic
/scripts/center_crop.py
564
3.53125
4
import PIL.Image def center_crop(img, new_w, new_h): current_w, current_h = img.size # Make sure the new width and new height are smaller than the original image # assert current_w > new_w # assert current_h > new_h # Compute the co-ordinates of the left top and right bottom coordinates left ...
cfd92acd6e2a3213f178bb7a508240d51aa9d483
andrew-ge-wu/mm
/CUSTOM/lstm-fraud/2/resource/examples/keras_fit_generator.py
2,314
4.03125
4
""" Use a pipeline to feature eng. Fit a keras model using model.fit_generator. """ import pandas as pd from keras import layers, models from keras.utils import to_categorical from sklearn.metrics import confusion_matrix from sklearn.preprocessing import StandardScaler from iterators import CSVIterator from pipeline i...
ab0391fca94210e3ef2d7c7407970d4ac2c19f8c
millioncloud/helloGithub
/src/test-002.py
1,479
3.78125
4
#coding=utf-8 from string import lower import os def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n return sum def person(name, age, **kw): if 'city' in kw: # 有city参数 pass if 'job' in kw: # 有job参数 pass print('name:', name, 'age:', age, 'other:...
2189ca6602abb0cc7cc66d02aacc09f2feba3ea2
lucasc3275/CTI-110
/P4T2_Bug Collector_LucasChristopher.py
564
4.28125
4
#This program keeps a running total of bugs collected over a 7 day period #March 20, 2020 #CTI-110 P4T2-Bug Collector #Christopher Lucas #set accumulator to 0 and assign variable "total_bugs" #for 7 days: prompt user to enter the number of bugs collected each day #add the daily number of bugs to the accumulator...
a4928145585cffa592fb2c13492f1fac6fd6d767
lucasc3275/CTI-110
/P5HW2_Part1_Math Quiz_LucasChristopher.py
1,066
4.25
4
#This program will ask the user for the sum of 2 random numbers and advise if correct or incorrect. #April 19, 2020 #CTI-110 P5HW2-Part1-Math Quiz #Christopher Lucas #Define main function #Generate 2 numbers and assign variables to each #add the 2 numbers and assign variable 'total' #display the nu...
4a53fc4b35a03d6455eafbff683e5d96ac4c4944
A-Kryston/ISM-4930-Python-Public
/Py_Assignment_1_Iterations-For-Loop.py
690
4.0625
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: # Andrea Kryston # Assignment 1 - Iterations, For Loop # September 29, 2019 # This script increases salaries for five of the top performing associates; # In reality, a much longer list of all employees' salaries could be used, which would be an even better use of the ...
f4c8c6d5696804fca33eae2b6a31d4c545d3657d
sparshjaincs/Python-program-bank
/source code/Programs/Python/Programs21.py
111
3.578125
4
l=[i for i in range(1,6)] #list comprehension print(list(map(lambda x:x*x,l))) print("Press Enter") input()
f9b50faab3a05b16b9c20170f4146860cad3b459
sparshjaincs/Python-program-bank
/source code/Programs/Python/Programs4.py
176
3.9375
4
def GCD(x,y): if y==0: return x else: return GCD(y,x%y) a,b=map(int,input("Enter two integer seperated by space:").split()) print(GCD(a,b)) print("Press Enter") input()
e0bffd7d2797a2c4fab82fbc4d1ed97ce34c898b
VuPhan99/AI
/30-08-2019/bai6.py
313
4.09375
4
def count_characters(sentence): dictinary = {} for charaters in sentence: Keys = dictinary Keys() if charaters in Keys: dictinary[charaters]+ =1 else dictinary[charaters] =1 return dictinary sentence = input('enter your number') count_characters (sentence)
33a0b53e9694a660392fe0476b71d1acce712b9c
lhcaleo/CodingChallenges
/Kattis_Problems/commercials.py
569
3.5
4
# maximum subarray prolbem # https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/ # https://open.kattis.com/problems/commercials def commercials_260711526(): N , P= [int(x) for x in input().split()] # profit = income - cost sequences = list(map(lambda z: int(z) - P, input().split())) max_so_far = max_en...
f68428bc06a89bc588a22f62a5ebf6152c66acef
kazlewis/bmi203_finalproject
/bmi203fp/methods.py
13,602
3.703125
4
import numpy as np import random def sigmoid(x): # Definition of sigmoid return 1 / (1 + np.exp(-x)) def dsigmoid(y): # definition of derivative of sigmoid, in a format to solve incompatability issues with numpy matricies return np.multiply(y, 1.0 - y) def train_autoencoder(input_data, desired_output, input_...
b13c8cfae38b2ecacbd926dee29bd42bb0de9e54
tecki/metaclasses
/metaclass/__init__.py
3,969
4.5625
5
""" :mod:`metaclass` -- Writing and using metaclasses ================================================= Metaclasses are a very powerful tool in Python. You can control the entire class creation process with them. Most of the time, however, they are too powerful. This module helps you to use some of the advantages of ...
b9d6b42daa29d7574747ab7af5f527d793c3f720
MDCurrent/DailyProgrammer
/DailyProgrammer/3.21.2019/leapyears.py
1,047
3.9375
4
def isLeapyear(n): '''Params: Integer N, Returns if N is a leap year based on revised Julian calendar''' if n % 4 == 0 and n % 100 != 0 or n % 4 == 0 and n % 900 in (200, 600): return True else: return False def leaps(start, end): count = 0 for i in range(start, end): if i...
787ee025dfc80f312770c890c074dedfad764b1e
elhadjmb/fivedd
/app/core/file.py
523
3.53125
4
""" file: file class (if there are files as features or just to store the file) """ import os.path class File: def __init__(self, path="/"): self.path = r"{}".format(path) # if Checker.path(path) else Exceptions.flag(type=Dictionary.Internal()) self.file_name = os.path.basename(self.path) ...
1ab7a0a1b0aa32c5f71d1482cc8b4be310db0b48
anurag03/HackerEarth
/trailling-zeros.py
353
4.25
4
#!/usr/bin/python value = int(raw_input("Enter a value between 1 and 1000 :")) while value < 1 or value > 1000: print "You have entered a invalid value" value = int(raw_input("Enter the a value between 1 and 1000 :")) div = 5 initial_value = 0 while value > div: initial_value = initial_value + (value / div) div = d...
a060b516277511369292eb1df8cc82a7d8641584
ArturoCamacho0/DataScience
/1. Pensamiento Computacional con Python/Programas numéricos/menu_numericos.py
2,010
3.671875
4
import os # Ennumeración exhaustiva def enumeracion(objetivo): respuesta = 0 print('ENNUMERACIÓN EXHAUSTIVA\n') while respuesta**2 < objetivo: respuesta += 1 if respuesta**2 == objetivo: print(f'La raíz cuadrada de {objetivo} es {respuesta}') else: print(f'{objetivo} no tiene una raíz exacta') # Aproxim...
c90baf06f4a37613d6cf4880fce73ae5082d1c41
ArturoCamacho0/DataScience
/2. POO y algoritmos con Python/Optimizacion/problema_morral.py
1,459
4.03125
4
""" El problema del morral nos plantea que tenemos un morral en donde debemos meter todos los objetos posibles sin pasar la capacidad del morral generando el máximo valor posible dentro """ # Primero definimos nuestra función def morral(morral_tam, pesos, valores, n): # Ahora comprobamos que no se nos hayan acabado l...
c6cade01178eb3393cc62855fcfe1102848da317
ArturoCamacho0/DataScience
/2. POO y algoritmos con Python/Programación Orientada a Objetos/tipos_de_datos.py
465
3.875
4
class Coordenada: def __init__(self, x, y): self.x = x self.y = y def distancia(self, otra_coordenada): x_diff = (self.x - otra_coordenada.x)**2 y_diff = (self.y - otra_coordenada.y)**2 return (x_diff - y_diff)**0.5 if __name__ == '__main__': coord_1 = Coordenada(2, 15) coord_2 = Coordenada(5, 20) di...
21d584a7c209584199f9f0789442dbbd21063b76
cs-richardson/encryption-jelchakieh21
/caesar.py
1,257
4.09375
4
#this code takes the user's plaintext and converts it into Caesars cipher with a shift of 1. This code was created by Julian. plainText = str(input("Please enter your plaintext: ")) alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v...
9de1e5145f5005797b17dfabb04dda8361286edd
nawawee/python
/UDPChat_Python/client.py
579
3.546875
4
#Client from socket import * host = raw_input("Enter Server IP: ") port = input("Enter Server Port: ") bufsize = 1024 sock = (host,port) print("*************Client side*************") server = socket(AF_INET,SOCK_DGRAM) print("Socket server created:", sock) print('.................Connection established to server:',...
73f5e478bd65a0e6a10af79f9ba58abdf298f88f
alimozzamandurjoy/Skill-Jobs-Assignment
/Assignment1/Assignment1_4.py
133
3.65625
4
#Write a Python program to remove duplicates from a list. l = [2, 4, 4,4,4,10,30,40,70,30,10, 20, 5, 2, 20, 4] print(list(set(l)))
12cc77796480628610522fff0036402b75ae8a65
rohithrajreganti/BugFreeCodes
/BugFreeCodes/CodeChef/Easy/Lapindrome.py
727
3.546875
4
""" Author - Rohith Raj R email - rohithrajreganti@gmail.com Date - 8/01/2017 Problem CODE - LAPIN CODE CHEF """ def tester(s1,s2): l1=0 for i in s1: if(s1.count(i)==s2.count(i)): l1+=1 if(len(s1)==l1): return True else: return False test=int(raw_inp...
5289c727009d52a7f5a17aa87dfac417f89ad95a
Nahid015/Python
/Python Lab/Code11.py
575
3.8125
4
c = 'Y' while True: if c == 'Y': x = input('Enter your marks : ') x = int(x) if x >= 80: print('A+') elif x >= 75 and x < 80: print('A') elif x >= 70 and x < 75: print('A-') elif x >= 65 and x < 70: print...
a65fe5fd8753f56048efda811ead69c07f58cc72
ssurenr/30-day-challenge-hackerrank
/Challenge8.py
414
3.75
4
#!/usr/bin/env python3 import sys entry_count = int(input()) entries = {} for count in range(entry_count): response = input().split(" ") entries[response[0]] = response[1] lookup_list = [] lookup_entries = str(sys.stdin.read()).splitlines() count = 0 for lookup in lookup_entries: if lookup in entries: ...
7e430377277f89c36f570e38feb3cb02daf5f102
stanleychilton/portfolio
/Stock_market/python_scripts/test.py
504
3.6875
4
from datetime import datetime buy = 1 price = 1.2 print((buy+(buy*.1))) if (buy+(buy*.1)) <= price: print("true") else: print("false") # datetime object containing current date and time now = datetime.now() print(now) # dd/mm/YY H:M:S dt_string = now.strftime("%H%M") b = '2030' ...
1d3bf3681be44654a488ab97b48eb17ae91f75c5
stanleychilton/portfolio
/exmaple files/new projects/menu file.py
795
4.03125
4
options = ["A - addition", "B - subtraction", "Q - quit"] def addition(num1, num2): return num1 + num2 def subtraction(num1, num2): return num1 - num2 def get_inputs(): number1 = int(input("input first number: ")) number2 = int(input("input second number: ")) return number1, number2 while Tr...
50939cded00c7c158acaa3a0907b535782dc0185
stanleychilton/portfolio
/exmaple files/webassignment/server.py
4,988
3.640625
4
# This is a very basic HTTP server which listens on port 8080, # and serves the same response messages regardless of the browser's request. It runs on python v3 # Usage: execute this program, open your browser (preferably chrome) and type http://servername:8080 # e.g. if server.py and broswer are running on the same ma...
ab71e1c6c77f9e9bae564a61969a38f95417228d
stanleychilton/portfolio
/exmaple files/tutorials/171 tut 11/tutorial 11.py
1,267
3.796875
4
# d = {} # # count = 1 # # for x in range(3): # emp = {} # userin = input("please input an item") # emp["items"] = userin # # d[count] = emp # count += 1 # # userkey = int(input()) # print(d[userkey]["items"]) # # for i in d: # print(d[i]) # # d[2] = {"something":"new"} # print(d) # # del(d[2]) ...
00de541ef09b05934b46c303cb87526f2af47ed6
stanleychilton/portfolio
/exmaple files/comp/shootout.py
132
3.625
4
t = int(input("")) for i in range(t): h = list(map(int, input().split())) if h[0] >= 2 and h[0] <= 13: while True:
5af63f30f4257ba1073a7f626c3f7ef57ec76a9b
Aziz1Diallo/python
/maximum.py
956
3.84375
4
a=int(input("type the first digit : ")) b=int(input("type the second digit : ")) c=int(input("type the third digit : ")) d=int(input("type the fourth digit : ")) e=int(input("type the fifth digit : ")) if a<b: max1=b else : max1=a if c<d: max2=d else: max2=c if max1<e: max3=e else : max3=max1 if max3<max2: p...
3068a45eb293eaa63cc7c573e68ceb10f7fc59c7
Aziz1Diallo/python
/primenumb.py
163
3.765625
4
attempt=0 n=0 while n<1 or n>10: n=eval(input('type a value from 1 to 10 ')) attempt+=1 tries="try" if attempt==1 else "tries" print(attempt," ",tries)
fb52c056b12cba5cabdc63c36de85ebc649172be
gabipires/PythonBrasilExercicios
/01.Estrutura_Sequencial/09.farenheit_celsius.py
162
3.9375
4
farenheit = int(input("Informe a temperatura em Farenheit: ")) celsius = round((5 * (farenheit - 32)/9.0),2) print(farenheit, "ºF é igual a", celsius, "ºC")
717279225d09a3eb47125bfa99432376f8e888f8
gabipires/PythonBrasilExercicios
/01.Estrutura_Sequencial/10.celsius_farenheit.py
154
3.859375
4
celsius = int(input("Informe a temperatura em Celsius: ")) farenheit = ((celsius / 5.0) * 9.0) + 32.0 print(celsius, "ºC é igual a", farenheit, "ºF")
a3a98d736b88befca34870c0b862de206b88d43c
AmmarSaqib/IntroToAI
/lab_1/lab_1_b.py
2,806
4.59375
5
""" Lab: 1 Task: B Your task is to implement a basic Priority Queue, using Arrays, in python in an OOP fashion. Priority Queue is an extension of queue with following properties: -> Every item has a priority associated with it. -> An element with high priority is dequeued before an element with low prio...
072ce83da45d911a6115a50a70c670e8fa58c72c
Geoff-Lucas/Challenge_Problems
/index_finder.py
1,252
3.890625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 19 22:07:19 2021 @author: Geoff This problem was asked by Dropbox. Given a string s and a list of words words, where each word is the same length, find all starting indices of substrings in s that is a concatenation of every word in words exactly once. For example, g...
0592b629bf3581bdd6f5dd2589f9767b9608d0ff
LeonardoVieiraNeto/30Days_of_Python
/Day1.py
10,921
3.703125
4
import time useSleep = 0 '''Aula 1 ''' '''30 Days of Python''' name = input('What is your name?') #promts user input in console and store in a variable print('Welcome to the world of Python ' + name) # prints to console '''Aula 2 ''' '''30 Days of Python''' num = 100 # variable assignement print(type(num)) # <cla...
fc520fa664145410052a23ab1792f543988b27db
Asobu77/python_basic
/Section_3/9.py
266
3.703125
4
# printで出力 print('Hi', 'Mike' ,sep=',', end='\n') print('Hi', 'Mike' ,sep=',', end='\n') # print関数内でsepを指定することで、引数をつなげることができる # print関数内でendを指定することで、出力末尾を指定できる
8540d2996faf192cb62731496d1cd28bd6d86dd3
Asobu77/python_basic
/Section_5/45.py
229
4.25
4
# enumerate関数 for fruit in ['apple', 'banana', 'orange']: print(fruit) # enumerate関数を使うことでindexを入れることができる for i, fruit in enumerate(['apple', 'banana', 'orange']): print(i, fruit)
21bc3244e05cdbf5b4f487e5c80347e5f20a9beb
Asobu77/python_basic
/Section_5/33.py
234
4
4
# if文 # インデント依存 x = -10 if x < 0: print('negative') elif x == 0: print('zero') else: print('positive') # ifのネスト a = 5 b = 10 if a < 10: print('a < 10') if b < 20: print('b < 20')
c06fddb00c692f2a229701fbacda656694331599
Asobu77/python_basic
/Section_5/63.py
129
3.71875
4
# ジェネレータ内包表記 def g(): for i in range(10): yield i g = g() g = (i for i in range(10)) print(g)
eb1a25fa73437f52dae4ebcef6176b26db4c9cfb
Asobu77/python_basic
/Section_3/10.py
500
4.125
4
# 数値 print(2 + 2) print(2 - 2) print(2 * 2) print(4 - 2 * 2) print(type(1.6)) print(type(1)) print(17 / 2) print(17 // 2) print(17 % 2) print(2 ** 2) print(round(10 / 3, 3)) # round()関数 少数第何位を第二引数で指定してそれ以下ま丸める import math # import math サインコサインなど、数式が使用できる result = math.sqrt(25) print(result) print(help(math)) # help...
356eb0006c732032403aa0fcb8c27ed1073397be
Asobu77/python_basic
/Section_4/30.py
280
3.90625
4
my_friends = {'A', 'B', 'C'} A_friends = {'B', 'D', 'E', 'F'} print(my_friends & A_friends) f = ['apple', 'banana', 'apple', 'banana'] print(f) # setはリストを集合に変換する # ユニークな要素を表示したい場合等に使える kind = set(f) print(kind)
a4064898e0b13ec7b8e70b994d7fd1f1a7705354
Vylmion/PDF-Watermarker
/watermarkPDFfiles.py
671
3.59375
4
from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter # How to watermark PDF pages bellow: pdf_file = "super.pdf" watermark = "wtr.pdf" merged_file = "merged.pdf" with open(pdf_file, "rb") as input_file, open(watermark, "rb") as watermark_file: input_pdf = PdfFileReader(input_file) watermark_pdf = P...
0e52d3c0e24e81e0afb04cf29e6b840d59caf808
wenquanlu/DP-Operations-Research-App
/app.py
1,886
3.96875
4
from resource import resource_allocation from knapsack import knapsack_problem print("#######\n" + "# # ##### ###### ##### ## ##### # #### # # ####\n"+ "# # # # # # # # # # # # # ## # #\n"+ "# # # # ##### ...
f98f41de4bc3a470a2956038ab4c1bf8f8c47f2a
Kagirim/FamilyTree
/FamilyTree.py
4,443
3.96875
4
from Person import Person import pickle class FamilyTree: def __init__(self): self.adjList = dict() """ Given a person, this method returns the parent, if its a root of the familyTree returns None """ def findParent(self,person): if person is None: return None for parent, children i...
aa7212d83e430c80e9de6bb29263e15d6c276210
toxicthunder69/Selection
/Exercises/Date2.py
609
4.09375
4
#Joseph Everden #02/10/14 #Date Program 2 day_input = int(input("Enter the day (dd): ")) month_input = int(input("Enter the month (m): ")) year_input = int(input("Enter the year (yy): ")) month = ["January","February","March","April","May","June","July","August","September","October","November","December"] mon...
c542dc114fb96da551c7402d5d24156d4b19b716
antonshelepov/algorithms
/linkedLists/singlyLinkedListCycleCheck.py
1,097
3.734375
4
# given a singly linked list, write a function which takes in the first node in a singly linked list and returns a boolean indicating if the linked list contains a "cycle" from nose.tools import assert_equal class Node(object): def __init__(self,value): self.value = value self.nextnode = Non...
ebeeec2eaba00fc1ec90f1f04e7cb807c45b3ceb
antonshelepov/algorithms
/recursion/memoization.py
760
4.1875
4
# Memoization refers to remembering results of method calls based on the method inputs and then returning the remembered result rather than computing the result again #factorial_memo = {} # #def factorial(k): # # if k < 2: # return 1 # # if not k in factorial_memo: # factorial_memo[k] = k * factori...
8a170f930a85dc7906ef66c166cfc2cb7e6a1030
antonshelepov/algorithms
/trees/treeWithTreelib.py
485
3.625
4
# this is an example of tree implementation using treelib package # https://treelib.readthedocs.io/en/latest/ # https://medium.com/swlh/making-data-trees-in-python-3a3ceb050cfd from treelib import Node, Tree tree = Tree() tree.create_node("CEO","CEO") #root tree.create_node("VP_1","VP_1",parent="CEO" ) tree.create_no...
3602fedea3326b6971265742d048a40a3497b2d1
GlitchWalker/Learn-Python-3-The-Hard-Way---Exercises
/ex19.py
3,350
4.34375
4
## Defines function "cheese_and_crackers" as well as defining arguments it expects def cheese_and_crackers(cheese_count, boxes_of_crackers): ## Prints text with {cheese_count} inline print(f"You have {cheese_count} cheeses!") ## Prints text with {boxes_of_crackers} inline print(f"You have {boxes_of_crac...
8a1efa620fed84389b71add42ab69a2f37e6686f
GlitchWalker/Learn-Python-3-The-Hard-Way---Exercises
/ex20.py
1,726
4.28125
4
# Imports feature argv from module sys from sys import argv # defines this script name and input_file as two arguments script, input_file = argv # defines function print_all, defines argument f from given argument def print_all(file): # reads file f and prints result to end of file print(file.read()) # defin...
bd153e4ad482772a313697169ea5429aac47c1d1
bpsom/cs7641
/project1/SUDecisionTree.py
2,986
3.5625
4
#!/usr/bin/env python3 import numpy as np """ Import the DecisionTreeClassifier model. """ #Import the DecisionTreeClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.tree import DecisionTreeRegressor class SUDecisionTree(object): """ This is a Decision Tree Learner - Using Correlation a...
94f5e5f3c6380f9a6ce1c8e30629c40988db5b0f
kmad1729/python_notes
/metaprogramming/descriptor_demo.py
1,120
3.78125
4
'Simple script showing how to use descriptors for type checking' class descriptor: def __init__(self, name, inst_typ): self.name = name self.inst_type = inst_typ def __get__(self, instance, cls): print("getting inst var", self.name) return instance.__dict__[self.name] def...
de78ff8ef86f33a33504603edcb636156b464f65
kmad1729/python_notes
/gen_progs/disp_retweets.py
1,476
3.546875
4
#!/usr/bin/env python3 '''Display the number of retweets a tweet gets using 4 characters total with max one position past the decimal point in US and Indonesian standard (eg 1.5 b, 3.2k) 100 -> 100 1000 -> 1k 9999 -> 9.9k 10,000 -> 10k 50,000 -> 50k 99,999 -> 99.9k 100,000 -> 100k 500,000 -> 500k 999,999 -> 999k 1,...
a57097749a39eb8fba11fa618a9e020af9597652
aixocm/algorithms
/algorithms/fenzhi.py
559
3.671875
4
def karatsuba(num1,num2): if num1 <10 or num2 < 10: return num1*num2 size1 = len(str(num1)) size2 = len(str(num2)) half = int(max(size1,size2) / 2) a = int(str(num1)[0:half]) b = int(str(num1)[size1-half:]) c = int(str(num2)[0:half]) d ...
18af117b6c7dae3b16b7e04f2c36b7f42b0c8003
zova21git/learning-git
/utils.py
3,794
3.890625
4
import tensorflow as tf from tensorflow import keras ###Use the "ImageDataGenerator()" class from keras.processing.image to build out an instance called "train_datagen" with the following parameters: train_datagen = tf.keras.preprocessing.image.ImageDataGenerator( rescale = 1./255, shear_range = 0.2, zoom_...
6443988cbdd9591d12a40c631c4d399836a37ed5
ineq-lab/Nauka-python
/Lokata.py
574
3.640625
4
# -*- coding: utf8 -*- start = int(input("stan konta? ")) rate = int(input("Ile lat na lokacie? ")) n = float(input("Stopa oprocentowania w skali roku? ")) wynik = start*(1+rate*n) print("Po {} latach kapitał będzie wynosił {:.2f}zł" .format(rate, wynik)) start = float(input("Stan początkowy konta wynosi: "...
fee701b197479aed11241d176ebaca32477d1792
devanshi16/hackerRank-NLP
/trigram.py
462
3.78125
4
import sys from collections import Counter from functools import reduce from operator import iconcat def Trigrams(sentence): words = sentence.split() return [" ".join(words[i:i+3]) for i in range(len(words)-2)] if __name__ == '__main__': text = sys.stdin.read().lower().split('.') #finish the input by ente...
7d5a9515611a09a9781fd8894dbd09135c08d50b
curiousTC/AoC2020
/Day2/day2.py
1,692
3.578125
4
def findValidPassword(inputList): validPw = 0 for line in inputList: val = line.replace(":"," ").split() #print(f'Password policy: {val[0]}, character: {val[1]}, password: {val[2]}') countChar = 0 for char in val[2]: if char == val[1]: countChar += 1...
1e6e6647f77864a8c22e802be8770bce62e35ed9
lac2860/python-basics
/main.py
272
4.125
4
first_name = input("What is your first name? ") print("Hello,",first_name) if first_name == "Craig": print(first_name,"is learning python") else: print("You should totally learn Python, {}!".format(first_name)) print("Have a great day {}!".format(first_name))
d5f4c9d60dad1ffc9634109f78c86e40569d982a
robophilosopher/lingo
/parser.py
1,183
3.765625
4
NUM = "NUM" STR = "STR" SYM = "SYM" LBR = "(" RBR = ")" class Parser: def __init__(self, tokens): self.tokens = tokens self.cursor = 0 def lookahead(self): return self.tokens[self.cursor][0] def list(self): self.consume(LBR) ret = self.elements() self.con...
bf7964f075d1e13ba469e3017b2527989d38584f
cxy592394546/LeetCode_py
/Code/Daily/2105/Week6/31/342.py
239
3.796875
4
from math import sqrt class Solution: def isPowerOfFour(self, n: int) -> bool: if n < 1: return False val = int(sqrt(n)) if val ** 2 != n: return False return val == val & -val
0fa48df0d55d385e27c691daf154f3309c07f193
cxy592394546/LeetCode_py
/Code/Other/GG/O/56_i.py
476
3.625
4
from typing import List class Solution: def singleNumbers(self, nums: List[int]) -> List[int]: num = 0 for item in nums: num ^= item li = num & -num ret = [0, 0] for item in nums: if item & li == li: ret[0] ^= item else: ...
d28f8570a48cb1e57623c412e8077ad6e7dfa015
cxy592394546/LeetCode_py
/Code/Daily/2102/210212/119.py
486
3.640625
4
from typing import List def func(rowIndex: int) -> List: rlist = [] for i in range(rowIndex + 1): if i == 0: rlist.append(1) elif i > rowIndex / 2: rlist.append(rlist[rowIndex - i]) else: j = 0 val = 1 while j != i: ...
35cd0b9a6cb0201448bd933c6448bb6b99c729a9
cxy592394546/LeetCode_py
/Code/Other/GG/G/04/04.05.py
803
3.671875
4
import collections class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isValidBST(self, root: TreeNode) -> bool: if not root: return True li = collections.deque([[root, -float("inf"), float("inf")]]) ...
a5be8fcf89698fd464fbf5b892d3800636a44dad
cxy592394546/LeetCode_py
/Code/Daily/2105/Week3/10-tree/872.py
697
3.78125
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: def preorder(node, li): if not node: return ...
37c49f5673080539e81df1a060ec0740703b14a9
cxy592394546/LeetCode_py
/Code/Other/GG/O/y60.py
411
3.625
4
from typing import List class Solution: def dicesProbability(self, n: int) -> List[float]: li = [1/6 for _ in range(6)] for i in range(2, n + 1): tmp = [0 for _ in range(5 * i + 1)] for j in range(len(li)): for k in range(6): tmp[j + k] +...
943e4364138c6db843eda9d320afe3eb17f1547b
cxy592394546/LeetCode_py
/Code/Daily/2103/14/706.py
1,090
3.578125
4
class MyHashMap: def __init__(self): self.table = [[] for _ in range(997)] """ Initialize your data structure here. """ def put(self, key: int, value: int) -> None: for item in self.table[key % 997]: if item[0] == key: item[1] = value ...
3d1f79e677deb02963235c690e7a180cbffdfc1c
cxy592394546/LeetCode_py
/Code/Daily/2103/03/338.py
259
3.578125
4
from typing import List def func(num: int) -> List[int]: ret = [0] gap = 1 for i in range(1, num + 1): ret.append(ret[i - gap] + 1) if i == gap: gap *= 2 return ret if __name__ == '__main__': print(func(5))
2f0b1c7b44a79695f2f7bd21efe0f4413e646c5a
cxy592394546/LeetCode_py
/Code/Other/GG/G/03/03.05.py
700
3.78125
4
class SortedStack: def __init__(self): self.stackA = [] self.stackB = [] def push(self, val: int) -> None: if not self.stackA or self.stackA[-1] >= val: self.stackA.append(val) else: while self.stackA and self.stackA[-1] < val: self.stack...
ee564181f2840526ab151ae8cae2dd674886d54e
AlexOsi/Finding-volume-of-cylinder-using-circumference-and-height
/solution.py
225
4
4
# Finding volume of cylinder using circumference and height def volume_circumference_height(circumference, height): pi = 3.14 radius = circumference / (2 * pi) volume = pi * radius ** 2 * height return volume
17b359998209171e01355cb30a351e87abe77cd6
LeonardoArroba/Ejercicios-realizados-en-clase
/Semana_3/For.1.py
1,108
3.78125
4
class For: def __init__(self): pass def usoFor(self): nombre= "Andres" datos =["Andres",18,True] numeros = (1,8,6,4,2) estudiante = {"Nombre": "Andres", "Edad": 50, "fac": "Unemi"} listaNotas = [(30,40),(20,40),(50,40)] listaAlumnos = ({"No...
59ef8efe1f8f4ebba85370616f495871e80d64e5
LeonardoArroba/Ejercicios-realizados-en-clase
/Semana_3/ejer2.py
678
3.96875
4
class For: def __init__(self): pass def usoFor(self): nombre= "Andres" datos =["Andres",18,True] numeros = (1,8,6,4,2) estudiante = {"Nombre": "Andres", "Edad": 50, "fac": "Unemi"} listaNotas = [(30,40),(20,40),(50,40)] listaAlumnos = ({"No...
e5fba2af620a74703b4055d8f4b4c167f829934f
Gago-jpg/Prueba-de-VS-Code
/Diccionario.py
4,562
3.796875
4
#!/usr/bin/python3 from colorama import init,Fore,Back,Style while True: init() print("Serie de ejercicios Con diccionaios y sus metodos") print("ejercicio 1 = '1' :") print("ejercicio 2 = '2' :") print(Fore.RED+"salir"+" :") user_input = input(" :") #+++++++++++++++++++++++++++++++++...
b0f91f81b30f9180b183222031bfc76a4ba26282
weizhixiaoyi/leetcode
/list/83.remove-duplicates-from-sorted-list.py
1,215
3.875
4
# -*- coding:utf-8 -*- # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def printList(head): while head: print(head.val, end=' ') head = head.next print() class Solution: def deleteDuplicates(self, head: ListNo...
0d59ddf2d219e75a982c92f693c92ae390fb3b93
weizhixiaoyi/leetcode
/lcof/2/22.链表中倒数第k个节点.py
742
3.6875
4
# -*- coding:utf-8 -*- # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def getKthFromEnd(self, head: ListNode, k: int) -> ListNode: if not head: return None slow, fast = head, head cur_k = 0 ...
edcb5a789c9645a259b7d05716d8bd495a636a53
weizhixiaoyi/leetcode
/nowcoder/test/0812-阿里巴巴/01.py
469
3.515625
4
# -*- coding:utf-8 -*- def solve(n, m): nums = [i + 1 for i in range(n)] from copy import deepcopy paths, path = [], [] def dfs(start): if len(path) == m: paths.append(deepcopy(path)) for k in range(start, n): path.append(nums[k]) dfs(k + 1) ...
22cffbbae10774e0ccdb9b8f5c5e256d624ab098
weizhixiaoyi/leetcode
/greedy/134.gas-station.py
1,865
3.640625
4
# -*- coding:utf-8 -*- from typing import List class Solution: # 模拟 """ def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int: l = len(gas) if l == 1 and gas[0] >= cost[0]: return 0 if l == 1 and gas[0] < cost[0]: return -1 for i in range(0, l): ...