blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
9a72ef42150c09a29cc513ef53c59ef0165a6bf0
fearnoevil7/PythonStack
/python/fundamentals/functions_intermediate1.py
584
3.625
4
import random def randInt(min = , max = ): num = random.random(1.0, 101.0) return num import random print(random.random() * 100) import random def randInt(min = "", max = ""): if len(min) > 0: num = float(min) + 100 return random.random() * num - float(min) if min == "" and max == "":...
37e0ae1d93687dab5e2b6dbb11055a189d211a6d
fearnoevil7/PythonStack
/python/fundamentals/users_with_bank_accounts.py
2,038
3.96875
4
class BankAccount: def __init__(self, account_balance, int_rate,): self.account_balance = account_balance self.int_rate = int_rate def deposit(self, amount): self.account_balance += amount return self def withdraw(self, amount): self.account_balance -= amount ...
2ca11eaec64818697ef8153e3ca58c631d325afd
Dark-TN/Analisis-algoritmos
/Tarea 1/tarea1.py
620
3.6875
4
n = 10 global rec rec = 0 def recursion1(n): global rec if n < 1: return 1 else: rec += 1 return recursion1(n/2) + n def recursion2(n): global rec if n < 1: return 1 else: for i in range(3): rec += 1 return recursion2(n/2) + n de...
c116894ea4d4a2a93804f482fd68d6d590b225b1
TracySanFilipo/mystery_word
/mystery_word.py
4,450
4.0625
4
import random import sys def difficulty_from_user(): while True: difficulty = input("Choose a difficulty level: select 1 for easy, 2 for normal, or 3 for hard: ") if difficulty == '1': return '1' elif difficulty == '2': return '2' elif difficulty == '3': ...
1577e6b9980c64665b7789935dabd43354ad0cde
srgzyq/study
/PythonStudy/pyBegining/ex3.py
592
3.984375
4
# Prints a sentence in a centered "box" of correct width sentence = raw_input("Sentence: ") screen_width = 80 text_width = len(sentence) box_width = text_width + 6 left_margin = (screen_width-box_width) // 2 print print ' ' * left_margin + '+' + '-' * (box_width-2) + '+' print ' ' * left_margin + '| ' + ...
67bbf83f536c9978cf6e7e2764877f113003ce0d
brange/advent-of-code-python
/2020/day18.py
2,274
3.796875
4
from utils import api YEAR, DAY = 2020, 18 def calc(row, is_part2=False, start_index=0, start_subcalc='('): sum_ = 0 index = start_index operator = '+' add_or_multiply = lambda value: sum_ + value if operator == '+' else sum_ * value while index < len(row): item = row[index] if it...
55a870349405f243b9a7b6fad1a4a27c82d9017a
rohitgit7/Ethans_Python
/Class4_[13-10-2018]/dictionary.py
2,117
4.40625
4
#Dictionary is a collection which is unordered, changeable and indexed data = { 'name' : 'Rohit', 'roll_no' : 20, #will be overriden by last key value 'city' : 'Pune', 'roll_no' : 34, 2 : 234} #dict() is a constructor too print data print "type(data)", type(data) data['name'] = 'India' data['call'] = 12345...
e16bae19fa0a5725dbbc2f28a3ad75f4f29c1e1b
rohitgit7/Ethans_Python
/Class14_[08-12-2018]/inheritance.py
898
3.984375
4
class parent1: firstvar = "This is firstvar in parent1" secondvar = "This is secondvar in parent1" class parent2(object): #object is passed means it inherits ONLY object class nothing else thirdvar = "This is thirdvar in parent2" secondvar = "This is second var in parent2" class child(parent2,parent1): #secon...
a8c836841bb5422473a60ffdee9b09f1be7e49ac
rohitgit7/Ethans_Python
/Class12_[01-12-2018]/regex.py
567
4.15625
4
import re #match() checks for a match only at the beginning of the string #while search() checks for a match anywhere in the string var = "This is a regex with is repeated" a = re.match(r'(.*) is (.*)',var) s = re.search(r'(.*) is (.*)',var) print a print a.group() print a.group(1) print a.group(2) print s.group() p...
7c9ce41e8653586ddd1e030039f58924447fc038
rohitgit7/Ethans_Python
/Class5_[14-10-2018]/Conditions.py
596
4.15625
4
#0 = False #non-zero are True name1 = raw_input("Enter name1:") name2 = raw_input("Enter name2:") if name1 != name2: print "Names are not same" elif name1=='Rohit': print "Name is Rohit" else: print "Names are same" stud = {1:{'Name':'Prakash','boy':True,'girl':False}, 2:{'Name':'Pooja','boy':False,'girl':True}}...
afe039a8f713e6a13372d2de91ec8c0d972a3d6d
gwlilabmit/Ram_Y_complex
/msa/msas_with_bad_scores/daca/base_complement.py
1,870
4.3125
4
#sequence = raw_input("Enter the sequence you'd like the complement of: \n") #seqtype = raw_input("Is this DNA or RNA? \n") sequence = '' seqtype = 'DNA' def seqcomplement(sequence, seqtype): complement = '' for i in range(len(sequence)): char = sequence[i] if char == 'A' or char == 'a': if 'R' in seqtype o...
0112738183556f44eae969097a92582412e3682b
gwlilabmit/Ram_Y_complex
/consensus/separate_by_fasta_header.py
633
3.609375
4
#this is a really dumb script. It literally takes in a fasta format file with multiple entries #e.g. >gene_1 \n sequence_1 \n >gene_2 \n sequence_2 ... #and it exports each >gene \n sequence into a separate file named based on the salient header infile = open("21_cleavage_windows_final.txt", "r") #choose your input fi...
5f08f6f1d7132752d95fe793fec309850323f21f
KrishnaB7/python
/games/graphical/tictactoe.py
4,285
3.6875
4
#! /usr/bin/python3 import random from tkinter import * tk = Tk() canvas = Canvas(tk, width=300, height=300, bg="gray75") canvas.pack() canvas.create_rectangle(0, 0, 300, 300, fill="", width=10) canvas.create_line(100, 0, 100, 300, width=5) canvas.create_line(200, 0, 200, 300, width=5) canvas.create_line(0, 100, 300, ...
450279a995a169486ff909047c0e989d9e7dd200
KrishnaB7/python
/graphics/turtle/snake.py
606
3.78125
4
#! /usr/bin/python3 import turtle import time import random t = turtle.Pen() t.speed(0) t.width(75) colors = ['red2', 'blue2', 'springgreen', 'yellow2', 'aqua', 'orange', 'hotpink'] t.color(random.choice(colors)) for x in range(3): for x in range(150): t.color(random.choice(colors)) t.forward(1) ...
fb6f8741d3f5e49ce1cad26a3b2d9da4a52cdf2d
KrishnaB7/python
/graphics/tkinter/worm.py
350
3.71875
4
#! /usr/bin/python3 from tkinter import * tk = Tk() canvas = Canvas(tk, width=500, height=500) canvas.pack() a = -200 b = -200 for y in range(100): c = 0 for x in range(100): canvas.create_oval(a, b, a+500, b+500, fill="gray"+str(c), outline="gray"+str(c)) a = a + 0.7 b = b + 0.7 ...
5eead0bd31ab85a27925a22a450abc5eeff8f689
gayathrib17/pythonpractice
/IdentifyNumber.py
1,356
4.40625
4
# Program to input from user and validate while True: try: # try is used to catch any errors for the input validation into float num = int(input("Please input a integer between -9999 and 9999: ")) except ValueError: # ValueError is raised when we are attempting to convert a non numeric string into floa...
acd35b53f0c96a58668fac75da7ff94e6d7421d6
tina0430/Python_examples
/begining/chapter02/ex2_11.py
997
3.71875
4
mydict=dict(k1=1, k2='abc', k3=3.4) print(mydict) print() coffee = {'espresso':'에스프레소', 'latte':'라떼'} print(coffee) print('coffee 사전에 등록된 자료 개수:',len(coffee)) print(coffee['espresso']) #키로 검색 print(coffee.keys()) print(coffee.values()) print(coffee.items()) print() print(list(coffee.keys())) print(lis...
f219cb1f4b53b70520b2532ff69a6d7327bf9373
tina0430/Python_examples
/begining/chapter02/ex2_09.py
779
3.546875
4
t=('a','b','c','a') #t='a','b','c','a' #괄호를 적지 않아도 튜블이 되나 권장하지 않음 print('t는',t) print('t * 2는', t*2) print('t가 가지고 있는 원소의 개수는 %d개'%(len(t))) print('t가 가지고 있는 \'a\'의 개수는 %d개'%(t.count('a'))) print('t가 가지고 있는 첫 번째 \'a\'의 인덱스는 ', t.index('a')) print() p=(1,2,3) #p[1]=10 #에러 - 튜플은 수정이 안된다. q=list(p) ...
158f0c4565cf18a81993bcf711e529ac5d8f9f58
tina0430/Python_examples
/machine_learning/ex07.py
413
4
4
#간단한 1차 방정식 import numpy as np import matplotlib.pyplot as plt def step_function(x): return 2*x+1 #1.0 부터 4.5까지 05씩 증가시키기 x = np.arange(1.0, 4.1, 0.5) y = step_function(x) #1.0 1.5 2.0 print("x :", x) print("y :", y) #파란색 그래프를 위한 실험용 데이터 y_answer = [3.1, 4.1, 4.9, 6.1, 6.9, 8.2, 9.1] plt.plot...
de1cbe1a6567efc5f23c74d65a05beefad5ce94e
tina0430/Python_examples
/begining/chapter03/ex3_03.py
106
3.796875
4
def swap(a, b): return b, a a = 1 b = 2 print(swap(a,b)) a='해' b='달' print(swap(a,b))
693433f1fbfc06da7a419a86ad8d68eb731b9e93
tina0430/Python_examples
/begining/chapter03/ex3_12.py
303
3.578125
4
def make2(fn): return lambda : "안녕" + fn() def make1(fn): return lambda : "반가워" + fn() def hello(): return "홍길동" hi = make2(make1(hello)) print(hi()) @make2 @make1 def hello2(): return "신기해" hi2 = hello2() print(hi2) hi3 = hello2 print(hi3)
e908e4814f2cdf8e0973ed51ae6c3cda19e30ba9
cutiebananaface/Homework_quantum
/Homework3.py
5,805
3.640625
4
import numpy as np import matplotlib.pyplot as plt import scipy.linalg as la import scipy.integrate as integrate import math from EigDiag import EigDiag class Matrix(): # this will make my matrix elements. Every matrix element will be an object of this class masse = 0.00054858 u = 1.00784 / (2 * ma...
5732c3664ff8bd9ea2961eb127b4ab49717ad31f
Geovo/kalcula2r
/functions.py
1,164
3.5
4
# here go the functions and their values class Function: def __init__(self, name, func, params): self.name = name self.run = func self.params = params[1:-1].split(", ") # skip the whitespace print(self.params) def run_with_array(self, ary): out = "(" for i, a in ...
41149abd77dcd92469e5dd3e24fc3edf92a89664
kcollett1/Stanford_Algorithms
/course4/week3/graph.py
3,238
3.765625
4
''' This is my implementation of a WEIGHTED UNDIRECTED complete graph as an adjacency list, modified to only store the vertex coordinates and not every single edge connecting them. This can work because this is a complete graph, so there is implicitly an edge from each vertex to every other vertex, and the...
fbfea856df728657eb1e74f3debd72fe81e6c75a
kcollett1/Stanford_Algorithms
/course2/week2/get_shortest_paths.py
1,453
3.53125
4
#!/Users/kcolletti1/opt/anaconda3/bin/python3 from graph import Graph import time def main(): test_graph = Graph() with open('dijkstraData.txt') as graph_info: for graph_line in graph_info: data = [v for v in graph_line.strip().split('\t')] source_vert = int(data[0]) ...
6a881b0d48bcf895069315e30a0b56fe8b753505
kcollett1/Stanford_Algorithms
/course4/week4/2sat_scc.py
4,004
3.875
4
#!/Users/kcolletti1/opt/anaconda3/bin/python3 ''' In this code, we take as input different instances of a 2-SAT (2 satisfiability) problem. We implement an algorithm that constructs a graph from the variables and clauses (this is the "implication" graph where each variable exists on the graph as two vertices...
746f43e4d0563a027b6efeaa9a8ce8576c3eaf79
kcollett1/Stanford_Algorithms
/course1/week3/sort_list.py
3,079
4.15625
4
#!/Users/kcolletti1/opt/anaconda3/bin/python3 ''' This code takes as input a list of numbers from 1 to 10000 in unsorted order. We run quick_sort on the list to sort it, using four different pivot choice methods. First, we always choose the first element to be the pivot. Second, we always choose the last elem...
a18667443823447e611493bf4dfc4fb4aa8693df
kcollett1/Stanford_Algorithms
/course3/week1/heap.py
9,080
3.5
4
''' my implementation of a min and max heap, from a previous section, with some very slight modifications to apply it to kruskal's minimum spanning tree finding greedy algorithm (which uses a min heap). ''' class Heap: def __init__(self): self.arr = [] self.size = 0 # equivalent to le...
aa9dd18cc533e68e8deee6ca5c8c5d8884905e14
kcollett1/Stanford_Algorithms
/course1/week2/matching_index.py
1,970
4.03125
4
''' this is my implementation of an algorithm I designed to decide if there exists an index in a sorted array of distinct integers that matches the array value at that location. this algorithm is basically binary search, as we can check the middle element and if it is not equal to the index at that value, e...
d9950e20d25acaa05c64a3968fa857ad7dec5c33
BrianPugh/pugh_torch
/pugh_torch/utils/misc.py
593
3.6875
4
from contextlib import contextmanager from time import time @contextmanager def timeit(msg=""): """Timing context manager Example usage: >>> with timeit('Data Reading'): ... time.sleep(5) Data Reading executed in 5.002 seconds. Parameters ---------- msg : str M...
002604e0881cdef8fab2f55c09d85d49586bfee5
aaallliiieeeee/LearnPythonProjects
/howOldExact.py
289
4
4
print("Let's see how long you have lived in days, minutes, and seconds.") print("Please enter your age...") age = int(input("Age: ")) days = age * 356 minutes = age * 525948 seconds = age * 31556926 print 'You have been alive for', days, 'days', minutes, 'minutes and', seconds, 'seconds'
3b86fbfbb63fda4dfa00ec23f3faccc6efd601be
borowis/dcp-cs212
/Lesson3/reparser.py
9,145
3.515625
4
import functools import re def search(pattern, text): "Match pattern anywhere in text; return longest earliest match or None." for i in range(len(text) or 1): m = match(pattern, text[i:]) if m is not None: return m def match(pattern, text): "Match pattern against start of text; return long...
0604bd2aef3b546c96495ea78bd243523d240a4e
willdickson/ad_coyote_lake
/ad_coyote_lake/wind_speed.py
4,780
3.703125
4
import scipy import scipy.special import scipy.interpolate import matplotlib.pyplot as plt def wind_speeds_from_normal(mu, sigma, number, cutoff, plot=False, normalize=True): """ Generates a respresentative sample of wind speeds (and weights) from normal distribution with mean mu and standard deviation si...
0d31ceaf319227752a0c3b9be4219e8a8a37b479
luzak100/cwiczenia
/vowels6.py
286
3.734375
4
vowels=['a','e','i','o','u'] word=input("Podaj słowo, w którym należy wyszukać samogłoski: ") found={} for letter in word: if letter in vowels: found.setdefault(letter,0) found[letter]+=1 for k,v in sorted(found.items()): print(k,'znaleziono',v,'raz(y).')
7c5694988591983d66a1463bcfc6512f74a54ef4
MrMallet/Python
/SqRoot.py
139
4.125
4
#find the square root and round up import math num= int(input("Please enter an number: ")) num = math.sqrt(num) print(math.ceil(num))
2e5f3ae7d60dd92be1512474c5d88fb8ff411e73
MrMallet/Python
/exercise10.py
168
3.578125
4
import random a = random.sample(range(100),5) b = random.sample(range(100),10) print(a) print(b) list=[x*y for x in a for y in b if x*y %2 != 0] print(list)
4ca096567cfcf9673f70d793dda1c06d94db2f04
MrMallet/Python
/exercise7.py
179
3.515625
4
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] b=[] #for i in a: #if i % 2==0: #b.append(i) #print(b) b= [element for element in a if element %2 ==0] print(b)
66eb4d1e1fa652502dc8b5d2d88a20bb2b3a208f
pointerness/python
/datastructures/assigment1.py
547
3.78125
4
#DSA-Assgn-1 def merge_list(list1, list2): merged_data="" #write your logic here for i in range(len(list1)): if( list1[i] != None): merged_data+=list1[i] j=len(list2) -i-1 if(list2[j] != None): merged_data+=list2[j] merged_data+=" " return merged_...
43dc3287790059c23c350e17c5bdee0ab8451051
ncw1992120/Python_Cookbook
/01.DataStructureAndAlgorithms/01.09.py
637
3.828125
4
# -*- coding: utf-8 -*- #!/usr/bin/env python """ Q:有两个字典,找出它们中间可能相同的地方。 A:要找出两个字典的相同之处,只需通过keys()或者items()方法执行常见的集合操作即可。 """ a = { 'x' : 1, 'y' : 2, 'z' : 3 } b = { 'w' : 10, 'x' : 11, 'y' : 2 } #Find keys in common a.keys() & b.keys() #Find keys in a that are not in b a.keys() - b.keys() #Find (key,value) p...
4e680b385fae4f732f7c05544e81a262f6a9ee87
ncw1992120/Python_Cookbook
/01.DataStructureAndAlgorithms/01.14.py
842
3.578125
4
# -*- coding: utf-8 -*- #!/usr/bin/env python """ Q:在同一个类的实例之间做排序,但是它们并不原生支持比较操作。 A:内建的sorted()函数可接受一个用来传递可调用对象(callable)的参数key,而该可调用对象会返回待排序对象中的某些值,sorted则利用这些值来比较对象。 """ class User: def __init__(self, user_id): self.user_id = user_id def __repr__(self): return 'User({})'.format(self.user_id) users = [User(23)...
947209bfe0069b4506fc0dfaab195cb21eae9668
Akshayab/crypto-project
/Problem2.py
9,765
3.84375
4
import binascii import os # Author: Akshay Budhkar # For purposes of understanding the algorithm - use the following terminology # Message M, Response R, Encrypted Message Em, Encrypted Response Er # Assume username for our purposes is abudhkar # M = LOGIN abudhkar hello_world # R = WELCOME abudhkar # M = LOGIN abudhk...
83ec2d22d6a1e52cb0a27a1fac8dc680c5afa7f4
Xiaojia1234/Python-algorithm-data-structure
/Dynamic programming/chapter03/beibao_search.py
1,331
3.578125
4
''' 0-1背包问题: 徒步旅行者,可携带物品险种为a公斤,右n种物品可选择装入包中, 已知每种物品的重量及其使用价值,问此人如何选择携带的物品,使使用价值最大? 类似问题: 工厂下料问题、运输过程中的货物装载问题、人造卫星内物品装载问题 ''' # 1. 通过回溯法求解0-1背包问题 info = [ [3,8], [2,5], [5,12] ] selects = [] max_select = [] max_value = 0 def search(depth,rest): if depth == 3: print(selects) values = []...
6b1d8af759f062da86f6ad8ea9b6fc9062ee66d2
Xiaojia1234/Python-algorithm-data-structure
/Sorting_Algorithm/sorting.py
2,450
3.59375
4
''' 冒泡排序: 复杂度:在该排序算法中,要遍历n-1轮,每一轮都要比较数组中的元素,所以时间复杂度是O(n2) 稳定性:比较的过程中相同的元素并不会发生交换,所以冒泡排序是一种稳定的排序算法。 相邻的两个元素进行比较,然后把较大的元素放到后面(正向排序),在一轮比较完后最大的元素就放在了最后一个位置, 因为这一点像鱼儿在水中吐的气泡在上升的过程中不断变大,所以得名冒泡排序。在该排序算法中,要遍历n-1轮, 每一轮都要比较数组中的元素,所以时间复杂度是O(n2) ''' alist = [1,5,2,76,3,2,7,8,4,23,78,32,65] def bubble_sort(alist): length =...
c9ce9e2d12d889e8f38fb3bbd1e3bc02f9a8b842
navsinghoberoi/PythonDemoProject
/Basics/IntermediateConcepts.py
3,135
4.40625
4
# Lambda function (func without any name, usually 1 liner functions) lambdaMultiply = lambda x, y: x * y print("Value computed using lambda method = ", lambdaMultiply(4, 5)) # Another way of implementing lambda functions: print((lambda x, y: x * y)(4, 5)) # *args (used to pass variable number of arguments to a func...
1e80b81792deaf2f5e70a18a4690f9a89a22baf4
navsinghoberoi/PythonDemoProject
/date.py
348
3.703125
4
import time import calendar print("Current epoch value = ", time.time()) timeStructure = time.localtime(time.time()) print("Current time structure :", timeStructure) # Print current local time # localtime = time.asctime(time.localtime(time.time())) print("Local current time :", localtime) # Print calendar # print(...
1110b8b86c71d30e8e220e005cc60ac2c3ce546a
oscarhuang1212/Leecode
/LeetCode#073_Set_Matrix_Zeroes.py
2,350
4.15625
4
# File name: LeetCode#73_Set_Matrix_Zeroes.py # Author: Oscar Huang # Description: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. # # Example 1: # Input: # [ # [1,1,1], # [1,0,1], # [1,1,1] # ] # Outp...
89ceb1a2c3038093307e2587fd99f6d740766edc
ryotaro-45123/DL-from-Scratch
/doc-test.py
366
3.65625
4
def print_sum(x, y): """This function is test function Parameters ---------- x: int y: int Return ------ object: int Examples -------- >>> print_sum(1, 2) 3 >>> print_sum(-1, 2) 1 """ print(x + y) if __name__ == "__main__": import d...
5542fa9ae52f57efd86e56cfdfc297e3ef9b12eb
rk280392/study
/base_excpetion.py
330
3.953125
4
my_dict: dict = {'name': 'Bob', 'age': 33, 'language': 'Python'} my_list: list = [1, 2, 3, 4, 5] try: print(my_dict['name']) print(my_list[10]) except KeyError as error: print(f'Bad key: {error}') except IndexError: print(my_list[-1]) except BaseException as error: print(f"something went wrong: ...
de0fbc404e5981e9b5dbbe9d109e4a87d7bf5cc3
rk280392/study
/rand_number.py
290
4.03125
4
import random num = 0 num = random.randint(1,10) print(num) user_input = int(input('guess a number : ')) while user_input != num: print('try again') user_input = int(input('guess a number between 1,10 : ')) if user_input == num: print('correct the number is {}'.format(num))
34139d1c16b117de2ebec38068840d7095ea8ba3
rk280392/study
/check_vowels_consonents.py
184
4.15625
4
vowels = ['a', 'e', 'i', 'o', 'u'] types = ["Vowel" if i in vowels else "Consonant" for i in "hello"] types = ['Vowel' if i in vowels else "Consonents" for i in "hello"] print(types)
5d86b69836575d44dba007670014705322af10c8
rk280392/study
/number_reversal.py
134
3.765625
4
reverse = 0 remainder = 0 n = 1234 while n>0: remainder= n % 10 n = n//10 reverse = reverse*10+remainder print(reverse)
04c46dfd8cdbdd62f77fa6327ac8955148f0e33c
twinkle13531/from2019_to2020
/dotinstall/Argparse_py/argparse_0.py
1,335
3.5
4
# CLI...Command Line Interface # https://www.sejuku.net/blog/23647 # actionの項目を指定して、引数の指定によって実行結果が変わることを確認していきます。 # 引数の追加 parser.add_argument('-e', '--encode', help='select mode', action='store_true') parser.add_argument('-d', '--decode', help='select mode', action='store_true')...
1638acad57e08aa43f7cbbd98fbe2da7b132c54d
wafi543/CodingDojo-Bootcamp
/Python_Stack/_python/fundamentals/functions_intermediate_II.py
1,619
4.03125
4
# Update Values in Dictionaries and Lists x = [ [5,2,3], [10,8,9] ] students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'} ] sports_directory = { 'basketball' : ['Kobe', 'Jordan', 'James', 'Curry'], 'soccer' : ['Messi', 'Ronaldo', 'Rooney'] ...
e14dc4328e592c5bd83ad2e6d393177b78446b2a
rupali23-singh/dictionary
/interview.py
128
3.6875
4
name=input("enter any word") i=0 empty_dic={} while i<len(name): if empty_dic[name[i]]=1: i=i+1 print(empty_dic)
22ee80b577fb40bf226e0a7d502f6800878c56b9
rupali23-singh/dictionary
/dict_4question.py
140
3.6875
4
person={"name":"jack", "age":20, "gender":"organisation"} result=person["age"] x=person.get("gender") print(x) print(result)
01523a31c606de533d690cf350a0a7575ce94820
manupantha/Assignment2
/Function_Assignment/20.py
371
3.953125
4
l1 = input("Enter the elements of array 1 : ") s1 = l1.split(',') for i in range(len(s1)): s1[i] = int(s1[i]) print(f"array1 : {s1}") l = input("Enter the elements of array 2 : ") s2 = l.split(',') for i in range(len(s2)): s2[i] = int(s2[i]) print(f"array2 : {s2}") result = list(filter(lambda x: x in s1, s2)) ...
bc4e21c09982e7463d2d6a5c95365a92cbeb78b4
manupantha/Assignment2
/18.py
195
4.28125
4
lst = [] n = int(input("enter the length of the list: ")) for i in range(n): elements = int(input("element: ")) lst.append(elements) print(lst) print("the largest number is: ", max(lst))
4b779f6f93f19c9efc80e98f0cb3bc21346800d5
manupantha/Assignment2
/24.py
67
3.578125
4
l1 = [1, 2, 3, 4, 5] new_list = list(l1) print(l1) print(new_list)
982a56223417dfe16649dfcdb473d78d38d479fa
manupantha/Assignment2
/46.py
88
3.796875
4
t = input("enter the tuple elements: ") a = tuple(x for x in t.split(',')) print(len(a))
5626b9c833f28c9eb33a56e203017e8df780cb85
manupantha/Assignment2
/3.py
107
3.90625
4
str = input("enter the string") char = str[0] str = str.replace(char, '$') str = char + str[1:] print(str)
89677245f2f1b483e9c0f056dccee831ea035a3e
manupantha/Assignment2
/35.py
130
3.8125
4
my_dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4} for dictkeys, values in my_dict.items(): print(dictkeys, ' is ', my_dict[dictkeys])
0f8d8095ec6676d3e632ffcc88ccce6a201e0ee4
johanna1996/ds-quick-tips
/012_dockerizing_fastapi/container/train.py
855
3.59375
4
# Importing the required Python libraries import numpy as np import pandas as pd import pickle from sklearn import datasets from sklearn.linear_model import LogisticRegression # Loading the iris dataset from Scikit-Learn iris = datasets.load_iris() # Converting the iris dataset into a Pandas DataFrame df_iris = pd.Da...
0786184930cc73c2b9137846641464a8c22e89af
AnildoCaldasDev/Introduction_In_Python
/src/funcaZip.py
142
3.890625
4
lista1 = [1, 2, 3, 4, 5] lista2 = ["abacate","bola","cachorro","dinheiro","elefante"] for i, nome in zip(lista1, lista2): print(i, nome)
40cf9960f7d94a088185c14c4395e90f486ea113
narayan-ns26/Assignment
/map.py
724
3.921875
4
#importing libraries import pandas as pd import numpy as np #collecting dataset city_dataset = pd.read_csv("cities.csv") #slicing city name from the city_dataset city_column = city_dataset.name_of_city #slicing population from the city_dataset population_column = city_dataset.population_total #conca...
f8f0c0880108b4696dbf6c81a67bfc8c7c8e5263
Jhinv/JhinB2.github.io
/PITO/Exercises/Conditions_Loops/wordReversal.py
153
4.125
4
word = input("Write the word to reverse: ") for char in range(len(word)-1,-1,-1): #dont get the -1 print(word[char],end="") #and the end=""
922e9ef4910216c82bcf3beeebe7a2e97caa9928
martinmongi/thesis
/src/union_find.py
615
3.609375
4
class UnionFind: def __init__(self,s): self.parent = {k:k for k in s} self.size = {k:1 for k in s} def find(self,x): while self.parent[x] != x: x, self.parent[x] = self.parent[x], self.parent[self.parent[x]] return x def union(self,x,y): xr = self.fi...
95ed5275b262ca8e8e7c51bbdfe20f81ea990ff7
Cbernard23/Caesar-Cipher
/caesarCipher.py
1,063
4.09375
4
########################### ###Author: Chris Bernard### ########################### def readFile(): fileName = input("What is the name of the file that you would like to encrypt?") inFile = open(fileName, "r") inputString = inFile.read() inFile.close(); #print(inputString) return inputString def encrypt(iString...
3443f2c0e7178a31fd4f977c01bcac550d05565a
mycodebw/ele_python_study
/test/animal.py
989
3.75
4
class Animal(object): def run(self): print('Animal is running...') class Dog(Animal): def run(self): print('Dog is running...') class Cat(Animal): def run(self): print('Cat is running...') def run_twice(animal): animal.run() animal.run() a = Animal() d = Dog() c = Cat() ...
5d16eb97f8f9c840dfd99bf437ec3963f70b93f4
GabrielRockson1999/new-hello-world
/hello.py
56
3.5
4
print("Hello World") name = input( "Enter your name: ")
b9366279395c59b2bb3248f350ac93a370fb9571
Linerre/Automate_Boring
/Hands-on Python/isNum.py
1,331
3.8125
4
# 3.1.8.2. Is Number String Exercise # isNumberString.py def isNum(): ''' input: any legal python number: -1.5, .5, 1., -4 output: True or False depending on the input ''' testString = input('Please enter a number: ') if testString.startswith('-') or testString.find('.') != -1: newString = testString.replace...
92cc8d8b15f2074c1eaf9ca4d6d2c37f27b39f24
Linerre/Automate_Boring
/listfunction.py
112
3.609375
4
def separate(somelist): for i in somelist: i = i + ', ' separate(somelist) 'That\'s Alice\'s cat'
11d9cdbfc0e7070ac391a4040ffff1a8414340cd
mdvsh/python-stuff
/Algos/newtonraphson.py
756
3.5625
4
''' Newton-Raphson Method (Used this yesterday in my logistic regression code; found it out to be cool...) @author: Me ''' from sympy import diff from decimal import Decimal def NewtonRaphson(func, a): ''' Finds root from the point 'a' onwards''' while True: c = Decimal(a) - ( Decimal(eval(func)) / De...
2392192820c230c919b684c3d2d9ba92b8ca4d59
Gt-gih/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
594
4.25
4
#!/usr/bin/python3 """ Module with function that add two integers """ def add_integer(a, b=98): """Function that add two numbers Raises: TypeError: a parameter must be integer type TypeError: b parameter must be integer type Args: a (int): The first parameter. b (int):...
3b5f8c3e6f1bd65ba15d4af55840ef50afae0ffe
Gt-gih/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
362
4.1875
4
#!/usr/bin/python3 def uniq_add(my_list=[]): # new list new_list = [] for element in my_list: # checking element not exist in list 🔄 if element not in new_list: new_list.append(element) result = 0 # adding each element in list into result 🔴 for item in new_list: ...
813068b38978c4648067188bebff9792d8064afa
Gt-gih/holbertonschool-higher_level_programming
/0x0B-python-input_output/11-student.py
622
3.890625
4
#!/usr/bin/python3 """ Module that create a Student class """ class Student: """ Student class """ def __init__(self, first_name, last_name, age): """Init method Args: first_name (str): Student First name last_name (str): Student last name age (int)...
d2ef796c2e1a0be12fc0c3e1703ea7670d5c6d81
Gt-gih/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
293
3.953125
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): # Copy of list ✅ copy_list = my_list.copy() idx = 0 for i in copy_list: if i == search: # replace the element 🔁 copy_list[idx] = replace idx += 1 return copy_list
33d9a250dc5c0a149079862d49d79c268c8c3d0f
ian-richard/w3_weekend_hmwk
/tests/game_test.py
2,223
3.5625
4
import unittest from app.models.game import * from app.models.player import * from app.models.selection import Selection class GameTest(unittest.TestCase): def setUp(self): self.rock = Player("Bob", Selection.ROCK) self.paper = Player("Barbera", Selection.PAPER) self.scissors = Player("Ma...
a6c4493ba209ffd2471e5a5d955f51f77957ce8d
ugurcan-sonmez-95/HackerRank
/Algorithms/Warmup/Staircase/main.py
151
4
4
### Staircase - Solution def staircase(size): for i in range(size): print((size-i-1)*' ' + (i+1)*'#') size = int(input()) staircase(size)
91b1d47bc640f7be4863e20a0d02da032b15571d
ugurcan-sonmez-95/HackerRank
/Algorithms/Strings/Gemstones/main.py
196
3.65625
4
### Gemstones - Solution def gemstones(str_list): intersect = set.intersection(*str_list) print(len(intersect)) str_list = (set(input()) for _ in range(int(input()))) gemstones(str_list)
7efcc2fda5bfade6f553c9c2e0cd697721d342f0
ugurcan-sonmez-95/HackerRank
/Algorithms/Implementation/Modified_Kaprekar_Numbers/main.py
433
3.578125
4
### Modified Kaprekar Numbers - Solution from math import pow def kaprekarNumbers(p, q): count = 0 for num in range(p, q+1): squared, digits = num ** 2, pow(10, len(str(num))) n1, n2 = squared // digits, squared % digits if n1+n2 == num: print(num, end=' ') coun...
4851e2f3786c32ec56ef098c2b4bceed1801f74d
ugurcan-sonmez-95/HackerRank
/Algorithms/Strings/Making_Anagrams/main.py
273
3.921875
4
### Making Anagrams - Solution def makingAnagrams(s1, s2): for ch in s1: if ch in s2: s1 = s1.replace(ch, "", 1) s2 = s2.replace(ch, "", 1) count = len(s1) + len(s2) print(count) s1, s2 = input(), input() makingAnagrams(s1, s2)
e7aeb93c5816f97f0e0295aec8b2ece8d24ee547
ugurcan-sonmez-95/HackerRank
/Data_Structures/Linked_Lists/Delete_duplicate-value_nodes_from_a_sorted_linked_list/main.py
1,361
4.03125
4
### Delete duplicate-value nodes from a sorted linked list - Solution class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, node_d...
3aadbccdb77ed18d0db258ab4364fa9820f0363b
ugurcan-sonmez-95/HackerRank
/Algorithms/Strings/Game_of_Thrones_1/main.py
416
3.609375
4
### Game of Thrones - I - Solution def gameOfThrones(s): sorted_s = tuple(sorted(s)) count, oddCount = 1, 0 for i in range(len(sorted_s)-1): if sorted_s[i] == sorted_s[i+1]: count += 1 else: if count % 2 != 0: oddCount += 1 count = 1 i...
66ec69f6de86da90de2399dd7e59b419a404aaf0
ugurcan-sonmez-95/HackerRank
/Algorithms/Implementation/Viral_Advertising/main.py
294
3.84375
4
### Viral Advertising - Solution from math import floor def viralAdvertising(n): shared, likes, cumulative = 5, 2, 2 for _ in range(n-1): shared = likes * 3 likes = floor(shared/2) cumulative += likes print(cumulative) n = int(input()) viralAdvertising(n)
7043a470be61eaac28e943151b612f628baa23a7
ugurcan-sonmez-95/HackerRank
/Algorithms/Strings/Two_Characters/main.py
730
3.609375
4
### Two Characters - Solution def validate(check_valid): for i in range(len(check_valid)-1): if check_valid[i] == check_valid[i+1]: return False return True def main(s): max_size = 0 unique_chars = tuple(set(s)) list_of_uniques = tuple(unique_chars) for i in range(len(list_...
41bf798eddc02dc1d1da10c16ecc9025200c97f3
ugurcan-sonmez-95/HackerRank
/Algorithms/Greedy/Grid_Challenge/main.py
637
3.5625
4
### Grid Challenge - Solution def gridChallenge(grid): sorted_grid = [] for i in range(len(grid)): sorted_grid.append("".join(sorted(grid[i][0]))) for i in range(len(sorted_grid)-1): for j in range(i+1, len(sorted_grid)): for k in range(len(sorted_grid[0])): if s...
3878da598216ca6ef190b7eb4fb774918b1b27d7
ugurcan-sonmez-95/HackerRank
/Algorithms/Strings/Weighted_Uniform_Strings/main.py
535
3.578125
4
### Weighted Uniform Strings - Solution def weightedUniformStrings(s, query_count): total_weight = set() count = 1 for i in range(len(s)): weight = ord(s[i])-ord('a')+1 if (i+1 != len(s)) and (s[i] == s[i+1]): count += 1 else: count = 1 total_weight.a...
a85ce54ebcb27939f8dde8aac5f9d069dc7a4be3
wenhanglei/leetcode_python
/list/odd_even_linked_list.py
1,794
3.96875
4
""" Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. Note that the relative order inside both the even and odd groups should remain as ...
7987f3dc68eaa80f0695146b8b38bf7f04609f64
wenhanglei/leetcode_python
/array/coin_change.py
1,278
3.796875
4
""" You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume...
cf62b50d0b09a093a62302e1d6a02d91e327f93c
wenhanglei/leetcode_python
/graph/test_minimum_height_trees.py
246
3.5625
4
from minimum_height_trees import Solution s = Solution() # n = 6 # edges = [[3, 0], [3, 1], [3, 2], [3, 4], [5, 4]] n = 6 edges = [[0,1],[0,2],[0,3],[3,4],[4,5]] if __name__ == "__main__": r = s.findMinHeightTrees(n, edges) print(r)
03e1f5958982a01d6686cccce3d91f961e17afa1
HMurkute/PythonMatplotlib
/LearnMatplotlib_PieChart.py
637
3.78125
4
import matplotlib.pyplot as plt slices = [7, 2, 2, 13] activities = ['sleeping', 'eating', 'working', 'playing'] colors = ['c', 'm', 'r', 'b'] plt.pie( slices, labels=activities, colors=colors, startangle=90, shadow=True, # This make slices have shadows. explo...
fc89eebc2b54c0af29768a3a3d3a989534223fdf
werisonfernandes/python-samples
/Chapter03-Lists/List.py
319
3.71875
4
# lista preenchida estaticamente lista_estatica = ["xpto", True] # lista preenchida dinamicamente lista_dinamica = [input("Digite o usuário: "), bool(int(input("Está logado? ")))] # lista vazia lista_vazia = [] # lista nula list1 = None print(list1) if list1 is None: list1 = [10] list1.append(20) print(list1)
dc57ea9cb38c765ab8d35b6069a5acafdcbe3dd9
werisonfernandes/python-samples
/Chapter06_OperationalSystem/UserData.py
632
3.640625
4
# -*- encoding: utf-8 import getpass from datetime import datetime print("Usuário.......: ", getpass.getuser()) print("Data Completa.: ", datetime.now()) print("Dia...........: ", datetime.now().day) print("Mês...........: ", datetime.now().month) print("Ano...........: ", datetime.now().year) print("Hora..........: "...
09f4bfb3709cb12b36bca7e0a0f387470eec93d1
werisonfernandes/python-samples
/Chapter03-Functions/Main.py
465
3.5
4
from Chapter03_Functions.Functions import * # minhaLista = [] # print("Preenchendo") # preencherInventario(minhaLista) # print("Exibindo") # exibirInventario(minhaLista) # print("Pesquisando") # localizarPorNome(minhaLista) # print("Alterando") # depreciarPorNome(minhaLista, 20) # print("Excluindo") # print(excluirPorS...
e90400a9618e772a426a22e8bf2ad4accaae4011
gautamjagdhish/distributed-systems-assignment
/A5/170010031/hadoop_reg/mapper.py
494
3.5
4
import sys e = 2.718281828459045 weights = [ float(x) for x in sys.argv[1:] ] def gradient(line): X = line[:-1] y = line[-1] z = sum( x*w for x, w in zip(X,weights) ) s = 1. / (1. + e**-z) return [x * (s - y) for x in X] for line in sys.stdin: #parse floats line = list( map(float, ...
a21c42c4af16770b4bff688d2f36938197909196
mark-powell/advent-of-code-2020
/day3.py
668
3.71875
4
lines = open('day3_input.txt').readlines() mapHeight = len(lines) mapWidth = len(lines[0])-1 def hasTreeAt(x, y): actualX = x if x < mapWidth else x % mapWidth return lines[y][actualX:actualX+1] == '#' def getTreeHits(xVel, yVel): treeCount = 0 xPos = 0 for yPos in range(0, mapHeight, yVel): ...
a5fb1325c1e0b3b3534d90cf8f364c1377a0a19c
jaseela65/python_newPrgm
/quiz new.py
6,714
4.15625
4
print("..........Welcome To Python Quiz Competition.......\n") import re import sys def quiz_login_functtion(): name=input("Enter your name:") mail_id=input("Enter your Email-id :") mail_id_pattern='^\w+([\.-]?\w+)*@gmail.com' if(re.search(mail_id_pattern,mail_id)): return "---Login suce...
5396b8418cf7c78edbd8f764607077eb23fbf556
jaseela65/python_newPrgm
/create an empty list,set,tuple,dictionary.py
1,200
4.21875
4
# Python program to make an empty list a=[] print("values of a:",a) print(" \Type of a :",type(a)) print("Length of a :",len(a)) #output values of a: [] Type of a : <class 'list'> Length of a : 0 .......................................................... # Python program to make an empty tuple ...
67adc574f4774122d6c7aa0be2855ae1552156e2
jaseela65/python_newPrgm
/semprgm11111.py
1,701
4.0625
4
'''# while loops n = 5 while n > 0: n -= 1 print(n) #.......................... i = 1 while i < 6: print(i) i += 1 #................... # while... else i = 1 while i < 6: print(i) i += 1 else: print("i is no longer less than 6") #........................................
a9451647d52b543e46af69d80b96fae64001d908
ngchrbn/DS-Roadmap
/DS Code/1. Programming/Python/Data_Structures/Sets/example.py
321
4.09375
4
# Complexity: O(1) s1 = set([1, 2, 3, 4, 5]) # To add a new item s1.add(6) # To update it with another set s2 = {7, 8, 9} s1.update(s2) # To remove an item (throw an error if the item is not found) s1.remove(5) # or using 'discard(item)' => if the item is not found # it does nothing s1.discard(10) print(s1) ...