blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b6db409712e90785738b4bc5811c3a33c5a13a01
JJavier98/AA
/PRACTICAS/P1/Template/Práctica1.py
40,394
3.609375
4
# -*- coding: utf-8 -*- """ TRABAJO 1. Estudiante: JJavier Alonso Ramos """ # Importamos módulo para trabajar con datos matemáticos import numpy as np # Importamos módulo para gráficos 2D import matplotlib.pyplot as plt # Importamos el módulo para formater tablas import pandas as pd # Importamos el módu...
2e746f0e79eb1456172445679d6c448cf168c15f
Jeetendranani/yaamnotes
/python/base_deque_implementation.py
499
3.5
4
class deque(object): def __init__(self, iterable=(), maxsize=-1): if not hasattr(self, 'data'): self.left = self.right = 0 self.data = {} self.maxsize = maxsize self.extend(iterable) def extend(self, iterable): for elem in iterable: self.appen...
879d4e5db45225968c1b55578319da27481669a9
Sakshi1504/Python-OOPS
/Generator.py
413
4.125
4
def topten(): yield 5 yield 1 yield 2 yield 3 values=topten() print(values) print(values.__next__()) #works same as generator, don't repeat the values that are already processed for i in values: print(i) #now if we want to process multiple values def top(): num=1 wh...
edfe7b1801ac480833b1b9245d8cbc2890279fb9
bloomspes/problems
/leetcode/5830.py
334
3.84375
4
''' Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false. An integer m is a divisor of n if there exists an integer k such that n = k * m. ''' class Solution: def isThree(self, n: int) -> bool: count = len([i for i in range(1, n+1) if n % i == 0]) retur...
866381686162c7d024d150f51f6af67d98c48997
MateusPatz/python
/Vigenère.py
5,904
4.09375
4
#!/bin/python3.5 import os tipo=int(input("Digite 1 para Ceasar\nDigite 2 para viginere\n")) nomeArquivo=input("Digite o nome do arquivo:") if tipo == 1: if os.path.isfile(nomeArquivo): #abrir arquivo e ler palavra arquivo = open(nomeArquivo, encoding="utf8") palavraCifrada = arquivo.readline().strip() arquiv...
66862a453d91ffd240bc1c550ff1f7010f9a285d
Tayo-Wunmi/Python-Mentorship-Program
/WEEK ONE/Challenge 5, Time Convert.py
607
4.15625
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> #CHALLENGE: # Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter convert...
5be66e5a90a26039ecdb7b2f5164de1fb554c019
jankurej/python
/Updating Variables.py
1,315
4.53125
5
#Updating Variables #One of the most common forms of reassignment is an update where the new value of the variable depends on the old. For example: x = x + 1 #This means get the current value of x, add one, and then update x with the new value. The new value of x is the old value of x plus 1. Although this assignmen...
433789f422bdc1e9572735c9494caec96adad137
aeron15/BLAST_genes_and_count_haplotypes
/compute_Mean.py
1,305
3.6875
4
""" Computes arithmetic mean, standard deviation and the minimum of a file parser.add_argument('macs2_files',help='This is a comma-delimited list of files that are output from MACS2. BED format is required, so you can use the summits.bed files or the .narrowPeak files') parser=ArgumentParser(description='Basic scri...
f27918ced7da67d7e91deaa3986058f1d937fa42
404232077/python-course
/ch03/3-3-1-dict1.py
796
3.859375
4
dict1={} print(dict1) lang={'早安':'Good Morning', '你好':'Hello'} print(lang) lang={'早安':'Good Morning', '你好':'Hello'} print('「你好」的英文為',lang['你好']) lang={'早安':'Good Morning', '你好':'Hello'} #print('「你好嗎」的英文為',lang['你好嗎']) lang={'早安':'Good Morning', '你好':'Hello'} print('「你好」的英文為',lang.get('你好')) print('「你好嗎」的英文為',lang.get('...
83abc36095644d1396184b38a8dc544dd02b77b2
jia80H/python-learning-experience
/12 正则表达式/01 正则基础.py
4,384
3.578125
4
""" 正则表达式介绍 """ # 正则表达式用来处理字符串 # 对字符串进行检索和替换 # 1. 检索 2. 替换 import re x = 'hello\\world' # 在正则表达式里,如果像要匹配一个\ 需要\\\\ # 第一个参数就是正则表达式匹配规则 # 第二个参数表示要匹配的字符串 m = re.search('\\\\', x) # match和search # 还可以在字符串前面加r , \\ 就表示 \ m = re.search(r'\\', x) # search和match方法执行结果是一个Match类型的对象 print(m) # <re.Match object; span=(5, 6)...
ce284979c2bb0ffb23ba7d8e381c8edcd786d53d
Ashiq-am/KBC-game
/1.py
3,558
3.65625
4
while (wrong != True): ques_no += 1 ran = random.randint(0, len(questions) - 1) print("\n\nQ.", ques_no, ":-", end="") print(questions[ran]) for num, option in enumerate(options): print(str(num + 1) + "." + option[ran]) print("Would you like to take lifeline, if yes, press 9...
a95d5448ae40fa04d8bc6ede1e214e3c4516dbcb
Elka75/my-first-blog
/firsttask.py
161
3.71875
4
def ifelse(): a = 8 if a > 5: print("No!") elif a < 5: print("No, too!") else: print("True!") ifelse() #l = [8, 4, 2, 9, 1, 0] for i in l: print(i)
27907057b676c920e31ce15dedaf1b568580e10a
rengoodgame/ren_first
/V6.py
1,511
3.5
4
""" 和V5功能一样,只是利用request功能实现 利用parse模块模拟post请求 分析百度辞典 分析步骤 1.打开F12 2.尝试输入girl,发现每次桥一个字母都有请求 3.请求地址为http://fanyi.baidu.com/sug 4.利用Network-ALL,找到文件的url地址 5. """ import urllib.request,urllib.parse import json baseurl = 'https://fanyi.baidu.com/sug' # 存放的用来模拟form的数据一定是dict模式 #**kw:表示就是形参中按照关键字传值,多余的值都给kw,且以字典*的方式呈现 da...
20f059ce0e4e2cfe7beebe5fff74bf0599a6c17d
rjuang/rum
/rum/displays.py
13,499
3.71875
4
""" Classes for managing display state in a midi controller. """ from rum.scheduling import Scheduler class Display: """ Pseudo-interface that all displays must implement. A display can show a field of characters where the rows are lines of text and the columns are individual characters of each line. I...
3dc521a5b6e0685b030507b837a20ffa01e8b53d
NguyenNgocHaiIT/PythonBasic
/TEST_PYA0502E/Ex_5.py
1,130
3.859375
4
class Person: def __init__(self, name, birth, email, address): self.Name = name self.Birth = birth self.Email = email self.Address = address def Show_info(self): print("Tên : ", self.Name) print("Năm sinh : ", self.Birth) print("Email : ", self.Email) ...
a870afb1b1b1ac75f8d4370c5eba4510e8f7f910
jankovicgd/gisalgorithms
/listing21.py
485
3.71875
4
# 2.1 Point # Listing 2.1 - run file to test the Point # Import the point class from geometries from geometries.point import * # Define points a and b a = Point(1, 2) b = Point(5, 3) # Print point a print(a) # Print results of logcal operations between a and b print(b > a) print(a < b) print(a == b) print(a != b) p...
24ffb9ecd29761e07e8169c9f7bbf2b0bfc9fea8
sowmyapa/PythonProjects
/reverse.py
279
4.25
4
""" Define a function called reverse that takes a string textand returns that string in reverse. For example: reverse("abcd") should return "dcba". """ def reverse(text): output=""; for i in range(len(text)): output=output+text[len(text)-i-1]; return output;
afbaf8a36f38fbad492cdb9b96dbb513bf6f8a36
letteropener/algo_exercises
/Ladder.py
2,310
4.03125
4
''' You have to climb up a ladder. The ladder has exactly N rungs, numbered from 1 to N. With each step, you can ascend by one or two rungs. More precisely: with your first step you can stand on rung 1 or 2, if you are on rung K, you can move to rungs K + 1 or K + 2, finally you have to stand on rung N. Your task is t...
cfce13ec34a4cf74957687b6e4d548d4b3d27876
HengyueZ/astrofix
/astrofix/Fix_Images.py
23,922
3.53125
4
# -*- coding: utf-8 -*- """ """ import numpy as np from scipy import optimize from warnings import warn from astropy.utils.exceptions import AstropyUserWarning def Squared_Expo(x1,x2,y1,y2,a,h): """ Squared_Expo(x1,x2,y1,y2,a,h) Compute the covariance matrix between points in set 1 and set 2, us...
f16db47150fe7cc07db101377c69930cf4b6b2c4
marceloigor/ifpi-ads-algoritmos2020
/Fabio01_Parte01/q7 soma e diferenca dos elementos.py
400
3.859375
4
# 7. Leia 3 números, calcule e escreva a soma dos 2 primeiros # e a diferença entre os 2 últimos. # Entrada num1 = int(input('Digite o 1º número: ')) num2 = int(input('Digite o 2º número: ')) num3 = int(input('Digite o 3º número: ')) # Processamento soma = num1 + num2 diferenca = num2 - num3 print(f'Som...
8c85c4f3d5d6cde3bc0a16dcd0d9104496024c34
JAY-YANG1/python3
/02operator.py
4,429
3.9375
4
num1 = 10 num2 = 20 num3 = num1 + num2 # 정수 + 정수 = 정수 num1 = 30.5 num2 = 50.5 num3 = num1 + num2 # 실수 + 실수 = 실수 num1 = 10 num2 = 30.5 num3 = num1 + num2 # 정수 + 실수 = 실수 # 매출액 구하기 month1 = int(input('1월 매출 : ')) month2 = int(input('2월 매출 : ')) month3 = int(input('3월 매출 : ')) quarter1 = month1 + month2 + month3 pr...
90c36b2b5e006ce7f92ae975bd4efc805e29d97d
Sambhaji-Jagtap/Py_Functions
/functions.py
96
3.515625
4
def fun(): return "Sambhaji", "Jagtap", 1234 a=fun() print(a) for item in a: print(item)
0281cd5fdb17c8562c2d44a47fe1e9287d462056
Heraklesss/RepositorioPython_005
/ejemplo1.py
529
3.984375
4
#ingresar 2 numeros, mostrar la suma y la umtiplicacion de ambos a=int(input("Digite un numero: ")) b=int(input("Digite otro numero: ")) suma=a+b multi=a*b print("La suma de " + str(a) + "y de" + str(b) + "es igual a: " + str(suma)) print("La multiplicacion de " + str(a) + "y de" + str(b) + "es igual a: " + str(mult...
02e17891d78b95ccfbab0a21b733c08b4bef1109
BrustureanElena/LabAI
/LAB2/main1.py
3,027
3.609375
4
# method that reads data from file #params : input :mat, file # output: number of towns-INT, town1-SourceTown -INT,town2-DestinationTown -INT def readFromFile(mat, file): file = open(file, 'r') numberTowns = int(file.readline()) m=numberTowns while m!=0: lineList = [] l...
081176012b4b41723fe13ff84efae23dcf152303
hyesungoh/algorithm-practice
/eachString.py
238
3.65625
4
# 이름 : 오혜성 # 날짜 : 12 05 2017 # 주제 : 문자열에서 서로 다른 문자열의 개수 s = input(); l = [] for i in range(0, len(s)): for j in range(i, len(s) + 1): l.append(s[i:j]) print(len(set(l))-1)
e249129e3fce48cdd462128a8849e81e28ee6985
anaruzz/holbertonschool-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
633
4.09375
4
#!/usr/bin/python3 class MyInt(int): """ class MyInt that inherits from class int but reverses the == and != operators """ def __init__(self, data): """ initialize the data @data: value of the object """ if isinstance(data, int): self.__data = data...
90c1daef8ad56aef8cd26bdea62d3c47fda2b3c9
mhofwell/cs50
/pset6/dna/utils.py
2,327
3.71875
4
from sys import argv, exit import csv import re # ensure proper input format from command line def sanitize(argv): if len(argv) != 3: print("Missing command-line argument") exit(1) # initialize the dnaDB dict using the dictionary file identified in input def initDict(argv, dbFile, tmp): db...
377d9960c41c07cb5150b7d717097bdbeb75621c
Cccmm002/my_leetcode
/463-island-perimeter/island-perimeter.py
1,588
3.984375
4
# -*- coding:utf-8 -*- # You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)...
190470e37bc4931108ed12c504db3b6732710bd0
aayushmansingh/Programming
/Celebrity_Problem_GFG.py
1,381
3.78125
4
#Problem link: https://practice.geeksforgeeks.org/problems/the-celebrity-problem/1 #Please try yourself first, before moving on to the solution. class Solution: #Function to find if there is a celebrity in the party or not. def celebrity(self, M, n): # code here stack = [] ...
e717bd8005f70d79efb2f38cfa94e30d6422b41d
Davidxswang/leetcode
/medium/397-Integer Replacement.py
871
4
4
""" https://leetcode.com/problems/integer-replacement/ Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacements needed for n to become 1? Example 1: Input: 8 Output: 3 Expl...
1b5218cd016b18cd3bde827b01864bcc50cab2e8
cathrynploehn-NIST/AuthenticationEquation
/py/keystrokeAlgorithm.py
5,332
3.890625
4
import re # Calculate number of keystrokes needed for a password entered in the mobile Apple brand platform # Each "screen" method simulates a real screen on the device. # In this model, each keypress does not trigger an automatic transition back to screen 1. # Ipad keystroke count based on the screens of th...
a2b0b781a907a359dc268dfcd7ac70c01563cf32
kevnefeg/Python
/listas/ejercicio_listas.py
173
3.890625
4
#practicas de listas dias=["lunes","martes","miercoles","jueves","viernes","sabado","domingo"] dia = dias[0] print(dia) dia = dias[5] print(dia) dia = dias[6] print(dia)
fbbd811d9b544d00ec39f46f27ae500e56b905bc
SickScarecrow8/CYPAmauryFD
/mayor_de_3.py
347
3.890625
4
a = int ( input ("Dame el primer numero: ")) b = int ( input ("Dame el segundo numero: ")) c = int ( input ("Dame el tercer numero: ")) if a > b and a > c: print(f"{a} es el numero mas grande.") if b > c and b > a: print(f"{b} es el numero mas grande.") if c > a and c > b: print(f"{c} es el numero mas grande.") p...
5b70b287d51c1d9b455eef7927e7c2cbd303c3df
ianyxtan/SDV602-YiXiong-Milestone-2
/SDV602-Milestone-2-Prototype/pages/home.py
3,184
3.578125
4
""" The home page will consists of the layout, event handlers and routes Why this is in one file? Because this is not a very huge file, the reason is to make finding things easier """ import PySimpleGUI as sg from PySimpleGUI.PySimpleGUI import WIN_CLOSED class HomePage(): """ The home page class will initi...
f6d507a0277d41487516943365a2e77d447872f3
mariaelisa492/Fundamentos_python
/semana_6/programas/interfaz/tkinter_ejecuta.py
2,189
3.609375
4
""" Empaquetar en Frames """ from tkinter import * window = Tk() width_window = 400 height_window = 200 width_screen = window.winfo_screenwidth() height_sreen = window.winfo_screenheight() x = (width_screen/2) - (width_window/2) y = (height_sreen/2) - (height_window/2) window.geometry('%dx%d+%d+%d' % (width_window...
25a149647adac3ea30cca500bb59bbc5ed5dd6d3
daviddzxy/CSES
/Trailing Zeros/main.py
98
3.59375
4
n = int(input()) i = 5 zeros = 0 while n // i > 0: zeros += n // i i *= 5 print(zeros)
6553f1488ad2cd432ebb31013999b5063f4d74d4
Hrishikesh-3459/leetCode
/prob_36.py
1,005
3.59375
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: for i in board: print(i) for row in board: for elm in row: if elm == '.': continue x = row.count(elm) if x > 1: ret...
9734d24352656c3f77d9cb566527be60bcf34621
Amrithnath/46-python-excercises
/ex6-summul.py
435
3.8125
4
#!/usr/bin/python import sys import os import time def main(): os.system('clear') given=input("enter the list of numbers\n") start=time.time() tot=sum(given) pro=mul(given) print("sum="+str(tot)) print("product="+str(pro)) print("time taken:",time.time()-start) def sum(data): ans=0 for num in data: ans=ans+...
69a5e8c9311e5e7578f56fa723320937d2769534
Hassan6678/Socket-Programming
/TCPServer.py
1,162
3.515625
4
from socket import * serverPort = 12000 ''' Create a socket socket.AF_INET - address family, IPv4, some otehr possible are AF_INET6, AF_BLUETOOTH, AF_UNIX socket.SOCK_STREAM - TCP, conection-based, socket.SOCK_DGRAM - UDP, connectionless, datagrams, socket.SOCK_RAW - raw IP packets ''' serverSocket = socket(family=AF...
2a328126b193cae31bdc7bc7fca289c3faff5f13
ganesh909909/html-bootstrap
/extracting digits using func.py
184
3.59375
4
def func(testlist): return(list(map(lambda x:int(''.join([ele for ele in x if ele.isnumeric()])),testlist))) a=func(['1','2','3','hello456','hai123','welcome123']) print(a)
213da8513c1cf221cd9db4a083e49e219d6fa731
verbalhanglider/my_secret_santa_picker
/secretsanta/__init__.py
1,030
3.75
4
from random import shuffle, choice def assign(participants): """a method to take a list of participants and return gift giver and reciever :param participants: an iterable containing strings to match up :type participants: list :return: a set of key:value pairs representing a secret santa giver and ...
4b3d8e345f498c6950b54a45a69258fa58b14949
xenron/sandbox-github-clone
/jw2013/Leetcode-Py/Search for a Range.py
1,350
3.53125
4
class Solution: def searchRange(self, A, target): left = self.searchRangeRecur(A, target, lambda x, y: x >= y, 0, len(A) - 1) if left >= len(A) or A[left] != target: return [-1, -1] right = self.searchRangeRecur(A, target, lambda x, y: x > y, 0, len(A) - 1) - 1 retu...
8d299fbf4d468be4f44b084c98b37c98118881b6
vivekvkt/programing_coding_test
/data_structure_python/searching/missing_element.py
222
3.65625
4
def findMissingElement(arr): n = len(arr) total_sum = (n+1)*(n+2)//2 #t = sum(arr) for i in range(n): total_sum-=arr[i] return total_sum arr = [1, 2, 4, 5, 6] print(findMissingElement(arr))
d6de2fc4e7be81a181cd6e99e7b963ea8d95ec06
roy355068/Algo
/Trees/116. Populating Next Right Pointers in Each Node.py
1,576
3.84375
4
from collections import deque class Solution(object): # do it in-place. # Iterative level-order traversal # O(N) for time complexity because need to visit every node once # O(N) for space complexity because of the queue size def connect(self, root): if not root: return dq...
2343f5e473529f24405f8fc5452b96032c262e2e
cs360f14/JungleJamboree
/GamePlay/Person.py
2,787
3.65625
4
#!/usr/bin/python ################################## # File Name: Person.py # Author: Group 3 # Date: 11/10/2014 # Project: Jungle Jamboree # Purpose: Person class ################################## from Inventory import * """ The Person Module """ class Person : def __init__ (self, name, healthEffect = 0)...
c04ddba091083cc5ef042ea742069999a72b7b5c
msaiganesh/SoilSensorAPI
/JenFoxBotSMSV1c.py
1,444
3.8125
4
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) file = open("SensorData.txt", "w") #stores data file in same directory as this program file #Define function to measure charge time def RC_Analog(Pin): counter=0 start_time = time.time() #Discharge capacitor GPIO.setup(14, GPIO.OUT) GPIO.o...
f91007e3a0fb940f95a8fc28d455b4e7934fa535
liwaya29/python
/4_basic_operators.py
435
3.578125
4
sum = 1 + 9 print(sum) diff = 9 - 1 print(diff) prod = 3 * 3 print(prod) quot = 25 / 5 print(quot) print(type(quot)) # modulo rem = 26 % 5 print(rem) # exponent res = 5 ** 5 prod = 5 * 5 * 5 * 5 * 5 print(res, prod) cube = 2 ** 3 sqr = 2 ** 2 print(cube, sqr) r = 1 + 2 * 3 / 4.0 print(r) # PEMDAS r = 1 + (2 ...
5a219e65fa719af2399edb8876d4c9e279cb81e3
bpbirch/DictDeque
/src.py
10,923
3.96875
4
#%% # creating a dict-based deque structure that allows for O(1) addition and removal # from either end of the deque #%% import numpy as np import time import matplotlib.pyplot as plt from string import whitespace, punctuation import urllib.request #%% # Deque # writing vanilla list-based deque class Deque: def ...
7ace120b7230d9d4288ff1dc2a23f6cf27ccd021
Joie-Kim/python_ex
/final_exercise/ex13.py
999
3.890625
4
# 13. DashInsert # 숫자로 구성된 문자열을 입력받은 뒤 문자열 안에서 홀수가 연속되면 두 수 사이에 -를 추가하고, # 짝수가 연속되면 *를 추가하는 기능을 구현해 보자. input_data = input() try: # 예외처리 연습 numbers = list(map(int, input_data)) # 각 문자를 정수로 변환. 리스트로 만듦 print(numbers) except ValueError as e: print(e) result = [] # 결과 저장 리스트 for i, number in enumerate(num...
c1ac68263a17d35ee4d95e008aaf46a648379660
pwlodarczyk92/python-problems
/tasks/gohome.py
1,317
4.21875
4
# write program that reads two integers - pair of user's coordinates on a map (x and y). # by entering 'a', 'w', 's' and 'd' characters, user moves by one unit in given direction. # after every move, his current coordinates are printed. # after reaching home, victory message is printed. # after pressing 'x' character, ...
1d0833c6edf0c64981f478c00484a5f13e753805
manhcuongpbc/tranmanhcuong-fundamental-c4e18
/Session04/login.py
444
3.9375
4
count = 0 while True: if count == 3: print("fail 3 times") break else: name = input("user name: ") if name == 'c4e': passs = input("pass: ") if passs == 'aaa': print("login success") break else: p...
df4f13f1d9f119ad95dd22f11f266b0b8eea199d
raunaklakhwani/Algorithms
/GenerateAllPossibleSortedArraysFromAlternateElementsOfTwoGivenSortedArrays/Main.py
1,279
3.59375
4
# URL : http://www.geeksforgeeks.org/generate-all-possible-sorted-arrays-from-alternate-elements-of-two-given-arrays/ from copy import deepcopy def generatePossibleSortedArraysUtilB(a, b, ai, aj, bi, bj, element): for i in xrange(bi, bj + 1): if b[i] >= element: return range(i, bj + 1) retur...
978422a00b47e5f906ddb88d0b912e8b0fd42ec1
taoranzhishang/Python_codes_for_learning
/study_code/Day_14/18有名对象与匿名对象.py
302
3.71875
4
class cl: def display1(self): print("有名对象") def display2(self): print("匿名对象") cl1 = cl() # 实例化有名对象 cl1.display1() # 调用有名对象的方法 cl().display2() # 调用匿名对象方法,与匿名函数一样,没有名字只能用一次
f077bc88c496ff6764c0df0784f86f27e01bcdec
sarthakmanna/sorting-
/QuickSort Analysis.py
2,764
3.59375
4
import time as tm import matplotlib.pyplot as pl import random as rd LOWER, UPPER, STEP = 50, 1000, 50 def generate(size): return [rd.randint(0, int(1e18)) for i in xrange(size)] def sort(ar): # https://www.geeksforgeeks.org/iterative-quick-sort/ def partition(arr, l, h): i = (l - 1) x ...
bfb44a19692b3814dd29942424e22869865174a2
rogeriosilva-ifpi/adsi-algoritmos-2016.1
/atividade_d/prova-d(Guilheerme)/9.py
358
4.09375
4
#Escreva um programa que receba um numero inteiro e #que recursivamente escreva os seus 10 primeiros multiplos. def multiplo(numero): if numero==0: return 1 else: if numero%2 == 0: print(numero) print(multiplo(numero+1)) #return numero + 1 else: ...
a68fef1d060c51c005c2af87fde53ad5962b6280
srikarvaka/Neural-networks-training
/Basic_NN.py
1,365
4.28125
4
import numpy as np ''' A simple neural network demonstration using python This neural network has one hidden layer with 3 nodes in it This demonstration is about simple forward propogation ''' #y is the marks scored and x is (sleep, study) hours y = np.array([[85], [70], [78], [94]]) #to make it 4 x 1 colomn ve...
2c86478843bf84d9edd4bcbcc6c9e3afe2ce1bbd
yshshadow/Leetcode
/300-/438.py
1,635
3.875
4
# Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. # # Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100. # # The order of output does not matter. # # Example 1: # # Input: # s: "cbaebabacd" p: "abc" # # Ou...
e518439952d3a127b8ddd8f255a8b4e9419906e2
dimekai/Blackjack
/blackjack.py
8,488
4.03125
4
''' It also known as 21, is a card game where players try to get as close to 21 points as possible without going over. This program uses images draw with the text characters, called ASCII art. The playing cards in this program are an example of ASCII art ''' import sys, random # Set up the constants HEARTS = chr(...
4d2dedf8084f5c3865753329bff300a1619c81d7
PolinaStaroverova/homework
/my_first_program.py
603
3.96875
4
print('С помощью нескольких математических операций любое число можно превратить в 4') a=input('Введите любое число: ') print('Число', a, 'умноженное на 2 равно',float(a)*2) b=float(a)*2 print('Число', b, 'плюс 8 равно', b+8) c=b+8 print('Число', c, 'поделенное на 2 равно', float(c/2)) d=float(c/2) print('Число...
a60ab6a821c01c966925b990b12721f9ce34fd60
antilectual/CodingPractice
/LeetCode/1299. Replace Elements with Greatest Element on Right Side (easy).py
480
3.9375
4
# 1299. Replace Elements with Greatest Element on Right Side # Algorithm: iterate the list from right to left finding the largest value and replacing the current value in the same index in a copy of the list class Solution: def replaceElements(self, arr: List[int]) -> List[int]: newList = [] maxInt...
209d0bcf62b15911b5ff025ca6de2dfbcbe4ba77
jordan-carson/Data_Structures_Algos
/Coursera/1. AlgorithmicToolbox/week3_greedy_algorithms/3_maximum_advertisement_revenue/dot_product.py
829
3.625
4
#Uses python3 import sys def max_dot_product(a, b): # sum = total = 0 for i in range(len(a)): total = total + a[total] * b[total] return total print(max_dot_product()) # res = 0 # # for i in range(len(a)): # # max_a = get_max_index(a) # # max_b = get_max_index(b) # ...
030ec516f198272905643b15ce1f611eb0d43938
sidaker/dq
/pythonconcepts/functprgram/func1.py
441
3.703125
4
def sort_by_last_letter(strings): # last_letter is a local function def last_letter(s): return s[-1] # print(last_letter) # new function is created evrry timke def is executed return sorted(strings,key=last_letter) aa = sort_by_last_letter(["Advik", "Loikhi", "Daddy", "Amma"]) print(aa) d...
125c5632f62e91907910a9568041e0b6e35830a1
jaehyunan11/Python_Learning
/Day_30/main.py
465
3.828125
4
# File not found with open("a_file.txt") as file: file.read() # KeyError a_dictionary = {"key": "value"} value = a_dictionary["non_existent_key"] # IndexError fruit_list = ["Apple", "Banana", "Pear"] fruit = fruit_list[3] # TypeError text = "abc" print(text + 5) """ 1. Try : Something that might cause an excep...
289f1744b1eae3e73e7374750b1ad7a693e0adae
meat00/my-leetcode-python
/0014longest-common-prefix.py
996
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Solution: def longestCommonPrefix(self, strs) -> str: if not strs: return str() prefix = strs[0] prefix_len = len(prefix) for s in strs[1:]: i = 0 cur_prefix_len = 0 while i < prefix...
1a85cab35bb432c58b61c24258fb2fdd7ff0abcb
ZehuaWang/python_ladder
/python_ladder/python_ladder/stack/IntegerToBinary.py
438
3.6875
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 3 18:47:05 2020 @author: ewang """ from stack import Stack def div_by_two(dec_num): s = Stack() while dec_num > 0: remainder = dec_num % 2 s.push(remainder) dec_num = dec_num // 2 bin_num = "" while ...
7c2f528136d99ea81ed850ae70c113b469fc633e
miranda-lin/GWC_2016_Projects
/Python/runner.py
3,016
3.546875
4
import pygame import random from city2 import Scroller # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) GREY = (129, 129, 129) TB = (50,204,203) LB = (204,255,255) LP = (255,204,255) P = (229,204,255) colors = [TB,LB,LP,P] def random_color(): retu...
5bdb12e229406c0046ca95c75c0a2955fcf2f2f2
Bayanalotaibi/Advanture-Game-Project
/main.py
14,661
4.03125
4
import time import random '''This game is about player journey to his/her deputy ceremony at the king Palace in the Great Island, an Island controled by the villin (king servent) who tries to stop player from attending the ceremony by controling the enviorment of the great Island Defind lists and functions, Lists, the ...
f7c1fdd54c605d64f8e5d3bff656a062cf57b09d
patrik-nilsson/Python
/6.3.py
981
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from motor import Hybridmotor def main(): #Create Hybrid Engine Motor1=Hybridmotor() #Start/stop the Engine for Motor1 reply=raw_input("Start/Stop engine: ") Motor1.changestate(reply) #Run Fuel driving test with the Hybrid Engine? reply=raw_input("Run test? (y/n) ")...
704362c5e88b2446e59ce46b4246e38720d04e34
hhebo/leetcode
/0086_Partition_List/Partition_List.py
1,020
4.0625
4
# -*- coding: utf-8 -*- """ Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. Example: Input: head = 1->4->3->2->5->2, x = 3 Output: 1->2->2->4->3-...
6acc500ea342e219abb9024164a21eb299db058f
ayesha928/fyp
/src/dummy_pcb/dummy_pcb.py
3,967
3.5
4
from lib.protocol import encode_command, decode_command import time class PCB(object): """ This class contains those functions and methods which reflects the pcb as dummy (software of pcb) Varibale pcb_status stores the status of all the sections and devices in the form of nested lists """ pc...
cb73d24bf772a6c29470dfb1a463999eff4ec472
DanielleSinnett/DanielleSinnett.github.io
/model2.py
2,384
4.0625
4
# -*- coding: utf-8 -*- """ model2.py created on Wed Feb 13 20:23:59 2019 @author: Danielle Sinnett, student number 200827672 This is the second version of the agent based modelling portfolio. It sets up two agents, walks them one step in a 100 x 100 grid and plots their final location. To run it: 1. Download this f...
63c8ece3c50575067096481219ee4578bfb88da4
jjerry-k/learning_data_structure
/Doubly_linked_list/02_Append.py
1,060
4.15625
4
class Node: def __init__(self, data): self.data = data self.prev = None self.next = None class Doubly_Linked_List: def __init__(self): self.head = None self.tail = None def __str__(self): res_str = "|" iterator = self.head while itera...
d788cd197169073318071c1171ef258cee1bf047
SBrman/mixed
/mixpy/linkedLists.py
1,258
3.78125
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: extra = 0 def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: if l1 == None and l2 == None: return ListNode(s...
29f16cca9eed39d201adc463387979dbacff0313
sjbncode/python-test
/test1.py
1,658
4.0625
4
# -*- coding: UTF-8 -*- name=raw_input("\n\n enter some value") if name=="aa": print 'this is aa' else: name+=" other" print name #print name #string print "-------------------------string---------------------------------" s='ilovepython' print s[0] #i print s[1:5] #love print s[2:] #lovepython print s*2 #ilovepy...
b4b180df5c5fedea48f4dab41eb4a90b889aa47c
magnoazneto/IFPI_Algoritmos
/Fabio02a/fabio02a_10_data_valida.py
623
3.6875
4
def main(): dia, mes, ano = map(int, input('Digite a data: ').split('/')) print('Data válida.') if testa_data(dia, mes, ano) else print('Data inválida.') def testa_data(dia, mes, ano): if dia > 31 or dia <=0 or mes > 12 or mes < 0 or ano <= 0: return False elif (mes % 2 == 0 and mes < 8) or (mes % 2 != 0 and me...
d8d472523169ead212e0e679fb7b6630bf488571
marcelomonier/aulasPython
/for.py
226
3.578125
4
def main(): lisPar = [] listImpar = [] for x in range(1, 101): if x % 2 == 0: lisPar.append(x) else: listImpar.append(x) print(lisPar) print(listImpar) main()
4c1c5ac6e54d3ba29594e3a18358f2d0976767f6
renatasarmet/robopaa
/TrabRoboCMD/roboForcaBruta.py
1,728
3.828125
4
from random import randint # Definição de funções #Definindo o tabuleiro, cada célula possuindo ou não uma moeda def definir_tabuleiro(n_linhas, n_colunas): T = [] while len(T) != n_linhas: linha = [] while len(linha) != n_colunas: a = randint(0,1) linha.append(a) ...
041af82321e2db5dfc958fe56886fca45279c5bf
tarunkathuria1/standard_deviation
/graphs/class1.py
698
3.59375
4
import csv with open('class1.csv',newline='') as f: reader = csv.reader(f) file_data = list(reader) #to remove headers from CSV file_data.pop(0) total_marks = 0 total_entries = len(file_data) for marks in file_data: total_marks += float(marks[1]) mean = total_marks / total_entries print ('Mean ...
2b09cf04614e8591cf11d816f9c956c643ccdaee
polortiz4/bme590_assignment02
/bradyTachyCardia.py
733
3.53125
4
import numpy as np def bradyTachyCardia(HRinst): """Determines when bradycardia or tachycardia occurred in the ECG trace :param HRinst: (ndarray) :returns: (list) of same length as HRinst that indicates when brady- or tachycardia occurred """ bradyTachy = [''] * np.size(HRinst) for i, ...
e24468f92f5ecd9c03f2fb009a639170e22fdda9
1914866205/python
/pythontest/day39数据样本和清洗.py
481
3.984375
4
""" 数据样本和清洗 """ from random import randint, sample, shuffle, uniform # 使用random的sample抽烟十个样本 lst = [randint(0, 50) for _ in range(100)] print(lst[5]) lst_sample = sample(lst, 10) print(lst_sample) # 使用内置random中的shuffle函数冲洗数据 lst = [randint(0, 50) for _ in range(100)] shuffle(lst) print(lst[:5]) # 生成满足均匀分布的坐标点 x, y = ...
9fa0a41d13a0b4ed1524bb1c978386eab568b368
pingguosanjiantao/Elements-of-Programming-Interviews
/16-Recursion/code/16.1-The towers of hanoi problem.py
596
3.515625
4
NUM_PEGS = 3 def computeTowerHanoi(numRings): pegs = [[]] * NUM_PEGS for i in range(numRings, 0, -1): pegs[0] += [i] doComputeTowerHanoi(numRings, pegs, 0, 1, 2) # peg flow: from -> use -> to def doComputeTowerHanoi(numRingsToMove, pegs, fromPeg, toPeg, usePeg): if numRingsToMove > 0: ...
9eb53cdc729caf6e24be806e8b1fc3720c61519e
iwyna03/IN104_Andriatsiferana_Irina_Roxana
/sportif.py
778
3.71875
4
#Class of Sportifs class Sportif : def __init__(self,weight): self.__weight = weight class Wife (Sportif) : def __init__(self, size, sport, name): self.size = size self.sport = sport self.name = name def getSports(self): print("Miss.",self.name,"makes", self.sport) def getSize(self): ...
57da1b556f0ca5b8467911d0bc9f9f335281e4f2
RohanPhadnis/YoungWonks
/Level5/data_structures/queue_exercise.py
1,226
3.84375
4
# Queue: ordered FIFO data structure. insertions done at the end, deletions done at the begining import random class Queue: def __init__(self, limit): self.__array = [] self.__limit = limit def get_limit(self): return self.__limit def get_size(self): return len(self.__ar...
30f76f56794edfe57e9c23a9119ba456e413b65f
a-paxton/bwlf
/bwlfCleanup.py
1,553
3.53125
4
############### # B(eo)W(u)LF Code: # By-Word Long-Form Data Preparation # This code reads in a sample text file, reformats it, and exports it to # a new file before further formatting and analysis. # Written by: # Date last modified: June 16, 2013 ############### # coding:utf-8 import os,re,unicodedata,shlex,glob ...
df80303f985dc3662039efd128f96fa757eb029e
chenshaobin/python_learning_demo
/classDemo.py
2,405
3.859375
4
#!/usr/bin/python # -*- coding: utf-8 -*- class Student(object): def __init__(self, name, score, gender): # 属性的名称前加上两个下划线__就变成了一个私有变量 self.__name = name self.__score = score self.__gender = gender def print_score(self): # print('%s: %s' % (self.name, self.score)) ...
e637e2e8c213bf5c07269244edfa2cf0e693c361
gwAdvNet20/HelloInternet
/python/hellosrvPython.py
639
3.546875
4
#!/usr/bin/env python3 # SOCKET SERVER import socket import sys HOST = "0.0.0.0" # Listen on all interfaces PORT = int(sys.argv[1]) # Port num is a command line argument msg = "Goodbye in Python" print("Starting Python hellosrv") with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.setsockopt(socket....
65732d5b9bbdade2357e9043d9ed3a66a0740daf
prabhat-krai/NOSQL_lite
/db/utils/process_json.py
2,191
3.96875
4
import json def is_json(json_input): #checking if the input by user is valid json try: json_check = json.loads(json_input) #loading in python's JSON parser and catching if it throws exception except ValueError as e: return False return True def extract_key_value(json_input): #taking the json as input and...
56d20b043c976e8f08e4cbb4a10c3631f23f88d2
AthosFB/Exercicios-Python
/ExercícioDoCurso/005.py
255
3.59375
4
valor = int(input('\033[4;33mColoque um número: ')) ant = valor - 1 suce = valor + 1 print('\033[mO Antecessor é \033[1;35m{}\033[m e o sucessor é \033[1;31m{}\033[m'.format(ant, suce), end=' ') print('E o valor original é \033[1;36m{}'.format(valor))
6a7d40ad9cda55d76f053e2679cfa5464c544cb5
Dazpoet/Learning-python
/CourseExampleAssignements/turtletest.py
132
3.515625
4
#!/usr/bin/env python3 import turtle import time for i in range(0,3): turtle.forward(100) turtle.right(120) time.sleep(5)
24ca85b13a484da3fd3730011684ed12ea8b95eb
SCurtis95/cst8279
/question12.py
270
4.125
4
## Question 12 ## temp = input("Please enter in the degrees in fahrenheit: ") fahTemp = int(temp) celsius = ((fahTemp - 32) / 1.8) cel = round(celsius) finalTemp = str(cel) print("The temprature " + temp + " in fahrenheit is " + finalTemp + " degrees in celsius")
63de51f44a66eab55d637ad655d8cd219b23474e
TitanicThompson1/FPRO
/Play/Functional Programming/to_fahrenheit.py
196
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 20 11:19:09 2018 @author: Ricardo Nunes """ def to_fahrenheit(t): result=list(map(lambda a: round(a*(9/5)+32,2),t)) return result
b9f43bd43b9a7b81dabc929a3879ff254c649ee2
lfontesc/Python_Study
/Curso_Excript_Python/Modulo_Programação_Python/Aula_13.py
376
4.1875
4
#======================================== #=============== lfontesc =============== #======================================== # Types of Variables num_int = 5 num_dec = 7.5 val_str = "olá" print("Numero Inteiro ", num_int) print("Este numero",num_int," é inteiro") print("Este numero é: %i" %num_int) print("Este nume...
5d677e61b650ec789cbebda851b690a284d4381a
danielhinker/delivery-route
/truck.py
5,134
3.59375
4
from search import searchDistance from hashmap import packagesHash from utils import currentTime import datetime class Truck: # Initializes the attributes of each truck # O(1) time def __init__(self, hashmap, name, nodeArray, originalAmount): self.currentLocation = "4001 South 700 East" self.packa...
ac7844ec6989ae1077f39dacfc26ae5d416f0f45
ricardoag-gh/TalleresPrograAvanzada
/Taller#5/main.py
5,365
3.640625
4
from CONTROLLER.controllers import Controller from MODEL.models import Player from testing import write_json import json corriendo = True num = 0 #Instancia de controller controlador = Controller() #Instancia usuario usuario = Player() while corriendo : print("=========================================...
2ff22ee382fdc3181ac72340c95db5f2a652292c
orlyrevalo/Personal.Project.2
/Project2.8.3.py
1,038
4.25
4
'''Functions''' # Returning a Simple Value print("Returning a Simple Value") def get_formatted(first_name, last_name): """"Return a full name, neatly formatted.""" full_name = first_name + ' ' + last_name return full_name.title() musician = get_formatted('jimi', 'hendrix') print(musician) #...
ac19bdfbf7066d6cdde59c6790e8f029acd839aa
lapisco/Advanced-Programming-Lists
/Lista_de_Fluxograma/Adriell/Questão 1.py
245
3.953125
4
#Ler um número e cálcular o dobro def dobro(num): return num*2 if __name__ == '__main__': print('digite o número\n') num = input() print('o número digitado foi {:}, já seu dobro é {:}:'.format(num, dobro(int(num))))
38efd2b01fea0e3fa86f46f2aeb146e83bc78994
paul-khouri/fruitbowl
/reg_expressions.py
1,121
4.0625
4
"""Regular expressions checker""" import re def test_one(): pattern = "r'\d\d\d'" s = "my 456number is 123" t= "AS910586758 jkakdhkshAS91067" #match = re.search(r'[\d]+', s) #match = re.findall(r'[\d]+', s) #match = re.findall(r'[\d]+nu[mb]+', s) match = re.findall(r'AS[0-9]{5,5}', t) ...
727bf392ab638df8d0fab9d237182c681bea9b91
Hari0399/Hari-_IT--Python
/rolldice.py
171
3.90625
4
import random while True: n=(input("Enter r to roll the dice,or q to quit:")) a=input("enter r or q") if(a=='r'): r=random.randint(1,6) print(r) else: break
3bba61a7bbaaabaa650ed825c0b07d063ea172f6
binrohan/30days_30problems
/problem005/day3.py
229
3.53125
4
num = 0 i = 0 while num == 0: i = i+20 if (i%11 == 0 and i%12 == 0 and i%13 == 0 and i%14 == 0 and i%15 == 0 and i%16 == 0 and i%17 == 0 and i%18 == 0 and i%19 == 0 and i%20 == 0): num = i break print num
d81834817cb4b268ce81692c573ef87f7b317299
b3296/py
/test/hello.py
432
3.859375
4
# age = 18 # name = 'bxl' # print('{0} was {1} yeas old'.format(name,age)) # print('string must in "" by {0}'.format(name)) # printStr=name+'is'+str(age)+'yeas old' # print(printStr) # print('{0:.5f}'.format(1/6),end='this is end') # print('{0:-^18}'.format('9')) # i = 5 # print('{0}'.format(i)) # i = i+1 # print(i) s ...