blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a0c16d1e4eecc96e437924ee7335013261e18810
sumonbis/DS-Pipeline
/notebooks/featured-70/time-travel-eda.py
7,650
3.59375
4
#!/usr/bin/env python # coding: utf-8 # ## Exploration of the date features ## # In[1]: import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: train = pd.read_csv('.....
383daeb888ab0748ebc5e9df45a983b998d1977f
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4138/codes/1637_2446.py
372
3.71875
4
s = int(input(" insira a senha: ")) a = s // 100000 b = s //10000 - (a * 10) c = s // 1000 - ((a * 100) + (b * 10)) d = s // 100 - ((a * 1000) + (b *100) + (c * 10)) e = s // 10 - ((a * 10000) + (b *1000) + (c * 100) + (d * 10)) f = s % 10 sp = b + d + f si = a + c + e if (sp % si != 0): mensagem = "senha invalida" ...
dddb18e98800f14bb8557349439d937b9776a6a0
puzzledpromise/pybites
/275/domains.py
1,295
3.515625
4
from collections import Counter import bs4 import requests COMMON_DOMAINS = ("https://bites-data.s3.us-east-2.amazonaws.com/" "common-domains.html") TARGET_DIV = {"class": "middle_info_noborder"} def get_common_domains(url=COMMON_DOMAINS): """Scrape the url return the 100 most common ...
e7f4291d18799e962453f77c82c9b15dc3019bb6
drakonorozdeniy/Programming
/Practice/Autum/Python/19. Медвежья память.py
444
3.625
4
print("Введите длину пароля:") lenght=int(input()) print("Введите символы") simbols=str(input()) code = [''] code_new = [] for i in range(lenght): for j in code: for k in simbols: code_new += [j + k] code = code_new code_new = [] for j, i in zip(code, range(len(code))): if (not all([k in j fo...
9ed36759106473343375505cb78d83c5cc44b0d3
zerihunz/pyz
/operators.py
405
4.15625
4
a = 3 + 5 print(a) b = 'some' + 'bar' print(b) c = -5.2 print(c) d = 'la' * 5 print(d) #Power operator is ** e = 2 ** 6 print(e) #Division operator is /, Divide and floor operator is //, what that means is divide x by y and round the answer to the nearest integer, if one of the values is float, the result is a float #P...
2760434dc1ba24dab9a1f62b6f61f6f86d1d1bcd
dg5921096/Books-solutions
/Python-For-Everyone-Horstmann/Chapter3-Decisions/P3.19.py
774
4.125
4
# Write a program that prompts the user to provide a single character from the alpha­ # bet. Print Vowel or Consonant, depending on the user input. If the user input is # not a letter (between a and z or A and Z), or is a string of length > 1, print an error # message. from sys import exit character = str(input("Ente...
f4ade422306e224cf7f8cc94818c069c816a6ab1
joewaldron/ALevel
/thequiz.py
1,441
4.625
5
''' Anything written here is called a comment - the computer ignores it, so this lets you explain what your code does. This type of comment can have as many lines as you like, as long as it is between the sets of three apostrophes. ''' # Comments can also look like this, starting with a hash symbol. # Useful if someth...
0c39dd1a17927a4779c1f73c9ec1ea79c5392ea4
hsuanhauliu/leetcode-solutions
/medium/product-of-array-except-self/solution.py
987
3.859375
4
class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: """ Two-pass approach One the first pass, use the list to record the product of all elements on the left side including the number itself. On the second pass, we traverse backward. The product excluding self ...
a1f4376d0e586e49364e342cdcd8196052d6bb26
QuirinoC/46Exercises
/simpleIO32.py
1,030
4
4
def get_user_file(): try: print("\nFile must be in the same folder, \n\ Please write with extension, if the file is \n\ a .docx please write file.docx\n") userInput = input("\nFile name: ") # DEBUG #userInput = "palindrome.txt" file_ = open(userInput,"r+") #file_ = o...
45217849c1944795fd4518695d9f293f1e16c1a5
jayzane/leetcodePy
/greedy/665_check_possibility.py
1,598
3.8125
4
from typing import * class Solution: """ 给定一个长度为 n 的整数数组,你的任务是判断在最多改变 1 个元素的情况下,该数组能否变成一个非递减数列。 我们是这样定义一个非递减数列的: 对于数组中所有的 i (1 <= i < n),满足 array[i] <= array[i + 1]。 示例 1: 输入: [4,2,3] 输出: True 解释: 你可以通过把第一个4变成1来使得它成为一个非递减数列。 示例 2: 输入: [4,2,1] 输出: False 解释: 你不能在只改变一个元素的情况下将其...
7d2aa9ce7ecda857408648b35472e5e03ce214be
Kim-Do-Yun/studyname
/question_pile/question221-230.py
1,004
4.03125
4
def print_reverse(string): print(string[::-1]) print_reverse("python") def print_score(score_list): print(sum(score_list)/len(score_list)) print_score([1,2,3]) def print_even(even_list): for i in even_list: if i%2 == 0: print(i) def print_keys(dic): for keys in dic.keys(): ...
9d55c4853b8f2253b229a3fc2e6dbe40f9a44674
Dude036/cs1400-sp18
/2-01/main.py
1,316
4.375
4
#!/usr/bin/python ''' Case Studies will be homework assignments from now on ''' # Using Turtle - https://docs.python.org/3.3/library/turtle.html import turtle from random import randrange turtle.circle(15) turtle.circle(35, steps=3) # input("Wait") turtle.colormode(255) turtle.penup() turtle.goto(0, 150) turtle....
9332f911b41e40769962486e18eca5dcbceab532
Kori3a/M-PT1-38-21
/Tasks/Olga Tuchinskaya/HW7/characters.py
784
3.65625
4
from random import randint class Creature: def __init__(self, health, attack, level): self.health = health self.attack = attack self.level = level class Hero(Creature): def __init__(self): Creature.__init__(self, randint(170, 280), randint(20, 40), 23) class Monster(Creatu...
0a26b51b8e7cdea122e0283b7ae74b5def156912
AhnJG/AI-Project
/Perceptron_Xor/Perceptron_Xor_3.py
1,389
3.53125
4
#b가 없으면 x1 = 0, x2 = 0인 상태에서 학습시킬 수 없다 #3층 네트워크, 1L : 2, 2L : 1, 3L : 1 import numpy as np X = np.array([[0,0,1,1],[0,1,0,1]]) #2,4 Y = np.array([0, 1, 1, 0]).reshape((1,4))#1,4 W1 = np.random.rand(1,2) * 2 - 1 #1,2 W2 = np.random.rand(1,1) * 2 - 1 #1,1 theta = 0.1 b1 = 0 b2 = 0 def propagate(W1, W2...
a02b3a94e68236e9df0b286028f824c222e1748d
nptit/checkio-3
/StickSawing.py
734
3.59375
4
#!/usr/bin/python def checkio(number): k = int(number ** 0.5) table = [x * (x + 1) / 2 for x in range(1, k + 1)] candidates = [([], -1)] #just try all for i in range(k - 1): for j in range(i + 1, k): if sum(table[i:j + 1]) == number: candidates.append((table[i:j ...
420a26c598dc46ec8be5cc4db4607230fd063fb0
BUEC500C1/health-monitor-4-heros
/AlertModule/Alert/alertModule.py
2,999
3.984375
4
''' 4 main functions: Receive message Set threshold Alarm Send data to display ''' # import needed libraries import sys import time import requests import json import urllib3 # receive information def recMsg(msg, val): # Once we did not receive data, # we will request again from traffic ...
01d5336a83b8b8aa4196ff13686e45e6a884e865
dcosmic/thinkcspy3
/ch06/06.13-slope_and_intercept.py
1,332
3.90625
4
import sys import math def isnum(x): if isinstance(x, int) or isinstance(x, float): return True else: return False def slope(x1, y1, x2, y2): if isnum(x1) and isnum(y1) and isnum(x2) and isnum(y2): if x1 == x2: slp == math.inf else: slp = (y2 - y1)...
d87a8bcc3357b7d383fda77c53dad89133c716e9
Half-Quarter/algorithms_in_python
/data_structure/heap_sort.py
1,463
3.6875
4
# basic definition """ A is a num array, using 1-coordinate. For Node i, its value = A[i] PARENT Node is i/2 LEFT CHILD Node is 2i RIGHT CHILD Node is 2i+1 """ def max_heapify(A,i): l_i = (i+1)*2 - 1 r_i = (i+1)*2 +1 -1 l = A[l_i] ori = A[i] try: r = A[r_i] except: ...
ec1f007d3ad7389902ba0085dfd8ebdaaee4c267
menduhkesici/Project_Euler
/Problem 27 - Quadratic primes.py
487
3.546875
4
def isPrime(n): if n < 0: return False for x in range(2, int(n**0.5) + 1): if n % x == 0: return False # NOT prime number return True # prime number max_primes = 0 max_a_b = 0 for a in range(-999,1000): for b in range(-1000,1001): n = 0 while True: quad_exp = n**2 + a * n + b if i...
68912a09e5c386daba4393a4e66daf46d67d16fb
Martin-Ascouet/Tp12_2nd_anee
/Exercice4.py
192
3.578125
4
def listSum(l): if len(l) != 0: a = l[0] del l[0] return a+listSum(l) return 0 print(listSum([])) # 0 print(listSum([42])) # 42 print(listSum([3,1,5,2])) # 11
9728dd42abedbdd6320be1a8153fd76a03b9bd22
alexjercan/algorithms
/old/hackerrank/interview-kit/triple-sum.py
1,073
3.546875
4
#!/bin/python3 import math import os import random import re import sys # Complete the triplets function below. def triplets(a, b, c): r = 0 xs, ys, zs = sorted(list(set(a))), sorted( list(set(b))), sorted(list(set(c))) cnt = 0 xys = {} i = 0 for y in ys: while i < len(xs) a...
a6c3c33ebf2f2da51e2d9fa739e95e67c31b4d7c
aquatiger/LaunchCode
/mystery drawing.py
799
3.84375
4
# Draw a picture based on the txt file mystery # When UP go to the next line, read x,y coordinates, go to that point # When DOWN go to the next line, read x,y coordinates, go to that point and continue until UP import turtle wn = turtle.Screen() # Set up the window and its attributes wn.bgcolor("beige") hadir...
82f3f1fc30bbc88f704a21a28ab20bd3386235bf
behraam/moving2
/moving2.py
5,244
3.734375
4
import pandas as pd import matplotlib.pyplot as plt from datetime import datetime as dt def calculate_amortization_amount(principal, interest_rate, period): x = (1 + interest_rate) ** period return principal * (interest_rate * x) / (x - 1) def amortization_schedule(principal, interest_rate, period): amo...
3226200139d535e1b6ddf9ecfacdaf0beb325c20
zhangxianyou33/python_demo
/io_biancheng/open_file.py
1,461
4.25
4
#方法一:使用系统内置函数open def open_file(): try: file = open(r"test.txt", "r") print("文件名称:",file.name) print("文件是否已关闭:",file.closed) print("文件访问模式:", file.mode) finally: file.close() print("使用close方法,关闭文件状态为:", file.closed) open_file() print("======open方法,写入文件======") de...
80dccbceb92f2a9b75892ca7dc5236c1bb82be6f
rajatsharma98/CS677
/HW/lyndon97_8_1_8.py
1,235
3.59375
4
import os import pandas as pd import numpy as np wd = os.getcwd() input_dir = wd file_read = os.path.join(input_dir,"tips.csv") df = pd.read_csv(file_read) df['tip_percent'] = 100.0 * df['tip']/df['total_bill'] df_smoke = df[df['smoker'] == 'Yes'] df_nonsmoke = df[df['smoker'] == 'No'] # calculate cor [total_bill,...
32a7cbb5434e362f6028ff4c433c4cf437aa11dc
Jhruzik/pyreiseamt
/pyreiseamt/scraper.py
6,430
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Import Modules from bs4 import BeautifulSoup import requests import re # List all available Countries def list_countries(): """List all available countries for extraction This function will create a connection to the website of the German Foreign Off...
9279d7f850031f1577e7f82f0bd45989ec62093d
joshua-hampton/my-isc-work
/python_work/numpy_exercises/numpydimensions.py
326
3.96875
4
#!/usr/bin/python import numpy as np ''' Quick code to find the maximum number of dimensions a numpy array can have ''' a=1 dim=[1] while True: try: print np.zeros(dim) print 'number of dimensions:',len(dim) dim.append(a) except ValueError: print 'max number of dimensions in numpy array:',len(dim[:-1]) e...
3164466f73b761f160c63c730d20836df1192f65
l3eamster/Data_Structure
/labTest/Stack.py
3,932
3.9375
4
class Stack : def __init__(self,list = []) : #สร้าง empty list if list == []: self.items = [] else: self.items = list def __str__(self) : #พิมพ์ของที่อยู่ใน stack จากล่างขึ้นบน return str(self.items) def __len__(self) : ...
fcb042235ebc244420132573f2dede7003fa58ce
biswajithgopinathan/StudentInterventionSystem
/student_intervention.py
6,404
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 31 22:35:29 2017 @author: Biswajith Gopinathan """ # Building a student Intervention Progam """1. Classification vs Regression Your goal is to identify students who might need early intervention - which type of supervised machine learning problem is this, classi...
e3ca56a83a63c1261fc574d7f9c31276737c2166
Rich-Mala-05/Esercizi-di-pagina-73
/es5-6_pag292.py
1,148
3.78125
4
class Prodotto: def __init__(self, tipo, peso, marca, taglia, stagione): self.tipo = tipo self.peso = peso self.marca = marca self.taglia = taglia self.stagione = stagione def assegna_prezzo(self): print("Hai chiesto alla cassiera quanto costa questo capo di...
29b8d18abaae47ea807f4efa9f37250a4b610354
swetakum/Rosalind
/FIndingMotifinDNA.py
2,401
3.703125
4
# Given two strings ss and tt, tt is a substring of ss if tt is contained as a contiguous collection of symbols in # ss (as a result, tt must be no longer than ss). # The position of a symbol in a string is the total number of symbols found to its left, including itself # (e.g., the positions of all occurrences of ...
ad59e63a88296bc747486c1f36d3d4b7186fc476
celsopa/theHuxley
/HUX - 2174.py
212
3.671875
4
m3Agua = float(input()) custoAgua = float(input()) totalAgua = m3Agua*1000*custoAgua print("{:.2f}".format(custoAgua)) print("{:.2f}".format(custoAgua*80/100)) print("{:.2f}".format((custoAgua*80/100)+custoAgua))
553588bbe3b900c718efc99eef21e2d9a48223a0
RumorsHackerSchool/PythonChallengesSolutions
/Guy/hackerrank.com/Arithmetic_Operators.py
516
4.0625
4
''' Task Read two integers from STDIN and print three lines where: The first line contains the sum of the two numbers. The second line contains the difference of the two numbers (first - second). The third line contains the product of the two numbers. Input Format The first line contains the first integer, . The secon...
9dd2ec87213039e919e8fba2994faf61db1e6a95
MayeshMohapatra/ImageSegmentation-UNet
/model.py
2,401
3.5
4
from tensorflow.keras.layers import ( Conv2D, BatchNormalization, Activation, MaxPool2D, Conv2DTranspose, Concatenate, Input, ) from tensorflow.keras.models import Model # implementing on unet architecture ##Simple Conv block with 2 3x3 conv layers def Convolution_block(input, num_filte...
a477b207c81bbbff6e34a298ed55c6573dcd3698
issokov/BlackJackAndFeatures
/engine/card.py
612
3.796875
4
from enum import Enum, unique @unique class VALUE(Enum): TWO = 0 THREE = 1 FOUR = 2 FIVE = 3 SIX = 4 SEVEN = 5 EIGHT = 6 NINE = 7 TEN = 8 JACK = 9 QUEEN = 10 KING = 11 ACE = 12 @unique class SUIT(Enum): HEARTS = 0 DIAMONDS = 1 CLUBS = 2 SPADES = 3 ...
1b3eb41ec455b839cc6d521c61c36fe7956b02f7
bssrdf/pyleet
/F/FindCompoundWordsinList.py
1,353
4
4
''' Given a list of words, find words in that list that are made up of other words in the list. For example, if the list were ["race", "racecar", "car"], return ["racecar"]. ''' from collections import defaultdict class Node(defaultdict): def __init__(self): super().__init__(Node) self.termina...
3c08ccdd1eb368e79d246636b75e85a9c574b3f2
Xu-Guo/GQQLeetCode
/Array/287_FindtheDuplicateNumber.py
797
3.609375
4
class Solution(object): def findDuplicate(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) - 1 mi, ma = 1, n while mi <= ma: mid = mi + (ma - mi) / 2 less, equal, high = 0, 0, 0 for num in nums: ...
7df8995e594f8a1af2779d36d24fd2c55c988f11
NicolasOng/BlockchainSimulation
/message.py
412
3.5
4
class Message: def __init__(self, header, data): self.header = header self.data = data def __str__(self): return "HEADER:\n\t" + self.header + "\nDATA:\n\t" + self.data.__str__() def encode(self): ''' encodes the message to bytes. assumes that the message has a header of "Block", and data of a block,...
6f4545f820bbf901e75e9242f9ade0640bbf6722
ramugadde/Python-Practice
/PythonSessions/B_Python_BasicPractice/M_FunctionsTypes2.py
331
3.515625
4
print("********Function with return values**************") def returnValue(): print("Good morning") return 10 x= returnValue() print("Returned value:",x) print("********Function with default return values**************") def returnValue(): print("Good morning") x= returnValue() print("Returned v...
708f8773376a026dbc5f90966276732634db6457
anyatran/school
/CG/SciPy/DateYChart_01.py
395
3.75
4
# -*- coding: utf-8 -*- import datetime from time import sleep start = datetime.datetime.now() sleep(5) #delay the python script for 5 seconds. stop = datetime.datetime.now() elapsed = stop - start if elapsed > datetime.timedelta(minutes=4): print "Slept for greater than 4 minutes" if elapsed > dat...
cb01794ce752e44f7f88c56384b59bd736bc5759
aaronbushell1984/Python
/Day 3/Functions.py
1,974
4.40625
4
# ***LESSON*** # Rewrite this function into reusable functions number = int(input("Please enter a number:")) if number % 3 == 0 and number % 5 == 0: print("FizzBuzz") elif number % 3 == 0: print("Fizz") elif number % 5 == 0: print("Buzz") else: print(number) # Rewrite to def is_fizz(number): """ret...
7daede4fae945a0287a320c3168dad557f3bc408
gotha331/python-learning
/10-异常/04-try_expect_finally结构.py
696
3.5
4
# Files: # Author:jiang liu # Date :2020/3/26 19:21 # Tool :PyCharm # 无论是否发生异常,都会执行finally部分 # try: # a = input("请输入一个被除数:") # b = input("请输入一个除数:") # c = float(a) / float(b) # except BaseException as e: # print(e) # else: # print("除的结果是:", c) # finally: # print("我是finally中的语句,无论发生异常与否,都执行!")...
47d94611fb97332e902073ba75296f21e455707d
NanZhang715/AlgorithmCHUNZHAO
/Week_07/findKthLargest.py
1,589
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 215. 数组中的第K个最大元素 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 输入: [3,2,1,5,6,4] 和 k = 2 输出: 5 链接:https://leetcode-cn.com/problems/kth-largest-element-in-an-array/ """ from typing import List class Solution: def findKthLargest(self, nums...
6141c4dbe8d061c7a2807c361434722657f0148a
hkelder/Python
/Lesson2/palindrome.py
298
4.4375
4
# Ask the user for a string and print out whether this string is a palindrome or not. def palindrome(): userString = input("Enter something:").lower() if userString[::-1] == userString: print("It's a palindrome") else: print("This is a normal string.") palindrome()
9b9d577e45bcb4da3fd3e3e07d647b8b3bdefc11
vensder/py_hw_2016
/hw8_A_shapes.py
2,875
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # 2016_python.py # # Student Dmitry Makarov <vensder@gmail.com> import math class Point: ''' Базовый класс "точка", которая имеет две координаты ''' def __init__(self, x, y): self.x = x self.y = y class Shape: ''' Базовый ...
b86eeb22b303e017b5c6013f335f9e3ab3975674
illuminous/pythonScripts
/outfileParse_stageII.py
2,389
3.515625
4
import profile def fidYear(inputfile): perimeterfile = {} global perimeterfile poly = open(inputfile, 'r') FID = -1 #start counter at -1 because of header """analyse the polygon perimeter file and store the FID and associated year in a dictionary""" for polyline in poly.readlines(): ...
8fa8dd213dff9c4aa6ff0fc132d3a127fc3492a6
arv1983/Hackaton
/hackathon.py
725
3.640625
4
hackathon_1 = ["Team Kenzie", "Team Ateliware", "Team VHSYS", "Team Mirum"] hackathon_2 = ["Team Ateliware", "Team Kenzie", "Team VHSYS", "Team Mirum"] hackathon_3 = ["Team Mirum", "Team Ateliware","Team VHSYS", "Team Kenzie"] def get_score(team_name, teams): return 'O ' + team_name + 'ficou classificada em ' + st...
5360ad601f6d0b2be61fc069046767305f3f052d
kamilhabrych/python-semestr5-lista7
/zad7_7.py
761
3.609375
4
import random def sortuj(l): l.sort() print(l) lista = [] for x in range(100): dlugosc = random.randint(3,8) slowo = '' for y in range(dlugosc): losowana_litera = random.randint(97,122) litera = chr(losowana_litera) slowo += litera lista.app...
cfb0bda884fa22246986fb6dd3aacde006644386
summercake/Python_Jose
/02.Strings.py
444
3.90625
4
print('Hello') print('This is also a string') print("I'm a string") print('I\'m a string') print("I\'m a string") print('Here is a new line \n and here is the second line') print("Here is a new line \t and here is the second line") print(len('Hello world')) s = "Hello World" print(s) print(s[0]) print(s[2]) print(s[2:]...
bcda1cc42939b066adeb47a7993cc6e7ad7a88c7
vivekpabani/powerball-game
/powerball/main.py
747
3.671875
4
#!/usr/bin/env python """ The main script to run the powerball game simulation. """ __author__ = "vivek" from .game import Game from .player import Player def main(): # The game simulation is done with following steps: # # 1. Create a game instance with no players. # 2. Invoke the begin method, w...
e321326d2f73ed6b6c97cb8278628c3ec5f5cbe9
manamster/GameOfPig
/computerPlayer.py
1,988
3.953125
4
import time class Computer(object): def __init__(self, name, score = 0): """Sets name, total, and round points""" self.name = str(name) self.totalPoints = score self.roundPoints = score self.probability = 1 print("This computer is hard mode be careful!\n") def getTotal(self): """Return...
f66b4a1fbbc2006b71197db847f791b1616d20c2
lightopen/queue-in-python
/queue.py
1,580
3.828125
4
class Queue(object): """ 循环队列 默认队列容量为4,可在实例化时自定义 """ def __init__(self, capacity=4): self.capacity = capacity self.index = -1 self.head = 0 self.tail = 0 self.queue = [] self.length = 0 # 计数,返回长度 def count(self): ...
0b52c35ba9484f202044ef6271d4241496d5437f
KiaHKR/uFood
/src/bin/validation.py
430
3.65625
4
"""Runs a script to check that the user's OS is supported.""" import platform suppOS = ["Windows"] def checkOS(os): """Check that OS is Supported.""" if os not in suppOS: msg1 = "Your operating system ({}) is not supported in this build. " msg2 = "Compatible operating system(s): {}" ...
216a594c01feef5a940078794c4b0134011d8d3c
damngamerz/python-practice
/practice/while.py
102
3.78125
4
count = 0 while count<10: print("count:",count) count+=1 print("Good bye!")
6c89278e1854e34e4a86d40ce7980932ccd393bd
yg-kim-korean/This_is_CodingTest
/Sort/UptoDown.py
348
3.84375
4
n = int(input('몇개 넣을래? : ')) array = [] for i in range(n): array.append(int(input(str(i+1)+'번째 숫자 : '))) # for i in range(1,len(array)): # for j in range(i,0,-1): # if array[j] > array[j-1]: # array[j],array[j-1] = array[j-1],array[j] array.sort(reverse=True) for i in array: print(i , ...
5f923f72a76337142824ad81d034e1fa9ca3cd54
itineraries/scheduler-and-mapper
/pickle_nyu_unwritten_times.py
3,244
3.609375
4
#!/usr/bin/env python3 ''' This module is responsible for telling pickle_nyu how long it takes the bus to get from one place to another. Normally, the schedule has this information. However, for some reason, NYU decided not to include the information for some stops. That's why it has to be provided by this module. The...
cafaf42bed178c4f871df70083121a839ecba7e7
alexandre146/avaliar
/media/codigos/294/294sol64.py
87
3.734375
4
a = int(input()) b = int(input()) consumo = (a/b) print("%.3f"%(consumo) +' km/l')
9f5b28132b1fd01c099491baee29e09f34abac35
luizfelipe1914/Listas-Python
/Lista 02/Questao5.py
340
4.125
4
#!/usr/bin/env python3 #-*- encoding: UTF-8 -*- def main(): try: number = int(input("Informe um número: ")) except: print("Apenas valores numéricos são aceitos!") if(number % 2 == 0): print(f"{number} é par.") else: print(f"{number} é ímpar.") if(__name__ == "__main__"...
abde31fef9613d0d3adefcd09df8672ac71b8226
eduardoanj/cursopyton
/Nova pasta (2)/python/ex 42.py
184
3.53125
4
#Escreva um algoritmo para imprimir os 10 primeiros # números inteiros maiores que 100. #enquanto eu sei quantos são, utilize o for for i in range(100, 110): print (i + 1)
2f49066b97332020524b72cc09b490c8a54b0e60
pjhu/effective-script
/lintcode/lintcode/search_range_in_binary_search_tree.py
1,277
3.59375
4
# -*- utf-8 -*- """ eleventh http://www.lintcode.com/en/problem/search-range-in-binary-search-tree/ """ import profile import queue # Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None class SearchRangeInBinarySearchTree(object): ...
062235d5e7cfe20b0113efbc3c37eafe7a5eacb2
rahul118bbsr/Indus-Script-Analysis
/ConditionalProbability.py
1,075
3.671875
4
import operator def conditionalProbability(fileDir, given): output = {} given = given.strip().split("-") for line in fileDir: line = line.strip().split('-') for i in range (len(line)): startIndex = i stopIndex = i + len(given) if(stopIndex < len(line) and...
ed0db4ed28dd8c94378c5e14f384a7aab03b2027
juhosalmi/study_planner
/src/course.py
874
3.578125
4
''' Created on 22.3.2013 @author: jtsalmi ''' from period import Period class Course(object): def __init__(self, name, ects, period, description, prerequisites): self.name = name # Name of the course self.ects = int(ects) # Number of credits self.period = period # The periods in...
4a732146e083740df4e5ef38766ce89e96451d5c
giancarlo-garbagnati/RosalindSolns
/08-DivideAndConquer/01_dc_bins.py
2,514
3.765625
4
""" http://rosalind.info/problems/bins/ Binary search is the ultimate divide-and-conquer algorithm. To find a key k in a large file containing keys A[1..n] in sorted order, we first compare k with A[n/2], and depending on the result we recurse either on the first half of the file, A[1..n/2], or on the second half, A[n/...
6f9f34df9c6ddf07c77edc2901640997fffbdb0e
Joshua0128/JudgeGirl-Coding-GYM
/一轉示範/自製資料結構 python 示範/main.py
349
3.609375
4
from MyStack import * from Student import Student mStack = MyStack() try: for i in range(9,-1,-1): mStack.push(Student(i)) for element in mStack: print (str(element), end=" ") print() while(True): print(str(mStack.pop()), end=" ") except NoElementException as err: pr...
101828f41cdef50e8b423367d217c7a18bd144d9
AntoData/CoronavirusWebScraper
/api/MapGenerator.py
14,253
3.75
4
# Created on 21 jul. 2019 # @author: ingov # We use folium to generate the maps import folium # We use LinearColormap to create scales for pair of colours-values from branca.colormap import LinearColormap # We use branca to create the legend for our map import branca # We import this module to manage data frames impo...
d730afaac0970063547e66afa1d8721a43ee9610
jiaruipeng1994/jLeetCode
/l115_Distinct-Subsequences_DP-Matrix_Space-optimization_暴力递归-动态规划.py
5,286
3.8125
4
#!/usr/bin/python3 # coding: utf-8 ################################################################## ## Description # Given a string S and a string T, count the number of distinct subsequences of S which equals T. # A subsequence of a string is a new string which is formed from the original string by deleting some (ca...
9f6977008ac13b376128e980aafb0a7cb855d2ab
ballib/SC-T-111-PROG
/prof/Lokaprof/Lokaprof_2016/points.py
920
3.859375
4
def open_file(filename): try: with open(filename, 'r') as file: file_list = [] for line in file.readlines(): points = [] x, y = line.rstrip().split() points.append(int(x)) points.append(int(y)) file_list....
9e2d6414020d163115197f64e13cccf6204ed574
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/bdgmul001/question4.py
1,093
4.375
4
# program that uses recursive functions to find all palindromic primes between two integers supplied as input (start and end points are included). # Mulisa Badugela # BDGMUL001 # 08 MAY 2014 import sys sys.setrecursionlimit (30000) N =eval(input('Enter the starting point N:\n')) # user input start point if...
6e1200d7b5d13e454f4380c2128480594b7dd400
mpetrozzi78/PyPoll-and-PyBank
/Python-Bank-and-Python-Poll/PyPoll.py
2,532
3.921875
4
# First we'll import the os module # This will allow us to create file paths across operating systems import os # Module for reading CSV files import csv # Module to do the sorting import operator #csvpath = os.path.join('..', 'Resources', 'election_data.csv') election_file = open('election_data.csv', "r") # Splt the...
76c23193444355920da20c9b0e38eb548d2b5b43
yabirgb/algoritmicaGrupo
/greedy/Genetico/read.py
890
3.59375
4
from math import sqrt filename = "ulysses16" def distance(t1, t2): return sqrt( (t2[1] - t1[1])**2 + (t2[2] - t1[2])**2 ) def coordenadas(filename): with open("datosTSP/" + filename + ".tsp", 'r') as f: cities = [] size = int(f.readline().split(" ")[1]) for city in range(size): ...
9361436143ec7724ca36b9ff044137e0aaf79b6f
Zahed75/Python_practice
/list_quiz.py
1,042
4.3125
4
# print the second value fruits = ["apple", "mango", "litchi"] print(fruits[1]) # change the value from apple to the litchi fruits = ["apple", "mango", "litchi"] fruits[0] = "litchi" print(fruits) # use to the append method to add orange fruits = ["apple", "banana", "mango", "litchi"] fruits.append("orange") pri...
3881fca601873f24fd58c3361b3f44f622011996
fulcrumandco/TDBv0.1
/TheDarkBelow.py
6,664
3.546875
4
from sys import exit import xml.etree.ElementTree as ET from xml.etree.ElementTree import parse, Element import random from random import randint, choice error_list = ["I didn't understand that.", "What are you saying?", "That doesn't compute.", "Dude, what.", "You aren't making sense.", "That's highly illogical...
682240fdc8d48fb268816f89c587351cc5d01795
connor-mcnaboe/CaesarCipher
/ceasarCipher.py
2,750
3.984375
4
#Programmed by Connor McNaboe #Questions or suggestions refer to https://github.com/zerodarkbirdy/CaesarCipher # #This program takes a text file and encrypts it using a caesar cipher. import argparse import os import time import sys parser = argparse.ArgumentParser() # Define comamand line args parser.add_argument(...
aa82c75a941804ee7ddbda65b23db10f8468e86f
yuenliou/leetcode
/496-next-greater-element-i.py
3,481
3.5625
4
#!/usr/local/bin/python3.7 # -*- coding: utf-8 -*- from typing import List class Solution: def _nextGreaterElement(self, nums: List[int]) -> List[int]: """ 思路1:暴力解 思路2:单调栈 [2,1,2,4,3] """ res = [0] * len(nums) stack = [] # 倒着往栈里放 for i in range(len(n...
03c0e1f942558bbc7e67891e430e4030ec1ede07
mchez808/OOPython
/ch1-oop-basics/instance_book.py
2,833
4.3125
4
# instance methods and attributes class Book(object): """ [from PEP 257] The docstring for a class should summarize its behavior and list the public methods and instance variables. If the class is intended to be subclassed, and has an additional interface for subclasses, this interface should be listed separat...
6d2f3963f2367f2ee692a902061090fc8d1ca6ca
palakbaphna/pyprac
/Strings/12NumOfWOrds.py
271
4.28125
4
#Given a string consisting of words separated by spaces. # Determine how many words it has. To solve the problem, use the method count. #s = 'In the hole in the ground there lived a hobbit' s = input() t = s.count(' ') print("No of words in the given string =", (t+1))
2ecb017b7880809956d1976fd275f7324cf26189
itspratham/Python-tutorial
/Python_Contents/geeksforgeeks/matrix/prg1.py
276
3.78125
4
# Count zeros in a sorted matrix # def countzero(arr): # count = 0 # for i in range(len(arr)): # for j in range(len(arr)): # if arr[i][j] == 0: # count = count +1 # return count # # print(countzero([[0,0,0],[0,0,1],[0,1,1]]))
78e77dfb7487c4a0e147bed43537737558d0da65
developer579/Practice
/Python/Python Lesson/Second/Lesson8/Sample2.py
347
3.671875
4
class Person: def getName(self): return self.name def getAge(self): return self.age pr1 = Person() pr1.name = "鈴木" pr1.age = 23 n1 = pr1.getName() a1 = pr1.getAge() pr2 = Person() pr2.name = "佐藤" pr2.age = 38 n2 = pr2.getName() a2 = pr2.getAge() print(n1,"さんは",a1,"才です。") print(n2,"さんは",a2,"才です。")
9474029aa43223974c8ef522b9c6986a42fafac5
thabo-div2/python_functions
/main.py
549
4.0625
4
# Exercise 1 - Python Functions # Defining an argument def distance_from_zero(x): # Passing an argument if type(x) == int or type(x) == float: # Checking the type of variants return abs(x) else: return "Nope" print(distance_from_zero(-5)) print(distance_from_zero(6)) print(distance_from_...
56591910a0ce88d83c1f8aee3116ea9b2d0850c5
rubenvereecken/challenges
/Cracking the Coding Interview/Extra/itertools.py
408
3.859375
4
__author__ = 'ruben' def permutations(array): if len(array) == 1: yield [array[0]] else: for i, el in enumerate(array): pre = array[0:i] post = array[i+1:len(array)] next = permutations(pre + post) for perm in next: yield [el] + p...
9867d1c8aa6477cf4b0d5055ca5bc9d330cf7b36
lxh1997zj/-offer_and_LeetCode
/剑指offer-牛客顺序/to_offer_20.py
1,305
3.796875
4
# !/usr/bin/env python3 # -*- coding:utf-8 -*- '定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为O(1)),在该栈中,调用min、push、pop的时间复杂度都是O(1)' class Solution: def __init__(self): self.stack = [] self.minstack = [] def push(self, node): # write code here self.stack.append(node) if ...
1f8515352a5dc921e979c54bb46f96fc782dbda7
nlfox/leetcode
/20_Valid_Parentheses.py
586
3.671875
4
class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] m = {'{': '}', '[': ']', '(': ')'} for i in xrange(len(s)): if m.has_key(s[i]): stack.append(s[i]) else: if stac...
12e01791ff9e57b65d91cd75c74876319936adec
frankkarsten/MTG-Math
/Burn_with_interaction.py
11,934
3.640625
4
import random from collections import Counter from itertools import combinations import math list_of_opening_hands = [] for Guide in range(8): for Bolt in range(8): for Charm in range(8): for Land in range(8): if Guide + Bolt + Charm + Land == 7: hand = { 'Goblin Guide': Guide, 'Lightning Bo...
27ee51ca0050278be04461d6cb832f22a0928fe1
1buraknegis/Python-Tkinter-examples
/radioButton.py
708
3.515625
4
import tkinter as tk form = tk.Tk() form.title("RadioButton") form.geometry("500x450") x = tk.StringVar() def kontrol(): if x.get() == "1": print("buton1") elif x.get() == "2": print("buton2") else: print("buton2 ve buton1") buton = tk.Button(form, text="tıkla",...
47e8eb7df50a4ac811640a35bd329063deaefd6d
MohammedAlewi/competitive-programming
/leetcode/Tree Problems/Construct Binary Search Tree from Preorder Traversal.py
1,431
3.796875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def __init__(self): self.preorder=None self.bsd=None self.tree=None self.index=0 def bstFrom...
c3b1196717ce806c474a45a059f96fe5cda759e4
JSYoo5B/TIL
/PS/ProjectEuler/P007/sieve_of_eratosthenes_functional.py
765
4.15625
4
#!/usr/bin/env python3 """ Sieve of Eratosthenes 1. Get all prime numbers which is less than given number by the Sieve of Eratosthenes algorithm. (Loop till the sqrt of given number) 2. Search the complete divisor from the prime numbers in descending order. """ from math import sqrt REQUEST = 10001 LIMIT = 10000...
4ac452616e32a8aebb7897705a36ffe933b33267
min-0/pitapat_python
/GUI/Color Pen.py
715
3.53125
4
from tkinter import * top = Tk() def paint(event): x1, y1 = (event.x - 1, event.y - 1) x2, y2 = (event.x + 1, event.y + 1) cnvs.create_oval(x1, y1, x2, y2, outline=penC, fill=penC) def redColor(): global penC penC = 'red' def greenColor(): global penC penC = 'green' def blueColor():...
7929cc3ff992b439df93253ec29be142ff094e49
hongyong3/TIL
/Algorithm/Swea/D1_6318.py
131
3.765625
4
word = 'abcdef' mat = {} for i in range(len(word)): mat[word[i]] = i for k, v in mat.items(): print("{}: {}".format(k, v))
f60e3cfc05524cf261d15314f5c79e24058b2b3b
vnallani259/VenkyPhython
/python/simple.py
348
3.734375
4
num = eval(input("Please enter an integer in the range 0...9999: ")) if num < 0: num = 0 if num > 9999: num = 9999 print(end="[") digit = num//1000 print(digit, end="") num %= 1000 digit = num//100 print(digit, end="") num %= 100 digit = num//10 print(digit, end="") num %= 10 print...
6997ae87f4d381e101747985982494e4cd5ef32e
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_117/1255.py
1,044
3.59375
4
import sys def get_horizontal(lawn, row): return lawn[row] def get_vertical(lawn, col): return [row[col] for row in lawn] def check_lawn(lawn): for y, row in enumerate(lawn): for x, cell in enumerate(row): h = get_horizontal(lawn, y) v = get_vertical(lawn, x) ...
52b07d4448f00bdec6e9034ba98003346070bf7b
CAVIND46016/Project-Euler
/Problem20.py
463
4
4
#n! means n × (n − 1) × ... × 3 × 2 × 1 #For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, #and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. #Find the sum of the digits in the number 100! from functools import reduce def factorial(n): return reduce(lambda x,y:x*y,range(1,n+1),1...
04b3f02c9e67bd6fc62d991bf1576bb450b117e5
bmihovski/PythonFundamentials
/stateless.py
1,666
4.21875
4
""" You will be given groups of 2 strings, each on a new line. There will ALWAYS be at least 2 input lines, and there will NEVER be a case when there are less than 2 input strings, for a given element of the input. Now to the main logic - the elements of the input. You can refer to the elements of the input as states. ...
fee192054c80568ef1147c2fdf7f65a6ec94c306
907117139/lianxi
/第四周/交互式循环代码.py
295
3.96875
4
#average.py def main(): sum=0 count=0 moredate="yes" while moredate[0]=="y": x=eval(input("enter a number>>")) sum=sum+x count +=1 moredate=input("Do you have more number(yes or no)") print("\n The average of the numbers is",sum/count) main()
c4cee250505b4d6409d9c7230fbce4ac313da256
vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3
/Algorithms/2 Graph/GraphAdjMatrix.py
6,160
3.515625
4
#!/usr/bin/env python import heapq import sys from collections import deque class Graph(object): def __init__(self, cnt): self.count = cnt self.adj = [[0 for _ in range(cnt)] for _ in range(cnt)] def AddDirectedEdge(self, source, destination, cost=1): self.adj[source][destinati...
915bee4e9ad5f90ff490470c05065b97d402209a
snehaljadhav7/Data-Science
/Assignment1/calculatingBMI.py
236
4.21875
4
#!/bin/python3 import math weight_pounds = int(input("Enter your weight in pounds:")) height_inches = int(input("Enter your height in inches:")) BMI=703*(weight_pounds / (height_inches*height_inches)) print("Your BMI is",round(BMI,1))
a714f0d37f8d54d4b139e574c0c5baa8bc7bd864
zenggang888/blogs
/Python/learning/函数.py
556
3.765625
4
def add_num(): total = 0 for i in range(1,101): print(i) total = total + i return total def factorial(n): total = 1 if n < 0: return None elif n == 0: return 1 else: for i in range(1,n+1): total = total*i return total print(factorial(-1...
45b74623ce1696ab13f409c4f998195747f38b9c
UESTCYangHR/leecode_test
/search-in-rotated-sorted-array-ii.py
925
3.71875
4
# coding=utf-8 # @Time: 3/15/2019 2:45 PM from typing import List class Solution: def search(self, nums: List[int], target: int) -> bool: pol = len(nums) - 1 while pol > 0 and nums[pol] >= nums[pol-1]: pol -= 1 ans = self.binary_search(target, nums[:pol]) if ...
49e4e7cad6bd0566409a5fa4a376e3a597662ead
prpllrhd/morePYTHON
/cookbook/lambda/lambda1.py
343
3.796875
4
#!/usr/bin/env python3 """ example: using lambda key to sort a tuple of second field instead of first one """ import os def script(): pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')] pairs.sort(key=lambda pair: pair[1]) print (pairs) def help(): print (__doc__) def main(): help() script() if __name__=...
5956a08c5b5435b8593de27a82b46eb31dc7ef16
maecchi/PE
/pe055.py
549
3.765625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- # # pe055.py - Project Euler # LIMIT = 10000 count = 0 # 数字が回文数であるかを判定する def isPalindrome (number): digit_number = list(str(number)) reverse_digit_number = digit_number[::-1] return digit_number == reverse_digit_number def checkPalindrome(number): for x in xrange(1,...
1caec6ff5e1fe41f901c362842a041b19b1c0550
grrrrnt/smart-parking
/MissingDigit.py
5,507
3.875
4
import re pre = str() num = str() suf = str() numCheck = str() numCorrect = str() def sufValue(str): switcher = { "A": 0, "Z": 1, "Y": 2, "X": 3, "U": 4, "T": 5, "S": 6, ...