blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
20f44cd8fa9e25a2f81c356c9858c4444553ba76
mundaneprogramming/mundaneprogramming.github.io
/code/twitterlogin.py
1,476
3.546875
4
import tweepy import os ### ENTER YOUR FILE HERE DEFAULT_TWITTER_CREDS_PATH = '~/.creds/me.json' # It should consist of a single dictionary and at a # minimum have these fields: # { # "access_token": "BLABHALHSRF7rkEALn621F3DdR1wpo0Rbq1VP", # "access_token_secret": "BLABLAHtTwZHOK8WOJ5Ec2Cxl3O8Dd73iJUPuQRF1f",...
93b128a9cc13706ddd5b6f42115ccab410d3a617
ChadJung/swea
/pool.py
435
3.546875
4
def solve(n, s): global result if n >= 12: if s < result: result = s else: solve(n + 1, s + day * monthly[n]) solve(n + 1, s + mth) solve(n + 3, s + tri) t = int(input()) for tc in range(1, t+1): day, mth, tri, year = map(int, input().split())...
77d374ef64f6e68d7ef99800297f32d8e14d2c31
lomo44/DiscreteOps
/A5_facility/facility_structs.py
433
3.71875
4
from collections import namedtuple Point = namedtuple("Point", ['x', 'y']) class Facility: def __init__(self): self.index = 0 self.setup_cost = 0 self.capacity = 0 self.max_capacity = 0 self.location = None self.customers = [] class Customer: def __init__(self)...
1ef80583f3c9e7098080da291f3c002589d97e75
realpython/materials
/python-enum/days.py
332
3.59375
4
from enum import Enum, auto # class Day(Enum): # MONDAY = 1 # TUESDAY = 2 # WEDNESDAY = 3 # THURSDAY = 4 # FRIDAY = 5 # SATURDAY = 6 # SUNDAY = 7 class Day(Enum): MONDAY = auto() TUESDAY = auto() WEDNESDAY = 3 THURSDAY = auto() FRIDAY = auto() SATURDAY = auto() ...
6305a194b4c7c62090a77c553745d8f11a58ef5b
s-light/OLA_rainbow_generator
/modules/rainbow.pyx
908
3.71875
4
#!/usr/bin/env python2 # coding=utf-8 """ Rainbow. function should return rgb value for specific position of rainbow. """ from __future__ import print_function # https://docs.python.org/2.7/howto/pyporting.html#division from __future__ import division from hsv2rgb import hsv2rgb_rainbow_8bit import int_math def...
abc001d85aa75e50c371e0e27053935b3dbc5618
Aissen-Li/lintcode
/64.mergeSortedArray.py
953
3.8125
4
class Solution: """ @param: A: sorted integer array A which has m elements, but size of A is m+n @param: m: An integer @param: B: sorted integer array B which has n elements @param: n: An integer @return: nothing """ def mergeSortedArray(self, A, m, B, n): if m == 0: ...
db1b2d11ad528f5209af9870413b50f888c974c0
Donal-Flanagan/CyberdyneCollective
/tutorials/Intro to Computer Science with python_NUIG/Python Programs/prime.py
579
4.1875
4
# prime.py # by Dnal def main(): n=input("Please input the number you would like checked:") import math if n==1: print "The number ",n," is a prime number." elif n==2: print "The number ",n," is a prime number." else: x=2 while x<=math.sqrt(n): ...
3c8d30cae53e45dd20d570fac23db51c1fa9d362
qqzii/TMS
/lesson24/task59.py
363
3.5
4
import json import requests response = requests.get(' https://www.nbrb.by/api/exrates/rates/dynamics/145?startDate=2021-6-18&endDate=2021-6-25') data = json.loads(response.text) print(data) def average(data_): summa = 0 days = 0 for i in data_: summa += i['Cur_OfficialRate'] days += 1 ...
041284c8f1c934ea31ddb0974ed0b051f883d794
949429516/Cloud
/Dijkstra_algorithm.py
1,807
3.8125
4
""" 狄克斯特拉算法 *不能有负权边 1.找出最便宜的节点 2.计算该最便宜的节点前往各个邻居的开销,并且更新邻居节点 a 6 1 start 3 final 2 5 b """ # 每个节点到邻居的权重 graph = {} graph['start'] = {} graph['start']['a'] = 6 graph['start']['b'] = 2 graph['a'] = {} graph['a']['fin'] = 1 graph['b'] = {} graph['b']['a'] =...
fa388d9aa93c130de96fe3d33b8b8800cb9ea05b
humachine/AlgoLearning
/leetcode/Done/38_CountAndSay.py
941
3.640625
4
#https://leetcode.com/problems/count-and-say/ ''' All sequences start with '1' 1 is one 1 = 11 11 is two 1s = 21 21 is one 2 one 1 = 1211 1211 is one 1 one 2 two 1s = 111211 Given a number n, return the nth number string in this sequence. ''' class Solution(object): def findNextSequence(self, curr): res =...
4938dcf2cd40196b545e3285e8a2a3559da72bad
traffaillac/traf-kattis
/excursion.py
318
3.5625
4
i = 0 # index of first 1 in sorted list j = 0 # index of first 2 in sorted list swaps = 0 for k, c in enumerate(input()): if c == '0': swaps += k - i # swaps to put 0 at index i in list of size k i += 1 j += 1 elif c == '1': swaps += k - j # swaps to put 1 at index j in list of size k j += 1 print(swaps)
254554bb8eb5f0de827f3be443d8ff4c34c5ec5d
anjalimi/IB-scripts
/dup in an array.py
165
3.609375
4
# A = [3, 4, 1, 4, 1] A = [1,2] A = sorted(A) duplicate = -1 for i in xrange(0, len(A)-1): if A[i+1] == A[i]: duplicate = A[i] break print duplicate
94b5f552c91352c065d855f2902b9368a12ed400
AdamZhouSE/pythonHomework
/Code/CodeRecords/2604/60876/241855.py
275
3.6875
4
import sys list=sys.stdin.readline().split(",") target=input() list[0]=list[0][2] for i in range(1,len(list)): list[i]=list[i][2] list.sort() jud=False for item in list: if item>target: print(item) jud=True break if not jud: print(list[0])
0dddebcd45e09a2bf4718562f27e117819ff8237
lucianogiannini/Intro-to-Programming-Python-
/Assignment 3/PS3_Part3.py
647
3.84375
4
ducks = ["Pack", "Nack", "Lack", "Quack", "Kack", "Ouack", "Jack", "Mack"] print(ducks) ducks = sorted(ducks) print(ducks) ducks.append("Zach") print(ducks) corner = ducks.pop(5) print(ducks) ducks.insert(2,"Tack") print(ducks) ducks = sorted(ducks) ducks.reverse() print(ducks) ducks.insert(2,corner) prin...
212082633c637faa60594ab755d3ef2af57b35f0
AK-171261/matrix_programmes
/matrix_addition_subtraction.py
4,462
4.1875
4
''' Matrix addition and subtraction are element by element operation. No of row in matrix1 = No of row in matrix2 No of column in matrix1 = No of column in matrix2 m1 = [[10,20], [30,40], m2 = [[1,2],[3,4]] res = m1+m2 [[11,22],[33,44]] ''' ''' Matrix multiplication is not element by element operation. No. of column in...
cc8c61b72d2c68e5d6fa9cfb36cb7d98899b2689
vladimir-babichev/advent-of-code-2019
/solution/day5.py
3,917
3.515625
4
#!/usr/bin/env python3 import os from typing import List from solution.day2 import Day2 # from day2 import Day2 class Day5(Day2): def __init__(self, input=[], phaseSetting=None): self.programPos = 0 self.inputIdx = 0 self.finished = False if type(input) == str: self.rea...
e8e7eacd58714d89a325ded3d8abd3a96b0769af
livelifeyiyi/myleetcode
/155. Min Stack.py
1,027
4.03125
4
class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] self.mini = None def push(self, x): """ :type x: int :rtype: void """ self.stack.append(x) if self.mini is None: ...
2ed3f2f6ba910f13de789cbd40815e301ac2a37e
yukti99/Computer-Graphics
/LAB-2/polygon.py
1,547
3.546875
4
from graphics import * boundary_values = [] xvmin = -450 yvmin = -450 xvmax = 450 yvmax = 450 xwmin = -2000 ywmin = -2000 xwmax = 2000 ywmax = 2000 def line(x0,y0,x1,y1,win,color): dx = x1 - x0 dy = y1 - y0 xsign,ysign = 1,1 if (dx < 0): xsign=-1 if(dy < 0): ysign=-1 dx = abs(dx) dy = abs(dy) if (dx > ...
2becf3aec84be1dca2625df23ff2637c340d5a94
romanpindela/pa-music-library-pa-python-sample-master-progbasic-python-codecool
/music_reports.py
2,257
3.640625
4
artist_id = 0 album_id = 1 year_id = 2 genre_id = 3 time_id = 4 def get_albums_by_genre(albums, genre): """ Get albums by genre :param list albums: albums' data :param str genre: genre to filter by :returns: all albums of given genre :rtype: list """ genre_albums = [album for album in...
eaccb7406489203d2e124b5853e9e42070261f79
Priya2120/function
/que 3.py
276
3.515625
4
# Q1 . Aapko max function ka use krke di hue list me se sbse # bada value print krvani hai. Input num = [3, 5, 7, 34, 2, 89, 2, 5] def MAX(num): i=0 k=num[i] while i<len(num): b=num[i] if b>k: k=b i=i+1 print(k) MAX(num)
9318e92cfb25e63243b4ffb69ce01757cba3c2a7
jpetersen85/homework1
/SolutionRegex.py
878
3.921875
4
##### Homework 1 ##### ##### CNS-380/597 #### import re #Write a regular expression to fit the following: #1 Phone number in the format of # xxx-xxx-xxxx regex1 = '\d{3}\-\d{3}\-\d{4}' #2 Phone number in the format of # (xxx) xxx-xxxx regex2 = '\(\d{3}\)\s\d{3}\-\d{4}' #3 Phone number in the format of # +x xxx...
4fcf4e58cf116fdfb19d063e20e861a814175a77
CurtisJohansen/numpy-pandas-visualization-exercises
/numpy_exercises.py
1,351
4.21875
4
import numpy as np a = np.array([4, 10, 12, 23, -2, -1, 0, 0, 0, -6, 3, -7]) # 1. How many negative numbers are there? print(a) np.count_nonzero(a < 0) # 2. How many positive numbers are there? print (a) np.count_nonzero(a > 0) # 3. How many even positive numbers are there? is_pos = a > 0 is_even = a % 2 == 0 pos_e...
c948c898e0ba49e1bccdcba614a972737164319f
cepGH1/dfesw3cep
/pyth5.py
331
4.03125
4
colNum = int(input("how many columns would you like? ")) rowNum = int(input("how many rows would you like? ")) print(colNum*rowNum) my2DArray = [[0 for col in range(colNum)] for row in range(rowNum)] print(my2DArray) for row in range(rowNum): for col in range(colNum): my2DArray[row][col] = row*col print(m...
acd487f9c792e0214f0231ba7a270099750b0f94
magello-group/machine-learning
/k-means/lab2/Plotter.py
820
3.546875
4
import matplotlib.pyplot as plt class Plotter(object): """Plotter just to make plotting easy.""" def __init__(self, xAxis, yAxis): self.xAxis = xAxis self.yAxis = yAxis plt.ion() # set plot to animated def show(self): plt.show(block=False) def setAxes(self): axes = plt.gca() axes.set_xlim(self.xAxis)...
ec824d83193793c3c24ce4d8681944b2cdfd795c
liweichen8/Python
/3onlyodd.py
363
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 20 17:07:32 2020 @author: liweichen """ def only_odd_digits(n): b = len(str(n)) for x in range(1,b+2,1): num = n//(10**(b-x)) print(x, num) if num%2 == 0: break if x <= b: return False el...
b1653a3841f0dcbbd4426f5a20d7784b7de6af26
tapaseid/dsa
/dynamic_programming/rotate_an_array.py
386
4.125
4
# Left rotate a sorted array def leftRotate(arr, d): # Time complexity O(n) n = len(arr) reverse(arr, 0, d) reverse(arr, d+1, n-1) reverse(arr, 0, n-1) return arr def reverse(arr, start, end): while start < end: arr[start], arr[end] = arr[end], arr[start] start += 1 end -= 1 # driver method if __name_...
472608bc89b27b3110c3f82254ca6133f0d09763
prisetio/Python
/belajar-python/list_edit.py
245
3.578125
4
# Membuat List nama = ["priyo", "setio"] # Menambah Data ke List nama.append("bangun") # Mengakses List nama[0] # Menghapus Data dari List nama.remove("priyo") # Mengubah Data di List print(nama) nama[1] = "bening" print(nama)
5c2ec8d37720008e93b1e34778c84aca9f11be4f
imSamiul/Python_Exercrsises
/break and continue statement.py
1,767
4.125
4
# # 1. print string within str # for val in "String": # if val == "i": # break # print(val) # print("The end") # # 2. print 1 to 4 # i = 0 # while i < 6: # x = i + 1 # print(x) # i = x # if i == 4: # break # print("the end") # # 3. print string without i # for val in "string": # ...
fd42a644a102a29de7138a941cfd19aa3d0f4fba
gergodanko/OW-2019-09-06-
/sum.py
96
3.71875
4
sum=0 for i in range(101): sum+=i print("The sum of the first 100 number : {}".format(sum))
6fd63dc402cb08e9aa072581e5c69b18ec278798
Hethsi/project
/Lines.py
155
4.09375
4
P=input("Enter the paragraph:") num_lines=0 with open(P,'r')as f: for line in f: num_lines+=1 print("Number of lines in a paragraph:") print(num_lines)
cd35722eb7f5df662f0adfd220b6df45d2f6ba05
behrouzmadahian/python
/python-Interview/3-search/3-interpolationSearch.py
1,177
4.3125
4
''' The Interpolation Search is an improvement over Binary Search for instances, where the values in a sorted array are uniformly distributed. Binary Search always goes to middle element to check. On the other hand interpolation search may go to different locations according the value of key being searched. For e...
897d76e8d0c0c1022113751b5c08cbbe9925b1b2
akashvshroff/Puzzles_Challenges
/longest_substring.py
718
4.03125
4
def longest(s): """ Return the longest alphabetical substring. Eg: >>> s = 'abshdbhsbaaaabbbbdddddad' >>> longest(s) "aaaabbbbddddd" """ max_str, max_len = '', 0 temp_str, temp_len = '', 0 if len(s) <= 1: return s for i in range(len(s)): if not temp_str: ...
d5f1c04caeb4d0bca0cd1e428f8daaedf1c5cec4
Andrewlearning/Leetcoding
/剑指offer/32.整数中1出现的次数(从1到n整数中1出现的次数).py
2,146
3.625
4
class Solution: def NumberOf1Between1AndN_Solution(self, n): print(self.helper(n)) return self.helper(n) def helper(self,n): res = 0 bit = 1 while bit <= n: high = n / bit #31155 / 100 = 311 low = n % bit #31155 % 100 = 55 # (311 + 8...
b530a89f3baf152a18b702913984a4482bd68469
pbcquoc/coding-interview-python
/sort_algorithm/sort_big_int.py
327
4.15625
4
""" https://www.geeksforgeeks.org/sorting-big-integers/ * if the lengths are different, just compare length * if the lengths are same, compare lexicon """ def sort_big_int(arr, n): arr.sort(key=lambda x: (len(x), x)) arr = ["54", "724523015759812365462", "870112101220845", "8723"] sort_big_int(arr, len(arr)) prin...
143888c8ad4d8791e96a759671ee3a5fcb89a75c
daniel-hampton/computer_vision_scratch
/tests/test_sample.py
345
3.71875
4
""" Example test file """ import unittest from .context import sample class MyTest(unittest.TestCase): def test_words(self): words = "My String" self.assertEqual(words, sample.myprint(words), msg="hello there") def test_myfunc_adds_2(): assert sample.myfunc(3) == 5 if __name__ == '__main...
0461f684ef6cc6bb0a6242bf8198c2df6a10b103
Hardworking-tester/HuaYing
/practice/test35.py
431
3.8125
4
# encoding:utf-8 # author:wwg def bubbleSort(nums): for i in range(len(nums)-1): # 这个循环负责设置冒泡排序进行的次数 for j in range(len(nums)-i-1): # j为列表下标 if nums[j] > nums[j+1]: # nums[j] = nums[j+1] nums[j], nums[j + 1] = nums[j + 1], nums[j] print nums ...
4ac8bcea876dc6c91b6e2394a8e41b4cd5939457
procendp/Study_alone
/나도코딩_파이썬/13_continue_break.py
694
3.640625
4
# continue absent = [2, 5] # 2, 5번 결석일 때, 제외하고 출석 부르게 하는. nobook = [7] for student in range(1, 11) : # 1 ~ 10번까지 출석번호 있음 if student in absent : # student가 absent에 포함됐다면, 즉, 결석했다면 continue. continue # continue 만나면 내려가지 않고 다음 반복으로. elif student in nobook: print("오늘 수업 여기까지, {0}는 교무실로 따라와".format(s...
8af0f0b7f4424ad3f893df7f8bcdf040afc7d4f6
felipesantos10/Python
/mundoDois/ex039.py
698
4.1875
4
#Faça um programa que leia o ano de nascimento de um jovem e informe, de acordo com a sua idade, se ele ainda vai se alistar ao serviço militar, se é a hora exata de se alistar ou se já passou do tempo do alistamento. Seu programa também deverá mostrar o tempo que falta ou que passou do prazo. nome = str(input("Qual o...
cec6328f6f7a001296ca256d43cc8203cbeb14e2
derick-droid/pythonbasics
/nestedloops.py
362
4.3125
4
for x in range (5): for y in range (4): print(f"{x}, {y} ") #EXERCISE OF NESTED LOOPS numbers = [5, 2, 5, 2, 2 ] for number in numbers: # BUT NO NESTED LOOPS USED print("*" * number) # USING NESTED LOOPS numbers = [5, 2, 5, 2, 2] for number in numbers: output = "" x_counts = output for i...
f63b0375131142aa82b83c71c726e551540c6508
skanin/NTNU
/Informatikk/Bachelor/Codewars/Tribonacci.py
393
3.921875
4
dic = {} trib = [] def tribonacci(signature, n): if n == 0: return [] if n in [1,2,3]: return signature[n-1] f = 0 if n in dic: return dic[n] else: f = tribonacci(signature, n-1) + tribonacci(signature, n-2) + tribonacci(signature, n-3) dic[n] = f trib.ap...
a48b12f11fe55f8ce26e9067425388ccf9774899
munsangu/20190615python
/START_PYTHON/3日/09.タプル、ディクショナリー、集合/07問題.py
510
3.765625
4
print("\n===문제1===") a = set([1,2,3,4,5,6]) b = set([4,5,6,7,8,9]) c = set([5,6,7,8,9,10]) num1 = tuple(a.intersection(b,c)) num2 = tuple(a.union(b,c)) num3 = tuple(a.difference(b,c)) print("교집합 : ", num1,"\n합집합 :", num2, "\n차집합 : ", num3) print("\n===문제2===") a = [1,1,5,5,4,3,6,7,2,1,5,5,8,5] a = list(set(a)) print(...
86780ea69ccc3aa118b4439370dfc9dea468e461
prabhathkota/MLPractise
/jumpStartScikitLearn/8_ensembles/7_gradient_boosting_classification.py
772
3.546875
4
# Gradient Boosting Classification # Gradient Boosting is an ensemble method that uses boosted decision trees like AdaBoost, # but is generalized to allow an arbitrary differentiable loss function (i.e. how model error is calculated). from sklearn import datasets from sklearn import metrics from sklearn.ensemble import...
d598a728b8d54f3aa36754cae7709b7876f92c46
Vaseem-Sh/20A91A05B8_VASEEM_CSE.B
/whileloop.py
619
4.25
4
#While loop initial_value=int(input('Enter the start value ')) ending_value=int(input('Enter the end value ')) stepcount=int(input('Enter the stepcount value ')) while (initial_value<=ending_value): print(initial_value, end=" ") initial_value=initial_value+stepcount print('After the end of loop...
f196a73648efac611da3ea77bd35bd0d7ff44e8d
atkabyss/1G_python
/定期テスト/K019C1068_石井恭輔_Exam013.py
345
3.65625
4
holiday = ['元日', '成人の日', '建国記念の日', '春分の日', '昭和の日', '憲法記念日', 'みどりの日', 'こどもの日', '海の日', '山の日', '敬老の日', '秋分の日', '体育の日', '文化の日', '勤労感謝の日', '天皇誕生日'] i=0 while i <= 15: print("祝日:" + holiday[i]) i=i+1
63c0dc6db22032e043b1c99f70652a06709a09dc
ankit3466/Python
/problem12.py
1,167
3.515625
4
import pyqrcode from googlesearch import search n=input("Enter your search :") url=[] j=1 for i in search(n,stop=3): url.append(i) qr=pyqrcode.create(i) qr.svg(str(j)+".svg",scale=8) j=j+1 ## create a html code for the images <html> <body> <h1> QRCODE for search hello </h1> ...
63fe98b347d59dace793f1b1e34fdce9f9ee90ad
jlisi321/Python-Learning-Programs
/guessing_game.py
456
3.984375
4
import random print ("Guessing Game!(1-100)") guessCheck = False randomNumber = random.randrange(1, 100) tries = 0 while(guessCheck == False): tries = tries + 1 guess = int(input("Guess: ")) if(guess == randomNumber): guessCheck = True else: guessCheck = False if(guess < randomNumber): print ("You gue...
d48cb4e9127a67f9726a63f4a1f27095424d35c3
prem-n/web-crawler
/wiki.py
11,018
4.3125
4
#!/usr/bin/env python """ Module for crawling through Wikipedia. Each URL is represented as a Hyperlink object. Each Hyperlink object contains the path length from this page to PHILOSOPHY. This is used to optimize the path length computations for random pages by re-using path lengths from visited pages. Candidate so...
dd16bac64e7d51c178ee04a414e6156ee493ab22
chenxu0602/LeetCode
/897.increasing-order-search-tree.py
2,202
3.8125
4
# # @lc app=leetcode id=897 lang=python3 # # [897] Increasing Order Search Tree # # https://leetcode.com/problems/increasing-order-search-tree/description/ # # algorithms # Easy (70.40%) # Likes: 771 # Dislikes: 474 # Total Accepted: 73.6K # Total Submissions: 103.1K # Testcase Example: '[5,3,6,2,4,null,8,1,null...
f73ceedc377ed5f053ae6b793c4711caceadace4
EgbieAndersonUku1/ProjectEuler
/palindrome_product.py
1,134
4.15625
4
# -*- coding: utf-8 -*- # problem 4 #A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. # alias on EulerProject -> Walter_brian220 import time def is_palli...
3baa55cbea5d2d9fa1c827e7da4388897b99fffb
aahladv/Adaptive_MATLAB
/Scrap/Sim 6/Glitch.py
1,879
4.03125
4
print("Hey I'm Glitch, your new assistant") x= input("What's your name:") print ("Hey there ", x) y=input("What's your gender?") if y== "male": print("welcome gentleman") elif y== "female": print("Hey sweet lady/girl") else: print("so you don't prefer to say") z=input("Where are you from :") if z=="hyderaba...
2ca9a5d2fe8aa50cd876fabf14391d6ba19e9071
cheshyre/advent-of-code
/2020/15/counting.py
293
3.515625
4
def do_step(last_called_dict, last_num_called, iteration): cur_num = 0 if last_num_called in last_called_dict: cur_num = iteration - last_called_dict[last_num_called] - 1 last_called_dict[last_num_called] = iteration - 1 return last_called_dict, cur_num, iteration + 1
f6450552c0106b00017a25d72dc3867df94463b8
shenzhichen0821/demo_test
/sorting/radix/radixSorting.py
1,231
3.875
4
# -*- coding:utf-8 -*- from sorting.utils import sorting @sorting("radix") def radixSorting(source_list): """ 基数排序 :param source_list: :return: """ for dest in range(1, len(str(len(source_list))) + 1): source_list = countingSortingByElement(source_list, dest) return source_list de...
964cf665eec8cb6eb2b4f5b887dc05d70cb8db6f
tsilva00/Curso-em-V-deo
/pythonexercicios/ex006.py
248
3.953125
4
#código que recebe um número e devolve o seu dobro, triplo e a raiz quadrada n = int(input('Escolha um número:')) print('O dobro do número {} é {}!\nO triplo é {}!\nA raiz quadrada de {} é {}!'.format(n, (n*2), (n*3), n, (n**(1/2))))
8eefc55186aa98636c8ee3e93acd43520dd12429
NeilWangziyu/Leetcode_py
/flatten.py
869
3.703125
4
# Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child class Solution: def flatten(self, head): """ :type head: Node :rtype: Node """ list_r...
8ddbc6dac3073055eb44b5de083edc9d5fa5efce
lucaspetrus/lambdata
/lambdata/OverwatchCharacters.py
998
3.5625
4
class Overwatch: """This class is used to take in Overwatch Characters attributes in order to help assemble the correct team""" def __init__(self, playerclass=10, health=5, speed=6, damage=0, healing=0, shield=0, winrate=0): self.playerclass = playerclass self.health = health self.speed ...
d26a96ce8ae4e200447a944f1e652168f6070996
supby/algo_train
/colorful_numbers.py
1,183
3.65625
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ def get_digits(number): return [int(s) for s in str(number)] def get_power_set(number): digits = get_digits(number) ret = [] a = [0]*len(digits) combinations(a, 0, ret, digits) return ret d...
0bdcef25517a2abcae66032f8f63132b03767efd
alexanderozerov/stepic.org-challenges
/python_basic/course_512/python_3_7_3.py
188
3.625
4
dicts = {input().lower() for _ in range(int(input()))} words = set() for i in range(int(input())): m = input().lower().split() words.update(m) for k in words - dicts: print(k)
844bc36ac71c2f4f18e6203aa7d45b3cdb108690
jpl1991/Machine-Learning
/Python/sort2DArray2.py
482
3.765625
4
def sortMatrix(matrix): row_len = len(matrix) col_len = len(matrix[0]) #temp = [0]*(row_len*col_len) temp = [] for rows in matrix: for col in rows: temp.append(col) temp.sort() k = 0 for i in range(0, row_len): for j in range(0, col_len): matrix[i][j] = temp[k] k+=1 return matrix matrix = [[ ...
a0cc799ae98fea033fb1d60e5d320e74096d2b8a
zhangchizju2012/LeetCode
/867.py
1,743
3.6875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sun Jul 8 20:11:55 2018 @author: zhangchi """ class Solution(object): def primePalindrome(self, N): """ :type N: int :rtype: int """ if N == 1: return 2 elif N <= 7: for i in rang...
3588920fdb807bb8f5e21dcf152a732935819044
sornastalin/codekata
/digits.py
86
3.75
4
n=int(input("enter number:")) count=0; while<n>0): count=count+1 n=n//10 print(count)
96e5180d9d960bc81868ee154f178ed908a60a00
DrkSephy/practice
/fb/overlapping_time.py
552
3.859375
4
# Given a list of tuples of start/end times, # determine the number of time covered by the intervals. # i.e: input -> [(1, 4), (2, 3)] = 3 # input -> [(4, 6), (1, 2)] = 3 # input -> [(1, 4), (6, 8), (2, 4), (7, 9), (10, 15)] = 11 # [(1, 4), (2, 4), (6, 8), (7, 9), (10, 15)] def interval(arr): arr.sort() ending =...
e09853b5d84d6ddf98ce0048217d6d38da946f14
gergob/project_euler
/python/problem16__power_digit_sum/problem16__power_digit_sum.py
515
3.828125
4
__author__ = 'greg' """ 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def get_sum_of_power(number, power): result = number ** power result_as_string = str(result) print "Number %s on %s power is %s" % (str(number), str(power), st...
07016ea41bfb794f7031b2974af066c23b248f98
raghuprasadks/pythontutoriallatest
/gui/simpleinterest.py
1,303
3.859375
4
# Import tkinter ''' from tkinter import * class SimpleInterest(): def __init__(self): window = Tk() window.title("Simple Interest Calculator") Label(window, text = "Annual Interest Rate").grid(row = 1,column = 1, sticky = W) Label(window, text = "Number of Years").grid(row = 2,column = 1, sticky = W) L...
7e01332c593dc86f42f2dbbfe1eb95086e7e13e4
armenjuhl/PeaksAndValleys
/src/peaksAndValleys.py
2,444
4.28125
4
test_data = ['5', '6', '7', '6', '5', '4', '5', '6', '7', '8', '9', '8', '7', '6', '7', '8', '9'] """ peaks - Returns the indices of peaks. A peak has a lower number on both the left and the right. valleys - Returns the indices of 'valleys'. A valley is a number with a higher number on both the left and the right. pea...
d4d9a474a5a790a41e87027466beb3c7f462e650
nveenverma1/Dataquest
/Practice/3_Pandas_n_Numpy_Fundamentals/Practice/Exploring Data with pandas-292.py
2,156
3.796875
4
## 2. Using iloc to select by integer position ## import pandas as pd import numpy as np f500 = pd.read_csv("f500.csv", index_col=0) f500.index.name = None f500.loc[f500["previous_rank"] == 0, "previous_rank"] = np.nan fifth_row = f500.iloc[4] first_three_rows = f500[:3] first_seventh_row_slice = f500.iloc[[0, 6], :...
234dd82aa5d3a477b51eeefd45f71fa7c3705961
Prithamprince/Python-programming
/selectionsort.py
256
3.734375
4
array=list(map(int,input().split(" "))) size=len(array) for i in range(0,size): for j in range(i+1,size): if(array[j]<array[i]): min=array[j] array[j]=array[i] array[i]=min print(*array,sep=" ")
e15070c1f2236570f5424c945be23ab2c74d9150
meking03/MIT6001
/book_script.py
10,591
4.1875
4
# -*- coding: utf-8 -*- """ Created on Sun May 3 13:24:34 2020 @author: egultekin """ ### Lesson 1 : What is computation? # print('Yankees rule, ', 'but not in Boston!') # x, y = 2, 3 # x, y = y, x # print('x = ', x) # print('y = ', y) ### Lesson 2 : Branching and iteration # def find_largest_odd(x, y, z): # ...
d708ceb31cbd3f8decb20bafc4589808d52d2c04
AlexRodriguezVillavicencio/Backend
/tarea/semana 1/1.YanQuenPo.py
1,782
3.8125
4
from random import choice #JUEGO DE YANQUEPO print('***************************************************************') print('***************************************************************') print('*************!BIENVENIDO AL JUEGO DE YANQUENPO!****************') print('*************************************************...
e98e73c6f472fa97e7d85dc4172838fd4e4b400c
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/anagram/657763fe68c446b8a4521dacc7d87b56.py
614
3.78125
4
from collections import Counter class Anagram(object): def __init__(self, word): self.source_word = word.lower() self.source_matcher = Counter(self.source_word) def match(self, prospects): """ Compare the source word against the list of prospects and return found ana...
20b26b2398e53b10a54bbaec73d85724659c9367
Diogogrosario/FEUP-FPRO
/RE05/adigits.py
527
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 23 21:45:01 2018 @author: diogo """ def adigits(n1, n2, n3): n1=int(n1) n2=int(n2) n3=int(n3) if n1>=n2>=n3: return (n1*100)+(n2*10)+n3 elif n1>=n3>=n2: return (n1*100)+(n3*10)+n2 elif n2>=n1>=n3:...
6ce05b89b18662e9e0830d3a72766868e1b90606
CNZedChou/ReviewCode
/pythoncode/multisubstraction.py
908
3.828125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- """ @Author : Zed @Version : V1.0.0 ------------------------------------ @File : multisubstraction.py @Description : @CreateTime : 2021-1-15 14:23 ------------------------------------ @ModifyTime : """ import random import time cor...
4f86e5c338b123530ade81a51e24e98ed8734760
jytaloramon/monitoria-estrutura-dados-2k20
/aula5/main_editor_text.py
1,146
3.703125
4
from Stack import Stack def main(): status = True text = '' stack = Stack(100) operation = ('rm', 'add') while status: print(text, end='\n\n') status = bool(int(input('Continuar (0 = N; 1 = S)? '))) if not(status): continue op = int( inpu...
572ece1d8dca5f36e1ec05c0dd4f2f27d9c76ba8
fabiobarretopro/Aprendendo-Python
/Classes01.py
423
3.703125
4
class MinhaClasse(object): pass class Pessoa: def __init__(self, nome, idade): self.nome = nome self.idade = idade class PessoaFisica(Pessoa): def __init__(self, cpf, nome, idade): Pessoa.__init__(self, nome, idade) self.cpf = cpf p1 = Pessoa("Marcos", 28) print(p1.nom...
6788bbcc4014aba0e9ce8289379104bfc2bdacc8
NikossAndri/ergasies_py
/ergasia5.py
962
3.625
4
import random sunolo=0 n=input("Give dimension 3 or higher:") #Με <3 δεν σχηματίζονται τριάδες m=input("Give dimension 3 or higher:") #Με <3 δεν σχηματίζονται κάθετες ή διαγώνιες τριάδες for loop in range(1, 101): sos=0 n=int(n) m=int(m) k=n*m if (k%2==1): l=(k//2)+1 else: ...
2fd532bff3d6545cfbd04c844bda90ce59a3fe37
vsofat/SoftDev
/Fall/17_csv2db/db_builder.py
1,436
3.703125
4
#Kiran Vusksanaj & Vishwaa Sofat: Goldfish #SoftDev pd1 #skeleton :: SQLITE3 BASICS #07 Oct 2019 # initialized from care packagej import sqlite3 #enable control of an sqlite database import csv #facilitate CSV I/O DB_FILE="discobandit.db" db = sqlite3.connect(DB_FILE) #open if file exists, otherwise create...
7c4aa51e5d19b9f2675eb655c00aa8419cd787b1
tiscal404/PyPNB
/Aula02/exercicio-03.py
546
4.03125
4
#! /usr/bin/python3.6 from datetime import datetime def ageinseconds(y,m,d): try: birthday = datetime(int(y),int(m),int(d)) diff = (datetime.now() - birthday).total_seconds() return 'You have lived {} seconds so far'.format(diff) except: return 'Sorry. Something went wrong!' ...
b2f9e4b23d8d91dcc00d6c55d62210c50b9d503c
rmount96/Digital-Crafts-Classes
/programming-101/strings2.py
391
3.640625
4
name = "Ryan" place = "Nebraska" today = "Tuesday" emotion = "well" print(name+ " " +place) haiku = f"\tHello {name} \nI hope that your {today} is going well. \n\tI'm really {emotion}" print(haiku) print(f"\tHello {name} \nI hope that your {today} is going well. \n\tI'm really {emotion} ") print("\tHello %s \nI hope...
2fc8118176c696a8eaf3ab358498febb24ff354f
trewarner/ErrorCode-404
/test1.py
224
3.640625
4
def buggy() x = input("Are you happy? (yes or no)") if (x=="no")) print("cheer up") elif (x=="yes) print(that's nice" else print("I don't know what you mean...") if [1+2+3] = [6: return {str
aa8c3679810282c8a8ae4b4b00c0f81c32ca53be
sadroschott/Computer-Vision-Action
/framwork learn/viusal/tflearn_visual_tet.py
4,634
3.71875
4
# -*- coding: utf-8 -*- """ Convolutional Neural Network for MNIST dataset classification task. References: Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. "Gradient-based learning applied to document recognition." Proceedings of the IEEE, 86(11):2278-2324, November 1998. Links: [MNIST Dataset] http://...
5e5c0f27279a85b80a2e7af5df6912aabc75accc
MohammadUmer526/PythonCrashCourse
/Chapter10/10.8(Cats And Dogs).py
613
3.8125
4
file_names = ['C:\\Users\\Muhammad Umer\\Desktop\\dogs.txt' , 'C:\\Users\\Muhammad Umer\\Desktop\\cats.txt' ] # path of a files in a list for file_name in file_names: # loop for accessing two files print("Reading file: "+ file_name) # give the name of file individually, after first file name it goes down then co...
05658ee71c3cf6d7a5e5791eebeba6aaa75116f4
atolat/PreCourse_1
/Exercise_3.py
3,209
4.09375
4
class ListNode: """ A node in a singly-linked list. """ def __init__(self, data=None): self.data = data self.next = None class SinglyLinkedList: def __init__(self): """ Create a new singly-linked list. Takes O(1) time. """ # Initialize List ...
6a3a4806530bf524ba4e91fb0451515eb8c6e1c9
oppalu/Algorithm
/leetcode/top100/279.py
1,329
3.609375
4
# perfect squares # Given a positive integer n, find the least number of perfect square numbers # (for example, 1, 4, 9, 16, ...) which sum to n. # n=12,output=3(4+4+4) # n=13,output=2(4+9) from math import floor, sqrt import sys class Solution: def find(self, n): if n in self.data: return ...
6b669aa81406d9c5d3ea368de447e8ce302c81dd
gillerbiller/HangMan
/HangMan.py
2,701
3.890625
4
import random word = "" wordDict = {} listOfUnderscores=[] chances = 0 sequence_of_guessed_letters = [] def setup(): global word global sequence_of_guessed_letters word = (random.choice(["pop", "under", "garden", "pie", "happy", "awkward" ,"bookkeeper"])) def key_value(): for x in range(len(...
156a3a2b5d711470bf69974d18d91f901ffa11b8
Nortsev/algo_and_structures_python
/Lesson_2/2.py
575
4.0625
4
""" 2. Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560, то у него 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). """ def recursion(a, i, j): if a == 0: print(f'Четных - {i}; Нечетных - {j}') else: if a % 2 == 0: i += 1 els...
3b297af778b56c7fa4f20e028dfe116161643148
c940606/leetcode
/Non-overlapping Intervals.py
1,118
3.703125
4
# Definition for an interval. class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e class Solution(object): def eraseOverlapIntervals(self, intervals): """ 给定一个区间的集合,找到需要移除区间的最小数量,使剩余区间互不重叠。 注意: 可以认为区间的终点总是大于它的起点。 区间 [1,2] 和 [2,3] 的边界相互“接触”,但没有相互重叠。 --- 思路: 贪心算法 ...
853a06d2857e8a9cdb5caa5baded899f93943a38
svamja/project_euler
/p056-digit-sum.py
388
3.578125
4
import time start_time = time.time() max_sum = 0 for a in xrange(80, 100): for b in xrange(80, 100): n = a**b s = str(n) # my first lambda! digit_sum = reduce( (lambda x, y: int(x) + int(y)), s ) if digit_sum > max_sum: max_sum = digit_sum print max_sum end_...
891410a3b9128aec02a8f77d8995eeeefd7a0b2f
AlexandreInsua/ExerciciosPython
/exercicios_repaso/exercicio31.py
857
4.21875
4
# Programa que acepte por parámetros de consola 2 números enteros (base y exponente) y # calcule base elevado a exponente. # Ej exponente 2 8 # Resultado= 256 # Nota: Valida que los datos sean correctamente pasados. import sys #print("numero de parametros" + str( len(sys.argv) ) ) #print("parametros:"+ str( sys.ar...
ec964c7742cdbe2284cf654064f3d8d1cc2ede60
luid95/python-course
/09-listas/main.py
1,709
4.34375
4
""" LISTAS [arrays] Son colecciones o conjuntos de datos/valores, bajo un unico nombre. Para acceder a esos valores usar el indice numerico. """ # Definir lista con [] peliculas = ["Batman", "Spiderman", "Star Wars"] # Definir lista con function list() cantantes = list(('2pac', 'Orake', 'JLO')) years = list(...
7737733ad885f737630ba47086dfc52f12be0870
techtalksaty/PythonCoreLanguageTutorial
/12-NumberGuessingGame.py
585
4.21875
4
import random #Number Guessing Game ''' 1-Random Library 2-User Input 3-DataType Casting 4-While Loop 5-If - Else ''' secret_num = random.randrange(1,5) your_guess = 0 guess_count = 0 max_guesses = 3 has_more_guess = True while int(your_guess) != secret_num and has_more_guess: if guess_count < max_guesses: ...
9838ed13bc216b60a6eb5646ebd5150d996fcbe9
DENSLIN/DENSLIN
/Allocation.py
399
3.546875
4
test = int(input()) print("\n") def function(x, y): count = 0 y = int(y) for data in x: data = int(data) if y >= data: y = y - data count += 1 return count while test >= 1: n, b = input().split() a = sorted(input().split()) buy_house = function(a,...
869bbfdff03d1c2c5cc50ee21bb779ef4d2a1861
RodFernandes/Python_USP_Curso_Ciencias_da_Computacao_1
/pontos.py
294
3.71875
4
import math xa=float(input('Entre com o valor de XA:')) xb=float(input('Entre com o valor de XB:')) ya=float(input('Entre com o valor de YA:')) yb=float(input('Entre com o valor de YB:')) d=math.sqrt(((xb-xa)**2)+((yb-ya)**2)) if d >= 10: print('Longe:',d) else: print('Perto:',d)
850704603bd635dfd91077978ede975b69e7cdae
OliverTarrant17/CMEECourseWork
/Week3/Code/Vectorize1.py
1,110
3.8125
4
#! usr/bin/python """ Author - Oliver Tarrant A python version of Vectorize1.R which uses vectorisation to summ all the elements of a 1000x1000 matrix of random uniform variables""" import scipy as sc import timeit import time M = sc.random.uniform(0,1,[1000,1000]) # Creates a matrix of random # unifro...
f637b2f968089da2c0502c5cf668a95f648f0ea6
wertson/PCClass
/pos_system.py
2,831
4.3125
4
# WERTSON FURTADO # COMI-1150-399# FINAL PROJECT # 05/01/2019 # PROGRAM TITLE: POS SYSTEM # PROGRAM DESCRIPTION: THE PROGRAM WILL GIVE THE USER 3 OPTIONS TO ADD TO THE CHECK (CHEESEBURGER, PIZZA, SODA) # ONCE THE USER SELECT A ITEM, THERE WILL BE OPTIONS ON HOW THEY WANT THAT ITEM, SUCH AS #...
9899e50f86ff76e8b901e5444a8000d6ac6db543
mariaciornii/Rezolvarea-problemelor-IF-WHILE-FOR
/Problema3. WHILE FOR IF.py
244
3.875
4
n = int(input('Introduceti n: ')) m = int(input('Introduceti m, m<n: ')) while (n % m == 0): n = n // m if (n == 1): print('Numarul introdus este o putere a lui ', m) else: print('Numarul introdus nu este o putere a lui ', m)
888f99d84630258727ec4c7c9b8e4fd3a97446e2
cnast/pong
/pong.py
5,219
4
4
# Implementation of classic arcade game Pong # To play, copy and paste code into Codeskulptor http://www.codeskulptor.org/ or visit http://www.codeskulptor.org/#user38_YnAr1o7lQ6ro2ON.py # Player 1 controls paddles with W & S; Player 2 uses Up and Down arrows import simplegui import random # initialize globals - pos...
b8804998ef8c286fd7683f7577c5ea0005e467cd
amitsaxena9225/XPATH
/Python_Evening_Batch/conditinal _statement.py
266
4.0625
4
#a = 15 a =(int(input("Enter the value::::::"))) if a==10 and a %2==0 : print("even") elif a==11: if a %2==0: print("even") else: print("odd") else: if a % 2 == 0: print("even") else: print("odd")
72f1cc96626efd7df93f4c059c95ac75c95d40d4
SeanM743/coding-problems
/play.py
593
3.59375
4
def suduko_check(board): n = len(board) def has_duplicate(b): block = set(filter(lambda x: x != 0, board)) return not len(b) == len(block) if any( [has_duplicate(board[i][j]) for i in range(n)] or [has_duplicate(board[j][i] for i in range(n))] for j in rang...
fbfd13a3f5254f9983370a64960f1726480a1670
southpawgeek/perlweeklychallenge-club
/challenge-101/roger-bell-west/python/ch-2.py
731
3.6875
4
#! /usr/bin/python3 import unittest def ot(pp): points=pp points.append(points[0]) xp=list() for i in range(3): xp.append(points[i][0] * (points[i+1][1]-points[i][1]) -points[i][1]*(points[i+1][0]-points[i][0])) xp.sort() if xp[0] <= 0 and xp[2] <= 0: return 1...
99ee8e5166902cd0c636ae727aad515e63668f1e
sumedha-0304/sumedha_
/vocabgame.py
1,837
3.65625
4
import tkinter from tkinter import * import random from tkinter import messagebox # you can add more words as per your requirement answers = [ "bit", "debug", "python", "vaccine", "angular", "graphics", "energetic", "passion" ] words = [ "itb", "ugbed", ...
ed4376ab5b2fcfc377e5ba7740f2238bb15ddfc3
Lucas-Guimaraes/Reddit-Daily-Programmer
/Easy Problems/291-300/296easy.py
1,287
3.890625
4
# https://www.reddit.com/r/dailyprogrammer/comments/5j6ggm/20161219_challenge_296_easy_the_twelve_days_of/ def twelve_days(): #Lst #1 fornames, #2 for ordinal, #3 each gift, #4 list to print each time num_lst = ["A", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve...