blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
be0844228e5f7c0a3f839f9a1946897d6ac5fc3d
estevanmendes/circlify
/circlify.py
16,589
4.15625
4
#!/usr/bin/env python # encoding: utf-8 """Basic circle packing algorithm based on 2 algorithms. Circles are first arranged via a version of A1.0 by Huang et al (see https://home.mis.u-picardie.fr/~cli/Publis/circle.pdf for details) and then enclosed in a circle created around them using Matoušek-Sharir-Welzl algorit...
60bc4dc92e11cdb3b40d47f95fbf374d70eba1d4
ishmeetkaur24/pythonproject
/Date_Time_Demo.py
241
4
4
#WAp to Display current date and time import datetime import time currentDate = datetime.datetime.today() print (currentDate) for i in range(100): TodayTime = datetime.datetime.today() print(TodayTime) time.sleep(2)
66858c07ada89061322b79ebf6898778d2bce2b8
aricaldoni/band-name-generator
/main.py
390
4.28125
4
#Welcome message print("Welcome to the authomatic Band Name generator.") #Ask the user for the city that they grew up in city = input("What city did you grow up in?: \n") #Ask the user for the name of a pet pet = input("What is the name of your pet: \n") #Combine the name of their city and pet and show them their band ...
6070c2c0be06988ab9a3d5954e33a131e9d075af
Sanych13/LITS
/HW 4.05.3.py
263
3.734375
4
a = input("Ввести число: ") paired = 0 unpaired = 0 for i in a: if int(i) % 2 == 0: paired += 1 elif int(i) % 2 != 0: unpaired += 1 print('парних - ' + str(paired)) print('непарних - ' + str(unpaired))
355156d4a28f9e2a01a2c45ac12ed3cd90f457d0
dogpetkid/python-networkingtest
/chess.py
38,614
3.59375
4
##Chess written by Dogpetkid ##Imports import os from Choose import * try: import winsound except: pass try: ##Import the multiplayer additions from clienttest import * from servertest import * multi = True except: multi = False ##Mess alert print("If you see this... you might have a box that just pop...
e3facb72fe0b03b080c4f240a3713655b80068c3
dantonyy/BIOMEC-Trabalho1-Paulo
/main.py
4,016
3.734375
4
#coding: utf-8 """ Faculdade de Medicina de Ribeirão Preto - Universidade de São Paulo (FMRP-USP) Fundamentos de Informática em Biomecânica Docente: Paulo Santiago Discentes: Dantony de Castro B. Donato (11845581) Criado em: """ xc1 = [365.8, 365.8, 107] yc1 = [211, 107, 211] xp1 = [0, 0, 50.9] yp...
5c63ce1e8387c64d3ed06025e7ae0a90dd61f246
TARMAH/HACKER-RANK
/PYTHON/Athlete Sort.py
262
3.546875
4
N,_ = map(int,input().split()) LIST = [] for i in range(N): l = [] l = list(map(int,input().split())) LIST.append(l) index = int(input()) LIST = sorted(LIST, key=lambda t : t[index]) for part in LIST: print(*[p for p in part])
8cada92aa1eecda58efbc5d50f56de5cab26b6e7
TARMAH/HACKER-RANK
/PYTHON/Word Order.py
285
3.6875
4
N = int(input()) DICT = dict() for _ in range(N): key = input() if key not in DICT: DICT[key] = 1 else: DICT[key] = DICT[key] + 1 STRING = "" for key, val in DICT.items(): STRING=STRING+str(val)+" " print(len(DICT)) print(STRING)
d2cc66762b5b732d6c0c43748cd3eeae8d5c1324
TARMAH/HACKER-RANK
/Project Euler/Project Euler #4 Largest palindrome product.py
621
3.5625
4
SET = set() def isPalindrome(n): return str(n)[0:3]== str(n)[3:6][::-1] def generatePalindromes(): I = 100 while I < 1000: J = 100000//I while J < 1000: if isPalindrome(I*J): SET.add(I*J) ...
728a60887376041c8d4d75494003dde3593dbcd6
TARMAH/HACKER-RANK
/ALGORITHMS/Larry's Array.py
2,153
3.5
4
t = int(input()) for i in range(t): a = 0 n = int(input()) li = [int(x) for x in input().split()] for j in range(n): for k in range(j+1,n): if li[j]>li[k]: a += 1 if a%2 == 0: print("YES") else: print("NO") ''' The formu...
017be2332653827a9a4d8432f995f0038f6fe668
curlyae/DGSim
/function/edit_data.py
6,510
3.78125
4
from data.connect_database import * """ .. note:: This module provides methods to maintain database """ def update_data(database_name, table_name): """ This function is used to update information in database :param database_name: string The database to connect to :param table_na...
102f1cf1344f532134df14053857809190d2fdb6
gabrieldcpadilha/scripts_python
/sorteio_de_duplas_lista.py
330
4.09375
4
""" Crie um programa que sorteie uma dupla e mostre na tela. Exemplo do sorteio: 'Aluno3 Aluno6' 'Aluno2 Aluno5' 'Aluno1 Aluno4' """ from random import shuffle lista1 = ['Aluno1', 'Aluno2', 'Aluno3'] lista2 = ['Aluno4', 'Aluno5', 'Aluno6'] shuffle(lista1) shuffle(lista2) for p1, p2 in zip(lista1, lista2): print...
0104b7e76ce4331093bd64834ad8ede3755d3a02
jusemarinho/exercicios-python
/EstruturaDecisao/ex3.py
189
4
4
letra = input("Digite um sexo (F ou M): ") if letra.upper() == "F": print(letra,"- Feminino") elif letra.upper() == "M": print(letra,"- Masculino") else: print("Sexo inválido")
f5c9367f74930c55f161356ec5249462885440c3
jusemarinho/exercicios-python
/EstruturaSequencial/ex2.py
88
4
4
numero = input("Digite um número: ") print("O número informado foi {}".format(numero))
afac3ede0e89a69c636e9e01180ee881bddb9af6
jusemarinho/exercicios-python
/EstruturaDecisao/ex2.py
113
4.03125
4
valor = float(input("Digite um numero: ")) if valor < 0: print("É negativo.") else: print("É positivo")
1c35c7cf689c6b801f2b0786098800458e2b01c0
jusemarinho/exercicios-python
/Lista/ex2.py
193
4.125
4
lista = [] print("Digite os 10 números: ") for item in range(10): numero = float(input()) lista.append(numero) lista.reverse() print("-----------") for item in lista: print(item)
2b6763ffdfa1c5fe25fcb4a3ee9394b7cc5df5a0
jusemarinho/exercicios-python
/EstruturaDecisao/ex6.py
337
4.09375
4
num1 = float(input("Digite o primeiro numero: ")) num2 = float(input("Digite o segundo numero: ")) num3 = float(input("Digite o terceiro numero: ")) if num1 > num2 and num1 > num3: print("O numero:",num1,"é maior") elif num2 > num1 and num2 > num3: print("O numero:",num2,"é maior") else: print("O numero:",n...
2b0b64d86296e84012025eb2f05a4b96ad5f4a5b
sherlockliu/Pythonic
/generator/yield.py
318
4
4
# !/usr/bin/python def not_a_generator(max_range: int) -> list: result = [] for r in range(max_range): result.append(r) return result def generator(max_range: int): for r in range(max_range): yield r g = generator(3) print(g.__next__()) print(g.__next__()) print(g.__next__())
9a93924ac56637394c78a7e1ae3fa7d29aa49534
capuche777/talkpython-10apps
/02_guess_the_number.py
726
4.0625
4
import random # Importa libreria para generar numeros random print('-------------------------') print(' GUESS THE NUMBER GAME ') print('-------------------------') print() the_number = random.randint(0, 100) # randinit genera un entero random, en este cao el rango es de 0 a 100 guess = -1 name = input('What is your...
0e69818ec6f8ad515e065e28ecffa88adf45e4c0
mddeloarhosen68/Python-Variables
/Global Variable.py
316
4.0625
4
#Global Variables #Ex:1 x = "awesome" def myfunc(): print("Python is " + x) myfunc() #Ex:2 x = "awesome" def myfunc(): # Create a variable inside a function, with the same name as the global variable x = "fantastic" print("Python is " + x) myfunc() print("Python is " + x)
6939303de26749e934042948fc26f1ee47fc25a4
edwardkonig/Aulas_de_python
/Objetos.py
848
4.03125
4
class Cachorro(): patas = 4 def __init__(self, nome, idade): self.nome = nome self.idade = idade def __str__(self): return "Este é o cachorro de nome " + self.nome def __repr__(self): return self.nome def latir(self): print("\"Au-au\"") print("{}, d...
591d5f4e43b1a8de1da12c270b2aff93edd62af0
davidga1996/prim-for-python
/prim.py
2,802
3.78125
4
import copy class Prim: def __init__(self, graph): #recogemos el grafo self.graph = graph #agregamos una lista vacia de aristas al grafo self.graph.prim = [] def create(self): i = 0 #tomamos el primer vertice vertex = self.graph.vertexs[i] wh...
94e3e6fb385d4cf0845d95aa52ff2b7678ec632f
sarekashi/kana-learn-py
/app.py
1,396
3.78125
4
import json, random file_json = open('data/kana.json') data = json.loads(file_json.read()) class bcolors: W = '\033[0m'; R = '\033[31m'; G = '\033[32m' arr = []; score = hira_quiz = 0; kana = data['kana'] for x in kana: arr.append(x) # randomize the arr random.shuffle(arr) # option to choose between hirag...
794e8642bd9c8507aed82a55ddba43586c9952be
MatanLidjiTalpiot/Reversi
/Gui.py
23,330
3.734375
4
import Game import Player from tkinter import * from math import * from time import * from random import * from copy import deepcopy # Method for drawing the gridlines def drawGridBackground(outline=False): # If we want an outline on the board then draw one if outline: screen.create_rectangle(50, 50, ...
1f347fab34431168beed6529148c886f904a5560
JaredJWoods/CIS106-Jared-Woods
/ses4/Ses4 Problem3 [JW].py
538
3.765625
4
print("$25 shipping fee waived for orders over $50") print("Type the price of your book[s] followed by [ENTER].") c=float(input()) print("The cost per book is: $",c) print("How many books will you be ordering?") q=int(input()) print("You are requesting:",q,"book[s].") t=float(c*q) print("Your subtotal comes to: $",t) i...
77127671637e5b1c26a78a25035bafca35213b71
JaredJWoods/CIS106-Jared-Woods
/ses8/PS8p2 [JW].py
354
4.03125
4
import time start = int(input("Enter starting number: ")) increment = int(input("Enter skip counting increment: ")) stop = int(input("Enter stopping number: ")) print() count = start print(" Counting ",start," to ",stop," by ",increment) while count <= stop: print(count) count = cou...
d578e45eea14c0cf3831224ac1c273a5bff1c79d
JaredJWoods/CIS106-Jared-Woods
/ses6/PS6p2 [JW].py
337
3.8125
4
def battingAverage(hits, atBats): average = float(hits)/float(atBats) return average lastName = str(input("ENTER LAST NAME: ")) hits = float(input("ENTER NUMBER OF HITS: ")) atBats = float(input("ENTER NUMBER OF AT BATS: ")) average = battingAverage(hits, atBats) print() print("NAME: ", lastName) print("AVERA...
9dd763a877c874d831426e0114a5909ececbfe99
JaredJWoods/CIS106-Jared-Woods
/ses11/PS11p1v3 [JW].py
6,434
3.671875
4
#---------------------------------MODULE_IMPORT------------------------------------- import time #time is for my delay between lines import sys #sys is beyond me but something I needed for the "typing" effect #----------------------------------VARIABLES----------------------------------------- index = int(input("#1 ...
5c90d207ec78f0c29467ad3e5f7a66bca9d21e44
JaredJWoods/CIS106-Jared-Woods
/ses8/PS8p5 [JW].py
1,144
4.1875
4
def incomeTax(gross): if gross >= 500001: rate = 0.30 print("You are in the highest tax bracket with a 30% federal income tax rate.") elif gross >= 200000 and gross <= 500000: rate = 0.20 print("You are in the middle tax bracket with a 20% federal income tax rate.") else: rate = 0.15 pr...
f98c704418702a3b3ab6c82bff81ec7a52049c77
venu2508/code_test
/code2.py
1,058
4.03125
4
def validinput(n): ''' validate input ''' if n%2==0 and n%3==0: return True return False def listofzeros(length): ''' returns list f zeros ''' return [0]*length def doWork(n): ''' this gives output of places where maths students should sit ''' sitting = [] # sitting[column][row] ...
004d092fd2cbdfc37618a59348e908c2b480bbf6
David-Lor/Loguru-Context-examples-lightning-talk
/examples/misc/threading-contextvar.py
1,986
3.984375
4
"""THREADING ContextVars Demonstration of Python ContextVars behaviour on threads """ from threading import Thread from contextvars import ContextVar from time import sleep from uuid import uuid4 RequestID = ContextVar("ID of the request") def _do_sleep(time_to_sleep): request_id = RequestID.get() print(f"S...
fdd4c896536b5c22b9f6cf002acf1d30ca14b1ba
YesManKablam/CountdownLetterGame
/letterGame.py
4,679
3.796875
4
# G00301273 # John Conor Kenny # Countdown Letter Game # Imports a timer function to see how long it takes to run the program import time start_time = time.time() # Opens the wordlist and asigns it to a list with open('newDic.txt', 'r') as fileopen: words = [line.strip() for line in fileopen] # Imports the rando...
bcace89ffd90e0d388ea8b874a14988df6831910
garciaomar/improved-octo-succotash
/src/classes.py
1,744
3.640625
4
from math import fabs class BoundingBox: treshold = 20 same_word_treshold = 10 #Initiate the class def __init__(self, word, coords): self.word = word elements = coords.split(' ') self.top_right_x = int(elements[0]) self.top_right_y = int(elements[1]) self.b...
38be351daedebb52f0c8c10c07da9427964cb656
Zohaib-Sathio/push-a-project-hacktoberfest
/Python Projects/Functions.py
293
3.734375
4
def addtwo(a,b) : added=a+b return added x=addtwo(3,2) print(x) def subtwo(c,d): sub=c-d return sub y=subtwo(4,4) print(y) def my_function(country = "Country"): print("I am from " + country) my_function("Sweden") my_function("India") my_function() my_function("Brazil")
28cde805af45660b4d1f69504a1f709f5a9d28a9
sofiacavallo/python-challenge
/PyBank/Drafts/homework_attempt_4.py
2,126
4.1875
4
# Reading / Processing CSV # Dependencies import csv import os # Files to load and output budget_data = "budget_data.csv" budget_analysis = "budget_analysis.txt" # Read the csv and convert it into a list of dictionaries with open(budget_data) as budget_data: reader = csv.reader(budget_data) # Read the he...
a234b4918edf6bb42ce8adc3b0966cb5c7f1f85a
diwasx/dotfiles
/Script/nepali_calendar/main.py
899
3.734375
4
#!/bin/env python3 import sys from datetime import datetime import adbs # current_date_ad = "2019/06/04" current_date_ad = datetime.today().strftime('%Y/%m/%d') current_date_bs = adbs.ad_to_bs(current_date_ad) # print(current_date_bs["year"]) if len(sys.argv)==2: if sys.argv[1] == "ne": # Nepali font ...
22e52a11e24de49f3c24a2dc3cb6e236a0a45922
JeonSuHwan/Data-Science
/DS1/DictionaryGeneration.py
285
3.734375
4
#Set tuple K about keys K=("White","Red","Black") #Set tuple V about values V=(1000,1001,0) def makeDict(k,v): d=zip(k,v) return d print("K :",K) print("V :",V) # Print dictionary D=makeDict(K,V) print("D :", end=" ") for a,b in D: print("{} : {}".format(a,b),end=" ")
67a4705ab7e55c17de86ac966540fb552e4b645c
qaespence/Udemy_PythonBootcamp
/6_Methods_and_Functions/Homework.py
2,178
4.4375
4
# Udemy course - Complete Python Bootcamp # Section 6 Homework Assignment # Write a function that computes the volume of a sphere given its radius def vol(rad): return (4.0/3)*(3.14159)*(rad**3) print(vol(2)) # Write a function that checks whether a number is in a given range # (Inclusive of high and low) def...
20c69b12d94322a8a58f4373987ddc5297d6abb9
JDmocho/Python-Exercises
/5_logical_operators.py
516
4
4
# task with logical operator IsWeekend = True print('IsWeekend=', IsWeekend) Temperature = 0 print('Temperature:', Temperature) Snow = True print('Snow=', Snow) GoSkiing = IsWeekend and Temperature <= 0 and Snow print('GoSkiing', GoSkiing) # another task IsWeekend1 = False print('Is weekend =', IsWeekend) Temperat...
5948ceed31db511b3ec6894e8c76e9a3f80f9865
lynnvmara/CIS106-Lynn-Marasigan
/Session 5/Extra Credit.py
935
4.21875
4
print("What is your last name?") name = input() print("How many hours?") hours = int(input()) print("What is your rate per hour?") rate = int(input()) if hours > 40: print(name + "'s regular pay for the first 40 hours is $" + str(rate) + " per hour for a total of $" + str(40 * rate) + ". The " + str(hours - 40) + " h...
c25c418679ffdeb532dffb1409fbfe486167ca5a
lynnvmara/CIS106-Lynn-Marasigan
/Session 7/Assignment 2.py
237
4.125
4
print("What is the starting value?") start = int(input()) print("What is the stop value?") stop = int(input()) print("What is the increment value?") increment = int(input()) while start <= stop: print(start) start = start + increment
8ea939d49a0e9f6de7c34972611b0243a3df6d7d
lynnvmara/CIS106-Lynn-Marasigan
/Session 4/Assignment 2.py
365
3.9375
4
print ("What is your last name?") name = input() print ("What is the first exam score?") score1 = int(input()) print ("What is the second exam score?") score2 = int(input()) print (name + "'s total score, with a first exam score of " + str(score1) + " worth 40% and a second exam score of " + str(score2) + " worth 60%, ...
3f195d11e81422ee80b866e42e024737d51d530b
ruizhang84/LeetCode-OJ
/insertionSortList.py
771
3.71875
4
class Solution(object): def insertionSortList(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None: return head root = ListNode(0) root.next = head temp = head.next head.next = None head = temp ...
654197fca86dde9218b02302c4f9b0d576177afc
ruizhang84/LeetCode-OJ
/rightSideView.py
794
3.75
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def rightSideView(self, root): """ :type root: TreeNode :rtype: List[int] """ if ...
8cdac073ea3899fa4e7eb8cc97e52b82bd3ef1b1
ruizhang84/LeetCode-OJ
/generateTrees.py
1,677
3.71875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def generateTrees(self, n): """ :type n: int :rtype: List[TreeNode] """ ans = [[]...
488a41d4c2d38d8719550b17c7852c6ed0470bd8
ruizhang84/LeetCode-OJ
/kthSmallestBST.py
718
3.703125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def kthSmallest(self, root, k): """ :type root: TreeNode :type k: int :rtype: int ...
e59637f5ed3e098ed14cd902ce539bcccdc7954d
MMMclaughlin/Data-visualisation-of-Proteins
/uniplot/analysis.py
1,525
3.609375
4
def average_len(record):#function to find average protein length "takes the list of proteans and then finds the average length of them all returning " totallength = 0#set total length for i in enumerate(record):#loop through the list totallength=totallength+record[i[0]]#add the length of selected pr...
34c244ca5ffea4bd647dd29bc2eb7bccfa436db8
radunm/jobeasy-algorithms-course
/HW_1.py
1,789
4.1875
4
# Sum of 3 modified # Rewrite a program with any number of digits. # Instead of 3 digits, you should sum digits up from n digits number, # Where User enters n manually. n > 0 from random import randint min_rand = 1 max_rand = "9" result = 0 digit = int(input("Please, enter digit: ")) digit -= 1 while digit > 0...
dada4202db884cbeb2c19042d26089564d2fb435
MorKalo/L10_HomeWork20-10-21
/Targil 9.py
1,155
4.1875
4
#ייצר את הפונקציות הבאות: div, mul, sub, add #פונקציות אלו צריכות לקבל שני פרמטרים y, x .כל אחת מהן צריכה לחשב את הפעולה המתמטית שהיא מייצגת ולהחזיר את התוצאה #כעת קלוט שני מספרים מהמשתמש )באמצעות input ,)קרא לארבעת הפונקציות שכתבת והדפסאת מה שהן החזירו #default ל- y, x אשר הוא אפס #add=חיבור def getDiv(x=0,y=...
50d17e24caa9844634242559bd042bf58f867dc4
JMass1/curso_python
/desafios/DESAFIO 61.py
305
3.75
4
a1 = int(input('Digite o primeiro termo da PA:')) r = int(input('Digite a razão da PA:')) n = int(input('Digite o número de termos desejado:')) lista = [] pa = int(a1) i = int(1) while n >= i: lista.append(pa) pa += r i += 1 print('Os {} primeiros termos da PA são:'.format(n)) print(lista)
78be9a3ad194f0874eee3f1aff50e43e288070d6
JMass1/curso_python
/desafios/DESAFIO 24.py
137
3.75
4
print('========== DESAFIO #24 ==========') sn = str(input('Em que cidade você nasceu?')).strip().capitalize() print(sn[:5]=='Santo')
03878de3f3524ff6ec984cce48ecd5eea59a18d6
JMass1/curso_python
/desafios/DESAFIO 75.py
538
4.0625
4
#IMPUTANDO VALORES EM TUPLAS num = (int(input('Digite um valor:')), int(input('Digite outro valor:')), int(input('Digite mais um valor:')), int(input('Digite um quarto valor:'))) print(f'Os numeros digitados foram {num}.') print(f'O numero 9 apareceu {num.count(9)} vezes.') if 3 in num: print(f'O numero 3 apareceu...
6cf6378fcf487db385b2201e773d5a2943b854e7
JMass1/curso_python
/desafios/DESAFIO 67.py
290
3.9375
4
# PROGRAMA PARA IMPRIMIR A TABUADA DE UM DADO NUMERO n = 1 num = 0 while True: print('-'*30) num = int(input('Quer saber a tabuada de qual valor? ')) print('-'*30) while n <= 10: print(f'{num} * {n:<2} = {num*n}') n += 1 if num < 0: break
f2e6313d2515598feba85c285328230664ccd866
JMass1/curso_python
/desafios/DESAFIO 16.py
178
3.859375
4
from math import trunc print('========== DESAFIO #16 ==========') n1 = float(input('Digite um número:')) n2 = trunc(n1) print('O porção inteira de {} é {}'.format(n1,n2))
f9b59d6d14bd4815ade502f840e5e8be52d0b47e
JMass1/curso_python
/desafios/DESAFIO 48.py
482
3.84375
4
print('========== DESAFIO #48 ==========') soma = int(0) cont = int (0) for c in range(3,496,3): if c%2 != 0: cont += 1 soma += c print('A soma dos {} valores solicitados é {}'.format(cont,soma)) ## Solução com uso de LISTA: i = int() nums = [i for i in range(3, 496,3) if i % 2 !=0] ...
c3fcce1c5c6a713cf1a49432368cec9a8e2ed667
JMass1/curso_python
/desafios/DESAFIO 78.py
699
3.875
4
#TRABALHANDO COM LISTAS lista = [] for i in range(0,5): lista.append(int(input(f'Digite um numero para a posicao {i+1}: '))) if i == 0: maior = lista[i] menor = lista[i] elif lista[i] > maior: maior = lista[i] elif lista[i] < menor: menor = lista[i] print(f'Dentro dos num...
814dc7252b7f1bb0d3fb79a72990716c3ea6c915
kurthill/probRobotics
/p2.1.py
257
3.546875
4
# Calculate the probability that the sensor is faulty def filter(bel): den = bel + 0.3333*(1-bel) return bel / den p = 0.01 print('0: {}'.format(p)) for i in range(1, 11): p = filter(p) print('{}: {}'.format(i, p)) print('hello world')
56b49b961fe4dd30e2e31832a9bed9640a1799ea
TEC-ANPI-IS2021-KDSB/Catalogo-ANPI---TEC-I2021
/Catalogo_Grupo_1/Parte 1/punto_fijo.py
1,514
3.8125
4
import sympy as S import matplotlib.pyplot as plt # Utiliza las librerías sympy y matplotlib # Funcion para calcular ceros de funcion con el Metodo del Punto Fijo # Entradas: # funcion : la funcion en texto # valorInicial : estimacion del cero # iterMax : iteraciones maximas # Salidas: # [ce...
998649baa7285122e041cdaf4a5dfbe984bc7c86
vishnuap/Algorithms
/Chapter-03-Arrays/Zip-It/Zip-It.py
1,449
4.875
5
# Chapter-3: Arrays # Zip-It # 1. Create a function that accepts two arrays and combines their values sequentially into a new array at alternating indices starting with the first array. Extra values of either array should be included afterwards. Given [1,2] and [10,20,30], return [1,10,2,20,30] # 2. Combine the two arr...
a687b9ce18b76a8c47809ec4f1c1cba11c42a09f
vishnuap/Algorithms
/The-Basic-13/Max-Min-Avg/Max-Min-Avg.py
386
3.875
4
# The Basic 13 # Max-Min-Avg # Given an array print the max, min and average values for that array def mma(arr): max = reduce((lambda x,y: x if x > y else y), arr) min = reduce((lambda x,y: x if x < y else y), arr) sum = reduce((lambda x,y: x+y), arr) print("The max is {}; min is {}; avg is {}").forma...
c847c6634e70a105c0fd65c0f83619e55e07937f
vishnuap/Algorithms
/Chapter-01-Fundamentals/You-Say-Its-Your-Birthday/You-say-its-your-Birthday.py
385
4.21875
4
# Chapter-1: Fundamentals # You-say-its-your-Birthday: # If 2 given numbers represent your birth month and day in either order, log "How did you know?", else log "Just another day..." myBDate = [3, 6] def bd(num1, num2): if num1 in myBDate and num2 in myBDate: print("How did you know?") else: ...
56c6b7dc97ec4603e5ab899bd72463ba3b15db7f
vishnuap/Algorithms
/Chapter-03-Arrays/Array-Nth-Largest/Array-Nth-Largest.py
2,588
4.40625
4
# Chapter-3: Arrays # Array-Nth-Largest # Given 'arr' and 'N', return the Nth largest element, where N-1 elements are larger. Return null if needed # Assume the arguments are an array with integers and an integer and both are passed to the function # Since we want Nth largest such that N-1 elements are larger, if ther...
c64da30e9e1e5e6c456829e4ece37cc5795a6476
vishnuap/Algorithms
/The-Basic-13/Array-with-Odds/Array-with-Odds.py
210
4.09375
4
# The Basic 13 # Array-with-Odds # Create an array with all odd integers between 1 and 255 inclusive def makeArr(): arr = [] for i in range(1, 256, 2): arr.append(i) print(arr) makeArr()
5cf62c7b4439da6886a3dcde946d642ca9a33e17
vishnuap/Algorithms
/Chapter-01-Fundamentals/Math-Help/Math-Help.py
537
4.09375
4
# Chapter-1: Fundamentals # Math-Help # Cartman doesn't really like math class and needs help. You are given two numbers - the co-efficients M and B in the equation Y = MX + B. Build a function that returns the X-intercept # X-intercept is where Y = 0. So # 0 = MX + B # => X = -B/M # So given M and B, X = (-1 * B)/M ...
3dc49d530e386fd3b266e007bc640f34d7046ef2
vishnuap/Algorithms
/Chapter-01-Fundamentals/Always-Hungry/Always-Hungry.py
489
4.1875
4
# Chapter-1: Fundamentals # Always-Hungry # Create a function that accepts an array and prints "yummy" each time one of the values is equal to "food". If no array element is "food", then print "I'm hungry" once # Assume the argument passed is an array def yummy(arr): hungry = 1 for i in range(0, len(arr)): ...
437f5172648fa184d26b649d351d11356c8b6c58
vishnuap/Algorithms
/Chapter-03-Arrays/Array-Rotate/Array-Rotate.py
4,195
4.28125
4
# Chapter-3: Arrays # Array-Rotate # 1. Given an array, implement rotate(arr, shiftBy) that shifts the array's values to the right by the amount specified in shiftBy.Wrap-around any values that shift off the array's end to the other side. Operate in-place and don't use built-in functions # 2. Allow for negative shiftBy...
44839717752081e621cee28e4eeea834b839cb69
vishnuap/Algorithms
/Chapter-04-Strings-AssociativeArrays/Common-Suffix/common-suffix.py
1,354
4.0625
4
# write a function that, given an array of strings, returns the longest common suffix (word-end) among all of them. given ["determination", "nation", "communication", "promotion"], return "tion". Given ["nice", "ice", "baby"], return "" (empty string) # assuming the validations are not required for the array being pa...
93cb895cbc0a72249e25dac5489153f304dcac91
vishnuap/Algorithms
/The-Basic-13/Print-Ints-and-Sum-0-255/Print-Ints-and-Sum-0-255.py
260
4.28125
4
# The Basic 13 # Print-Ints-and-Sum-0-255 # Print integers from 0 to 255. With each integer print the sum so far def printIntsSum(): sum = 0 for i in range(0, 256): sum += i print("{} - Sum so far = {}").format(i, sum) printIntsSum()
5ecdbe43cf811c46afe8a20274536b09060e87a6
vishnuap/Algorithms
/Chapter-02-Fundamentals-2/Clock-Hand-Angles-Revisited/Clock-Hand-Angles-Revisited.py
1,500
4.09375
4
# Chapter-2: Fundamentals-2 # Clock-Hand-Angles-Revisited # Refer to Clock-Hand-Angles in the same chapter # Print only integer values for the angles. import math # Assume the argument passed is a positive integer # Approach: # 1 full rotation of any hand = 360 degs # In 1 min = 60 secs, seconds hand covers 360 degs. ...
23355dd307a13236d38a8bde6571435771f8f1c2
vishnuap/Algorithms
/Chapter-03-Arrays/Array-Nth-to-Last/Array-Nth-to-Last.py
453
4.46875
4
# Chapter-3: Arrays # Array-Nth-to-Last # Return the element that is N from array's end. Given ([5,2,3,6,4,9,7], 3), return 4. If the array is too short return null # Assume the arguments are an array and an integer and both are passed def nthToLast(arr, num): return None if num > len(arr) else arr[-1 * num] myAr...
2dee4ac13bfc34d72b3a4bb04d199ab8be5de782
vishnuap/Algorithms
/Chapter-01-Fundamentals/What-Really-Happened/What-Really-Happened.py
1,334
4.15625
4
# Chapter-1: Fundamentals # What-really-Happened # (refer to Poor Kenny for background) # Kyle notes that the chance of one disaster is totally unrelated to the chance of another. Change whatHappensToday() to whatReallyHappensToday(). In this new function test for each disaster independantly instead of assuming exactly...
c86a6295b69a14f635b5433edd3ad9f1b6044ca6
vishnuap/Algorithms
/Chapter-04-Strings-AssociativeArrays/Drop-the-Mike/drop-the-mike.py
997
4.25
4
# Create a function that accepts an input string, removes leading and trailing white spaces (at beginning and ending only), capitalizes the first letter of every word and returns the string. If original string contains the word Mike anywhere, immediately return "stunned silence" instead. Given " tomorrow never dies ...
23c7d2c5550cd5e851ef1a7dedd4421659f1a842
vishnuap/Algorithms
/Chapter-04-Strings-AssociativeArrays/Integer2Roman/Integer2Roman.py
3,022
4.0625
4
# Given a positive integer, return a string containing that value represented in roman numerals.In this representation, I = 1; V = 5; X = 10; L = 50; C = 100; D = 500; M = 1000; 4 = IV; 9 = IX; 40 = XL; 90 = XC; 400 = CD; 900 = CM # Conversion of integers to romans will have to start by seperating the big, rounded int...
0d0ffaa8f3359bedd40bb5a1495339eecb8f03bc
vishnuap/Algorithms
/Chapter-01-Fundamentals/Multiples-of-3-But-Not-All/Multiples-of-3-but-not-all.py
386
4.65625
5
# Chapter-1: Fundamentals # Multiples of 3 - but not all: # Using FOR, print multiples of 3 from -300 to 0. Skip -3 and -6 # multiples from -300 down means multiply 3 with -100 and down. -3 and -6 are 3 * -1 AND 3 * -2. So if we skip them, the multipliers are -100 down to -3. for i in range(-100, 1): if ((i != -1...
262182ef4352290f9df20d28a56e15068e4a5eaa
vishnuap/Algorithms
/Chapter-04-Strings-AssociativeArrays/String-Trim/String-Trim.py
948
4.09375
4
# Write your own function to recreate the string.strip() function of python. Given str = " I am Me ", remove whitespace from both sides and return "I am Me". # Using the ord(char) values (9 = tab, 10 = newline, 13 = carriage return, 32 = space) to do this. First from the front, then from the back. Using the "...
905092abe8da1ea55e92a9d4a6b7f34565f2597b
vishnuap/Algorithms
/Chapter-02-Fundamentals-2/Statistics-Until-Doubles/Statistics-Until-Doubles.py
838
4.1875
4
# Chapter-2: Fundamentals-2 # Statistics-Until-Doubles # Implement a 20-sided die that randomly returns integers between 1 and 20 (inclusive). Roll the die, tracking statistics until you get a value twice in a row. After that display number of rolls, min, max and average import random as rd def stats(): done = Fa...
31b22e49ea518465e4e9b84f9bce3ff9ac222f46
f-alrajih/Simple-Calculator
/directions.py
2,879
4.5625
5
# Welcome, Faisal, to your first project in Python! # Today's project is to build a simple calculator that allows the user to choose what type of operation they want to do (add, subtract, multiply, or divide) and then takes the two numbers the user gives it and does the operation. # You will need to build four differ...
6cc529edec29f0bb16d7a9c78929bc1880a849e9
GaboEspadas/Computational-Statistics
/Series-2/solution_series2.py
2,297
3.84375
4
""" Series 2 More Simple Linear Regression and Selection Author: Gabriel Espadas """ import matplotlib.pyplot as plt import numpy as np from sklearn.linear_model import LinearRegression import requests import pandas as pd import statsmodels.api as sm # 1 - a) Download data, exploratory analysis, linear regression a...
e5adf749ad46659bc94ec4c4990be0fa3f270f9b
thebigbluebox/Code-Playground
/Algorithms/Python/CTCI/DataStructures/BinaryTree.py
2,460
3.9375
4
# Thanks to https://stackoverflow.com/questions/2598437/how-to-implement-a-binary-tree class Node: def __init__(self, val): self.__l = None self.__r = None self.__p = None self.__v = val def set_left(self, left): self.__l = left def get_left(self): return s...
d0d8b8af3bdca33394fb929be4c937b971f5a6dc
c0r3war/bibcoin
/block.py
1,782
3.84375
4
""" All about blockchain """ from datetime import datetime import hashlib class Block: "A basic block of blockchain" def __init__(self, prevblock=None): self.transactions = [] self.prevblock = prevblock self.nounce = 0 self.hash = None self.height = 0 # If...
e5e50ec95ded99887ce3447bd60042f992cc6453
StevenSunzh/children_AI_Education
/蓝桥杯历届考题及本届大纲/lq005.py
1,789
4.0625
4
# -*- coding: utf-8 -*- ''' 绘制分形树 ''' import turtle as tt # import turtle as tl # 把树干画出来 tt.speed(300) distance = 60 tt.left(90) tt.penup() tt.backward(distance) tt.pendown() tt.forward(distance) # y型,指定长度和角度 def ybranch(new_distance, degree): if new_distance < 5: return tt.left(degree) tt.forwar...
1ddc67098c1a2c9c7c15902e49655df6269ae6d3
rosarioValero/Programacion
/Ejercicios-Pr1/ejercicio3.py
221
4
4
# Ejercicio3: Diagrama que diga si un número es par o no print ("Introduce un número: ") N = int(input()) if N ==0: print ("Si es par.") elif N%2 == 0: print ("Si par.") else: print ("No es par")
c38ffa71f5bd44395114a52e200cd011bd4c3ef3
rosarioValero/Programacion
/Ejercicios-Pr5/ejercicio7.py
597
3.9375
4
"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA5 - EJERCICIO 7 Escriu un programa que demani un nombre (límit) i després et demani nombres fins a què la suma dels nombres introduits superi un nombre inicial. El programa termina escribint la llista de nombres""" print("Introduce el número limite") num=int(input()) ...
fa624f2a54619b753fbef9cfc9630dae67f92670
rosarioValero/Programacion
/Ejercicios-Pr5/ejercicio1.py
409
4.0625
4
"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA5 - EJERCICIO 1 Escriu un programa que te demani paraules i les guardi en una llista. Per a terminar d'introduir paraules, simplement pitja Enter. El programa termina escribint la llista de paraules.""" print("Introduce una palabra") pal=input() lista=[] while p...
abd0c998b57bf63c36afaddb760c8a6f227a7287
rosarioValero/Programacion
/Ejercicios-Pr2/ejercicio5.py
394
4
4
# Ejercicio5: Escriure un programa on el usuari entri 3 qualificacions d'exàmens # i calculi la mitja d'aquestes qualificacions. print("Introduce la primera nota") nota1 = float(input()) print("Introduce la segunda nota") nota2 = float(input()) print("Introduce la tercera nota") nota3 = float(input()) media =...
9fb5a1366d12831b7f3b22d2f68b65a8ca773910
rosarioValero/Programacion
/Ejercicios-Pr6/ejercicio9.py
746
4.28125
4
qq"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA6 - EJERCICIO 9 Escribe un programa que permita crear una lista de palabras y que, a continuación, cree una segunda lista con las palabras de la primera, pero sin palabras repetidas (el orden de las palabras en la segunda lista no es importante). """ print("Dime cuá...
466f1535379027fbf6cc322b1baf90095e73e57e
rosarioValero/Programacion
/Ejercicios-Pr7/ejercicio4.py
575
4.375
4
"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA7 - EJERCICIO 4 Escribe un programa que pida una frase, y le pase como parámetro a una función dicha frase. La función debe sustituir todos los espacios en blanco de una frase por un asterisco, y devolver el resultado para que el programa principal la imprima por pantall...
d2e1f8e6121ab0aa44fe8e899166b768028f39ed
rosarioValero/Programacion
/Ejercicios-Pr5/ejercicio9.py
748
4.21875
4
"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA5 - EJERCICIO 9 Escriu un programa que et demani noms de persones i els seus números de telèfon. Per a terminar de escriure nombres i numeros s'ha de pulsar Intro quan et demani el nom. El programa termina escribint noms i números de telèfon. Nota: La llista en la que es...
0ec29d10cd70854692ccd36f49594fa95ae8d040
VicziTomi/Python_FirstSteps
/02.py
969
3.953125
4
import random if 5 > 2: print("5 is greater than two") x = "Cuki" y = "Cicn" z = x + " " + y # print(z) a = 2j # print(type(a)) # print(a) tenthPow = 1e6 # print(tenthPow) # Generate random number: minValue = 1355425 maxValue = 245135777235 genNumber = random.randrange(minValue, maxValue) print(genNumber) print...
463616e731e37c89d1bab0fc57c5365b9c9878e4
VicziTomi/Python_FirstSteps
/firstClass.py
419
3.640625
4
class First: x = 5 var1 = First() print(var1.x) class Person: def __init__(self, name, age): self.name = name self.age = age variable = "random string" def greatMe(self): print("Hello, my name is: " + self.name) p1 = Person("John", 32) p2 = Person("Kate", 30) print(p1.name...
0122970b498a59df7715b6900670dceb84ec47f4
AlexeySukhanov/python_exp
/DataQuest/String Data Cleaning/string_data_cleaning.py
705
3.78125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ String data cleaning Created on Tue Jun 16 01:55:55 2020 @author: user """ cleaning_dict = {'A': 'a', 'B': 'b', 'C': 'c', 'D': 'd', 'E': 'e', 'F': 'f', 'G': 'g', 'H': 'h', 'I': 'i', 'J': 'j', 'K': 'k', 'L': 'l', 'M': 'm', 'N': 'n', 'O': 'o', 'P': 'p', 'Q': 'q', 'R': ...
32ba009fc07e931fb586bc2882c249b927457246
bhabicht/gravity-sim
/code/planet_system_creation.py
6,331
3.84375
4
import numpy as np class Massiveobject: """ Representation of a physical object. This class should represent the sun or a planet or a rocket. It has 4 attributes, name, mass, position x, starting velocity v. The last 3 parameters are necessary to solve the differential equation which governs...
894ad7d37fe04fa57835322578e9e3b643161741
ryananggada/PyReversi
/reversifunc.py
3,149
3.75
4
import random import globalvar as gv # initialize the board to starting position def initializeBoard(board): board[3][3], board[3][4] = gv.P2, gv.P1 board[4][3], board[4][4] = gv.P1, gv.P2 return board # shows the board, used for debugging purposes def showBoard(board): for x in range(8): for ...
9a209fa770a66dfb30fdb64a538da6631d583d5c
tarunvelagala/python-75-hackathon
/slice_list.py
325
3.890625
4
# indexing on list and tuple lst = [10, 20, 30, 'ramu', -22.5] print(lst[0]) print(lst[1]) print(lst[2]) print(len(lst)) #slicing in list print(lst[0:3]) print(lst[:]) print(lst[0::2]) print(lst[::-1]) tpl = (1, 2, 3, 4) print(tpl[0]) print(len(tpl)) print(tpl[:]) print(tpl[3::-1]) # repetition print(lst*2) print(tp...
a072bbc02f91778e4f4a26c4d41c188430805578
tarunvelagala/python-75-hackathon
/date-time-1.py
394
3.734375
4
# HANDLING DURATION from datetime import * dt = datetime(2018, 12, 20, 13, 2, 10) duration = timedelta(days=15, hours=10, minutes=30) print(dt+duration) print(dt-duration) # to measure the time taken by the program from time import * t1 = perf_counter() i, sum = 0, 0 while(i < 1000000): sum = sum+i i += 1 sl...
9d6b104a638a7d302a5aa5f89467ce47d7b5e972
tarunvelagala/python-75-hackathon
/input_output.py
239
4.125
4
# Input Example name, age = [i for i in input('Enter name and age:').split()] # Output Example print('Hello "{}", Your age is {}'.format(name, age)) print('Hello %s, Your age is %s' % (name, age)) print('Hello', name, 'Your age is', age)
cfd5b8a81f5f8511605f928ff658e78c9953db0e
tarunvelagala/python-75-hackathon
/logging.py
323
4
4
# Logging the Exceptions, errors and warnings import logging logging.basicConfig(filename='log.txt', level=logging.WARNING) try: a = int(input('Enter a number:')) b = int(input('Enter another number:')) c = a/b except Exception as e: logging.exception(e) else: print('The result of division is', ...
f6935c6ba61d642592b25748c95073d5a65b93e2
dheerajsharma25/python
/assignment11/ass11_4.py
301
3.8125
4
#Q4. Call factorial function using thread. import threading from threading import Thread import time class factorial(Thread): def run(self): n=int(input("enter any number:")) fact=1 for i in range(1,n+1): fact = fact * i print("factorial:",fact) t=factorial() t.start()
29ef8a7e547d0447fad1be9fd35d4dca442eff85
dheerajsharma25/python
/assignment6/ques6_6.py
87
3.890625
4
i=1 n=5 while(i<=n): j=1 while(j<=i): print("*",end="") j=j+1 i=i+1 print("\n")
2ccf71624478a3e9867ca75475630053040631b2
dheerajsharma25/python
/assignment8/assignment9/ass9_1.py
437
4.3125
4
#Q.1- Create a circle class and initialize it with radius. Make two methods getArea and getCircumference inside this class. import math class circle: def __init__(self,radius): self.radius=radius def area(self): getarea=math.pi*self.radius*self.radius print(getarea) def circumference(self): ...