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
67e8ad3ba4ebb9e4b4d3156eac9e3392031feaf3
vinny0965/phyton
/1P/meuprojeto/Projeto Twiter/00.py
521
4.0625
4
"""1.Ao iniciar o programa, ler um conjunto de usuários (e seus dados) de um arquivo texto; 2. Ao iniciar o programa, ler um conjunto de postagens de cada usuário de diversos arquivos textos 3. Exibir os dados de um usuário qualquer 4. Escolher um usuário e mostrar suas postagens 5. Escolher um usuário e criar um novo ...
f351fdd81332d1dd5abffb8c63bdfa940f1cefc9
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Lista de Exercicios 5/Atividade4.py
292
3.8125
4
listaChar=[] consoantes=0 print("Informe os caracteres") for i i range(10): listaChar.append(input("Caracter" + str(i`+1) + ";\n")) char=listaChar[i] if(char not in ("a, e , i , o ,u")): if(char not ("a,e ,i , o , u")): consoantes +=1 print(consoantes)
9466334fc01f2c762888ab3f74b00612586bbb58
vinny0965/phyton
/1P/funçoes/01.py
174
3.78125
4
def nomeidade(): nome=input("digite um nome") idade=int(input("digite a idade")) print('Seu nome é',nome,'e sua idade é',idade,'anos') nomeidade() nomeidade()
7cebbba31f3a32ee6c504a2ccfda058a376b67ba
AsteriskVideogameGroup/BYOB
/src/foundation/geometrictools/Position.py
843
3.859375
4
class Position: ########## ATTRIBUTES DEFINITION ########## # _x : float # _y : float def __init__(self, x: float, y: float): self._x = x self._y = y def __hash__(self): return hash((self._x, self._y)) def __eq__(self, other): return (self._x, self._y) == (ot...
e3689f65f55577bc9d2bc2bddf80f2f0c7a38e79
astavonin/img-bot
/src/data_provider/tools.py
395
3.59375
4
def shorten_string(text, max_len=18): no_newline = text.replace('\n', ' ').replace('\r', '') postfix = "..." if len(no_newline) > max_len: return no_newline[:max_len - len(postfix)] + postfix else: return no_newline def get_or(data, key, default=None): if data is None: retu...
e6505215e5459bb97023426a8dd937e908bd198e
missulameghana/Intelligent-Traffic-Control-System
/single-junction.py
6,239
3.828125
4
import time import os from random import randint import RPi.GPIO as GPIO """ This is an example for four lanes at a single junction in which the traffic density is calculated using the ITLC algorithm and gives the number of vehicles passed over time. The variables in calculating time in the algorithm have taken to b...
656899048a8f819d0ecdaa9dda50db1f6077039c
pymzml/pymzML
/example_scripts/gzip_mzml.py
684
3.515625
4
#!/usr/bin/env python3 import sys import os from pymzml.utils.utils import index_gzip from pymzml.run import Reader def main(mzml_path, out_path): """ Create and indexed gzip mzML file from a plain mzML. Usage: python3 gzip_mzml.py <path/to/mzml> <path/to/output> """ with open(mzml_path) as fin:...
d09ab979cc16fc80b336933b3df9818cad9b4e47
samuel-walker/fme-desktop-data-integration
/edits.py
3,202
3.578125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Edits existing content by inserting or replacing # an include to edit or add content. Run after downloading warehousing # generateChapters.py. import os import time import json # Function to read edits from JSON and make them to Markdown files def editBook(edit_file = "edit...
fec34a4294c68ecbf04283915bf213c475cdbb56
Joevaen/Scikit-image_On_CT
/Draw/polygon.py
239
3.546875
4
# 生成多边形内部的点的坐标 from skimage.draw import polygon import numpy as np img = np.zeros((10, 10), dtype=np.uint8) r = np.array([1, 2, 8]) c = np.array([1, 7, 4]) rr, cc = polygon(r, c) img[rr, cc] = 1 print(img)
52331982218e1eaa82d28c4c854ca0d0d858cd2c
Joevaen/Scikit-image_On_CT
/Graph/route_through_array.py
841
3.5
4
# 路径查找算法 MCP和MCP_Geometric import numpy as np from skimage.graph import route_through_array image = np.array([[1, 3], [10, 12]]) print(image) # Forbid diagonal steps route_through_array(image, [0, 0], [1, 1], fully_connected=False) # Now allow diagonal steps: the path goes directly from start to end route_through_a...
27be22733ecbe880c2b4392751bfc6b4bb3023a8
Mhapankar123/Ongaku
/Backend/ongakubackend/test.py
126
3.671875
4
def main(n): for i in range(1,n): for j in range(n,i+1): print(i,end=" ") print("\r") main(5)
cb9e788d91c0ea6a39c01249af02a06bed472259
PedroPauloPP/SEII-PedroPaulo
/Semana03/prog05.py
438
3.828125
4
language = 'Python' if language == 'Python': print('Language is Python') elif language == 'Java' print('Language is Java') else: print("No match") user = 'Admin' logged_in = True if user == 'Admin' and logged_int: print('Admin Page') else: print("Bad Creds") a=[1,2,3] b=[1,2,3] print(id(a)) print(id(b)) p...
fe197515e67a74cf884a57bc73e76fac6d58a04b
Yun-Su/python
/PythonApplication1/PythonApplication1/不定长参数传递2.py
194
3.75
4
def f(a,b,*,c): #申明函数的时候 * 号可以单独出现 return a+b+c print(f(1,2,c=3))#出现 *号以后的参数必须用关键字方式传入否则报错 #计算出1+2+3的值
41e11c5c0c449e131862c3ec423137bd9ce619b8
Yun-Su/python
/PythonApplication1/PythonApplication1/匿名函数.py
679
4.1875
4
#python 使用 lambda 来创建匿名函数。 #所谓匿名,意即不再使用 def 语句这样标准的形式定义一个函数。 #lambda的主体是一个表达式,而不是一个代码块。 #仅仅能在lambda表达式中封装有限的逻辑进去。 #lambda 函数拥有自己的命名空间, #不能访问自己参数列表之外或全局命名空间里的参数。 #虽然lambda函数看起来只能写一行,却不等同于C或C++的内联函数, #后者的目的是调用小函数时不占用栈内存从而增加运行效率 sum = lambda a,b: a + b #调用sum() print ("相加后的值为 : ", sum( 10, 20 )) print ("相加后的值为 : ", sum( 2...
e658a46d2cc198fa8c9c1e261fef5536d3e824db
Yun-Su/python
/PythonApplication1/PythonApplication1/super().py
1,483
4
4
class A(): def go(self): print ("class A") class B(A): def go(self): super(B, self).go() print ("class B") class C(A): def go(self): super(C, self).go() print ("class C") class D(B,C):#从左到右执行,优先递归查找父类中的方法(如果有),并执行,然后递归查找父类中的属性,并执行,最后运行实例本身的属性和方法 def go(self): ...
108da285348c6ee92721cdc79e110430580135ad
Yun-Su/python
/PythonApplication1/PythonApplication1/类的方法重写.py
534
3.953125
4
class Parent: # 定义父类 def a(self): print ('调用a类方法') class Child(Parent): # 定义子类 def a(self): print ('调用a1类方法') c = Child() # 子类实例 #c.a()#访问实例中的方法时,实例对象会先在当前类中找相同名字的类的方法,如果没有找到,继续找父类中的类的方法. super(Child,c).a() #只有super(Child,self).a()才能简写成super().a() #用子类对象调用父类已被覆盖的方法 #super函数用于解决多...
ecb34713166971bb77565e6c32d530ed608f5601
Yun-Su/python
/PythonApplication1/PythonApplication1/递归函数.py
1,004
3.96875
4
def fact(n): if n==1: return 1 return n * fact(n - 1) print('10的阶乘是',fact(10)) #1*2*3*4*5.....*N #递归函数的优点是定义简单,逻辑清晰。 #理论上,所有的递归函数都可以写成循环的方式, #但循环的逻辑不如递归清晰。 #使用递归函数需要注意防止栈溢出。 #在计算机中,函数调用是通过栈(stack)这种数据结构实现的 #每当进入一个函数调用,栈就会加一层栈帧,每当函数返回,栈就会减一层栈帧。 #由于栈的大小不是无限的,所以,递归调用的次数过多,会导致栈溢出。 #尾递归方式解决栈溢出 def fact1(n):...
195947a73281bee74d614d7d5325fa764ad4339c
Yun-Su/python
/PythonApplication1/PythonApplication1/混合参数调用.py
522
3.703125
4
def f1(a, b, c=0, *args, **kw): print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw) def f2(a, b, c=0, *, d, **kw): print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw) print( f1(1, 2, c=3)) print(f1(1, 2, 3, 'a', 'b')) print(f1(1, 2, 3, 'a', 'b', x=99)) print(f2(1, 2, d=99, ext=None)) args =...
ae97c97d95d5a88caaae663d3325646394e7a7e5
pto8913/KyoPro
/ABC/ABC077/A.py
153
3.640625
4
# URL: https://atcoder.jp/contests/abc077/tasks/abc077_a S = input() T = input() ans = "NO" if(S[::-1] == T and S == T[::-1]): ans = "YES" print(ans)
dca568e7928c64859ab8f3c4dd38fbdb983fea37
pto8913/KyoPro
/ABC/ABC071/B.py
197
3.578125
4
# URL: https://atcoder.jp/contests/abc071/tasks/abc071_b S = input() ans = "abcdefghijklmnopqrstuvwxyz" for s in S: ans = ans.replace(s, "") if(ans == ""): print("None") else: print(ans[0])
042e7aaa30a53e6978096a665ebca1093e599b37
pto8913/KyoPro
/ABC/ABC079/A.py
156
3.578125
4
# URL: https://atcoder.jp/contests/abc079/tasks/abc079_a N = input() ans = "No" if(N[0] == N[1] == N[2] or N[1] == N[2] == N[3]): ans = "Yes" print(ans)
87a8b15856986ff8fc36de4c4665d8ade02bffdf
digvijaybhakuni/python-playground
/pyFunc/ch3-func-review.py
464
3.59375
4
def shut_down(s): if s == "yes": return "Shutting down" elif s == "no": return "Shutdown aborted" else: return "Sorry" print shut_down("no") """ Import and use """ from math import sqrt print sqrt(13689) """ Distance from zero if its int or float """ ...
7dfefde1793fb13e763b1149aa2415d73eb6e31f
digvijaybhakuni/python-playground
/pyBasic/ch1-none.py
692
3.90625
4
my_none = None print my_none my_string = "My Name is Digvijay" print my_string my_int = 1 print my_int my_float = 1.2 print my_float my_bool = True print my_bool my_var = """This is multiline string""" print my_var del my_var my_var = 1 print my_var # some operation of maths print 'Adding 2 + 2' pr...
e3ce4ff4dff53081b377cee46412ea42365651fa
digvijaybhakuni/python-playground
/pyListDictionaries/ch1-list.py
2,221
4.1875
4
numbers = [5, 6, 7, 8] print "Adding the numbers at indices 0 and 2..." print numbers[0] + numbers[2] print "Adding the numbers at indices 1 and 3..." print numbers[1] + numbers[3] """ Replace in Place """ zoo_animals = ["pangolin", "cassowary", "sloth", "tiger"] # Last night our zoo's sloth brutally...
fa1b6e9d0cea8485822701b4d8fdeb95838895ab
R151865/cloud_9_files
/testing/testing_submissions/testing_assignment_002/.~c9_invoke_HR3JAn.py
12,066
3.5
4
""" Truck test cases test to create truck with valid data test to for invalid data for truck #max cargo weight test max_cargo weight should not be negative or zero or none #cargo_weight test cargo_weight should be integer only not be negative or zero or none #load test load when after accleration test load when ...
011c3037bea8adc81ea91730c0641839e79cabbc
R151865/cloud_9_files
/mysite2/myapp/car.py
1,544
3.75
4
class Car: horn="Beep Beepk" def __init__(self,max_speed=None,acceleration=None,tyre_friction=None,color=None): self.color=color self.max_speed=max_speed self.acceleration=acceleration self.tyre_friction=tyre_friction self.current_speed=0 self.is_e...
8a8beb99e850d3796b68fc03c5c6212e26f46bec
brenchen27/PythonIntro
/Homework/Homework17.py
519
3.578125
4
class Videogames: def __init__(self, game, rating, console): self.game=game self.rating=rating self.console=console def familyFriendly(self): if self.rating=="e": print("True") elif self.rating=="e 10+": print("True") elif self.raating=="...
e8d9f50ff898c00c82b55c5b31962458a8cf4c74
IlyaRozumouski/EpamTasks
/Task_4/4.6.py
262
3.859375
4
instances = 0 class Singleton: def __init__(self): global instances if instances == 0: instances += 1 else: print("Object of this class is already existing") c = Singleton() f = Singleton()
d64730b632bdf00f0835f1b42a31536993b1a004
IlyaRozumouski/EpamTasks
/3.3.py
1,350
3.59375
4
def get_top_performers(file_path, number_of_top_students=5): with open(file_path) as file: s = file.read().split("\n") list = [] for elem in s: list.append(elem.split(",")) del list[0] i=0 out=[] while i<number_of_top_students: ...
3868c07526e9ad35eaa9ff1d0db82c80f41d8c3a
IlyaRozumouski/EpamTasks
/3.5.py
477
3.765625
4
from decorators import previous @previous def sum_list(*args): if type(args[0]) == str: result = str() for item in args: result += item print("The present result is: ", result) return result if type(args[0]) == int: result = 0 for item i...
c64a12edb4f8947b65c339126c266a235dd6261a
btjanaka/algorithm-problems
/hackerrank/pairwise-sum-and-divide.py
1,081
3.65625
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) pairwise-sum-and-divide # Title: Pairwise Sum and Divide # Link: https://www.hackerrank.com/challenges/pairwise-sum-and-divide/problem # Idea: Realize that floor((a+b)/ab) = floor((a+b)/ab) if a = 1 or b = 1, 1 if a # = b = 2, 0 otherwise. Thus, we only really ...
cd025796d5e0c9eb267ec5095b881b35528fa944
btjanaka/algorithm-problems
/hackerrank/two-characters.py
1,000
4.09375
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) two-characters # Title: Two Characters # Link: https://www.hackerrank.com/challenges/two-characters/problem # Idea: Brute force -- for all possible pairs of letters, check if we get a # string of alternating letters by only extracting those letters from `s`. # ...
dfd3418c2a6aa5f253473d8c0ddf9bd67f1dfee0
btjanaka/algorithm-problems
/kattis/inversefactorial.py
1,251
3.859375
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (Kattis) inversefactorial # Title: Inverse Factorial # Link: https://open.kattis.com/problems/inversefactorial # Idea: We can't calculate any factorials directly since n is so big, so we have # to instead look at the log. The number of digits in a number in base b is # ceil...
1a9d365fd929a1e1722e5d3c1c795478d8f3ec64
btjanaka/algorithm-problems
/hackerrank/non-divisible-subset.py
1,149
3.53125
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) non-divisible-subset # Title: Non-Divisible Subset # Link: https://www.hackerrank.com/challenges/non-divisible-subset/problem # Idea: The sum of a pair of numbers x1, x2 is divisible by k iff # (x1%k) + (x2%k) == k. Hence, if we have numbers that, when modded b...
26948c0f13ec5eaba3738f25e8ee7750bf460519
btjanaka/algorithm-problems
/kattis/gamedesign.py
2,235
3.578125
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (Kattis) gamedesign # Title: Game Design # Link: https://open.kattis.com/problems/gamedesign # Idea: To avoid ever having the ball hit another block inadvertently, maintain # several bounds telling how large the grid is so far. Then add a block for each # move, and make sur...
e156826f40473fc149bcc909a91528f46faa5044
btjanaka/algorithm-problems
/hackerrank/little-chammys-huge-donation.py
1,066
3.71875
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) little-chammys-huge-donation # Title: Little Ashish's Huge Donation # Link: https://www.hackerrank.com/challenges/little-chammys-huge-donation/problem # Idea: Since there is a closed formula we can use to calculate the sum of # squares from 1 to n, we can binar...
80caefb09d26b09568ff6b87591e41c3a53a32b2
btjanaka/algorithm-problems
/hackerrank/string-construction.py
472
3.734375
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) string-construction # Title: String Construction # Link: https://www.hackerrank.com/challenges/string-construction/problem # Idea: Since you can copy any substring at no charge, you can just copy single # letters that you previously purchased. Thus, the cost is...
8e793181b319d87503a977984f19dbd8c902b1df
btjanaka/algorithm-problems
/hackerrank/lazy-sorting.py
1,123
3.671875
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) lazy-sorting # Title: Lazy Sorting # Link: https://www.hackerrank.com/challenges/lazy-sorting/problem # Idea: Count the number of permutations q that are considered "sorted" by taking # the number of total permutations (n!) and dividing by the factorial of the ...
3e135957326756b7df5eb63c4bb41ae5d8143852
btjanaka/algorithm-problems
/hackerrank/sherlock-and-anagrams.py
965
4.09375
4
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) sherlock-and-anagrams # Title: Sherlock and Anagrams # Link: https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem # Idea: Find all substrings of the string, sort their characters, and put them # into a dictionary to see how many times each one oc...
52c0773a6f69824b10bfe91e91d21acb1154012b
pmcollins757/check_sudoku
/check_sudoku.py
2,091
4.1875
4
# -*- coding: utf-8 -*- """ Author: Patrick Collins """ # Sudoku puzzle solution checker that takes as input # a square list of lists representing an n x n # sudoku puzzle solution and returns the boolean # True if the input is a valid # sudoku square solution and returns the boolean False # otherwise. # A valid sudo...
0bb65d60dcfdcff0de9b2d8a70472fc2b5591b57
sasankyadavalli/leetcode
/leafSimilar_872.py
827
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: if root1 is None and root1 is None: return True ...
ac6c19991be95444cceada15dc59ba5db33074ad
sasankyadavalli/leetcode
/angleClock_1344.py
515
3.578125
4
class Solution: def angleClock(self, hour: int, minutes: int) -> float: m = minutes * 6 # Scale up minutes [0, 360): 360/60 = 6 h = (hour%12) * 30 # Hours to [0, 12), then scale up to [0, 360): 360/12 = 30 h += m / 12 # Adjust hour hand: full rotation of minute hand moves hour h...
01fb0dbcbef484595ae20c217b30918fa3a1a6a0
sasankyadavalli/leetcode
/nextLargerNodes_1019.py
604
3.796875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def nextLargerNodes(self, head: ListNode) -> List[int]: index = 0 ans = [] stack = [] while head is not None: ans.append(...
63d70bb8e92696c372990595ccb24332f56b42b5
sasankyadavalli/leetcode
/sortColors_75.py
422
3.703125
4
class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ res = [0]*3 for ele in nums: res[ele] += 1 index = 0 for i in range(0, len(res)): for _ in range(0, re...
52378c914d063567d3bb8e22f6295b236bbb7823
sasankyadavalli/leetcode
/flatten_430.py
795
3.875
4
""" # Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child """ class Solution: def flatten(self, head: 'Node') -> 'Node': if not head: return None def travel(node): ...
7ce2d6a59195cc271f3384e71d337523547d1cea
sasankyadavalli/leetcode
/rotateRight_61.py
965
3.8125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def rotateRight(self, head: ListNode, k: int) -> ListNode: if not head: return None if head.next == None: return head ...
7defd8a92031b57bc1d726b89e03ab4f9229a1c1
sasankyadavalli/leetcode
/pseudoPalindromicPaths_1457.py
1,165
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def pseudoPalindromicPaths (self, root: TreeNode) -> int: path = [] self.count = 0 d...
aed3974f15038defb877191c72e6e48fd6f0e129
sasankyadavalli/leetcode
/pathSum_113.py
744
3.609375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: if root is None: return [] self.result = [] ...
c9bb08c40e3198d1acd0f083bc9ac2b669c037a3
sasankyadavalli/leetcode
/isPrefixOfWord_1455.py
313
3.578125
4
class Solution: def isPrefixOfWord(self, sentence: str, searchWord: str) -> int: words = sentence.split() a = len(searchWord) print(words) for i in range(len(words)): if searchWord in words[i][0:a]: return i+1 break return -1
3bcfa78c189ee5d5db328b1e464bc3dfd2e8276b
Collinbarlow98/Assignments
/Calculate/FizzBuzz.py
446
4.03125
4
fizz = "Fizz" buzz = "Buzz" no_fizz_buzz = "Where is FizzBuzz?" def ask_user_input(): greet = "Hello please enter an integer!" print(greet) def fizz_buzz(): number = int(input("Number: ")) if (number % 3 == 0 and number % 5 == 0): print(fizz + buzz) elif (number % 5 == 0): print(bu...
0aec57f8df033b34f77e00d28b5ed568faa1f3aa
Bashirkazimi/BashirLearning
/src/resnext.py
5,996
3.546875
4
""" Tensorflow keras implementation of ResNext https://github.com/Bashirkazimi/BashirLearning Author: Bashir Kazimi """ import tensorflow as tf from tensorflow.keras import layers, Model, Sequential import numpy as np def conv_batch_relu(x, filters, kernel_size, strides, padding, bn=False, act=True): """ con...
82f710527bd72805587aae228c39695c46ebb218
ViVaHa/Leetcode
/HashTable/36.py
1,053
3.625
4
class Solution: def isValid(self,board,i,j,number): if board[i][j]==".": return True col=[0 for x in range(len(board))] for x in range(len(board)): col[x]=board[x][j] row=board[i] if row.count(number)>1 or col.count(number)>1: print(number)...
98cb1edcf281136820a1b24e20034bf7c0f9ecac
ViVaHa/Leetcode
/Strings/17.py
789
3.5625
4
class Solution(object): def backTrack(self,digits,index,kvmap,temp,ans): if index==len(digits): ans.append(temp) return items=kvmap[digits[index]] for item in items: self.backTrack(digits,index+1,kvmap,temp+item,ans) def letterCombinations...
4b4b378390b96e6daba17e900729a2480271df99
ViVaHa/Leetcode
/Array/289.py
1,210
3.546875
4
class Solution: def isSafe(self,x,y,board): if x<0 or y<0 or x>=len(board) or y>=len(board[0]): return False return True def getSum(self,board,x,y): direc_x=[-1, -1, -1, 0, 0, 1, 1, 1] direc_y=[-1, 0, 1, -1, 1, -1, 0, 1] s=0 for t in range(8): ...
aa622d38ab15bc2360e1b23bb954ff69dfbd1746
NatalliaValuika/Natallia_Python
/6.py
258
3.671875
4
import random n = int(input("ВВедите размер списка:\n")) A =[] for i in range(n): a = random.random(1,9) A.append(a) s = sum(A) l = len(A) a = s/l print("Элементы списка") for i in range(n): print(A[i])
ffbaf54f5cc1a439f6b85a157ae4e68607e188dd
flashjaysan/python-projects
/100-days-of-python-challenge/day-025/us-states-game-start/main.py
963
3.8125
4
import pandas import turtle from turtle import Screen, Turtle data = pandas.read_csv('50_states.csv') states = data['state'].to_list() screen = Screen() screen.title('U.S.A. States Game') usa_image = 'blank_states_img.gif' screen.addshape(usa_image) turtle.shape(usa_image) turtle = Turtle() turtle.hideturtle() turtl...
c78d47ae10e38de463b88acc9d4a4d4143a0b36c
flashjaysan/python-projects
/solid-and-design-patterns/creational-design-patterns/singleton/singleton.py
1,678
3.515625
4
class SingletonObject: class __SingletonObject: """ A file-based message logger with the following properties Attributes: file_name: a string representing the full path of the log file to which this logger will write its messages """ def __init__(self): ...
4c2b0a4f32a44f24f7ce0932c8b2170f590a5cee
flashjaysan/python-projects
/100-days-of-python-challenge/day-011/blackjack.py
3,631
3.828125
4
import random logo = """ .------. _ _ _ _ _ |A_ _ |. | | | | | | (_) | | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / | \/ | / \ | | |_) | | (_| | (__| ...
b6bc4069f879ce8deca0be6a42b039584ca8ed6e
flashjaysan/python-projects
/100-days-of-python-challenge/day-018/turtle-spirograph.py
388
3.734375
4
import turtle import random def random_color(): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) return r, g, b turtle.colormode(255) timmy = turtle.Turtle() timmy.speed(0) timmy.width(2) for i in range(90): timmy.color(random_color()) timmy.circle(100) ti...
8f435e25fd154890632b8e7119f821293b25b5c1
flashjaysan/python-projects
/100-days-of-python-challenge/day-022/pong.py
823
3.546875
4
from turtle import Screen from paddle import Paddle from ball import Ball from score import Score import time screen = Screen() screen.bgcolor('black') screen.setup(800, 600) screen.title('Pong') screen.tracer(0) r_paddle = Paddle((350, 0)) l_paddle = Paddle((-350, 0)) ball = Ball() score = Score() screen.listen() s...
09133dafa828fd01581fbfc7863a3e849d67fd15
flashjaysan/python-projects
/100-days-of-python-challenge/day-027/miles-km-converter.py
874
3.90625
4
import tkinter root = tkinter.Tk() root.title('Miles to Km Converter') root.minsize(width=640, height=360) root.config(padx=20, pady=20) miles_input = tkinter.StringVar() miles = tkinter.Entry(root, textvariable=miles_input) miles.grid(row=0, column=1) miles_label = tkinter.Label(root, text='miles') miles_label.grid...
a0a0ab90a2b4982fa26ee16590354279e8522067
marcotello/PythonPractices
/match_flower_name.py
785
3.734375
4
# Write your code here # HINT: create a dictionary from flowers.txt def create_flowers_dictionary(filename): flowers_dictionary = {} #use with to open the file filename #use the for loop syntax to process each line #and add the actor name to cast_list with open(filename, 'r') as f: for line...
60950955c5fcd3bc7a7410b78c3be383feb7e9ed
marcotello/PythonPractices
/Recursion/palindrome.py
1,696
4.4375
4
def reverse_string(input): """ Return reversed input string Examples: reverse_string("abc") returns "cba" Args: input(str): string to be reversed Returns: a string that is the reverse of input """ # TODO: Write your recursive string reverser solution here ...
a26b16019c44c2ff2ea44916bcc3fa66a62a826e
marcotello/PythonPractices
/P0/Task1.py
2,427
4.3125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 1: How many different telephone num...
2252d7e3ea30fe49636bbeeb50f6c3b3c7fdf80d
marcotello/PythonPractices
/DataStrucutures/Linked_lists/flattening_linked_list.py
1,622
4.125
4
# Use this class as the nodes in your linked list class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class LinkedList: def __init__(self, head): self.head = head def append(self, value):...
2146ad3ffe83f49bf1886173c85d656c41509ff0
elementalsouls/Cyanide-Framework_v0.2
/tola_atom/encoders/sha512_file.py
293
3.828125
4
import hashlib def encrypt_string(hash_string): sha_signature = \ hashlib.sha512(hash_string.encode()).hexdigest() return sha_signature hash_string = input("Enter a String: ") sha_signature = encrypt_string(hash_string) print("Hash Equivalent : ", end ="") print(sha_signature)
bcfb4e22fb9a8a4463d45ab977b15c99e6b3385e
mehdi-ahmed/using_python_with_databases
/week1/inheritance.py
717
3.828125
4
class PartyAnimal: x = 0 name = "" def __init__(self, name): self.name = name print(self.name, 'I am constructed') def party(self): self.x = self.x + 1 print(self.name, 'party count', self.x) class FootballFan(PartyAnimal): # Extends PartyAnimal points = 0 d...
5f4361e2e64302a3df3caca82e639fafe972bc53
xllDark-Profet/Analisis-Numerico
/Talleres/Corte 1/Ejercicio horner python/Ejercicio horner python/Ejercicio_horner_python.py
253
3.609375
4
#Desarrollado por Alejo, Cris y Andy <3 valorX=int(input("Ingrese el valor de X: ")) coeficientes=[4,3,3,0,2]; resultado=0; CLC=len(coeficientes) for i in range(0,CLC): resultado= resultado * valorX + coeficientes[i] print("Resultado:"+str(resultado))
890cd08cd010b3e6f31327655cba102f1f1c06ad
xllDark-Profet/Analisis-Numerico
/Codigos/INTERPOLACION/biseccion.py
293
3.625
4
from math import* def biseccion(f, a, b, e): while b-a>=e: c=(a+b)/2 if f(c)==0: return c else: if f(a)*f(c)>0: a=c else: b=c return c def f(x): return pi c=biseccion(f, 0, 2, 0.0001) print(c)
1543e31bbe36f352dd18b284bd9fc688332e9486
LucasBeeman/Whats-for-dinner
/dinner.py
1,446
4.40625
4
import random ethnicity = [0, 1, 2, 3] type_choice = -1 user_choice = input("Which ethnnic resturaunt would you like to eat at? Italian(1), Indian(2), Chinese(3), Middle Eastern(4), Don't know(5)") #if the user pick I dont know, the code will pick one for them through randomness if user_choice.strip() == "5": ...
ca9cc1184c70c9089eac0a5b6d3f18c81eb196c8
jiangxiulong2021/DataEngine
/L1_A1.py
292
3.703125
4
""" 黑马训练营第一节课 Action1:求2+4+6+8+.。。+100的求和 """ # 变量初始化 count = 0 # for循环求和,利用range函数取[2~102)的偶数,+2 for i in range(2, 102, +2): count = count + i # 打印计算结果 print("SUM(2+4+6+8+...+100)=", count)
9b17b50ce4409e7901bf3a783fac8a5007833321
jianminwei/pycharm_prj1
/dataquest_4_2.py
535
3.515625
4
# this script is to print out nfl_suspensions_data.csv file to the output # and we can then copy paste from the output to a notepad. # This is indirectly download a csv file from the training class. import csv f = open("C:\\dev\\python\\nfl_suspensions_data.csv", 'r') csvreader = csv.reader(f) nfl_suspensions = list(...
b4e37c88fdebf1a03a74ba262cb28062c7ad9c0a
jianminwei/pycharm_prj1
/dataquest_1_8.py
1,143
3.53125
4
import csv ############################# #Adding a __str__ method # # Every class should define a __str__() method as a good practice class Dataset: def __init__(self, data): self.header = data[0] self.data = data[1:] def __str__(self): data_string = self.data[:10] return str(...
d2972fa663b481612b80258f4c515f52604a93a2
jianminwei/pycharm_prj1
/dataquest_1_6.py
941
3.640625
4
import csv #Adding a column method class Dataset: def __init__(self, data): self.header = data[0] self.data = data[1:] def print_data(self, row): # New method **remember to add self**. print(self.data[1:1+1]) def print_header(self): # New method **remember to add sel...
a07e53d9fd84afd15a846590a54d7988918e8910
jianminwei/pycharm_prj1
/dataquest_4_5.py
762
3.71875
4
################################## # Define a new class: Suspension # A Suspension instance represent a row from nfl_suspensions import csv f = open("C:\\dev\\python\\nfl_suspensions_data.csv", 'r') csvreader = csv.reader(f) nfl_suspensions = list(csvreader) nfl_suspensions = nfl_suspensions[1:] ######## training c...
b3e448abd629f888c8fe4a2d05b3d1db594d1e09
aulb/ToAsk
/Technical Questions/217 - Contains Duplicate Array.py
359
3.59375
4
from collections import Counter class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ counter = Counter() for num in nums: count = counter.get(num, 0) if count > 0: return True counter...
2e0013802194373ba713edb929f64b4edfa31ae8
aulb/ToAsk
/Technical Questions/027 - Remove Element Array.py
573
3.671875
4
# https://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range # In place # Shuffle around doesn't work because you don't exactly know where to shuffle to # def removeElement(nums, val): # for i in range(len(nums) - 1, -1, -1): # # Strategies: # # Iterate backwards # if nums[i] == val: # ...
175e8663587f7b87ccae973fcd160745fcdf147b
aulb/ToAsk
/Technical Questions/079 - Word Search.py
1,342
3.90625
4
class Solution: def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ """ Try to make this iterative to really learn. """ if not board or not word: return False # DFS setup stac...
d88e119552c9fb0baf2ca55339dbb93dc9d36bb3
aulb/ToAsk
/Technical Questions/029 - Divide.py
728
4.03125
4
def divide(dividend, divisor): # Negative integers if divisor == 0: return 0 divisorp = abs(divisor) dividendp = abs(dividend) # Cases for negative and positive neg = (dividend < 0 and divisor > 0) or (divisor < 0 and dividend > 0) r = 0 while dividendp - divisorp >= 0: dividendp = dividendp - divisorp ...
28fbc765ca9bcfd90305280b7b28d68acdebf035
aulb/ToAsk
/Technical Questions/003 - Length Longest Substring.py
872
3.546875
4
""" https://leetcode.com/problems/longest-substring-without-repeating-characters/ 8:02 - 8:40 """ class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ # Corner case, length is 1 if len(s) == 1: return 1 # G...
fd28160b1b877d07d409a9c38fbe3df3761add01
aulb/ToAsk
/Technical Questions/141 - LL Cycle.py
933
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 hasCycle(self, head): """ :type head: ListNode :rtype: bool """ if not head: return False # Rabbi...
517f97fba66cbf66920b469fd03a16b7270df54a
aulb/ToAsk
/Technical Questions/538 - BST to Greater Tree.py
755
3.84375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def change_sum(self, root, add_by): if not root: return add_by right_value = self.change_sum(root.right, ...
b6c1dff3e2502fb89a62913c2be9112786318181
aulb/ToAsk
/Technical Questions/048 - Rotate Image.py
928
3.5
4
def transpose(matrix): n = len(matrix) for i in range(n): for j in range(i + 1, n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] def flip_y(matrix): n = len(matrix) for i in range(n): for j in range(n // 2): matrix[i][j], matrix[i][~j] = matrix[i][~j], matrix[i][j] class Solution(object): ...
919a6c59373e5dc4c597a778cf95a2009a87f9c8
aulb/ToAsk
/Technical Questions/155 - Min Stack.py
1,870
3.9375
4
class StackItem(object): def __init__(self, x, minimum=None): """ initialize your data structure here. """ self.value = x # 0 is falsey in Python self.minimum = minimum if minimum != None else x def __repr__(self): return 'val: {}, min: {}'.format(self....
1ac3f414211cd2ad4be8a86b16f4ba645ede1674
aulb/ToAsk
/Technical Questions/miscellaneous/vertical_print_bt.py
299
3.59375
4
# TODO: BST today def vertical_print(node): levels = {} def add_level(node, position): if not node: return level = levels.get(position, []) level.append(node.val) add_level(node.left, position - 1) add_level(node.right, position + 1) add_level(node, 0) return levels print(levels)
7eef879dd0e65487750e3329a805f667b05f5c47
aulb/ToAsk
/Technical Questions/102 - Print Level Order.py
1,056
3.703125
4
def levelOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ # Node queue holds all the nodes on the same level node_queue = [root] # Result holds results for each level [[1],[2,3],[4]] result = [] while node_queue: # Container for current level results ...
18a174f1d2de0da1943caa7a3883dce38023089c
aulb/ToAsk
/Technical Questions/094 - BT Inorder Iterative.py
1,923
3.78125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution(object): def inorderTraversal(self, root): """ :type root: TreeNode :rtype: L...
f0cb86df5faae366e37db5a389ab1e1b61ef0ee8
aulb/ToAsk
/Interview Preparation 2/shunting_yard.py
821
3.921875
4
from collections import deque def is_left_associative(): pass def rank(): return 1 def compare_operator(a, b): pass def get_rid_of_spaces(expression): return expression.replace(' ', '') def check_validity(expression): pass def calculate(expression): # Work with clean expression expression = get_rid_of_space...
c14d15f8cb2d935bc0393eaabbf2c29fa9724006
aulb/ToAsk
/Technical Questions/112 - Has Path Sum.py
782
3.921875
4
# This solution is for if there is any path that results in sum # # Base case root is nothing but theres still sum to do # if root == None: # return False # # Otherwise # remainder = sum - root.val # if remainder == 0: return True # elif remainder < 0: return False # else: # return self.hasPathSum(root.left, r...
96fc4fb80d4b4e66559750920013c7f40dd75778
aulb/ToAsk
/Interview Preparation 1/215 - Find Kth Largest.py
2,239
3.5
4
# O(n) time, quick selection def findKthLargest(self, nums, k): # convert the kth largest to smallest return self.findKthSmallest(nums, len(nums)+1-k) def findKthSmallest(self, nums, k): if nums: pos = self.partition(nums, 0, len(nums)-1) if k > pos+1: return self.findKthSma...
37e38ee8f79063c4625aa4226c4cde9b8f847554
lukasHD/adventofcode2019
/Day1/day1.py
1,936
4.09375
4
# https://adventofcode.com/2019/day/1 def calcFuel(mass): fuel = int(mass / 3) - 2 return max(0, fuel) # def calcFullFuel(mass): # fuel = calcFuel(mass) # if fuel < 0: # fuel = 0 # print("For mass {} required Fuel is {}".format(mass, fuel)) # else: # additionalFuel = calcFullFu...
8b16e7a380af251d5ae1ba33c588b476e0d1ed65
lukasHD/adventofcode2019
/Day13/day11.py
11,922
4.125
4
# --- Day 11: Space Police --- # You'll need to build a new emergency hull painting robot. The robot needs to be able to move around on the grid of square panels on the side of your ship, detect the color of its current panel, and paint its current panel black or white. (All of the panels are currently black.) # The ...
b8863c7035f733688c1202def09bde7fa2b1d3e2
shreyasvinaya/School_assignments
/assign_7/stacks/twio.py
773
3.921875
4
#2. Import the file into another program, send a string in the form of a stack. Reverse the string using pop. #3. Using the same file convert a decimal number into its binary equivalent using the stack functionality import mods as m #s = 'hellooo' def rev(s): st = [] top = 0 for i in s: top = m.push(...
7d678a1e3751cda8115d6682d5162c9351d799c2
shreyasvinaya/School_assignments
/running.py
380
3.609375
4
from functions import * ''' a=testing1(100,25) print(a) print(multiply(4,5,6)) a=input('enter a sentence') print(cap_and_rev(a)) print(no_of(a)) arr = eval(input('ENTER A LIST')) insertionSort(arr) print ("Sorted list is:",arr) a=int(input('enter a number')) n=int(input('enter its exponent')) print(p...
edaf50bbf4f019d71b1ae5cbb5c672cdab00dd82
shreyasvinaya/School_assignments
/revision/pythogorean.py
451
3.515625
4
#pythogorean triplets import math a=int(input('enter the number till which you want pythogorean triplets')) l=[] for x in range(1,a): pass for y in range(1,x): pass m = ((x**2) + (y**2))**(1/2) if int(m)==m: pass l.append([x,y,m]) '''for d in range(len(l)): pass for s in range(len(l)):...
a0082ee6edebb654455d932ce86ceb0046e6d113
electronicstrivia/arduino-hand-gesture-computer
/modified py code arduino.py
1,170
3.734375
4
# gesture control python program for controlling certain functions in windows pc import serial # add Serial library for serial communication import pyautogui # add pyautogui library for programmatically controlling the mouse and keyboard. A...
e73c490d9e8c12c8a6bcbefb8e6f66a9da835124
DTRademaker/DL_tutorials_2020
/20200513_cnn_week5/hw/DM/answers_1-3.py
3,495
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 1 14:31:58 2020 @author: dario """ import torch import torch.nn as nn import torch.nn.functional as F import torchvision class Net(nn.Module): def __init__(self): super(Net, self).__init__() # 1 input feature, 8 output feature...
6f4b4b8e1122c06045b3eb9c3b9cca80c8d5adcd
muthueee/python-programming
/beginner level/odd or even no.py
125
3.84375
4
num = int(input()) for n in range(10000): if (num % 2) == 0: print "is Even" break else: print " is Odd" break
896315757c4d7c1aad82092980c75daecee6fa48
callnileshmahajan/PythonDev
/continuebreak.py
250
3.609375
4
shopping_list = ["milk", "pasta", "eggs", "spam", "bread", "rice"] for item in shopping_list: if item == "spam": continue print("Buy " + item) for i in range(0, 100, 7): if i != 0 and i % 11 == 0: break print(i)
5f4a5e55d321bc8de2fd1061e086cc830fb9a552
MarcinRe/Rozdzialy
/Rozdzialy/4/4.7.py
624
3.515625
4
# -*- coding: utf-8 -*- print"---------------3.27----------------" li=[1,9,8,4] print [element*2 for element in li] print li li= [elem*2 for elem in li] print li print"---------------3.28----------------" params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"} print params.keys() print params.va...