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
4e434ae94cb4983728930ded459f06e3226fe483
priscila-rocha/Python
/Curso em video/ex025.py
133
4.03125
4
nome = str(input('Digite o seu nome completo: ')).upper().strip() print('O nome digitado tem Silva? {}'.format('SILVA' in nome))
2f6aac8f2c4e972c3a3f2b2b5303702c0a0dc8a6
SaranshSinha/1BM17CS089
/1b.py
324
3.78125
4
def fib(n): i=0 j=1 if n==1: print("[0]") elif n==2: print("[0,1]") else: print("0") print("1") for c in range(n-2): s=i+j print(s) i=j j=s x=int(input("enter the number of fib to generate")) fib(...
1cdec1b8e8ee66f79dcbd800c93a1db425569566
jas-nat/MNIST-pytorch
/practice.py
3,715
3.71875
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 10 23:19:06 2019 @author: Jason Nataprawira CNN practice using MNIMS (numbers) dataset """ import torch import torch.nn.functional as F from torch import nn, optim import torchvision from torchvision import datasets, transforms import matplotlib.pyplot as plt...
97c42bc14b0c1872b3d0d131c9f2bb2fda97d5ca
PriyanK7n/StocKPrd
/BUILding_RNN.py
4,237
3.609375
4
# -*- coding: utf-8 -*- # Recurrent Neural Network # Part 1 - Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the training set dataset_train = pd.read_csv('Google_Stock_Price_Train.csv') training_set = dataset_train.iloc[:,[1] ].value...
d3f50c7eb1879b44725f99ade6ac3b8bb791abbf
simranbarve/Stack
/Stack.py
1,319
4.03125
4
class Stack: def __init__(self, stack_length = 5): #attributes self.stack_length = stack_length self.stack = [None] * stack_length self.pointer = -1 def isFull(self): if self.pointer == (self.stack_length - 1): return True return False def isEmpt...
d04f228272990514374009476b16ef91610fa0f7
AbhishekVel/LibraryManagement
/library.py
3,693
3.96875
4
import sys from .user import User from .book import Book list_of_books = [] list_of_users = [] def createUser(): username = input("Enter in your desired username.\n") list_of_users.insert(0, User(username)) def addBook(): title = input("Enter the title of the book.\n") text = input("Enter the text of the book.\n...
7c98019039b87698910b399c8004d1b7c3ca5abf
kathirraja/sample-python-programs
/mystr.py
171
3.59375
4
class myst(): name = ''; ins= ['kathir'] ins = myst() ins[0].name = 'kathir' ins.append('raja') ins[1].name = 'raja' print ins[0].name print ins[1].name
d5f2013cf74e758202243484f87650ed00c7e85c
rafia37/ASTR400B_Bushra
/HW4/ReadFile.py
950
3.640625
4
import numpy as np import astropy.units as u def Read(filename): """ A function that generates, time, number of particles and particle information from a given file. PARAMETERS filename : Name of the file to generate information from. Type = str Returns time : Time in 10 Myr. Type = ...
99c13849fa490073cad4fad2c44c0c6898efdede
josetom/Geeks
/project-euler/19-counting_sundays.py
155
3.828125
4
import calendar s = 0 for year in range(1901, 2001): for month in range(1, 13): if(calendar.weekday(year, month, 1) == 6): s = s + 1 print(s)
ccc8e763807b7a1a7a94bcaf6bbcb05f2056e8e0
rrajvanshi1947/python
/dataStructuresFall/intToBin.py
1,009
3.703125
4
import math #Nice try bro! # def intToBin(number): # if type(number) == float or number <= 0: # return 'Error' # tempNumber = number # binaryNumber = '' # firstPower = math.floor(math.log2(tempNumber)) # print(firstPower) # firstPowerString = str(math.floor(math.log2(tempNumber))) ...
5a2218f6db14f35c77f731ed14970dd186fce12e
rrajvanshi1947/python
/dataStructuresFall/binaryTree.py
2,747
3.890625
4
class Node(): def __init__(self, value): self.data = value self.left = None self.right = None class BinaryTree(): def __init__(self, rootValue): self.root = Node(rootValue) def preorder(self, node): if node: print(node.data, end="-") self.pre...
6e92d5e689efec042480060cc90643a67c8efe00
rrajvanshi1947/python
/edabit/squarePatch.py
197
3.65625
4
def square_patch(n): # if n == 0: # return [] return [[n]*n for i in range(n)] # def square_patch(n): # return [[n]*n]*n print(square_patch(0)) # a = [1,2] # print(type(a)) print(str(True))
2d8653aa2ae5a8417a1dda8d1cd22edaf4b95bc2
rrajvanshi1947/python
/Basics/enumerate.py
692
3.5
4
arr = ['su', 'bm', 'me', 'ta', 'gm', 'vw', 'fe', 'ch'] # for item in enumerate(arr): # print(item) # for item in enumerate(arr, 4): # print(item) for index, item in enumerate(arr): print("Index: {}, Item: {}".format(index, item)) dic = dict(enumerate(arr)) print(dic) a = [(i, j) for i, j in enumerate(d...
c855e1e63eed03dfec6f6396475f1e941c2e9d7b
rrajvanshi1947/python
/Basics/listComprehension.py
146
3.65625
4
a = [value**2%5 for value in range(1, 10)] print(a) b = [2,3,4] c = [5,6,7] e = [8,9,10] d = [(a,b,f) for a in b for b in c for f in e] print(d)
6a8ec0788897a95997f84fe6796435b5e8f982ac
rrajvanshi1947/python
/edabit/evenOdd.py
284
3.875
4
def even_odd_transform(lst, n): # for value in lst: # if value%2 == 0: # value -= 2*n # continue # value += 2*n # return lst lst = [ value + 2*n if value%2 == 1 else value - 2*n for value in lst ] return lst print(even_odd_transform([1,4,3,6,7], 2)) arr = [1,4,3,6,7]
de50d9e614e8f2233ff1767df675395f09c8ba2e
rrajvanshi1947/python
/leetcode/strings/longCommonPrefix.py
1,312
3.546875
4
# class Solution(object): # def longestCommonPrefix(self, strs): # """ # :type strs: List[str] # :rtype: str # """ # if len(strs) == 0: # return '' # res = '' # strs = sorted(strs) # for i in strs[0]: # if strs[-1].startswith(r...
012940ac5deab7071a4da8e4928cf7a7e7e43261
rrajvanshi1947/python
/Basics/if_elif_for.py
447
4.09375
4
name = "Roopam" if name is "Roopam": print("Hey Roopam! How's the Python learning coming along?") print("What are your plans for tomorrow?") elif name is "Shubham": print("What's up Shubham?") else: print("Wrong guy") print(len(name)) names = ('Roopam', 'Anshul', 'Kunwar', 'Suri', 'Ravi') #This i...
d171e6f722aba2d703a266fcce762f51a6b859db
rrajvanshi1947/python
/interviews/robinWhiteboard.py
1,878
3.796875
4
import math def maxRepeat(nums): # This is to find number which exists more than 50% of times num, count = nums[0], 1 for i in range(1, len(nums)): if count == 0: num = nums[i] count = 1 elif nums[i] == num: count += 1 else: count -=...
de5ea80b0e525471791d1de75bd07b54dcb64647
rrajvanshi1947/python
/Data Structures/linkedlist.py
4,157
4
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if self.head is None: self.head = new_node return curr_node ...
040d326c86197593d58e20f9937c1fbed437729f
distoration/AutoDisker-0.1v-PYTHON
/AutoDisker 0.1v python/Folders/make_folders.py
629
3.9375
4
import os, sys def makefolders(): path = 'C:\\our_directories' x = int(input('number of folders you need: ')) for i in range (1,x+1): os.chdir(path) Newfolder = 'hard_drive-' + str(i) try: if not os.path.exists(Newfolder): os.makedirs(Newfolde...
9a02e277ab565469ef0d3b768b7c9a0c053c2545
JamesRoth/Precalc-Programming-Project
/randomMulti.py
554
4.125
4
#James Roth #1/31/19 #randomMulti.py - random multiplication problems from random import randint correctAns = 0 while correctAns < 5: #loop until 5 correct answers are guessed #RNG num1 = randint(1,10) num2 = randint(1,10) #correct answer ans = num1*num2 #asking the user to give the answe...
f20345615710588bba8603fb8b2e23656fc562ff
vinaysawant/Sliding-Window-Minimum
/sliding_window_minimum.py
1,104
4.0625
4
#!/usr/bin/env python '''Implementation of Sliding Window Minimum Algorithm. This module contains one function `sliding_window_minimum`. See http://people.cs.uct.ac.za/~ksmith/articles/sliding_window_minimum.html for a longer explanation of the algorithm.''' from collections import deque __author__ = "Keegan Carrut...
2bd4e0106ec77db30f15c57e5e3977d00b05a88e
WoodlinSmith/T34Emulator
/src/system.py
84,084
3.75
4
import utils from CurrentStatus import CurrentStatus class system: def __init__ (self): ''' @author Woodlin Smith @param self - the emulator object @description The constructor builds the core of the emulator. It initializes the registers and main memory, and sets the base ...
3fbbb99ca32b48e0a431920def248cd7b0324456
wahroden/Casimir-Programming
/circle.py
505
3.625
4
import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt #import scipy as sc #import numpy as np print("Enter the coordinates of the circle and the radius within (0 to 10) individually") x=float(input()) y=float(input()) radius=float(input()) circle = plt.Circle((x,y),radius) #circle = plt.Circle((0.1,0...
981fee829cbcbe5d9c18dff67b740adcda9c9bcc
rajat-rg/DSA-450-LB
/array_matrix_searchingSorting/count_say.py
541
3.65625
4
def countSay(n): if n==1: return "1." if n==2: return "11." if n>2: new_str = "" stri = countSay(n-1) i=1 count=1 curr= stri[1] while curr != '.': prev = stri[i-1] curr=stri[i] if(curr == prev): ...
a93cb460d4a6a3864d9b742d5f12e126b84806b8
JoshEthan/GoldPair
/stockList.py
737
3.546875
4
from stock import Stock class StockList: def __init__(self, symbols_file): self.symbols_file = symbols_file self.get_list_of_symbols() self.get_list_of_stocks() self.list_of_stock = self.get_list_of_stocks() ''' GET LIST OF SYMBOLS: Will get a list of symbols ''...
0b6a822b74baeccb56e2921e0057d744cc65f1ec
Python-Repository-Hub/the-art-of-coding
/Level.1/Step.01/1.1_Sum-of-Integers.1.py
143
3.953125
4
def sum_of_integers(n): s = 0 for i in range(1, n + 1): s += i return s n = int(input()) s = sum_of_integers(n) print(s)
ff637a95d77070a50016d4738754c997e330e107
ljx407/helloPython
/learnPythonTheHardWay/ex15.py
744
3.890625
4
# import a module named argv that you can use the function below from sys import argv # take the parameter that you input in the shell to varaibles script, filename = argv # open a file specified by the variable of filename, then assign it to a variable txt = open(filename) # print the filename print "Here's your fi...
7d6a996d7d0186cf91e7a809f77caa65db0801e9
xelop/Compilador-mypy
/Ejemplos_Parser/InputPrint.py
668
3.921875
4
#Esta es una prueba para verificar print e input # OJO no hay funciones ni variables input() #no trae parentesis input() #se espera que lo acepte input(123,2) #se espera error, pues no se acepta expresion entre() input(x+x) #se espera error input("digite un valor", x) #...
43bd8d984f4637c2c06a1ced39f930585b72a3f9
ruchir-hj/fun-coding
/leetcode solutions/Python/Maximum Depth of Binary Tree/maxDepthOfBinaryTree.py
483
3.5625
4
class TreeNode: def __init__(self): self.val = x self.left = None self.right = None class Solution(Object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ return self.maxDepthHelper(root, 0) def maxDepthHelper(self, node...
71d409e60044a0d26e5828ec680032bed0ab2a9b
LGK-GoG/game-of-greed
/game_of_greed/banker.py
663
3.890625
4
class Banker: def __init__(self): self = self def shelf(self, points_to_add): """ Creates a 'shelf' to temporarily store 'unbanked' points. Input is the amount of points (integer) to add to shelf. """ pass def bank(self, points_from_shelf): """ ...
361fa7449fe213b4a988d1ed4dc90318453a48db
jleuschen17/6.0002
/HW3/tests.py
13,760
4.28125
4
# -*- coding: utf-8 -*- # Problem Set 3: Simulating robots # Name: # Collaborators (discussion): # Time: import math import random import ps3_visualize import pylab # For python 2.7: from ps3_verify_movement27 import test_robot_movement # === Provided class Position class Position(object): """ A Position r...
2112945f67738daae21ebba1267c99d30fb647ff
gabrielaraujo3/exercicios-python
/exercicios/ex7COMNOVO.FORMAT.py
119
3.828125
4
n1 = float(input('Primeira nota: ')) n2 = float(input('Segunda nota: ')) m = (n1+n2)/2 print(f'A nota média é {m}.')
50a6909b1e9834968d50ae803ffe7dfe98ec6f08
gabrielaraujo3/exercicios-python
/exercicios/ex24.py
90
3.90625
4
n = str(input('Digite o nome de uma cidade: ')).strip() print(n[0:5].upper() == 'SANTO')
e5a49ba4850bf82b24690b9b08d7469d89ca3457
gabrielaraujo3/exercicios-python
/exercicios/ex49a.py
129
3.75
4
n1 = int(input('Digite um número e te mostro a tabuada dele ;): ')) for c in range(1, 11): print(f'{n1} x {c:2} = {n1*c}')
e0260afa372ff9c5a9ae310338c3ae827a19ae37
gabrielaraujo3/exercicios-python
/exercicios/ex12.py
203
3.515625
4
n1 = float(input('Valor do produto (R$): ')) n2 = float(input('Desconto em porcentagem (%): ')) d = n2/100 d1 = n1*d nv = n1-d1 print('Novo valor do produto com {}% de desconto: R${:.2f}'.format(n2,nv))
e23b8caac31cc3c62dd2c235eec176f54c0cbf3e
weibalangzi/doc
/py-course/test/list/list_切片.py
495
4.0625
4
a = [1, 2, 3, 4, 5, 6] print(a[:3]) # [1, 2, 3] print(a[3:]) # [4, 5, 6] print(a[1:5]) # [2, 3, 4, 5] # 步长为2时,取值时会跳过一个元素 print(a[1:5:2]) # [2, 4] # 步长为1时,等同于[1:5],因为默认步长就是1 print(a[1:5:1]) # 未设置起始位置和结束位置,步长为2,等同于[0:6:2] print(a[::2]) # [1, 3, 5] print(a[::]) # [1, 2, 3, 4, 5, 6] print(a[1:6:]...
d82333b2e582e71edf95dd5a579f342896258ae6
weibalangzi/doc
/py-course/test/dict/创建.py
517
4
4
# 字面量创建 a = {a: 1, b: 2} # 构造函数创建 b = dict(a=1, b=2) # 通过zip创建 c = dict(zip(['a', 'b'], [1, 2])) print(c) # {'a': 1, 'b': 2} # 通过列表创建 d = dict([('a', 1), ('b', 2)]) print(d) # {'a': 1, 'b': 2} # 通过字典创建 e = dict({'a': 1, 'b': 2}) print(e) # {'a': 1, 'b': 2} # 通过字典推导式创建 f = {i: i * 2 for i in rang...
5d29f49ccb6be4f74eb820f52b4c915b8b5e5773
weibalangzi/doc
/py-course/test/utils/itertools迭代工具.py
246
3.90625
4
import itertools a = 'ABCD' # 全排列 for i in itertools.permutations(a): print(i) # 全排列,指定长度 for i in itertools.permutations(a, 2): print(i) # 组合 for i in itertools.combinations(a, 2): print(i)
624d9c2f10d64537d14d0217df92f955451cfd3d
weibalangzi/doc
/py-course/test/class/创建.py
1,157
4.09375
4
class Good_item: """ 商品 """ def __init__(self, name, price, num): self.name = name self.price = price self.num = num class Store: """ 一个简单的类 """ # 自执行初始化函数 def __init__(self, name): # 设置商店名称 self.name = name # 设置商店...
b0f34718a7665455094d3bf448929a0c20c840ec
maksyudgil/task_solution
/riddle_main.py
793
3.921875
4
# This task is to introduce arrays/strings/conditions in Python. Also some logical thinking. # Each of the ? must be replaced with a char, that is unique (so can't be same as on left or right). def solve_riddle(str): # Please enter your solution here # ... return str def run_tests(): is_correct_solution(sol...
9505b66c7da1046ebbbcfca2fe9b53142326bcaa
Marvinh5/Py_game
/ball.py
1,497
3.5625
4
from game_object import game_object from shared import direction import game_constants class ball(game_object): def __init__(self, game, image): self.__direction = direction(-1, -1) self.__dead = False self.__speed = 4 super(ball, self).__init__(game, image) @prope...
b8c0aa2e17e4e491d67dc3441826fad3b13a069b
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_move_object_slow_on_opposite_key.py
1,788
3.640625
4
# pygame.key module # https://www.pygame.org/docs/ref/key.html # # Python only running while loop once # https://stackoverflow.com/questions/59706667/python-only-running-while-loop-once/59706711#59706711 # # How to get if a key is pressed pygame # https://stackoverflow.com/questions/59830738/how-to-get-if-a-key-is-pres...
0a689af0af3c755ee9552a8e42183a16350c980a
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_intersect_spritecollide_collide_circle.py
1,597
3.875
4
# pygame.Rect object # https://www.pygame.org/docs/ref/rect.html#pygame.Rect # # How do I detect collision in pygame? # https://stackoverflow.com/questions/29640685/how-do-i-detect-collision-in-pygame/65064907#65064907 # # GitHub - PyGameExamplesAndAnswers - Collision and Intersection - Overview # https://github.com/Ra...
c240a9928361e55a1c9ffb056490b595ade31553
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/snake/chain/snkae_chain_movement_grid_move.py
2,075
3.546875
4
# How do I chain the movement of a snake's body? # https://stackoverflow.com/questions/62010434/how-do-i-chain-the-movement-of-a-snakes-body/62010435#62010435 import pygame import random pygame.init() COLUMNS, ROWS, SIZE = 10, 10, 20 screen = pygame.display.set_mode((COLUMNS*SIZE, ROWS*SIZE)) clock = pygame.time.Clo...
fe7fe02002ec99a509e76bcccedad86b184bc4f0
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_random_movement_points.py
2,240
3.671875
4
# How to plot circles every 20 pixels between two randomly generated points in Pygame? # https://stackoverflow.com/questions/56245338/how-to-plot-circles-every-20-pixels-between-two-randomly-generated-points-in-pyg/56245525#56245525 # # GitHub - PyGameExamplesAndAnswers - Random movement distribution # https://github.c...
0e9c5d0c1b31e3833d95a783383b5eb6f8dd7911
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_draw_line_slowly_1.py
1,533
3.578125
4
# pygame.draw module # https://www.pygame.org/docs/ref/draw.html # # How to slowly draw a line in Python # https://stackoverflow.com/questions/57618029/how-to-slowly-draw-a-line-in-python/57621742#57621742 # Slowly drawing a line in pygame while other lines remain static # https://stackoverflow.com/questions/5763085...
6d92e6086aad7cb8c1d3d8bf8206bdbf7cd1c038
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_intersect_spritecollide.py
1,437
3.78125
4
# pygame.Rect object # https://www.pygame.org/docs/ref/rect.html#pygame.Rect # # How do I detect collision in pygame? # https://stackoverflow.com/questions/29640685/how-do-i-detect-collision-in-pygame/65064907#65064907 # # GitHub - PyGameExamplesAndAnswers - Collision and Intersection - Overview # https://github.com/Ra...
3175e9cab01ebc1dc6855159b4e46e6c1dcf32ae
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_timer_counter.py
1,311
3.75
4
# pygame.time module # https://www.pygame.org/docs/ref/time.html # # Python 3.8 pygame timer? # https://stackoverflow.com/questions/59944795/python-3-8-pygame-timer/59944869#59944869 # # How to display dynamically in Pygame? # https://stackoverflow.com/questions/56453574/how-to-display-dynamically-in-pygame/56454295#...
186800e5cd2caee764716c945134865d80aa73ac
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_sprite_mouse_drag.py
3,057
3.578125
4
# pygame.event module # https://www.pygame.org/docs/ref/event.html # # pygame.sprite module # https://www.pygame.org/docs/ref/sprite.html # # Drag multiple sprites with different “update ()” methods from the same Sprite class in Pygame # https://stackoverflow.com/questions/64419223/drag-multiple-sprites-with-different-...
c69efdf7f96f21ca68538a20a2c1647310fac16f
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_rectangle_collidepoint.py
1,405
3.75
4
# pygame.Rect object # https://www.pygame.org/docs/ref/rect.html # # How to detect when a sprite is clicked # https://stackoverflow.com/questions/58917346/how-to-detect-when-a-sprite-is-clicked/58935218#58935218 # # GitHub - PyGameExamplesAndAnswers - Collision and Intersection - Click on rectangle # https://github.com...
114a9c4e99c676eeae3fd13b2dd22b6d456a766b
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_blend_surface_change_color_1.py
2,453
3.625
4
# pygame.Surface object # https://www.pygame.org/docs/ref/surface.html # # Trying to make sections of sprite change colour, but whole sprite changes instead # https://stackoverflow.com/questions/58385570/trying-to-make-sections-of-sprite-change-colour-but-whole-sprite-changes-instea/58402923#58402923 # # GitHub - PyGam...
8baced6286fbe30297c4e9e80e27283bc03784eb
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_sprite_update.py
1,411
3.625
4
# pygame.sprite module # https://www.pygame.org/docs/ref/sprite.html # # Why We Have to Use self.rect and self.image to Determine Rect and Surf on Sprites? # https://stackoverflow.com/questions/68454667/why-we-have-to-use-self-rect-and-self-image-to-determine-rect-and-surf-on-sprite/68456266#68456266 # # GitHub - Sprit...
b4651bb963f9f421e2fc2dea56aed0fbdb3c9812
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_math_vector_angle_between_vectors.py
1,880
3.84375
4
# pygame.math module, pygame.math.Vector2 object # https://www.pygame.org/docs/ref/math.html # # How to know the angle between two vectors? # https://stackoverflow.com/questions/42258637/how-to-know-the-angle-between-two-vectors/64563327#64563327 # # GitHub - PyGameExamplesAndAnswers - Vector - Angle between vectors # ...
384d933aa0317ab5e3621f3a1ba25464f9247d08
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_draw_rectangle_round_corners.py
2,007
3.828125
4
# pygame.draw module # https://www.pygame.org/docs/ref/draw.html # # Setting a pygame surface to have rounded corners # https://stackoverflow.com/questions/63700231/setting-a-pygame-surface-to-have-rounded-corners/63701005#63701005 # # GitHub - PyGameExamplesAndAnswers - Shape and contour - Draw rectangle # https://...
f74d06987bb67c1967dff14870a29b09db5ff8dd
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_draw_line_dashed.py
1,853
3.953125
4
# pygame.draw module # https://www.pygame.org/docs/ref/draw.html # # How to draw a dashed curved line with pygame? # https://stackoverflow.com/questions/66943011/how-to-draw-a-dashed-curved-line-with-pygame/66944050#66944050 # # GitHub - PyGameExamplesAndAnswers - Shape and contour - Draw lines and polygons # https:/...
3ad6f06f7c814691dabd42cb6b8ea15c951c0f15
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_tetris_shapes.py
1,453
3.84375
4
# Tetris generating coloured shapes from blocks # https://stackoverflow.com/questions/66765536/tetris-generating-coloured-shapes-from-blocks/66767879#66767879 # # GitHub - PyGameExamplesAndAnswers - Tetris # https://github.com/Rabbid76/PyGameExamplesAndAnswers/blob/master/documentation/pygame/pygame_tetris.md impor...
52a7141fc6cace3ba61733042ebaf91eb3026a77
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_move_car.py
1,627
3.796875
4
# pygame.key module # https://www.pygame.org/docs/ref/key.html # # How to turn the sprite in pygame while moving with the keys # https://stackoverflow.com/questions/64792467/how-to-turn-the-sprite-in-pygame-while-moving-with-the-keys/64792568#64792568 # # Image rotation while moving # https://stackoverflow.com/question...
dd50ee338fde8e9e00fbeffb93ecb0522b7d7c94
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_move_follow_4.py
1,459
3.71875
4
# pygame.math module, pygame.math.Vector2 object # https://www.pygame.org/docs/ref/math.html # # Pygame make sprite walk in given rotation # https://stackoverflow.com/questions/66402816/pygame-make-sprite-walk-in-given-rotation/66403030#66403030 # # GitHub - Move towards target - Follow target or mouse # https://github...
75551f0ff278196da1cef9f6e35b8f4f7da482e0
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_intersect_circle_triangle.py
2,835
3.75
4
# pygame.math module, pygame.math.Vector2 object # https://www.pygame.org/docs/ref/math.html # # How to make ball bounce off triangle in pygame? # https://stackoverflow.com/questions/54256104/how-to-make-ball-bounce-off-triangle-in-pygame # # GitHub - PyGameExamplesAndAnswers - Collision and Intersection - Circle and p...
6291a6698cad0ded501e67e9a95fdf05b148134b
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_color_lerp_2.py
1,262
3.875
4
# How to fade from one colour to another in pygame? # https://stackoverflow.com/questions/51973441/how-to-fade-from-one-colour-to-another-in-pygame/68702388#68702388 # # GitHub - PyGameExamplesAndAnswers - Color # https://github.com/Rabbid76/PyGameExamplesAndAnswers/blob/master/documentation/pygame/pygame_color.md im...
1a4da551bea1fd3a3adb535d91298752f2f3ab1c
aryanbangad/hello-world
/milestone 2/fibonacci numbers.py
179
4.03125
4
def fibon(): n = int(input("how many fibonacci numbers do you want: ")) a = 1 b = 1 output = [] for i in range(n): output.append(a) a,b = b,a+b print(output) fibon()
966f95e47f23f1a813cbfa5bc672b54e250e4ae2
tartley/colortuple
/colortuple/colortuple.py
5,914
3.78125
4
from __future__ import division from collections import namedtuple from random import uniform class Color(namedtuple('__BaseColor', 'r g b a')): ''' 4-component named tuple: (r, g, b, a), all floats from 0.0 to 1.0, with some methods. .. function:: __init__(r, g, b[, a=1]) ``r``, ``g``, `...
9dd9a0a09487fb7d604e470b72fd439765b61d25
ConsultantFoodie/Info_Ret_CS60092
/Information_Retrieval_CS60092/Assignment_1/ASSIGNMENT1_18EC10020_4.py
3,102
3.640625
4
import os import json import sys ''' B-tree or binary tree not implemented since they give approximately the same time complexity The space complexity, implementation, and handling of trees is worse than a sorted list, so they are not used This works only because the corpus is static. In case of a dynamic corpus, tree...
720df1162a781277bdcd5d1c2743ba8dc927a9a4
DavidKwan/alien-downloader
/Alien Collector.py
3,122
3.59375
4
# coded in python """Reddit Alien Banner Downloader This is a simple script to download the alien image banner for a given subreddit url to a local directory called 'images'. To use it, call the function download_alien with the parameter as a string containing the URL. For example, calling download_alien("http://www....
ddda27bf9906caf8916deb667639c8e4d052a05f
AXDOOMER/Bash-Utilities
/Other/Python/parse_between.py
918
4.125
4
#!/usr/bin/env python # Copyright (c) Alexandre-Xavier Labonte-Lamoureux, 2017 import sys import numbers # Parser def parse(textfile): myfile = open(textfile, "r") datastring = myfile.read() first_delimiter = '\"' second_delimiter = '\"' index = 0 while(index < len(datastring)): first = datastring.find(fir...
ea30f1250722b857e92302767df43422be5380c3
sunnycqcn/popgen
/codon/identify_telomere_repeats.py
1,680
3.5625
4
#! /usr/bin/env python import os import re import sys from collections import defaultdict from sys import argv from Bio import SeqIO #Scan one strand for telomere repeats ###Arguments: #First: Input file with sequence(s) to be scanned: #Second: Expected repeat motif sequence (5'-> 3') in upper case #Third: Which stra...
ffa85ebfe290cfc51bb32cb5a226aa6d33e80062
tanhuacheng/Documents
/python/google_tech_dev_guide/decomp.py
1,599
3.59375
4
#!/usr/bin/python3 # -*- coding:utf-8 ''' decompression string ''' __author__ = 'tanhuacheng' def find_most_pair(s): x = 0 p = 0 for i in range(len(s)): if s[i] == '[': x = i if not p else x p += 1 elif s[i] == ']': p -= 1 if not p: ...
0ff2c7e8d52820a327f2ab0ffd7532f1360cf519
tanhuacheng/Documents
/python/args.py
694
3.578125
4
#!/usr/bin/python3 # -*- coding:utf-8 'args 和 kwargs' __author__ = 'tanhc' def test_var_args (f_arg, *argv): print("first normal arg:", f_arg) for arg in argv: print("another arg through *argv:", arg) def greet_me (**kwargs): for key, value in kwargs.items(): print("{0} == {1}".format(ke...
36f87ab876eedb940e3272fc3fb50ebe939d8463
jbjbjb1/file-metadata-scanner
/file_cleanup/filename_match.py
1,525
3.578125
4
# Purose: Find files based on filename. import re import numpy as np import pandas as pd def get_filenames(df, save_ouput_path): """Checks for files that match required filename format.""" # Get list of files filenames = df['File'].tolist() files_matched = [] files_project = [] files_type = [...
14aa86062d198e0a444fb3dce6e198441bf64c6b
lssantos20/lssantos20.github.yo
/Calculadora.py
906
4.0625
4
class Calculadora: #define o nome da class #_init_() é o metodo inicializador de classe recebendo # 2 parametros operando 1 e operando 2 def __init__(self, num1, num2): # self faz referencias ao proprio objeto self.resultado = 0 # então estamos definindo o atributos self.operando1 = nu...
54894dd09aaf337a6d0bc3be6bbb47e1476c4325
mmm7/aoc2020
/day13/day13.py
512
3.5
4
from math import gcd from functools import reduce from input import BUSES,T def lcm(a,b): return a*b//gcd(a,b) assert lcm(6,10)==30 print(T,BUSES) wait=[] for b,_ in BUSES: w = (-T)%b wait.append((w, b, w*b)) wait.sort() print(wait) print("A:",wait[0][2]) def coll(a,b): am,ar = a bm,br = b t=0 while...
4a6cdc7124bb08e2f637bd717ea1e6d598cfcef2
AalizzweII/Autoit-Obfuscator
/System/Kernel/ExtractKeywords.py
5,460
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from re import match,findall,compile,search,sub ## GENERAL ## def is_keyword_block(line,key): line = line.strip() aux = line.lower() if aux.find(key)==0: return True else: return False ############# ## IF ## def is_if(line): return is_k...
01cfba26eeb0c63997496eb9a83e0e38168cddef
Kim-YoonHyun/Algorithm
/code11-02.py
489
3.671875
4
import random ## 함수 선언부 def find_min_index(ary): min_index = 0 for i in range(1, len(ary)): if ary[min_index] > ary[i]: min_index = i return min_index ## 전역 변수부 before = [random.randint(33, 190) for _i in range(20)] after = [] ## 메인 코드부 print('정렬 전 -->', before) for i in range(len(be...
0d92d66c6eaeed75b9ac171ed9c11c5055046e79
Kim-YoonHyun/Algorithm
/code07-11.py
1,138
3.65625
4
## 함수 def is_queue_full(): global SiZE, queue, front, rear if ((rear+1) % SIZE) == front: return True else: return False def is_queue_empty(): global SIZE, queue, front, rear if front == rear: return True else: return False def en_queue(data): global SIZE, que...
49c33bb519c6142f0832435d2a66054baceadf1a
cmedinadeveloper/udacity-data-structures-algorithms-project1-unscramble
/Task1.py
666
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv phone_nums = [] with open('texts.csv', 'r') as f: reader = csv.reader(f) for text in list(reader): phone_nums.extend(text[:2]) with open('calls.csv', 'r') as f: reader = csv.reader(f) for cal...
a9f3e569e91a316d6027c4e43b0d01120d444556
CarlosSotoB/UNIDAD-III
/ejercicios/composite.py
2,322
3.9375
4
# Author: Jose Carlos Soto Barco #description: a class is declared by a component class Component(object): """ Abstract class """ def __init__(self, *args, **kwargs): pass def component_function(self): pass class Child(Component): # Inherit from the abstract class, Componen...
98e3ddf1a6fcbf18a8053f865a99c40de02f90f9
dbuts/EuelerQuittingGame
/simulation.py
1,323
3.734375
4
import random from math import e, ceil class Simulation: def __init__(self, minimum, maximum, valSize): self.min = minimum self.max = maximum self.size = valSize self.values = [] self.generate() #Generates array of (size) items between given min/max def generate(sel...
f150c2160c0c5b910fde7e3a05c40fc26e3c213c
HopeFreeTechnologies/pythonbasics
/variables.py
1,419
4.125
4
#So this file has some examples of variables, how they work, and more than just one output (like hi there.py did). ####################### # #Below is a variable by the name vname. V for variable and name for, well name. # Its my first ever variable in Python so by default it's awesome, so i let it know by giving it t...
6d4ada29ffb46a7015fafd08df93aa18ea01518b
abinesh1/pythonHackerRank
/strings/prob53.py
460
3.625
4
## https://www.hackerrank.com/challenges/the-minion-game/problem from itertools import combinations def minion_game(string): l = len(string) stuart, kevin = 0,0 for x in range(l): if(string[x] in 'AEIOU'): kevin+= (l-x) else: stuart+= (l-x) print("Draw") if kevin==stuart else print("Stu...
917d2ab8b3cc007dca2118cad820ff084f68ff44
abinesh1/pythonHackerRank
/itertools/prob51.py
178
3.8125
4
## https://www.hackerrank.com/challenges/compress-the-string/problem from itertools import groupby n = input() print(*[(len(list(y)), int(x)) for x,y in groupby(n)], sep = ' ')
22b93dddb37a939c794fbb6395cd579eebb93749
abinesh1/pythonHackerRank
/collections/prob57.py
285
3.640625
4
##https://www.hackerrank.com/challenges/py-collections-deque/problem from collections import deque d = deque() for i in range(int(input())): text = input().split() arg = text[1:] cmd = str(text[0])+ '(' + str(','.join(arg)) + ')' eval("d.{0}".format(cmd)) print(*d)
5580c7850afcc47637a0ad666f19368cf0aa8ee6
welitonsousa/UFPI
/estatisticas/av1/desafios/5.py
665
4
4
""" Sem utilizar nenhuma biblioteca tais como numpy ou pandas, faça um código em Python para calcular os decis: a. faça uma versão para que o usuário informe 20 números. b. faça uma versão que os 20 números são gerados automaticamente """ import random def decis(array): decis = [] array.sort() print(array) fo...
d0789ac768487eb3c72ae35f41d8804dede60a87
welitonsousa/UFPI
/programacao_orientada_objetos/av1/lista02/11.py
216
3.78125
4
alunos = {} for i in range(0, 2): name = input('Nome do aluno: ') alunos[name] = (float(input('Nota 1: ')) + float(input('Nota 2: '))) / 2 print(alunos.get(input('Buscar aluno: '), 'Anuno nao encontrado'))
4b97c6977fa2b7f4bb153caf889e4cec6c7cc66a
welitonsousa/UFPI
/programacao_orientada_objetos/estudo/lista01/10.py
781
3.640625
4
entradas = int(input()) atividades = [] for i in range(0, entradas): ati = input() horarios = ati[len(ati) - 11: ].split(' ') horario_inicio, horario_fim = horarios[0], horarios[1] nome_atividade = ati[0: len(ati) - len(horario_fim + horario_inicio) - 2] atividades.append({ 'nome': nome_at...
7ae6c5e6868797c9bdd239db2b0995dff45422c4
welitonsousa/UFPI
/programacao_orientada_objetos/av1/lista02/7.py
240
3.625
4
def multiplyArrays(arrayOne, arrayTwo): arrayTree = [] for i in range(0, len(arrayOne)): arrayTree.append(arrayOne[i] * arrayTwo[i]) return arrayTree arrayTree = multiplyArrays([1,2,3,4,5], [2,2,2,2,2]) print(arrayTree)
3b80f4307e79641e4ff66973b5242778d8c2a23a
welitonsousa/UFPI
/programacao_orientada_objetos/av1/lista04/interface_accounts.py
498
3.546875
4
import abc class Accounts(abc): @abc.abstractmethod def send_money(self): """method for sending money when making a transfer""" pass @abc.abstractmethod def post_historic(self): """method for adding a new item to your account history""" pass @abc.abstractmethod ...
e4fb34e189caa479514a3d733a4ea2947b7d9b43
welitonsousa/UFPI
/programacao_orientada_objetos/av1/lista03/class3elevador.py
3,670
4.28125
4
""" Crie uma classe denominada Elevador para armazenar as informações de um elevador dentro de um prédio. A classe deve armazenar o andar atual (térreo = 0), total de andares no prédio (desconsiderando o térreo), capacidade do elevador e quantas pessoas estão presentes nele. A classe deve também disponibilizar os segui...
8080dcf4552433ad0e9ed309434a8dfbb9e5e840
cpe202fall2018/lab0-thebarrettlo
/planets.py
474
3.96875
4
def weight_on_planets(): # write your code here userInput = input("What do you weigh on earth? ") userWeight = float(userInput) # User weight under alternate gravitation pulls marsWeight = userWeight * 0.38 jupiterWeight = userWeight * 2.34 # Print new weights print("\n" "On Mars you ...
3e82023bff7885ad4aeb905437dfdbf262bf5d56
pedro-abundio-wang/computer-vision
/notebooks/convolutional-neural-networks-for-visual-recognition/classifiers/softmax.py
4,352
3.65625
4
from builtins import range import numpy as np from random import shuffle from past.builtins import xrange def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. I...
e8fbd1cb84d0e0016f2c01cd139c38206035835d
RyanFatsena/Python_C9_ManipulasiStr
/3.C9.py
496
3.6875
4
#3 # Pertambahan Bintang def starFormation1(n) : for r in range(1,n+1) : star = "*" * (1 + (r-1)*2) print(star.center(10)) # Pengurangan Bintang def starFormation2(n) : for r in range(n,0,-1) : star = "*" * (1 + (r-1)*2) print(star.center(10)) # Syarat def starFormation3(n)...
1f5055c9644b707d7e074cd3187465228dfa2b51
ashutoshfolane/Hashing-2
/contiguous_array.py
740
3.703125
4
""" Problem: Contiguous Array Leetcode: https://leetcode.com/problems/contiguous-array/ Time Complexity: O(n) Space Complexity: O(n) """ class Solution: def findMaxLength(self, nums): # Define a hashmap with default values to cover corner case hmap = {0:-1} count = 0 max_length = 0...
7d317571e784b573510d5972e9d368a45fb84e6d
XifeiNi/LeetCode-Traversal
/python/sysdesign/addSearchWord.py
1,400
4.09375
4
class TrieNode(): def __init__(self): self.children = {} self.isWord = False class WordDictionary: def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def addWord(self, word: str) -> None: """ Adds...
7b4fed52dd8affa4ece97250277fbdf5d9601839
XifeiNi/LeetCode-Traversal
/python/sysdesign/time_based_key_value_store.py
1,200
3.546875
4
from collections import defaultdict class TimeMap(object): def __init__(self): """ Initialize your data structure here. """ self.hashMap = defaultdict(list) def set(self, key, value, timestamp): """ :type key: str :type value: str :type ...
630cb1fc6b447449c63a1ac0015b21b6aab91897
XifeiNi/LeetCode-Traversal
/python/DP/shortestWordDistance.py
952
3.625
4
from collections import defaultdict class WordDistance(object): def __init__(self, words): """ :type words: List[str] """ self.dictionary = defaultdict(list) i = 0 for word in words: self.dictionary[word].append(i) i+=1 ...
d87afa73d6e502f6b5721fe493547b653f6d06ce
XifeiNi/LeetCode-Traversal
/python/tree/recoverBinaryTree.py
818
3.84375
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 recoverTree(self, root: TreeNode) -> None: """ Do not return anything, modify root in-pl...
f755228fd38ce95e9a2fc2da7adac038b2cabc4f
XifeiNi/LeetCode-Traversal
/python/heap/examRoom.py
1,940
3.625
4
class ExamRoom: def __init__(self, N: int): self.numSeats = N self.heap = [] self.availFirst = {} self.availLast = {} self.putSegment(0, self.numSeats - 1) def seat(self) -> int: while self.heap: _, first, last, valid = heapq.heappop(self.heap) ...
0eebd9e8ef66e9ec720b2ee4464bd45b5003efd4
Ayers-Kendall/Gallifreyan
/pieces/word.py
483
3.625
4
import numpy as np import cv2 from sentence import Sentence class Word(object): # Constructor def __init__(self, parent, characters): if not isinstance(parent, Sentence): print('Parent of a word should be a sentence!!') raise TypeError self.parent = parent ...
b68bb078deb4ab933e12061c3634783544f25df1
apurva-gupta/Applications-in-AI
/Optical Character Recognition using HMM/ocr.py
21,989
4.03125
4
#!/usr/bin/python # # Perform optical character recognition, usage: # ./ocr.py train-image-file.png train-text.txt test-image-file.png # Training file used during assignment: Tweets.train.txt # (based on skeleton code by D. Crandall, Oct 2017) # """ This program aims at recognizing characters in a given image us...
4a263002fb4ad5b409d20700d6849a59f601d79b
arentij/ft2db
/string_work/xx2x3xplus_1_3.py
870
3.578125
4
def back(x): if x % 6 == 0: return [x-1, x // 2, x // 3] elif x % 3 == 0: return [x-1, x // 3] elif x % 2 == 0: return [x-1, x // 2] else: return [x-1] v = int(input()) d = {v: back(v)} v_values = [] to_check = [v] to_check2 = [] n = 0 while 1 not in to_check: for y...