blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4a8dc097c4a732ae274d4cd50fbfc6751d30f4b0
vishhy/Python
/lnr_regression.py
1,112
3.546875
4
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error # it is linear model diabetes= datasets.load_diabetes() # ['data', 'target', 'frame', 'DESCR', 'feature_names', 'data_filename', 'target_filename']) # print(diabetes.DESC...
8454ff017dca54ea14ea3180e092b9258a62c88b
EmirVelazquez/thisIsTheWay
/numbers.py
358
3.6875
4
# This grabs a module to access more math functions from python from math import * # Common examples of working with number datatypes and common functions first_num = -5 print(str(first_num) + " comes after 4.") print(abs(first_num)) print(pow(3, 2)) print(max(5, 2)) print(min(10, 1)) print(round(3.646)) print(floor(3...
dbdad667b9583aa440e780bcd20897d5ac7e8baa
GitContainer/Pythonista-1
/算法2/bubblesort.py
269
3.796875
4
l = [5,6,0,-1,3,-6,12,1] def bubblesort(l): for i in range(len(l)-1): for j in range(len(l)-i-1): if l[j]>l[j+1]: l[j], l[j+1] = l[j+1], l[j] return l print(bubblesort(l)) # 没什么坑,注意 j 要减 去 i, i要减去 1
53846c764935a95d32cdc39d51fb6414649a10d4
awarbler/awarbler.github.io
/cse210/week04/soloWork/hiloTest.py
1,867
4.28125
4
import random """HILO BASIC 1 1.2 """ # get computer to pick random number 1-100 and have user guess number # also get the count of how many times user guessed # create an array of guesses and then append the guesses by the player number # then display well and print the % of guess using the length of the guesses # ...
c9019603a65fb9b95d2bedab61c152c578e7857c
lddsjy/leetcode
/python/fibonacci.py
748
3.640625
4
# -*- coding:utf-8 -*- class Solution: def jumpFloor(self, n): if n == 1: return 1 if n < 1: return None id = 1 a = 1 b = 1 while id < n: id +=1 c = a+b a = b b = c return c s = Solution(...
a934db1c245a19dd6a54e009849c39d99e94bd21
andrericca/Testevape
/Cópia de hello.py
528
3.65625
4
#!/usr/bin/python a = input("Quantidade total de VG?: ") b = input("Quantidade total de PG?: ") c = input("Tamanho de cada frasco?: ") d = input("Porcentagem da essencia?: ") e = input("Porcentagem de vg?: ") f = input("Porcentagem de pg?: ") vgml = c * e / 100 eml = c * d / 100 pgml = c * f / 100 - eml print 'VG=',...
652599653a79a0f252a9fea6ec4b7786753c5029
murayama333/python2020
/02_oop/tr/src/27_exception/ex_tr7.py
419
3.640625
4
class MyRequiredError(Exception): pass class MyLengthError(Exception): pass def validate(value, length): if len(value) == 0: raise MyRequiredError() if len(value) > length: raise MyLengthError() try: value = input("Input: ") validate(value, 5) print(value) except MyRequ...
19be3dbb7b1aef57fd4bf07ffae4ba409faa9927
gerardogtn/SistemasInteligentes
/01-MarsExplorer/sample.py
762
3.515625
4
from drawable import Drawable from positionable import Positionable import random class Sample(Drawable, Positionable): SIZE = 10 COLOR = 'green' def __init__(self, x, y): super().__init__(x, y, self.SIZE) def draw(self, canvas): canvas.create_oval(self.x - self.SIZE / 2, self....
098076350a6b0e8b9538642e33e8924b8f87a60b
AnujVijjan/Youtube
/tutorial54.py
474
3.828125
4
class Father: surname = "xyz" def __init__(self): self.father_name = "xyz" class Mother: def __init__(self): self.mother_name = "abc" class Child(Father, Mother): def __init__(self): self.child_name = "pqr" def diplay(self): # print(self.father_name) # p...
23ab7f0444c31f072bf2fd3bf377dfa6dd4406ea
VityasZV/Python-tasks
/5 semestr/homework-7/DungeonMap.py
1,510
3.78125
4
from collections import defaultdict def tunnels_from_input(): tunnels = defaultdict(set) a_to_b = input().split(" ") while len(a_to_b) != 1: tunnels[a_to_b[0]].add(a_to_b[1]) tunnels[a_to_b[1]].add(a_to_b[0]) a_to_b = input().split(" ") beg = a_to_b[0] en = input() retu...
5d0b4675d65b7ca1817031f6261e48291b467e74
22zagiva/Module-a
/moda_challenge.py
358
4.03125
4
for i in range(10): print("Hello, Python!") #----------------------------------------- for x in range(10): print(x) #----------------------------------------- for b in range(1, 11): print(b) #----------------------------------------- for c in range(2, 21, 2): print(c) #----------------------------------------...
7bee0b702d1cfe4e474ea16865cda8b9af546135
aysegulkrms/SummerPythonCourse
/Week1/01_Hello_World.py
427
4.375
4
# Printing First Hello World with double quotes print("Hello World") # I am writing a single line comment # Printing Hello World with single quotes print('Hello World') # Print out your name with the Print function print("My name is Cemil Koc") print("Hi, Python") """ I can add multiple line comments by using tripl...
5e8cfdae143f882adc017fbf529627cedc301533
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc002/B/4414718.py
267
3.578125
4
from datetime import date,timedelta y,m,d=map(int,input().split("/"))#??????? dt=date(year=y,month=m,day=d)#?????date????? while dt.year/dt.month%dt.day:#?????????????? dt+=timedelta(days=1)#???????????????????????? #print(dt) print(dt.strftime("%Y/%m/%d"))
f07cd326f1a6cc86d96716b09b1e3fdc5f4ee1a9
aayushrai/Project_Eulers_solution
/problem 9.py
286
3.640625
4
def abc(): for a in range(0,500): for b in range(0, 500): for c in range(0, 500): if a<b<c: if a+b+c == 1000: if a**2+b**2 == c**2: return a,b,c a,b,c =abc() print(a*b*c)
155ffecfc68a5c96a5427b259ff583695fe8b7b4
stuart727/edx
/edx600x/L06_Objects/more_operations_on_lists.py
1,190
4.21875
4
import string f ="lalala" print list(f) print f.split(" ") print [x for x in f] '''changing collection while iterating over elements''' '''remove an element''' elems = ['a', 'b', 'c'] for e in elems: print e elems.remove(e) print 'A',elems # MISSING element b # when you remove the...
d8bfa1037e47e75c32bda0478751f63f69e31ae5
gptix/Graphs
/projects/graph/graph.py
5,845
3.875
4
from util import Stack from util import Queue """In the file graph.py, implement a Graph class that supports the API in the example below. In particular, this means there should be a field vertices that contains a dictionary mapping vertex labels to edges. For example: { '0': {'1', '3'}, '1': {'0'}, ...
534eb82acda7a7f67c995ff6b51979a648bf2a74
HidoiOokami/Projects-Python
/POO/data.py
865
4.15625
4
class Data: # Contrutor nome magico __init__ def __init__(self, dia = 3, mes = 7, ano = 1997): self.dia = dia self.mes = mes self.ano = ano #Metodo especial que converte para str #self objeto que esta sendo usado nesse momento e um this def __str__(self): # metodo magico ...
bb0d09b70817dd7a9caf8c78d93c51ebac45ab79
sahanavandayar/150_PythonCourse
/a3FINAL.py
14,175
3.6875
4
# Important variables: # movie_db: list of 4-tuples (imported from movies.py) # pa_list: list of pattern-action pairs (queries) # pattern - strings with % and _ (not consecutive) # action - return list of strings # THINGS TO ASK THE MOVIE CHAT BOT: # what movies were made in _ (must be date, becau...
be6dd8523e6f758ece23e131d890641613f71406
tcandzq/LeetCode
/HashTable/BrickWall.py
1,503
3.828125
4
# -*- coding: utf-8 -*- # @File : BrickWall.py # @Date : 2020-03-09 # @Author : tc """ 题号 554. 砖墙 你的面前有一堵方形的、由多行砖块组成的砖墙。 这些砖块高度相同但是宽度不同。你现在要画一条自顶向下的、穿过最少砖块的垂线。 砖墙由行的列表表示。 每一行都是一个代表从左至右每块砖的宽度的整数列表。 如果你画的线只是从砖块的边缘经过,就不算穿过这块砖。你需要找出怎样画才能使这条线穿过的砖块数量最少,并且返回穿过的砖块数量。 你不能沿着墙的两个垂直边缘之一画线,这样显然是没有穿过一块砖的。 示例: 输入: [[1,2...
d61d5b6b6b0a4e95ba7406814414d2d069961695
silhuzz/Engeto-Project-2-
/main.py
6,333
3.96875
4
#PISKVORKY 2.0 # by Tomas S def zadani_hrace(): while True: pole = input("Vyber si velikost hracího pole.\nVelikost musí být mezi 3 - 100") if not pole.isdecimal(): print("Zadej celé číslo") continue if not (int(pole) < 3) and not (int(pole) > 100): nako...
ff32bffbe4b9f85b7da15b3b9bc4e5a8dc1c9d7d
bestyuan/Time-Series-Forecasting-With-LSTMs
/DataVisualization.py
373
3.546875
4
import pandas as pd from matplotlib import pyplot dataset = pd.read_csv('pollution.csv', header = 0, index_col = 0) values = dataset.values groups = [0, 1, 2, 3, 4, 5, 6, 7] i = 1 pyplot.figure() for group in groups: pyplot.subplot(len(groups),1,i) pyplot.plot(values[:,group]) pyplot.title(dataset.columns...
5a0d28005a7e8153746748532848aafbe243f47e
logancrocker/interview-toolkit
/code/queue/queue.py
421
3.75
4
class Queue: def __init__(self): self.queue = [] def isEmpty(self): return len(self.queue) == 0 def add(self, data): self.queue.append(data) def remove(self): if (not len(self.queue) == 0): self.queue.pop(0) else: print("Empty queue!") def peek(self): ...
5394b0578e81dfc09d109fa035c58427d1b6e2b6
Gerrydh/Project-2018
/Python Scripts/Min & Max Sepal Lengths.py
796
3.875
4
# Ger Hanlon, 02.04.2018 # This code returns the min and max value of the sepal lenghts, Column(0). #https://stackoverflow.com/questions/46281738 with open("Iris data2.csv") as file: # open, then close the Iris Dataset file lines = file.read().split("\n") #Read each line and split each line num_list = [] # o...
e3211950e94767d9813875958e5dc0a5764c6f44
PeravitK/PSIT
/WEEK3/[Midterm] Donut.py
587
3.734375
4
"""donut""" def donut(): '''eiei''' var_a = int(input()) var_b = int(input()) var_c = int(input()) var_d = int(input()) if var_c > 0: ans = var_d//(var_b+var_c) if var_d - (var_b+var_c)*ans < var_b: price = ((var_a*var_b)*ans)+(var_d-((var_b+var_c)*ans))*var...
45e2461e92a689b81291644b1c76672b6e9985f3
guam68/class_iguana
/Code/Daniel/python/lab11-simple_calculator.py
386
3.859375
4
from math import * print('-' * 50 + '\nType "done" to quit\n' + '-' * 50 ) while True: try: expression = input('\nEnter a math expression using [+, -, *, /] operators: ') if expression == 'done': break answer = eval(expression, {'__builtins__': None}) print(an...
b021c4ff2248e7b1cadbf07baf77b09dadb5ca04
krnets/codewars-practice
/5kyu/Find the Partition with Maximum Product Value/index.py
2,676
3.84375
4
""" 5kyu - Find the Partition with Maximum Product Value You are given a certain integer, n, n > 0. You have to search the partition or partitions, of n, with maximum product value. Let'see the case for n = 8. Partition Product [8] 8 [7, 1] 7 [6, 2] ...
8988890c2e21561e3f08e729a8dc6c07d4678fcf
cnspaulding/PFB_problemsets
/PythonPS7/ps7q1.py
284
3.703125
4
#!/usr/bin/env python3 import re poem_file = open('Python_07_nobody.txt', 'r') poem= poem_file.read() found = re.findall(r'Nobody', poem) #print(found) for found in re.finditer(r'Nobody', poem): occur = found.group(0) position = found.start(0)+1 print(occur, position)
1ce7d67781fdc92c37badfc30dd0d46c46087ce0
mingweihe/leetcode
/_1057_Campus_Bikes.py
1,508
3.578125
4
import heapq class Solution(object): def assignBikes(self, workers, bikes): """ :type workers: List[List[int]] :type bikes: List[List[int]] :rtype: List[int] """ # Approach 2 Bucket Sort Algorithm, time O(m*n) dists = [[] for _ in xrange(2001)] for i...
8882d09d9c1b34b07ad5b56931c85f996e358476
matheusschuetz/AulasPython
/17-Aula17/exercicio/exercicio2.py
1,187
4.09375
4
# 1 - Faça um menu interativo que tenha: Cadastro da banda, cadastro # do album, cadastro da musica, Sair. # O menu deve ser executado até que se escolha a opção sair. # Cada opção deve ser mostrada # quando selecionado a opção sair, deverá aparecer na tela as # informações das banda cadastradas, # albuns e musicas...
bd0e0bc07201db9f2611c051b9e80e39f92d3e0d
tudennis/LeetCode---kamyu104-11-24-2015
/Python/reordered-power-of-2.py
870
3.765625
4
# Time: O((logn)^2) = O(1) due to n is a 32-bit number # Space: O(logn) = O(1) # Starting with a positive integer N, # we reorder the digits in any order (including the original order) # such that the leading digit is not zero. # # Return true if and only if we can do this in a way # such that the resulting number is...
3e00a53218a5bec14326413929bf0ce342e05134
Simran-02/Bootcamp-project-
/3.py
829
3.765625
4
#Add salting and iterartion to your hashes. #ans:- import uuid import hashlib def hash-password(password): salt=uuid.uuid4().hex return hashlib.sha256(salt.encode()+password .encode()).hexdigest()+':'+salt def check-password d(hashed-password,user-password): password,salt=hashed...
5ca27e6b0ef870ec25424c828a7a69aa8de7de38
Frankiee/leetcode
/math/963_minimum_area_rectangle_ii.py
2,174
3.515625
4
# [Classic, Rectangle] # https://leetcode.com/problems/minimum-area-rectangle-ii/ # 963. Minimum Area Rectangle II # History: # Facebook # 1. # Mar 6, 2020 # Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from # these points, with sides not necessarily parallel to the x and ...
3346c37a5c2348d3a3effb03ba090493187320c9
archived-user/Numpy-Tutorial-SciPyConf-2016
/exercises/wind_statistics/wind_statistics_completed.py
3,933
4.125
4
# Copyright 2016 Enthought, Inc. All Rights Reserved """ Wind Statistics ---------------- Topics: Using array methods over different axes, fancy indexing. 1. The data in 'wind.data' has the following format:: 61 1 1 15.04 14.96 13.17 9.29 13.96 9.87 13.67 10.25 10.83 12.58 18.50 15.04 61 1 2 14...
8beebd284d4bfb1f318da07454481b7998a0b18f
bruceewmesmo/python-mundo-03
/ex074.py
293
3.921875
4
# EXERCICIO 074 - from random import randint num = (randint(1,10),randint(1,10),randint(1,10),randint(1,10),randint(1,10)) print('Os valores sorteados foram:', end= ' ') for n in num: print(f'{n}', end = ' ') print(f'\n O maior número sorteado foi {max(num)} e o menor {min(num)}')
78572132e86875c8fce575d9a0874515bf131f4b
susyhaga/Challanges-Python
/Frauenloop/Tip_calculator/tip_calculator.py
416
3.84375
4
guest = 2 bill = 80 tipPercentage = 10 def calculator(): percentage_x = bill * tipPercentage / 100 print(percentage_x) tip_x = percentage_x / guest print(tip_x) bill_division = bill / guest print(bill_division) total = bill_division + tip_x print( f'Each guest needs to pay {to...
32343a1b93d85debc90b8b779fd607f630c8387e
superSeanLin/Algorithms-and-Structures
/29_Divide_Two_Integers/29_Divide_Two_Integers.py
786
3.609375
4
class Solution: ## may use Euclidean algorithm(辗转相除) to calculate greatest common divisor def divide(self, dividend, divisor): """ :type dividend: int :type divisor: int :rtype: int """ negative = 1 if dividend * divisor < 0: # different sign ...
c603d54cd7c9852ade76502c97afd531b0ea8924
msanchezzg/AdventOfCode
/AdventOfCode2019/day12/day12-1.py
2,592
3.65625
4
class Luna: def __init__(self): self.velocidad = Velocidad() self.posicion = Posicion() def __repr__(self): s = 'pos= <' s += 'x=' + str(self.posicion.x) + ', ' s += 'y=' + str(self.posicion.y) + ', ' s += 'z=' + str(self.posicion.z) + '>, vel= <' s ...
18c77c2867fcacaae590f44c735446831f2360d1
mjburgess/public-notes
/python-notes/14.Extra/ExerciseX-PEP8.py
863
4.4375
4
# CHAPTER: PEP8 # OBJECTIVE: Complete the following questions. # PROBLEM: Revise this file and apply PEP8 guidelines; do not change the logic. # TIME: 15m class Person: def __init__(self, first_name): self.first_name = first_name def get_name(self): return self._format(self.firs...
a87179fcbcc0c67b3e41ad4e28e30190f190072f
mknotts623/client_search
/db_functions.py
1,938
3.8125
4
import sqlite3 conn = sqlite3.connect('client_data.db') c = conn.cursor() def create_table(): # need to get ALL parameters later c.execute('PRAGMA foreign_keys = ON;') c.execute('CREATE TABLE IF NOT EXISTS clients(' 'client_name TEXT PRIMARY KEY,' 'email TEXT NOT NULL, ' ...
a01ae760263715cf870040d7e9e8a96e38e458be
SpencerNinja/practice-coding
/Python/CS1400and1410/2019 03 01 Yahtzee.py
1,109
4.03125
4
# Yahtzee Simulation # Spencer Hurd # Instructions # Write a function called Yahtzee_Simulation() # Simulate rolling 6 dice 1 million times # Keep track of the number of the computer rolls a yahtzee # probability of getting yahtzee=6*5*4*3*2*1 # return the number of wins divided by the number of tries # no ...
8545ad67add5b9cf6b48b0508459506c824eb4c9
danieltshibangu/Mini-projects
/recursion1and2.py
696
4.0625
4
# Python code to demonstrate printing # pattern of numbers def foo1( n ): if n == 2: return 1 else: return 3 * foo1( n - 1 ) ''' Recursive calls, foo1(5) foo1(5) == 9 * 3 = 27 foo1(4) == 3 * 3 = 9 foo1(3) == 3 * 1 = 3 foo1(2) == 1...
6a8806df67796f9a5ca19a6e442a8900e25798f7
sathwikmatcha/project-euler
/#48.py
1,120
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 1 15:33:58 2020 @author: Sathwik Matcha """ def factorial(n): if n < 0: return 0 elif n == 0 or n == 1: return 1 else: fact = 1 while(n > 1): fact *= n n -= 1 return fact def C(n,r): ...
49a2e7a3d570ccbbb1ff55396b8d12f09a5a81ce
AlexGalhardo/Learning-Python
/YouTube Ignorancia Zero/Arquivos/52 - Arquivos II: Bytes e For loops/Jogo.py
6,873
3.734375
4
""" Jogo simples de ataque e cura """ #importa o modulo random import random def Salvar(player_vida, player_sp, inimigos): """ Função usada para salvar o jogo """ pass def CarregaJogo(): """ Função que carrega um jogo """ pass def main(): """ Função Princip...
d889543a31e3a3071202afbb04b55e5d2df9a48d
aniruddhamurali/Project-Euler
/src/Python/Problem41.py
1,201
3.71875
4
import math import itertools def isprime(n): """Checks number (n) for primality, and returns True of False.""" n = abs(n) if n < 2: return False if n == 2: return True if not n % 1 == 0: return False if n % 2 == 0: return False for x in range(3, round(mat...
a4fd327e609889ed1667efcd7e490191bac65b01
97cool-vikas/Interviewbit
/Python3/Arrays/Bucketing/Maximum Consecutive Gap.py
757
3.78125
4
''' Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Example : Input : [1, 10, 5] Output : 5 Return 0 if the array contains less than 2 elements. You may assume that all the elements in the array are non-negative integers...
89548131b010ebc9a7e2fba774af1861f51a951c
mentalcic/lpthw
/ex29_study_drill.py
1,884
3.984375
4
# Study Drill 4. # Can you put other Boolean expressions from Exercise 27 in the if-statement? # Try it. ################### print("\n\nExample 1:\n") a1 = True b1 = 1 != 0 and 2 == 1 print("Printing value of a1:", a1) print("Printing value of b1:", b1) if a1 != b1: print(f"{a1} is not equal to {b1}!") if a1 =...
f9e9329b0efe777fe2ce07ffc8e0c7cfa3c165d7
mvpfreddy7/python01
/Assignments/assignment_3.3_Freddy_Sanchez.py
267
4.34375
4
#assignment_3.3 gpa = raw_input("enter your GPA:") gpa = float(gpa) if gpa < 0.0 or gpa > 1.0: print "value out of range" elif gpa >= 0.9: print "A" elif gpa >= 0.8: print "B" elif gpa >= 0.7: print "C" elif gpa >= 0.6: print "D" elif gpa < 0.6: print "F"
e2967c3c1d551f7c929b16071d1645feca3ea03c
IronE-G-G/algorithm
/leetcode/340lengthOfLongestSubstringKDistinct.py
1,332
3.5
4
""" 340 至多包含k个不同字符的最长子串 给定一个字符串 s ,找出 至多 包含 k 个不同字符的最长子串 T。 示例 1: 输入: s = "eceba", k = 2 输出: 3 解释: 则 T 为 "ece",所以长度为 3。 示例 2: 输入: s = "aa", k = 1 输出: 2 解释: 则 T 为 "aa",所以长度为 2。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/longest-substring-with-at-most-k-distinct-characters 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处...
f75b769d78a1c1436f9054cbaaa5a3f39e46f85a
medaey/bts-sio-public
/01_Algorithme/012_python/2021-10-21_listeBis.py
937
4.25
4
# Tableaux - Listes en python # Liste : ensemble d'elements de types quelconques # Creation d'une liste vide # 2 methodes maliste1 = [] maliste2 = list(); # Creation d'une liste non vide maListe3 = ['Bonjour', 3.14, 45, 'A', True] # Taille d'une liste fonction len() print("taille de la liste maliste3: ",...
18868c724ba1655e0b9fc82014dd7e5453380822
lmb633/leetcode
/98isValidBST.py
2,001
3.84375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isValidBST(self, root): result, _, _ = self.isvalid(root) return result def isvalid(self, ro...
0eb5cbf11d3e2ee30d125685752dfa78519f9805
Rohitguptashaw/My-first-games-and-codes
/count substrings in a string.py
206
3.609375
4
def abc(str1,str2): cont=0 for i in range(len(str1)): if(str1[i:i+len(str2)]==str2): cont+=1 return cont str1=input("string1") str2=input("sub") q=abc(str1,str2) print(q)
87671e2d65148179d961a58f841533b4777c6f15
MarioCioara/PEP21G01
/modul4/modul4_1.py
2,495
3.71875
4
#dictionare # my_dict = { # 'key1': 'value1', # 1: '1', # None: print, # (1,2): 'list' # # } # for key in my_dict.keys(): # print('keys: ',key) # print() # for value in my_dict.values(): # print('values: ',value) # for key, value in my_dict.items(): # print(key, value) #Vrem sa aflam m...
9451ae5b2018d7fa40c0b5d27d654325899e28ef
brookeclouston/Sudoku
/build_graph.py
3,834
3.828125
4
""" Author: Brooke Clouston Date Created: August 24 2019 Creates and displays a sudoku board. """ import random class Graph: """ Class: Graph Creates and displays a sudoku board. """ def __init__(self): """ Function: __init__ Initializes empty game board. """ self.board = [["x", "x...
8a2368590945c5748d7423751ae5f7ba3558db2f
musawakiliML/Project-Euler-Challenge
/Even Fibonacci Numbers.py
1,087
4.09375
4
''' Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. '...
44e6ade8aef823230be98d86773057614536dac5
ganqzz/sandbox_py
/testing/parametrized_tests/test_tennis_unittest.py
630
3.75
4
import unittest from tennis import score_tennis class TennisTest(unittest.TestCase): def test_score_tennis(self): test_cases = [ (0, 0, "Love-All"), (1, 1, "Fifteen-All"), (2, 2, "Thirty-All"), (2, 1, "Thirty-Fifteen"), (3, 1, "Forty-Fifteen"),...
8c209f0a80f85c8f016910a3dc88bddb77387305
Torisels/pipr
/pipr5_6/music.py
2,072
3.609375
4
import time import datetime class Artist: def __init__(self, first_name, last_name, nickname, albums=None, songs=None): self.first_name = first_name self.last_name = last_name self.nickname = nickname self.albums = albums self.songs = songs class Album: def __init__(s...
08c6a71851ce62d88021710ee2c40859411f7de8
Luke-Beausoleil/ICS3U-Unit4-06-Python-RGB_values
/rgb_values.py
523
4.28125
4
#!/usr/bin/env python3 # Created by: Luke Beausoleil # Created on: May 2021 # This program returns all possible RGB values def main(): # this function outputs the RGB values # variables red = 0 green = 0 blue = 0 # process & output for red in range(256): for green in range(256):...
417fec87ee612ce9218b2a5686a502cd0461a84f
azewierzejew/IPP-male-zadanie-testy
/src/chooseCommentToEOFVariant.py
1,007
3.578125
4
#!/usr/bin/python3 from shutil import copyfile from os import getcwd cwd = getcwd() info = ''' Choose out when there's comment without newline (ends with EOF): error - there should be error message printed (cause line without newline) nothing - nothing should be printed (cause it's a comment) Please write your decis...
7d0e03984c3487726420d25da0e8fef5e9ec8be1
naitikshukla/practice
/sample_problems/Fredo and Array Update.py
537
3.75
4
num='15' #input 1 array = "1 2 3 4 5 6 7 8 9 10 89 21 27 98 56 23 12 23 43 98 198 22210" #input 2 array = [int(i) for i in array.split()] #convert to list in integer num = int(num) ...
7ee55c8aa1a0e4b79530f09ac7eb95309f16cb26
S-pl1ng/python-web-scraping
/re_assgn.py
404
3.796875
4
#This assignment involves using Regular Expressions (RegEx) to extract and sum all numbers from a given file import re file = open(r"C:\Users\Hp\python_web_course\actual_data.txt") total=0 for line in file: line=line.rstrip() num_list = re.findall("[0-9]+", line) if len(num_list)>0: for i in range...
0dbfc386fdd5f9e34e8918315aefef921940eadc
greenfox-zerda-lasers/hvaradi
/week-03/day-3/pirate.py
839
3.859375
4
# create a pirate class # it should have 2 methods # drink_rum() # hows_goin_mate() # if the drink_rum was called at least 5 times: # hows_goin_mate should return "Arrrr!" # "Nothin'" otherwise class Pirate(): def __init__(self, name, age, hair): self.alcohol=0 self.name=name self.age=age ...
08c46ef56d05d1d908a47b8d632ae1e7e8074fbb
tushargoyal02/python
/10.py
337
4.09375
4
#! /usr/bin/python3 a=input("enter a number") b=input("enter b number") def name(a,b): # here a=hello and b=world # so var2 will be helloworld here var2=a+b print(var2,"<-- this is inside") # whille return var2(helloworld) return var2 print(name(a,b)) # here print is helloworld var2=a print("outside",var2) ...
bb7f07e4c921c723da11a3719cb9475db4d828d7
Shakirsadiq6/Basic-Python-Programs
/Basics_upto_loops/Loops/series.py
264
3.78125
4
'''Add first seven terms of 1/1! + 2/2! + 3/3! + ...''' __author__ = "Shakir Sadiq" SUM = 0 for i in range(1,8): FACTORIAL = 1 for j in range(1,i+1): FACTORIAL *= j division = i/FACTORIAL SUM += division print("Sum of First Seven Terms=", SUM)
e4a04e3d952f4bbad3029dcdcdf7d074a2f52670
weshao/LeetCode
/96.不同的二叉搜索树.py
1,676
3.5
4
# # @lc app=leetcode.cn id=96 lang=python3 # # [96] 不同的二叉搜索树 # # https://leetcode-cn.com/problems/unique-binary-search-trees/description/ # # algorithms # Medium (69.24%) # Likes: 934 # Dislikes: 0 # Total Accepted: 98.1K # Total Submissions: 141.8K # Testcase Example: '3' # # 给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种...
f79757553d52dfd984ce02d5afd10842f25de626
Fondamenti18/fondamenti-di-programmazione
/students/761660/homework01/program01.py
1,325
3.71875
4
''' Si definiscono divisori propri di un numero tutti i suoi divisori tranne l'uno e il numero stesso. Scrivere una funzione modi(ls,k) che, presa una lista ls di interi ed un intero non negativo k: 1) cancella dalla lista ls gli interi che non hanno esattamente k divisori propri 2) restituisce una seconda l...
f009e2fc2448e512e03b65cd463749515db12bfe
dreamgonfly/py-ng-ml
/machine-learning-ex1/ex1/ex1.py
4,118
4.0625
4
## Machine Learning Online Class - Exercise 1: Linear Regression # Instructions # ------------ # # This file contains code that helps you get started on the # linear exercise. You will need to complete the following functions # in this exericse: # # warmUpExercise.py # plotData.py # gradientDescent.py...
3f35bb52c28eddd26b14847e2111afb2a0ed62fe
sunilsm7/python_exercises
/Python_practice/practice_01/sentenceAbrevation.py
1,586
4.3125
4
""" Write a python function which accepts a sentence and converts it into an abbreviated sentence to be sent as SMS and returns the abbreviated sentence. Rules to follow while shortening: A. Spaces are to be retained as is, i.e. even multiple spaces are to be retained. B. Each word should be encoded separately - If a...
683145a8cef1f4a7c8147c43732b62069accd123
Harisha-1990/PythonCoding
/38_tuple.py
234
4.21875
4
my_tuple = (1,2,3,4,5) print(my_tuple[1]) # just like a list we can access tuple through index print(5 in my_tuple) user ={ (1,2):[1,2,3] #we're trying to use tuple inside dictionary ,'greet':'hello' ,'age':20 } print(user[(1,2)])
cc16aa75d6e7f41724db2b8961f45de632e033c0
FreedomPeace/python
/basicKnowledge/02DataType.py
252
3.921875
4
a = 3 print(a) print(type(a)) a = 3.22 print(type) print(type(a)) a = True # bool类型两个值 True False print(type(a)) # str类型 a = "i am a it programmer" print(type(a)) # 多行字符串 a = """ dog cat sheep """ print(a) print(type(a))
f1c98bb1103fbfce19d8700d1a2ef5c5bd3af542
acacivare12/Mock-Atm3-
/auth.py
3,247
4.03125
4
#register # - first name, last name, password, email # - generate user account #login # - account number & password #bank operations #Initializing the system import random import validation import database from getpass import getpass def init(): print("Welcome to bankPhP") haveAc...
871e0ddb474c299d725b8416378552bad60219eb
2020rkessler/main-folder
/functions/code-a-long.py
916
3.8125
4
# reading: https://www.codementor.io/kaushikpal/user-defined-functions-in-python-8s7wyc8k2 # built in functions print('hello, I am a function') print(len('hello')) # user defined functions # create a function called find_me() # args1 = arr of ints # arg2 = one number you are looking for # output = 1.) true or false #...
accd556e0a28cbbb36bf29a59ec23399746bad7e
xiangcao/Leetcode
/python_leetcode_2020/Python_Leetcode_2020/67_add_binary.py
1,272
3.671875
4
""" Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Constraints: Each string consists only of '0' or '1' characters. 1 <= a.length, b.length <= 10^4 Each string is either "0" or doesn't contain any leading zero. """ class S...
3d6b9f8f450b9d9a53b9a3587a0d8bfe37a49f0a
ShiroOYuki/Leetcode
/Python/94/main.py
723
3.796875
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right # Question request:Binary Tree Inorder Traversal(left,root,right) class Solution: def inorderTraversal(self, root: TreeNode): if not root: return ...
b907c60a2c7ec2e249de8417bd0f649116133d06
kumailn/Algorithms
/Python/Kth_Smallest_Element_in_a_BST.py
833
3.890625
4
# Question: Given the root node of a tree, find the nth smallest element in the tree # Solution: Traverse in order iteratively and keep track of the nth smallest element # Difficulty: Easy def kthSmallest(self, root: TreeNode, k: int) -> int: stack = [] val = None # Iterative in ord...
6957be286171d7047773134d979048c8b3375a13
Manishthakur1297/Card-Game
/Card_Game_Tests.py
1,923
3.609375
4
import unittest from .Card_Game import Game class MyTestCase(unittest.TestCase): def setUp(self): self.card = Game(4) def test_Condition1_WHEN_ALL_SAME(self): self.card.players = [['A', '7', 'J'], ['2', 'K', '6'], ['6', '9', 'A'], ['5', '5', '5']] self.assertEqu...
02a127f12fadce6caa83a161f0ddf6f02b00a84a
naffi192123/Python_Programming_CDAC
/Day1/2-aera_of_circle.py
223
4.3125
4
radius = int(input("Enter the radius: ")) pi = 3.14 if radius <= 0: print("invalid input") else: area = pi*(radius**2) perimeter = 2*pi*radius print("Area of circle is: ", area) print("Perimeter of circle is", perimeter)
3f8e211951fdd7afa36dbba5de54ae62befdf24c
JenZhen/LC
/lc_ladder/company/amzn/oa/Partition_Labels.py
1,223
4
4
#! /usr/local/bin/python3 # https://leetcode.com/problems/partition-labels/ # Example # A string S of lowercase letters is given. We want to partition this string into as many parts as possible # so that each letter appears in at most one part, and return a list of integers representing the size of these parts. # # Ex...
a51c0fca9a194b149626d8dacc1acc3ec3a45e33
MaximOksiuta/for-dz
/dz8/1.py
1,285
3.625
4
import datetime class Date: def __init__(self, date): self.date = date @classmethod def splitter(cls, date): return list(map(int, date.split('-'))) @staticmethod def validation(date): data = date[2] d = datetime.date.today() date[2] = d.year if data > d.ye...
7bfddd5e86844a9a1b79d3675b4a412aec7e88f1
tanran-cn/arithmetic-data_structure-py
/practice/Sum3.py
2,126
3.78125
4
# _*_ coding: utf-8 _*_ # 2019/3/28 16:01 __auther__ = "tanran" """ 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。 注意:答案中不可以包含重复的三元组。 例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4], 满足要求的三元组集合为: [ [-1, 0, 1], [-1, -1, 2] ] """ class Solution: def threeSum(self, nums: list) -> lis...
4237818115065574102271c16c031ffca4dbd8d3
GauriShrimali/Detect-Humans
/detectHuman.py
436
3.65625
4
#PROBLEM STATEMENT 10 #Input: A image contains a human or no human #Output: Prediction if the image contains a human or not import cv2 import imutils det = cv2.HOGDescriptor() det.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector()) image = cv2.imread('img.jpeg') (area, _) = det.detectMultiScale(image)...
8f0a836523a87dba09a2ca96745a75f1381494cf
Lorenzoksouza/DesafioKoper
/conversor.py
3,643
3.796875
4
from num2words import num2words from tkinter import * def numero_para_extenso(num_inicial="0"): """ Funçâo que converte numeros para seu formato por extenso com a entrada de um numero :param num_inicial: Double :return num_extenso: String """ LANG = 'pt-BR' if num_inicial != '': i...
8ec5c6d699c0c7f29e326a10f694608fbb29feaf
Takeda1/pythonPrograms
/src/ericjb/aiprojects/hw6/linalg_hw6.py
813
3.6875
4
""" A short script that will contain solutions to numpy exercises for CS444 HW6. """ import numpy as np # Declare numpy arrays here... A = np.array([[ 2, -5, 1], [ 1, 4, 5], [ 2, -1, 6]]) B = np.array([[ 1, 2, 3], [ 3, 4, -1]]) y = np.array([[ 2], ...
74887db1eea7edc9bb59fb5ed1159316da82f87a
drsagitn/algorithm-datastructure-python
/algorithms/reversed_linked_list.py
983
3.921875
4
""" Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL """ class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseList1(self, head: ListNode) -> ListNode: if head is None or head.next is None: ...
d1c18b8a9475bbf36ca814e6688e8f8beff5b40b
ningpop/Algorithm-Study
/06_이인규/week4/11050.py
236
3.703125
4
def factory(num,result): if num <= 1: return result return factory(num-1,result*num) n, k = map(int,input().split()) up = factory(n,1) down1 = factory(n-k,1) down2 = factory(k,1) print(int(up/(down1*down2)))
8fd3293d1aa45c419c19ed7057929378b2a02f9d
byAbaddon/Book-Introduction-to-Programming-with----JavaScript____and____Python
/Pyrhon - Introduction to Programming/7.1. Complex Loops/13. Fibonacci.py
99
3.609375
4
fib = int(input()) f1, f2 = 1, 1 for i in range(fib): f1 += f2 f1, f2 = f2, f1 print(f1)
a5480cd7a228418eef3052ead47446d2bd0af32a
Srinjana/CC_practice
/MISC/TCS NQT/minty.py
1,343
3.625
4
# Problem statement: # It was one of the places, where people need to get their provisions only through fair price(“ration”) shops. As the elder had domestic and official work to attend to, their wards were asked to buy the items from these shops. Needless to say, there was a long queue of boys and girls. To minimize t...
58c46a76f3153c9d97c843897a3c04e20f822fb7
JakubR12/cds-visual
/src/assignment-1.py
1,926
3.75
4
#!/usr/bin/env python """ Load image, find height and width, save output Parameters: path: str <path-to-image-dir> outfile: str <filename-to-save-results> Usage: assignment1.py --image <path-to-image> Example: $ python assignment1.py --path data/img --outfile results.csv ## Task - Save csv showing heigh...
62ea153c8a1167728642fa25359003fcc0a3571e
wattaihei/ProgrammingContest
/AtCoder/ABC-D/157probD.py
1,527
3.8125
4
class UnionFind(): # 作りたい要素数nで初期化 def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) # ノードxのrootノードを見つける def Find_Root(self, x): if(self.root[x] < 0): return x else: self.root[x] = self.Find_Root(self.root[x]) ...
48d4829e7da323d5810191291ad6a5f1e4c75bde
alabarym/Python3.7-learning
/get_sqrt.py
416
3.984375
4
import math def get_square_roots(number): sqrt_values = [] if number == 0: sqrt_values.append(0) return sqrt_values elif number < 0: return sqrt_values elif number > 0: sqrt_values.append(-math.sqrt(number)) sqrt_values.append(math.sqrt(number)) return s...
abb0644da7bf431ba81658c35af31206c83eb2f6
cdjasonj/Leetcode-python
/反转从m到n的链表,请使用一趟扫描完成反转.py
1,409
4.09375
4
''' 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 说明: 1 ≤ m ≤ n ≤ 链表长度。 示例: 输入: 1->2->3->4->5->NULL, m = 2, n = 4 输出: 1->4->3->2->5->NULL 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reverse-linked-list-ii 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' #超了 # Definition for singly-linked list. # class ListNode: # def __init__(se...
0780a48a2aa71410803dda82f23d45dba41add07
DatBiscuit/Projects_and_ChallengeProblems
/Projects/Challenge_Problems/Swap_Variables/sv.py
311
3.96875
4
v1 = 1 v2 = 2 #Your code goes here (Answer provided): v3 = v1 v1 = v2 v2 = v3 print(v1) print(v2) #OR v1 = 1 v2 = 2 #Your code goes here (Answer provided): v3 = v1 v4 = v2 v2 = v3 v1 = v4 print(v1) print(v2) #OR v1 = 1 v2 = 2 #Your code goes here (Answer provided): v1, v2 = v2, v1 print(v1) print(v2)
02b29b2ba0c29de84adf3553dd72202bfffe7bda
JeterG/Post-Programming-Practice
/CodingBat/Python/Warmup_2/array_count9.py
247
3.78125
4
#Given an array of ints, return the number of 9's in the array. def array_count9(nums): if (9 in nums)==False: return 0 else: count=0 for i in nums: if i==9: count+=1 return count
aef9d362fb85529544fdda4a2e23a4a599796896
FloMko/advent2017
/day3/circle.py
1,232
3.875
4
def neighbors(matrix, i=0, j=0, offset=0): """find sum of neighbor""" num = matrix[i-1+offset][j-1+offset] + matrix[i-1+offset][j+offset] + \ matrix[i-1+offset][j+1+offset] + matrix[i+offset][j+1+offset] + \ matrix[i+offset][j-1+offset] + matrix[i+1+offset][j-1+offset] + \ matrix[i+1+of...
1b733650922767a03670a581d19ef4bf8e07194f
lallmanish90/coltSteelePythonCourse
/https_requests/requests_module.py
325
3.5
4
""" **requests module ** -lets us make HTTP request from our Python code! -installed using pip -usedful fro webscraping/crawling, grabbing data from other APIs, etc - """ import requests url = "http://google.com" response = requests.get(url) print(f"your request to {url} came back w/ status code {response.status_cod...
b7e863fbd50670c02040cc926029f6fcc5a38cbe
amitjain17/FSDP2019
/DAY2/h2.py
521
4.1875
4
# -*- coding: utf-8 -*- """ Created on Wed May 8 16:03:53 2019 @author: NITS """ def leap(yr): #create function if yr%4 == 0 and yr%100 !=0 or yr%400 ==0: #if the number is divided by 4 and 400 than the number is leap year print ("year is leap year") return True else...
de8aaa2419023d53df3883debc2e7be39343c828
CarlosWillian/python
/exercicios/ex 011 a 020/ex012.py
178
3.765625
4
print('Descontão pra você') n1 = float(input('Digite o preço da sua compra: R$ ')) print('O valor a pagar com seus 5% de descontos aplicados é: R$ {:.2f}'.format(n1*0.95))
28be6543781556ee7b0b7af64eef83ddd78a8c30
JerinPaulS/Python-Programs
/ALlElementsInBST.py
1,729
3.9375
4
''' 1305. All Elements in Two Binary Search Trees Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order. Example 1: Input: root1 = [2,1,4], root2 = [1,0,3] Output: [0,1,1,2,3,4] Example 2: Input: root1 = [1,null,8], root2 = [8,1] Outpu...
97606ee8f5f901138b652e2abac9a5e989a29804
lucasoliveiraprofissional/Cursos-Python
/Curso em Video/desafio086b.py
766
4.375
4
'''Crie um programa que crie uma matriz de dimensão 3x3 e preencha com valores lidos pelo teclado. No final, mostre a matriz na tela, com a formatação correta.''' '''Fiz a versão b pois quis ver o que na dele não estava igual ao meu, pois o meu segundo meu raciocinio está certo, porém não funciona.''' matriz= [[0, 0,...
c9aff1967a82faa6f477aed11bbc7deb8ce96efb
hofmanng/algoritmos-faccat
/prog117.py
411
3.984375
4
# # Faca um programa que peca dois numeros, base e expoente, calcule e # mostre o primeiro numero elevado ao segundo numero. Nao utilize a # funcao de potencia da linguagem. # # Declaracao de variaveis e entrada de dados base = int(input("Insira a base: ")) exp = int(input("Insira o expoente: ")) mult = 1 # Processa...
ca6779bcc9a445cfece9272cc3c17d3f34a90931
aalicav/Exercicios_Python
/ex068.py
429
3.765625
4
from random import choice resultado = choice(['PAR','IMPAR']) c = 0 while True: escolha = str(input('Escolha [Par ou impar]:')).upper().strip() if 'PARIMPAR' not in escolha: escolha = str(input('Escolha [Par ou impar]:')).upper().strip() if escolha != resultado: print(f'Você perdeu, mas ganh...