blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3614f09c9a9c189e04eaddd259a306671d5e4835
netraf/skillbox-phyton
/10.py
187
3.515625
4
def salary(hour_cost, day_quantity): total = (hour_cost * 8) * day_quantity final = total - (total*.13) return final a = salary(600, 2) b = salary(1200, 6) print(a, b)
eee5215ed117d58ca22f9d58b4c19499a2443546
fagan2888/leetcode_solutions
/accepted/Median_of_Two_Sorted_Arrays.py
871
3.65625
4
## https://leetcode.com/problems/median-of-two-sorted-arrays/ ## almost feels like cheating since python's standard library ## provides a way to merge two sorted lists using heaps under ## the hood, so we do that then figure out where to index to ## get our median. ## comes in at 64th percentile in runtime and 61st...
c885df85b495b97830552bd6fd1c7835523ef989
logancyang/lintcode
/biSearch/searchInsertPosition.py
1,091
4.09375
4
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume NO duplicates in the array. Example [1,3,5,6], 5 -> 2 [1,3,5,6], 2 -> 1 [1,3,5,6], 7 -> 4 [1,3,5,6], 0 -> 0 """ class Solution: """ @pa...
f3df13e8ea8e22ba3ab41ab851de12e81cc16088
wszy5/snake_game
/snake.py
1,581
3.6875
4
from turtle import Turtle UP = 90 DOWN = 270 RIGHT = 0 LEFT = 180 STARTING_POSITIONS = [(-20, 0), (-40, 0), (-60, 0)] class Snake: def __init__(self): self.turtles = [] self.create_snake() self.move() def create_snake(self): for position in STARTING_POSITIONS: self...
b23b7f7defeea82863198c9d7d4f09ce03625988
miri114/MyPyPrograms
/scoop.py
871
4.15625
4
class Scoop(): def __init__(self, flavor): self.flavor = flavor """ This function is to create and print instances of class scoop""" # def create_scoops(): # scoops = [Scoop('chocolate'), # Scoop('vanilla'), # Scoop('persimmon')] # # for scoop in scoops: # print...
d7270da9e7e6154ca0b40aa16c44a2a6749a760a
therealmikkelw/automate-the-boring-stuff
/examples/writeExcel_example.py
631
3.75
4
import openpyxl, os # Using Workbook() method to create a new workbook object wb = openpyxl.Workbook() # List sheet names # wb.get_sheet_names() # Access sheet object sheet = wb['Sheet'] # .get_sheet_by_name('Sheet') # Assign values to cells sheet['A1'] = 42 sheet['A2'] = 'Hello' # Using create_shee...
7f378b4f56867b9cfe8f6587ddb85409f01bfd6b
wangyiwen9956/ichw
/wcount.py
1,533
3.546875
4
#!/usr/bin/env python3 """wcount.py: count words from an Internet file. __author__ = "WangYiwen" __pkuid__ = "1700011805" __email__ = "wangyiwen@pku.edu.cn" """ import sys from urllib.request import urlopen def wcount(lines, topn=10): dic={} for i in """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""": lines2...
41ced65cc4a2b0dce8e29947e10199bff086d970
ahadahmedkhan/Solution
/chapter6/ex 6.3.py
648
3.796875
4
glossary={ 'string':' A series of character.', 'comment':' A note in a program that the interpreter ignores.', 'list':' A collectiiion of item in a particular order.', 'loop':' Work through colection of items, one at a time.', 'dictionary':'A collection of key-value pair.', } word='string...
30dee2de70599c0c6aea3144e58a051fc02acdc1
prometheus61/lpthw
/ex5.py
622
3.84375
4
name = 'Zed A. Shaw' age = 35 # not a lie height = 74 # inches weight = 180 # lbs eyes = 'Blue' teeth = 'White' hair = 'Brown' print ("Let's talk about %(name)s. who is %(height)d inches tall" % ({'name':'Zed Shaw' , 'height':79})) print "He's %x inches tall." % height # hexadecimal values print "He's %o pounds heavy....
977323d5ae000f17564de518faefd9f5371eae80
shrenik77130/Repo5Batch22PythonWeb
/#8_PythonList/ListEx1.py
388
4.1875
4
#WAP to demonstrate Python List colors = ['red','orange','blue','white','black','blue'] print(colors) print("First Color = ",colors[0]) print("Second Color = ",colors[1]) print("Last Color = ",colors[-1]) print("First Two Colors :",colors[0:2]) #Ass: create list of numbers. and print last two numbers numbers = [1...
0492d3c7fd7fec5725f9914d06e7eb0431773d79
daniel-reich/ubiquitous-fiesta
/nC7iHBbN8FEPy2EJ2_19.py
490
3.71875
4
class Rectangle: ​ def __init__(self, sideA=0, sideB=0): self.sideA = sideA self.sideB = sideB ​ def getArea(self): return self.sideA * self.sideB def getPerimeter(self): return 2 * (self.sideA + self.sideB) ​ class Circle: import math def __init__(self, radius): self.radius = radius ...
bf512b9bffdaaa3e61dbe674f05bfaaab92f7fdf
Sw4b3/DatabaseConnection
/DatabaseConnection/DatabaseConnection/DatabaseController.py
2,351
3.609375
4
import mysql.connector class DatabaseController(object): def getConnection(self): connection = mysql.connector.connect( host="localhost", user="root", passwd="", database="StudentDB" ) return connection def viewStudent(...
72bc3701fa9389270beb3391f7b7270a7b012e1d
anantbarthwal/python_codes
/scope.py
72
3.515625
4
a=20 def sum(a): a=a+1 b=20 print(a) sum(a) print("a=",a)
42ba465fc5760c8ec85443ea1d48288fef9980fc
6660-Kp/cs1026
/ass2/main.py
5,283
3.9375
4
"""" Name: xinhe xia ASSIGNMENT 2 """ import volume #import a math function ac=[] #create a list name ac ap=[] #create a list name ap ae=[] #create a list name ae gg=1 while gg==1: #while gg is equal to 1 do the thing below ...
ce798b1cf4dcd27d958da4941de35dbd23ea1aae
ajay-02/codevita_gamified
/level 3/fibonacci_tri.py
381
3.84375
4
def Hosoya( n,m): if((n==0 and m==0)or(n==1 and m==0)or(n==1 and m==1)or(n==2 and m==1)): return 1 if n>m: return Hosoya(n-1,m)+Hosoya(n-2,m) elif m==n: return Hosoya(n-1,m-1)+Hosoya(n-2,m-2) else: return 0 def printHosoya(n): for i in range(n): for j in range(i+1): print(Hosoya(i,j),e...
90e438c46ad170d15dd778eb7a629ca65887e1f6
felipevalentin/livraria
/livraria_classes.py
1,639
4
4
""" Classes para um sistema de biblioteca, podendo ser criado um usuário e 4 tipos de livros, sendo um deles chamado Generico que é utilizado como modelo para as heranças das outras 3 """ class Usuario: """ Cria um usuário com nome e senha pro sistema de livraria """ def __init__(self, nome, senha): ...
d4ab6d5c530c524ca378c4e3fe3337152e4decbf
iqballhafizi/pywinda
/ForDocumentation/docs/PyWinda/pywinda.py
21,312
3.625
4
import numpy as np import pandas as pd def cAngle(i): x=i % 360 return x class environment: """ Creates the stand-alone environment with the given unique ID. Some generic conditions are added by default. See example below. :param uniqueID: [*req*] the given unique ID. :Example: ...
68afd9a53163b91642f9c0c44fd2c8155b262382
neelamy/InterviewBit
/Hashing/fourSum.py
2,358
3.796875
4
# Source : https://www.interviewbit.com/problems/4-sum/ # Given an array S of n integers, are there elements a, b, c, and d in S such # that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. # Algo/DS : Hashing # Complexity :O(n^2) from collections import defaultdict cl...
c76d4b500fc0602be09b117ece7c31e879342fec
tocarmeli/LeetCode
/easy/palindromeNum.py
358
3.828125
4
# https://leetcode.com/problems/palindrome-number/ # Question 9: Palindrome Number class Solution: def isPalindrome(self, x: int) -> bool: concatenatedNum = str(x) palindrome = concatenatedNum[::-1] if (palindrome == concatenatedNum): return True return False test = S...
d7d321c4eee9a5ebc2bf830145b6d01e42f6ce76
lukasz-kolodzinski/backpack
/backpack.py
1,116
3.78125
4
#Simple two-players game. Player has to guess what is hidden in his mate's backpack. players = [] for x in range(2): players.append({ 'user':'', 'points':0, 'backpack':[] }) players[x]['user'] = input('Provide name for player ' + str(x + 1) + ': ') print('Enter 4 things that you...
2e8e0ae56a87e7201d7701e497840c65d25c0617
sabdulmajid/Beginner-Python-Programs
/Multiples-CL.py
1,712
3.96875
4
# Multiples-CL.py # Question 1: # With FOR Loop: number = int(input('Enter a number, for which the first ten multiples of the number: ')) for counter in range(1, 11): multiple = counter * number print(number,'x', counter,'=', multiple) # With WHILE Loop: number = int(input('Enter a number, for...
819165f4d7b4e64a6328ba60e0d776d8fb49c7a4
realbigws/From_CA_to_FullAtom
/modeller9v8/modlib/modeller/util/matrix.py
756
4.09375
4
"""Utility methods for handling matrices""" def matrix_to_list(matrix): """Flatten a 3x3 matrix to a 9-element list""" lst = [] if isinstance(matrix, (list, tuple)) and len(matrix) == 3: for row in matrix: if isinstance(row, (list, tuple)) and len(row) == 3: lst.extend(r...
1594a5e8aeb3ebab28d7756d94e99f6714001220
ogbr/homework
/webinar1/1_1.py
274
3.578125
4
login = input("Введите логин") print(login) password = input("Введите пароль") print(password) sum=float(input("Введите сумму к оплате")) print (f"Ваша сумма к оплате с комиссией {sum+0.1*sum:0.2f}")
aef3b5a8f43ba3dc1c77ed21478315dcc08cb6b3
geffenbrenman/Link-a-Pix-AI-final-project
/Project/xml_parser.py
2,373
3.609375
4
import xmltodict def get_xml_from_path(path): """ Create dictionary with the following items: name - Puzzle name width - Puzzle width height - Puzzle height colors - List of RGB values [str] paths - dictionary where the keys are the colors and the values are lists of lists o...
34a84f3f1a24b655fdfe4a75fb6f49a7cb257074
Izzyrael/PythonLibrary
/01_Fundamentals/16_Inheritance_And_Polymorphism.py
2,386
4.78125
5
# Inheritance is how we can create a 'parent-child' relationship with our classes # imagine having a class that already has properties that we don't declare because they come from our 'parent' class # python allows us to do this # lets make an 'animal' class class Animal: def speak(self): return "I'm an ...
583d8a0f0a0359c17d2aa6fa4f2ad0039a25bca7
OneNobleGnome/exercises
/chapter-5.2/test_ex_5_13.py
490
3.546875
4
from ex_5_13 import find_falling_distance import unittest class TestFallingDistance(unittest.TestCase): def test_one_second(self): expected = 4.9 actual = find_falling_distance(1) self.assertEqual(expected, actual) print(find_falling_distance(1)) def test_zero_seconds(self...
33c7fef0696c9f7dc6bca36c280c5cc09b19d8e2
crizer03/Python
/1 - inheritance.py
1,570
4.28125
4
# Types of inheritance # Single A > B class A: pass class B(A): pass # Multi Level A > B > C class A: pass class B(A): pass class C(B): pass # Hierarchical A > B, A > C class A: pass class B(A): pass class C(A): pass # Multiple A > C, B > C class A: pass class B: pass clas...
c5140f7120d1527e1f968aa6ab7e6be092ee86ef
vins-stha/hy-data-analysis-with-python
/part03-e14_operations_on_series/src/operations_on_series.py
513
3.71875
4
#!/usr/bin/env python3 import pandas as pd def create_series(L1, L2): #print(L1,L2) indices = ['a','b','c'] s1 = pd.Series(L1, index =indices) s2 = pd.Series(L2, index =indices) return (s1, s2) def modify_series(s1, s2): s1["d"] =s2["b"] del(s2["b"]) return (s1, s2...
ff0986c0f907c2f6b425913b877f51ca4d972d10
anmolrajaroraa/core-python-july
/01-functions.py
453
3.75
4
# def fn_name(param1, param2, ..., paramn): # statement1 # statement2 # return statement def inputNumbers(): a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) c = int(input("Enter third number: ")) return a, b, c, 13, 34, 5, 3, 2, 99, 33 # packing *x, y = i...
fae1b6fbbc7ab1af258ae2f70b5887d452dff591
snowraincloud/leetcode
/529.py
1,165
3.65625
4
from typing import List class Solution: def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]: if not board: return board l = len(board) w = len(board[0]) points = [] points.append((click[0], click[1])) while points: ...
b1f6801705c66bb334c2ebb1ef3749301164d12b
VladislavJanibekyan/py_home
/git_class.py
1,385
4.25
4
class Car: #class Car(): class Car(object): brand = "BMW" year = 2019 color = "red" def presentation(self): return self.brand, self.year, self.color bmw = Car() bmw.brand = "bmw" mercedes = Car() mercedes.brand = "mercedes" print(bmw.presentation()) print(mercedes.presentation()) print(Car.pre...
40e8409c8f0d6b675c49bb7fc0024443237ca354
Robertzzz123/Python-labs
/Lab 5/Lab 5.py
1,971
3.75
4
import math class Fraction: """Находим сумму сложения двух дробей""" def __init__(self, n, d): self.num = int(n / self.gcd(abs(n), abs(d))) self.denom = int(d / self.gcd(abs(n), abs(d))) if self.denom < 0: self.denom = abs(self.denom) self.num = -1 * self.num ...
eaea60dee33f86ac9274031ad8c0f09412724f64
portugol/decode
/Algoritmos Traduzidos/Python/Algoritmos traduzidos[Filipe]/ex2.py
114
3.53125
4
lado = input('Medida do lado do quadrado: ') area=int(lado)*int(lado) print('A area do quadrado é:',area)
6e7468ba558528ca36e8f38dac2d8c1b42447331
plume-n/plume
/python/Day04_20180821_najw.py
1,134
3.703125
4
#task 1 排序 a = [1,2,3,4,5,6,7,8,9] a.reverse() print('task1 逆序操作:') print(a) #学生管理系统 print('\ntask2 学生管理系统:') person_list = [] num = 1 str_in = input('学生管理系统:\ \n 1.新增学生\ \n 2.查找所有学生\ \n 3.根据学号查找学生\ \n 4.根据学号删除学生\ \n 5.退出\ \n 请输入序号操作:') while str_in != '5': if str_in == '1': person = {'number':'','name':'',...
bef52cebe93d0c16f662501fee9a5f1182cf8e4c
ethanwllms/QC-Project
/QC-Pi/createDirectory.py
743
3.546875
4
import os import datetime def findCurrentYear(): now = datetime.datetime.now() return str(now.year) def createDIR(directory): if not os.path.exists(directory): os.makedirs(directory) elif os.path.exists(directory): print("Directory (" + directory + ") already exists") pass else: print ('Error: Crea...
40db7eafe46899cd31c47c81983117345ff600ba
616049195/random_junks
/random_games/magic/Magic.py
865
3.84375
4
""" # credit goes to: HK # created on 2014.08.17 # status: semi-done """ from random import randint class Magic(object): """ does the magic""" number = 0 ran_num = 0 def intro(self): print "\nChoose a number between 1 and 10." wait = True while (wait): if raw_input("Once you are done, enter \"YES\": ...
ce9e901fdc32770c1ba7cea4a074f2ecd8abcd06
m-lair/Projects
/lair-project-6.py
4,846
3.890625
4
from tkinter import * import math class TipCalculator: def __init__(self): window = Tk() window.title("Tippity Split") Label(window, text = "Tippity Split - Tip Calculator", fg = "Red").grid(row = 1, column = 1, ...
2bc2912ce3a782156edff88c3f159fb376587883
kmark1625/Project-Euler
/p9.py
499
4.09375
4
import itertools def pythagorean_generator(): #Generates a pythagorean triplet sets = itertools.combinations(range(500),3) while True: a, b, c = next(sets) if (a**2 + b**2 == c**2): yield (a,b,c) def find_1000(): a,b,c=0,0,0 sets = pythagorean_generator() while (a+b+c) < 2000: a,b,c = next(sets) prin...
f9244a1d2f2aa6a2b60b16845558444ac9f025fb
Artificial-Ridiculous/Codes
/Python/leetconde-cn/二叉树遍历.py
1,206
3.78125
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None n5 = TreeNode(5) n3 = TreeNode(3) n6 = TreeNode(6) n2 = TreeNode(2) n4 = TreeNode(4) n1 = TreeNode(1) n5.left = n3 n5.right = n6 n3.left = n2 n3.right = n4 n2.left = n1 def bfs(root:TreeNode): p = r...
47353d7ef1d34872e0a0404005e010f42d95febb
dilaraism/-solutions
/codewars/python/simple_pig.py
255
3.828125
4
def simple_pig(s): from string import punctuation sp = lambda x: x[1:]+x[0]+"ay" if x not in punctuation else x return " ".join([sp(i) for i in s.split(" ")]) print simple_pig("Quis custodiet o ipsos custodes ?") print simple_pig("Pig latin is cool")
8afc2cbfaf63b6b6c34ecc49bf16b027b164f245
saurabh-pandey/AlgoAndDS
/leetcode/queue_stack/stack/clone_graph.py
2,795
3.625
4
#URL: https://leetcode.com/explore/learn/card/queue-stack/232/practical-application-stack/1392/ #Description """ Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. class Node { ...
a3775466d520e001307f4a23a1c1d63d7286be97
Software05/Github
/Modulo-for/app3.py
487
3.875
4
palabraSinVocal = "" # Indicar al usuario que ingrese una palabra userWord = input('Ingrese la palabra: ') # y asignarlo a la variable userWord userWord = userWord.upper() for letra in userWord: if letra == 'A': continue if letra == 'E': continue if letra == 'I': continue if l...
f8f65452d503b6a3238e0875512e5c236cf07cb3
agw2105/TravelingSalesman
/TravelingSalesmanProblem.py
5,332
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 14 11:21:55 2020 @author: alysonweidmann """ import math import random from collections import deque """ """ def dist(xy1, xy2): """ Calculate the Euclidean distance between two points. """ # TODO: Implement this function! x1 = ...
7f6afb0ce1f96358fff33def93b1e184bf8e9705
Cryptoriser7/Curso-emVideo-Python
/calculadora_941.py
1,364
3.765625
4
from time import sleep print() sleep(0.5) print('Calculadora Automatica de Produção\nReferencia 941') print() print() sleep(0.5) print('Insira valores de produção:') sleep(0.5) p = int(input('Paletes Completas: ')) b = int(input('Palete Incompleta: ')) df = int(input('Sucata Fundição: ')) dm = int(input('Sucata Maquin...
f382b1aa3321904463b3332ef202e256ff66174c
Viccari073/exercises_for_range_while
/exer_estruturas_de_repeticao_28.py
404
3.84375
4
""" Faça um programa que leia um valor N inteiro e positivo, calcule e mostre o valor E, conforme a fórmula a seguir: E = 1 + 1/1! + 1/2! + 1/3! + 1/4!...+1/N! """ from math import factorial num_final = int(input("Digite o termo final da sequência fatorial: ")) soma = 1 for n in range(1, num_final + 1): ...
086dd5d4943aff5a4fb82453c43f9ea5bd23b73a
vanigupta20024/Programming-Challenges
/SpiralOrderMatrix1.py
1,137
3.765625
4
''' Given a matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order. ''' class Solution: # @param A : tuple of list of integers # @return a list of integers def spiralOrder(self, A): top = 0 bottom = len(A) left = 0 right = len(A[0]) di...
9ea00a56132a55089ca8ce9b639083de94c62522
cbiswajeet89/Face-Detection-App
/face_detection.py
1,000
3.5625
4
import cv2 #Pre-trained faces trained_face_data=cv2.CascadeClassifier('haarcascade_frontalface_default.xml') #reading image #img=cv2.imread('mypic.png') #To capture video from webcam webcam=cv2.VideoCapture(0, cv2.CAP_DSHOW) # 0 value takes the default cam in the system #Iteration over frames while True: successful...
da2f006a1a30c07f42bf0eb8ed54bf1a0796f06a
ErenBtrk/Python-Fundamentals
/Numpy/numpy-exercises18.py
246
4.25
4
# 18- Calculate squares of the elements of the matrix in exercise 9 import numpy as np np_matrix = np.random.randint(10,50,15) np_matrix = np_matrix.reshape(3,5) print(np_matrix) np_matrix_square = np.power(np_matrix,2) print(np_matrix_square)
a74f115ed3498b82488b2b6d8e46c311ad2b510e
SayarGitHub/Intermediate-Python
/9.py
3,891
4.96875
5
# The general syntax of a lambda function is quite simple: # lambda argument_list: expression # The argument list consists of a comma separated list of arguments and the # expression is an arithmetic expression using these arguments. You can assign # the function to a variable to give it a name. # The following exam...
cc091c228f488ec198a09bcfbae7bcd9e1f648ca
kyoungje/bank_atm_controller
/test.py
3,266
3.5
4
# test program for the ATM controller import atmctrl def showAccounts(): print("\n===================================\n") print("\n[ List of Accounts ]\n") account_list = atmctrl.getAccounts() for acc in account_list: print("ID: ", acc[0], ", Balance: $", acc[1], ",\t Name: ", acc[2]) pri...
aa798de6f6fa87815eb337cbd8877a63f004810f
dxc19951001/Everyday_LeetCode
/130.被围绕的区域.py
3,535
3.515625
4
from typing import List class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ # 核心思想--dfs # 由题:任何边界上的 'O' 都不会被填充为 'X'。 # 任何不在边界上,或不与边界上的 'O' 相连的 'O' 最终都会被填充为 'X'。 # 可以理解为:边...
9f1d7ebe2f906827721d5007ed4c6ab110d0999b
Fastiz/artificial-intelligence-systems
/autoencoder/encoded_graph.py
576
3.625
4
import matplotlib.pyplot as plt def read_from_file(path): file = open(path, "r") lines = file.read().splitlines() return [(float(x), float(y), letter) for x, y, letter in [line.split(" ") for line in lines]] def plot(): values = read_from_file("../data") x = [x for x, y, letter in values] y...
1f5b21f2b798ec44bb1dbf0a2af2d3c37d8a5b90
rakeshsukla53/interview-preparation
/Rakesh/graph-theory-algorithms/graph_valid_tree_cycle_find.py
994
3.8125
4
from collections import OrderedDict class Solution(object): def topological_sorting(self, graph, root): state = set() def dfs(node): if node in state: raise ValueError('Cycle') else: state.add(node) for k in graph.get(node, [])...
90c9614732fe48917627cef15a0f099a03e2ff46
JenniferDominique/Arthur_Merlin_Games
/Main.py
3,790
3.828125
4
from Merlin import * from random import randint print() print('_____________________ ARTHUR MERLIN GAMES _____________________') print() #___________________ Problema das Damas _____________________# print('....... Problema das Damas .......') print() arquivos = ['casamento.txt', 'casamento no.txt', 'ca...
360cd4c249e7685721cfeb212cdd75933f24508b
jrschmiedl/Sudoku
/SudokuSolver.py
2,227
3.828125
4
# Sudoku Solver 1.0 # @author Jacob Schmiedl puzzle = [ [7,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] # solves the puzzle...
7ebc2621de57aba29a68be3d6dacaa16ebf4c4dc
yywecanwin/PythonLearning
/day03/13.猜拳游戏.py
657
4.125
4
# -*- coding: utf-8 -*- # author:yaoyao time:2019/9/28 import random # 写一个死循环 while True: # 1.从键盘录入一个1-3之间的数字表示自己出的拳 self = int(input("请出拳")) # 2.定义一个变量赋值为1,表示电脑出的拳 computer = random.randint(1,3) print(computer) if((self == 1 and computer == 2) or (self == 2 and computer == 3) or (self == 3 an...
ffcef51cc07f551c87aa41906b41ece138dcd9e9
daniel-reich/ubiquitous-fiesta
/biJPWHr486Y4cPLnD_13.py
244
3.578125
4
def chunkify(lst, size): output=[] i=0 new_list=[] n=0 while i < len(lst): output.append([]) #print(output) for k in range(0,size): if i < len(lst): output[n].append(lst[i]) i+=1 else: break n+=1 return output
c765b63a9a589e540afec1e34b96e383f5ebc1a3
aman9924/Python-Projects
/HealthManage.py
4,050
3.84375
4
def getdate(): import datetime return datetime.datetime.now() # time= getdate() # print(time) def lock(k): if (k == 1): p = int(input("Enter 1-Exercise 2-Food:- ")) if (p == 1): value = input("Enter The Exercise:- ") with open("Aman-Exercise.txt",...
6d891f3138392da3eb552cd5228069fd0adf63fb
RaviSankarRao/PythonBasics
/11_Reading_Files.py
632
3.5625
4
# using OPEN cmd to open files # first param - File name with relative path # second param - mode # r - read, w - write, a - append, r+ - read and write employee_file = open("Employees", "r") # check if file is readable print(employee_file.readable()) # read - read the entire file # print(employee_file.read()) # ...
0d1ff287d135793de6708134ae3a804afb2d2339
naveensantu/Open_cv-Tutorial
/drawing_assesment.py
2,038
3.8125
4
# # Image Basics Assessment import numpy as np import cv2 import matplotlib.pyplot as plt #%matplotlib inline # #### TASK: Open the *dog_backpack.jpg* image from the DATA folder and display it in the notebook. Make sure to correct for the RGB order. image=cv2.imread(r"D:\Computer Vision with OpenCV and Deep Learning\C...
20c009fa3f977cbc29a33827699e78c6da08eb9f
smv5047/Sprint-Challenge--Data-Structures-Python
/ring_buffer/ring_buffer.py
1,067
3.546875
4
class RingBuffer: def __init__(self, capacity): self.capacity = capacity self.storage = [] self.buffer_pointer = 0 def append(self, item): # Is buffer at capacity? if len(self.storage) < self.capacity: self.storage.insert(len(self.storage), item) ...
d1709b74fd6754a389dc09c9429413f7479c2efc
Brienyll/python-automate
/Map.py
196
3.71875
4
def add_five(x): return x + 5 nums = [11, 22, 33, 44, 55] result = list(map(add_five, nums)) print(result) nums = [11, 22, 33, 44, 55] result = list(map(lambda x: x+5, nums)) print(result)
6d950efdfc2fd19da03b627f8a8b388929e1a011
warsang/CCTCI
/chapter2/2.3-false/deleteMiddleNode.py
804
3.734375
4
class node(object): def __init__(self,name,child): self.name = name self.child = child def main(): llist = [] f = node("f",None) e = node("e",f) d = node("d",e) c = node("c",d) b = node("b",c) a = node("a",b) llist = [a,b,c,d,e,f] deleteNode(c,llist...
75562289656f729df56a9f59fd7e0a1dbccd89d8
WaterH2P/Algorithm
/LeetCode/751-1000/836 isRectangleOverlap.py
950
3.9375
4
# 【简单】836. 矩形重叠 # 矩形以列表 [x1, y1, x2, y2] 的形式表示,其中 (x1, y1) 为左下角的坐标,(x2, y2) 是右上角的坐标。 # 如果相交的面积为正,则称两矩形重叠。需要明确的是,只在角或边接触的两个矩形不构成重叠。 # 给出两个矩形,判断它们是否重叠并返回结果。 class Solution: def isRectangleOverlap(self, rec1, rec2) -> bool: # 判断不重叠 if rec1[3] <= rec2[1] or rec2[3] <= rec1[1] or rec1[2] <= rec2[0] or ...
9a5e91177601e8939a7695be41786b7666a9e08f
weardo98/Github
/1.5.3/1.5.3.PY radius_changer.py
1,458
4.21875
4
##### # radius_changer.py # # Creates a Scale and a Canvas. Updates a circle based on the Scale. # (c) 2013 PLTW # version 11/1/2013 #### import Tkinter #often people import Tkinter as * ##### # Create root window #### root = Tkinter.Tk() ##### # Create Model ###### radius_intvar = Tkinter.IntVar() radius_intvar.s...
f4e90092c38faf6e1636c97d5da54294e6874f36
PaulKitonyi/Python-Practise-Programs
/testing_classes/Employee/employee.py
534
3.84375
4
class Employee(): """class to simulate Employees""" def __init__(self, first, last, annual_salary): self.first = first self.last = last self.annual_salary = annual_salary def give_raise(self, amount=''): self.annual_salary += 5000 amount = amount ...
d684a7e8750fa8ee27cc9f9f04cc7e7bee972688
georgePopaEv/python-exercise
/DAY5P.py
1,401
3.9375
4
# ord sa transformam din char in int # chr sa transformam din int in char # caractere speciale # start 33 ----------------Finish 129 # 33 la 47 inclusiv char special 58 la 64, 91 la 96, 123 la 128 # 48 la 57 inclusiv cifre # 65 la 90 si de la 97 la 122 litere mari si mici import random print("Bine ai venit la...
6a6d8db5763d38ccac76aadfadf5d6c1c5d83c58
stolksdorf/BGSAWorkshop
/Python/ex2.py
410
3.515625
4
import sys import csv print sys.argv #Make sure you inputed a filename if len(sys.argv) < 2: print "Must provide an input file name" sys.exit() inputFilename = sys.argv[1] dataset = csv.reader(open(inputFilename, 'rb')) for rowNumber, row in enumerate(dataset): # Don't process the first row, all the column names...
f999d2da67e27fae68bdeaedd3d53b9381a68cf8
NARMATHA-R/PYTHON-PRACTICE
/replace() .py
84
3.75
4
txt = "I like bananas" x = txt.replace("bananas", "mango") print(x) #I like mango
aa35a95f312fbd81d579618fd9cbcf0314762899
a1347539/algorithms-and-data-structure
/dataStructure/heap.py
1,886
3.5625
4
class maxHeap: def __init__(self): self.heap = [] self.size = 0 def parent(self, i): i+=1 if i == 1: return None return (i-1) // 2 def leftChild(self, i): if i * 2 > self.size: return None return i * 2 def...
b6c14b24676d59cc28dde57a96cdca5f6f498e14
skipkolch/Linear_regression
/Task_5/Task 5/featureNormalize.py
2,335
3.5625
4
import numpy as np from numpy.matlib import repmat def featureNormalize(X): """ Функция позволяет вычислить нормализованную версию матрицы объекты-признаки X со средним значением для каждого признака равным 0 и среднеквадратическим отклонением равным 1 """ X_norm = X mu =...
d72785f1a4bf7443e2563e18f31b0cfdda8cbf37
jawnbriggz/Trigrams
/trigrammer.py
2,587
3.703125
4
import re import sys import string import operator def book_parser(x): full_text = [] for line in x: # strip of punctuation and lowercase it line = line.lower() line = line.translate(str.maketrans('','',string.punctuation)) temp = line.split() full_text += temp OVERALL_LENGTH = len(full_text) return...
1e238c16531818644f8b43c98cbed109ca77ac22
LittleAndroidBunny/Python_Cheatsheet_Nohar_Batit
/Beer-sheva Ref/Excercises/e_Linked_list.py
3,936
4.15625
4
from b_ll_node import Node class LinkedList: # Why doesn't the class inherit the node class? def __init__(self, seq=None): """ Linked list init function :param seq: Use seq != none to generate a linked list from any python sequence type """ self.next = None self...
f163b69671fbd87d129be56c16749773fe145bad
shuvo14051/python-data-algo
/Problem-solving/HackerRank/p18-Mutations.py
322
3.515625
4
def mutate_string(s, position, character): li = [] result = '' for i in s: li.append(i) li[position] = character for j in li: result += j return result if __name__ == '__main__': s = input() i, c = input().split() s_new = mutate_string(s, int(i), c) print(s_ne...
66ca15e4f5a7cef6f39046deb431194e358cbbfa
rdghenrique94/Estudos_Python
/Curso_Python/Modulo2/ex042.py
632
3.875
4
def main(): print("="*30) print("Analisando Triangulos") print("="*30) r1 = float(input("Primeiro Segmento: ")) r2 = float(input("Segundo Segmento: ")) r3 = float(input("Terceiro Segmento: ")) if r1 == r2 != r3 or r1 == r3 != r2 or r2 == r1 != r3 or r2 == r3 != r1 or r3 == r1 != r2 or r3 ...
2ea32c0747ce15b2a5e2069ef54a8b7212f6c939
prajwalccc13/Hacktoberfest2020
/vigenere.py
386
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: darshasawa """ phrase = input("Please enter the phrase: ") key = input("Enter the key: ") phrase = phrase.upper() key=key.upper() key_length = len(key) encrypt_phrase = "" for i in range(len(phrase)): value =(ord(phrase[i])+ord(key[(i%key_length)]))%26 ...
f92d4b48b24066bd4887966b5238f54428a4daf3
vitorflc/flasktutorial
/tutorial4.py
903
3.671875
4
## Tutorial 4: HTTP Methods (GET/POST) & Retrieving Form Data # get - insecure way to get info - you don't care if people see it (link etc) # post - secure way (form data, not going to be saved) from flask import Flask, redirect, url_for, render_template, request app = Flask(__name__) @app.route("/") #define como ac...
edda1e2e6d9fd0cbbe25b3a9a956de087c84fc1f
rozen03/codeforces-solutions
/757A.py
223
3.703125
4
#!/usr/bin/env python3 text = input() bolba="Bulbasaur" chars = {} for i in bolba: chars[i] = 0 for i in text: if i in bolba: chars[i]+=1 chars['u'] = chars['u']//2 chars['a'] = chars['a']//2 print(min(chars.values()))
2bd4ef9b6c8264110837172b7e33f3080ace69e6
ironboxer/leetcode
/python/337.py
6,113
4
4
""" https://leetcode.com/problems/house-robber-iii/ The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a b...
92c22b5a180955961487ae6f2cc7771a549650d6
oguzbalkaya/ProgramlamaLaboratuvari
/fibonacci.py
252
3.75
4
#n. fibonacci sayısını bulur. known={0:0,1:1} def fibo_rec(n): if n in known: return known[n] else: result = fibo_rec(n-1)+fibo_rec(n-2) known[n]=result #print(known) return result print(fibo_rec(10))
4459e52dbc267e4b68605a2d5611d8173123af80
kurrenda/aplikacja
/Zajecia_2/Cw3.py
121
3.875
4
def delete(letter, text): print(text.replace(letter, "")) txt = "Ha Ala Ha ma Ha kota Ha" a = "Ha" delete(a, txt)
62dbac5648858507b73c587f96dfb867506d0190
SpringSnowB/All-file
/m1/d3/esercise14.py
708
3.71875
4
""" 比较四个数大小 """ wight1 = float(input("请输入第一个人的体重:")) wight2 = float(input("请输入第二个人的体重:")) wight3 = float(input("请输入第三个人的体重:")) wight4 = float(input("请输入第四个人的体重:")) # if wight1>=wight2 and wight1>=wight3 and wight1>=wight4: # print("最重的是:"+str(wight1)) # elif wight2>=wight3 and wight2>=wight4: # print("最重的是:"+st...
3f466095480bd6735b808ec2a3ba24df585bab3e
seangz/PythonCrash
/UserInput/pizzatoppings.py
214
3.8125
4
prompt = "\nWhat pizza toppings do you want? " prompt += "\nSay 'done' when you're done with your toppings. " message = "" while message != 'done': message = input(prompt) if message != 'done': print(message)
4da294427a1ea95b3caa76fb1afa82acb1a73f0d
manelbonilla/hackerrank
/006.Arrays Left Rotation.py
332
3.8125
4
#!/bin/python3 import math import os import random import re import sys # Complete the rotLeft function below. def rotLeft(a, d): for x in range(0, d): a.append(a.pop(0)) return a #Input #2 # 1, 2, 3, 4 #Expected Output #3, 4, 1, 2 list = [1, 2, 3, 4] print(str(rotLeft(...
141ad8951be67835912e00db310bf236e329b125
joao-lopesr/Exercice-Lists
/List 4 Ex 3.py
92
3.71875
4
List = [1, 3, 5, 7, 9, 10] addition = [2, 4, 6, 8] List[-1] = addition print (List)
d749a4a1eefff77ef85b5d39cca779a27c0fe76e
MathewtheCoder/Leetcode-Solutions
/addtwonumbers.py
3,400
4
4
from typing import List, Union class ListNode: # Function to initialise the node object def __init__(self, data): self.val = data # Assign data self.next = None # Initialize next as null # Linked List class contains a Node object class LinkedList: # Function to initialize head def...
c5a3a36a4ca5d1bce2451548ca3abf590aaa0e3c
Noel62608/PythonVendingMAchine
/car.py
1,197
4.15625
4
class Car: #Constructor Method - Waiter that takes the order for your Car. def __init__(self,whatColor,wheelSizeInput,model,isElectric,engineHp): self.color = whatColor self.wheelSize = wheelSizeInput self.type = model self.electric = isElectric self.horsepower = engineHp def drive(self): ...
7ec5b07f596b5a43ba37b5003b2468794fbe9641
MrQ722/leetcode-notes
/Python3/#234 回文链表.py
2,797
3.796875
4
# 双指针 # 执行用时:92ms,击败36.40% # 内存消耗:23.2MB,击败61.05% # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def isPalindrome(self, head: ListNode) -> bool: if not head: return True val = [] while he...
351e79d71059e89664cddd394ac4db110beab3d3
hsyun89/PYTHON_ALGORITHM
/FAST_CAMPUS/링크드리스트.py
746
4.125
4
#파이썬 객체지향 프로그래밍으로 링크드리스트 구현하기 from random import randrange class Node: def __init__(self,data,next=None): self.data = data self.next = next class NodeMgmt: def __init__(self, data): self.head = Node(data) def add(self, data): if self.head =='': self.head = Node...
b73af1a4f920d70c5d5f66f4059d2431d51585b1
Griffinw15/Intro-Python-I
/inclass/rps.py
2,421
4.53125
5
# Planning # Write a program to play Rock Paper Scissors with a user # Let's flesh out the rules and think about how this is going to work ​ # Rules: Rock -> Scissors # Scissors -> Paper # Paper -> Rock ​ import random ​ # Flow: # Start up program ​ # Keep track of number of wins, losses, and ties ...
04e60c5dd84e54606d81bb253eb94f800adc67cc
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/_PyAlgo-Tree/Cryptography/Diffie_Hellmann/diffie_hellman.py
2,160
4.1875
4
""" - Diffie-Hellman algorithm is used only key exchange not encryption and decryption - A public-key distribution scheme cannot be used to exchange an arbitrary message, rather it can establish a common key known only to the two participants value of key depends on the participants and their private and public key inf...
acece788b3940d58e2451b45ffac7ab807f359b5
rupesh1149/python-goto-repo
/closure.py
577
3.875
4
# A Closure is a function object that remembers values in enclosing scopes even if they are not present in memory def transmit_to_space(message): "This is the enclosing function" def data_transmitter(): "The nested function" print(message) data_transmitter() print(transmit_to_space("Test m...
70f1b4151e85b266a237192667835b5a9f49689e
SamuelJadzak/SamuelJadzak.github.io
/calculator.py
1,664
3.984375
4
def add(num1, num2): """Returns num1 plus num2.""" return num1 + num2 def sub(num1, num2): """returns num1 - num2.""" return num1 - num2 def mul(num1, num2): """returns num1 * num2.""" return num1 * num2 def div(num1, num2): """returns num1 / num2.""" try: ...
1d28b13d64c414f95a03a4de9f0b3ef42dcb6297
oshirohugo/unicamp-2014-1
/mc302/lab07/ativ07.py
2,320
3.515625
4
#This module is used read fuel usage and distance #data and calc consume statistics from it #Hugo K. Oshiro data = {} #dictionary to store data input - 'date' : (volume, kms) consumes = {} #dictionary to store consumes calc by date - consume : (consume, 'date') consumesList = [] #list to store consume kmsL...
d6b207df2a17bedff2634f4b302bf7845a1fa5de
AminHoss/Wave_2
/Roulette_Payout.py
698
3.75
4
import random numbers = [0, 00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,31, 32, 33, 34, 35, 36] red = [1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32, 34, 36] black= [2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31, 33, 35] number = random.choice(numbers) p...
8998c4a05f6317c43a237fd740f045b5b04cbc5c
xiaozhi521/PythonLearn
/venv/Scripts/com/def/DefTest.py
431
3.515625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #import __init__; #__init__.printme("111") Money = 2000 def AddMoney(): # 想改正代码就取消以下注释: global Money Money = Money + 1 print Money AddMoney() print Money import math content = dir(math) print content; print locals() # 返回的是所有能在该函数里访问的命名 print globals() # 返回的是...
ad55a21c492832cd968e7b3fe8c9034c8dd3dfd2
GitKurmax/coursera-python
/week01/task21.py
658
3.671875
4
# Улитка ползет по вертикальному шесту высотой H метров, поднимаясь за день на A метров, а за ночь спускаясь на B метров. На какой день улитка доползет до вершины шеста? # Формат ввода # Программа получает на вход целые H, A, B. Гарантируется, что A > B ≥ 0. # Формат вывода # Программа должна вывести одно натуральн...
a11376608160513fab58d7b1abfeab93a7da9efb
youngerous/algorithm
/etc/Sortings/InsertionSort.py
1,062
4.15625
4
class InsertionSort: """ Complexity: O(N^2) - O(N) for moving key(step) - O(N) for pairwise swap Assumption: Operations of Comparison and Swap are equal in cost. - But usually comparison is more expensive than swap. - When using Binary Search, we can make comparison cost O(NlogN). - However, inserting...
200a6bbcb231745e630985f9267b181c1ad6eaa6
perglervitek/Python-B6B36ZAL
/permutations.py
907
3.6875
4
def permutations(array): perms = [] if len(array) == 0 or len(array) == 1: return [array] else: for key, firstItem in enumerate(array): remainingItems = array[key+1:] + array[:key] for permut in permutations(remainingItems): perms.append([firstItem] + ...
b4ae80e5a5d1c09ae91a269d4b4cc82b31962e95
Artekaren/Trainee-Python
/V30_lista_a_dicc_viceversa.py
662
4.15625
4
#Ejercicio30: #Caso1: Convertir un diccionario en una lista con la función items() list({"k1": 5, "k2": 7}.items()) #Caso2: Convertir una lista en diccionario con la función dict() dict([('k1', 5), ('k2', 7)]) #Caso3: Cruzando información de dos listas. 2 formas. nombres = ['Alumno1', 'Alumno2', 'Alumno3'] notas = ...