blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f520c08f05bc4a7dfab6baa3a498af31a4c381ad
cuso4414/selinium
/1/bubble.py
655
3.90625
4
class BubbleSort(): #函数名需要注意,小写单词,多个单词之间使用下划线链接,尽量使用动词,get_... def bubble_sort(self,list_a): #排序次数 for i in range(1,len(list_a)): print("这是第{}次排序~".format(i)) #对比次数 for j in range(len(list_a)-i): print("这是第{}次对比".format(j)) if list_...
d208986462ea599735f5d7f25aa2074bcf9d5352
satish88397/PythonPractice
/loop8.py
141
3.90625
4
#ran=list (range(1,6)) #print(ran) #print("the capital letter of a to z is follow:") #for i in range(65,91,1): # print(chr(i),end=" ")
82bad6c17f7c135aa3bd8cae57fbfea9e1c24e39
alu0100825978/prct12
/src/modulo.py
762
3.921875
4
PI=3.1415926535 import sys #funcion para calculo de pi llamada "calculo" def calculo(n): suma=0.0 for i in range (1,n+1): if(n<0): return suma x_i= float ((i-0.5)/n) #calculo del intervalo xi fx_i= float (4./(1+x_i**2)) #calculo de f(xi) suma = suma + fx_i #sumatorio de f(xi) ...
d68616252b3d9fd03472427d3fe79b47ccef3f1d
Lynch201/liaoxuefeng
/Database/Sqlite3.py
1,304
3.890625
4
#!user/bin/python # -*- coding: utf-8 -*- # 201609260929 # lynch.wang import os import sqlite3 db_file = os.path.join(os.path.dirname(__file__), 'test.db') if os.path.isfile(db_file): os.remove(db_file) # 初始数据: conn = sqlite3.connect(db_file) cursor = conn.cursor() cursor.execute('create table user(id varchar(20) ...
ecb0fd437095e6a3f5eaed341e7bfd857485cab9
JozhueBrown/python-test
/Manejo_archivos.py
2,052
3.71875
4
##en este archivo se trabajara sobre guardar los datos de algun programa ejecutado para que no se pierdan al momento de conluir #Fases: creacion, apertura, escritura, cierre ##importamos librerias from io import open##open es para abrir un archivo externo archivo_texto=open("archivo.txt", "w" )##('nombre archivo', 'mo...
459a349c2b82e49a6f983907dd11250ac71eddab
SimonKocurek/Algorithms-and-Fun
/python/multiset_splittable.py
963
3.5
4
def partition_exists(multiset, index, current_sum, target_sum): if current_sum == target_sum: return True if index + 1 == len(multiset): return False new_index = index + 1 return partition_exists(multiset, new_index, current_sum + multiset[index], target_sum) or \ partition_exi...
633fa7d5094e42fdde8a5840a844808f28d07707
Aman-Maheshwari7/Blockchain-Cryptocurrency
/anycoin.py
6,592
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri May 14 13:15:07 2021 @author: Aman Maheshwari Creating a cryptocurrency """ #importing libraries #request- connecting nodes in a decentralised blockchain import datetime import hashlib import json from flask import Flask, jsonify,request import requests from uuid import uu...
545d323ef3482213e9719feb01ab094b316efda3
JuanGinesRamisV/python
/practica 6/p6e8.py
899
3.890625
4
#juan gines ramis vivancos p6ej8 #Escribe un programa que te pida primero un número y #luego te pida números hasta que la suma de los números #introducidos coincida con el número inicial. #El programa termina escribiendo la lista de números. print('escribe un limite') limite=int(input()) suma=0 print('escribe un valor'...
34fb9959703fede9cfbddda34621df07e4e5ce43
a524631266/pythondesignmodel
/0.python基本知识汇总/并发知识/线程任务/1.threading.py
599
3.65625
4
# 类似于 multiprocessing from threading import Thread import os import time l = [1,2,3] # 特点1,线程的pid与主程序的pid一样,说明,线程是由进程创建的 def test(): time.sleep(1) l.append(1) print("线程",os.getpid()) for i in range(5): t = Thread(target=test) t.start()#只有start之后才能开始执行 # t.join() # 进程会等待,等到test执行完,才会执行main,否则会执...
dc2424357981085eedf2f448e76f088892eec755
sdlbp/LeetCode
/leetcode-algorithms/605. Can Place Flowers/605.py
758
3.90625
4
""" https://leetcode.com/problems/can-place-flowers/description/ """ class Solution: def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ length = len(flowerbed) i, count = 1, 0 flowerbed = [0] + flowerb...
f2750d8c1645a9e33fad883c91b7ede4362ebe9a
srac1777/learnPython
/CtCI-Python/LinkedLists/2p7.py
903
3.921875
4
import sys sys.path.append( "/Users/shashankracherla/code/learnPython/Data Structures Implementations/") from linked_list import LinkedList from node import Node def intersection(h1, h2): curr = h1 h1_set = set() while curr != None: h1_set.add(curr) curr = curr.next curr = h2 ...
f858caf4ebbf028552963135c92c022a8c8e2729
FabioLeonel/Python
/Pythonexercicios/ex.96_100.py
2,042
3.84375
4
#AULA 20 #ex.96 def area(larg, comp): a = l * c print(f'A área de um terreno {larg} x {comp} é de {a}m²') print('Controle de Terrenos') l = float(input('Largura(m): ')) c = float(input('Comprimento (m): ')) area(l, c) #ex.97 def escreva(ola): print(f'-' * (len(ola) + 2)) print(f' {ola}') print(f'...
5260ede5f029321c17bf0f2ee9e6290425455f10
MartinaLima/Python
/exercicios_python_brasil/estrutura_sequencial/10_converter_celsius_fahrenheit.py
236
4.09375
4
print('\033[1m>>> CONVERSOR DE TEMPERATURA <<<\033[m') c = float(input('Informe a temperatura em Célsius: ')) f = c*1.8+32 print('-'*40) print('\033[1mRESULTADO:\033[m') print(f'{c:.1f}º Célsius = \033[1m{f:.1f}º Fahrenheit')
1d019370ceaf27d4093221d6c0042f5321bd59ce
doityu/Project_Euler
/PE1...50/pe-07.py
404
3.90625
4
import math # 素数判定関数(総当たり √N) def isPrime(number): if(number < 2): return False for i in range(2, int(math.sqrt(number)) + 1): if(number % i == 0): return False return True gole = 10001 n = 0 number = 1 while True: if(isPrime(number)): n += 1 if(n == gole):...
061afa8f312c8ed02a6a3e4f6760b8c5f043eee8
jdvpl/Python
/Universidad Nacional/ejercicios/utiles_escolares.py
735
3.90625
4
""" Unos padres de familia desesperados por determinar el dinero que debenpedir prestado para pagar los ́utiles escolares de su hijo, le han pedidocrear un programa de computador que a partir de una lista de los preciosde cada ́util escolar y de la cantidad de cada ́util escolar en la lista,determine el precio ...
7f88d64aa7c57ab754a7832faadc81d77c628597
AakashJaswal/DataStructures-and-AOA
/Python/AOA/sort/merge_sort.py
755
3.765625
4
n = [4, 3, 2, 1] def merge_sort(nums: list[int], start, end): if (end == start): return nums middle = (start + end) // 2 merge_sort(nums, start, middle) merge_sort(nums, middle + 1, end) merge(nums, start, middle, end) return nums def merge(nums, start, middle, end): L = nums[st...
7dd63e46450ae3d304365023e42fa576ae829fa7
aksh1251/PythonCode
/Summation.py
184
3.84375
4
number1 = input("Enter number 1: ") number2 = input("Enter number 2: ") summation = number1+ number2 print(summation) print(type(number1)) print(type(number2)) print(type(summation))
65993fd0bca8b077269cfbb2de7e2f0ae4ccbd55
lkmflam/05-Python-Programming
/03_Flow_Control/performance_labs/MadLibExercise.py
833
4.21875
4
main() print("You will now begin playing MadLibs! I will ask for you to print multiple words and all you have to do is follow the guidelines.") verb1 = input("Please enter your first verb. Always remember nothing inappropriate.") noun1 = input("Please enter your first noun.") adj1 = input("Please enter ...
9da03b84e13a8585f69e4824710b3031c1e011e2
Israelmath/Escola-com-db
/Escolabd.py
8,008
3.609375
4
""" Faça um programa que permita que o usuário entre com diversos nomes e telefones para cadastro e crie um arquivo com essas informações. Obs. No arquivo de saída, as informações de cada usuário deverão estar em uma linha """ from random import randint from Individuos import Usuario from Verificadores import * impor...
e8d401f2dca3548fd36e1f9ae5686a7d88bf737b
Jingwu010/Code-Practice
/leetcode/zuma-game-dp.py
2,769
3.875
4
class Solution: def findMinStep(self, board, hand): """ :type board: str len(board) <= 20 :type hand: str len(hand) <= 5 :rtype: int """ # Do we get balls after removing them from board? No def removeElem(string, elem, times): ...
ed85bbb1d92b202aa4bcf5562e005f8509e55a68
oliveirajonathas/python_estudos
/pacote-download/pythonProject/exercicios_python_guanabara/ex018.py
321
3.8125
4
import math angulo = math.radians(float(input('Informe o valor do ângulo: '))) sen = math.sin(angulo) cos = math.cos(angulo) tan = math.tan(angulo) print('Em relação ao ângulo {} temos que:\n' 'Seu seno é {:.1f}\n' 'Seu cosseno é {:.1f}\n' 'Sua tangente é {:.1f}'.format(angulo, sen, cos, tan))
c8b86db7d1ecae7c2a74915da1297caacf961f78
dkhaosanga/class_python_labs_031218
/word_count.py
1,816
3.75
4
# # def strip_words(emma_strip): # for space in emma_strip.strip() # return strip_words() # # def word_count(emma_string): # string_words = {} # for word in emma_string.split(): # if word in string_words: # string_words[word] += 1 # else: # string_words[word] = 1 ...
ff301db66603a46784c4dc653132d7ee12ea58a7
ijpulidos/kinoml
/kinoml/core/components.py
749
3.5
4
class MolecularComponent: """ Abstract base molecular entity. Several components can form a System. Proteins, ligands, and other molecular entities are derived from this class. """ def __init__(self, name="", metadata=None, *args, **kwargs): self.name = name if metadata is None:...
bbe6728fcd717c23acfa1eaf75d7dab13386eeee
kbpersik/cource-work
/2 ЧАСТЬ/задача (17).py
384
3.59375
4
import numpy as np import random N = random.randint(1, 10) M = random.randint(1, 10) L = random.randint(1, M) A = np.random.randint(0, 100, (N, M)) print("Матрица:\r\n{}".format(A)) row = np.random.randint(-9, 10, M) print("Строка для вставки: {}".format(row)) A = np.insert(A, L, row, axis=0) print("Нов...
d44e311b7ddf3a5bbdac0c82bef9e29309305f94
medva1997/bmstu
/Lab0 2015-09-19.py
1,322
4.09375
4
"Поиск корней квадратного уравнения" import math print("Решения уравнения вида ax^2+bx+c=0") a = int(input("Введите, пожалуйста, коэффицент a=")) b = int(input("Введите, пожалуйста, коэффицент b=")) c = int(input("Введите, пожалуйста, коэффицент c=")) if(a!=0): D=b*b-4*a*c if (D<0) : pr...
4b40f47e3935d2e865307b2e3ec0fb4192b0db04
ChangxingJiang/LeetCode
/0901-1000/0991/0991_Python_1.py
567
3.71875
4
import functools class Solution: _BIG = 10 ** 9 @functools.lru_cache(None) def brokenCalc(self, x: int, y: int) -> int: if x > y: return x - y if x == y: return 0 if y % 2 == 0: return self.brokenCalc(x, y // 2) + 1 else: re...
207a32a81942f305786dd216e749a9d1cc3fbe9b
shobhit-nigam/strivers
/day3/misc/1.py
181
3.578125
4
lista = ['aa', 'hh', 'aa', 'KK', 'dd', 'rr', 'ff', '25', 'WW'] x = 'dd' in lista print(x) y = lista[4] == 'dd' print(y) x = 'rr' in lista print(x) y = lista[4] == 'rr' print(y)
797e49abfd0e26dadc39b70a907fc6accd56150d
TakezoCan/sandbox
/trafficLight.py
2,185
3.859375
4
#!/usr/bin/env python3 # # Filename: trafficLight.py # Date: 2018.10.31 # Author: Curtis Girling # Function: Runs three LEDs as a traffic light when button is pressed # from time import sleep # import sleep function for delay timing import RPi.GPIO as GPIO # import GPIO library to use GPIO pins # Lables for BCM pin...
d998d2e58ba3d3ba4927c857059ddb1145ecc56d
sahuer/Tarea_03
/esfera.py
773
3.75
4
#encoding: UTF-8 # Autor: Daniel Sahuer # Calcula volumen, área y diámetro de una esfera import math def calcularDiametro(diametro): #Calcula el diámetro totalDiametro = diametro * 2 return totalDiametro #Regresar def calcularVolumen(volumen): #Calcula el volumen totalVolumen = (4/3) * math.pi * (volume...
05ab8617f03bfe1b4282b9de9502e77f372b52b3
Mankarn-Sandhu/Tic-Tac-Toe
/TikTacToe.py
3,345
3.890625
4
import random board = [" "," "," "," "," "," "," "," "," "," "] #10 spots because the first one is technically the 0th def print_headerandboard(): print (""" IIIIIIIIIIIII IIIIIIIIIIIIIII IIIIIIIIIII I I I I ...
ffbd55369b375bc266a64c266c80e3422368e63a
spezifisch/leetcode-problems
/find-the-difference/one.py
347
3.640625
4
class Solution: def findTheDifference(self, s: str, t: str) -> str: t = list(t) for c in s: t.remove(c) return t[0] # Runtime: 64 ms, faster than 11.61% of Python3 online submissions for Find the Difference. # Memory Usage: 13.1 MB, less than 5.00% of Python3 online submission...
45c4da0f135f970642eac724affbd214f530fe27
vsanjuan/costcalculationtool
/activity_cost.py
2,464
4.5625
5
class Activity(object): """ Represents an activity to be performed in order to deliver the product to the customer. """ def __init__(self, name, code, output_unit, throughput, output_time_unit, fixed_cost = 0, variable_cost = 0): """Initialize a new activity by specifying its nam...
105b2159c19045e34b697c341fae353bd87ae4b0
encalien/programming_problems
/Lists, Strings/2_08_perfect_square.py
826
4.46875
4
# 2.08 Write a function on_all that applies a function to every element of a list. Use it to print the first twenty perfect squares. The perfect squares can be found by multiplying each natural number with itself. The first few perfect squares are 1*1= 1, 2*2=4, 3*3=9, 4*4=16. Twelve for example is not a perfect squ...
3d5d6c0147565cd5f8d0ec10f2a71a0b7cd3c402
farhan1ahmed/Training
/Week2Day3/Lists.py
295
3.515625
4
tries = int(input("Enter number of commands: ")) l = [] for t in range(tries): com = input().split() command = com[0] arguments = com[1:] if command != 'print': s = ", " eval("l."+command+"("+s.join(arguments[:])+")") elif command == 'print': print(l)
a3298e2909a6f095dc48d6ac180e6afbae01db20
Arihant2001/Hacktoberfest-2022
/merge_sorted_lists.py
1,862
4.40625
4
# Python program to merge two sorted linked lists in-place by Deepanshu Mittal. # Linked List node class Node: def __init__(self, data): self.data = data self.next = None # Function to create newNode in a linkedlist def newNode(key): new_node = Node(0) new_node.data = key new_node.next = None return new_nod...
0e9f070c661638840d0b0c52b7fbac8c0fb71dcd
notha99y/WebScraping
/src/utils.py
299
3.90625
4
import os def make_dir(directory): ''' Creates a directory if there is no directory ''' if not os.path.exists(directory): os.makedirs(directory) else: print("Directory already exist: {}. No action taken".format(directory)) if __name__ == '__main__': pass
43612b0a87cedd22daa715c1133ddfc16a61cf1b
liucheng2912/py
/leecode/easy/链表/反转链表.py
500
3.765625
4
class ListNode(object): def __init__(self,val): self.val=val self.next=None class Solution(object): def reverseList(self,head): #三指针实现翻转,通过cur将读取的加在pre的头部 if not head or not head.next:return head pre,cur,next=None,head,head,next while cur.next is not No...
785637cce9440cec9a3b377034eeece399c3564b
estraviz/codewars
/8_kyu/Training JS #32: methods of Math---round() ceil() and floor()/python/solution.py
328
3.734375
4
"""Training JS #32: methods of Math---round() ceil() and floor()""" from math import ceil, floor def round_it(n): left, right = str(n).split('.') if len(left) < len(right): return ceil(n) elif len(left) >= len(right) + 1: return floor(n) elif len(left) == len(right): return r...
9aa5bff140e343daa19324d4bc2747fd83ff21f9
cboe07/CS-Fundamentals
/unit 6/linear_search.py
1,662
3.953125
4
# def linear_search(array, target): # for i in range(len(array)): # if array[i] == target: # return True # return False # my_array = [1,2,3,4] # # print(linear_search(my_array, 2)) # # print(linear_search(my_array, 5)) # # print(linear_search(my_array, 4)) # def linear_search_recursive(array, target, curren...
3bbb049e7d13d2592eb5f27e589835be2e923e8e
JSmalley1/ProjectEuler
/Problems1_10/Problem4.py
210
3.578125
4
def is_palindrome(val): return str(val) == str(val)[::-1] choices = set() for x in xrange(100, 1000): for y in xrange(x, 1000): n = x * y if is_palindrome(n): choices.add(n) print sorted(choices)[-1]
242c152a8302fe1625ee5bce5da3e6c3f20f68f9
sucman/Python100
/1-10/4.py
869
4.09375
4
# -*- coding:utf-8 -*- ''' 题目:输入某年某月某日,判断这一天是这一年的第几天? 程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天, 特殊情况,闰年且输入月份大于2时需考虑多加一天: ''' year = int(raw_input("年:")) month = int(raw_input("月:")) day = int(raw_input("日:")) months = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334) if 0 < month <= 12: sum = months[month -...
d61db8d58322d8a49c5118313785cbe71836be30
problems-forked/Dynamic-Programming
/Longest Common Substring/main(2).py
858
3.609375
4
def find_LBS_length(nums): n = len(nums) lds = [0 for _ in range(n)] ldsReverse = [0 for _ in range(n)] # find LDS for every index up to the beginning of the array for i in range(n): lds[i] = 1 # every element is an LDS of length 1 for j in range(i-1, -1, -1): if nums[j] < nums[i]: lds...
a05fcf0da02bd6fb27b6f8c76290566cbec898f5
H3Cki/T-Bot
/cogs/utils/general.py
436
3.8125
4
def splitList(lst,size): output = [] while lst: if len(lst) <= size: output.append(lst) lst = None else: output.append(lst[:size]) lst = lst[size:] return output # l = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] # s =...
e580db0552ce779ef8f1403808d6fcd8305776f7
zopepy/leetcode
/nextPermutation.py
936
3.515625
4
class Solution: def nextPermutation(self, nums: 'List[int]') -> 'None': """ Do not return anything, modify nums in-place instead. """ def find(nums, val, l): i = l-1 while i>=0 and nums[i] <= val: i-=1 return i def reverse(...
72e7f87651c04fbdcee1aed55eae652d2f4e5230
La0/advent
/2016/3.py
651
3.765625
4
import re def is_triangle(sides): total = sum(sides) for i in range(3): remaining = sides[i] if (total - remaining) <= remaining: return False return True def solve(lines): grid = [map(int, re.findall('(\d+)', line)) for line in lines] triangles = [] for i in rang...
06e0bf38aea0bed64df096fd5572b6a2a869809f
trocks1122/AIProject5
/classFiles/item.py
428
3.6875
4
class Item(object): def __init__(self, name, weight): #item has a name and weight, no bag but has potential bags and has constramits self.name = name self.weight = int(weight) #convert to int self.bag = None self.potential_bags = {} self.constraints = [] def putInBag(self, bag): if self.bag: self.ba...
68ebb59014fe393d80068da2f617cd00a047a454
victorkolis/Playground
/AutomatizationSoftwares/phone_number_finder.py
682
4.15625
4
#!/usr/bin/env python3 # Victor deMatos # Copyright (c) 2020 CODE FUTURE INVENT # Description: # This piece of software's goal is to satisfy a need to find patterns # in a text (of any sort) to trim off phone number patterns # such as americans and canadians are: xxx-xxx-xxxx import re import pprint def phone_number...
2376052401fc0f596ca75a6e919caf5cef1d5faa
HUSS41N/Python-Tut
/PythonTutorial9.py
1,592
4.28125
4
# if certain condition is met only then the block will be executed # if(True): # print("Hello") # print("Python is cool") # print("Python is cool") # print("Python is cool") # if(False): # print("This will not be printed") # if(2+2 == 4): # print("Printed 4") # if(2>10): # print("This will ...
14424ff29a51cc0e59f44e04793fa18748bb2ec9
piperpi/python_book_code
/万门数据结构与算法进阶班课件/6.11/LinkedList.py
4,589
4.0625
4
class Node: def __init__ (self, value = None, next = None): self.value = value self.next = next class LinkedList: def __init__(self): self.head = Node() self.length = 0 def peek(self): if not self.head.next: raise ValueError( 'LinkedList is empty' )...
55bf5cdb0d99c84fa8305b602893ca6bb5a4da5e
sdlbp/LeetCode
/leetcode-algorithms/136. Single Number/single-number.py
963
3.640625
4
class Solution: def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ return self.v_3(nums) def v_3(self, nums): res = 0 for num in nums: res ^= num return res def v_2(self, nums): """ 28ms ...
30dae9f16354ea418adad7a8f9dfcaecdf7c3ac6
Nellyth/Lsv-Tech
/Practica/21-03-2019/Actividad #24.py
1,271
4.0625
4
#crear un diccionario donde la clave sea el nombre y el valor sea el telefono, se puede pedir n datos hasta que el #usuario no desee ingresar mas, NO SE PUEDEN REPETIR DATOS. diccionary={} def datos(key, value): if( not key or not value): print("El Usuario O Telefono No Pueden Estar Vacios") print...
05c85616cc19ed986ec786b4ceda06ccbbc14263
Vlad-Kornev/PythonApplication12
/Strings.py
142
3.578125
4
str = input() substr = 'G' substr1 = 'C' p = str.upper().count(substr) p1 = str.upper().count(substr1) print (((p + p1) / len(str)) * 100)
b5f04e8cc707103aa39da2c6fe8822626b37372c
kmu-swproj2-class2-team1/open_space
/junseong/assignment5.py
531
3.9375
4
import time def fibo(n): if n <= 1: return n return fibo(n - 1) + fibo(n - 2) def iterfibo(n): a, b = 1, 1 for i in range(n - 1): a, b = b, a + b return a while True: n = int(input("Enter The Fibo Num :")) if n < 0: break start_time = time.time() print("R...
be34bbec531b0d8a34a84322543fe2d927c8a598
jimkaj/PythonForEverybody
/5_1.py
379
3.96875
4
#total, count, average for series total = 0 count = 0 average = 0 while True: itervar = input("Enter a number or enter 'done' ") if itervar == "done": break try: num = float(itervar) total = total + num count = count + 1 except: print("Invalid input"...
8c438d84a260e3ff3b98d9d24f5852187b445edc
Akarshit7/Python-Codes
/Coding Ninjas/Patterns 2/Code : Inverted Number Pattern.py
210
3.6875
4
# Print the following pattern for the given N number of rows. # 4444 # 333 # 22 # 1 n= int(input()) i=1 while i<=n: j=1 while j<=n-i+1: print(n-i+1,end="") j=j+1 print() i=i+1
a8c9ce96a9b032c1c4020b6b6666b15616814410
SpooderManEXE/Hacktoberfest2020-Expert
/Python Programs/areaofrectangle.py
381
4.4375
4
# Python Program to find Area of a Rectangle width = float(input('Please Enter the Width of a Rectangle: ')) height = float(input('Please Enter the Height of a Rectangle: ')) # calculate the area Area = width * height # calculate the Perimeter Perimeter = 2 * (width + height) print("\n Area of a Rectangle is: %.2f"...
dcf2eff080805037b167ccb9607393c8ae377eaa
pastelsneakers/pastels-cogs
/birthday/birthdayparty.py
1,611
3.53125
4
import discord from discord.ext import commands class BirthdayParty """A custom birthday party widget. Celebrate with the whole server! """ def __init__(self, bot): self.bot = bot @commands.command() async def mycom(self): """This does stuff!""" #Your code will go here ...
c0c2395499be8364b9eaada4b19df763818bd4af
usama-nayab/Hacktoberfest2021
/Python/rsa-encrypt-decrypt.py
1,648
4.09375
4
# Following is the implementation of RSA Encryption and Decryption Algorithm # Input any number as plaintext # The public and private keys change everytime as we generate random prime numbers everytime # Eg: # Enter message to encrypt: 234 # Public Key: e = 4205, n = 23213 # Private Key: d = 8297, n = 23213 # Ciphertex...
fea0760693d3b51d189dd4b45f58850e07937e6a
mehzabeen000/list
/magic_square.py
712
3.65625
4
s=[[8,3,4], [1,5,9], [6,7,2]] for x in range(0,len(s)): if len(s)==len(s[x]): pass else: print("Not a square") break diag=0 diag1=0 for x in range(len(s)): diag+=s[x][x] y=len(s)-1 diag1+=s[x][y] row=[] col=[] for x i...
9892e1d3686c23b4c6cd40b1fc8468161a98bd61
youssefneff/youssefneff
/Checkpoint5.py
2,084
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #question 1 class Point3D(object): def __init__(self, x, y, z): self.x = x self.y = y self.z = z def affiche(self): return (self.x, self.y, self.z) my_point = Point3D(1,2,3) t=my_point.affiche() print("tuple:",t) # In[2...
a82373aacf009e085d5fb89fb2a15a54b6fef7b2
michael-mck-doyle/Python
/19_Practice_Folder/practice_files/19_26_Methods.py
349
3.796875
4
""" __ References __ The definitive guide on how to use static, class or abstract methods in Python - https://julien.danjou.info/guide-python-static-class-abstract-methods/ """ class Pizza(object): def __init__(self, size): self.size = size def get_size(self): return self.size print(Pizza...
dc681e5304e3951d5463c2f24b0c8c7ed37412e8
durkin482/BrainGame
/loop.py
640
4.03125
4
print "\nYou've mastered the use of Mermaid Man's utility belt and have shrunken " print "down to the size of a single cell. Using this ability, you have been allowed " print "to enter my brain and search for whatever you wish. Luckily for you, " print "my brain has been compartmentalized into four areas that you will ...
a170e9a0e189f13f82ad1d3db03326cbf6e0b599
varinnair/google-foobar
/Level 3/find_access_codes.py
584
3.78125
4
def find_multiples(l, num): count = 0 for e in l: if e % num == 0: count += 1 return count def find_divisibles(l, num): count = 0 for e in l: if num % e == 0: count += 1 return count def answer(l): count = 0 i = 1 while i < len(l) - 1: ...
c03e71339751c57027be1c3989989c9c24dbe511
KirosKost/vol3
/operators.py
1,292
4.15625
4
# TODO: Логические операторы # number = int(input('Введите число: ')) # if number < 10: # print(f'Вы ввели число {number}, оно меньше 10 ') # else: # print(f'Вы ввели число {number}, оно больше 10') # number = int(input('Введите число: ')) # if number < 0: # print(f'число {number} отрицательное') # elif ...
a663266b7cdcdf1f932215e42b827a8c53e9a1e7
SwethaSrikanth/LeetCode-for-Fun
/Maximum Sub_Array.py
608
3.765625
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 2 00:06:42 2018 @author: Swetha Srikanthan """ class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 cur_sum = max_sum = nums[0] ...
d165670807fb33dbb9b7d31630ef0e2da4df846a
rohanJa/LCM-LeetCodeMaychallenge-
/Codevita/elections.py
1,051
3.578125
4
size=int(input()) s=list(str(input())) temp=s.copy() count=0 countA=0 for val in range(len(s)-2,-1,-1): if(s[val]=='-'): if(s[val+1]=='A'): s[val]='A' count+=1 elif(s[val]=='B'): if(count%2==0): countA+=count//2 else: countA+=(count//2)+1...
84b761ddc7041a8623eb457b2fbc9034bf2e6002
balswyan/senior-capstone-spring-2019
/Scripts/Reddit/Reddit.py
1,529
3.71875
4
import json import requests def get_url_info(url): """ To pull the information/text in a html file. :param html_file (string): name of an html file to process. :return html_info (dict): the basic information in the html file. """ data = _get_request(url + '.json') data = _get_submission_o...
9d2c442eec17d78c0fe6a3e0a8c4753f71dfb5b2
dhananjay-arora/Computer-Comm-Networks
/Assignment_0/Question10.py
1,270
4.5
4
#You will keep track of when your friend’s birthdays are, and be able to find that information based on their name. #Create a dictionary of names and birthdays. #When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. dictionary={'friendName':[],'birth...
ea3b327edffe5b5fb0175f9a91ff1d9e130efe09
fbidu/Etudes
/Python/Calculo de Pi/Wallis.py
153
3.9375
4
n = int(input("Digite o número de interações: ")) pi = 2 i = 0 x = 2 while i < n: pi = pi*(x/(x-1))*(x/(x+1)) x += 2 i += 1 print(pi)
942913bb09b0a3149ebe202730bc122a6f3f2cc5
deedee1886-cmis/deedee1886-cmis-cs2
/quiztester.py
252
3.953125
4
print "Type in 3 different numbers (decimals are OK!)" A = raw_input("A ") B = raw_input("B ") C = raw_input("C ") if A == B == C: print "you didn't follow directions" else: foo = [A, B, C] print "The largest number was " + max(foo)
dcc6534a97d9347cbc29a4332253a3b91dbe6fdb
Cremily/text-adventure
/Chooseyourownadventure.py
11,167
3.5
4
global PLAYER_INV PLAYER_INV = {} GAME_ON = True from colorama import init init() from colorama import Fore,Back,Style def read_inventory(): if len(PLAYER_INV) == 0: print("You aren't carrying anything!") return False inv_string = "You have the " for count,key in enumerate(PLAYER_...
8aecea05bbcd3fce3a4c5ea5107425f9c55cf5b6
BjarkiF/GSKI
/PA1/array_list.py
6,009
4.0625
4
class IndexOutOfBounds(Exception): pass class NotFound(Exception): pass class Empty(Exception): pass class NotOrdered(Exception): pass class ArrayList: def __init__(self): #self.lis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] self.lis = [] self.order_check = 1 #Time complexity...
1540cc61792586f54b489aef92dd2df06be83c6a
rlim19/py_misc
/isPerfectNo.py
804
3.84375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ################################################# # Perfect number is a number which # # the addition of its divider (except itself) # # equals itself # # e.g 6 is a perfect number # # because 6 = 1+2+3 = 6 ...
11a5ad8b7f437d56217ff2f90ca5a30fce7d7c68
stupak-r-b/Erik-Metiz
/3.5.py
788
4.25
4
# list with some different people some_people = ["me", "mother", "grandmother", "Alex", "some_one_else"] print(some_people) del some_people[4] some_people.append("mr.Peterson") for people in some_people: print(f"Дорогой(гая) {people}, приглашаю тебя на мой день рождения. С Ув. Роман!") print("\n\nУв. гости! С больш...
259da8a42c26dcdbfea0a370ab25637ad51bd90f
nanisaladi24/Leetcode_py_codes
/Easy/reverseString.py
411
3.90625
4
def reverseString(s): """ :type s: List[str] :rtype: None Do not return anything, modify s in-place instead. """ size = len(s) temp1="" temp2="" temp="" for i in range(int(size/2)): temp1=s[i] temp2=s[size-1-i] s[i]=temp2 s[size-1-i]=temp1 #pri...
15adab8223897cee9e26840d618d9f4fdfedc2ae
jgalvan/idle
/scopes/Func.py
1,456
3.53125
4
from .Scope import Scope, AccessModifier class Func(Scope): """Represents a function in the language. Apart from the inherited scope attributes, it contains a return type and an optional access modifier. Access modifiers are not currently fully supported. """ def __init__(self, name, access_m...
279f1be1e8a7f49c333f13b046a9e7db8ae14d1d
hzmangel/Leetcode-codes
/109-convert-sorted-list-to-binary-search-tree/solution.py
1,769
3.9375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None @classmethod def buildFromArray(cls, nums): nodes = [ListNode(n) for n in nums] for i in range(len(nodes) - 1): nodes[i].next = nodes[i + 1] ...
aae4c5af882349141cef6f8eef6561d24a769b14
RubenvdBerg/SatToolAG
/MB/GetMaxDark.py
802
3.71875
4
from math import asin,sqrt,pi def GetDarkTime(R): """Calculates the length of time an object is in darkness in an equatorial circular orbit around the Earth with the given orbit radius in [meters]""" mu = 398600.*10**9 R_E = 6371000. return 2*asin(R_E/R)*sqrt(R**3/mu) def GetOrbitTime(R): """Cal...
a4d4e03810147d0053621ec7b9f7bcc41056752e
cypher386/tumblrbot
/testfoo.py
2,231
3.59375
4
#!/usr/local/bin/python2.7 """ Tumblr API Example - Python CLI """ import oauth2 import urlparse import pytumblr import json """ insert creditials here REQUEST_TOKEN_URL = 'http://www.tumblr.com/oauth/request_token' AUTHORIZATION_URL = 'http://www.tumblr.com/oauth/authorize' ACCESS_TOKEN_URL = 'http://www.tumblr.co...
3d7018c78079199d52430d95e9760b4760f91cea
TelematicaTesteo6JK/ep-bva-EdsonMR
/Practica1/prueba.py
3,213
3.71875
4
import os import string import funcion opcion = 0 while opcion != 3: data = [0, 0, 0, 0] # Save data expectResult = ["", "", "", ""] # Save expect result for each data os.system("cls") # print("\t\t...::: Test to validate grade :::...") print("\n\t1. Equivalence Partitioning(EP)\n\t2. Bo...
ea3b90a6cf40ad550e7238557c6d6069cf2cb33a
fabrizzio-gz/tic-tac-toe
/graphics.py
6,380
3.515625
4
from os import path import pygame try: img_dir = path.join(path.dirname(__file__), 'img') except NameError: img_dir = 'img' # Defining colors BLACK = (0, 0, 0) GREEN = (0, 255, 0) # Game settings WIDTH = 480 TOP = 100 SIZE = 450 CELL = SIZE // 3 BORDER = 5 class Text(pygame.sprite.Sprite): """pygame.Sp...
d43d7b5bc79d76f7f15ce479af317867bc5ebda1
Fellenex/clangCount
/characterCount.py
5,120
3.546875
4
# Author: Chris Keeler, August 22nd 2014 import glob import math import matplotlib.pyplot as plt import numpy as np #This function checks to see if a file has a specific extension def hasExtension(fileName, extension): return (fileName[len(extension)*-1:] == extension) # This function collects the text of all of t...
3952befa605be72ba1859d61466e4bb05fb579ea
nikeethr/rflexstudygroup
/nikeethr/hacker_rank/indivisible_set_naive.py
2,088
3.765625
4
def compute_max_indivisible_set(k, S): """ Computes and returns largest subset of S, S' such that there exists no (x, y) in S' where (x + y) % k = 0. precondition: S consists of unique natural numbers. Let P = {(x,y) in S | x != y and (x + y) % k = 0} Let f(x) = {x in S | n...
55080c515584e75f6e591d8b5282c7e4e96a3f19
KMuriungi/Python-Geek-Code
/IfStatementInput.py
879
4.03125
4
print("\"a\" is equal to 10:") a = input("Enter the Value of \"a\" :") print("\"b\" is equal to 20:") b = input("Enter the Value of \"b\" :") print("\"c\" is equal to 30:") c = input("Enter the Value of \"c\" :") print("It Prints only the value of \"a\" since its correct") if(a==10): print(a) elif (b...
fd40d2148db62eea9b3a5230bbd0cbe1aee67654
jury16/Python_Course
/3_07.py
794
4.3125
4
""" Задание 3.07 Ввести строку с клавиатуры Если длина строки больше 5 - вывести значение на экран Если длина строки меньше 5 - вывести строку “Need more!” Если длина строки равна 5 - вывести строку “It is five” """ s = input('Input string ') if len(s) > 5: print(len(s)) elif len(s...
cca74995f60478aa2f63c93f77164a7dfa2fbe20
ellisonbg/py4science
/book/examples/poly_univar.py
10,460
3.890625
4
"""Univariate polynomial manipulations with Numpy and Sympy. This code shows how to use univariate polynomials with Numpy and Sympy, based on a simple problem that appears often in least-squares fitting contexts. Consider solving the equation x^2 sum_i(a_i/(a_i x + b_i)) = k where a, b are arrays and k is a scala...
974e35b53ed0318244f7f5afe881bc97a5ab5ad7
mlitsey/Learning_Python
/IntroPY4DS/day3/austin-pw.py
937
4.34375
4
# Password entering exercise # 01. Allow the user to enter a password that matches a secret password # 02. Allow them to make 5 attempts # 03. Let them know how many they have made # 04. Display if password is correct or if max attempts has been reaced. SECRET_PW = 'katana' pw_in = '' cur_attempts = 0 MAX_ATT...
aa319991268374258221da01d05fc8ebd46a3e28
15110500442/pa-
/深度学习/code/Coursera-Machine-Learning-master/ml-ex2/ex2_reg.py
3,256
4.21875
4
## Machine Learning Online Class - Exercise 2: Logistic Regression # # Instructions # ------------ # # This file contains code that helps you get started on the second part # of the exercise which covers regularization with logistic regression. # # You will need to complete the following functions in this exerics...
47d21df3bce23c51524b9bf9d0ee55003a285236
seanchoi/algorithms
/CyclicRotation/cyclicRotation.py
1,030
4.3125
4
""" An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is mov...
785894a1168ddedffaa6dd5104de167e4f5ed370
MarcPartensky/Python-2019
/Teletype/mymaths/variable.py
630
3.75
4
class Variable: def __init__(self,name="Unknown",content=[None]): self.name=name self.content=content def __add__(self,other): if type(other)==int: name=self.name+"+"+str(other) content=self.content+Variable(other,[other]).content return Variable(name,...
6c742df4d1d5c7076fc1eb4f0143e92d83d8e2b8
TangliziGit/dataquest
/Python Programming/Scopes and Debugging/SaD_template.py
8,379
4.25
4
# coding: utf-8 # In[1]: from __future__ import print_function # #Python Programming # ##Scopes and Debugging # ###1: Find the total number of borrowers in default # Just so we can get an idea of how large the problem of student loan debt is, let's first find the total number of borrowers in defau...
7eedc050bd8c952f19a232d76809c08ad74a6963
shailajaBegari/loops
/lcm of two numbers.py
148
3.71875
4
n1=int(input('enter number')) n2=int(input('enternumber')) i=1 while True: if i%n1==0 and i%n2==0: print(i) break i=i+1
55477df07d697ab792e0798c268a2fd6cf233b2a
GlitchLight/Algorithms_DataStructures_Python
/Структуры данных/Деревья поиска/Обход двоичного дерева поиска/tree_traversal.py
1,648
3.8125
4
# Формат входа. Первая строка содержит число вершин n. Вершины дерева пронумерованы числами от 0 до n−1. Вершина 0 является корнем. # Каждая из следующих n строк содержит информацию о вершинах 0,1,...,n−1:i-я строка задаёт числа # key i,left i и right i, где key i — ключ вершины i, lefti — индекс левого сына вершины ...
18bba221c22dbe5718113729abc6f1bf61502102
GfayB/FayDailyStudy
/Python/BOOK1/7test.py
864
3.96875
4
#7.3.3使用用户输入来填充字典 responses = {} polling_active = True while polling_active: name = input("What is your name?") response = input("Which mountain would you like to climb someday?") responses[name] = response repeat = input("Would you like to let another person respond?(yes/no)") if repeat == 'no':...
0a4337915a9dc2a04785fbe57e3152f0efc39907
Shefali24M/json_read_write_python
/Read_json_python.py
335
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 13 20:13:40 2019 @author: SHEFALI MANGAL """ import json with open('file.txt') as json_file: data = json.load(json_file) for p in data['person']: print('Name: ' + p['name']) print('Hobbies: ' + p['hobbies']) print('Roll no: ' + p['roll no...
6f86c63c4eb42cea416465b2a53571656934e3c6
JacobMagers/PHYS-410-510
/Exercise 3 - Hurricane Data Mining/storms.py
6,968
4.28125
4
import csv def frequency_counter(year1, year2): """ The following function determines the frequency of hurricanes between two specified years. I will call it for each decade, as per the assignment. """ storm_id_freq = [] with open("/Users/jacobmagers/Documents/Clas...
756fdbaf531d9600aa878676daf41f6a62ef1392
mariaEduarda-codes/Python
/outros/prova_matematica.py
802
4
4
""" Faça uma prova de matemática para crianças que estão aprendendo a somar números inteiros menores do que 100. Escolha números aleatórios entre 1 e 100, e mostre na tela a pergunta: qual é a soma de a + b, onde a e b são números aleatórios. Peça a resposta. Faça cinco perguntas ao aluno, e mostre para ele quant...
035946911b5a4b8ecaa3495203b38f1371fdf008
qmnguyenw/python_py4e
/geeksforgeeks/python/basic/9_14.py
2,620
4.28125
4
Python | Elementwise AND in tuples Sometimes, while working with records, we can have a problem in which we may need to perform mathematical bitwise AND operation across tuples. This problem can occur in day-day programming. Let’s discuss certain ways in which this task can be performed. **Method #1 : Usi...
4eb94a08695b1080b4a88c85a4d9422a9ed1b558
crap0101/laundry_basket
/date_from_today.py
897
3.90625
4
#!/usr/bin/env python import argparse import datetime import locale import sys _DESCRIPTION = 'date of the nth day from today' _PROGNAME = 'date_from' locale.setlocale(locale.LC_ALL, '') def _parse (args): parser = argparse.ArgumentParser(prog=_PROGNAME, description=_DESCRIP...
aaf64c2aa3e8556e69a8faf6aa353e677a598772
NimrodSchneider/WorldOfGames
/GuessGame.py
2,363
4.125
4
import random import os from GlobalFunctions import delete_last_line from Utils import screen_cleaner user_guess_number = 0 # Function Generate number creates a global secret number for game # Functions enters a random number between 1 - Difficulty number into secret number def generate_number(difficulty_num...