blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4eccc46ac6a27ed06c52a9f96d689e424b2fc5d8
aandr26/Learning_Python
/Coursera/Week4/Week4b/Project/project_template.py
6,920
4
4
# Implementation of classic arcade game Pong import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / 2 HALF_PAD_HEIGHT = PAD_HEIGHT / 2 LEFT = False RIGHT = True SCORE...
f63968e54881348076c5bb054c0ef006a570406d
w940853815/my_leetcode
/medium/209.长度最小的子数组.py
1,622
3.578125
4
# # @lc app=leetcode.cn id=209 lang=python3 # # [209] 长度最小的子数组 # # https://leetcode-cn.com/problems/minimum-size-subarray-sum/description/ # # algorithms # Medium (44.78%) # Likes: 536 # Dislikes: 0 # Total Accepted: 109.7K # Total Submissions: 244.7K # Testcase Example: '7\n[2,3,1,2,4,3]' # # 给定一个含有 n 个正整数的数组和一...
8a7c1571bff9747480b3abec8dc58177e9f0cc33
dl-00-e8/Python_for_Coding_Test
/10-2.py
786
3.71875
4
def findParent(parent, x): if parent[x] != x: parent[x] = findParent(parent, parent[x]) return parent[x] def unionParent(parent, a, b): a = findParent(parent, a) b = findParent(parent, b) if a < b: parent[b] = a else: parent[a] = b n, m = map(int, input().split()) par...
9585d1e145c500321059f9ae5554a939de71abe2
marcusshepp/hackerrank
/python/openkattis/erase.py
316
3.546875
4
num, str_one, str_two = int(raw_input()), raw_input(), raw_input() def switch(s): x = str() for i in range(len(s)): if s[i] == "0": x+="1" else: x+="0" return x x = str_one for i in range(num): x = switch(x) if x == str_two: print "Deletion succeeded" else: print "Deletion failed"
bd1488f7ee61d4c2dc41983c0582ab8b5b95ae1f
MurylloEx/Data-Structures-and-Algorithms
/Week_3/merge_sort.py
648
3.59375
4
import math def merge_sort(srcList, sl_idx, sr_idx): if sr_idx > sl_idx: middle = (sl_idx + sr_idx) // 2 merge_sort(srcList, sl_idx, middle) merge_sort(srcList, middle + 1, sr_idx) merge(srcList, sl_idx, middle, sr_idx) def merge(srcList, l_idx, middle, r_idx): r_len = (middle ...
1232a0159d9e68c85db5cc130622b3e2c3a0ad67
rwelsh98/isat252
/PC_chp FIles/PC_chp8/pizza.py
911
3.71875
4
""" Your module description """ #Passing an arbitrary number of arguments def make_pizza(*toppings): """Print the list of toppings that have been requested.""" print(toppings) make_pizza('pepperoni') make_pizza('mushrooms','green peppers', 'extra cheese') #improve def make_pizza(*toppings): """Summari...
3f0037139ad867fd30abfd2502ad7291e8ea9282
chuckinator0/Projects
/scripts/symmetricTree.py
1,035
4.40625
4
''' Given a binary tree t, determine whether it is symmetric around its center, i.e. each side mirrors the other. ''' # # Definition for binary tree: # class Tree(object): # def __init__(self, x): # self.value = x # self.left = None # self.right = None def mirror(s,t): # let's look at situations wh...
e93131c72f9fc4e5b704169d804c67fd0891abe7
swatirathore15/python
/cropimage.py
351
3.65625
4
from PIL import Image left = int(input("Pixels From Left : ")) top = int(input("Pixels From Top : ")) right = int(input("Pixels From Right : ")) bottom = int(input("Pixels From Bottom : ")) img_path = str(input("enter Image path : ")) image1 = Image.open(img_path) crop_image = image1.crop((left, top, right, ...
c8f5c64ec4a167ea93b2ec088205c428e194faa8
5l1v3r1/python_hacking_code
/random_dice.py
255
3.875
4
import random print("This is a rolling dice simulator") min_dice = 1 max_dice = 6 while True: print(random.randint(min_dice,max_dice)) nExt = input("Roll again? ") if nExt.startswith("y"): continue else: break
a89057edd56b008f0e289477f3522af494996f22
namratarane20/python
/algorithm/primenumber.py
510
4.25
4
#this program is used to find prime number within the given range of numbers from user from util import utility try: start = int(input("enter from where you want to find prime number :")) stop = int(input("enter till where you want to find prime number :")) if start > -1 and stop < 1002: ...
e3aa009a79f3d5ee18a6fce162c824e88cf90bc5
pfengdev/pysnake
/DefaultMap.py
344
3.640625
4
from Map import Map from Wall import Wall class DefaultMap(Map): def initWalls(self): wall = Wall(0, 0, 1, 20) self.addWall(wall) wall = Wall(760, 0, 1, 20) self.addWall(wall) wall = Wall(0, 0, 20, 1) self.addWall(wall) wall = Wall(0, 760, 20, 1) self.addWall(wall) def __init__(self): super(Defa...
46ab0371ef00ec8b075c8bf3378e80605aa995eb
vipsinha/Python
/Udacity/1_DataStructures.py
7,707
4.46875
4
''' A good understanding of data structures is integral for programming and data analysis. As a data analyst, you will be working with data and code all the time, so a solid understanding of what data types and data structures are available and when to use each one will help you write more efficient code. Remember, ...
6e51244b0c6b80e60354da5f53cb79e273e5882c
reiterative/aoc2019
/password.py
886
3.59375
4
minval = 137683 maxval = 596253 def test_ascend(number): s = str(number) for i in range(1, len(s)): if int(s[i]) < int(s[i-1]): return False # /if # /for return True # /def def test_repeat(number): s = str(number) dup = 0 match = False for i in range(1, len(...
d8dcb88f3060ceb43340acf641b98bc6e0eb0c2f
carojasq/python_projects
/Decorators/simple_decorator.py
349
4.5
4
#A decorator is just a callable that takes a function as an argument and returns a replacement function. def outer(func): def inner(): f = func() return f+1 return inner def func1(): return 1 decorated = outer(func1) # Decorated is a decorated version of func1 func1 = outer(func1) #Func1 reassigned print (...
799a4597f5ea2fbedc3954ce072d73cd5984b99f
a62mds/exercism
/python/atbash-cipher/atbash_cipher.py
506
3.515625
4
#!/usr/bin/env python from string import ascii_lowercase as abcs ekey = dict(zip(abcs, reversed(abcs))) dkey = {v : k for k, v in ekey.iteritems()} def decode(encstr): subst = lambda c: dkey[c] if c.isalpha() else c return ''.join(map(subst, ''.join(encstr.split()))) def encode(rawstr): subst = lambda c...
1b1c962ba53de50a21e629bf889cb1dadf762a63
codeAligned/codingChallenges
/CodeFights/arcade/python/groupDating.py
298
3.6875
4
def groupDating(male, female): return [[male[idx] for idx in range(len(male)) if male[idx] != female[idx]], [female[idx] for idx in range(len(male)) if male[idx] != female[idx]]] """ TESTS """ male = [5, 28, 14, 99, 17] female = [5, 14, 28, 99, 16] res = groupDating(male, female) print(res)
80b4479b4ab53d4058f8596f2be2f7f3da5e24da
as950118/Algorithm
/python/DP/1914.py
1,034
3.90625
4
import sys def my_pop(n, cur, stack): if cur >= 0: return stack[cur], cur-1, stack[:cur] else: return 0, cur, stack def hanoi(n, f, b, t): stack = [] flag = 1 cur = -1 while flag: while n>1: print("adad") stack.append(t) stack.append...
7de5616da67f29909fbe8e9a397c9a44109ff477
allanfs1/Java-c-c-python
/python/Qt/has.py
748
3.71875
4
#-*-coding:utf8;-*- #qpy:3 #qpy:console print("This is console module") m=5 cont=0 livre ='L' lista = [None for i in range(m)] def hashing(x): return x % m def main(): global cont while True: if lista is not None: numero = int(input("Insira um numero:")) cont+=1 if cont < m: pos=hashing(n...
e340a497e6ceda441743b00ff7fa565226602559
putraprstyo/python-OOP
/latihan-encapulasi/main.py
1,465
3.59375
4
class Hero: # private variable __jumlah = 0 def __init__(self, name, health, attPower, armor): self.__name = name self.__healthStandar = health self.__attPowerStandar = attPower self.__armorStandar = armor self.__level = 1 self.__exp = 0 self.__heal...
aed3b69baea1773df909aa6df2b3b87cbe238a5a
rpoliselit/python-for-dummies
/exercises/068.py
848
3.953125
4
""" Create a program that reads the age, and gender of several people. To each registered person the program should ask if the user wants to continue. In the end show: [1] Number of people over 21 [2] Number of registered men [3] Number of women under 21 """ print(f""" {'='*30} {'REGISTER':^30} {'='*30}""") major = un...
43fc37b83ce83822b9de60bf6f207890b7849438
jeff-hwang/Algorithm
/LeetCode/172. Factorial Trailing Zeroes.py
785
3.765625
4
class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ ''' fact = self.factorial(n) ln = len(str(fact)) lst = list(str(fact)) rst = 0 for i in range(ln-1, -1, -1): ...
d2ad0c8292ccf5fe146aef29e5cdc08150f5d26e
Domnus/Learning-Code
/Udemy Exercises/Function Practice Exercises/LEVEL 1 PROBLEMS/Master_Yoda.py
260
3.84375
4
# MASTER YODA: Given a sentence, return a sentence with the words reversed def master_yoda(words): mylist = [] new_word = '' mylist.append(words.split(' ')) for i in range(len(mylist). -1): new_word.join master_yoda('I am home')
40509e6625c05b09fdce2bc6f511084f7400c369
subnr01/Programming_interviews
/programming-challanges-master/codeeval/016_number-of-ones.py
546
4
4
#!/usr/bin/env python """ Number of Ones Challenge Description: Write a program to determine the number of 1 bits in the internal representation of a given integer. Input sample: The first argument will be a text file containing an integer, one per line. e.g. 10 22 56 Output sample: Print to stdout...
c69f8ff5529848c5c0741226afe6debfb960a229
facesvision/Monty-Hall
/monty_hall.py
1,013
3.734375
4
import random class MontyHall: def __init__(self): self.doors = [1, 2, 3, 4] self.winner_door = random.choice(self.doors) def turn1(self, chosen_door): if chosen_door == self.winner_door: other_doors = [door for door in self.doors if door != chosen_door] retu...
bdb9d5872001d8309f7eb2a176d7726f8a3daedc
Shourya-Tyagi/Algorithms_basic
/insertionsort.py
612
4.125
4
#def insertion_sort(list_a): # for i in range(1,len(list_a)) : # value_to_sort = list_a[i] # # while list_a[i-1] > value_to_sort and i > 0 : # list_a[i-1] ,list_a[i] = list_a[i] , list_a[i-1] # i = i-1 # return list_a def insertion_sort(list_a): indexing_length = range(1, len(...
45ea597788636b9cde1909789c45fcc171ced32c
corinnemedeiros/plaintext
/CodingChallenge_multidigits_alt_3functions.py
540
3.75
4
encoded_string = "12oocvz09jqquiH11yywxsanmvbpI13yer6twweop14s 21gebwvsrxeqdwygrtuhijwT11hhllknbvxzdH00E01iR10kkjsagetrdE" # empty lists to store found characters DECODED_WORD = [] DECODED_WORD_MULTIDIGIT = [] # converts the encoded string into a list of individual characters CHARACTER_LIST = list(encoded_string) LE...
0d3d94d9b38f2e1a4671cfd9a8b8345468d4b6d1
larrythwu/python-tensorflow-exercises
/KNN/knn.py
1,562
3.609375
4
import sklearn from sklearn.utils import shuffle from sklearn.neighbors import KNeighborsClassifier import pandas as pd import numpy as np from sklearn import linear_model, preprocessing # preprocessing -> convert test in data file to numerical values data = pd.read_csv("car.data") print(data.head()) le = preprocessin...
da2a565e9ebc5bb0ddb8b6ab781f92d0df81c350
ibrahimGuilherme/Exercicio_Guilherme
/exercicio14.py
120
3.765625
4
import math numr = float(input('Digite um número real: ')) print(f'Número {numr} - Parte inteira {math.trunc(numr)}')
86260963fe2db4356d853c534eace3ba421e995d
bulat92/OZON-Skils
/j.py
1,248
3.5625
4
import tkinter as tk from tkinter.filedialog import askopenfilename, asksaveasfilename def open_file(): filepath = askopenfilename( filetypes=[("Текстовые файлы", "*.txt"), ("Все файлы", "*.*")]) if not filepath: return txt_edit.delete("1.0", tk.END) with open(filepath, "r") as input_file: text ...
1fe971f3a5b0a3757b88782509f61845ee9e4141
skosantosh/python
/s01_method_inheritance.py
693
3.953125
4
class Rectagle(): def __init__(self): print("Rectagle Created") def whoAmI(self): print("Rectagle") def draw(self): print('Drawing') # This class inheritance from Rectagle class # this doesn't vahe mothod whoIam, draw it stell inheritance from rectagle # if we un comment Rectagle...
dd191147d9ab0ba965a249bed5e4b12e76adfd05
superY-25/algorithm-learning
/src/algorithm/202003/lengthOfLIS.py
380
3.796875
4
""" 给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/longest-increasing-subsequence """ class Solution: def lengthOfLIS(self, nums: list) -> int:
7056d4b35c1873a098eaee6fa93ab6f5a2af11ad
MrBanh/textFileToSpreadsheet
/textFileToSpreadsheet.py
1,686
3.6875
4
#! python3 # textFileToSpreadsheet.py - Reads in the contents of several text files from desktop, and insert the contents # into a spreadsheet; one line of text per row, one text file per column import os import openpyxl from openpyxl.utils import get_column_letter import sys desktop = os.path.join(os.environ['USERP...
c96990247bb544ffad1f171fca1fcb2cb1b34fc0
wing1king/python_xuexi
/阶段1-Python核心编程/04-数据序列/03-元组/hm_02_定义元组.py
304
3.765625
4
# 1.多个数据元组 # t1 = (10, 20, 30) # print(t1) # print(type(t1)) # 2.单个数据元组 # t2 = (10,) # print(type(t2)) # 3.如果单个数据的元组不加逗号 # t3 = (10) # print(type(t3)) # int # t4 = ('aaa') # print(type(t4)) # str # # t5 = ('aaa',) # print(type(t5)) # tuple
540810795ec427964bad133afebdec927796f59f
yuryanliang/httpclient
/segment/http_client_practice.py
4,381
4
4
""" The goal is to write reusable client code that can be used to access an HTTP API that returns currency exchange rates in JSON format. Note that the exchange rates at a specified date are immutable: the same request would always return the same response. This API is live on the internet and can be accessed using a...
485d5c80a3d29ddaa7f4e187b7b9909f441b9b2f
ramjiik1992/201909-hp-python
/scripts-threading-socket/threading-2.py
696
3.859375
4
import threading as t import time class Counter(t.Thread): _count=0 def __init__(self,max,name=None): t.Thread.__init__(self) self.max=max self.name= name if(name !=None) else 'Thread#'+Counter._count Counter._count+=1 def run(self): print('{} started'.format(se...
ff2242681c678f7e42b509941097fb43607eaa47
ak-alam/Python_Problem_Solving
/max_of_three/main.py
440
4.28125
4
''' Find the largest of the three numbers. ''' first_num = int(input('Enter value :')) sec_num = int(input('Enter value :')) third_num = int(input('Enter value :')) if first_num > sec_num and first_num > third_num: print(f'Large Number is {first_num}') elif sec_num > first_num and sec_num > third_num: print(f'La...
17194706c33250717bb8415fe9bf95870e18b12d
Dansmith-rgb/dinosaur_game
/dinosaur_game/background.py
804
3.53125
4
import pygame class Background(object, pygame.sprite.Sprite): def __init__(self,x, y): pass """ def collide(self, bird, win): returns if a point is colliding with the pipe :param bird: Bird object :return: Bool bird_mask = bird.get...
81711c7aa4f4bd4568092dba570ef1ef862a472f
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/brnann016/question2.py
772
3.984375
4
#Vending machine program #Annika Brundyn #16/04/2014 cost = eval(input("Enter the cost (in cents):\n")) deposit1= eval(input("Deposit a coin or note (in cents):\n")) total_deposit=deposit1 while total_deposit<cost: deposit=eval(input("Deposit a coin or note (in cents):\n")) total_deposit+=deposit if tota...
e8eb61ee07ad9b9c14f24828dc19f23fc98ac87e
vmukund100/practice
/Intro_computation_Guttag/temp2_chpt5_6.py
14,346
3.96875
4
# -*- coding: utf-8 -*- """ Spyder Editor Author - Vineetha Mukundan To uncomment, press ctrl+1 This is a temporary script file. Contains exercise codes from Chapter 5 & 6 of 'Introduction to Computation and programming by Python' by John Guttag' Third Edition """ # t1 = (1, 'two', 3) # t2 = (t1, 3.25) # ...
b1740a4f4c332a4d4a4e997e134222a585af0743
Mahrokh-Eb/LA-college-Python
/sameForLoop.py
215
3.90625
4
# getting same result, # writting for loop in two ways: firstName = 'MAhrokh' for i in firstName: print(i) print('----------------') lastName = 'Ebrahimi' for i in range(len(lastName)): print(lastName[i])
d1f64a86ad12f9d117a099438cd5b09556679b0e
banjarajanardan/algorithmicToolboxUniversityOfSanDiego
/week3_greedy_algorithms/7_maximum_salary/largest_number.py
339
3.703125
4
#Uses python3 import sys def largest_number(a,n): for i in range(n): for j in range(n-1): if((a[j]+a[j+1])<(a[j+1]+a[j])): a[j+1], a[j] = a[j], a[j+1] return "".join(a) if __name__ == '__main__': n = int(input()) a = input() a = a.split() print(largest...
c5ed75caa0046dcf06284870e05a12e1e1370017
niallmul97/Poker-Minigame
/poker-mini-game.py
5,520
3.59375
4
import random class Card: def __init__(self, value, suit): self.value = value self.suit = suit #def faceCardSwitchCase(self, i): #faceCards = {11: 'J', 12: 'Q', 13: 'K', 14: 'A'} #return faceCards.get(i, str(i)) def show(self): if self.value == 11 or self.value == ...
04511079d26730994d932713b86343af0868834d
mustang25/CS-325-Project-1
/algo4_linear.py
754
3.796875
4
#!/usr/bin/env python3 """Linear algorithm based on the psuedocode from https://atekihcan.github.io/CLRS/E04.01-05/""" def linear(array): """Linear algorithm to determine the maximum subarray in an array. The algorithm will return a subarray and the maximum sum that was found. Arguments: array ...
93682ef567ed20d5ff6fb0996833873b7e44be9f
asen-krasimirov/Python-Advanced-Course
/9. Error Handling/9.1 Lab/test.py
162
3.515625
4
try: string = input() repeated_times = int(input()) print(string*repeated_times) except ValueError: print("Variable times must be an integer")
d62b77c6a9d32a388711fc7f7d65c0597e068452
Ryctorius/Curso-de-Python
/PycharmProjects/CursoExercicios/ex028.py
300
4
4
import emoji import random n = random.randint(0, 5) a = int(input('Digite um numero inteiro de 0 a 5: ')) if n == a: print('Parabéns! Você venceu!!!') else: print('Que pena, você errou! O número sorteado foi {}.'.format(n)) print(emoji.emojize('Obrigado por jogar conosco :sunglasses:'))
e92bd2f8cbeb13a289934a135994e7bafe42fe4d
Nikunj-Gupta/Python
/practice/Level3/swap.py
285
3.875
4
a=[] length = input("Enter length of the list: ") i = 1 while(i<=length): n = input("Enter a number: ") a.append(n) i = i + 1 pos1 = input("Enter position 1: ") pos2 = input("Enter position 2: ") swap = a[pos1] a[pos1] = a[pos2] a[pos2] = swap print "New List : " + str(a)
31ff4bdddd9ea3a29967ee42b37f87eee8ab0290
adwylie/simple-hangman
/game.py
2,517
3.671875
4
class Hangman: MAXIMUM_TRIES = 5 PHRASES = ['3dhubs', 'marvin', 'print', 'filament', 'order', 'layer'] def __init__(self, phrase, guesses=None, tries=None): # Allow an existing game to be continued if given all arguments. # TODO: Validate arguments? self.phrase = phrase self...
5c0c1e43ee15a3a0d37828905ed8b66c1dd1594e
spurgn14/thantology
/Password Checker.py
1,370
4.0625
4
#Author: Jonathan Anthony Hernandez #Password Checker Program #Description: Easy Password Checker using list, if-else, and for loop Lower_letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] Upper_letters= ['A', 'B', 'C', 'D...
ede0013a66c4ef42597769dbc8142e946a69d1ea
MegatronChen/MCLearnGUI
/BuildInModule_Learn/GUI/2018.05.14Strat_GUI.py
1,179
3.546875
4
__author__ = 'lenovo' print('\n') # 《python编程》GUI章节学习 # Chapter7 # # Example7.1 # from tkinter import Label # widget = Label(None,text='Hello GUI world!') # widget.pack() # widget.mainloop() # # Example7.6 # from tkinter import * # Label(text='hello GUI world!').pack(expand=YES,fill=BOTH) # mainloop() # # Examp...
2cde1073d9e106525a4746802a396415370c6632
RIAW2013/Intro-to-Python
/palindrome.py
500
3.703125
4
palList= [] def palindrome(x, y): while y > 99: palin = x * y palin_for = str(palin) palin_bac = str(palin)[::-1] if palin_for == palin_bac: palList.append(palin) if x < 100: x = 99...
cce091aa62914b3e55f1f977e5b538a1cd7107fe
sdeepanshu368/Python-Mini-Projects
/pr6 JumbledNames.py
440
4.09375
4
import random n = int(input("Enter the numbers of friends : ")) firstName = [] lastName = [] for i in range(n): fname = input(f"Enter the first name of friend {i+1} : ") lname = input(f"Enter the last name of friend {i+1} : ") firstName.append(fname) lastName.append(lname) random.shuffle(firstName) ran...
2451bc034f033787c672009605c616125270f5ee
cyrillelamal/pogrom
/sem4/task2/primo.py
947
4.28125
4
# Разработать прототип программы «Калькулятор», позволяющую # выполнять базовые арифметические действия и функцию обертку, # сохраняющую название выполняемой операции, аргументы и результат в # файл FILE = "./log.txt" def logger(func): def calc_with_log(*args, **kwargs): res = func(*args, **kwargs) ...
8d806192b0d9e7c4e9af1329defdcaf1362bac97
PacktPublishing/Getting-Started-with-Python
/Chapter10/hash.py
242
3.640625
4
def hash(data): counter = 1 sum = 0 for d in data: sum += counter * ord(d) return sum % 256 items = ['foo', 'bar', 'bim', 'baz', 'quux', 'duux', 'gnn'] for item in items: print("{}: {}".format(item, hash(item)))
c45e6e8119be02380ee93ee99b5549ed7d974a2a
NawaskhanFathimaMafeeza/code1
/Circle1.py
140
3.65625
4
class Circle: def __init__(self,r): self.radius=r def __int__(self): return 3.14 * (self.radius ** 2) C1=Circle(8)
26538ae43d48a8e2fda3ba44cf72081f9fb7cb6f
yurygnutov/hexlet
/solutions/fibonacci.py
250
3.765625
4
__author__ = 'yury' # Return the N'th item in the Fibonacci sequence. Hint: The first item in the sequence is 0. # Example: # 13 == solution(7) def solution(num): if num < 2: return num return solution(num - 1) + solution(num - 2)
ce59d267a57fa4a947177dc6d76e7c61b62dbdaa
nahaza/pythonTraining
/ua/univer/HW06/ch10ProgTrain05/__main__.py
728
4.375
4
# 5. RetailItem Class # Write a class named RetailItem that holds data about an item in a retail store. The class # should store the following data in attributes: item description, units in inventory, and price. # Once you have written the class, write a program that creates three RetailItem objects # and stores the fo...
17ad695b6269c43f88487f3be5d4d4da03f5f270
Gabeali93/Gabe
/Ali_Networking1.py
935
4.46875
4
#1.) ###Prompt for 'url'###> 2.)read JSON data from the 'url' USING URLLIB 3.) parse and extract the comment #counts JSON data 4.)compute the sum of the numbers in the file and enter below #using python3 in terminal import urllib.request import json url = input("Enter name of website: ") #create variable 'url' t...
06014a5f79fed9d0404e076bf39129224d1e1efc
Kedaj/Cmp108
/.gitignore/Mj16.py
652
3.8125
4
import turtle win = turtle.Screen() tic = turtle.Turtle() tic.speed(10) win.setworldcoordinates(-0.5,-0.5,3.5,3.5) for i in range (0,10): tic.penup() tic.goto(0,i) tic.pendown() tic.forward(9) tic.left(90) for i in range (0,10): tic.penup() tic.goto(0,i) tic.pendown() tic.forward(9) ...
4ac0cc8ac3a42bd745aaf482c75e66419a402b88
sanjeevbhatia3/Python-Programming
/statements.py
276
4.125
4
is_raining = False if is_raining: print("Take Umbrella") else: print("It is not raining") dinner = 'cheese pizza' if dinner == 'veggie pizza': print('I will have it') elif dinner == 'chicken pizza': print('I may have it') else: print('I am not hungry')
4ea49bee81aca5a227dda469c0b7af91d0489df5
Hazurl/adventofcode
/2022/advent_of_code/day17/__init__.py
6,879
3.90625
4
from typing import Iterable, Optional, TypeVar def main() -> None: with open("./advent_of_code/day17/input.txt") as f: raw_input = f.read() print(f"Part 1: {part1(raw_input)}") print(f"Part 2: {part2(raw_input)}") class Grid: def __init__(self): self.rows = [] def _add_row(self...
c6be6235bc81bc0dd648cfc94c84f3b7846e2ea9
Dturati/Lagrange
/lagrange.py
2,423
3.90625
4
#Python 3 #David Turati #Metodo de imterpolacao da forma de lagrange # _*_ coding:latin 1 _*_ from math import sqrt from functools import reduce class Lagrange(object): dominio=[] imagem = [] resultado_numerador = [] resultado_denominador = [] temp = [] #construtor def __init__(self,tm): print("Inicio") s...
06ea2de924d733888fe13f8e0609f35db03ac7aa
w1r2p1/crypto-pair-search-engine
/crypto_pair_search_engine.py
2,528
4.3125
4
import cryptowatch as cw # Asks user to input a trading pair they would like to search # Think about whether they will enter the entire name or the 3-letter ticker # Will eventually need this to be a dropdown list with search pair1_currency1 = input('Enter the abbreviation for the 1st currency of the 1st trading pai...
21e29fa1afe44ffcd4bb274b8882335d671d267b
bodii/test-code
/python/python-cookbook-test-code/7 section/12.py
4,080
3.796875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ Topic: 第七章:函数 Desc: 使用 def 语句定义函数是所有程序的基础。本章的目标是讲解一些更加高级和不 常见的函数定义与使用模式。涉及到的内容包括默认参数、任意数量参数、强制关键 字参数、注解和闭包。另外,一些高级的控制流和利用回调函数传递数据的技术在这 里也会讲解到。 Title; 访问闭包中定义的变量 Issue:你想要扩展函数中的某个闭包,允许它能访问和修改函数的内部变量。 Answer: 通常来讲,闭包的内部变量对于外界来讲是完全隐藏的。但是,你可以通过编写访 问函数并将其作...
5ad92eb7c97e913b947092519fa6b3faccbfdf3f
Minakshi-Verma/Intro-Python-II
/src/item.py
663
3.921875
4
class Item: def __init__(self, name, description): self.name = name self.description = description #create instances of class Item item_1 = Item('key', 'You can open the treasure box!') item_2 = Item("sword", "You can kill the monsters!") item_3 = Item("flashlight", "You can see in the dark") ite...
c67628e5ed8ab483de84d6f3b58a3df8df7c9ca0
eronekogin/leetcode
/2020/longest_increasing_path_in_a_matrix.py
1,488
4.0625
4
""" https://leetcode.com/problems/longest-increasing-path-in-a-matrix/ """ from typing import List class Solution: def longestIncreasingPath(self, matrix: List[List[int]]) -> int: if not matrix or not matrix[0]: # Empty matrix. return 0 R, C = len(matrix), len(matrix[0]) me...
0c1543ef06f262abfc38b6ba403db391fa64f4f6
tpracser/PracserTamas-GF-cuccok
/week-03/day-3/06a.py
404
4.34375
4
# create a function that takes a list and returns a new list that is reversed list = [2, 6, 8, 4, 10, 7] def newList(lista): new_list = [] print("The original list:", lista) for i in range(len(lista)): lastPosition = len(lista)-1 new_list.append(lista[lastPosition]) lista.remove(li...
9b422733fd6b4342546b16d7b8344fdbc9d97fc8
chr1sM/Programacao
/Ficha 4 (Entregar)/Ex 2.py
687
3.890625
4
#1 euro = 1.2323 dolar dolar = 1.2323 #1 dolar = 0.81148 euro euro = 0.81148 print('Conversao de Euro(€) para Dolar($) ou Dolar($) para Euro(€)') print('Introduza o valor e o caracter. ') valor = float(input('Introduza o valor: ')) caracter = input('Escolha o caracter que queira E ou D: ') def conversao(valor, caract...
b5c442809a7a218bdff857ae6f63c9a8224605ad
praveen5658/cspp1
/cspp1_practise/cspp1-assignments/m6/p3/digit_product.py
660
3.859375
4
''' Author :Praveen Date : 04-08-2018 ''' def main(): ''' THis function prints the product of digits in the given number ''' int_input = int(input()) if int_input == 0: print(int_input) else: fl_ag = 0 if int_input < 0: fl_ag = 1 int_input = abs(in...
0938686867e8f3011b30682a1a68b92afba4320e
poparrish/AutoDock
/Rotation_Matrix/calc_pose.py
789
3.5
4
import math def calculate_translation(y_theta, z_dist, approach_dist): """ Returns the translation vector needed to reach the "approach point" (rad, dist) :param y_theta: rotation of platform (rad) :param z_dist: distance to platform (cm) :param approach_dist: desired distance in front of platform...
44d076f38a1a4acc1b338abf50b9d02d8e461907
mariamhayrapetyan/Sudoku_AI_Diff_Search_Algorithms
/CSP.py
6,577
3.578125
4
import itertools rows = "123456789" cols = "ABCDEFGHI" class Sudoku: def __init__(self, grid): self.variables = list() self.variables = self.generate_variables() self.domains = dict() self.domains = self.generate_domains(grid) global_constraints = self....
621e565e4f87ed43f7161fed09e40872fe051398
sanketc029/python_assi2
/Assi_2/assignment2_5.py
283
4.03125
4
def prime(no): cnt=1 for i in range(2,no): if no%i==0: cnt=0 break if cnt == 1: print("Number is prime") else: print("Number is not prime") print("Enter the number") no=int(input()) prime(no)
ee3125537d60fccede81f704729fb3889d0f17de
sainathurankar/Python-programs
/InsertionSort.py
310
4.125
4
def InsertionSort(arr): l=len(arr) for i in range(1,l): key=arr[i] j=i-1 while j>=0 and arr[j]>key: arr[j+1]=arr[j] j=j-1 arr[j+1]=key arr=list(map(int,input("Enter array: ").split())) InsertionSort(arr) print("Sorted Array:",*arr)
56f84ee9f7bc86723e50cc8a3fb949a3a6637795
jdwestwood/algorithms_pt2
/HWwk3_prob1_knapsack.py
1,963
3.703125
4
# Algorithms Pt2 HW 3 problem 1 9/19/2013 # # File format is: # [knapsack_size][number_of_items], followed by [value1][weight1] ... , one item per line # Maximum value of items in knapsack, subject to total weight <= knapsack size # # see slides-dp-algo2-dp-knapsack.pdf's from lecture notes # 9/26/13: ran progr...
5570b28b00245d5c3a3cbefa2882b218dcde94ee
oneshan/Leetcode
/accepted/013.roman-to-integer.py
982
3.828125
4
# # [13] Roman to Integer # # https://leetcode.com/problems/roman-to-integer # # Easy (45.22%) # Total Accepted: # Total Submissions: # Testcase Example: '"DCXXI"' # # Given a roman numeral, convert it to an integer. # # Input is guaranteed to be within the range from 1 to 3999. class Solution(ob...
d3dcb43a7fa8e193bc5364d6f016e6a7ca188465
fascarii/Projetos-Python
/Curso em vídeo - Python/Exercícios/cev_ex026.py
909
4.125
4
# contando número de aparições de uma letra sem acento # não consegui fazer sozinho texto = str(input('Digite seu texto:\n')).strip().lower() #conta quantas vezes a letra aparece contagem_a = texto.count('a') #localiza a posição a partir do começo da frase, depois pelo fim prim_a = (texto.find('a')+1) ult_a = (text...
6292f47843616d7c476fa4898c81772620a4b161
9Echo/gc-goods-allocation
/app/test/test_json.py
897
3.515625
4
import json class Customer: def __init__(self, name, grade, age, home, office): self.name = name self.grade = grade self.age = age self.address = Address(home, office) def __repr__(self): return repr((self.name, self.grade, self.age, self.address.home, ...
d79fc10d6e4f2741d94c0a847b2fa4d8b939ff28
eireneapostol/codeadvent
/day7/code2.py
5,663
3.8125
4
''' --- Part Two --- The programs explain the situation: they can't get down. Rather, they could get down, if they weren't expending all of their energy trying to keep the tower balanced. Apparently, one program has the wrong weight, and until it's fixed, they're stuck here. For any program holding a disc, each progr...
124ca339577cf68b84fd5e4dbf666f4dd3e2b568
chudierp/stacksandqueues
/stacks/stack.py
341
3.78125
4
class Stack: def __init__(self): #CREATE AN EMPTY stack #put the front at index 0 #back at index n - 1 self.my_stack = [] def enstack(self, item): self.my_stack.append(item) def destack(self, item): self.my_stack.pop(0) def peek(self, item): re...
bfd721addfc2915b3a08754547cc9f8ac7163eb5
rakeshvar/Lekhaka
/telugu/splitglyph.py
536
3.8125
4
import re pattern = re.compile(r'([క-హ]|్[క-హ]|[ా-్])') def akshara_to_glyphs(akshara): if akshara[-1] in "ృౄౢౣ": return akshara_to_glyphs(akshara[:-1]) + [akshara[-1]] elif len(akshara) <= 2: return [akshara] elif akshara[1] == "్": parts = pattern.findall(akshara) if ...
8142c2460a3c997838fad6b2959135420be9b602
JefterV/Cursoemvideo.py
/Exercícios/ex075.py
612
3.90625
4
num = (int(input('Numeor inteiro: ')), int(input('Numeor inteiro: ')), int(input('Numeor inteiro: ')), int(input('Numeor inteiro: '))) print(f'O numeros digitados foram: {num}') print(f'O numero 9, foi digitado {num.count(9)} vezes') if 3 in num: print(f'O valor 3, apareceu na posição {num.inde...
db0617dadb2166b737ba83b2de4504e6f73530ff
soultalker/gaoyuecn
/Python123/format.py
251
4.125
4
age = 20 name = 'Swaroop' print('{0} was {1} years old when he wrote this book'.format(name,age)) print('{:.3f}'.format(float(age)/3)) print('{name} wrote {book}'.format(name='Swaroop',book='A Byte of Python'),end='/') print('{:_^11}'.format('hello'))
af45ba17d4be17b325ebfa292b88b8c84b6e027a
roshangardi/Leetcode
/70. Climbing Stairs.py
2,085
4.28125
4
# I didn't understand why this solution of fibonacci method works. # Update: I finally understood when I traced the recursion tree diagram from bottom up from typing import List """ The problem seems to be a dynamic programming one. Hint: the tag also suggests that! Here are the steps to get the solution incrementally...
f30627e838410b236e552589ebca6c5afb52a553
jesssyb/PythonYear2
/3.4/3.4.py
1,890
3.953125
4
#Jessica #Continents def infile(): op = open("Continent.txt",'r') l = [] for x in op: l.append(x.rstrip()) op.close() l2 = [] for x in range(len(l)): split = l[x].split(',') app = l2.append(split) for x in range(len(l2)): l2[x][2] = eval(l2[...
fd896458e66fceca47a79b19c9956799f4e5d26b
indurkhya/Python_PES_Training
/Ques49.py
691
4.09375
4
# Write a program to perform following file operations # a) Open the file in read mode and read all its contents on to STDOUT. # b) Open the file in write mode and enter 5 new lines of strings in to the new file. # c) Open file in Append mode and add 5 lines of text into it. fo = open("firstFile.txt","r") print(...
72c12f538fbd1b2b32e317d90e941a3c3c652770
yuriarthurf/Python-semana-3
/parte2 - 8.py
284
3.796875
4
def funcao(j): return j + 1 list = [] n = 0 while n != 'sair': list.append(n) n = input("Digite os elementos da lista. Digite 'sair' para sair: ") list.pop(0) def my_map(list, f): for i in list: print(i) print(my_map(list, funcao(10)))
66750243e6f40e42a16fb063deff84a763aa354a
Alejandro-C/aprendiendo.py
/4-tipos_de_datos_complejos.py
930
3.875
4
# TUPLAS miTupla = (1, 'a', 3, 'e', 5, 'i', 7, 'o', 9, 'u') print(miTupla) # Un elemento de la tupla print(miTupla[2]) # Una seccion de la tupla print(miTupla[2:6]) # Otra forma de acceder a los elemtosde la tupla print(miTupla[-1]) # LISTAS miLista = [1, 'a', 3, 'e', 5, 'i', 7, 'o', 9, 'u'] print(miLista) # Un elemen...
8acf366a767976cdfd3a3fb5ea7d04eafaaf1705
Shubham8037/Project-Euler-Challenge
/Problem 1 - Multiples of 3 and 5/Problem_1.py
1,090
4.4375
4
#!/bin/python3 """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below the provided parameter value number """ def solLogic(multipleOf, actualRange): # Range is updated since problem ...
18c3e41d36fc4b1a9850fe1c744251bf74d54080
YaniLozanov/Software-University
/Python/PyCharm/04.Complex Conditional Statements/06. Point on Rectangle Border.py
2,537
4.34375
4
# Problem: # The fruit shop during the working days works at the following prices: # fruit: banana apple orange grapefruit kiwi pineapple grapes # price: 2.50 1.20 0.85 1.45 2.70 5.50 3.85 # Saturday and Sunday the shop runs at higher prices: # fruit banana apple orange gra...
4ecdd7bcaa012faeab67757349af33f333a181f3
Westopher/pythonHelloWorld
/hello.py
4,920
4.15625
4
""" print("hello world") print("test") print("saving?") age = 20 name = 'West' print(f'{name} was {age} years old when he wrote this book') sport = "soccer" skill = "nutmeg" print(f"West is so nice at {sport}, he {skill}s people all the time") """ """ i = 5 print(i) i = i + 1 print(i) multiLineString = '''Thi...
acd62fe871c3f5649cb573f8ac764f552dc7ba47
brainhackerbrain/pythonlessons
/1.py
172
3.671875
4
#!/usr/bin/python # -*- coding: utf-8 -*- a=2 b="bbb" print("Введите переменную с ") c=input() print ("a="+str(a)) print ("b="+str(b)) print ("c="+str(c))
c5a08065910567971f3a1adf7932df03148750f3
Calebp98/project-euler
/45.py
852
3.6875
4
'''Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ... Pentagonal Pn=n(3n−1)/2 1, 5, 12, 22, 35, ... Hexagonal Hn=n(2n−1) 1, 6, 15, 28, 45, ... It can be verified that T285 = P165 = H143 = 40755. Find the next triangle number that ...
6d14606ae8e228ab3c6fd0319e9a999e9379c178
MirzaTabassum/Python
/sharpen.py
1,514
3.78125
4
""" File: sharpen.py Project 7.10 Defines and tests a function to sharpen an image. """ from images import Image def sharpen(image, degree, threshold): """Builds and returns a sharpened image. Expects an image and two integers (the degree to which the image should be sharpened and the threshold used to ...
22bddaead4e16d572f589bfbcd44fa06779ddc72
mothermary5951/videau
/dumpversion_hashmap.py
7,612
4.125
4
def new(num_buckets=256): # creates a new function with the potential for 256 (2 to the 7th) containers """Initializes a Map with the given number of buckets.""" # python uses 'map' instead of 'dictionary' aMap = [] ...
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...
5d5ffa14450b6724bde4a5956e6edd129326e2b7
muokiv/The-Art-of-doing-40-challenges
/2_Miles_Per_Hour_Conversion_App.py
269
3.71875
4
# -*- coding: utf-8 -*- """ Created on Fri May 15 15:02:06 2020 @author: mitta anand """ print("Welcome to Miles Per Hour Conversion App.") n=float(input("Enter speed in Miles per Hour: ")) a=n*0.4474 res=round(a,2) print("Speed in meters per second is:",res)
e56008a3f8d13e17098bdc74ccf21deef99e39a9
CAgAG/Arithmetic_PY
/lanqiao/2013_java_/世纪末的星期.py
849
3.53125
4
import datetime """ 标题: 世纪末的星期 曾有邪教称1999年12月31日是世界末日。当然该谣言已经不攻自破。 还有人称今后的某个世纪末的12月31日,如果是星期一则会.... 有趣的是,任何一个世纪末的年份的12月31日都不可能是星期一!! 于是,“谣言制造商”又修改为星期日...... 1999年的12月31日是星期五,请问:未来哪一个离我们最近的一个世纪末年(即xx99年)的12月31日正好是星期天(即星期日)? 请回答该年份(只写这个4位整数,不要写12月31等多余信息) """ if __name__ == '__main__': ...
a06b5c8ef0c896ace8cc51cfb544966455753eee
EggheadJohnson/SmallerProjects
/Python/stupidgame/stupidgame.py
6,952
4
4
# 2048 is a very popular game. Countless variations have been created around it. Many students # lost class time to trying to achieve a highscore. I was curious as to whether it would be # possible to get to 2048 randomly. It's not. This program is designed to run a Monte Carlo # simulation of the game as many tim...
2785e4f30e27211e413b7ae887876e374d67100f
Tong-Ou/MC-and-Jet-Tutorial
/practice2.py
1,025
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 30 20:02:12 2018 @author: Tong Ou """ import numpy as np import numpy.random as random import matplotlib.pyplot as plt n_points=1000 def gauss(x,mu,sigma): t=1/np.sqrt(2*np.pi*sigma**2)*np.exp(-(x-mu)**2/(2*sigma**2)) return t #Generate random n...
848cd55a7e132cc05310fef0e64620c7c9ccc6d1
florencevandendorpe/Informatica5
/06 - condities/Risk.py
674
3.734375
4
#invoer a = float(input('het aantal ogen van aanvaller 1: ')) b = float(input('het aantal ogen van aanvaller 2: ')) c = float(input('het aantal ogen van aanvaller 3: ')) d = float(input('het aantal ogen van verdediger 1: ')) e = float(input('het aantal ogen van verdediger 2: ')) #sorteren f = max(a, b, c) g = max(d, e...
d8c352576730947a91b69909177985cc0afb9dee
devaljansari/consultadd
/3.py
655
3.5625
4
import datetime currentDT = datetime.datetime.now() print (str(currentDT)) print ("Current Year is: %d" % currentDT.year) print ("Current Month is: %d" % currentDT.month) print ("Current Day is: %d" % currentDT.day) print ("Current Hour is: %d" % currentDT.hour) print ("Current Minute is: %d" % currentDT.minut...