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
ea54fc55ca5f69eb2952c369b4f107d15cd78902
daxata/assignment_1
/daxata.py
489
3.65625
4
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> P = 5500 #pricipal amount (initial investment) >>> r = 6.2 #annual nominal interest rate (as a decimal) >>> n = 3 #number of times the interest is compounde...
66964f525117475a750ce2144f48c97df6d2ec5c
trault14/Intro_TensorFlow
/Classification_Fully_Connected.py
3,958
3.671875
4
import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from libs import datasets from libs import utils """ ==== DESCRIPTION OF THE NETWORK ==== This fully connected neural network is trained to classify images that each represent the drawing of a number from 0 to 9. The input to the network is an ...
58f5520908c4d928039bf471e575e6f9c5826734
oliviamriley/class
/Algo/hw/hw4/q3.py
208
3.765625
4
#!/usr/bin/env python def find_min(A): #base case if(len(A) == 2): if A[0] < A[1]: return A[0] else if A[1] <= A[0]: return A[1] for i in range(len(A)):
359f1658650f9444ee0ef8ddced0d5b4e1fb9487
Kalpesh14m/Python-Basics-Code
/Basic Python/28 OS Module.py
1,330
4.4375
4
""" The main purpose of the OS module is to interact with your operating system. The primary use I find for it is to create folders, remove folders, move folders, and sometimes change the working directory. You can also access the names of files within a file path by doing listdir(). We do not cover that in this video,...
3abea91c0a753cd9740555dcc6b1c5c3fc71d184
prusinski/NU_REU_git_NZP
/python_plot.py
406
3.703125
4
%matplotlib inline import numpy as np import matplotlib.pyplot as plt #plot exponential curve from 0 to 2pi t = np.linspace(0,2*np.pi,100) plt.plot(t,np.exp(t),'m', label = 'Exponential Curve') plt.title('Plot of $e^x$') plt.xlabel('t (s)') plt.ylabel('$y(t)$') plt.legend() plt.grid() plt.text(2.5,0.25,'This is a \nE...
d4c4fef207761af41536ea218a940089d13e18c0
Alihasnat10/Algorithms-and-Data-Structures
/Picking Number.py
469
3.65625
4
def pickingNumbers(a): # Write your code here a.sort() ans = [] count = [] for i in range(len(a)): ans = [] for j in range(i, len(a)): if abs(a[i] - a[j]) <= 1: ans.append(a[j]) else: break count.append(len(a...
1ad1f406136227258ad9a2c78b5fa9b7e020a33f
luokeke/selenium_python
/python_doc/Python基础语法/4.程序的控制结构/条件判断及组合.py
705
3.921875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/11/27 17:35 # @Author : liuhuiling print() ''' 条件判断,比较运算符 操作符 数学符号 描述 < < 小于 <= <= 小于等于 >= >= 大于等于 > > 大于 == = 等于 != ≠ 不等于 条件组合,保留字 操作符及使用...
99d500ac3750c696f56c168722feb70db3a6e671
MysteriousSonOfGod/python-3
/basic/multi/threading4.py
1,772
3.625
4
import time import threading import concurrent.futures def do_something(seconds=1): print(f'Sleeping {seconds} second(s)...') time.sleep(seconds) return 'Done Sleeping...' # 1. Using threading start = time.perf_counter() threads = [] for _ in range(10): t = threading.Thread(target=do_something, args=[1.5]) ...
cdf9415cdd7af7b3225d01cc7cd2b65e6db6a15a
slottwo/cursoemvideo-python3-m3-exe
/#106(helper).py
780
3.984375
4
# Exercício Python 106: Faça um mini-sistema que utilize o Interactive Help do Python. O usuário vai digitar o # comando e o manual vai aparecer. Quando o usuário digitar a palavra 'FIM', o programa se encerrará. Importante: use # cores. # Situação: def titulo(tit: str, color: str): w = len(tit) + 4 print(co...
aab6e0a41308a5f752fa53c7709059fc5caa8dff
ckitagawa/Algorithms-And-DataStructures
/python_algorithms_data_structures/rbtree.py
11,353
3.546875
4
import queue global RED, BLACK RED = 0 BLACK = 1 class RBNode(object): def __init__(self, key, value, left=None, right=None, parent=None, color=RED): self.key = key self.value = value self.lchild = left self.rchild = right self.parent = parent self.grandparent = None self.uncle = None self.sibling = ...
c860c1f1c4ddeb99e540b3e526287b5c6c166b93
vignesh787/PythonDevelopment
/Week11Lec5.py
196
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 19 07:50:19 2021 @author: Vignesh """ a = 10 b = 20 ''' if a < b : small = a else: small = b ''' small = a if a < b else b print(small)
7c3f19fa73e05e78f6496bcc609b1658718da321
yubi5co/python-practice
/Python_basic/2.2day/07. 문자열, 슬라이싱.py
824
4.0625
4
# 문자열 sentence = 'hello world' print(sentence) sentence2 = "hello human" print(sentence2) sentence3 = ''' it's funny programming and easy language!!''' print(sentence3) # 슬라이싱 주민번호 = '990120-1234567' print('성별 :' +주민번호[7]) # []: 번호의 위치 (순서는 왼쪽에서 오른쪽으로, 0부터이다.) print('년 :' +주민번호[0:2]...
8a4746e88d01215419422b19daa94af4e8a21b88
itchenfei/leetcode
/304. 二维区域和检索 - 矩阵不可变/python_solution_1.py
905
3.578125
4
# 给定 matrix = [ # [3, 0, 1, 4, 2], # [5, 6, 3, 2, 1], # [1, 2, 0, 1, 5], # [4, 1, 0, 1, 7], # [1, 0, 3, 0, 5] # ] # # sumRegion(2, 1, 4, 3) -> 8 # sumRegion(1, 1, 2, 2) -> 11 # sumRegion(1, 2, 2, 4) -> 12 # 上图子矩阵左上角 (row1, col1) = (2, 1) ,右下角(row2, col2) = (4, 3),该子矩形内元素的总和为 8。 class NumMatri...
29deca3f01fb54a7f253006676f3b374bf60050f
Stevvie5/csc401
/csc401_homework3.py
1,621
3.859375
4
sample_data = [ 'Laaibah,208.10,10', 'Arnold,380.999,9', 'Sioned,327.01,1', 'Shayaan,429.50,2', 'Renee,535.29,4' ] def print_columns(data): print('Name Cost Items Total') for words in data: word = words.split(",") print('{:20}{:6.2f} {:6} {:6.2f}'.forma...
b5025d44ff83b51bf94bab019631ae86304229a4
misbahmehmood/Python
/number slicing with module.py
183
3.5625
4
import random def first_last6(nums): if nums[0]==6 or nums[-1] == 6: return True else: return False list= random.sample(range(0,50),5) print(first_last6(list))
9b98954eca57ddd280e325689adb90d3c5bdeaaf
dcryptOG/pyclass-notes
/4_functions/3_function_practice.py
10,937
3.890625
4
# WARMUP SECTION: # LESSER OF TWO EVENS: Write a function that returns the lesser of two given numbers if both numbers are even, but returns the greater if one or both numbers are odd # lesser_of_two_evens(2,4) --> 2 # lesser_of_two_evens(2,5) --> 5 def even_odds(a, b): if a % 2 == 0 and b % 2 == 0: retu...
a17a28135088fbac292437a7a95b328d7059ac72
yxnga/compsci
/TASK 1/programming challenge 1/PYTHON.py
169
3.859375
4
timest = int(input("which timest?: ")) howm = int(input("how many?: ")) for i in range(1,howm+1): product = i * timest print(timest, "times", i, "equals", product)
7a252c15b4993f6696f8478f4fc11b003e084a98
huitianbao/Python_study
/exe3advanced/09_function_exercises/sec_two.py
433
3.734375
4
#coding:utf8 import string def func(name,callback=None): if isinstance(name,str): if callback==None: return name.capitalize() else: return callback(name) else: print('输入有误,请重新输入') assert func('lilei')=='Lilei' # assert func('lilei',str.upper())=='LILEI #此方法 ...
7284449524becd7d1a2a1c0c3d083d86d08796e4
jorgeluisrocha/neural-networks
/perceptron.py
2,223
3.9375
4
""" AUTHOR: jorgeluisrocha LAST UPDATED: 10-22-2016 This file in its current conception is to create a Perceptron object and has two functions which allows it to learn how to behave like an OR gate and an AND gate. """ from random import choice from numpy import array, dot, random from pylab import plot, ylim class ...
eeaf574809ac76ba710e4349488f37604195c9b0
jaredparmer/ThinkPythonRepo
/metathesis.py
594
3.796875
4
# these functions solve exercise 12.3 of Allen Downey's _Think Python_ 2nd ed. from dict_fns import load_words_dict from anagram_sets import signature, anagram_dict def metathesis_pairs(d): for anagrams in d.values(): for word1 in anagrams: for word2 in anagrams: if word1 < wor...
def2b8d3cb6044f0d11df046f56a3fee1a7b1d30
cappe/DataAnalysis
/exercise_3/code/exercise_3.py
6,407
3.515625
4
import csv import numpy as np import math import operator from scipy import stats def loadDataset(filename): with open(filename, 'rb') as csvfile: lines = csv.reader(csvfile) dataset = list(lines) normalized_data = [] for col in range(6): column = [] for row in range(len(dataset)): dataset[row][col]...
cb5ab0a8d40a039c71364a5b6e0d541b303d4b8a
hocinebib/Projet_Court_H-H
/src/comp_plot.py
909
3.765625
4
#! /usr/bin/python3 """ plot two lists of values """ from matplotlib import pyplot as plt def compare_plot(lst_rsa, lst_pjct, res_lst): """ Plot the accessibility values obtained by our program and the ones given by naccess Arguments : lst_rsa : list of naccess residus accessib...
eef616e6a1f35932a96686634155918277dab3ef
hoylemd/hutils
/python/packages/Unix/hutils/numberLists.py
476
3.890625
4
# hutils.numberLists module import random import math # function to generate a list of random integers def generateInts(num_numbers, lower, upper): # calculate the range list_range = upper - lower # seed the random number generator random.seed() #initialize the list new_list = list() # generate the random i...
eec3b4a10688888a233bfb7afd6dfb010d6ad3ce
zcgu/leetcode
/codes/23. Merge k Sorted Lists.py
653
3.828125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ from heapq import * ...
c3a18ea98e13eceef42a4e6e015fae9885b10bb3
jocoder22/PythonDataScience
/DataFrameManipulation/stack_unstack.py
963
3.890625
4
import pandas as pd #################### Stack and Unstack # Unstack users by 'weekday': byweekday byweekday = users.unstack(level='weekday') # Print the byweekday DataFrame print(byweekday) # Stack byweekday by 'weekday' and print it print(byweekday.stack(level='weekday')) # Unstack users by 'city': bycity byci...
e60c61c4414148f4586500828a71aa5429b0d013
shanbumin/py-beginner
/012-tuple/demo03/main.py
1,515
3.890625
4
# 元组的应用场景 #打包和解包操作。 # 打包 a = 1, 10, 100 print(type(a), a) # <class 'tuple'> (1, 10, 100) # 解包 i, j, k = a print(i, j, k) # 1 10 100 # 在解包时,如果解包出来的元素个数和变量个数不对应,会引发ValueError异 #有一种解决变量个数少于元素的个数方法,就是使用星号表达式, # 我们之前讲函数的可变参数时使用过星号表达式。 # 有了星号表达式,我们就可以让一个变量接收多个值,代码如下所示。 # 需要注意的是,用星号表达式修饰的变量会变成一个列表,列表中有0个或多个元素。 # 还...
a18d804b3bc24c3f7b4e4c3ae5272dc75ad8acb5
iCodeIN/data_structures
/dynamic_programming/target_ways.py
453
3.671875
4
import collections def findTargetSumWays(A, S): count = collections.Counter({0: 1}) for x in A: step = collections.Counter() for y in count: step[y + x] += count[y] step[y - x] += count[y] count = step print(step) return count[S] if __name__=='__main...
8cd7080aabdd298cb339ccd673eb4696316092b0
pololee/oj-leetcode
/companies/affirm/expression_evaluation.py
1,737
3.875
4
import unittest from functools import reduce class ExpressionEvaluation: def evaluate(self, s): if not s: return 0 return self.evaluateUtil(s.split(' ')) def evaluateUtil(self, array): if not array: return 0 size = len(array) i = 0 opera...
4d340841b4d895e9c38e87cf9b38b127f8ffef09
yayshine/pyQuick
/google-python-exercises/basic/wordcount.py
2,751
4.3125
4
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
8bf496aa75e60eb1c0dc150a896f81ad65776309
ironsketch/pythonSeattleCentral
/tests/QUIZ6/MichelleBerginQuiz6.py
1,157
3.9375
4
# Importing random from random import randint # Using random to pick a number 1 or 0 def flipCoin(): flip = randint(0,1) return flip # Using flipCoin multiple times and adding up the total of heads def flipCoins(n): counter = 0 for i in range (n): flip = flipCoin() if flip == 1: ...
3252f20d479d10a4abe864bb34cd41815e6b285c
rprouse/python-for-dotnet
/ch03-lang/l05_generators.py
282
3.859375
4
def main(): for n in fibonacci(): if(n > 1000): break print(n, end=', ') def fibonacci(): current, nxt = 0, 1 while True: current, nxt = nxt, nxt + current yield current if __name__ == '__main__': main()
c9b0749c5c726729cf5419234d15c5118bb11b6f
ladosamushia/PHYS639
/Projectile/Projectile_Mikelobe.py
2,743
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 4 13:28:41 2018 @author: Mikelobe """ import numpy as np import matplotlib.pyplot as plt #Simple Projectile Motion x0=0 #initial position y0=0 t0=0 #initial time v0y=200 #initial velocity v0x=60 tfin=100 Nsteps=1000000 Fx=0 #force in x Fy=-9.8 #for...
2e6d1343abc058926c7d187de59ac3c75e1285a5
Modester-mw/assignmentQ2
/main.py
1,712
4.0625
4
Question 2 In plain English and with the Given-required-algorithm table write a guessing game where the user has to guess a secret number. After every guess the program tells the user whether their number was too large or too small. At the end the number of tries needed should be printed. It counts only as one try if t...
1f15caa57a11a7b2db5345fdc76c84cb13124437
Srinjana/CC_practice
/ALGORITHM/DP/catalannum.py
1,445
4.03125
4
# Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following. # Count the number of expressions containing n pairs of parentheses which are correctly matched. For n = 3, possible expressions are ((())), ()(()), ()()(), (())(), (()()). # Count the number of possib...
e11e9d9e39602863c996b12b296a67333c9a557d
bohdi2/euler
/problem59_cache_plus_brute_force.py
1,744
3.9375
4
#!/usr/bin/env python3 from itertools import cycle import string def read_cipher(filename): """returns a list of integers""" with open(filename, "r") as filestream: data = [] for line in filestream: data += [int(s) for s in line.split(",")] return data def ints_to_string...
1aae9a3907db23fb19eec8cbd544e12798122264
Jas1028/Assignment3
/Function#2.py
1,789
4.15625
4
def GetHowManyApplesYouWantToBuy(): NumberOfAppleFunc = int(input("An apple cost 20 pesos each. How many apple/s do you prefer to buy? ")) return NumberOfAppleFunc def GetTotalAmountOfApplesYouNeedToPay(PreferredAppleF, PriceOfAppleF): AmountOfAppleFunc = int(PreferredAppleF*PriceOfAppleF) return Amo...
cfc2466d3e88b83f9a46c04a50e4fa37b1747d76
QuentinDuval/PythonExperiments
/graphs/RedundantConnection2_Hard.py
4,594
3.953125
4
""" https://leetcode.com/problems/redundant-connection-ii In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents. The given input is...
a89c86fec687e86b16746ffeccd4f396077bc616
debryc/LPTHW
/ex11.py
502
3.90625
4
# print question and add comma to prevent new line after printing print "How old are you?", # initialize variable age as whatever someone inputs age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() # print inputs print "So, you're %r old, %r tall and ...
96b1d5be314b1f77217556502c92eb7babdc0907
jeanniton-mnr/cs50
/pset6/credit/credit.py
2,149
4.15625
4
# This program test if a credit card number is valid # Author: Jeanniton Monero # email: jeanniton.mnr@gmail.com # website: jeanniton.me def main(): card_number = None card_number_str = None card_len = None total = None # Get card number print("Number: ", end="") card_number = (int)(in...
a70e8bc4b728daa4715ce36085e663c1f77d9d58
Serwach/SnakeGame
/snake5.py
2,542
3.84375
4
''' Snake Game Part 5 ''' import curses from curses import KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP from random import randint WIDTH = 35 HEIGHT = 20 MAX_X = WIDTH - 2 MAX_Y = HEIGHT - 2 SNAKE_LENGTH = 5 SNAKE_X = SNAKE_LENGTH + 1 SNAKE_Y = 3 TIMEOUT = 100 class Snake(object): REV_DIR_MAP = { KEY_UP: KE...
ad93327b2baf0cf732802ade88d9ab85d61f0c5a
JPGITHUB1519/Web-Development-Udacity
/Lessons/Lesson 4- User Accounts and Security/verifying_hashed.py
543
3.6875
4
import hashlib def hash_str(s): return hashlib.md5(s).hexdigest() def make_secure_val(s): return "%s|%s" % (s, hash_str(s)) # ----------------- # User Instructions # # Implement the function check_secure_val, which takes a string of the format # s,HASH # and returns s if hash_str(s) == HASH, otherwise None...
f63ce71f552ad28b64c25176e8b202885006c065
Dvk2002/Algo
/t4.py
535
4.1875
4
#Пользователь вводит две буквы. Определить, на каких местах алфавита они стоят, # и сколько между ними находится букв. A = input('Введите первую букву : ') B = input('Введите вторую букву : ') a = ord(A) b = ord(B) print(f' Место первой буквы : {a - 96}') print(f' Место второй буквы : {b - 96}') print(f' Коли...
f0ac3b8164669bed3090669eb7b8f2963044129d
hrithikguy/ProjectEuler
/p60.py
1,944
3.8125
4
import math import numpy as np #print "hi" def is_prime(n): if n == 2 or n == 3: return True if n < 2 or n%2 == 0: return False if n < 9: return True if n%3 == 0: return False r = int(n**0.5) f = 5 while f <= r: if n%f == 0: return False if n%(f+2) == 0: return False f +=6 return True ...
71958355fc594b8d7268ce25e17401e8f167206e
topherCantrell/countdown
/src/app_count.py
1,800
3.890625
4
import datetime import time import hardware def int_to_string(value,pad_to,pad_char='*'): ret = str(value) while len(ret)<pad_to: ret = pad_char+ret return ret def show_date(date): now_month = int_to_string(date.month,2,'0') now_day = int_to_string(date.day,2,'0') now_year...
adc3327fe24e67694446fd98f023306cafd012d2
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/STRINGS/Cipher.py
2,729
4.25
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #implements encoding as well as decoding using a rotation cipher #prompts user for e: encoding d: decoding or q: Qui import sys alphabet="abcdefghijklmnopqrstuvwxyz" print "Encoding and Decoding strings using Rotation Cipher" while True: o...
af43fea1a343914f64648e16b378f6ebccb38ad4
poojan14/Python-Practice
/8.py
626
3.671875
4
def Average(StuDict,Student): s=0 for i in StuDict: if i==Student: l=StuDict.get(i) break for ch in l: num=eval(ch) s+=num avg=s/len(l) avg="{:.2f}".format(avg) #to round off upto 2 decimal places return avg def main(): StuDict={} ...
08a4a90a8b71a1ac791139f0752181f8fd74f8aa
mmrahman-utexas/pycharm_code_backup
/Test/test2.py
212
4.03125
4
x = [int(x) for x in input("Enter the coordinates here: ").split()] if (x[3]-x[1])/(x[2]-x[0])==(x[7]-x[5])/(x[6]-x[4]): print("The two lines are parallel") else: print("The two lines are intersecting")
3540c5d93e9534ee89849e621b2dead5e4cfb544
ivenpoker/Python-Projects
/Projects/Online Workouts/w3resource/Basic - Part-I/program-20.py
1,031
4.375
4
#!/usr/bin/env python3 ############################################################################## # # # Program purpose: Given a string, returns sames string with a defined # # number of repetitions. ...
8d0b5646430c634d06a518d55aedb3233a55f10f
shifalik/practice
/shifali/files_io.py
6,448
4.09375
4
''' Created on Feb 22, 2018 @author: shifa ''' #FILES I/O #---------------------------------------------------------- #printing to screen print("Python is a really great languge", "isn't it?") print() #---------------------------------------------------------- #Reading Keyboard Input #input() #reads data from key...
879ae3f64a092631a29a4de798618ea6042114bc
aparnamaleth/CodingPractice
/Geeks4Geeks/StackasQueue.py
384
3.9375
4
class Stack: def __init__(self,n): self.q1 = [] self.q2 = [] def push(self, data): self.q1.append(data) print("pushing",data) def pop(self): n = len(self.q1) for i in range(n): for i in range(n-1): self.q1.append(self.q1.pop(0)) self.q2.append(self.q1.pop(0)) return self.q2 stack = Stack(3) ...
dacdad6563791818f23d1a9dd892c9be20522756
Kimuksung/algorithm
/kakao/kakao_winter_01.py
449
3.625
4
def solution(board, moves): answer = 0 arr = [] for move in moves: for doll in board: if doll[move-1] != 0: arr.append(doll[move-1]) doll[move-1]=0 break arr_len=len(arr) if arr_len>=2: if arr[arr_len-1] == ...
6be95036c0541b308fc9acccfb634d3fba14c29e
ALMTC/Logica-de-programacao
/TD4/05.py
169
3.625
4
def tempo(x): return x/3600.0 k=0 for i in range(10): print'Digite o tempo gasto(em segundos) na terefa',i k=k+input() print 'Tempo em horas:',tempo(k)
66448a6e7731095859bff07c5c7b6e83d314f5ed
wojtez/ThePythonWorkbook
/025.UnitOfTime2.py
1,325
4.375
4
# In this exercise you will reverse the process described in the previous # exercise. Develop a program that begins by reading a number of seconds # from the user. Then your program should display the equivalent amount of # time in the form D:HH:MM:SS, where D, HH, MM, and SS represent days, # hours, minutes and se...
bb204f79cb7e06f7c93d10d5562ac76b9da8f2dc
kakshat04/LearnGIT
/UnitTest_Learn.py
1,047
3.59375
4
import unittest from Calculate_Test import * from math import pi class TestCal(unittest.TestCase): def setUp(self): self.x = TestCalculate(10, 5) def tearDown(self): pass def test_add(self): self.assertEqual(self.x.addition, 15) def test_sub(self): # x = TestCalculat...
d35760887808a715470c86b1ff65efa53235bde3
lindaandiyani/Catatan-Modul-satu
/list,tuple dan set.py
1,692
3.609375
4
x =[(1,['a','b','c'],3), (4,5,6) ] x[0][1][2] ='andi' #semua yang ada di list bisa di ubah/diedit untuk tuple hanya bisa di count sama index x[0][1].append('d') print(x) y=(1,2,3,) # print(dir(y)) a= [1,2,3,1,2,3] b= (1,2,3,1,2,3) print(60*'=') # SET/HIMPUNAN # 1. no indexing # 2. duplicate element not allowed...
a0af2f8bec31ad46d3369233995455827cdce043
kqg13/LeetCode
/Heaps/topKFrequent.py
750
3.78125
4
# Medium heap problem 347: Top K Frequent Elements # Given a non-empty array of integers, return the k most frequent elements. # Example: # Input: nums = [1, 1, 1, 2, 2, 3], k = 2 Output: [1,2] from collections import Counter from heapq import nlargest class Solution: def topKFrequent(self, nums, k): ...
c3d5b6c73574c902b58aac1157926956acb36ed5
ixkungfu/lotm
/python/scripts/re.py
544
4.5625
5
import re re_string = '{{(.*?)}}' some_string = 'this is a string with {{words}} embedded in {{curly brackets}} \ to show an {{example}} of {{regular expressions}}' # uncompile for match in re.findall(re_string, some_string): print 'MATCH->', match # compile re_obj = re.compile('{{(.*?)}}') for match in...
a7a77c1a7d241a12adef5ee7d852ad671e37a577
shellytang/intro-cs-python
/01_week2_simple_programs/char-search-recursive.py
731
4.21875
4
# check if a letter is in an alpha sorted string using bisection search def isIn(char, aStr): ''' char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise ''' # base case: if string is empty, we did not find match if aStr == '': return...
644635e8421be4ab3e101ab892e69af1425a3f5b
MateuszMazurkiewicz/CodeTrain
/InterviewPro/2020.01.17/task.py
1,007
3.90625
4
''' Given a non-empty array where each element represents a digit of a non-negative integer, add one to the integer. The most significant digit is at the front of the array and each element in the array contains only one digit. Furthermore, the integer does not have leading zeros, except in the case of the number '0'. ...
9b3d18f82cf990077a6a56e8bcf3bf804a45a739
shadykhatab/python-tutorilas-
/170_code_challenges/40_code_challenge_solution.py
668
4.3125
4
""" write a function that capitalizes the first and fourth letters of a name ex: capitalize("macdonald") --> MacDonald """ # solution 1 def capitalize(name): first_letter = name[0] in_between = name[1:3] fourth_letter = name[3] rest = name[4:] return first_letter + in_between + fourth_letter + res...
1b6a5bef4975a0b86a5ae01263b0387202102940
RaphaelCoelhof3/Python-.coursera.
/Semana2/Opcional/Exerc3_sem2_opc.py
398
4.125
4
numero = int(input("Digite um número inteiro: ")) unidade = numero % 10 print("O dígito da unidade é:",unidade) numero_sem_unid = numero // 10 decimal_do_numero = numero_sem_unid % 10 print("O dígito das dezenas é:",decimal_do_numero) numero_sem_decimal = numero // 100 centezimal_do_numero = numero_sem...
8bc68401433360091e67c4514ef6d3b746072161
Sahithipalla/pythonscripts
/for.py
662
3.90625
4
my_list=[1,2,3,4,5,6,7,8,9,10] for asdf in my_list: print(asdf) my_list=[1,2,3,4,5,6] list_sum=0 for num in my_list: list_sum=list_sum+num print(list_sum) my_list=[1,2,3,4,5] for num in my_list: if num%2!=0: print(num) my_list=[1,2,3,4,5,6,7,8,9] for num in my_list: if num%2!=0: prin...
9e6c0ab429e9dc9fdb63a683b079707f91c57c58
rafaelperazzo/programacao-web
/moodledata/vpl_data/126/usersdata/159/29447/submittedfiles/ap2.py
785
4.125
4
# -*- coding: utf-8 -*- a=int(input('Digite a:')) b=int(input('Digite b:')) c=int(input('Digite c:')) d=int(input('Digite d:')) if a>=b and a>=c and a>=d: print(a) if b<=c and b<=d: print(b) elif c<=b and c<=d: print(c) elif d<=b and d<=c: print(d) if b>=a and b>=c and b>=d: ...
b2fe83532d6d928b2f217ee82a64c430c4111b56
BakJungHwan/Exer_algorithm
/Programmers/Level2/digit_reverse(jpt)/digit_reverse.py
208
3.6875
4
# _*_ coding: Latin-1 _*_ def digit_reverse(n): return [int(c) for c in str(n)[::-1]] # Ʒ ׽Ʈ ڵԴϴ. print(" : {}".format(digit_reverse(12345)));
4f00bb86f4ae37c85175e813e0728f7556bf7b2f
lovishagumber/assignment
/assingment2.py
375
3.828125
4
#Q1 print anything print("i am lovisha") #Q2 join two string print("acad"+"view") #Q3 print values of x,y,z x=2 y=3 z=4 print(x,y,z) #Q4 print let's get started print("let\'s get started") #Q5 s="acadview" course="python" fee=5000 print("hi you are in %s, your course is %s and fee is %d" %(s,course,fee)) #Q6 name=...
44916092a8dc31400d478184814be464a6aab48c
JamesMedeiros/Python
/media_de _10.py
134
3.625
4
n = 1 soma =0 while n <= 10: x = int(input("digite %dº numero: "%n)) soma = soma + x n = n + 1 print ("media : %4.2f" %(soma/10))
1bc68ebf2cb554269219028e7a4d761e2995f5a3
tom-010/brutal_coding
/coverage_delete/pet-project copy/fib.py
257
3.5625
4
def fib(n): if n < 0: print("error") if n <= 2: return 1 counter = 0 for i in range(1, 20): counter += i return counter def sum(a, b): print(a) print(b) return a + b def sub(a, b): return a - b
164a4aff3b53ff8448d30d73626b920b27961f03
Marino4ka/Exchange
/abacus.py
535
3.5
4
def print_abacus(value): answer = '' string = '|00000*****|' len_number = len(str(value)) while len_number != 10: len_number = len_number + 1 answer += (string[0:-1] + ' ' + string[-1] + '\n') len_number = len(str(value)) new_value = str(value)[::-1] while len_number != 0: ...
334ae4cf87ac15eead0e9c3c1be9ca2ec86b80ff
ww35133634/chenxusheng
/ITcoach/sixstar/基础班代码/15_面向对象/lx_08_创建对象传参.py
3,182
4.125
4
""" 演示创建对象传参 """ # class Man: # # 成员变量的定义 # def __init__(self): # 对象本身 # self.gender = None # self.name = None # self.place = None # # 成员方法 # def myself(self): # 成员方法去调用成员变量(公有变量) # print('我是:%s,性别是:%s,我来自:%s,我为中国加油!' %(self.name,self.gender,self.place)) # # man1 = Man...
ad382322807bae8292d2fde33f5f9872cad026e4
firerycon/2016_Python_Test
/module2_more_python/sphinx_example/src/m2_args.py
1,095
4.0625
4
import sys import argparse # 取得參數最原始的方法 list print('raw arguments = ' + str(sys.argv), end='\n\n') # 使用 Python 內建的參數解析 parser = argparse.ArgumentParser() # Positional argument(給參數時會依照順序填入,如果沒有提供會報錯) # 使用 type = 可以指定要轉換成什麼樣的型態(預設是字串) # help = 可以指定使用 -h 印出幫助訊息時,針對該參數顯示的說明 parser.add_argument('square', help="display a s...
1952e98e9266d3e84eba2c0f8b93a3367817403a
khush-01/Python-codes
/HackerRank/Mathematics/Fundamentals/Medium/Summing the N series.py
108
3.546875
4
mod = 10 ** 9 + 7 for _ in range(int(input())): n = int(input()) print((n % mod) * (n % mod) % mod)
03852842cb4ab3d970d5dc4266db3ec415ad31c8
yeos60490/algorithm
/leetcode/medium/add_two_numbers.py
841
3.78125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: #print(l1) sum_value = l1.val + l2.val carry = int(sum_val...
4aca83bdf3f3cf232cff6326ce0448a6dfde494a
iam-amitkumar/BridgeLabz
/DataStructureProgram/Problem13_PrimeAnagramStack.py
1,452
4.03125
4
"""Adding the Prime Numbers that are Anagram in the Range of 0 ­ 1000 in a Stack using the LinkedList and Print the Anagrams in the Reverse Order. @author Amit Kumar @version 1.0 @since 09/01/2019 """ # importing important modules from DataStructureProgram.Stack import * # this function checks whether the given two ...
2fee99cb34d796e297aac3f2eecd1af8a15482ed
tutejadhruv/Datascience
/Next.tech/Analyzing-Text-Data/solution/tokenizer.py
1,373
4.25
4
''' Tokenization is the process of dividing text into a set of meaningful pieces. These pieces are called tokens. For example, we can divide a chunk of text into words, or we can divide it into sentences. Depending on the task at hand, we can define our own conditions to divide the input text into meaningful tokens. Le...
76779e3a91d5c7d4ccf9b7125027b4e51dd9b962
FR0GM4N/Algorithm
/_basic/2차원 배열 연습.py
497
3.96875
4
a = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], ] # 2차원 리스트 출력 1 for i in range(len(a)): # 가로행 길이 (3) for j in range(len(a[0])): # 세로열 길이 (4) print(a[i][j], end=' ') print() # 1 2 3 4 # 5 6 7 8 # 9 10 11 12 # 2차원 리스트 출력 2 for i in range(len(a)): for j in range(len(a[0])): ...
07c121ef770d37bc413bd19734ba7c1bb96a8a51
Kevinxu99/NYU-Coursework
/CS-UY 1134/HW/HW2/lab3q3b.py
331
3.875
4
def square_root(num): n=num*10000 left=100 right=n while(right-left>1): mid=(left+right)//2 print(left," ",right) if(mid**2>n): right=mid elif(mid**2<n): left=mid elif(mid**2==n): return mid return (left/100) print(square_r...
25c5340e9c7521e850fbc2e696d196f116b360d1
Lekhaa13297/Codekata
/character.py
234
4.03125
4
r=input("enter the string") le=len(r) c=0 for i in r: if i.isalpha(): print("%s is a character"%(i)) c=c+1 else: print("%s is not a character"%(i)) if c==le: print("all are characters") else: print("all are not characters")
3190d35822f19d8c0d24c7a323262e6a059d1c78
sneharnair/Trees-3
/Problem-2_Symmetric_tree.py
1,333
4.125
4
# APPROACH 1: RECURSION (WITH NO INORDER) # Time Complexity : O(n), n: number of nodes of the tree # Space Complexity : O(lg n) or O(h) - h: height of the tree, space taken up by the recursive stack # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : None # # # Your code here ...
0751c9354d55301ddf84967f5e7874e2540a41a4
Khushbulohiya/DataStructures
/Strings_Array/mergesort.py
691
3.859375
4
#!usr/bin/python def mergesort(alist): print ("Splitting", alist) if len(alist) > 1: middle = len(alist)/2 left = alist[:middle] right = alist[middle:] mergesort(left) mergesort(right) i = 0 j = 0 k = 0 while i < len(left) and j < len(right): if left[i] > right[j]: alist[k] = right[j] k ...
5f796f9e72d54055b168882fdebbda33802926b7
chenpengcode/Leetcode
/search/540_singleNonDuplicate.py
1,172
3.765625
4
from typing import List class Solution: def singleNonDuplicate(self, nums: List[int]) -> int: lo = 0 hi = len(nums) - 1 while lo < hi: mid = lo + (hi - lo) // 2 halves_are_even = (hi - mid) % 2 == 0 if nums[mid + 1] == nums[mid]: if halv...
18657ce5d1a0e0d19caf231a87ce86fe58536f93
yanghaotai/leecode
/leetcode/704.二分查找.py
722
3.984375
4
''' 704. 二分查找 难度 简单 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。 示例 1: 输入: nums = [-1,0,3,5,9,12], target = 9 输出: 4 解释: 9 出现在 nums 中并且下标为 4 示例2: 输入: nums = [-1,0,3,5,9,12], target = 2 输出: -1 解释: 2 不存在 nums 中因此返回 -1 ''' def search(nums, target): """ :type nums: List[i...
44f635907f80799f8d4e6908d261ebc92156e4da
jspruyt/spark_devnet_code
/tropo_mission_test.py
528
3.671875
4
say("Hello, welcome to the language selector version 7") result = ask("please press 1 for French, 2 for Italian, 0 for english", { "choices": "[1 DIGITS]", "terminator": "#", "mode": "dtmf"}) log("the language of your choice:" + result.value) say("you chose " + result.value) if int(result.value) == 0: sa...
894fe78edc4fb9cd49af0cc131f9995724724c30
acneuromancer/problem_solving_python
/basic_data_structures/stacks/stack_example.py
391
3.78125
4
from Stack import Stack s = Stack() print('\nInitial size of the stack: ', s.size()) print('\nTest whether the stack is empty: ', s.is_empty()) s.push("Apple") s.push(True) s.push(6.31448) s.push(10) print('\nPeek into the stack: ', s.peek()) print('\nSize of the stack: ', s.size()) print('\nPop all items from th...
ad31705235f979e8f216bfcb0eabc9e8552157b9
cristiano250/pp1
/02-ControlStructures/#02-ControlStructures - zad. 44.py
245
3.53125
4
#02-ControlStructures - zad. 44 a=int(input("Podaj limit prędkości (km/h): ")) b=int(input("Podaj prędkość samochodu (km/h): ")) if b-a<=10: print("Mandat wynosi:",(b-a)*5,"zł") else: print("Mandat wynosi:",50+((b-a)-10)*15,"zł")
676c13054ebe36f2ac9c95bab6f28a8764cf1f11
beerfleet/udemy_tutorial
/Oefeningen/uDemy/bootcamp/lots_of_exercises/range_in_list.py
824
3.671875
4
""" Write a function called range_in_list which accepts a list and start and end indices, and returns the sum of the values between (and including) the start and end index. If a start parameter is not passed in, it should default to zero. If an end parameter is not passed in, it should default to the last value in...
159643866d779d6566aed82ed51993c26f51ac78
kkyaruek/project-euler
/python3/test_prime.py
943
3.96875
4
from math import sqrt from time import time def is_prime(n): if n <= 1: return False if n != 2 and n % 2 == 0: return False for i in range(3, int(sqrt(n)) + 1, 2): if n % i == 0: return False return True # sieve of eratosthenes def find_primes(start, end): sie...
c028225024835858e7a0a6a6b0dd922e1bee9b0c
Emma-2016/introduction-to-computer-science-and-programming
/lecture08.py
4,432
3.84375
4
#Iterative exponent def exp1(a, b): ans = 1 while (b > 0): ans *= a b -= 1 return ans #2 + 3b; when b =10, it is 32;when b=100, it is 302;when b=1000, it is 3002 #care about the rate of growth as size of problem grows, that is how much bigger does this get as I make the problem bigger #Asymp...
5805f3aba5e449d97af68ecd615191a1834d3466
0xb00d1e/AoC-2020
/9/solution.py
1,257
3.515625
4
def part1(): input_data = load_data() invalid_number = find_invalid_number(input_data) print(f'Answer - Part1: {invalid_number}') def part2(): input_data = load_data() invalid_number = find_invalid_number(input_data) numbers = find_numbers_in_sum(input_data, invalid_number) numbers.sort() ...
10346e9e8a68b82fd8da4230c6f53cf4cae93cd3
solankidhairya77/dhairya
/d2.py
254
3.640625
4
aa = "Hello Eric would you like to learn some Python today?" print(aa) bb = "dhairya solanki" print(bb.upper()) print(bb.title()) print(bb.lower()) cc= " \t Albert Einstein once said, \n “A person who never made a mistake never tried anything new." print(cc)
bfe9ca0f4372fc7c05cbbb0a4ca1880e6be32fc7
AasthaGoyal/Rock-Paper-Scissor-Game-
/(c).py
248
3.6875
4
import os import sys string = input("Enter a string:") string.strip(" ") i=0 while(string): while(string[i]==" "): #if(string[i]==" "): j =i break for k in range(0,j): print(string[k])
bd89b8b9e1582fcbe70fdbe239fbf411cb188fbe
bulutharunmurat/hackerrank
/Dictionaries&Hashmaps/countTriplets.py
454
3.609375
4
arr = [1, 2, 2, 4] r = 2 arr2 = [1, 3, 9, 9, 27, 81] r2 = 3 arr3 = [1, 5, 5, 25, 125] r3 = 5 from collections import defaultdict def countTriplets(lst, ratio): v2 = defaultdict(int) v3 = defaultdict(int) count = 0 for k in lst: count += v3[k] v3[k * ratio] += v2[k] v2[k * rati...
a8bc411483bd9b2fc4b383bda40d802a589cf6c6
green-fox-academy/Atis0505
/week-04/day-03/fibonacci/fibonacci.py
353
4.21875
4
def fibonacci_counter(int_index): if int_index == None: return None else: if type(int_index) is not int: return 0 if int_index == 0: return 0 elif int_index == 1: return 1 else: return fibonacci_counter(int_index-1) + fibona...
0d96e943254c004be51980b6bf163a093537870b
ajityadav924/pandas-practice2
/housingPd.py
604
3.71875
4
import pandas as pd df=pd.read_csv("Housing.csv") #print(df) print(df.head()) #to print 1^st 5 rows print(df.tail()) #to print last 5 rows print(df[20:30]) #to print the rows between 20 to 30 print(df.dtypes) print(df['bedrooms'].describ...
f0ea590195b012d386066010a46d6e026ae9d156
kcarollee/Problem-Solving
/Python/1110.py
389
3.5625
4
class Cycle: def __init__(self, N): self._n = N self._cycle = 1 def cycleThru(self): if self._n > 9: a, b = self._n // 10, self._n % 10 elif self._n <= 9: a, b = 0, self._n while 10 * b + (a + b) % 10 != self._n: self._cycle += 1 a, b = (10 * b + (a + b) % 10) // 10, (10 * b + (a + b) % 10) % 1...
1468c2627d445e483cb80d0f18c4b7eec3a0f50c
acneuromancer/problem_solving_python
/graphs_2/Graph.py
1,662
3.59375
4
class Vertex(object): def __init__(self, key): self.key = key self.neighbours = {} def add_neighbour(self, neighbour, weight = 0): self.neighbours[neighbour] = weight def __str__(self): return '{} neighbours: {}'.format( self.key, [x.key for x in sel...
b71fd0e5cd1d6233d89059fdaf5f98462a58d691
lastosellie/202003_platform
/한누리/04_algorithm_basic/mergesort.py
814
4.09375
4
def sort(l_list, r_list): list = [] while len(l_list) > 0 or len(r_list) > 0: if len(l_list) > 0 and len(r_list) > 0: if l_list[0] > r_list[0]: list.append(r_list[0]) r_list = r_list[1:] else: list.append(l_list[0]) ...
e86181c7db47e9d90152b8061e8037306b111507
Ankita2426/python
/python.123/practisessss.py
204
3.71875
4
def bubblesort(a): n = len(a) for i in range(n-1,0,-1): for j in range(i): if a[j]<a[j+1]: a[j+1],a[j]=a[j],a[j+1] a = [1,56,7,4,0,98,7] bubblesort(a) print(a)
4140224710e26d421c34a8a734818707ca20fdde
paramita2302/algorithms
/iv/Linkedlist/remove_duplicates_sorted_list.py
982
3.8125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def make_list(A): head = ListNode(A[0]) ptr = head for i in A[1:]: ptr.next = ListNode(i) ptr = ptr.next return head def display(head): L = [] while he...
febe57623d228ad4e62557341662adc168cdbf64
Coolman6564/python_learning
/mcb.pyw
2,132
3.59375
4
#! python3 # mcb.pyw - Saves and loads pieces of text to the clipboard. # Usage: py.exe mcb.pyw save <keyword> - saves clipboard to keyword. # py.exe mcb.pyw delete <keyword> - Deletes a keyword from the list. # py.exe mcb.pyw delete all - Deletes ALL keywords from the list. # py.exe mcb.pyw <keywo...
4fe8170e11af47366522ebe93da07c7f90f35cbc
hpylieva/algorithms
/FillingLinkedList.py
430
3.96875
4
from LinkedList import ListNode if __name__ == '__main__': dummyHead = ListNode(0) a = dummyHead for i in [2, 4, 3]: a.next = ListNode(i) a = a.next # dummyHead.next now is a linked list with values 2,4,3 # analogy l = [0, []] c = l print(f'l: {l}, c: {c}') c[1] = [...