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
36235860a4709f00a1525a891d9c73dc5804a299
Anh-VAnh/Project3
/menu.py
5,452
3.59375
4
import pygame import os from random import randint import pyttsx3 pygame.init() robot_mouth = pyttsx3.init() # Set screen size WIDTH = 400 HEIGHT = 600 screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN) running = True GREEN = (0, 255, 0) WHITE = (255, 255, 255) BLACK = (0, 0, 0) ...
17b623bbd001ad81a77ce24b89a5f7186bf1fd74
Stargent-Robotics-Community/ayushigeorge.py
/assignment1.py
593
3.765625
4
mylist =["riverdale", "friends", "lawschool", "jesuscode", "biohackers", "geteven", "bloodandwater"] for i in mylist: print(i) --Q2-- mylist= ["riverdale", "friends", "lawschool", "jesuscode", "biohackers", "geteven", "bloodandwater"] yourlist = input("your fav shows: ") mylist.append(yourlist) print(mylist) ...
eb28ae1ec98b3b88011e9d8d9cf89cc3b85a8a07
pavlomorozov/algorithms
/src/codility/python/Kadane.py
344
3.546875
4
def kadane(A): max=currentMax=A[0] for i in range(1,len(A)): if A[i]>A[i]+currentMax: currentMax=A[i] else: currentMax=A[i]+currentMax if currentMax>max: max=currentMax return max A=[-2, 3, 2, -1] print(kadane(A)) A=[3,2,-6,3,2,-5,2,7,9] print(A) print(kadane(A)) A=[-5, 6, 7, 1, 4, ...
a13ef15e8089b6ef53daadec829013b864132b85
pavlomorozov/algorithms
/src/codility/python/11_sieve_of_eratosthenes/Factorization_2.py
575
3.71875
4
# 21:06 - 21:39 def getPrimes(n): primes = [0] * (n+1) i=2 while i*i <= n: if primes[i]==0: k = i*i while (k<=n): if primes[k]==0: primes[k]=i k=k+i i+=1 return primes def getFactors(n, primes): factors = []...
64c2dfec7a47973676e6973d3e2d92cad72b4a35
pavlomorozov/algorithms
/src/codility/python/11_sieve_of_eratosthenes/Factorization_4.py
687
3.671875
4
#23:16-23:22 def getPrimes(n): primes = [0]*(n+1) i = 2 while i*i<=n: if primes[i]==0: k = i*i while k<=n: if primes[k]==0: primes[k]=i k+=i i+=1 return primes # 23:22-23:25 def getFactors(n, primes): factors...
e59b96d2f3400e5f8b52cb8a26ee3e7479913d29
dhoshya/grokking-algorithms
/quickSort.py
440
4.15625
4
# D&C def quickSort(arr): # base case if len(arr) < 2: return arr else: pivot = arr[0] # using list comprehension less = [i for i in arr[1:] if i <= pivot] # using normal syntax greater = list() for i in arr[1:]: if i >= pivot: ...
fe5d54e4995dde1d88c57f80b3ff5e3f122a8828
HenryDashwood/algorithms
/merge_lists/python/merge_lists.py
868
3.84375
4
def merge_lists_slow(list_a, list_b): return sorted(list_a + list_b) def merge_lists_fast(list_a, list_b): merged_list = [None] * (len(list_a) + len(list_b)) len_a, len_b, merged_len = len(list_a), len(list_b), len(merged_list) ind_a, ind_b, merged_ind = 0, 0, 0 while merged_ind < merged_len: ...
c1ed0cbcc6bbf1f1d289814b2a07e5ecec424c31
igobarros/maratona-data-science-brasil
/exercicios/eXcript_Python/Funcoes_dos_Dicionarios.py
581
3.765625
4
dic = { 101111: 'Igor', 202222: 'Dina', 303333: 'Afonso', 404444: 'Luana' } dic2 = { 404444: 'Luana', 505555: 'Dasdores' } t = (1, 2, 3) print(dic) print(len(dic)) #del(dic[101111]) #print(dic) print(dic.keys()) # retorna as chavez do meu dicionario print(dic.values()) # retorna os valores do...
5da54515959784acf33a0c52f638bd9bb0e1af5d
igobarros/maratona-data-science-brasil
/exercicios/Curso_Udemy_Python/sec3_aula40_1.py
320
3.734375
4
from abc import ABCMeta, abstractmethod class Animal(metaclass=ABCMeta): @abstractmethod def som_animal(self): return 'som de algum outro animal' pass class Cachorro(Animal): def som_animal(self): s = super(Cachorro, self).som_animal() return '%s - %s' % (s, 'AUAU') c = Cachorro() print(c.som_animal())
e89e7582f660a2fc48668c5030fe47b637e71861
igobarros/maratona-data-science-brasil
/exercicios/Curso_em_video/aula06_1.py
231
3.9375
4
n = input('Digite uma coisa: ') print(n.isnumeric()) # saber se é número print(n.isalpha()) # saber se é letra print(n.isalnum()) # saber se é alfa numerico print(n.isupper()) # verifica se está somente com letra maiúsculas
ec3d9974e6deb4db5a19f63ed582210a41b1cec4
igobarros/maratona-data-science-brasil
/exercicios/Curso_em_video/aula010.py
191
4.15625
4
time = int(input('Digite a idade do seu carro: ')) if time <= 3: print('Seu carro é novo') elif 3 < time <= 5: print('Carro tem meia idade') else: print('Carro ja está antigo')
6583ed16d218d93d436d313bea476ef176f9126a
igobarros/maratona-data-science-brasil
/exercicios/Curso_em_video/veiculo.py
2,142
3.5625
4
class Veiculo(object): nome_veiculo = 0 def __init__(self, nome, consumo_combustivel): self.nome = nome self.consummo_combustivel = consumo_combustivel self.quantidade_combustivel = 0 def getNome(self): return self.nome def setNome(se...
37b3345b3542eb8d5fbc843ad2edec56c1c096fb
igobarros/maratona-data-science-brasil
/exercicios/Curso_Udemy_Python/sec3_aula61.py
154
3.96875
4
lista = [ i * 2 for i in range(1, 11) ] # __next__ --> devolve o próximo item # __iter__ --> é chamado na inicialização de um iterador print(lista)
f017ed14bed91b66dd7775610337825796ed4f93
igobarros/maratona-data-science-brasil
/exercicios/Curso_em_video/ex013.py
176
3.828125
4
sal = float(input('Digite o salário do funcionário R$ ')) aum = sal + (sal * 0.15) print('O salário de R$ {} com o aumento de 15% ficará com R$ {:.2f}'.format(sal, aum))
4b0f1269272279131d9a95a913933c1aaaad8601
igobarros/maratona-data-science-brasil
/exercicios/eXcript_Python/while_else.py
78
3.765625
4
x = 0 while(x < 10): print(x) x = x + 1 else: print('Bloco else')
909a3f8e4c1e592b4a92ad9e84765e8cf4dc21c5
igobarros/maratona-data-science-brasil
/exercicios/Curso_Udemy_Python/sec3_aula34.py
1,032
4
4
from math import pi as PI class Forma: def __init__(self): print('Inicialização da forma') def area(self): print('Área da forma') def perimetro(self): print('Perimetro da forma') def descricao(self): print('Descrição da forma') class Quadrado(Forma): ''' Classe da forma do Quadrado''' def __init__(s...
0524557bbe094e30026eece57faf1e43eb8c72ae
igobarros/maratona-data-science-brasil
/exercicios/Curso_Udemy_Python/sec3_aula44.py
523
3.703125
4
class Data: def __init__(self, dia, mes, ano): self.dia = dia self.mes = mes self.ano = ano print(self) @classmethod def de_string(cls, data_string): dia, mes, ano = map(int, data_string.split('-')) data = cls(dia, mes, ano) return data @staticmethod def is_date_valid(data_string): dia, mes, an...
07028c029470f5c10f3486f6649ee51e231dca7d
igobarros/maratona-data-science-brasil
/exercicios/Curso_em_video_MUNDO2_incompleto/desafio40.py
260
4
4
nota1 = float(input('Informe a primeira nota: ')) nota2 = float(input('Informe a segunda nota: ')) media = (nota1 + nota2) / 2 if media < 5.0: print('Reprovado') elif 5.0 <= media <= 6.9: print('Recuperação') elif media >= 7: print('Aprovado')
459422f419b8578ff5c7fa0341316e298bf933fb
Geeky-star/Data-Structures
/Search word with prefix using Trie.py
1,100
3.71875
4
class TrieNode: def __init__(self): self.children=[None]*26 self.isendofword=False self.count=0 class Trie: def __init__(self): self.root=self.getNode() def getNode(self): return TrieNode() def insert(self,key): crawl=self.root length = len(...
16d20f249b4d0a38f1ee84f9541c2e30dc4f9a44
Geeky-star/Data-Structures
/Maximum nodes at which level.py
1,062
3.734375
4
from collections import deque class newNode: def __init__(self,data): self.data=data self.left=None self.right=None def maxLevel(root): if root is None: return 0 q = deque() q.append(root) level = 0 maxCount = 1 while (1): l...
c1d8c35d0a1b31c5f2de1e8efc89d85f84cd115b
Geeky-star/Data-Structures
/Left diagonal traversal of tree.py
711
3.734375
4
from collections import deque class Node: def __init__(self,data): self.data = data self.left = None self.right = None def diagonalPrint(root,m,d): if not root: return try: m[d].append(root.data) except: m[d] = [root.data] diagona...
e118b929bb4440ca1389b19da12ea14f0a9a03d4
LuisVargasVic/IntroductionProgramming
/potencia.py
175
4.15625
4
def power(x,y): c=0 for c in range(y): c= c+1 a= pow(x,c) return a x = int(input("Give me the number: ")) y = int(input("Give me the power: ")) r = power(x,y) print(r)
921e60291c7c799f8cc48d443770f20fbb5a5af1
LuisVargasVic/IntroductionProgramming
/vectors.py
218
3.578125
4
def dotproduct(x,y): ab=[] for i in range(0,len(x)): ab.append(x[i]*y[i]) return sum(ab) v1=[2,4,5,6] v2=[1,2,3,4] total=dotproduct(v1,v2) print ("The dot product of this two vector is: ",total)
c58f7ad55fb459f14ee2d6535fd887063a9850f9
renato130182/app_python
/aula5.py
1,243
4.21875
4
lista = [1,3,5,7] listaAnimal = ['cachorro','gato','elefante'] print(type(lista)) print(lista) # pode conter tipos de dados diferentes print(listaAnimal[0]) for x in listaAnimal: # x assume o valor na possição da lista print(x) print(sum(lista)) print(max(lista)) print(min(lista)) print(min(listaAnimal)) # segue ...
41693c1ac1365decb8e7155e33a2e8e27244196b
oyoungsun/base-ball-game
/playing_baseball.py
2,110
3.765625
4
import random def comnumber() : number1 = random.randint(1, 9) number2 = number1 number3 = number1 while number1 == number2 : number2 = random.randint(1, 9) while number1 == number3 or number2 == number3 : number3 = random.randint(1, 9) number.append(number1) number.append(number2...
d19d6c2bf762886ac87902c6d3af3d985927f456
jvano74/leetcode
/0077-combinations_test.py
1,868
3.78125
4
from typing import List from itertools import combinations class Solution: """ Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. You may return the answer in any order. Example 1: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3]...
3040ea9f9c92e5fc00b9ae13a4ff9408d6a8ff7c
Vge0rge/language-learner-alpha
/text_extractor.py
1,920
4.03125
4
#!/usr/bin/env python ################################################################# # text_extractor.py # The TextExtractor class can extract the text from a given file # and store the result to a sqlite database. # Copyright 2015 Vasilakis Georgios # MIT License ###################################################...
381afd79aaff456d75d1e979b18198d5e2a5cf71
igortchucao/AVI_FLASK_PYTHON
/main.py
1,845
3.59375
4
'''CODIGO DE APIS COM FLASK Minha primeira versão para aprendizado de Flask 03/05/2019 Flask é um micro-framework para Python. É baseado em Jinja2, Werkzeug ''' from flask import Flask, jsonify, request app = Flask(__name__) devs = [ { 'id': 1, 'name': 'Meliodas', ...
5063db0f7b57b3796b2c71e2610eb6bf136c7d49
inuishan/Santander-Value-Prediction-Challenge
/model.py
2,101
3.5625
4
import pandas as pd from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt import torch import numpy as np import torch.nn.functional as F from torch.autograd import Variable class Net(torch.nn.Module): def __init__(self, n_feature, n_hidden, n_output): super(Net, self).__i...
624c69a4f4c5c6cfcb7da0dc7334764352f6218f
Gireendra/python2
/ud4.py
372
3.828125
4
def split_string(source,splitlist): output=[] atsplit=True for c in source: if c in splitlist: atsplit=True else: if atsplit: output.append(c) atsplit=False else: output[-1]=output[-1]+c return output out...
d5ac72a51d7d254e7f0bc06bff01d9aaa79fea8b
AniketKul/learning-python3
/counter.py
1,450
4.0625
4
''' Counter is a subclass of a dictionary where each dictionary key is a hashable object and the associated value in an integer count of that object. There are 3 ways to initialize a counter. ''' from collections import Counter c1 = Counter('anysequence') c2 = Counter({'a':1, 'c':1, 'e':3}) c3 = Counter(a=1, c=1, e=3) ...
e44f1c6cef22aedc4f5114c69f0260f2a37646a9
AniketKul/learning-python3
/ordereddictionaries.py
849
4.3125
4
''' Ordered dictionaries: they remember the insertion order. So when we iterate over them, they return values in the order they were inserted. For normal dictionary, when we test to see whether two dictionaries are equal, this equality os only based on their K and V. For ordered dictionary, when we test to see whethe...
f1e78e878656fff8dbf4898aea375ab79aa1861a
inwk6312fall2017/programming-task-final-agebrekirstos
/task_final_3_1.py
702
3.546875
4
def replace_config(): """this function replaces the ip addresses starting with 172 with 192""" #with open (filename) as f: fin = open("running-config.cfg") fout = open("running-config-new.cfg", "w+") ip_1 = '172' ip_2 = '192' for line in fin: # fout.write(line) fout.write(l...
8f2af570c9b12cd841e3d9ee0a1fe045cc5cd935
Prosper21/Text-Generation
/storewordngramcounts.py
1,897
3.859375
4
import sys import json from nltk.util import ngrams from nltk.tokenize import RegexpTokenizer from nltk.probability import FreqDist #Set up a tokenizer that captures only words #This requires that input has been preprocessed to lowercase all letters TOKENIZER = RegexpTokenizer("[a-z]+") def count_ngrams(frequencies,...
e19402f1b10bbd8ded605603665384fbc59d5d03
halfmark/KMCTEST
/KMC_Test/KMC.py
1,680
3.734375
4
import re import queue class WhooziJuicy: def _init_(self,people): self.lists=people def Entry_Rules(self): #filter by digits next to alphabet ***Elders must enter the premises first* New_sorted_List=sorted(self.lists,key=lambda x:int(re.findall(r'\d+$',x)[0])) ...
2450f415ee3afe8d61d41f78210e900bd35f8c9d
karanotsingyu/just-coding
/bayes/martin-2-2.py
3,241
3.875
4
# Learning trajectories: # Martin, O. (2016). Bayesian analysis with python. Packt Publishing Ltd. # Martin, O. (2018). Python贝叶斯分析. https://book.douban.com/subject/30165551/ # ----------------------------------- import pymc3 as pm import numpy as np import scipy.stats as stats import matplotlib.pyplot as plt import s...
9c2553feafc8613c3975fd5e629a2de6475fe26e
SonaliSihra/separator
/main.py
843
3.5
4
from tkinter import * master = Tk() master.geometry("200x200") Label(master, text="Please enter your text here: ").grid(row=0) e1 = Entry(master) e1.grid(row=0, column=1) def retrieve_input(): inputValue = e1.get() print(inputValue) Button(master, text='Quit', command=master.quit).gri...
d8f4260583e222406a086ebbf96982b31c48e141
eovallea3786/While
/loro2.py
135
4.125
4
while True: numero = input("Ingrese un dato") print(numero) if numero.isnumeric() and int(numero) % 2 != 0: break
b3cfd1cdfbb6800a2b610571b1f720fd5219b8e2
katherineggs/estructura-datos
/Search Sort/Sort.py
1,804
4.25
4
#INSERTION SORT def InsertionSort(array): for i in range(1, len(array)): key = array[i] num = i - 1 while (num >= 0) and (key < array[num]): array[num+1] = array[num] num -= 1 array[num+1] = key return array def MergeSort(array): if len(array) > 1: ...
31334d5c9663300476b19a69bf4fa8940c1f0c71
codetaku/SIPB-IAP-Python-2013
/day2/challenge_2.py
124
3.71875
4
def string_reverse(string): if len(string) < 1: return string return string_reverse(string[1:]) + string[0]
be20bafc9595e1ccb720887e0894cf54ba037641
candeira/py-multihash
/multihash/multihash.py
8,214
3.625
4
# -*- coding: utf-8 -*- """ Multihash implementation in Python Multihashes, or self-described hashes, are binary objects comprised of a hash digest pre-pended with: - a one-byte code representing the hashing function, and - a length byte describing the length of the digest. The multihash specification is at https://...
e1142432cc2123a7a554453fb5b53d1575c6e40c
sauliusAbr/BVpython2
/1-1 Practice.py
3,721
3.953125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # [ ] print 'Hello!' and remember to save notebook! print('Hello!') # In[2]: #### [ ] convert \*this\* cell from markdown to a code cell, then run it print('Run as a code cell') # In[3]: # [ ] print your name print("Saulius") # [ ] print "is using Python" prin...
f4451ce74fd1b6d16856f09f21f2eee9ae8c8f9a
jorricarter/PythonLab1
/Lab1Part2.py
523
4.125
4
#todo get input currentPhrase = input("If you provide me with words, I will convert them into a camelCase variable name.\n") #todo separate by word #found .title @stackoverflow while looking for way to make all lowercase wordList = currentPhrase.title().split() #todo all lowercase start with uppercase #found .title() t...
a6b560cf6de8774e49f51f2210ab0251b5f51064
DataLover347/neologism-axes
/programmes/MyPrawClass2_3.py
23,346
3.5625
4
## Collects data from Reddit using getComments() ## ## Cleans data files collected using cleanAllFiles() ## # chcp 65001 import praw import time import datetime import csv import os import re import collections import glob csv.field_size_limit(100000000) # deals with larger cell field sizes class Reddi...
31be0c0d33f86ef2d189b121f35470b646ef9feb
arnabi11/practice_code
/try.py
2,802
3.796875
4
# k = 5 # j = k # stars = 0 # spaces=" "#2Spaces # starImg = "* " # while k>0: # stars += 1 # whites = k-stars # line = [] # str1 = "" # for i in range (0,whites):line.append(spaces) # for i in range (0,stars):line.append(starImg) # string = "" # for i in line: # string += i # ...
3c01d63e26579ad8d324d3a4886c51e788fcb7f2
arnabi11/practice_code
/PowerofNum.py
358
4
4
#code def power(num,pow): if(pow==0): return 1 # -*- coding: latin-1 -*- if(pow==1): return num else: return(num*power(num,pow-1)) def printNumber(num): if(num==0):return printNumber(num-1) print num num = int(raw_input("Enter N: ")) exp = int(raw_input("Enter exp: ")) ...
8723738c685b505b63cb1871cf1257704d666fd6
pooobaby/games
/Tetirs/piece.py
4,075
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright By Eric in 2020 from setting import * from display import GameDisplay class Piece(object): def __init__(self, shape, screen, gamewall): self.x = 4 self.y = 0 self.shape = shape self.turn_times = 0 # 翻转了几次,决定显示的模样 ...
3dc6731eb21881fba37bf085b637cad74f651262
pooobaby/games
/Tetirs/wall.py
2,919
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright By Eric in 2020 from setting import * # 游戏区墙体类。记住落到底部的方块组成的墙,消行 class GameWall(object): def __init__(self, screen): """ 游戏开始时,游戏区20*10个格子被'-'符号填充。墙是空的 """ self.screen = screen self.area = [] line = [WALL_BLANK_LABEL] * CO...
c769e0590f6bed9ae23eb92d4acc01af8662b3bd
AdamShechter9/adventofcode2019
/day1/__init__.py
1,973
3.875
4
from functools import reduce class Day01(object): def __init__(self, read_file_fn): self.raw_data = read_file_fn('day1').split('\n') self.data = [int(x) for x in self.raw_data if len(x) > 0] @staticmethod def calculate_fuel(x): fuel = x // 3 - 2 return fuel if fuel >= 0 el...
a6a32b2b5c17c33649f33762c0e63b77a05b2511
kerrizhang/StockAPI
/project3_indicators.py
3,811
3.515625
4
''' Project #3: Jack of All Trades Name: Kerri Zhang SID: 21529066 Date: 11/16/18 ''' class TrueRange: '''If enter TR as an indicator''' def __init__(self) -> None: self.stock_data = [] def set_data(self, data: [dict]) -> None: '''Stock data to generate indicators''' self.stock_dat...
bfb77554a46c0c654560da443f9168ebca5bc6a7
sequoiap/cookiecutter-controlshw
/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/hw3/dynamics.py
3,456
3.953125
4
import numpy as np import {{cookiecutter.project_name}}.parameters as P class Dynamics: """ The dynamics of a system. The parameters for any physical system are never known exactly. Feedback systems need to be designed to be robust to this uncertainty. In the simulation we model uncertainty b...
3c74d4ea6f778897e96d0d712c4dc32c0f018cad
sequoiap/cookiecutter-controlshw
/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/hw2/plotter.py
5,721
4.09375
4
import matplotlib.pyplot as plt from matplotlib.lines import Line2D import numpy as np # Enable interactive drawing plt.ion() class DataPlotter: """ Creates a dynamic data plot window that can be updated. The number of rows and columns can be specified in the init function, but are not taken as par...
d83ae94be5394bb576d0b4dc0d8b32d0161894d7
pimbi98/Python
/Udemy/AprendeAProgramarPythonConProyectos/8Funciones/81Funciones.py
1,454
3.96875
4
def EmitirMensaje(mensaje): print(mensaje) EmitirMensaje("Hola") EmitirMensaje("Esta es mi primer Función") def suma(n1,n2): #Variables definidas dentro de la funcion, estan ENCAPSULADAS, A menos que se declare como global. global resultado resultado = n1 + n2 print(resultado) suma(3,4) print("E...
09e876eeb3b7c0a7f2311a34ec75fc1879d3e391
pimbi98/Python
/Udemy/AprendeAProgramarPythonConProyectos/10POO/106Polimorfismo.py
594
3.890625
4
class Animales(): def __init__(self, Nombre, Mensaje): self.Nombre = Nombre self.Mensaje = Mensaje def Hablar(self): print(self.Mensaje) class Perro(Animales): def Hablar(self): #Objeto Perro puede modificar la funcion Hablar y para los perros toma este Hablar y no el superi...
ecc4b063051499ff5f8c76bd89592095426d1bda
pimbi98/Python
/Udemy/AprendeAProgramarPythonConProyectos/8Funciones/86FuncionesConStrings.py
237
3.921875
4
def StrToInt(str): n = int(str) return n Numeros = [1,3,502,32,54,232] StrNumero1 = "39" StrNumero2 = "43.34" print(min(Numeros)) #Tambien son Funciones. print(max(Numeros)) print(len(Numeros)) print(StrToInt(StrNumero1))
75e1e333681c236311f926bda9b8591aa6739b4b
daianeczm/python
/aula3_elif.py
243
3.96875
4
valor = int(input("Qual a sua idade? ")) if valor < 6: print("Que coisa fofa") elif valor < 18: print("Você ainda não pode dirigir") elif valor < 60: print("Você está na melhor idade") else: print("Você é o cara")
5bf8dfc3988c9857f6acd0542b22c228a3ac4c31
daianeczm/python
/aula3_if_else.py
145
3.828125
4
valor = int(input("Qual a sua idade? ")) if valor < 18: print("Você ainda não pode dirigir") else: print("Você já pode dirigir!")
76dcbab2e14a7e4c8911eb0b28ff5ceaff1cc07a
KritiThakrar/LetsUpgrade-AI-ML
/Day 3/Assignment AIML-Day3.py
1,343
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #Question 1 A=complex(2,4) B=complex(6,12) C=A-B print("Sutraction =",C) # In[6]: #Question 2 import math a=12 rt=math.pow(a,0.25) print(rt) # In[11]: #Question 3 x=5 y=6 temp=x x=y y=temp print("The value of x is: ",temp) print("The value of y is: ",x) print("T...
9d4b944664f57d76c2c007307974ffea3cd8f082
vudt93/DesignPattern
/Builder/Car.py
153
3.5
4
from Builder.Vehicle import Vehicle class Car(Vehicle): name = "" model = "" def print(self): print(self.name + " " + self.model)
4ffe36a1e0433adf030904d824eb0a36f4e7d40c
felixtran39/computation_hist
/djweb/dj_comp_hist/contribution_counter.py
995
3.859375
4
import csv def contribution_counter(metadata="metadata.csv"): """ This function returns a list of people who have contributed metadata. It returns a list of tuples where the first element is the person and the last element is the number of contributions. The list is ordered with the person who has ...
a7628291f72ce488f6c10aec3747d200db426568
kenji132/AtCoder
/2022/10-26/ABC116-B.py
183
3.578125
4
s = int(input()) s_history = [] count = 0 while s_history.count(int(s)) == 0: s_history.append(int(s)) if s % 2 == 0: s /= 2 else: s = s*3+1 count += 1 print(count+1)
a5f5933c9fc8e325c735ebd5ef7a793b53034867
kenji132/AtCoder
/2022/10-21/ABC086-B.py
170
3.609375
4
import math A,B = map(str, input().split()) new = int(A + B) sqrt_1 = math.sqrt(new) sqrt_2 = int(math.sqrt(new)) if sqrt_1 == sqrt_2: print("Yes") else: print("No")
1e160e3974e8b5dc7b8298898f724d4353ea7cb9
kenji132/AtCoder
/2022/12-10/ABC281/B.py
307
3.734375
4
S = input() if len(S) == 8: if S[0].isalpha() and S[-1].isalpha() and not S[-2].isalpha() and not S[1].isalpha(): for s in S[1:-1]: if s.isalpha(): print('No') exit() if S[1] != '0': print('Yes') else: print('No') else: print('No') else: print('No')
d84a44585f23e7e459cffa4d5ef06d6fc7a88e69
swapnil8424/DSA-in-python
/hashtable/ispellcheck.py
1,449
3.65625
4
class hashtable: def __init__(self): self.T=[None for i in range(30)] def insert(self,x): c=list() for i in x: c.append(ord(i)) d=self.horner(c) h=d%30 temp=ListNode(x,None) if(self.T[h]==None): self.T[h]=temp else: temp.next=self.T[h] self.T[h]=temp def search(self,y): e=0 a=lis...
ce97d7955bdaca023cc6981efcbe624866bb30dd
swapnil8424/DSA-in-python
/binary tree/p1.py
2,800
3.8125
4
class TreeNode: def __init__(self,p=None,k=None,l=None,r=None): self.parent=p self.key=k self.left=l self.right=r def preorder(self): print(self.key) if self.leftChild: self.leftChild.preorder() if self.rightChild: self.rightChild.preorder() class BinSearchTree: def __init...
d3ac4f176c8bfb3de941c3660ad0a305af610a4e
APK500/python-challenge
/PyBank/main.py
1,023
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 15 14:42:30 2018 @author: Adam Knapp """ #********************************************************************* row_count = len(data) import csv import os csvpath = os.path.join('Desktop\python-challenge\PyBank', 'budget_data_1.csv') import CSV With open(...
29526dc9212fab14f621e47f28983a1b27c5ba8b
rajathack007/Assignment10
/Assignment10.py
1,669
4.09375
4
#Q.1. Create a class animal and tiger and using inheritance method to solve it. class animal: def animal_attribute(self): print("Animal") class tiger(animal): pass a=tiger() a.animal_attribute() #Q.2.What will be the output of the above code. class A: def f(self): return self.g() def g...
616c3e8f63ae4f1b46c568c117158c49d26c444f
mhoff73/Python
/ball.py
1,479
4.0625
4
import pygame #initialize all modules in pygame pygame.init() #defining colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0 , 0) BLUE = (0, 0, 255) #set width and height of the screen (x,y) size = (700, 500) #creates the screen screen = pygame.display.set_mode(size) #include an capti...
4a9591e20e48c4851e3d589ef2882ff458c09dd4
mhoff73/Python
/test.py
226
3.671875
4
from turtle import * def pentagram (side_length): pencolor("red") pendown() fillcolor("black") begin_fill() for i in range(5): forward(side_length) right(144) end_fill() pentagram(50)
06c5041209b8fb73ceb98576feea33198560934f
karl2365/leet-code-2
/decodeString.py
831
3.625
4
class Solution: def decodeString(self, s: str) -> str: stack = [] mult = 0 currStr = "" #check each character is input string for char in s: if char == '[': stack.append(currStr) stack.append(mult) ...
1efdaf11e371b2985ac38d751b9fbe702f17a9f4
poschi3/AdventOfCode2020
/day01/day01.py
655
3.84375
4
# import math def find(expenses): for expense in expenses: for expense2 in expenses: sum = expense + expense2 if sum == 2020: return expense * expense2 def find2(expenses): for expense in expenses: for expense2 in expenses: for expense3 in ex...
9c9a2a68972d593c600d705a43dd3649cf1ea18d
KishorP6/PySample
/The Weight Detection Sensor Loops.py
313
3.796875
4
max_weight = int (input()) cargo_weight = int(0) num_of_cargo = int(0) x = int(0) while cargo_weight < max_weight : x = int(input()) num_of_cargo = num_of_cargo+1 cargo_weight = cargo_weight+x x = 0 if cargo_weight == max_weight : print (num_of_cargo) else : print (num_of_cargo-1)
d51e758b43989603f02fc40214a03a970be2d4d1
KishorP6/PySample
/LC - Decission.py
1,362
4.34375
4
##Input Format : ##Input consists of 8 integers, where the first 2 integers corresponds to the fare and duration in hours through train, the next 2 integers corresponds to the fare and duration in hours though bus and the next 2 integers similarly for flight, respectively. The last 2 integers corresponds to the fare an...
7695d391567beb232be40f86547034b208d52e02
KishorP6/PySample
/cargo coordinates.py
1,145
3.5625
4
import math len_cont = int (input()) len_cargo = int (input()) total_cargo = int (input()) num_cargo_one_row = (len_cont/len_cargo) num_cargo_one_level = num_cargo_one_row*num_cargo_one_row fully_occupied_levels = int(total_cargo/num_cargo_one_level) row_coord = int(0) col_coord = int(0) print (fully_occupied_le...
d4e2204f2822269454fcdeeb08484327337bdc1a
Siddharth-Gautam0/Hackerrank-Python
/set-add.py
108
3.640625
4
N = input() set1 = set() for i in range(int(N)): name = input() set1.add(name) print(len(set1))
e360b593062e08ac24e2111a9f053760555eded0
sn-donbenjamin/bloomberg-codecon-2017
/answers/heraldic-heresy.py
1,324
3.890625
4
#Problem : Heraldic Heresy #Language : Python 3 #Compiled Using : py_compile #Version : Python 3.4.3 #Input for your program will be provided from STDIN #Print out all output from your program to STDOUT import sys def check_line(line): metal = 0 color = 0 met = '' col ...
8704907c0bcbaa48c3973ac5230255ac360379bd
kbudaj/AdventOfCode2017
/day11/script.py
949
3.609375
4
class Hex(): directions = { 'n': (0, +1, -1), 'ne': (+1, 0, -1), 'se': (+1, -1, 0), 's': (0, -1, +1), 'sw': (-1, 0, +1), 'nw': (-1, +1, 0) } def __init__(self): self.x = 0 self.y = 0 self.z = 0 self.furthest = 0 def move...
f19940a994d065235202f99af096268dcdf3cd2c
CStage/MIT-Git
/MIT/Lectures/Lecture 2.py
342
4
4
#x=15 #y=5 #z=11 #print(x,y,z) #if x<y: # if x<z: print(" x is least") # else: print ("z is least") #elif y<x: # if y<z: print("y is least") # else: print("z is least") #else: print("y is least") y=0 x=100 itersLeft=x while(itersLeft>0): y=y+x itersLeft=itersLeft-1 print("y=", y, "itersLeft= "...
91b42de2d609b5450fba8616b738f0519842ec75
CStage/MIT-Git
/MIT/Lectures/Lecture 18.py
839
3.671875
4
from pylab import * import random #plot([1,2,3,4]) #plot([5,6,7,8]) #plot([1,2,3,4], [1,4,9,16]) #First list is x-values, second list is y-values #figure() #Says: "Create a new figure" #plot([1,2,3,4], [1,4,9,16], "go") #title("Earnings") #xlabel("Days") #ylabel("Dollars") #figure() #xAxis = array([1,2,3,4]) #Applyin...
ddeadc23b291498c7873533b16bf78c945670b2c
CStage/MIT-Git
/MIT/Lectures/Lecture 8.py
1,429
4.125
4
#Search allows me to search for a key within a sorted list #s is the list and e is what we search for #i is the index, and the code basically says that while i is shorter than the the #length of the list and no answer has been given yet (whether true or false) #then it should keep looking through s to see if it can fin...
9e11800cd87f7fa6c523cf6e0f6869e2ce59fb66
jacobeskin/Moon-Travel
/kuumatka_xv.py
1,828
4.25
4
import itertools import numpy as np import matplotlib.pyplot as plot # Numerical calculation and visualisation of the change in position # and velocity of a spacecraft when it travels to the moon. Newtons # law of gravitation and second law of motion are used. Derivative is # evaluated with simple Euler method. This ...
f546092ffaaba9dc93b06d34ddb7d4d0da29981c
paulo1er/PST-Toeic
/resize.py
4,720
3.53125
4
# -*- coding: utf-8 -*- import cv2 as cv import numpy as np import math from PIL import Image, ImageStat """ This file contains functions to crop the white borders around the image """ def distaucarre(point, org=(0, 0)): return (math.pow(point[0] - org[0], 2) + math.pow(point[1] - org[1], 2)) ...
a910655b892038f8630549c02d958efc09955ee5
sobolevV/algorithms_structures
/binary_tree.py
2,237
3.78125
4
import random class Node: stack = [] def __init__(self, value=None): self.val = value self.left_node = None self.right_node = None def create_tree(self, values: list): self.val = values[0] for el in values[1:]: self.add_value(el) def add_value(sel...
da3a99a100af4a5a325437b4b86706265562d628
Sintasitinuriah/IF1314-10219008
/Konstruktor/Main.py
815
3.84375
4
class Hero: #templete jumlah = 0 #Konstruktor def __init__(self, inputName, inputHealth, inputPower, inputArmor): self.name = inputName self.health = inputHealth self.power = inputPower self.armor = inputArmor Hero.jumlah += 1 print("Membuat nama dengan " + in...
88ea763c02489584cd415f5474cb6919623d2faf
ajaypp123/python_library
/panda_sample.py
530
3.59375
4
import pandas as pd s = pd.Series(list('abcdef')) a = pd.DataFrame(list('abcdef')) #reindex and fill nan with nulll print(s.reindex(range(10),fill_value="nulll")) print('**********************************************************') d = {'US': pd.Series([1., 2., 3.], index=['a', 'b', 'c']), 'IDN': pd....
b90b0882aec9a82950865ac61b7267f80777cb04
mori-cyber/Mathematical_and_time_calculations
/time.py
2,165
3.90625
4
def second(times): t={} t['h']=int(times/3600) times=times%3600 t['m']=int(times/60) t['s']=int(times%60) return t def time(h,m,s): h=h*3600 m=m*60 r=h+m+s return r def summation(h,m,s,hh,mm,ss): h = h * 3600 m = m * 60 hh=hh*3600 mm=mm*60 ...
e050bf9dbde856f206bac59513c3a19e47e23a92
nwelsh/PythonProjects
/lesson3.py
408
4.28125
4
#Lesson 3 I am learning string formatting. String formatting in python is very similar to C. #https://www.learnpython.org/en/String_Formatting name = "Nicole" print("Hello, %s" % name) #s is string, d is digit, f is float (like c) age = 21 print("%s is %d years old" % (name, age)) data = ("Nicole", "Welsh", 21.1) f...
05865082b9f165c102b359cd9deb8a53f1e78d87
nwelsh/PythonProjects
/lesson9.py
663
4.15625
4
# lesson 9: https://www.learnpython.org/en/Dictionaries phonebook = {} phonebook["John"] = 938477566 phonebook["Jack"] = 938377264 phonebook["Jill"] = 947662781 print(phonebook) # prints: {'John': 938477566, 'Jack': 938377264, 'Jill': 947662781} phonebook2 = { "John" : 938477566, "Jack" : 938377264, "Jill...
b2c98ddab1b7bea3c4b91b969260dbe3277f0caa
patrickbeekman/twitter_data
/src/twitter_grabber.py
4,653
3.90625
4
''' twitter_grabber.py A direct way to access the twitter RESTful api to grab twitter data for further data analysis. ''' import base64 import requests import json import os import pandas as pd import numpy as np base_url = 'https://api.twitter.com/' def main(args=None): bearer_token = authorize('keys.txt') ...
cad277b1a2ca68f6a4d73edc25c2680120b88137
tanvirtin/gdrive-sync
/scripts/File.py
1,380
4.125
4
''' Class Name: File Purpose: The purpose of this class is represent data of a particular file in a file system. ''' class File: def __init__(self, name = None, directory = None, date = None, fId = None, folderId = None, extension = ""): self.__name = name self.__directory = directory self.__date = date ...
7e67945fbf2195572f880da8a9e70eaf742c486c
dmitrytharn/learning_stuff
/palindrome_search.py
918
3.984375
4
''' Looks through a text file in search of palindromes (E.g.: stats, bob, anna, etc) Prints out the number of palindromes found in a file and prints them out. 60.000 word dictionary returns ~60 palindromes.''' import sys def load(file): try: with open(file) as in_file: loaded_txt = in_file.rea...
1170ebf427b1bdbbec732b67c257093e8ea64fd4
Pablosan94/python-course
/Chapter 2. Flow Control/truefalse.py
175
4.15625
4
if 0: print("True") else: print("False") name = input("Please enter yor name: ") if name: print("Hello, {}".format(name)) else: print("Are you the man wuth no name?")
e1fdc295f3620a0a964415b355f08a73697aa2a8
sachin-pandit-usc/NLP
/Assignment1_Part2/test.py
285
3.84375
4
global result result = [] def permutation(li): if li == [] or li == None: return if len(li) == 1: result.append(li[0]) print result result.pop() return for i in range(0,len(li)): result.append(li[i]) permutation(li[:i] + li[i+1:]) result.pop()
b80200cd57d095c8fbf22ed9e1f13965baad1a1f
tutss/Projeto-MAC216
/4fase/new/apres.py
4,802
3.640625
4
# -*- coding: utf-8 -*- import pygame as pg import fileinput import sys from math import * # inicialização do sistema pg.init() # altura e largura da arena, em células H, W = 15,15 # largura da célula l = 30 # altura da célula L = 2*l/sqrt(3) # cria a janela scr = pg.display.set_mode((2*W*l+l,int(1.5*L*H+L/2))) # s...
86582f53600dbf3e2533632f93d69cd6cc3e437a
wuzhisheng/project1
/zy4.py
1,274
3.984375
4
# -*- coding: utf-8 -*- class Person(object): #定义类 class 类名(所调用,继承的类) def __init__(self, name, ages): #类的属性 self.name = name self.ages = ages def print_way(self): #类的方法 print '%s,正在走路 ' % (self.name) class Student(Person): def __init__(self,name,ages,xuehao): Person._...
f0be4e8c6a4110ef2fbd0e8545d01bcdd4895e87
helluin912/reddit_challenges
/challenge199.py
1,105
3.65625
4
#!/usr/bin/python #https://www.reddit.com/r/dailyprogrammer/comments/2tr6yn/ DIGITS = """ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| | _||_| ||_| _| """ FONT = range(10) FONT[0] = """ ._. | | |_| """.splitlines() FONT[1] = """ ... .|. .|. """.splitlines() FONT[2] = """ ._. ._| |_. """.splitlin...
976246d86d0cf2527c0bc7a1df4353615160348b
Nazaf/MIT-6.00.1
/OddTuples.py
223
3.75
4
def oddTuples(aTup): #Converting tuple to a list to loop and [0::2] will take the first element and every other odd positoned values return tuple([item for item in list(aTup[0::2])]) #converting the tuple to list
0ed99cccf15d7b70f35f1056e14b088b8b9c5f65
nishantchaudhary12/Graphs
/adjacencyListRepresentation.py
1,117
4.09375
4
#adjacency list representation of Graphs class Node: def __init__(self, val): self.node = val self.next = None class Graph: def __init__(self, vertices): self.vertices = vertices self.graph = [None] * self.vertices def addEdge(self, src, dest): new = Node(dest) ...
4d03d0c840ac5d6e8d676fb74431bf416e635926
anand-ryuzagi/Problem-solving
/Array/11. max-sum-subarray-of-length-k.py
457
3.640625
4
def maxsubarrayoflengthK(arr,k): if len(arr) < k: return False ans = 0 curr_sum = 0 for i in range(k): curr_sum += arr[i] if curr_sum > ans: ans = curr_sum for i in range(k,len(arr)): curr_sum = curr_sum+arr[i]-arr[i-k] if curr_sum > ans: ...
a0479a78c24e116b1ce8d2f75fd4c1cc06232496
ridwanrahman/datastructures
/linkedlist/CircularLinkedList/circularLinkedList.py
3,954
3.875
4
from Node import Node class CircularLinkedList: def __init__(self): self.length=0 self.data = None self.next = None def circularListLength(self): if self.length==0: raise ValueError("List is empty") currentNode = self.head if currentNode == None: ...