blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
10deb7156ada89ac1008dd4453be118c874321b9
sam-w-thomas/puregains_backend
/verify.py
842
3.65625
4
import re def verify_birth_date(date): """ Verify birth date, returns false if not valid :param date: :return: """ valid = True if not re.match('^\d{4}\/(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])$', date): valid = False return valid def verify_str(string): """ Verify...
943c8433fd3370c691ac384d6752843688e492ac
kayartaya-vinod/2018_10_PHILIPS_PYTHON
/Examples/ex11.py
1,765
3.859375
4
def add(*nums): return sum([n for n in nums if type(n) in (int, float)]) def test_fn1(name, *args): print('name = ', name) print('args = ', args) print('-'*80) def print_info(name, email, phone, city='Bangalore'): print('name = ' + name) print('email = ' + email) print('phone = ' + phone)...
33e32b1db29c92f02556d790e3f446e93d1578c7
Yobretaw/AlgorithmProblems
/Py_leetcode/022_generateParentheses.py
743
4.03125
4
import sys import math """ Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()()" """ def generate_parentheses(n): res = [] generate_parentheses_help("", ...
cc3c54d2c82e2f04167ff23abf06b6ce5f1d2157
nischalshrestha/automatic_wat_discovery
/Notebooks/py/antfellow/titanic-pandas-seaborn-sklearn-log-regression/titanic-pandas-seaborn-sklearn-log-regression.py
12,169
3.765625
4
#!/usr/bin/env python # coding: utf-8 # # Survival on the Titanic # ### Predicting survival using pandas, seaborn & sklearn logistic regression # # ### Anthony Nicholas - 7 January 2018 # # ### **Steps** # 0. Introduction # 1. Imports # 2. First look at the data # 3. Preparing the data: # A. Age # B. S...
94c83b220b98b22d41cf4c6b6618fcf0de94bb35
Chiva-Zhao/pproject
/201909/20190903/svd_basic.py
4,017
3.875
4
from numpy import array, zeros, diag from numpy.linalg import inv, svd, pinv # The Singular-Value Decomposition, or SVD for short, is a matrix decomposition method for # reducing a matrix to its constituent parts in order to make certain subsequent matrix calculations # simpler. For the case of simplicity we will focus...
bed5e5e60459371786a025dfcc7c9c3fc353aedd
Devanand072001/python-tutorials
/oops/Class_Object/Car.py
501
3.734375
4
class Car: # manufacturer = None # model = None # color = None # year = None wheels = 4 # class variable def __init__(self,manufacturer,model,color,year): self.manufacturer = manufacturer self.model = model self.color = color self.year = year def start(s...
2a7a7972c7865f2dd32b9656fb96af752bc56b04
optimist2309/Techlistic
/assignment_1.py
1,482
4.03125
4
""" Assignment 1: Automate Your First Selenium Webdriver Script using Browser Commands - July 19, 2019 Automate using Browser Selenium Commands - Launch browser, maximize, validate page title and close browser. It should be your first webdriver script. Assignment Level - Beginner Steps to Automate: 1. Open this lin...
a7105e926a8337c78e61625143a69f3eca8cec46
InnovativeCoder/Innovative-Hacktober
/Data Structures and Algorithms/Stack and queue/Reversing a queue.py
942
4.3125
4
""" Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue. 1.enqueue(x) : Add an item x to rear of queue. 2.dequeue() : Remove an item from front of queue. 3.empty() : Checks if a queue is empty or not.""" # Python3 program to reverse a queue from queue import Queue # Uti...
11ecaccb2ebd8ab8fdb817d274e3baded0484558
AdamZhouSE/pythonHomework
/Code/CodeRecords/2716/49361/304990.py
171
3.796875
4
arr = [] while True: tmp = input() if tmp == ']': break if tmp == '[': continue tmp = tmp.replace("\"", "").replace(",","") print(tmp)
c5215c931b59630cd85ce6cd4177538c45acc5fa
daniel-reich/ubiquitous-fiesta
/LanWAvTtQetP5xyDu_11.py
1,923
3.53125
4
class Count: c = 0 ​ def coins_div(lst): Count.c += 1 # if len(lst) < 3: Dunno why this doesn't work, it seems to incorrectly activate for me :( # return False if Count.c == 16: print(lst, 'CC') return False if lst == [3, 2, 2, 5, 9, 3, 3]: return True class Wallet: def split(coins,...
9cd71748365289235740f18db27389556620602c
sharmishah/guvi
/code kata/fibo.py
83
3.640625
4
M=int(input()) X=0 Y=1 for i in range(0,M): print(Y,end=" ") Z=X+Y X=Y Y=Z
79995a957adab23847bbb4182a379a8ea3cf9c4a
rupikarasaili/Exercise
/LabThree/three.py
384
4.3125
4
''' Write a function that returns the sum of multiples of 3 and 5 between 0 and limit(parameter). For example, if limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20 ''' def myFunc(limit): sum = 0 for i in range(0, limit+1): if (i % 3 == 0 or i % 5 == 0): sum = sum + i ...
9a325b1f31e351c2de70d6686659e932f754e3aa
Nahalius/PythonBasics
/Simple/lists.py
417
4.3125
4
# -*- coding: utf-8 -*- #Lists myList = [1, 2, 3, 4, 5, "Hello"] print(myList) print(myList[2]) print(myList[-1]) myList.append("Simo") print(myList) #Tuples - like lists, but you cannot modify their values. monthsOf = ("Jan","Feb","Mar","Apr") print(monthsOf) #Dictionary - a collection of related data PAIRS myDict ...
aa4a20091a2f2f1853310a425c2a518d248b5d60
JoshTheBlack/Project-Euler-Solutions
/044.py
915
3.75
4
# coding=utf-8 # Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are: # 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... # It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 − 22 = 48, is not pentagonal. # Find the pair of pentagonal numbers, Pj and...
7f823f1e2e2876f30eb3ff1408fab3b1dfc8f9db
drStacky/ProjectEuler
/46_GoldbachsOtherConjecture.py
979
3.859375
4
''' Created on Dec 19, 2016 It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2x1^2 15 = 7 + 2x2^2 21 = 3 + 2x3^2 25 = 7 + 2x3^2 27 = 19 + 2x2^2 33 = 31 + 2x1^2 It turns out that the conjecture was false. What is the smallest odd comp...
c851fb79d08bc125f27909882769c62fcd3ee457
JaeinKim85/RC_BuildingSimulator
/5R1C_ISO_simulator/buildingSystem.py
3,285
3.6875
4
""" ========================================= Building System Parameters for Heating and Cooling ========================================= """ import numpy as np __author__ = "Prageeth Jayathissa" __copyright__ = "Copyright 2016, Architecture and Building Systems - ETH Zurich" __credits__ = [""] __license__ = "MIT"...
668b09442d77d05961beec5c2b4e1d7821429105
ThePrankMonkey/leetcode-answers
/python/2020_09/repeated_substring_pattern.py
1,283
4.09375
4
""" Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000. https://leetcode.com/explore/challenge/card/september-leetcod...
49f0915587dc1257a16bd6a36631628b81b3841d
HarinderToor/Python
/algorithms.py
3,217
3.96875
4
#!/usr/bin/env python3 from bookcase import bookcase def findSpace(aBookcase): """ Returns the row and column of a free position in aBookcase. """ assert aBookcase.getEmptySpaces() >= 1 rows = aBookcase.getRows() columns = aBookcase.getColumns() aSpace = (aBookcase.isEmptySpace(rows, colu...
a434bdd9bec4dbf24f9df94f294eeafd5fbd2e3d
InfoDeveloper-dev/Data-Structures
/Graphs/directed_graph_implement.py
2,542
4.0625
4
import numpy as np """ Abstract Data types means functionality of different operation of such data type is hidden from the user. Operation logics are hidden. """ class _Graphs: __slots__ = '_vertices', '_adj_matrix' def __init__(self, vertices): self._vertices = vertices self._adj_matrix = n...
2433532ffdca823860db71f1e766419235aa9d58
DVampire/offer
/sort.py
13,406
3.640625
4
# -*- coding:utf-8 -*- import time import numpy as np ''' 题目:排序 ''' class Solution(object): def func1(self, *args, **kwargs): ''' 思路一:冒泡排序(bubbleSort) 思想: 每次比较两个相邻的元素, 如果他们的顺序错误就把他们交换位置 平均时间复杂度:O(n^2) 最好情况:O(n) 最坏情况:O(n^2) 空间复杂度:O(1) 稳定性:稳定 ...
7d10c2d386c14b8b8d9ba3a08fe7ad1c7faa2fae
LuisGPMa/my-portfolio
/Coding-First-Contact_With_Python/test_program_3.py
140
3.609375
4
sample_list=[2,10,3,5] average= (sample_list[0] + sample_list[1] + sample_list[2] + sample_list[3])/4 print ('The average is ', average)
2f18ed014608754d79b3eb4731541356f8d4593a
JBPrew/RNG-Generator
/RNG Generator/Python/PythonRNG.py
1,674
3.84375
4
from random import randint #imports necessary packages desiredFile = input("File Name: ") #Asks for user input as a string for the desired file name and stores it in a variable, desiredFile if (desiredFile == ""): #sets the default name if no name is given as a random string converted from an integer desiredFile =...
04482d8419ab57a697cf4974f3e39419ceaec84c
liangqs961105/Practice
/1.千峰基础/Day13-文件操作/10-面向对象相关的方法.py
991
4.15625
4
class Person(object): def __init__(self, name, age): self.name = name self.age = age class X(object): pass class Student(Person, X): pass p1 = Person('张三', 18) p2 = Person('张三', 18) s = Student('jack', 20) # 获取两个对象的内存地址 id(p1) == id(p2) print(p1 is p2) # is 身份运算符运算符是用来比较是否是同一个对象 ...
d9406dbac91e4024f44c53a28d5a090037fd8531
nmessa/Python-2020
/Lab Exercise 12.1.2020/problem2.py
197
3.90625
4
##Lab Exercise 12/1/2020 Problem 2 ##Author: ##This program will calculate a number raised to a power def power(base, exponent): #Add code here print (power(2, 5)) #32
c7b90f03288aa68a5aaa59738bb17685b91560f9
rishavh/UW_python_class_demo.code
/overloaded.py
4,321
4.5625
5
#! /usr/bin/env python # # Operator overloading demonstration import numbers class Vector_3 ( object ) : """This class implements vector arithmetic for three dimensional vectors. The class includes overloaded operators for addition, subtraction, and multiplication (inner product)""" def __init__ (self, x, y, ...
983c895632a4420ac84a51bfc290b2a0a91df639
nikhilbansal064/pyvengers
/unpacking_list_2.py
843
4.6875
5
# -*- coding: utf-8 -*- """ Created on Mon Jun 4 21:49:38 2018 @author: Nikhil * Objective - we can unpack the list in various ways """ #one example # suppose we have list that contains person name and its secrete identity. avenger = ["Scott lang", "Ant man"] #One way to do it name = avenger[0] id...
8dd1827058fb0622abb07bc6bac0cfdef789a7a4
geediegram/parsel_tongue
/Ahmad/Function.py
677
3.5625
4
def create_a_student(first_name, last_name, age) class Native: def __init__(self, first_name, last_name, email, phone_number, sex, next_of_kin): self.first_name = first_name self.last_name = last_name self.email = email self.phone_number = phone_number self.sex = sex ...
d99f952f8695918693b12b9b45bff8d04f3664ee
gunny26/pygame
/effects/PascalTriangle.py
2,894
3.6875
4
#!/usr/bin/python3 import math # non std modules import pygame FPS = 50 DIM = (320, 200) class PascalTriangle(object): """Draw Pascal Triangle on surface, not moving""" def __init__(self, dim: tuple, base: int, radius: int, numrows: int): """ :param dim : surface - surface to draw on ...
3b7aa6d299abd64f4d7e12badc73f207f6092088
thalisonwilker/welcome-to-python
/classes_python.py
1,576
3.984375
4
class Rectangle(object): def __init__(self, width, height): self._width = width self._height = height def area(self): return self._width * self._height def perimeter(self): return 2 * (self._height + self._width) @property def width(self): return self._widt...
3278326c0b62c86e0fd28eed87c5f99501d882f4
t91310042/lab7.2
/main.py
599
3.640625
4
books = ["ULYSSES", "ANIMAL FARM", "BRAVE NEW WORLD", "ENDER'S GAME"] book_dict = dict() for i in range(len(books)): key = books[i] characters = len(key) unique_characters = len(set(key)) value = (characters, unique_characters) book_dict[key] = value # "ULYSSES": (7, 5) # "ULYSSES", (7, 5, 6.0) for ...
d5b68680b05b95f793257a47a624ca861f4b35c1
Skygear55/Training
/Training/Think Python/excercise 5 .py
578
3.765625
4
import turtle kircho = turtle.Turtle() def draw(t, length, n): if n == 0: return angle = 50 t.fd(length*n) t.lt(angle) draw(t, length, n-1) t.rt(2*angle) draw(t, length, n-1) t.lt(angle) t.bk(length*n) draw (kircho, 10, -1) turtle.mainloop() def koch...
9215b908b45ddc3f643a1805e80e9cb750cdb088
chloeeekim/TIL
/Algorithm/Leetcode/Codes/MergeTwoBinaryTrees.py
1,622
4.125
4
""" 617. Merge Two Binary Trees : https://leetcode.com/problems/merge-two-binary-trees/ 두 개의 binary tree가 주어졌을 때, 하나의 binary tree로 merge하는 문제 - binary tree를 overlapping하여 합을 구하는 문제 - 동일한 위치에 노드가 둘 다 있는 경우, 새 트리 노드의 값은 합이 된다 - 노드가 둘 다 있지 않은 경우, null 노드가 아닌 노드의 값이 된다 Example: - Input : t1 = [1,3,2,5], t2 = [2,1,3,null...
ff01416fdc46f82681e1f19e2d18f0e6c960d876
MarciaAndrea/devweb_ativ.complementar
/codigos.js.py/scripts_py/9c.py
1,330
4.21875
4
'''Classe Retangulo: Crie uma classe que modele um retangulo: Atributos: LadoA, LadoB (ou Comprimento e Largura, ou Base e Altura, a escolher) Métodos: Mudar valor dos lados, Retornar valor dos lados, calcular Área e calcular Perímetro; Crie um programa que utilize esta classe. Ele deve pedir ao usuário qu...
35d11e563db0330a89e91b21990860dd5a8e7ebc
juan7914/prueba1
/ejercicios clase dos 2/calcularR.py
290
4.0625
4
import math radio_circulo = float(input("ingrese numero del radio ")) if (radio_circulo < 0): print("el numero que ingresaste es negativo, el numero debe ser positivo") else: AreaCirculo = math.pi * radio_circulo**2 print("el area de este circulo es: ",round(AreaCirculo,2))
fcd2e7eac48620afcb1633eae98f026d8b66561a
mfaizabdul22/Hanoi-Tower-Problem
/hanoiTower.py
1,282
3.828125
4
class Stack(): def __init__(self): self._stack = [] self._top = -1 def __str__(self): return "".join("{}\n".format(x) for x in self._stack[::-1]) def peek(self): if self.isEmpty(): return return self._stack[self._top] def isEmpty(self...
9797c80e2ec3fc71aad47f3c7cd5a2e51dbae4fd
zhaque456/mtec
/Code Examples/python/hello.py
100
3.84375
4
for i in range(10): #print ("hello world") print (i) if (i>5): print ("Numbers higher then 5")
12d8eaedaa1d57fc6f86d93ee6d618521df81038
blackhourse/py_study
/lua/fun/Generator.py
1,523
3.90625
4
# 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间, # 如果我们仅仅需要访问前面几个元素,那后面绝大多数元素占用的空间都白白浪费了。 # # 所以,如果列表元素可以按照某种算法推算出来,那我们是否可以在循环的过程中不断推算出后续的元素呢?这样就不必创建完整的list,从而节省大量的空间。在Python中,这种一边循环一边计算的机制,称为生成器:generator。 # # 要创建一个generator,有很多种方法。第一种方法很简单,只要把一个列表生成式的[]改成(),就创建了一个generator: # a = (x * x fo...
2e4934959097a486063582bcbdb77464c9308463
chungtseng/Trial
/Rosalind/scripts/LREP_rev.py
1,820
3.6875
4
def parsing_suffix_tree(file_name): dna = '' k = 0 suf_dict = {} with open(file_name, 'rb') as in_data: for ind, line in enumerate(in_data): if ind == 0: dna = line.strip() elif ind == 1: k = int(line.strip()) else: ...
471408fdba10bdb351edd6cf241226e28d7dde3a
navazl/cursoemvideopy
/ex104.py
346
4
4
def leiaInt(txt): while True: num = str(input(txt)) if num.isnumeric(): num = int(num) return num else: print('Erro! Digite um número valido.') if num.isnumeric(): break numero = leiaInt('Digite um número: ') print(f'O número que você ...
a563b1d1575c10b666d95604bf8306c0b25dfa5b
GowthamSingamsetti/Python-Practise
/rough21.py
248
3.734375
4
print(ord("4")) x = 10 y = 10 print(x % y) x="ncjj" print(x[::-1]) print(3%10) n = int(input("Enter number: ")) rev = 0 while (n > 0): dig = n % 10 rev = rev * 10 + dig n = n // 10 print("Reverse of the number:", rev)
9af8bfac3b0320e74181b2d230c7cf5f1e148ecf
jiinmoon/Algorithms_Review
/Archives/Cracking_Code_Interview/Old/04_Trees_and_Graphs/4.1_routeBetweenNodes.py
1,805
3.90625
4
""" 4.1 Route Between Nodes Question: Given a directed graph, design an algorithm to find out whether there is a route between two nodes. --- This is asking for definition of the directed graph, and whether one has knowledge about the traversal algorithm. Directed graph implies that the nodes in the graph ...
460ab964d7b6377a7e7e40d4043d16ecd1636218
bangalcat/Algorithms
/leetcode/lru-cache.py
1,516
3.640625
4
class Node: def __init__(self, key, value, left=None, right=None): self.left = left self.key = key self.right = right self.value = value class LRUCache: # doubly-linked list. hash table def __init__(self, capacity: int): self.head = Node(None, -1) sel...
4cd72ffa44748212ec2b1882d0545da2b82526bf
PedroGustavo1/Exercicio_Fila
/questão 6.py
1,858
4.03125
4
class Fila: def __init__ (self): self.fila = [] def enqueue (self): nome_piloto = (input("Digite o nome do Piloto do Aviao: ")) numero_aviao = int(input("Digite o Numero do Aviao que ir entrar na fila: ")) self.fila.append(numero_aviao) print("Lista de espera atualiza...
7632ca0501f38a4a7b26a25ef90055b29d8f1de0
endol007/TIL
/Algorithms/3rd/1_week3_assignment.py
961
3.625
4
shop_prices = [30000, 2000, 1500000] user_coupons = [20, 40] def get_max_discounted_price(prices, coupons): prices.sort(reverse=True) coupons.sort(reverse=True) p_index = 0 c_index = 0 get_price = 0 while p_index < len(prices) and c_index < len(coupons): print(p_index) get_pric...
bd0c7aa56d5d34585eda399698dd610e8c2a5ee7
Gamefalcon24/Grade-Calculator
/main.py
2,525
3.640625
4
import tkinter from tkinter import * import tkinter.messagebox from tkinter.font import Font main = Tk() main.config(background='#4d4949') main.title('Grade Calculator') #Fonts bigFont = Font( family="Microsoft YaHei", size=24 ) # --- VARS --- GradeBox1 = tkinter.DoubleVar() GradeBox2 = tkin...
d5ca5b57fea4b22d63bdb7a710a75771e3395cb9
DeveloperLY/Python-practice
/05_sequence/_07_元组基本使用.py
167
3.6875
4
info_tuple = ("zhangsan", 18, 1.75, "zhangsan") print(info_tuple[0]) print(info_tuple.index("zhangsan")) print(info_tuple.count("zhangsan")) print(len(info_tuple))
57593fa101b97e031d7fb5e9baaade2fffafe20f
petersonb/predprey
/predatorprey.py
3,572
3.53125
4
class Animal: def __init__(self,name,pop,growth): self.name = name self.population = pop; self.growthConstant = growth self.predators = [] self.prey = [] self.relations = Relations() def getName(self): return self.name def getPo...
908b693eb2270b35f5318c2735dcf28b6595f4be
porlin72/School-Projects
/standard_deviation.py
842
3.953125
4
from math import sqrt grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] print float(2 ** (1/2)) def print_grades(grades): for grade in grades: print grade def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(gra...
2b987c442d436afc3dd76c3f9e58d6e7d1caaf2b
RamySaleh/Algorithms
/Interviews_LNK/Number_islands.py
1,991
3.5625
4
#https://leetcode.com/problems/number-of-islands/ from typing import List from Helpers import helper as hlp from Helpers import test_class class Solution(test_class.test_class): def setUp(self): super().setUp() def numIslands(self, grid): if not grid: return 0 count = 0 ...
61c7172bf27df287a3c75d9b0a1460997b015aae
Zochova/kvadraticka-rovnica-RodriskoSk
/kvad rovnica.py
549
3.765625
4
import math a=int(input("Zadaj hodnotu a: ")) b=int(input("Zadaj hodnotu b: ") or "0") c=int(input("Zadaj hodnotu c: ") or "0") if a==0: print("Toto nieje kvadratická rovnica") else: d=(b*b)-(4*a*c) if d>0 : d=math.sqrt(d) x1=(-b+d)/(2*a) x2=(-b-d)/(2*a) ...
48833d838c23df7b3532151204955da20d6e1034
daniel-reich/ubiquitous-fiesta
/n5Ar5F2CJMpGRXz3o_4.py
320
3.71875
4
def mineral_formation(cave): stalac = False stalag = False for x in cave[0]: if x != 0: stalac = True for x in cave[3]: if x != 0: stalag = True if (stalag and stalac) == True: return "both" elif stalag == True: return "stalagmites" elif stalac == True: return "stalactites"
55e286775e310eb0ccac03491a5b504ee85e0804
daviesl/InSARModelling
/island.py
5,760
3.71875
4
from collections import deque import numpy as np class Counter(object): def append_if(self, queue, x, y): """Append to the queue only if in bounds of the grid and the cell value is 1.""" if 0 <= x < self.grid.shape[0] and 0 <= y < self.grid.shape[1] and self.grid[x][y] == 1 and self.unqueued[x][y] ...
bf533550bf094278e1dc6435d558678937c4ec41
AmanRohidas/Tic-Tac-Toe
/main.py
2,767
4.03125
4
def print_board(a): print("",a[1]," │",a[2]," │ ",a[3]," ") print("────│────│────") print("",a[4]," │",a[5]," │ ",a[6]," ") print("────│────│────") print("",a[7]," │",a[8]," │ ",a[9]," ") def print_instructions(): print("\n----------- WELCOME TO TIC TAC TOE ------------\n\n") pri...
f505e50ead181ebf404e781e0551117fdf100206
jorgeacosta19/BrandTech_WebDev
/A6/6.10.py
86
4.1875
4
#10 - Write a Python program to check if an integer is the power of another integer.
777dfd6b7fc78554df8211bec75c22b6d70edcf9
valeonte/advent-of-code-python
/2020/day-18.py
2,680
3.765625
4
# -*- coding: utf-8 -*- """ Day 18 Advent of Code 2020 file. Created on Wed Dec 30 18:04:19 2020 @author: Eftychios """ import os from typing import Iterator os.chdir("C:/Repos/advent-of-code-python/2020") inp_string = "1 + 2 * 3 + 4 * 5 + 6" inp_string = "1 + (2 * 3) + (4 * (5 + 6))" inp_string = "2 * 3 + (4 * ...
9821701b56ea298d16d64bdac06209ddde550050
ToniMagdy/2048_Game
/2048.py
4,199
3.59375
4
import random def add(matrix): i = random.randint(0,3) j = random.randint(0,3) while (matrix[i][j] != 0): i = random.randint(0,3) j = random.randint(0,3) matrix [i][j] = 2 def start(): matrix = [] matrix = [[0] * 4 for i in range(4)] add(matrix) return matrix def...
b11f5621b8db41eaaed2a66b9baf5f84431596d5
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4138/codes/1575_2897.py
150
3.84375
4
# Use este codigo como ponto de partida # Leitura de valores de entrada e conversao para inteiro num = int(input("Digite o numero: ")) print(num*2)
f8d7bd72c28860cffd3e1bbaabfaa7661c911371
supperllx/LeetCode
/563.py
591
3.625
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 findTilt(self, root: TreeNode) -> int: res = 0 def func(root): if ...
3fa94e83881b5b6f7898815fd8490abaf76a5cc8
i-am-ajay/all_python
/LearningPython/salary/salary_head_sheets.py
1,844
3.625
4
# a program to divide excel sheets columns in seperate excel sheets. import openpyxl sal_workbook = openpyxl.Workbook() salary_head_list = ['PR_AIDA','PR_IBASIC','PR_IBONUS','PR_ITS','PR_IDA','DAY_AMT','DAY_OFF','PR_IDIRTY','EL_AMT','PR_EL','PR_DELEC','PR_DEPF','PR_IHRA','HRS_AMT','PR_DIT','PR_DLWPVAL','PR_LWB','PR_DM...
cb279c13715f6e3ec0283752678c2a522fa9cae6
s-ruby/uxr_spring_2021
/challenges/04_bootcamp_logic/stocks_challenge.py
1,361
4.21875
4
print("Challenge 3.2: Playing with the stock market") print() # Creating variables to store the current (approximate) market price of these 5 companies - Amazon, Apple, Facebook, Google and Microsoft. amazon = 3000 fb = 250 google = 1400 print("Challenge 3.2.1: Taking user input") # TODO: Write code to ask the clie...
c359fc186070f7e28b11c541f94daaff4d7c0cd0
PIvanov94/SoftUni-Software-Engineering
/PB-Python April 2020 Part 1/Dishwasher.py
683
3.9375
4
bottles = int(input()) detergent_quantity = bottles * 750 counter = 0 dishes = 0 pots = 0 while detergent_quantity >= 0: command = input() counter += 1 if command == "End": break if counter % 3 != 0: detergent_quantity -= int(command) * 5 dishes += int(command) ...
47e34c935a08c9cf56ccaf1c795bf354e262aa37
danoff0101/python-django
/ola mundo.py
265
4
4
idade = int(input ("qual a sua idade: " )) nome =input("digite o seu nome: ") #print(f"seu nome é {nome}") if idade >= 18: print("maior de idade") else: print("menor de idade") #print(f"OLA {nome} sua idade é {idade} anos")
cb6968b58873824c19a264d6d8db56650141e56e
hrmay/euler
/pe1.py
353
4.3125
4
""" 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 1000. """ total = 0 for i in range(1,1000): if (i % 3 == 0 or i % 5 == 0): total += i print("Sum of multiples of 3 ...
96ca78632278e9ff6826a89cddc028115b0f6af5
Lyon-NEU/Python
/InsertSort.py
600
4.21875
4
#!/usr/bin/env python #see git-hub Lyon-NEU import sys def insertSort(arr): """ insert sort: arr the array to be sorted """ if len(arr)<=1: return for j in range(len(arr)-1): key=arr[j+1] i=j while i>=0 and arr[i]>key : arr[i+1]=arr[i] i-- arr[i+1]=arr[i] def InsertionSort(A): for j in range(1,len...
c437bb75d648e16eaf9190cb02e13c706bf15d50
jessicabelfiore/python-exercises
/Chapter07/Exercise0701.py
282
3.96875
4
""" Exercise 7.1. Rewrite the function print_n from Section 5.8 using iteration instead of recursion. def print_n(s, n): if n <= 0: return print s print_n(s, n-1) """ def print_n(s, n): while n > 0: print s n -=1 print_n("Spam!", 5)
d13b3a565c7272e46ad79215745ab897a784962c
cicihou/LearningProject
/leetcode-py/leetcode45.py
890
3.515625
4
class Solution: def jump(self, nums: List[int]) -> int: ''' method 1 使用贪心策略,每次都在可跳范围内选择跳的最远的距离 到达我们上一轮的跳点之后,产生新一次跳跃,每次跳跃计为1,并重新更新边界 note: 到达 nums 的最后一个数,或者更后的位置,都算是到达了边界 furthest 统计我们当前获得的跳跃数,在本轮跳跃所覆盖的区间中,能够到达的 index 的最远位置 time: O(n) space: O(1) '''...
2ae36aeda85a824a1a052fde7fa24affd1bda986
liyimpc/pytool
/base/decoration.py
1,189
4.25
4
''' 装饰器 概念: 是一个闭包,把一个函数当做参数返回,一个替代版的函数返回,本质上就是一个返回函数的函数 ''' # simple decoration def func1(): print("lym is a good man") def outer(f): def inner(): print("***") f() return inner inner = outer(func1) inner() # difficult deoration def say(age): print("lym is %s years old" % (age)) ...
2f1a275544c506ef6e72c680bfb212733bc5e267
profnssorg/henriqueJoner1
/exercicio65.py
1,343
4.15625
4
""" Descrição: Este programa recebe todas as ordens de atentimento de uma fila de uma única fez e depois as executa. Autor:Henrique Joner Versão:0.0.1 Data:07/01/2019 Comentário: Não consegui pensar em uma forma diferente de resolver o problema, ficou igual ao livro. :/ """ #Inicialização de variáveis ultimo = 0 fi...
cc1b4adec60a5b3eea8d5078ea892baa7a17d7d9
RobAkopov/IntroToPython
/Week4/Practical/Problem3.py
297
3.84375
4
name = 'John' age = int(17) password = '123456&' if name == 'Batman': print('Welcome Mr.Batman!') else: if age < 16: print('Dear', name, 'you are too young to register') if ('*' not in password) and ('&' not in password): print('Please enter a different password')
5d5e6928519b831fc40985d77e198fe9800f9b03
nick-lay/Sedgewick-Algorithms
/1.3 union-find.py
5,830
3.65625
4
#!/usr/bin/env python3 """ """ import json import random import itertools def quickfind(pair): """Реализация простого алгоритма, решающего задачу связности. В основе алгоритма лежит использование массива целых чисел, обладающего тем свойством, что p и q связаны тогда и только тогда, когда p-ая и q-ая зап...
b28babc3d1d6342707bd23f09e2c66a2d3e8388c
kingds/project-euler
/python/solved/Problem_205.py
658
3.578125
4
# Peter has 9 4-sided dice (With sides 1, 2, 3, 4) # Colin has 6 6-sided dice (With sides 1, 2, 3, 4, 5, 6) # If they roll their dice and compare the totals, what is the probability # that Peter wins? (To 7 decimal places) from itertools import product def main(): peter_wins = 0 count = 0 for colin_sum in...
7530c1cb658587c34d3d91baaf0f3904c7c52762
fancystuff4/pythonProjects
/basicProject-3.py
642
4.1875
4
#black list students and white list students, number of students arego in to graduate black_list = ['ravi' , 'raj' , 'raju' ] number_student = int(input("total number of student in class: ")) student_list=[] white_list=[] for student in range(number_student): prompt = input("enter the name of students : ") ...
ff0462196e969243ae6ad5886b1cbd5ac71a59ce
Madanfeng/JianZhiOffer
/python_offer/67_把字符串转换成整数.py
2,444
3.609375
4
""" 写一个函数 StrToInt,实现把字符串转换成整数这个功能。不能使用 atoi 或者其他类似的库函数。 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号; 假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。 该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影响。 注意:假如该字符串中的第一个非空格字符不是一个有效整数字符、字符串为空或字符串仅包含空白字符时, 则你的函数不需要进行转换。 在任何情况下...
c7664144522a5a83e7d569b56cd275c71404c959
GopirajaV/Python
/mul_table.py
241
4
4
def table(): num = int(input("Enter the multiplicand number : ")) end = int(input("Enter the end multiplier number : ")) for i in range(1,end+1): print("%d x %d = %d"%(i,num,num*i)) if __name__ == '__main__': table()
e398aae1c449bbfc4cb747f749712ea4f73b3247
Dominic2681998/python
/lab3-8.py
112
4.03125
4
d = {"India":1, "is":1, "my":2, "country":2, "I":1, "love":1} Invert = {v:k for k,v in d.items()} print(Invert)
2ddb4cf7d0686b703bfea1a447d90f5547abcf16
mastertweed/Python
/CS265/matrix.py
699
3.96875
4
size = int(input("Enter size of Matrix: ")) A = [[0]*size]*size B = [[0]*size]*size C = [[0]*size]*size for k in range(2): for i in range(size): for j in range(size): if k == 0: A[i][j] = int(input("Enter Value for Position A"+'['+str(i)+']['+str(j)+'] ')) else: ...
fdad33ca16eceea747526e4f0e03491d90ac6d21
slavaGanzin/ramda.py
/ramda/converge.py
485
3.640625
4
from toolz import curry @curry def converge(converging, branches, args): """Accepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results ...
8bf583d74415392b8470fdf1b7e0fe98252ed5ae
brixtal/python-comp1
/2019.2/lista_5_prod.py
2,776
3.59375
4
#QUESTÃO 1 tupla = (1,2,3,4) nova_tupla = tupla + (5,) #QUESTÃO 2 nota_tupla_2 = nota_tupla + ("seis",) #QUESTÃO 3 lista = [1,2,3,4] nova_lista = lista + [5] # ou lista.append(5) ou list.append(lista, 5) #QUESTÃO 4 def qtd_palavras(frase): lista_palavras = frase.split(" ") qtd_palavras = len(lista_palavras) ...
ff3ed665a48c808aa27d3bdd1a19e282532cd92c
KainosSoftwareLtd/security-testing-framework
/attackfiles/utils/grep.py
3,143
3.8125
4
import os import re def find_files(root, file_types, ignore_dirs): """ Find all files that match the regex in the root directory and below. Ignore all directories in the ignore_dirs array. :param root: The directory to start the search. :param file_types: Array of file types including a dot, e.g....
6e14d495ff067119dfc9034b69dbbae673c3f20b
srechberger/SalesForecasting
/src/kaggleTutorials/dataCleaning/MissingValues.py
2,178
3.921875
4
import pandas as pd import numpy as np # read in all our data nfl_data = pd.read_csv('../../../data/kaggleTutorials/input/NFL Play by Play 2009-2017 (v4).csv.zip') # set seed for reproducibility np.random.seed(0) # look at the first five rows of the nfl_data file. # I can see a handful of missing data already! nfl_d...
8a960994295241bc3d2f066f2545d47b8071c2d3
1025888636/Grokking-Algorithms
/venv/ruls/各类语句.py
216
3.953125
4
# 1.条件语句 flag = True name = "Django" if name == "python": flag = False print("welcome boss") else: print(name) a=0 b=1 if ( a > 0 ) or ( b / a > 2 ): print("yes") else: print("no") # 在
3c706affec871f4fab4f2ea6249027bbc32a9c7e
arty-hlr/CTF-writeups
/2019/cryptoctf/midnight_moon/midnight_moon.py
1,076
3.5625
4
#!/usr/bin/env python from Crypto.Util.number import * from fractions import gcd import random from flag import flag def encrypt(msg): l = len(msg) // 2 k, m = bytes_to_long(msg[:l]), bytes_to_long(msg[l:]) c = 0 A = [] while c < 2: if isPrime(m): A.append(m) m <<=...
95eaa17cab0684a847daeb8bd763a1346eeb1a3d
hvaltchev/UCSC
/python1/notes/Module 3/Module 3 Sample Files/AbsoluteValue.py
686
4.5625
5
# Generate the absolute value of a number: # Function to determine generate the absolute value def absoluteValue(valueIn): if valueIn >= 0 : valueOut = valueIn else: valueOut = -1 * valueIn return valueOut #Test cases result = absoluteValue(10.5) print('The absolute value of 10.5 is', resu...
a595bc91cacd92dbafd257326f4bc40097cd2ff4
Tamenerdasa/Purchase-analysis
/src/purchase_analytics.py
5,963
3.8125
4
#Tamene Dasa # #This programe reads two input files, namely 'product.csv' and 'order_products.csv', #and finds the total order of a product from each department. Additionally, the program determines # whether the product is ordered for the first time. The excel or csv files are read with csv module # and channled to ...
bb42c83143e151e18f927a613eee4088e99f5048
Sana3339/study-guide-week-2-2
/oo.py
1,184
4.0625
4
# Create your classes here class Student(object): """A student.""" def __init__(self, first_name, last_name, address): self.first_name = first_name self.last_name = last_name self.address = address class Question(object): """A question in an exam along with its correct answer."""...
fb3567613cdb66ffc5e1f32dff581335122680bc
LauraR01/python_class
/ciclo3.py
260
3.984375
4
rango = 1 num = 1 tabla=int(input("ingrese la tabla de multiplicar: ")) rango=int(input("ingrese el rango de la tabla: ")) while tabla <= rango : mult = 1 while mult <= 10 : print(tabla, "*", mult, "=", tabla * mult) mult = mult + 1 tabla = tabla + 1
78aa63ab11d675859c5f683cb02bbb1541bfbd18
Arlisha2019/Calculator-EvenOdd-FizzBuzz
/EvenOdd.py
215
4.28125
4
user_number = int(input("Enter a number: ")) def even_or_odd(): if(user_number % 2 == 0): print("You entered an even number!") else: print("You have entered an odd number!") even_or_odd()
8a5da9c9832d3008fba8057142ee21784f197f99
krndev07/Kiran-Dev
/armstrong.py
184
3.890625
4
x=500 result = 0 while (x != 0) : remainder = x % 10 result +=remainder*remainder*remainder x/=10 if (x == result): print("arm") else: print("not")
bf3ceb00b11bd65615c4a0f04984c3017eb5fda7
BackToTheSchool/assignment_js
/1107/hw3.py
105
3.734375
4
quote = input("What is the quote ? ") name = input("Who said it ? ") print(name," said ","\"",quote,"\"")
695735374c2c5f2b96c6586a0ccae55594bf2107
HristiyanPetkov/Rock-paper-scissors
/rock.py
767
3.75
4
def check(choice1 , choice2): if choice1 == 'r' and choice2 == 'r': return "Tie" if choice1 == 'r' and choice2 == 'p': return "Player 2 won" if choice1 == 'r' and choice2 == 's': return "Player 1 won" if choice1 == 'p' and choice2 =...
24293589cbb832b6b6db58b4a849202c48bf16c2
codingskills1/Python-Learning
/upper.py
128
4.1875
4
print("Welcome to upper application") word = str(input("Enter the word that do you want to make it upper:")) print(word.upper())
3810b7db8b11e6eeb0a1a706637e96679c080b94
satish88397/PythonPractice
/ifelse1.py
228
4.125
4
#take len and bre of rectangle from the user and check is the square or not print ("enter length") l=input() print("enter breath ") b=input() if l==b: print("yes its and its square") else: print("no , its not square")
e0ecce8462625810bc31aa985c726ac85d9c1bcb
Felixiuss/Python_notes
/test.py
5,951
3.796875
4
""" Функции """ # пример изменения элементов списка(сам список остаеттся оригинальным) ls = [1, 2, 3, 4, 5, 6] for i in range(len(ls)): ls[i] += 1 print(ls) new_ls = [x + 10 for x in ls] # тоже но с помощью генератора print(new_ls) res = [] # другой вариант for i in ls: res.append(i + 100) print(res)...
b20c5b1ead0ed1d5a4eed0ea6b108b2a8ca65841
penroselearning/web_app_flask_training
/shopping_cart.py
394
4.15625
4
shopping_cart = ["Apples", "Mangoes", "Bananas", "Stawberries"] for item in shopping_cart: print(item) print() add_item = input("Enter the item in the cart: ").title() shopping_cart.append(add_item) remove_item = input("Enter the item you wish to remove from the cart: ").title() shopping_cart.rem...
a6e45f233e39cd62a8eccea61c04efbda30fd76a
inwk6312fall2019/wordplay-MengyuanHao
/ex9-5.py
211
3.671875
4
def uses_all(word,required): for letter in required: if aeiou not in word: return False elif aeiouy not in word: return False else: return True
4df1472c2c60c1b8fa2cb6d258fed5a5e3e003b1
omkaradhali/python_playground
/leetCode/needle_haystack.py
392
3.78125
4
def strStr(haystack: str, needle: str) -> int: if needle not in haystack: return -1 needle_length = len(needle) for x in range(len(haystack) - needle_length + 1): print(x, x+needle_length) temp = haystack[x:x+needle_length] print(temp) if temp == needle: ...
d81afccaa2da1364bf7838fe962813efa68d39f0
chuan-pk/dashboard
/dashboard/New_calen.py
13,810
4.09375
4
"""Calendar printing functions Note when comparing these calendars to the ones printed by cal(1): By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European convention). Use setfirstweekday() to set the first day of the week (0=Monday, 6=Sunday).""" import sys import da...
7d79e216f63a145d791fc8bfd9966d4c66b2b66e
YashMistry1406/data-structures-and-algo
/dynamic programming/learning_dp/based on knapsack/rod_cutting.py
1,993
4.09375
4
#the rod cutting problem is a variation of unbounded knapsack #where we replace the following variable respectively, #rod cutting --> unbounded knapsack #n --> capacity #prices --> values #size --> capacity &weights #if we look at the unbounded knapsack problem we can have the same item multiple times unlike 0-1 knapsa...
0994488cc3a7ef5534cf8b34fe96d687ece2e032
paulajusti/CloudComputingRepository
/lab3.py
521
4.125
4
phrase = input("Enter a string: ") for (x=0; x<5;x++) { if x=0 phrase=Oxo if x=1 phrase=OXO if x=2 phrase=123454321 if x=3 phrase=ROTATOR if x=4 phrase=12345 54321 #helps in recognition of letters uppercase and lowercase phrase = phrase.casefold() rev_str = reversed(phrase) #me...
6546a1b09c68866169650d6f74b13398c458cf43
30jawahar/pythonPRGMS
/vocon.py
141
3.84375
4
b=["a","e","i","o","u"] a = raw_input() if (a in b): print("The character is vowel") else: print("The character is consonant")