blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
71c5fefd77ff7b9817412d42f7b97fb425ee7c6c
cesarschool/cesar-school-fp-2018-2-lista1-giovanninp
/questoes/questao_5.py
884
3.53125
4
#Essa questão é relacionada à um calculo de uma possível perda de tempo #causada pelo consumo de cigarros. #A função ceil foi importada para fazer o arredondamento dos valores from math import ceil #Info de boas vindas: print('\nBem-Vindo ao FumanteSoft\n') #Entrada de dados: tempFumo = int(input('Digite o numero de...
4693c1ad5101c4b0a6a00635a76867320ba9430d
heyman333/datastructure_python
/QuickSort.py
1,500
4.21875
4
def quick_sort(list, start, end): # repeat until sublist has one item # because the algorithm is using in-place space, we can not use len(list) instead we use start, end for sublist if start < end: # get pivot using partition method pivot = partition(list, start, end) # recurse quick...
b2b0d1c6079185a3395fddcd8a097e3ca5c90494
kmike/funny-codes
/funny_codes/__init__.py
2,062
3.65625
4
# -*- coding: utf-8 -*- from __future__ import absolute_import from random import choice class FunnyCodes(object): """ Class for generating random strings of a given pattern and measuring some metrics. """ LETTER_GROUPS = [ u"AEIOUY", u"BCDFGHJKLMNPQRSTVXZ", u"123456789", ...
454ae7d26f1aae0aab6b77e558d79fb6fa1cf937
VineeS/Python
/Assignment1/factorial.py
201
4.28125
4
# factorial of a number num = int(input("Enter the value for which you need factorial ")) fact = 1 i = 1 while i <= num: fact = fact * i i = i + 1 print("factorial for ", num , "is" , fact)
d2a1b8f3de306c0900b5b7ac005ae361f33a3fdc
t-xim/challenges
/hackerrank/halloweenparty.py
678
3.796875
4
# https://www.hackerrank.com/contests/coding-challenge/challenges/halloween-party/problem # Difficulty: Easy import math # 2 methods of doing it # 1 is a simple multiplication of a floor of one number and the ceiling of another (half of K) # using a summation where you add 1 1 2 2 3 3 4 4 etc (floor n/2 + 1 from n = ...
c365f3a70a5656b38f759bbf907697c1f793a7c6
evanavaughan/byte-work
/week2/week2_day2/day2/03-student/03-student.py
564
3.78125
4
class Student(): pass def __init__(self, first_name, last_name, age, grades): self.first_name = first_name self.last_name = last_name self.age = age self.grades = grades def addgrade(self, grade): # adds grade to list of grades self.grades.append(...
178dc8a67680905cda7058f0f0e5b2f2c3bee6bf
chenrong1105/chenrong_zuoye
/pythoncs/mxdx_demo/mxdx_hhgame_demo2.py
859
3.90625
4
''' 一个多回合制游戏,每个角色都有hp 和power, hp代表血量,power代表攻击力,hp的初始值为1000, power的初始值为200。打斗多个回合 定义一个fight方法: my_hp = hp - enemy_power enemy_final_hp = enemy_hp - my_power 谁的hp先为0,那么谁就输了 ''' import random class Game: def fight(self): self.my_hp = 3 self.my_power = random.randint(0,3) self.your_hp = 3 ...
6f46ab3e516d3971d5a8eb4e4e92e64daa309b11
Fr1tzler/leetcode
/16xx/1669.py
483
3.796875
4
class Solution(object): def mergeInBetween(self, list1, a, b, list2): first_part = list1 while a - 1: a -= 1 b -= 1 first_part = first_part.next second_part = first_part.next while b: b -= 1 second_part = second_part.next ...
c6a6d327e1acf287f156dd90702a26e7000e718a
jusuni/FirstProjectTest
/venv/MovedAssignment1.py
5,704
3.9375
4
# ASSIGNMENT JULIO SUNI # IMPORTING DATETIME TO BE USED AFTER WHEN CREATING THE REPORT: import datetime today = datetime.date.today() # IMPORTING CSV TO BE ABLE TO READ THE CSV FILE import csv as cs # USING "try" AND "except" IN CASE THERE IS AN ERROR READING THE FILE: try: #CREATING THE CONNECTION WITH THE FILE...
47e159e640142d6e38cef62470ad39a5b4db0dce
wandersoncsouza/Fundamentos-de-programacao
/exercicio_006.py
516
3.703125
4
#CEDERJ - SÃO FIDELIS - FUNDAMENTOS DE PROGRAMAÇÃO #WANDERSON C. SOUZA print('Faça um programa que leia o nome de um vendedor, o seu salário fixo e o total de vendas efetuadas por ele no mês (em dinheiro).') print('Sabendo que este vendedor ganha 15% de comissão sobre suas vendas efetuadas, informar o total a receber n...
4bcdcf0fa8bdac4f65274c2ae2d6c6a423647e7c
Bombenchris/LeetCode-in-Python
/Array/229 Majority Element II.py
1,013
3.578125
4
from typing import List import collections class Solution: def majorityElement(self, nums: List[int]) -> List[int]: Count = dict(collections.Counter(nums)) times = len(nums)//3 Output = [] for key,value in Count.items(): if value > times and len(Output)<2: ...
b003755f7c86a2090306c49f6ca118423269f414
athenian-ct-projects/Food-Ninjas-JC
/Food-Ninjas-JC.py
4,674
4.03125
4
import random x = random.randint(0,5) #Story Line/ Instructions fooditems = ("Terkey", "Piza", "Chps", "Weffles", "Sandwhich", "Samon", "Checken Breaasts","Fired Chikens","Chiken Wings", "Cups of Nodles", "Burgrs", "Firied Rice", "Eggs and Bacoon", "Chick Mcnuget", "Gummmie Bear", "Friies", "Doonut", "Porck", "Brock...
5804617a0bcc698c68ca7ba8afb4a512a3b0e056
shunty-gh/samples
/python/all-paths.py
1,579
3.875
4
from collections import defaultdict class Graph: def __init__(self, vertices): self.V = vertices self.graph = defaultdict(list) def add_edge(self, u, v): self.graph[u].append(v) def printAllPathsUtil(self, u, d, visited, path): # Mark the current node as visited and stor...
891e022c91113bcc601318ad78f5a3d9aa43e790
hnoskcaj/WOrk
/8.py
505
3.609375
4
import sys m = int(sys.argv[1]) d = int(sys.argv[2]) y = int(sys.argv[3]) h = y- (14-m)/12 i = h + h/4 - h/100 + h/400 j = m + 12 * ((14 - m)//12) - 2 k = (d + i + (31*j)/12)%7 l = round(k) if l == 0: print("Sunday") else: if l == 1: print("Monday") else: if l == 2: print("Tuesday") else: if l == ...
4b5546cf668c6ddfed75db301df485b6159f2338
huiba7i/Mycode
/python/class code/code4.24/异常/异常类型.py
290
3.640625
4
# 1. 异常是有类型的 程序执行过程中出现的异常都是有数据类型的 # print(1/0) # 1.1 ZeroDivisionError # b = [1, 2, 3] # print(b[0]) # print(b[3]) # 1.2 IndexError # d = {"name": "lucy"} # print(d["age"]) # 1.3 KeyError a = 1 b = "2" print(a + b) # 1.4 TypeError
7d496e0c27c22b0bffbab45de29d0719370ae95c
icemanblues/advent-of-code
/2017/day01/day01.py
806
3.59375
4
from typing import List day_num = "01" day_title = "Inverse Captcha" def read_input(filename: str) -> List[str]: with open(filename) as f: content = [x.strip('\n') for x in f.readlines()] return content def part1(): line = read_input("input.txt")[0] curr = line[len(line)-1] count = 0 ...
f3b55c87a46271574f0a5872d3385edebe116290
Iswaria-A/ishu
/python/ex33.py
260
4
4
arr1=[1,2,3,4,5]; arr2=[None]*len(arr1); for i in range(0,len(arr1)): arr2[i]=arr1[i]; print("Elements of original array:") for i in range(0,len(arr1)): print(arr1[i]), print(); print("Elements of second array:") for i in range(0,len(arr2)): print(arr2[i]),
e25654b5a4c0223b93c36444ec3f327880bf4521
Newton-Musyimi/CSc-101-Practicals
/Prac 8/dice_roll.py
834
3.828125
4
import random import turtle wn = tr.Screen() #creates our game board wn.bgcolor("black") g = turtle.Turtle() c = turtle.Turtle() llx = 0 lly = 0 urx = 200 ury = 100 wn.setworldcoordinates(llx,lly,urx,ury) number_of_dice = rolls = 10000 min_val = number_of_dice max_val = number_of_dice * 6 for i in r...
b218db2967c9539c98ef083f8a4b4f94bbfa7f19
imechemi/pythonds
/postfix_evaluator.py
658
3.875
4
import stack from stack import Stack def calculate(op1, op2, operator): if operator == '-': return op1 - op2 elif operator == '+': return op1 + op2 elif operator == '*': return op1 * op2 elif operator == '/': return op1 / op2 def evaluate_postfix(postfix): operand_stack = Stack() expr...
c5498a090cf29da0906378c985e956346b395639
Woocheck/Python_excercise
/excercises/scrap2.py
1,396
3.515625
4
import requests import lxml.html as lh import pandas as pd #url = "https://en.wikipedia.org/wiki/List_of_Presidents_of_the_United_States" url = "https://www.orlen.pl/PL/DlaBiznesu/HurtoweCenyPaliw/Strony/archiwum-cen.aspx?Fuel=Pb95&Year=2020" page = requests.get(url) doc = lh.fromstring(page.content) tr_elements = ...
3a6e260d721f75a997efca29e63b142c8797180f
Explorerqxy/review_practice
/028.py
445
3.765625
4
def Print(pRoot): if not pRoot: return [] queue = [pRoot] outList = [] while queue: res = [] nextQueue = [] for point in queue: res.append(point.val) if point.left != None: nextQueue.append(point.left) if point.right != ...
342807973b5093d0ae1301116e3907087e56d847
diegoami/example-code
/01-data-model/first.py
796
3.5625
4
from frenchdeck import FrenchDeck, Card beer_card = Card('7', 'diamonds') print(beer_card) deck = FrenchDeck() print(len(deck)) print(deck[:3]) print(deck[12::13]) print(Card('Q', 'hearts') in deck) print(Card('Z', 'clubs') in deck) for card in deck: # doctest: +ELLIPSIS print(card) for card in reversed(deck): ...
bbe9b5677cc4f6546a41ddc2d428cc0edb2073c8
jamesaduke/toy-problems-new
/hacker-rank/hackerrank-problem-solving-algorithms/birthday-cake-candles.py
1,044
4.3125
4
# You are in charge of the cake for your niece's birthday and have decided the cake will have one candle for each # year of her total age. When she blows out the candles, she’ll only be able to blow out the tallest ones. Your task # is to find out how many candles she can successfully blow out. # # For example, if your...
c0e5b228da4eab68c84bcdb5d3516a08a94a8deb
jbclement87/tuto-python
/exo-5.11.py
321
3.671875
4
t1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] t2 = [ ' Janvier ' , ' Février ' , ' Mars ' , ' Avril ' , ' Mai ' , ' Juin ' , ' Juillet ' , ' Août ' , ' Septembre ' , 'Octobre ' , ' Novembre ' , ' Décembre ' ] a = 0 t3 = [] while a < len(t1): t3.append(t2[a]) t3.append(t1[a]) a = a+1 print(t3)
07bda099dee874a5f2c802b1c82fb169bd649c23
rogeriosilva-ifpi/ifpi_ads_algoritmos_2020
/algoritmos_fabio01_parte02/f1_p2_q7_dias_horas_minutos.py
346
3.671875
4
# Leia um número inteiro de minutos, calcule e escreva quantos dias, quantas horas e quantos minutos ele corresponde. minuto = int(input('Digite o número em minutos: ')) dias = minuto // 1440 horas = minuto % 1440 // 60 minutos = horas % 60 print(f'{minuto} minutos equivalem a {dias} dia(s) {horas} horas(s)...
3d5a376ae582c43adae320bff66227705dd18b68
sathappan1989/Pythonlearning
/Awesomenesscomprehensions.py
352
4.46875
4
#Awesomeness #Store five names in a list. Make a second list that adds the phrase "is awesome!" to each name, using a list comprehension. #Print out the awesome version of the names. names =['sachin','rohit','klrahul','kohli','ashwin'] great_names=[name.title() + " the great!" for name in names] for great_name in gr...
ef2c2a5176a9698e413285bfd411c12a2415cf0e
bunshue/vcs
/_4.python/tkinter/tk_Canvas2_draw5_SierpinskiTriangle.py
1,244
4
4
from tkinter import * # Import tkinter def display(): canvas.delete("line") p1 = [width / 2, 10] p2 = [10, height - 10] p3 = [width - 10, height - 10] displayTriangles(order, p1, p2, p3) def displayTriangles(order, p1, p2, p3): if order == 0: # Base condition # Draw a triangle to c...
7ba4e6777343195022e776cfe4fc2066f7ee9b44
Iamrhema/Projects
/Python/InvestmentCalculator.py
871
3.859375
4
import math #User enter their data. P = float (input("Enter how much you want to invest? R")) i = float (input("Enter your interest rate? ")) t = float (input("How long will you be investing? ")) interest = input("\nWhat type of investment would you like Simple or Compound interest (Compound or Simple) ? ").lo...
a664af17b69e56d40a1c2c703b7f138df3c330bf
originalMemory/algorithmPython
/heap_sort.py
2,552
3.71875
4
# coding=utf-8 """ @project : algorithmPython @ide : PyCharm @file : heap_sort @author : illusion @desc : 堆排序 @create : 2021/6/7 1:25 下午:37 """ class Solution: def heapSort(self, nodes: [int]) -> [int]: length = len(nodes) for i in range(length // 2 - 1, -1, -1): self.sink...
59f2d1883c271ec52050da228c83f7ab633a328f
qianlv/learning
/leetcode/palindrome_number.py
568
3.65625
4
# encoding=utf-8 class Solution: # @param {integer} x # @return {boolean} def isPalindrome(self, x): # 转化为字符串(感觉不可以?) # return str(x) == ''.join(list(reversed(str(x)))) # 或 return str(x) == str(x)[::-1] ans = 0 if x < 0: return False # 翻转数x ...
0384d6b292a3a1364fa102930871c3f388f12b54
yanbinkang/problem-bank
/interview_cake/nth_fibonacci.py
288
3.625
4
def fib(n): if n < 0: raise Exception("Index was negative.") elif n in [0,1]: return n prev = 0 prev_prev = 1 for index in range(n): current = prev + prev_prev prev_prev = prev prev = current return current print fib(5)
5022d28bb20d2dd6c29f6c55fa99840724f1981d
CNife/leetcode
/Python/code/longest_valid_parentheses.py
500
3.59375
4
from leetcode import test def longest_valid_parentheses(s: str) -> int: stack = [-1] result = 0 for i, c in enumerate(s): if c == "(": stack.append(i) else: stack.pop() if stack: valid_len = i - stack[-1] result = max(resu...
23553970ce9868ddb1dee3586ab5430bb4a23102
dlemel8/exercism_python
/isbn-verifier/isbn_verifier.py
301
3.640625
4
import string def verify(isbn): digits = [d for d in isbn if d in string.digits + 'X'] if len(digits) != 10: return False digits[-1] = '10' if digits[-1] == 'X' else digits[-1] multiples = [(10 - i) * int(d) for i, d in enumerate(digits)] return sum(multiples) % 11 == 0
23f8bf84fdca544318414c8ced5d306acb40eb0d
repsac/invert_tree
/invert_tree.py
5,932
4.34375
4
""" Given a tree structure, take the values and invert them left to right. Since the group (graph, tree, etc) can be arbitrary, like the example below, it can't be effectively represented in a flat list like a binary tree example 0 / | \ / | \ 1 2 3 /|\ \ ...
ddbe1c5ceb00efb5177bde03ccf71faa0210daee
luwei19941010/python_12
/homework-update.py
3,433
3.515625
4
#-*-coding:utf-8-*- # Author:Lu Wei def shop_list(): with open('goods.txt', mode='r', encoding='utf-8') as f: while True: print('欢迎使用LW的购物商场【商品管理】【查看商品列表】\n'.center(30, '*')) l_look=[] for i in f: l_look.append(i.strip()) shop_length=len(l_loo...
4e9c8a9a81874de43538207113cf282a4a197797
00derp/Tamatebako
/mahal_calc/simple.py
3,636
3.609375
4
#!/usr/bin/env python2.4 import matrix.matrix as mm import pdb class mmatrix(mm.matrix): def __init__(self, size): mm.matrix.__init__(self, size) def mean(self): """ Return a mean vector as a list. """ c,r = self.size(); float(c); float(r) mean_vector = [] ...
5a52ac2cdfadda853eb8cdb40ee53425642f80fd
LysanderGG/HackerRank
/Algorithms/Implementation/FindDigits.py
284
3.671875
4
#!/bin/python3 import sys def find_digits(n): ans = 0 for i in [int(char) for char in str(n)]: if i > 0 and n % i == 0: ans += 1 return ans t = int(input().strip()) for a0 in range(t): n = int(input().strip()) print(find_digits(n))
6899e4bbbc368d2ca59214abb75aade13d339315
mjgpy3/mfp-python3-examples
/chapter02/page020_026.py
1,874
3.703125
4
#!/usr/bin/env python3 from page018_020 import * from random import choice class Grid: def __init__(self, rows, columns): self.rows = rows self.columns = columns self.grid = self.prepare_grid() self.configure_cells() def prepare_grid(self): grid = [] for row in range(self.rows): g...
75665b33bc954275564951e1beb7f2504d63b796
avasilistov/OOP
/hero_decorator.py
2,752
3.890625
4
from abc import ABC, abstractmethod class Hero: def __init__(self): self.positive_effects = [] self.negative_effects = [] self.stats = { 'HP': 128, # health points 'MP': 42, # magic points 'SP': 100, # skill points 'Strength': 15, ...
405ccaa9486930735e65a101439b5337846b40ff
Ys-Zhou/leetcode-medi-p2
/1-100/Rotate_List.py
848
3.8125
4
# 230 / 230 test cases passed. # Runtime: 52 ms # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int ...
08829eccb0175aee63b97b6986edae04a63eb582
parasjain06/repo_
/src/postProcessing/PostProcessGaze.py
1,219
3.671875
4
from src.Notifier.Notifier import notify #Assuming:- Average time taken to process one frame is 2 seconds def calculateMin(frameCount): return (frameCount*2)/60 def notifyGaze(totalFrames,unAttentiveFrames): webexNotify ="" totalMins = calculateMin(totalFrames) unAttentiveMins = calculateMin(unAttenti...
9b730d0806eb867c9a2c8afd40a4b17f7e22cb03
lyl0521/lesson-0426
/homework/day05/homework07.py
1,325
3.671875
4
# mao from filecmp import cmp def square(x): return x ** 2 # map()的返回值已经不再是list,而是iterators, 所以想要使用, # 只用将iterator 转换成list 即可,比如 list(map()) print(list(map(square, [1, 2, 3, 4, 5]))) print(list(map(lambda x: x ** 2, [1, 2, 3, 4, 5]))) print(list(map(lambda x, y: x + y, [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]))) ...
e3a4eca22b3b846b1a3d577243d97dfec6d09115
Drlilianblot/tpop
/TPOP Python 3.x Practicals/library/library_application.py
3,981
3.75
4
## import all the classes from the file library.py ##(change the name of the file to your file containing YOUR ## classes Item, Member, Library, ...). We assume both files are in ## the same directory. from library import * ## Create a new instance of library main_library = Library() UID_base = 1 ## This is a meth...
eff9d11bb5f66b9043efb105b8693acf410794cf
ssantichaivekin/algos
/syntax_tree/Operator.py
1,173
4.25
4
''' Class operator define operator, how many arguments it gets, how to read (read via left to right or right to left), (or is it a prefix, suffix?) and how to evaluate such operators. ''' import re class Operator: def __init__(self, name, symbol, prec, num, rule) : ''' Initialize the Operator...
74724d389f02667ca5d8212849d9ff189b1a7c7a
rishabhsxn/Codes
/python3/coursera/Course2/assignments/ass7_2.py
947
4.09375
4
# Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: # X-DSPAM-Confidence: 0.8475 # Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. #...
c0c5473eabeed7401a7e65879332d1800d089ab0
anisko13/HW_Python_Start
/HW_Start_9/HW9_1.py
294
3.8125
4
text_1, text_2 = input('Your first word '), input('Your second word ') text_1_set = set(text_1) print(text_1_set) text_2_set = set(text_2) print(text_2_set) print(text_1_set.intersection(text_2_set)) print( set(input('first text ')) .intersection(set(input('second text '))) )
c374b9c8055a41392ae360ad81cc0f1f062c9e66
akshayjaryal603/oops_concept_python
/class_inbuilt_function.py
673
4.125
4
class Student: def __init__(self, name, id, age): self.name = name self.id = id self.age = age # creates the object of the class Student s = Student("John", 101, 22) # prints the attribute name of the object s print(getattr(s, 'name')) # reset the value of attribute age to 23 ...
d7c703dbf4a9848e7ff09d0b8426db4900b156ef
hyun-minLee/20200209
/st01.Python기초/py07선택문/py07_01ex1_if홀짝.py
957
3.859375
4
# 정수를 입력을 받습니다. # 입력 받은 문자열을 정수로 바꿉니다. # 문자열로 변환 ####################################### # 방법1. 문자열을 사용하는 방법 # 방법2. 나머지를 사용하는 방법 ####################################### ####################################### # 방법1. 문자열을 사용하는 방법 ####################################### # 마지막 자리 숫자를 추출 # 숫자로 변환하기 # 짝수 확인 # 홀수 확인 x=...
712563a8deb73e12459b01b4fd3e79f00644e140
blueboy1593/KAKAO_problem_solving
/2020_KAKAO_BLIND_RECRUITMENT/블록이동하기.py
1,589
3.796875
4
# BFS or 다익스트라 문제 # 다익스트라로 중간중간 단계를 어떻게든 표현을 하거나, # BFS로 겹치는 것이 있더라도 모든 경우의 수를 테스트하거나 # BFS는 visited로 하나씩만 방문할 때 썼던거라... 다익스트라를 해줘야할 것 같은데 ㅠㅠ def solution(board): answer = 0 # print(board) N = len(board) visited = [ [ [0,0] for _ in range(N) ] for _ in range(N) ] # 오우야! 이런식으로 3차원 배열 만드는 거구나. # vi...
3dc0f9993ed4cb4a7810f9a03811e581fbed3ff9
souravsaini/python-progs
/static_variable.py
449
3.671875
4
#!/usr/bin/python3 class Human(object): ''' Going to be Static variable ''' count = 0 ''' Constructor ''' def __init__(self): ''' Made static ''' Human.count += 1 ''' To String ''' def __str__(self): return str(Human.count) ''' Destructor ''' def __del__(self): print("Destroyed") if __name__ == '__...
72940bdd2bee4ee599ef4761756c03f678109b42
ankitsharma07/100PythonQuestions
/classVariable.py
929
3.921875
4
# Class variable and instance variable class CS_Student: # class variable stream = 'CSE' # init method def __init__(self, roll): # instance variable self.roll = roll # Object of CS students a = CS_Student(101) b = CS_Student(102) # Check for few things print(a.roll) print(a.stream)...
e9cddbcf0aeea41c130f61a2a6081edbe89271c0
vpatov/ProjectEuler
/python/projecteuler/complete/01-50/p015.py
905
3.6875
4
""" Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. https://projecteuler.net/problem=15 How many such routes are there through a 20×20 grid? """ import time startTime = time.perf_counter() size = 20 ### Recurs...
454412058391f45f85d26794d8d9235103ff1e4c
kingachlebek1/02-TypesandVariables
/02-TypesandVariables/2.zad.18.py
150
4
4
x=input("height(cm): ") x=int(x) inch=x/2.54 feet=int(inch/12) inch=inch-(feet*12) print(f"I am {x}cm tall, i.e. {feet} feet and {inch} inches.")
2e4202a40273fc1d2a8034856bb306050b9c725e
emmanavarro/holbertonschool-higher_level_programming
/0x11-python-network_1/2-post_email.py
589
3.53125
4
#!/usr/bin/python3 """ script that takes in a URL and an email, sends a POST request to the passed URL with the email as a parameter, and displays the body of the response """ import urllib.parse import urllib.request from sys import argv if __name__ == "__main__": url = argv[1] values = {'email': arg...
4bd40acd9c4453f9986a69a6c80dda49ee737845
Priyojeet/man_at_work
/Practice_files/number_count.py
465
3.921875
4
length = int(input("enter the number of elements you want:-")) def count_duplicate(arg): count = 0 for i in range(len(arg)): for j in range(i + 1, len(arg)): if (arg[i] == arg[j]): count += 1 break return count def create_list(arg): l=[] for i in...
f79c7d032214368b79caa9d1cdf80ebcf3775501
Sakshipandey891/sakpan
/greater_than_100.py
240
4.125
4
# number is greater than 100 or not? a=int(input("enter first number:")) b=int(input("enter second number:")) c=int(input("enter third number:")) x=(a+b)*c if x>100: print("greater than 100") else: print("less than 100")
ea7fda777f06c5c705ed444f99dfff9cf335b89f
naramdash/algorithm
/goorm/49087 여름의대삼각형/solution.py
533
3.765625
4
def solve(x1, x2, x3, y1, y2, y3): slope1to2 = abs((y2 - y1) / (x2 - x1)) slope2to3 = abs((y3 - y2) / (x3 - x2)) if slope1to2 == slope2to3: return 0 return round(abs((x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 * y2 + x1*y3)) / 2, 2) user_input_1 = input() user_input_2 = input() user_input_...
9db2c156b1d83e37f24bdada95bac690662ff7e4
paauwp/Human-Face-Detection
/face.py
1,526
4.09375
4
import cv2 #loading the test image #The function imread() loads an image from the specified file and returns it as a numpy N-dimensional array image = cv2.imread("test.jpg") #Before we detect faces in the image, we will first need to convert the image to grayscale, #that is because the function we gonna use t...
284d30197d437f4e1582a5bec8c6de04595c2b6f
kcwebers/Python_Fundametnals
/OOP/baby_steps.py
5,109
4.53125
5
class User: pass    # we'll fill this in shortly michael = User() anna = User() # The first parameter of every method within a class will be self, and the class's attribute names are also indicated by self.. # We'll talk more about self later, but for now just follow this pattern: self.<<attribute_name_of_your_c...
a0eca8532282e26666305b1f40f5a87a8502944f
thesayraj/DSA-Udacity-Part-II
/Project-Show Me Data Structures/problem_1.py
2,592
3.78125
4
class Node(object): def __init__(self,key,value): self.key = key self.value = value self.prev = None self.next = None class LRU_Cache(object): def __init__(self, capacity): self.capacity = capacity self.HashTable = dict() #dummy hea...
38ba64019551b1035bbc29e34db2fd901efb71e7
Bhavikaj97/python_codes
/count.py
687
3.9375
4
class node: def __init__(self,data): self.data = data self.left = None self.right = None def countnode(node): count = 0 if node is None: return 0 elif node.left is not None and node.right is not None: count = 1 + countnode(node.left) + countnode(node.r...
f3695ccc284a0a3a40067eae3dbc8e0cffffdcff
saurabhchris1/Algorithm-Pratice-Questions-LeetCode
/Binary_Tree_Right_Side_View.py
1,508
3.984375
4
# Given the root of a binary tree, imagine yourself standing on the right side of it, # return the values of the nodes you can see ordered from top to bottom. # # Input: root = [1,2,3,null,5,null,4] # Output: [1,3,4] # # Input: root = [1,null,3] # Output: [1,3] # # Input: root = [] # Output: [] # Definition for a bina...
0617307e6b8afdd4c80f49125c83087f21d75d8e
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/b0832682e654426faad06b7964bde2be.py
1,146
3.984375
4
""" Utility to get the date of meetups. Written by Bede Kelly for Exercism. """ import datetime from calendar import monthrange __author__ = "Bede Kelly" def meetup_day(year, month, weekday, selector): """Returns the date of a meetup.""" teenth_days = range(13, 20) # 20th not included. weekdays = ["Mon", ...
e50f5cbd83531b780cd41404aa9ec0ea42578930
Digya053/tensorflow
/hello_world.py
528
3.546875
4
import tensorflow as tf #create placeholders with the names you want to display in tensorboard x = tf.placeholder("float", name="X_name") y = tf.placeholder("float", name = "Y_name") addition = tf.add(x, y, name="addition_name") #create the session session = tf.Session() with tf.Session() as session: result = se...
499558c67a2bcb49309ba53afaaba38ceb06dc67
Yaoaoaoao/LeetCode
/algorithms/438_find_all_anagrams_in_a_string.py
1,531
3.5
4
class Solution(object): def findAnagrams(self, s, p): """ :type s: str :type p: str :rtype: List[int] """ if len(p) > len(s): return [] result = [] p_profile = [0 for _ in range(26)] for i in map(lambda x: self.index(x), list(p)): p_profile[i] += 1 # load prev...
aae5bbf953d252c0460e386a57b33741eac7c037
amartya-dev/java-learning
/strings/binarystring.py
634
3.546875
4
def binarySubstring(n,s): #code here low = 0 high = n-1 count = 0 while low<high: while True: if s[low]=='1': break low+=1 while low<high: print(low,high,count) t...
5f60c623c0eefece2aca9ccc877f072685484e8a
lhalla/advent-of-code-2019
/src/main/aoc/modules/wire.py
2,688
3.8125
4
#!/usr/bin/env python3 class WireNode: def __init__(self, x: int, y: int) -> None: self.x: int = x self.y: int = y self.wires: {int} = set({}) self.wire_steps: {int, int} = {} def add_wire(self, wire_no: int, wire_steps: int) -> None: self.wires.add(wire_no) if...
818c5d415f80a88f859eaa5f746960e34e4e2b52
lhd0320/AID2003
/official courses/month02/day03/file_read.py
619
3.75
4
# f = open("file", "r") # data = f.read(2) # print(data) # data = f.read() # print(data) # f.close() f = open("file", "r") # # while True: # # data = f.read(1024) # # if not data: # # break # # print(data) # data=f.readline() # print(data) # # # data=f.readlines() # # print(data) # # for line in f...
d005da9bd8ee5fcd53efdbf07d04745be4c3b920
daniel-reich/turbo-robot
/yFEMocjdiRjPhoDqv_23.py
1,090
4.03125
4
""" Create a function that returns `True` if there's at least one prime number in the given range (`n1` to `n2` (inclusive)), `False` otherwise. ### Examples prime_in_range(10, 15) ➞ True # Prime numbers in range: 11, 13 prime_in_range(62, 66) ➞ False # No prime numbers in range. prim...
d9d3b388153eadfbe4393e87dc06e4c94e7408f1
LennyBoyatzis/code-challenges
/problems/arrays_and_strings/find_second_min_element.py
487
4.09375
4
from typing import List def find_second_min(nums: List[int]) -> int: """Finds the second minimum element of an array""" first = second = float('inf') # Sentinel value as inf is always greater for num in nums: if num <= first: first, second = num, first elif num < second: ...
d1543e1e497787c90947abf660e62b80af4bba00
abuultjens/pearsonR_stream
/pearsonR_stream.py
1,126
3.53125
4
# python3.7 import fileinput import numpy as np import pandas as pd from scipy.stats.stats import pearsonr # get positional arguments import sys DATA = sys.argv[1] TARGET = sys.argv[2] # read in target file target = pd.read_csv( TARGET, header=0, index_col=0) # convert target to list of integers target_li = [] for...
9b2e4f5c3dcfbae72d53bb0cfedbdd29ab78e419
leandrohvieira/Python---Jogos
/Jogos/jogos.py
516
3.578125
4
import forca import adivinhacao def escolha_jogo(): print('********************************') print('****\033[1;30mEscolha o jogo desejado!\033[m****') print('********************************') print('(1) Forca (2) Adivinhação') jogo = int(input("Qual jogo?")) if (jogo == 1): ...
d28b73ae08dc62ac1f8d761c30d25c70de4c6c6b
Lee-Seonghyun316/class-python
/Day8 예외 처리와 파일/3 시저암호.py
754
3.5625
4
import string # Day8 폴더 안에 있어야 실행 된다! # 시저 암호를 구현하시오 # 평문이 들어있는 파일을 읽고 # 위의 암호표를 참고하여 변환한 후 # 평문 아래에 변환된 내용을 적으시오 # 모두 소문자로만 한정한다 # Ex) i am a boy # -> o dp d erb f = open("./Day8 예외 처리와 파일/3.txt", 'r') data = f.read() f.close() # 소문자만 받는 시저 암호 def solution(s, n): s = list(s) for i in range(len(s)): ...
94f2eb05880e68728b8743b736390d11b771f803
Nononolan45/python_ipssi
/test.py
723
3.625
4
# a = 12 # b = 20 # mot = "bonjour" # f = 10.5 # result = a + b # converted = str(result) # print result # print(type(converted)) # liste = [1,2,3,4,5,6,7,8] # list2 = [1,2,3,4,5,6,7] # liste = liste + list2 # print liste[0] # liste.append(12) # liste.remove(12) # liste.index(0) # print liste # while i < 10: # ...
918d6f832a333ff465d3db426dab52c73bf8037d
Realcomms/Python
/001.FirstStart/09.리스트.py
811
3.9375
4
# 리스트 name = [] print(name) print(type(name)) name2 = ["Seoul"] print(name2) # 리스트 만들기 int_list = [1, 2, 3, 4, 5] float_list = [1.1, 2.2, 3.3, 4.4, 5.5] string_list = ["Seoul", "Daejeon", "Daegu", "Busan", "Jeju"] all_list = [int_list, float_list, string_list] print(int_list) print(float_list) print(string_list) pri...
619d62fe5724c5bb5b973d015ba36ddfa6d152e9
avenet/project_euler
/14-longest-collatz-sequence.py
485
3.890625
4
def collatz_sequence_length(number): l = 1 while number != 1: if number %2 == 0: number = number / 2 else: number = number * 3 + 1 l+=1 return l number = 1 longest_length = 0 answer = 1 while number < 10**6: collatz_length = collatz_se...
0c53a415102d409c274929afb88e3062503d4dcb
Roshni-jha/ifelse
/maximum nu.py
123
3.984375
4
a=int(input("enter a number")) b=int(input("inter a number")) if a>b: print("maximum no") else: print("minimum no")
5c53361dcedfa2e79ed14006b8e0713f1c90da08
Sarkar-Physics/Python
/euler_CR.py
1,096
3.640625
4
import numpy as np import matplotlib.pyplot as plt def f(x,y): return (V-y/C)/R #R=10000.0 #C=1*10E-6 #(0.00001) #V=5.0 R=float(input("Enter R:")) C=float(input("Enter C:")) V=float(input("Enter V:")) #a=0 #b=1 a=float(input("Enter initial time(in sec):")) b=float(input("Enter required time(in se...
4057d7a7a92bf52d82220d79548d1d58d6b84edb
ngladkoff/2020P1
/ejerciciosRegistros.py
1,502
3.796875
4
class Fecha: def __init__(self, dia, mes, anio): self.dia = dia self.mes = mes self.anio = anio def __repr__(self): return "{0}/{1}/{2}".format(self.dia, self.mes, self.anio) def __str__(self): return "{0:02d}-{1:02d}-{2:4d}".format(self.dia, self.mes, self.anio) cla...
0b5b0b817b095318d9c5e64021c1fcc86962376e
msps9341012/leetcode
/Backtracking/permutations.py
1,064
3.578125
4
def permutations(list1): res=[list1[:2],list1[:2][::-1]] print(res) for i in range(2,len(list1)): res=gen_per(res,[list1[i]]) return res def gen_per(res,add_s): tmp=[] for string in res: for i in range(len(string)+1): tmp.append(string[:i]+add_s+string[i:]) res=tmp return res # DFS ''' 靈活運用nums[:i]+num...
98eea378e2280abe5fb0371c5290a1529a59e8b8
gurmehar98/PracticeProblems
/SubtreeOfAnotherTree.py
854
3.734375
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSubtree(self, s, t): return self._helper(s, t) def _helper(self, s, t): if self._dfs(s, t): return True if s == None: return False return self...
62c6c59c5d8a8638369a5385ab0c65e53777beab
gautamamber/advance-python-topic
/instance_creation/dunder_new.py
497
3.84375
4
class Example(object): """ Call __new__ first for creating instance of class and then __init__ for initialize the class """ def __new__(cls, *args, **kwargs): """ creating class instance :param args: :param kwargs: """ print("Instance of class is creat...
f38c6a8076227831aebb010d897649c5ec759a67
tim87henry/space_wallpaper
/space_wallpaper.py
1,410
3.578125
4
import ctypes from random import randint from selenium import webdriver """ The openImageWebPage proc is used to open the site and navigate to a random image, from the list of images. It then saves the image to the PC, in the given location. """ def openImageWebpage(imageFile): # img1 and img2 are random numbers ...
07e72a581ec5826054dfe498eaa18196bc4018d8
MDXiao/DS-Prep
/BinaryTree.py
1,713
4.1875
4
# Binary Tree in Python # class Node: def __init__(self, data): self.data = data self.left = None self.right = None #### TRAVERSALS #### ## Depth First Traversal Methods (DFS) ## # Complexities # Runtime: O(n + m) n = # of nodes, m = # edges (Graph Like) # Due to there being two edges, it's just O(n) # Space...
11b48d63f73f09d1b2d0999f7c1439eb0d2e1786
athletejuan/TIL
/Algorithm/BOJ/16_Dynamic_Programming/2748.py
269
3.796875
4
n = int(input()) a,b = 0,1 for i in range(n-1): a,b = b,a+b print(b) # n = int(input()) # def fib(n): # v = [0, 1] # if n < 2: # return v[n] # for i in range(2, n+1): # v.append(fib(i-1) + fib(i-2)) # return v[n] # print(fib(n))
fa296ed9d6e47c7ecf05b10fbaa683ce8dd8dca1
prteek/IO
/src/projects/archive/intro_to_ml.py
13,102
3.796875
4
# author : Prateek # email : prateekpatel.in@gmail.com # description : Hands on exercise in Introductory machine learning # # # Machine learning # # ## Types # #### Supervised: # Given a set of data the task is to learn the relationship between the input x and output y such that, when given a ...
cad273e7dd6d9741712cc07324f407704bcdb73c
udhayprakash/PythonMaterial
/python3/11_File_Operations/02_structured_files/03_csv/01_csv/k2_quoting_chars.py
1,287
4.03125
4
import csv # Example data data = [ ["John", "Doe", 25, "john@example.com"], ["Jane", "Smith", 30, "jane@example.com"], ["Bob", "Brown", "N/A", "bob@example.com"], ] # Quoting options quoting_options = [ csv.QUOTE_MINIMAL, csv.QUOTE_ALL, csv.QUOTE_NONNUMERIC, csv.QUOTE_NONE, ] # Iterate ov...
5c9a33de54d9f0bac668868881d6ce0da76521f9
dashboardijo/algorithm007-class02
/Week_07/G20200343040290/LeetCode_22_0290.py
265
3.578125
4
class Solution: def climbStairs(self, n: int) -> int: if n<=2: return n states = [0]*n states[0] = 1 states[1] = 2 for i in range(2,n): states[i] = states[i-1]+states[i-2] return states[-1]
dd1055d6c80af8c019058bfab31a618f00487027
MaximeCautres/AI
/hand_written_recognition/By_Cautre6porc/archives/backup/old_numporc.py
4,393
3.796875
4
""" The numporc library """ import math import random class Numporc: def __init__(self, row, column): self.size = (row, column) self.row = row self.column = column self.matrix = [[0 for _ in range(column)] for _ in range(row)] def randomize(self): ...
48745825e15e3a8b1111516b611e12fe685e1f33
ryh95/PyLeetcode
/remove_linked_list_elements.py
1,236
3.59375
4
# coding:utf8 # Definition for singly-linked list. # You should annotate the ListNode class for running code on Leetcode class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: List...
581433cff02629b31cd87734ba4981443edb87d0
harrsa92/Price-forecasting-SVM
/svr.py
1,281
3.578125
4
import csv import numpy as np from sklearn.svm import SVR import matplotlib.pyplot as plt dates = [] prices = [] windowlen = 10 def get_data(filename): with open(filename, 'r') as csvfile: csvFileReader = csv.reader(csvfile) next(csvFileReader) # skipping column names for row in csvFileReader: dates.append...
ab5d7be1e6935f03150fae13cfa22552d9b13635
githubuser1983/PySurreal
/alien_cards.py
5,103
3.625
4
#!/usr/bin/python3 from surreal import Surreal, canal import random import unittest preach = True speech = True symbols = ''' ☀ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☓ ☡ ☩ ☼ ☿ ♀ ♁ ♂ ♃ ♄ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♓ ♮ ♯ ♰ ♱ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ ⚘ ⚙ ⚚ ⚛ ⚜ ⚞ ⚟ ⚡ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ '''.split() random.shuffle(symbols) sorted_symb...
8527324612c0e7a2b16145ac7c40ce20819819cf
Kykyp3/ProjectEuler-Task-14
/Euler14.py
1,760
4.1875
4
# The following iterative sequence is defined for the set of positive integers: # n → n/2 (n is even) # n → 3n + 1 (n is odd) # Using the rule above and starting with 13, we generate the following sequence: # 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 # It can be seen that this sequence (starting at 13 and finishi...
813f1be899358fe2ea059045b0e2e7ddab10ec77
Tarang-1996/100-days-
/day9/selectionsort.py
414
3.984375
4
#selection sort num = int(input('enter the number of element ')) array = [] for k in range(0,num): array.append([]) for k in range(0,num): array[k]=int(input()) for j in range(0,num): minimum = array[j] l=j+1 for i in range(l ,num): if(minimum>array[i]): minimum=array[i] ...
42543b050f504a2f0dfa3556e629b12cb1032317
dimgrav/edX-MITx-6.00.1x
/others/OOPupdateHand.py
1,008
3.921875
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 18 14:25:51 2017 @author: Mitsakos """ def update(self, word): """ Does not assume that self.hand has all the letters in word. Updates the hand: if self.hand does have all the letters to make the word, modifies self.hand by using up the letters...
70aa47f1780616b29890a05a1e81ed06e8f324be
KoderDojo/hackerrank
/python/challenges/datastructures/linkedlists-insertend.py
994
4.3125
4
""" Insert Node at the end of a linked list head pointer input could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method """ clas...
c62955215e39906f6f9783998a682d74bd3aa98d
arzanpathan/Python-Programs
/Sample Programs/Prime No.py
323
4.15625
4
#WAP to Check whether the given no is prime or not (Prime no means divisible by its own) #for k in range(2,no):c=no/k if(c!=1): print('\nIt is Not a Prime No') no=int(input('\nEnter a No: ')) for i in range(2,no): if(no%i==0): print('It is not a Prime No') break if(i==no-1): print('No is Prime'...
ba14ab31a35db9dc936320e4403e539954650380
undersfx/python-interview-exercices
/playground/nonblank_descriptor_v2.py
1,632
3.5625
4
# Descriptor Definition class Nonblank: field_count = 0 def __init__(self): # Gets Nonblank class attrs cls = self.__class__ self.storage = f'{cls.__name__}_{cls.field_count}' # The incremental counter needs to change de class 'field_count' value, not the instances cls....
3c79aeb771265b7787af6b87d84fde24210de212
mortontaj/HackerRank
/HackerRANK/Square.py
637
3.71875
4
s = [[4, 9, 2], [3, 5, 7], [8, 1, 5]] print(sum(s[0]), sum(s[1]), sum(s[2]),) t = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for i in range(len(s)): # iterate through rows for j in range(len(s[0])): # iterate through columns t[j][i] = s[i][j] for r in t: print(r) x = 0 y = 0 for i in ran...
d7e8495a9b45901edf2e25dbd9cd597498300776
jenga/cerebellum
/rhesus/models/node.py
1,422
3.59375
4
class Node(object): def __init__(self, name): self.name = name self.inputs = {} self.outputs = {} self.vrs = {} def integrate(self, t, dt): ''' ODEs will be integrated in this function for one timestep of dt. If there are inputs, they should be checked ...