blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
c26c83862e011a002aa0f02afcbe2ba5827c3a21
reading-stiener/For-the-love-of-algos
/Trees/even_odd.py
1,057
3.984375
4
class Solution: def isEvenOddTree(self, root): level_list = {} def even_odd(root, level): if root: left_ans = even_odd(root.left, level+1) # append to list and check if level_list.get(level, -1) != -1: if level_list[le...
4042daf312212d5c47ed105d8996e9840cb3f2ed
rajib80/python-playground
/list-exercise/list-exercise-02.py
812
4.15625
4
# Open the file mbox-short.txt and read it line by line. # When you find a line that starts with 'From ' like the following line: # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 # You will parse the From line using split() # and print out the second word in the line # (i.e. the entire address of the person w...
2ab1838e48bd993e0da26526925017a1ba8812c7
kstolzenberg/LPTHW
/ex31.1.py
360
3.703125
4
# new game from scratch print "this is a new gyme. what do you want to play?" play = raw_input("..?") if play != "kittens" or play >= 15: print "ok now we are cooking with gas" what = raw_input("what are we cooking? ") if what == "meat" or what == "bean": print "yah i can smell it" else: print "time for gr...
fbe767958f6e5d4373a46b7d00117f84bdeae822
Aeee90/python
/algorism/EulerProject/9.py
219
3.671875
4
def solution(num): for a in range(num//3): for b in range(a+1, (num - a)//2): c = num - a - b if a**2 + b**2 == c**2: return (a*b*c) print(solution(1000))
bcc8de19dff3aad5224e90690ac0f2688e0e6dea
jenleap/adventofcode2018
/dayone/partone.py
745
4.03125
4
#Day 1: Chronal Calibration #Given a file containing frequency inputs, calculate the resulting frequency after all the changes in frequency have been applied. #Open the file. This file comes from https://adventofcode.com/2018/day/1/input. Inputs differ per user. frequency_inputs = open('input.txt') #Read each line of...
aaa80f255e06778ab27c8a44ca9b2b05d6c74a2e
coleenangelrose/python-exercises
/conditional-statements-exercise-2.py
303
4.125
4
hours = input('Enter Hours: ') try: hours = float(hours) rate = input('Enter Rate: ') try: rate = float(rate) pay = hours * rate print('Pay: ', pay) except: print('Error, please enter numeric input') except: print('Error, please enter numeric input')
1af3c816057364764100d63120322a8aecaa6e1d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2606/60672/277397.py
144
3.59375
4
ar=input() target=input() for i in range(len(ar)): if ar[i]==target: print(i) break elif i==len(ar)-1: print(-1)
4c64c991a2e57cb9a809714f97a0dcef94e90f4c
ChristophWuersch/dsutils
/src/dsutils/cleaning.py
6,856
3.640625
4
"""Data cleaning * :func:`.remove_noninformative_cols` * :func:`.categorical_to_int` """ from hashlib import sha256 import numpy as np import pandas as pd from sklearn.base import BaseEstimator, TransformerMixin def remove_duplicate_cols(df): """Remove duplicate columns from a DataFrame. Uses hashing to...
e671ddb57c075773ad5c7c868e20bd738377c6f9
jdcarvalho/aulas-gabriel
/8-operadores.py
1,563
4.25
4
#!/usr/bin/python3 # Operadores Unários valor = 1 # valor +=1 == valor = valor + 1 valor += 1 valor -= 1 print('\n----------------------Operadores Unários----------------------') print(valor) print('\n----------------------Operadores Binários----------------------') # Operadores Binários numero1 = 1 numero2 = 2 print(n...
e34fbd0bfdc8d888e19329150aeceee968722c29
manojkumar1053/GMAONS
/slidingWindow/avgSybarrayK.py
493
3.8125
4
def find_averages_of_subarrays(K, arr): result = [] windowStart = 0 windowSum = 0.0 for windowEnd in range(len(arr)): windowSum += arr[windowEnd] if windowEnd >= K - 1: result.append(windowSum / K) windowSum -= arr[windowStart] windowStart += 1 re...
c97c180471aecf1b4fceb6e2aa94e09f09194735
ErMax-Inc/Mores-Module-for-Python
/main.py
2,012
4.46875
4
def isInt(num): """ Finds if a number is an int or a float. This is a better version of the "isinstance" function in python. This function returns a bool value (like the "isinstance" function) :param num: The number to check if is a float """ num = str...
cf367fcb4a8206201da830e7d0c4939a26a00caf
santosh-srm/srm-pylearn
/11_strings_n_numbers.py
143
3.9375
4
a = 25 b = 55 print(f'sum of numbers {a} and {b} are {a+b}') a="25" b="55" print(f'string addition of {a} and {b} are representd by {a+b}')
bb1f75b55f4d0d236f255b6bf7b88823fcbcbeef
Glib79/kik
/hand.py
3,575
3.703125
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 3 15:58:40 2018 @author: Grzegorz Libera """ class Hand(object): """ Hand object """ chnd = 0 def __init__(self, start_pos, player): """ Hand initiation """ Hand.chnd += 1 self.tiles = [] self.size = 80 ...
a45c61b02857ebd57460a9db35bd3a7711753b8a
StarLight-Academy/python-codes
/palindrome.py
264
3.96875
4
def is_palindrome(n): rev = 0 temp = n while temp != 0: digit = temp % 10 rev = rev * 10 + digit temp = temp // 10 return rev == n if __name__ == '__main__': a = int(input('Enter number: ')) print(is_palindrome(a))
766a8caa3b0d15ba9fb327f3bf94d64a8b302171
kuchunbk/PythonBasic
/5_tuple/Sample/tuple_ex7.py
692
4
4
'''Question: Write a Python program to get the 4th element and 4th element from last of a tuple. ''' # Python code: >>> #Get an item of the tuple >>> tuplex = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e") >>> print(tuplex) >>> #Get item (4th element)of the tuple by index >>> item = tuplex[3] >>> ...
fc1c03b4493c52add0962e29c965ab5207f0eaed
ofir123/MP3-Organizer
/mp3organizer/datatypes/album.py
1,629
4.1875
4
class Album(object): """ A POPO class to hold all the album data. Contains the following information: Name, Artist, Genre, Year and Artwork (as path). """ def __init__(self, name, artist, genre=None, year=None, artwork_path=None, tracks_list=None): """ Initializ...
88fe2f9851f1a8728b26dfc1b351f027bf231b43
ypliu/leetcode-python
/src/056_merge_intervals/056_merge_intervals_TLE_ConnectedComponents.py
2,865
3.640625
4
# Definition for an interval. class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e import collections class Solution(object): def merge(self, intervals): """ :type intervals: List[Interval] :rtype: List[Interval] """ if not i...
e8f9fae0a9240e008c62708f6ff9ea28a3b087dd
Blankpanda/Scripts-and-Dotfiles
/scripts/python/line.py
2,632
3.8125
4
# arbitrarily counts the line numbers of files in a directory # not entirely accurate but I use this to get a general idea # of the number of lines a program that I have written is # composed of. import sys import os def main(): args = sys.argv if len(args) != 2: print("Invalid number of argume...
66ed2c63e1adc57484fc1bd2034a4e2feae68026
dylanlee101/leetcode
/code_week23_928_104/insert_into_a_binary_search_tree.py
1,583
4.09375
4
''' 给定二叉搜索树(BST)的根节点和要插入树中的值,将值插入二叉搜索树。 返回插入后二叉搜索树的根节点。 输入数据保证,新值和原始二叉搜索树中的任意节点值都不同。 注意,可能存在多种有效的插入方式,只要树在插入后仍保持为二叉搜索树即可。 你可以返回任意有效的结果。   例如,  给定二叉搜索树: 4 / \ 2 7 / \ 1 3 和 插入的值: 5 你可以返回这个二叉搜索树: 4 / \ 2 7 / \ / 1 3 5 或者这个树也是有效的: ...
e4de625b3cdc906f59a88b58a90910c2629a3234
dnootana/Python
/concepts/stackQueueDeque/stack.py
570
4.15625
4
#!/usr/bin/env python3.8 class Stack(object): def __init__(self): self.items = [] self.size = 0 def size(self): return self.size def isEmpty(self): return self.size == 0 def push(self,item): self.items.append(item) self.size += 1 def pop(self): if self.isEmpty(): raise Exception("Popping from...
aa03a0e614c8baebae7f8431a814e72d12e73183
Elton86/ExerciciosPython
/EstrtuturaSequencial/Exe15.py
1,100
4.03125
4
"""Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% para o sindicato, faça um programa que nos dê: 1. salário bruto. 2.quanto pagou ao ...
75d8347ee78f340b7396c801aa31b8779b47c87c
qujay/leetcode
/056-merge-intervals/merge-intervals.py
948
4.09375
4
# -*- coding:utf-8 -*- # Given a collection of intervals, merge all overlapping intervals. # # # For example, # Given [1,3],[2,6],[8,10],[15,18], # return [1,6],[8,10],[15,18]. # # Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s # se...
52ae7ab77c1b2d3d0cadde09b9060ff6d25b0cba
daniel-reich/ubiquitous-fiesta
/AnjPhyJ7qyKCHgfrn_4.py
148
4
4
# Fix this incorrect code, so that all tests pass! def remove_vowels(string): return "".join(vowel for vowel in string if vowel not in "aeiou")
00787f2f9919b312a6a36fa37de9e3d695917dbf
JonnatasCabral/algorithms
/caesar_cipher.py
345
3.84375
4
# Caesar Cipher def shift_position(shift, letter): if shift > 90 and letter.isupper(): shift -= 26 elif shift > 122 and letter.islower(): shift -= 26 return shift def encrypt(v, k): v = map( lambda x: chr( shift_position(ord(x) + k % 26, x)) if x.isalpha() else x, ...
b7d46778c3727e088d291dc76f644ddfd1df9930
flyingfruit/Algorithm
/test1/main.py
1,674
3.875
4
from collections import deque class Node(object): def __init__(self, value, p=None): self.value = value self.p = p class LinkList(object): def __init__(self, head=None): self.head = head def insert(self, date): node = Node(date, self.head) self.hea...
346e790744b3f800074d1207f1fe92dc4cc9eeac
danielkpodo/python-zero-to-mastery
/python_basics/datatypes/sets/setintro.py
214
3.734375
4
# last data structure # Sets are unorded collection of unique objects my_set = {1, 2, 4, 4, 5, 5, 5, 4, 3, 3} print(my_set) # useful methods new_set = my_set.copy() print(new_set) my_set.add(100) print(my_set)
bb4510f1b50b03478420727db1a9bbe576d01baa
wwest4/tdd-by-example
/part-3/triangle.py
507
3.984375
4
class Triangle: def __init__(self, a, b, c): self.a = a self.b = b self.c = c negative = a <= 0 or b <= 0 or c <= 0 illegal = a + b <= c or b + c <= a or c + a <= b if negative or illegal: raise ValueError('invalid Triangle dimensions') def type(se...
e803b2fe6a65c464b306219b7ecd5f41580485ef
ashishgupta2014/problem_solving_practices
/implimentation/X_O_Replace.py
3,706
3.671875
4
""" https://app.glider.ai/practice/problem/algorithms/replace-os-with-xs/problem Given a matrix of size N x M where every element is either ‘O’ or ‘X’, replace ‘O’ with ‘X’ if surrounded by ‘X’. A ‘O’ (or a set of ‘O’) is considered to be by surrounded by ‘X’ if there are ‘X’ at locations just below, just above, just ...
1904bdc89188cfe9834d5a50ca780780a9c44680
Lwq1997/leetcode-python
/primary_algorithm/array/moveZeroes.py
972
3.75
4
# -*- coding: utf-8 -*- # @Time : 2019/4/12 21:37 # @Author : Lwq # @File : plusOne.py # @Software: PyCharm """ 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数组上操作,不能拷贝额外的数组。 尽量减少操作次数。 """ class Solution: @staticmethod def moveZeroes(arr): """...
78bd77149314cba6cc1b4c64c6bd8c00a1bee6ad
yusseef/python-simple-codes
/simple factorial.py
125
4.125
4
print("enter the num") num=int(input()) factorial=1 for i in range(num): factorial=factorial*(i+1) print (factorial)
a087bd196a613a888c139fbd43f888ed8c952aa6
galacticsquad15/Python
/test_assign_average.py
873
3.609375
4
import unittest import assign_average class MyTestCase(unittest.TestCase): def test_a(self): my_value = 'A' self.assertEqual(assign_average.switch_average(my_value), 1) def test_b(self): my_value = 'B' self.assertEqual(assign_average.switch_average(my_value), 2) ...
0bdce7a44bb3ab4fa7c48a67d99a93cb38bbaa03
Erkinumur/hm_17.04.2020
/17.04.2020_task2.py
971
3.75
4
name = input('Как Вас зовут? ').title() hello = ('Hello', 'Привет') start = input('Напишите Привет или Hello: ') while start.title() not in hello: start = input('Напишите Привет или Hello: ') print(f'Hello, {name}!\n') offices = {'KZ': 'google_kazakstan.txt', 'PS': 'google_paris.txt,', 'UAR': 'google_uar.txt', ...
399d36e328d8996b7c5359faae4ccc89c8ef0bde
vk27inferno/Guess-the-Number
/GuesstheNumber.py
5,255
3.578125
4
class GuessNumber: font = ("Comic Sans MS", 15, "bold") title = "Guess the Number!" ask = "Guess a number between {} and {}: " def __init__(self, minNum = 0, maxNum = 1000, tries = 10): self.min = minNum self.max = maxNum self.retries = tries self.reset() def re...
e70d39bdd1533a31376c7b6609920535e9a06d65
TimeCracker/python
/range_function/range_test.py
781
3.8125
4
#! /usr/bin/env python3 # -*- coding:utf-8 -*- ############################################################### # © kenwaldek MIT-license # # Title: range function Version: 1.0 # Date: 28-12-16 Language: python3 # Description: de range funktie uitge...
368792d6415d63f803656ecdf94531b269432625
Yomiguel/freecodecamp-python-course
/readingwritingfiles.py
1,075
3.984375
4
#-------------------------reading files-------------------------- # 'r' for reading only, 'w' for writing only, 'r+' for writing and reading, 'a' for append. file_names = open("names.txt","a") """ #this line print the state of the file (r(readable), w(wirtable), r+ or a). print(file_names.writable()) #this line pri...
beed913c8cd5dafcb4deda90e60be5fabb290141
sonushahuji4/Data-Structure-and-Algorithm
/Linklist/linked.py
12,016
4.03125
4
class Node: def __init__(self,data): self.data=data self.next=None class Linklist: def __init__(self): self.start = None self.temp = None self.mov = None self.cur = None self.head = None self.size = 0 def insertData(self,data): if sel...
7efba58b1e7271d95dd5d51db388064eeb6f79cb
ablancoze/ComputacionBioInspirada
/TrabajoGenetico/mapa.py
1,070
3.5625
4
import numpy as np import random import sys from random import sample class mapa(): ciudad=np.zeros((3, 3)) nCiudades=3 def __init__(self,_nCiudades): self.ciudad=np.zeros((_nCiudades, _nCiudades),int) self.nCiudades = _nCiudades self.generarMapa() #Permite generar un mapa de ...
cd20d5431271a0a0a86e63ec490685b62534ec84
linlilin/GA
/editga.py
2,179
3.609375
4
""" Finding x,y for function minimization F(x,y) = 3x^2 + 2y^2 - 4x + y/2 using Genetic Algorithm wrismawan, E101 """ from random import randint import collections Individu = collections.namedtuple('Individu', 'ind fitness') class GA(object): def __init__(self, jum_pop=10, mut_rate=.3): self.jum_pop = jum...
6cb9616fa49f4b5a2c19c222672eb342d34c881b
NicholasBreazeale/NB-springboard-projects
/python-ds-practice/34_same_frequency/same_frequency.py
569
3.8125
4
def same_frequency(num1, num2): """Do these nums have same frequencies of digits? >>> same_frequency(551122, 221515) True >>> same_frequency(321142, 3212215) False >>> same_frequency(1212, 2211) True """ def frequency(string): le...
bc05e6f34a1eb1074ee29e2e3f379ff46fcd20ef
MadhanArts/PythonInternshipBestEnlist
/day13_task1/main.py
878
3.90625
4
from day13_task1.CoffeeMachine import CoffeeMachine from day13_task1.Drink import Drink my_machine = CoffeeMachine(3000, 2000, 1000, 0) latte = Drink("Latte", 200, 150, 24, 2.5) espresso = Drink("Espresso", 150, 100, 30, 3) cappuccino = Drink("Cappuccino", 150, 175, 20, 4) while True: print("****** Welco...
565fc38a24e86c52a53eb61cb37708f6be2e5a15
chuanfanyoudong/algorithm
/leetcode/String/WordBreak.py
660
3.796875
4
""" 不要用递归,用动态规划 @author: zkjiang @time: 2019/4/30 20:38 """ class Solution(object): def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: bool """ n = len(s) result_lis = [0]*(n+1) for i in range(n+1): for k...
e93cb8a3cc187dcaa0a0b9e8e83268a00e0b27cb
skhan75/CoderAid
/Techniques/Sliding Window/container_with_most_water.py
1,321
4.1875
4
""" Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You ma...
8cfaa3998bfcf56489392a6708b5f7c72cb7ad4c
mohdsameer7408/python_codes
/utils.py
156
3.875
4
# A program to find the greatest number!!! def find_max(numbers): g = numbers[0] for i in numbers: if g < i: g = i return g
b1f88ee984178fb719db7a4272dd84971162428a
Allan-Perez/CStudies-
/LinearAlgebra/linTransf.py
8,254
3.90625
4
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # A transformation is linear if it follows the following properties: # Additivity: L(u+w) = L(u)+L(w) # Scaling: L(cv) = cL(v) # Example of linear transformations to functions: derivative: chain rule. # Stuff worthy to note: ...
0e38062ad61e086ffa923a5bfeb603441769eed9
yuandaqiancheng/Python_learning
/shili.py
3,684
4.21875
4
#!/usr/bin/env python # -*- coding:UTF-8 -*- ''' #输出N以内的素数 import math l = [] n = int(input('please input a number more than 2:')) if n == 2: print('there is no prime less than 2!') else: for a in range(2, n): for b in range(2, int(math.sqrt(a)) + 1):#素数只需要不能整除2-根号自己就可以了。 l.append(a % b)#将所有...
0c67eb2bc3c1ffbdd1e05d77b1a54a4e4c970876
jessicazhuofanzh/Jessica-Zhuofan--Zhang
/mygame.py
12,226
4.25
4
# Isolated Island # Now updated to Python 3 # At the top of the file are declarations and variables we need. # # Scroll to the bottom and look for the main() function, that is # where the program logic starts. import random # random numbers (https://docs.python.org/3.3/library/random.html) import sys # system stuff...
517da59aa659529177df66df1956b0ba5ce74420
JeremiahZhang/gopython
/data-analysis-with-python/demographic_data_analyzer.py
4,915
4.15625
4
import pandas as pd def calculate_demographic_data(print_data=True): # Read data from file df = pd.read_csv('adult.data.csv', delimiter=',') # How many of each race are represented in this dataset? This should be a Pandas series with race names as the index labels. df_race = df.groupby('race')['age']....
fb515b67143eef6346b524e334ea8101573fd560
LacieNat/Algorithm-Practices
/coding interview book/Parenthesis.py
939
3.625
4
''' Created on Oct 9, 2015 @author: lacie ''' from collections import deque queue = deque([]) list = [] def generateParenthesis(numOfPairs, numOfOpen, numOfClose, queue): if numOfOpen == numOfClose and numOfOpen == numOfPairs: st = "" while len(queue) is not 0: st += queue.popleft() ...
800eb1c5ea1b4d4353653d19a30d52d30724aec5
won-cp/school-interface-four
/classes/interface.py
2,323
3.65625
4
from classes.school import School class SchoolInterface: def __init__(self, school_name): self.school = School(school_name) def run(self): authenticated = self.authenticate_user() if not authenticated: print("Please enter the valid credentials.") print() ...
f1103642d2a3d39a720223d5fbee1c718ede74b7
EEEGUI/LeetCode
/606. Construct String from Binary Tree.py
1,154
3.71875
4
class Solution: def tree2str(self, t): """ :type t: TreeNode :rtype: str """ ans = '' if not t: return '' stack = [t] while stack: node = stack.pop() while node: ans += str(node.val) i...
3fada598567b0e6df81d5d292b84edd4de9aa8ae
pangyouzhen/data-structure
/math_/7 reverse.py
361
3.734375
4
class Solution: def reverse(self, x): str_x = str(abs(x)) val = int("".join(str_x[::-1])) if x < 0: val = -val if (-2 ** 31) <= val <= (2 ** 31): return val else: return 0 if __name__ == '__main__': sol = Solution() ...
d0359dfcec94eecba64a381c58b3f18faede2401
dougfunny1983/Hello_Word_Python3
/ex055.py
342
3.9375
4
print('''############################## ##Maior e menor da sequência## ##############################''') print('→←'*30) peso = [] for c in range(1,6): peso.append(float(input(f'Digite o {c}º peso → Kg '))) peso.sort() print(f'O maior peso lido foi: {peso[4]} Kg') print(f'o menor peso lido foi: {peso[0]} Kg') print...
6fe89481e0f979e11c12395c96ba2ba83cc6364c
NakibHasan/Code-Examples
/Lab8P1.py
604
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 22 13:23:23 2018 @author: hasna """ principal = (int(input("what is the principal amount:"))) annualcontrib = (int(input("what amount do you add per year:"))) growthrate = 1.05 years = (int(input("how many years do you want to invest:"))) def constantinvestment(...
9b1fac7415526ae0bf56c9bfdc65a1800e6e98a6
rrodenburg/prfl
/archive/transposetest.py
289
3.53125
4
import numpy as np input = np.array( [ [[1,2,3,4],[5,6,7,8],[9,10,11,12]], [[13,14,15,16],[17,18,19,20],[21,22,23,24]] ] ) #print(input.shape) output = np.transpose(input,(1,2,0)) print(input.shape) print(output.shape) print(input) print(output)
0c9e429c5a926bab7622108c4d8759f15fe2f857
jianhui-ben/leetcode_python
/uber_oa_处理字符串.py
1,072
3.71875
4
#地里有过的面经, 就是给一个字符串string,里面只有 "W" "D" "L" 需要按照以下顺序排列 #1) 如果string 有“W”, 加到result 里, 输入的string remove这个“W” (每次只能remove一个) #2) 如果string 有“D”, 加到result 里, 输入的string remove这个“D” (每次只能remove一个) #3) 如果string 有“L”, 加到result 里, 输入的string remove这个“L” (每次只能remove一个) #4) 如果输入字符串没有 "W" "D" "L" , return result 不然从step 1重复 # exa...
f07c389047d92c5e2c853751376bebbfe5e4ce37
okhster/Python
/Lecture Notes/Lect3-1stFunction4.py
70
3.5
4
x=1 y=2 z=3 def f(x,y): sum = x+y sum=sum*sum print sum
3ca7e36467f4f7336bf34c8789688eb12c5d3e4b
vipinvkmenon/canddatastructures_python
/chapter10/example3.py
277
3.703125
4
# Chapter 10.3 #Parameter Passing def main(): # Main Function i = 0 print("The value of i before call " + str(i)) f1(i) print("The value of i after call " + str(i)) def f1(k): # Function f1 k = k +1 main() # Main Function entry
eed260d82f60d919847c61cadd5ac7c729039a52
jugomo/python_review
/basics/numtypes.py
337
3.53125
4
""" Data types - Python Author: Julio Gonzalez """ a = 13 b = -66 c = 33.6 #float d = 3+6j #complex e = 0B101 #binary f = 0XFF1 #hex g = False #boolean print(a ,b) print(type(b)) print(type(c)) cc = int(c) print(type(cc)) print(d) print(type(d)) print(e) print(type(e)) print(f) print(type(f))...
93145fa4c8f52873435e18a872398b1d8b1b34c3
AdityaWadkar/Python-Calculator
/calculator.py
1,570
3.546875
4
from tkinter import * import tkinter.messagebox as t a,y,yz,aw=0,70,"red","pink" def click(event): global s text = event.widget.cget("text") if text == "=": a=s.get() if "^" in s.get(): a=a.replace("^","**") try: value=eval(a) s.set(val...
a3fd72ccd2e1f5716b2a3d7dd42a39a8cdf086e9
hizircanbayram/Graduation-Project
/UNet/DataProcessing/quick_processing.py
6,618
3.875
4
import os def delete_unnecessary_files(dir_path): ''' Given a directory path, this function deletes the images created by pixel annotation tool that we dont wan't to. ''' file_names = os.listdir(dir_path) for file_name in file_names: if ('_mask' not in file_name) or ('_color_mask' in file_...
9d9743052e65922ac142508ecc66d6d5433adcb1
AK5123/coding-prep
/solved_problems/candies.py
570
3.828125
4
# https://www.hackerearth.com/challenges/competitive/hackerearth-test-draft-3-115/problems/c288d26a1c724b01be096c3ac6e919da/ def extra_candy (n, candies, extra_candies): # Write your code here big = max(candies) res = [] for i in candies: if i+extra_candies >= big: res.app...
668d6cc68666593b70fd6c31435f79ca02509bfd
sbbasak/CIT_ES_PP_2001_Assignment-1
/name+age.py
220
4.40625
4
# 2.Enter your Name And age and show it in your screen. print('Enter your name:') your_name = input() print('Enter your age:') your_age = input() print('Hi!' + your_name + ' you are ' + your_age + ' years old.')
f91784e33a7cc06f457c03f18c4a729fd623b55f
mwaskom/seaborn
/seaborn/objects.py
2,208
3.515625
4
""" A declarative, object-oriented interface for creating statistical graphics. The seaborn.objects namespace contains a number of classes that can be composed together to build a customized visualization. The main object is :class:`Plot`, which is the starting point for all figures. Pass :class:`Plot` a dataset and ...
e538eaf3f4be947c62b46a202e0ec37ad26de491
chesterking123/Leet-Code
/.ValidSudoku.py
774
3.578125
4
class Solution(object): def isValidSudoku(self, board): for row in board: row = [x for x in row if x!= '.'] if(len(row)!=len(set(row))): return False col_board = [i for i in zip(*board)] for row in col_board: row ...
44291f5f7667aeeaa79fb60ecd98016eec05d8db
Krishna3-cloud/salarypredicter-ml-model
/salarypredict.py
256
3.5625
4
import joblib pred_model=joblib.load("Salarypredicter-model.pk1") #Now to predict salary p=int(input("Enter years of experience-: ")) sal=pred_model.predict([[p]]) #Now print the predicted salary print("Estimated Salary is: ", round(sal[0],2), "INR.")
2f70882e135fc5417eefc13a0365ec46a7b1630c
prodevans-technologies/vipin-prodevans
/Python/prime.py
312
4.15625
4
''' Python Script to check whether entered number is prime or not ''' n=int(raw_input('Enter number : ')) print(n) flag=False for i in range(2,n): if n%i==0: flag=True break else: flag=False if flag: print("Not Prime") else: print("prime number")
91ea9b0f3390fd3b738080eb827779f3a051ee6a
Aasthaengg/IBMdataset
/Python_codes/p03424/s935030063.py
70
3.53125
4
n=int(input()) s=input() if 'Y' in s:print("Four") else:print("Three")
13308edb6d00d20dce3348c942d8ab6a234f46a1
yashgitwork/Python
/User_input.py
159
3.90625
4
name = input("What is your name?") print (name) age= input("What is your age?") age=int(age) print(age) pi = input("value of pi?") pi = float(pi) print(pi)
fc9697943050e12c3674ddbfa65e6815449da035
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/Lambda-Resource-Static-Assets/2-resources/_External-learning-resources/02-pyth/algorithms-master/algorithms/dp/planting_trees.py
1,921
4.34375
4
""" An even number of trees are left along one side of a country road. You've been assigned the job to plant these trees at an even interval on both sides of the road. The length L and width W of the road are variable, and a pair of trees must be planted at the beginning (at 0) and at the end (at L) of the road. Only o...
91acb3b85fba71beb1a56798166474ca1274efa2
LeeTeng2001/SJTU-ITE-Project-Platform
/app/testing/local_function.py
310
3.515625
4
import datetime import random # sd = datetime.date(2020, 1, 2) # ed = datetime.date(2020, 12, 1) def random_date_between(d1, d2=datetime.date.today()): time_difference = d2 - d1 new_time = d1 + datetime.timedelta(seconds=int(time_difference.total_seconds() * random.random())) return new_time
437d354adc62a7d38f1bfc6b03ee1fbdcd87dc3c
delmondesfe/python_jogos
/forca.py
848
3.984375
4
def jogar(): print("*********************************") print("***Bem vindo ao jogo da Forca!***") print("*********************************") palavra_secreta = "python" letras_acertadas = ["_","_","_","_","_","_"] enforcou = False acertou = False print("A palavra secreta contem...
a0fd4052e638f0a4028ae18a329f6236babb05ab
MasiaMatteo03/SistemiEReti
/pytohn_natale/es4_rot15.py
767
4.0625
4
def encode(string): strEnc = "" for elemento in string: elemento = ord(elemento) + 15 elemento = chr(elemento) strEnc = strEnc + elemento print(strEnc) def decode(string): strDec = "" for elemento in string: elemento = ord(elemento) - 15 elemento ...
3f01526070a2362c5622c147f399d46839ea3342
mlee177/sc_1
/badgenerator.py
684
3.84375
4
#!/bin/env python import random def changeCase(char): return char.lower if char.isupper() else char.upper() def repeat(char): return char * random.randint(1,4) def changevowel(char): return random.choice([vowel for vowel in 'aeiou' if vowel is not char]) for i in range(50): word = random.choice(list(open('wo...
4759121df92cbcb435acc15380147b6e49338089
kanwal07/Playing-with-Python
/Some more exercises/Question5.py
600
4.09375
4
#question5 #pseudo- input two strings and the index, #traverse through the first string till i reach the index and match the other string, #if match then true else false def substring(s1,s2,k): if((s1.index(s2,k)) == k): print ("True") else: print("False") s1 = input("Enter a string: ") s2 ...
430e77f9955546fd63613d4e75ddcf9c72e0fc7e
Pabloold/python
/task2-2.py
582
3.53125
4
my_list = [] user_count = input('Введите количество элементов в списке ') if not user_count.isdigit(): print('Введён неверный формат числа') exit() count = int(user_count) my_list.append(int(input('Введите первое число списка: '))) i = 1 while i < count: my_list.append(int(input('Введите следующее число...
d80bef70ea3b9612f68b9bd1ea1c7afbd9986a00
sirbowen78/lab
/filter_function_examples/using_filter.py
1,418
4.3125
4
# Populate the numbers. numbers = [x for x in range(1, 51)] # so far the best and shortest way to check prime number: # https://www.tutorialgateway.org/python-program-to-find-prime-number/ def is_prime(num): count = 0 for i in range(2, (num // 2 + 1)): if num % i == 0: count += 1 ...
4e6d5c47dc808301f3a77c6238d610abc1c2ecb2
Eleveil/leetcode
/Python/count-and-say.py
2,706
4.0625
4
''' The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n where 1 ≤ n ≤ 30, generate t...
bd5d3247ad6d85df9424ec92519ad32d3858610a
nayansethia/Nayan_Sethia_Assignments
/Nayan_Sethia_AWS_Assignment_1/Question 2/ns-aws-q2-script.py
1,165
3.671875
4
import boto3 s3 = boto3.resource('s3') print("Enter the name of bucket") my_bucket = s3.Bucket(input()) #to get bucket name as input from user print("Enter the name of object") obj=input() #to get object name as input from user l= s3.list_ob...
dd66b2f6e430640a4372e7ad5a79adda48ce75ec
josemgoujat/adventofcode2019
/day-1/day-1.py
652
3.71875
4
""" https://adventofcode.com/2019/day/1 """ with open('day-1.input', 'r') as input_f: modules_mass = [int(line) for line in input_f.read().splitlines()] # Star 1 def simple_fuel_calculator(mass): return mass // 3 - 2 answer_1 = sum(map(simple_fuel_calculator, modules_mass)) print(f'Answer 1: {answer_1}') ...
503af83972d7aef051f9603e5b34c5d1c0c09900
frwp/School
/Semester V/Kripto/exor.py
2,146
3.5
4
# Fungsi enkripsi def encrypt(plain,password): plainIntVector = [] for i in range(len(plain)): plainIntVector.append(ord(plain[i])) passwordIntVector = [] # inisiasi variabel baru untuk membuat setiap perubahan yang terjadi pada # password akan menyebabkan avalanche effect # variabel in...
b9a4d347e8439401fb4bec60b41f7efd12eca62c
yashsinghal07/Music-Player
/Project_gui/list_box.py
744
3.765625
4
from tkinter import * from tkinter import simpledialog,messagebox def show(): pos=lbl.curselection() if(len(pos)==0): messagebox.showerror("NO Selection","please select atleast one of them") else: sname=lbl.get(pos[0]) lbl1.config(text="you selected "+sname) root=Tk() roo...
f49b9ff6252a022a3c9467c26214269e15301e63
ihuei801/leetcode
/MyLeetCode/FB/Count and Say.py
606
3.5625
4
### # Time Complexity: O(2^n) len grows up to double # Space Complexity: O(2^n) ### class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ if n == 1: return "1" s = "1" for i in xrange(1, n): cnt = 1 ...
0e59284ad0349cd83f1a4fcdc85bf0c418b4f1ca
Marusya-ryazanova/Lesson_5
/Les.5.6.py
264
3.921875
4
some_dict = {'first_color': 'Red', 'second_color': 'Green', 'third_color': None} def remove_empty(some_dict: dict) -> dict: some_dict = {key: value for key, value in some_dict.items() if value is not None} return some_dict print(remove_empty(some_dict))
caf6175abec3ecf7613e926e68acf491b960b6b9
sachinarya9/python_concepts
/clas_inheritance.py
378
3.875
4
class Bird: def __init__(self,name,age): self.name = name self.age = age def whoisthis(): print('Bird') def swim(): print('Swim faster') class Penguin(Bird): def __init__(self,name,age): print('This is a Penguin') super.__init__(self,name,age) def whoisthis(): print('Penguin') def run(): print('R...
0ab76d3e5a8ea11295a06bb63725f9e86facf4b6
daimingzhong/Leetcode-Python
/src/leetcode/class0/best_practice.py
331
3.78125
4
import sys from typing import List # arr: List[int] def max_int(): max_int_in_python3 = sys.maxsize min_int_in_python3 = -sys.maxsize - 1 def swap(arr, fast, slow): # 交换两个数, e.x. arr = [1,3,2] tmp = arr[fast] arr[fast]= arr[slow] arr[slow] = tmp arr[fast], arr[slow] = arr[slow], arr[fast...
d17907bce11fca03f4226d3c551909c209026769
dankoga/URIOnlineJudge--Python-3.9
/URI_1146.py
170
3.890625
4
number_max = int(input()) while number_max > 0: numbers_str = ' '.join(str(n) for n in range(1, number_max + 1)) print(numbers_str) number_max = int(input())
a75ed6066d305f785823d93cea5f77104e84bb46
python20180319howmework/homework
/huangyongpeng/20180328/h8.py
132
3.953125
4
''' 删除元祖中的所有重复的元素,并生成一个列表 ''' t=(1,1,2,3,5,6,6,5,8) s=set(t) l=[] l.append(s) print(l)
cfe82ad42511f5d827c51366ae1d66faef89520e
rsreenivas2001/LabMain
/Sem 4/ps2/2.py
407
4.09375
4
from math import sqrt def distance(u, v): total = 0 for x, y in zip(u, v): # print(x, y) total += pow(y - x, 2) # print(total) print("The distance is : ", sqrt(total)) if __name__ == '__main__': u1 = list(map(int, input('Enter CoOrdinates of 1st point : ').split())) v1 = ...
f5c54b3a8c811a3308cee1b57d098838a717cbb8
Zhenye-Na/leetcode
/python/673.number-of-longest-increasing-subsequence.py
2,156
3.75
4
# # @lc app=leetcode id=673 lang=python3 # # [673] Number of Longest Increasing Subsequence # # https://leetcode.com/problems/number-of-longest-increasing-subsequence/description/ # # algorithms # Medium (38.40%) # Likes: 2157 # Dislikes: 116 # Total Accepted: 76.3K # Total Submissions: 197.7K # Testcase Example:...
ebc0e8c8cc28b943dd5ec0699fcf700c389d6e8d
SimonDef/learn_vocab_web
/app/learnvocab.py
1,400
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 18 17:35:52 2017 @author: simondefrenet """ import random WORDLIST_FILENAME = "French words - Sheet2Fr.csv" def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the ...
020362e264c9ba886af0519953b379afdec52ee1
henridvf/katas
/directorytree.py
772
3.71875
4
# 1. sort list to make split immediately useable # 2. split each list item on '/' # 3. loop through each part and create (nested) folder if needed def directoryTree(lst): tree = 'Desktop\n' for item in sorted(lst): for part in item.split('/'): if not part in tree: ...
66e5b4141e205feed66a7af68567b938855c1f58
LabForComputationalVision/pyPyrTools
/pyPyrTools/steer2HarmMtx.py
2,255
3.796875
4
import numpy def steer2HarmMtx(*args): ''' Compute a steering matrix (maps a directional basis set onto the angular Fourier harmonics). HARMONICS is a vector specifying the angular harmonics contained in the steerable basis/filters. ANGLES (optional) is a vector specifying the angular po...
4d3d648b6b1f9efefe38f6bdddece5567ac19c1f
whutweihuan/DeepLearing
/main08.py
279
3.71875
4
# -*- coding: utf-8 -*- """ author: weihuan date: 2020/3/13 19:16 """ # Pytorch实现基本循环神经网络RNN import torch import torch.nn as nn rnn = nn.RNN(10,20,2) input = torch.randn(5,3,10) h0 = torch.randn(2,3,20) output,hn = rnn(input,h0) print(output) print(hn)
c12fbd2a27f6208a1ce103ac9ad571e8bc2908f4
tndud042713/python_class_0914
/python수업자료/프로젝트/Day12.py
5,126
4.03125
4
# # 예제.1 # lst = [1,2,3] # print("첫 번째 출력: ",lst) # lst.append('a') # print("두 번째 출력: ",lst) # lst.append([100,200]) # print("세 번째 출력: ",lst) # #list형도 list에 들어간다 # append의 사전적 정의 # 한글로 "추가" 라는 뜻이다. # 예제.2 # lst = [1,2,3] # print("첫 번째 출력: ",lst) # lst.extend(['a','b','c']) # print("두 번째 출력: ",lst) # extend 함수는 리스트형을 ...
d2fe1c4857a320b06bdd3a7817876ba2afedb912
refschool/exercice-python
/exo/exo26.py
534
3.921875
4
import csv print(csv.__version__) with open('test.csv') as f: reader = csv.reader(f) for row in reader: print(row) """f = open('test.csv', 'r') next(f) #skip header for line in f.readlines(): liste = line.split(',') print(liste[1], liste[0], liste[2], liste[3])""" """ ['Yvon', 'Huynh',...
3fd7ae85312ae79c5c91adb61ab1521335917178
davidbliu/coding-interview
/arrays/lists_practice.py
799
4.03125
4
class ListNode: def __init__(self, val): self.value = val self.next = None def construct_list(): node = ListNode(0) curr = node for i in range(1, 10): next = ListNode(i) curr.next = next curr = curr.next return node def print_list(node): print 'printing list' curr = node while curr != None: pri...
94a81f9ad035749d2ebd4300e4b03c250dc36709
BAltundas/linked_list
/linkedList.py
1,938
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 3 15:28:51 2021 Implementation of linked list in python @author: Bilgin """ class node: def __init__(self,data=None): self.data = data self.next = None class linked_list: def __init__(self): self.head=node() def appe...
58c0671d928e1aaaa044c10132219ce2a76f80a3
velillajoseph/Velilla_104079_project01_SnakeyGame
/SnakeyGame.py
6,527
3.78125
4
from graphics import * from random import * class Snake: #Creating the window win = GraphWin('SNAKEY SNAKE', 800, 985) win.setBackground('black') #Defining snake and snake size size = 2 snake = [0] * size #Define apple apple = Rectangle(Point(0, 0), Point(0, 0)) GameOver = Text(...
bc10c7e372210429bdd80e5a2731d0f1af23740b
SenneRoot/AOC2020
/day_1/task_2.py
508
3.8125
4
def read_integers(filename): with open(filename) as f: return [int(x) for x in f] inputs = read_integers("input.txt") for i, first in enumerate(inputs): for j, second in enumerate(inputs[i:]): for k, third in enumerate(inputs[j:]): sum = first + second + third if (sum ...
19a9ce133bdc74c976c78f8ae74b2e199bcb8bfe
alrasyidlathif/leetcode-notes-question-answer-in-python3
/7.py
661
4.15625
4
''' Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example: Input: x = 123 Output: 321 ''' cl...