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
db73a48731ed073e252d56eedc05c98588ba1675
jayednahain/python-Function
/function_mix_calculation.py
386
4.15625
4
def addition(x,y): z=x+y return print("the addtion is: ",z) def substruction(x,y): z=x-y return print("the substruction is : ",z) def multiplication(x,y): z=x*y return print("the multiplication is :",z) a = int(input("enter a number one : ")) b = int(input("enter second nu...
c1d1bcd4a998a60f8f0b73df988e2984337810b5
eudys07/PythonKata
/Collections/Dictionary_implementation.py
1,744
4.125
4
#Dictionary print print 'Creating new Dictionary' print dict1 = {'name':'Eudys','lastname':'Bautista','age':31} dict2 = dict([('name','Aynel'),('lastname','Bautista'),('age',28)]) dict3 = dict(name='Eliel',lastname='Garcia',age=32) print 'dict1: ' print dict1 print 'dict2: ' print dict2 print 'dict3: ' print dict3 ...
e05b33c16addc9e6bc10a9012ea1fb45583426c4
andremarinho/aprendendopython
/desafio44.py
1,443
3.9375
4
print('='*10,' DESAFIO 44 ','='*10) preco_produto = float(input('Digite o valor do produto: ')) print('Condições de pagamentos: ') print(""" Escolha as condições de pagamento: Digite 1 para: À vista dinheiro/cheque desconto 10% Digite 2 para: À vista no cartão: 5% Digite 3 para: Em...
83f236f5a8e5d40da133d8ec627d47c1a8211a1f
andremarinho/aprendendopython
/desafio49.py
243
3.921875
4
from time import sleep print('='*10,' DESAFIO 48 ','='*10 ) numero = int(input('Escolha um numero:')) print('A tabuada do numero {} é...'.format(numero)) sleep(1) for c in range (1,10): print(' {} X {} = {}'.format(numero,c,numero * c))
37ef7ec1313b832dfecfdddf793478bed5face2e
andremarinho/aprendendopython
/desafio20.py
407
3.59375
4
from random import shuffle print('=' * 10, ' DESAFIO 20 ', '=' * 10) aluno1 = input('\033[1;31;40m Digite o nome do primeiro aluno:\033[m ') aluno2 = input('Digite o nome do segundo aluno: ') aluno3 = input('Digite o nome do terceiro aluno: ') aluno4 = input('Digite o nome do quarto aluno: ') lista = [aluno1, aluno2, ...
250198b48bab047a09c15691ad3178a0534c23e2
andremarinho/aprendendopython
/desafio58.py
783
3.8125
4
from random import randint from time import sleep print('-=-'*30) print("="*10, ' DESAFIO 58','='*10) print('-=-'*30) print(""" ESTE PROGRAMA VAI FAZER O COMPUTADOR 'PENSAR' EM UM NUMERO INTEIRO E PEDIR PARA O USUARIO ADVINHAR """) numeroComputador = randint(0,10) # Faz o computador sortear um numero print('PROCESSAN...
fda0438f818ef201302549b20b8f4d781febbc75
sraaphorst/data_structures_and_algorithms
/course_1_algorithmic_toolbox/week6_dynamic_programming2/2_partitioning_souvenirs/partition2.py
3,809
4.1875
4
#!/usr/bin/env python3 # By Sebastian Raaphorst, 2018. # # Goal: partitioning a set of values into two subsets of equal value. # This is in preparation for partition3.py, as solving this problem first will help me understand that problem # better. import unittest import itertools from random import randrange def par...
6b9e69d0884ca752998e2e57074d382f7e40486f
sraaphorst/data_structures_and_algorithms
/course_1_algorithmic_toolbox/week3_greedy_algorithms/3_maximum_advertisement_revenue/dot_product.py
655
3.5625
4
#Uses python3 import sys import unittest def max_dot_product(a, b): a = list(reversed(sorted(a))) b = list(reversed(sorted(b))) res = 0 for i in range(len(a)): res += a[i] * b[i] return res class TestDotProduct(unittest.TestCase): def test1(self): self.assertEqual(max_dot_pro...
16c288ecececc53d7a8b0204e8925826ff0c7822
JishnuRamesh/InterviewPreparationSorting
/quicksort.py
347
3.671875
4
import sys def qsort(lista): #print(sys.getrecursionlimit()) if len(lista) <= 1: return lista else: return qsort([x for x in lista[1:] if x < lista[0]]) + [lista[0]] + qsort([x for x in lista[1:] if x >= lista[0]]) lista = [2,4,1,5,-2,0,-4,3] qsorta = qsort(lis...
dfe3c9322f2ca126fba6f73ec08e37d484e5bca7
MZaid101/fmkit
/code_core/pyrotation_demo.py
48,682
4.03125
4
''' This file is part of the pyrotation python module, which is designed to help teaching and learning the math of 3D rotation. This file contains code to demo and test the core class and funcitons of 3D rotation. Author: Duo Lu <duolu.cs@gmail.com> Version: 0.1 License: GPLv3 Updated on Jan. 28, 2020, version 0.1 ...
0744bc4121694a7a1123a2705b1d83475742de0a
pranav0904/ChatBot
/Chatbot.py
1,301
3.625
4
''' Date: 11/12/2020 Project: Chatbot Author: Pranav Khiste ''' from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from datetime import datetime, date bot = ChatBot('Buddy', storage_adapter='chatterbot.storage.SQLStorageAdapter', database_uri='sqlite:///database.sqlite3') trai...
cf44391074a621add0dcf789d27f52ab83b8a18a
Emmalinda/wordcount
/wordcount.py
248
3.703125
4
def words(string): worddict={} result=string.split() for word in result: if word.isdigit(): count = result.count(word) worddict[int(word)] = word else: count = result.count(word) worddict[word] = word return result
fe64c2fa5c3bef1f654124a658826dd60098e6a5
Abijithhebbar/abijith.hebbar
/cspp1/m21/tiktaktoe.py
1,049
3.828125
4
'''program for checking various conditions in game''' def tic_tac_toe(matrix): '''function for playing Tictactoe game''' result = [] for i in range(0, 3): if matrix[i][0] == matrix[i][1] == matrix[i][2]: result.append(matrix[i][0]) for i in range(0, 3): if matrix[0][i] == mat...
edebe64f2a8f06539214fc7e2771e56a73130405
Abijithhebbar/abijith.hebbar
/cspp1/m22 exam/assignment3/tokenize.py
1,107
4.21875
4
''' Write a function to tokenize a given string and return a dictionary with the frequency of each word ''' # output_dictionary = {} def tokenize(string_input): """Tokenize function""" output_dictionary = {} new_string = '' for word in string_input: if word not in "`~!@#$%^&*()_+=.,;-\''": ...
c8be38244615b0cd1839787a5c8766acdcc951a6
zybea-world/TD
/beibao.py
634
3.5625
4
info = [ [3, 8], [2, 5], [5, 12] ] total = 5 arr=[] dict = [] max=0 def search(depth,rest): #当到了第三个人做决议的时候 #使用 if depth==3: global max, arr max_value = 0 dict = arr[:] for index,i in enumerate(dict): max_value += info[index][1]*i if max <= max_...
a78e9ad878a8325255e3533728e5fdbe6fc1cbb4
satyavank1988/Learning
/regex_group_pip.py
531
3.765625
4
import re message = 'Call me 999-052-2251 tomorrow or at 773-838-2557' message1 = 'Call me (999)-052-225 tomorrow or at 773-838-255' phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') pNR = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)') try: mo2 = pNR.search(message1) print mo2.group() except: print "non...
663548b02ff61efc4f418389866ea737f69367a6
Mewtwo76/python-starter-snake
/gameobjects.py
1,104
3.640625
4
class Pos: def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return f"x: {self.x}, y:{self.y}" class Food: def __init__(self, food): self.pos = Pos(food['x'], food['y']) class Hazard: def __init__(self, hazard): self.pos = Pos(hazard['x'], hazard['y']) class Snake: de...
09f4787b4c11fff8d250540027f507288292388f
IhorVintonyak/FORZA-4
/Forza4/all_function/function_update_v0.2/check4_diagonally_v_0.2.py
736
3.671875
4
table =[[0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [2,0,0,0,0,0,1], [0,2,0,0,0,1,0], [0,0,0,0,0,0,0], [0,0,0,2,0,0,0]] for i in range(len(table)): print(table[i]) def check4_diagonally(table:list,player:int) -> bool: for s in range(len(table)): for i in range(len(table[1])): if i <= 3 and s<=2 and t...
20965ecd6ac55dd83d54958e0fbef8353d1392bb
iibanezgordon/Python_exercises
/fibonacci.py
692
4
4
# -*- coding: utf-8 -*- """ Created on Sat May 27 17:35:13 2017 @author: iibanez """ def fibonacci(n): a=1 b=1 for i in range(1,n+1): yield a a,b = b,a+b while True: try: info = int(raw_input('Please, Introduce the length of the fibonacci series. ')) if info ...
606cbc4a1c554ff33d2382e828427fac2c3bac83
Roshni-Sahoo/LeanIn-ML-Circle
/assignment_problems/show_odd_even.py
119
4.15625
4
#Show Odd and Even limit=int(input()) for i in range(0,limit+1): if(i%2==0): print(i,"EVEN") else: print(i,"ODD")
4b657c93cd91db20449b78645f58da4bd1d68b13
raman22feb1988/Dictionary
/dictionary.py
2,603
3.5625
4
import re class Dictionary: def __init__(self): self.data = {} def add(self, word): branch = self.data for letter in (word + '\0'): if letter not in branch: branch[letter] = {} branch = branch[letter] def contains(self, word): branch =...
be7b453c3fa37a0967005d7e65e32d9cc2c74199
taprati/Rosalind
/Algorithmic_Heights/slow_counting_inversions.py
429
3.65625
4
# # Counting Inversions # def inversions(arr,n): inv = 0 for i in range(n): for j in range(i+1, n): if arr[i] > arr[j]: inv += 1 return inv # Input Data file = open("Data/rosalind_inv.txt","r") n = int(file.readline().strip('\n')) array = [int(i) for i in file.readli...
3d328bd09c6d42f26a0cff68bdc81d3fd7768003
taprati/Rosalind
/Algorithmic_Heights/binary_search.py
774
3.6875
4
# # Binary Search # # def binary_search(l,k,start,end): if start > end: return -1 mid = (start + end) // 2 if k == l[mid]: return mid + 1 elif k > l[mid]: return binary_search(A,k,mid+1,end) elif k < l[mid]: return binary_search(A,k,start,mid-1) # Open file and...
d406c489d63dba9cf8c6fa2adc550bcca457956c
Nurgazy24/task21_Punct
/task21Punct.py
501
3.921875
4
import re def remove_punctuation(pattern,phrase): for pat in pattern: return(re.findall(pat,phrase)) return('\n') phrase = """ - Встать! Суд идет! - Да здравствует наш суд, самый гуманный суд в мире! - Прошу садиться. Садитесь, садитесь - Спасибо, я постою. ...
c46eff7531be9a8718f3745b09d31056a7ef063d
chazr88/python-blackjack
/main.py
3,710
4.21875
4
import random import itertools #Itertools is used to multiply the 1st element of the first array with every element of the 2nd array. #EX ('A', 'Spade'), ('A', 'Club'), ('A', 'Diamond'), ('A', 'Heart') cardDeck = list(itertools.product(["A","2","3","4","5","6","7","8","9","10","J","Q","K"],["Spade", "Club", "Diamond...
644e96b5de53eeab536d56631c6bb6244249ac1c
maximematerno/Sprint-Challenge--Data-Structures-Python
/names/dll_queue.py
1,163
3.515625
4
import sys sys.path.append('../doubly_linked_list') from doubly_linked_list import DoublyLinkedList # a quene is first in first out(FIFO) # ie if theres a line of people waiting for something, the new person # enters at the back of the line, and doesnt get served until the # people ahead of him have gott...
b0ae010fc564a7b55df97e546ec4c281f51ef276
abhishek-vaish/uber-lyft-price-prediction
/model/data_manipulation.py
2,590
3.8125
4
import pandas as pd import numpy as np from sklearn.preprocessing import OneHotEncoder from sklearn.compose import ColumnTransformer def data_manipulation(data_set): """ Prepare the dataset for training the regression model. This function takes the csv file location as a parameter Parameters...
831f0c5f6fd0d17a9e6dc145ec9c570847842beb
grigkatrin/cs102
/exam/case1.py
5,036
3.8125
4
from typing import List, Tuple, Optional, Dict, Any def shape(maze: List): """ Функция возвращает размер лабиринта :param: maze: Лабиринт :return: Число строк, число столбцов """ assert maze, "maze can't be empty" return len(maze), len(maze[0]) def neighbours(maze: List, pos: Tuple) -> ...
9d604e2445e55bcff06bfb746fcd0b891af83a47
sanket8088-dot/faulty-calculator
/calculator.py
872
4.0625
4
# Exercise 2 - Faulty Calculator # 45 * 3 = 555, 56+9 = 77, 56/6 = 4 # Design a calculator which will correctly solve all the problems except # the following ones: # 45 * 3 = 555, 56+9 = 77, 56/6 = 4 # Your program should take operator and the two numbers as input from the user # and then return the result pr...
f9a93565a2f52e46ff91a6103b45860506fedb7a
kato1999/Link_Share
/python 練習/Atcoder/python分類/第1章/13_abc70A.py
355
3.84375
4
if __name__ == "__main__": a,b,c = input() print("Yes" if a==c else "No") #別解 # n= input() # print("Yes" if n[0]==n[2] else "No") #自分 # N = input() # if N[0] == N[2]: # print("yes") # else: # print("No") ''' リンク → https://atcoder.jp/contests/abc070/tasks/a...
b96c6468fb1fd35a48bd349fa3e40fea03630c22
kato1999/Link_Share
/python 練習/Atcoder/python厳選/1_abc86a.py
295
3.578125
4
if __name__ == "__main__": a, b = map(int, input().split()) print("Even" if a * b % 2 == 0 else "Odd") #自分 # a,b = map(int, input().split()) # print("Even" if a*b % 2 == 0 else "Odd") ''' リンク → https://atcoder.jp/contests/abs/tasks/abc086_a '''
bdb64347015b596f8149583ed7a629b45cbc7bfc
tracetidwell/triathlon
/race_predictor/bike_calcs.py
3,592
3.515625
4
import numpy as np import pandas as pd import math def bike_data(bike_course): #Function to calculate time to complete bike course based on average power #read the text file data = pd.read_csv(bike_course, header=None) data = data[:][0] #create a dataframe to store calculated values columns...
253cce492c2866f82e15e4c49c987c7668f6c057
vizance/Python_Data_Analysis
/第二章_CSV檔案處理/7csv_reader_column_by_name.py
1,114
3.8125
4
# -*- coding: utf-8 -*- #!/usr/bin/env python3 #使用特定欄位名稱-尋找特定欄位 #此範例要找"Invoice Number","Purchase Date" """ Created on Thu Sep 21 09:51:09 2017 @author: vizance """ import csv import sys input_file = sys.argv[1] output_file = sys.argv[2] my_columns = ['Invoice Number','Purchase Date'] my_columns_index = []#用來儲存搜尋欄位的ind...
c1155b2f24c5ec2a27046420bac05e1e8b6641de
vizance/Python_Data_Analysis
/第二章_CSV檔案處理/6csv_reader_column_by_index.py
866
3.625
4
# -*- coding: utf-8 -*- #!usr/bin/env python3 #選擇特定欄位-使用欄位index(如果欄位資訊不會太複雜/欄位資訊不會變動/所有資料欄位資訊都相同) #範例想保留Supplier與Cost """ Created on Wed Sep 20 15:07:45 2017 @author: vizance """ import csv import sys input_file = sys.argv[1] output_file = sys.argv[2] my_columns = [0,3]#要保留第0行與第3行 with open(input_file, 'r', newline=''...
f127c32743f453e034ee5944e32d136e225728ee
vizance/Python_Data_Analysis
/第三章_Excel檔案處理/pandas_value_matches_pattern.py
663
3.796875
4
# -*- coding: utf-8 -*- #!/usr/bin/env python3 #(pandas)篩選特定資料列-特定文字組合的值(範例:找J開頭的顧客) #正規表示可參考:https://goo.gl/Ngufha """ Created on Tue Oct 3 10:08:48 2017 @author: vizance """ import pandas as pd import sys input_file = sys.argv[1] output_file = sys.argv[2] data_frame = pd.read_excel(input_file, 'january_2013',index_...
4874c21e77392bc80509e3585c0a36f95b17394c
Mortr0n/userAssignment
/user.py
1,779
3.8125
4
class User: def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 0 def make_deposit(self, amount): self.account_balance += amount def make_withdrawal(self, amount): self.account_balance -= amount...
2a90bd5f2d87c0569f899cf301e69456c3b20aae
Yuma1/1
/chapter8/greeter.py
2,215
4
4
def greet_user(): """Display a simple greeting.""" print("Hello!") def greet_user2(username): """Display a simple greeting.""" print("Hello, " + username) def get_formatted_name(first_name, last_name, middle_name=''): """Return a fullname, neatly formatted.""" if middle_name: full_name = first_name...
6240459ea8e19d0fbcec288cc406caef2b5f984d
sinaesmaili216/hw7_maktab
/tamrin7.2.py
215
3.96875
4
import re def capital_space(word): words = re.findall(r'[A-Z][^A-Z]*', word) res = '' for word in words: res += word + ' ' return res print(capital_space('TheFirstProgrammingBootcamp'))
14b9a9f2ffef52f45884d4f32e340776479516c9
PythonBuffalo/Profile-Dis-PDB
/pdb/set_trace.py
306
3.953125
4
def recursive(n): if n <= 0: return 0 if n % 2: return n + recursive(n - 2) else: return n + recursive(n - 1) # we expect 11, but get 9... something is wrong here # use pdb.set_trace() to add a breakpoint and start up pdb import pdb pdb.set_trace() print recursive(5)
7a3c29e08029bdbfd42dbda0b6cc6c22144d01c8
Nate-17/LetsUpgrade-Python
/primenumber.py
444
4.28125
4
''' This is a module to check weather the given number is even or odd.'' ''' def prime(num): ''' This is the main function which check out the given number is even or odd. ''' if num > 1: for i in range(2, num): if (num % i) == 0: break return p...
44a26fe7a8c42d5ab7be994e2cc060e506001e90
tpereira131/solyd_python
/exercicio_aula7.py
407
3.953125
4
''' EXERCICIO: Escreva uma funcao que recebe um objeto de coleção e retorna o valor do maior numero dentro dessa colecao faça outra função que retorna o menor numero dessa coleção ''' lista = [] def retorna_maior(lista): maior = max(lista) return print(maior) def retorna_menor(lista): menor = min(lista) ret...
7b1cb8e3c82cb6a1f4237fde891a1b77d8927cb7
ghcookied/python-code-for-Microsoft-DAT210x-Programming-with-Python-for-Data-Science
/visualisation/several_scatters.py
1,417
3.8125
4
import pandas as pd import matplotlib.pyplot as plt import matplotlib import os # Look pretty... matplotlib.style.use('ggplot') # # TODO: Load up the Seeds Dataset into a Dataframe # It's located at 'Datasets/wheat.data' # # .. your code here .. os.getcwd() os.chdir('C:/Users/David/Documents/Technology/Python/edX/...
bf801d5b19f08a5a1c1368a58c3d70a01e5c1aad
YauheniRusinchuk/algorithms-in-python
/bubble_sort.py
263
3.6875
4
def bubble_sort(A): '''Сортировка пузырьком''' N = len(A) for bypass in range(1,N): for k in range(0,N-bypass): if A[k] > A[k+1]: A[k], A[k+1] = A[k+1], A[k] if __name__ == '__main__': pass
e3cb636fe2d67bb7c3c815c00e5b1c959b1424a1
vrundha/sudoku
/gym_sudoku/envs/sudoku.py
1,897
3.71875
4
import random import copy from typing import Any, Union import numpy as np class Sudoku: def __init__(self): self.puzzle = np.zeros((9, 9), dtype=int) def generate(self, n=10): """ Generates a sudoku puzzle :param n: number of cells in the puzzle that has to be filled "...
66ff889ab7a5e4d283cc83b06e9aceb6b4f5933a
OndrejHudecek/PythonAcademy
/Exercises/Task034_MinMax.py
615
3.640625
4
# Tvým úkolem je vytvořit dvě funkce: # Funkce my_min(), která imituje built-in funkci min(). # Funkce by měla přijmout jakoukoli sekvenci a vrátit položku s nejmenší hodnotou. seq = [43,45,87,21,23] def main(sequence): my_max(seq) my_min(seq) def my_min(sequence): minimum = seq[0] for num in seq[1...
d7336f2fbdf1333c433f8197fb4824238551b8b2
OndrejHudecek/PythonAcademy
/Lesson008/hangman.py
2,063
3.65625
4
"""Lekce #8 - Uvod do programovani, obesenec""" import random # I. KROK # Hlavni funkce + vymyslet postup def hlavni(): hrac = pridej_hrace() hadane_slovo = vyber_slovo() tajne_slovo, zbyvajici_tahy = schovej_slovo(hadane_slovo) while zbyvajici_tahy: zbyvajici_tahy = herni_kolo( hra...
139a00a6ec8110b3632b6d55c239356f1e1f0735
OndrejHudecek/PythonAcademy
/Exercises/Task031_VowelsConsonants.py
1,143
3.6875
4
# Napiš skript, který spočítá kolik samohlásek a souhlásek obsahuje následující string s anglickou větou: sentence = 'A speech sound that is produced by comparatively open configuration of the vocal tract.' vowels = 'aeiouy' counts = {'cons' : 0, 'vows' : 0} for char in sentence: if not char.isalpha(): c...
ec2b1825ed8859e97149f5b328e55e9fc393fcc6
rizkhita/tes_kli
/1.py
489
3.78125
4
# 1. Buat sebuah fungsi untuk mengubah kalimat berikut menjadi kalimat yang mudah terbaca: # italem irad irigayaj # iadab itsap ulalreb # nalub kusutret gnalali def reverse_sentence(s): words = '' for i in s: words = i + words # appending chars in reverse order words = words.split() ...
ec8199237ecdee055d66e8e831951e9e0dc3d00a
robertvandeneynde/parascolaire-students
/-Alexandre_/untitled-2.py
228
3.640625
4
# il affiche le nombre le plus grand de la liste liste = [1,2,7,2] if liste[0] > liste[1]: m = liste[0] elif liste[1] > liste[0]: m = liste[1] if m < liste[2]: m =liste[2] if m < liste[3]: m = liste[3]
11f32b04f8e425ddae692e28af93549fc99cda3e
robertvandeneynde/parascolaire-students
/matteo/exo3.py
118
3.515625
4
a = 1 b = 1 c = 0 if b > a: if a > c: print(c,a,b) else: print(a,c,b) else: ...
5dd579ae8acc767c3ce0486c6a8f9f6b6003b9da
robertvandeneynde/parascolaire-students
/antoine collon/janvier/test.py
273
3.859375
4
a = 2 b = 8 c = a+b if c == 10: print("hello") a=1 b=2 print("a,b") a=15 b=3 c=6 d=a+b+c if d==24: print("belgium") a=3 b=2 if a < b: print("1") else: b < a print("2") a=6 b=7 c=8 d=a+b+c if d==21: print("byebye")
0a10a00e45f796caeb29816f6318889717f7e1c4
robertvandeneynde/parascolaire-students
/MARIE C/MARIE A.py
214
3.75
4
a = 25 b = 60 c = 100 if c < a < b: print(c,a,b) if c < b < a: print(c,b,a) if a < b < c: print(a,b,c) if b < a < c: print(b,a,c) if a < c < b: print(a,c,b) if b < c < a: print(b,c,a)
6c4f4071b2aced241e8fe3101fa82f543f2d1dfe
robertvandeneynde/parascolaire-students
/jessica/exercice 4.py
274
3.609375
4
# exercice 4 a = 3 b = 3 c = 1 if a == 1 or a == 2 or a == 4 and a != b and a != c: if b == 1 or b == 2 or b == 4 and b != a and b != c: if c == 1 or c == 2 or c == 4 and c != a and c != b: print ("oui") else: print ("non")
9ae68cbc0c1b1ce8e82b21c6563e8b62063c467b
robertvandeneynde/parascolaire-students
/Nico W/snake nico lulu.py
16,294
4.09375
4
#!coding: utf-8 from __future__ import print_function, division ###################### # Base CINQ : Objets # ###################### # un objet permet de grouper plusieurs variables dans un... objet # par exemple on peut grouper la "vie" et le "mana" dans un objet "personnage" # D'abord on définit la cla...
137c8a7e5c3eb8b181f20b4805d57a6fedcef7b7
gtc666/2013-Summer
/Framework code.py
3,140
4.1875
4
class Technology(object): def __init__(self, label, color = "red"): """Each technology should be constructed with a text label and a color for display purposes""" pass class User(object): def __lt__(self, other): """this is a built in comparison function, so ...
1ec8ed0d05bd4cdbf41e49a9748118334eb22de6
xnbya/pythonstuff
/python/insertsort.py
1,028
3.796875
4
lstL1 = ['church','champagne','chat','chutzpah','chop','challenge','chocolate','chunder','chips','champion','chaffinch','chainsaw','cholangiogram','churlish','chortle'] #lstL1 = [5,4,6,2] print('insert sort') print(lstL1) #counters #intSwaps = 0 #intCompa = 0 from datetime import datetime tstart = datetime.now() #curr...
573f437a4122f74be1da6d4253897c29955ef427
xnbya/pythonstuff
/python/recursion2.py
108
3.59375
4
def sumofint(n): if(n==0): return n else: return n + sumofint(n-1) print(sumofint(int(input('n:'))))
b80b195b2bf2148356af3e7b66ab07c38114935d
xnbya/pythonstuff
/python/maths chal/task 3 dict.py
4,358
3.875
4
import random, os, pickle, math characters = {} weapons = {'Machine Gun':10,'Lightsaber':43, 'Snake':9, ' #check to see if there is an existing file, if there is ask the user if they want to open it if(os.path.exists('charactersdict')): openfile = input("Do you want to open the existing characters file? (y/n) [y...
5079501cfd45e00c1d215396f5085b979ed70f8b
aiizadku/balanced_parantheses
/parantheses.py
1,024
3.890625
4
def balance(string): right_stack = [] left_stack = [] for i, element in enumerate(string): if element == "(": left_stack.append(i) elif element == ")": if left_stack: left_stack.pop() else: right_stack.append(i) combined...
3e2029475bed147045fcebebb0647c51ce9c3b85
helios-earth/helios-sdk-python
/helios/utilities/logging_utils.py
846
3.53125
4
"""Utility functions for logging.""" import functools import logging.config from timeit import default_timer as timer logger = logging.getLogger(__name__) def log_entrance_exit(func): """ Decorator to log the entrance and exit of method calls. Args: func: The function to be wrapped. Returns...
481c5bf7331c477e037b13df745ebd49dfeed605
Zeranium/PythonWorks
/Ch06/p157.py
371
4.21875
4
""" 날짜 : 2021/02/25 이름 : 장한결 내용 : 교재 p157 - self 명령어 예 """ class multiply3: def data(self, x, y): self.x = x self.y = y def mul(self): result = self.x * self.y self.display(result) def display(self, result): print('곱셈 = %d' % (result)) obj = multiply3() obj.data(...
ed18364428b1df1b8a37229afa50c2bee0190816
Zeranium/PythonWorks
/Ch02/p.40.py
784
3.8125
4
""" 날짜 : 2021/02/18 이름 : 장한결 내용 : 교재 p40 - 관계연산자, 논리연산자 """ num1, num2 = 100, 20 # (1) 동등비교 bool_result = num1 == num2 print(bool_result) bool_result = num1 != num2 print(bool_result) # (2) 크기비교 bool_result = num1 > num2 print(bool_result) bool_result = num1 >= num2 print(bool_result) bool_result = num1 < num2 print...
141fd75259033a5825bf1ebeaa99cba6d406e108
Zeranium/PythonWorks
/Ch04/p.99.py
388
3.96875
4
""" 날짜 : 2021/02/21 이름 : 장한결 내용 : 교재 p99 - 딕트 객체 예 """ dic = dict(key1 = 100, key2 = 200, key3 = 300) print(dic) person = {"name" : "홍길동", "age" : 35, "address" : "서울시"} print(person) print(person["name"]) print(type(dic), type(person)) person["age"] = 45 print(person) del person["address"] print(person) person["p...
ecba6e981e5b12bfd489559d955652c10707a01d
Zeranium/PythonWorks
/Ch03/p.68.py
348
3.75
4
""" 날짜 : 2021/02/18 이름 : 장한결 내용 : 교재 p68 - random 관련 함수 2 예 """ import random r = random.random() names = ["홍길동", "이순신", "유관순"] print(names) print(names[2]) if "유관순" in names : print("유관순 있음") else : print("유관순 없음") idx = random.randint(0, 2) print(names[idx])
f0a9486b4b4aef30982e9304c6c70f550fd62ff4
Zeranium/PythonWorks
/Ch02/p.37.py
275
3.8125
4
""" 날짜 : 2021/02/18 이름 : 장한결 내용 : 교재 p37 - 변수와 자료형 예 """ var1 = "Hello Python" print(var1) print(type(var1)) var2 = 100 print(var2) print(type(var2)) var3 = 150.25 print(var3) print(type(var3)) var4 = True print(var4) print(type(var4))
438bb05f46492f5ae269cbec7743a395a1f19812
Zeranium/PythonWorks
/Ch03/p.74.py
260
3.640625
4
""" 날짜 : 2021/02/21 이름 : 장한결 내용 : 교재 p74 - 구구단 예 """ """ --- 2단 --- """ print("★구구단(2~9단)★") for i in range(2, 10) : print("---%d단---" % i) for a in range(1, 10) : print("%d * %d =" % (i, a), i*a)
a3b9b5c12d4d29592f345d7ed6a953b3f5cdab9a
Zeranium/PythonWorks
/Ch08/8_1_Exception.py
1,756
3.78125
4
""" 날짜 : 2021/02/24 이름 : 장한결 내용 : 파이썬 예외처리 실습하기 교재 p.212 """ # try ~ except if __name__ == '__main__': num1, num2 = 1, 0 r1 = r2 = r3 = r4 = 0 try: r1 = num1 + num2 r2 = num1 - num2 r3 = num1 * num2 r4 = num1 / num2 except: print('예외 발생...') print('r1 :', r...
abce4d982fb124630c958cc95b64223db0406c36
Zeranium/PythonWorks
/Ch09/9_6_Weather.py
1,966
3.5625
4
""" 날짜 : 2021/03/09 이름 : 장한결 내용 : 파이썬 셀레늄을 활용한 날씨 크롤링 실습 """ from selenium import webdriver import pymysql # 가상브라우저 실행 browser = webdriver.Chrome('./chromedriver.exe') browser.get('https://www.weather.go.kr/w/obs-climate/land/city-obs.do') trs = browser.find_elements_by_css_selector('#weather_table > tbody > tr') #...
85e24ab986ef4b93a01c89ae59f58fbb69af9483
Zeranium/PythonWorks
/Test/test4.py
353
3.5625
4
""" 날짜 : 2021/03/11 이름 : 장한결 내용 : 파이썬 연습문제 5.리스트 선택정렬 """ nums = [4, 2, 1, 5, 3] for i in range(4): for j in range(i+1, 5): if nums[i] > nums[j]: temp = nums[j] nums[j] = nums[i] nums[i] = temp # 정렬 후 출력 for n in nums: print(n, end = ', ')
a2bf3ecc57e4538b1a8849162c3218dfa5295927
Zeranium/PythonWorks
/Ch02/p.41.py
469
3.625
4
""" 날짜 : 2021/02/18 이름 : 장한결 내용 : 교재 p41 - 대입연산자 """ # (1) 변수에 값 할당(=) i = tot = 10 # i - 10; tot = 10 i += 1 tot += i print(i, tot) # 같은 줄에 중복 출력 print("출력1", end=", ") print("출력2") v1, v2 = 100, 200 # (2) 변수 교체 v2, v1 = v1, v2 print(v1, v2) # (3) 패킹(packing) 할당 lst = [1, 2, 3, 4, 5, 6] first, second, *third = lst...
e3e740e9ac942c101107c9d3c8f65d99d3ab647e
krismadden/myphone_working
/t9.py
2,775
3.90625
4
#!/usr/bin/python letter = "" message = "" print "Enter message.\n- Press 2-9 for letters.\n- Enter 0 for spaces and punctuation.\n- Press enter after each character.\n- Enter 01 as the last character to send." while True: letter = raw_input("Message = " + message + "\n") if letter == "2": message =...
686c1f0c8ebec7caade9bd99e8c45b5581e421e1
SweetLejo/DATA110
/past_exercises_leo/yig012_t2.py
1,562
4.28125
4
#Oppgave 1 from math import pi #imports pi from the math library, since its the only thing I'll use in this exercise it felt redundant to import the whole library radius = float(input('Radius: ')) #promts the user to enter a radius area = round((radius**2)*pi, 3) #defines a variable as the area, and rounds it to 3...
3abad3723738cb0333dae2b8c175a2c45457495c
wonderme88/python-projects
/tuple+list.py
134
3.703125
4
tup1 = (10, 20, 30, [1,2,3,4]) print tup1 #Modifyj the list inside the tuple. tup1[3].append(5) print tup1 #tup1[0]=100 ===> error
fac04373d57b33f9dd8298e01aaf36f0ebb3fb75
wonderme88/python-projects
/src/revstring.py
285
4.40625
4
# This program is to reverse the string def revStr(value): return value[::-1] str1 = "my name is chanchal" str2 = "birender" str3 = "chanchal" #print revStr(str1) list = [] list.append(str1) list.append(str2) list.append(str3) print (list) for x in list: print revStr(x)
e10a0af7adca68109ebeb211ad994b2877c5a52d
EugenieFontugne/my-first-blog
/test/python_intro.py
835
4.125
4
volume = 18 if volume < 20: print("It's kinda quiet.") elif 20 <= volume < 40: print("It's nice for background music") elif 40 <= volume < 60: print("Perfect, I can hear all the details") elif 60 <= volume < 80: print("Nice for parties") elif 80 <= volume < 100: print("A bit loud!") else: print("My hears are hurt...
cb730be36e0eca7dbe198e929780714322155fce
tlennen/hackerrank-practice
/Python Practice/python_lists.py
675
4
4
if __name__ == '__main__': my_list = []; #https://www.hackerrank.com/challenges/python-lists/problem N = int(input()) for x in range(0,N): values = input().split() if values[0]=="print": print(my_list) elif values[0]=="insert": my_list.insert(int(values[1]...
973888002fc4caeecb3a4bfddd39270d11014e8f
tlennen/hackerrank-practice
/Python Practice/error_handling.py
512
3.8125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT #https://www.hackerrank.com/challenges/exceptions/problem n = int(input()) for x in range(0,n): x=input().split() try: x[0] = int(x[0]) x[1] = int(x[1]) print(int(x[0]/x[1])) except ZeroDivisionError as e: ...
363b11a3d57f4163849fb6a33aa2fba08ab38892
unburied/Sprint-Challenge--Data-Structures-Python
/ring_buffer/ring_buffer.py
986
3.75
4
class RingBuffer: def __init__(self, capacity): # initialize variable with passed in data self.capacity = capacity # create an empty data structure to store data self.buffer = [] # create a queue to store index location of where data should be appended self.queue...
edbc7fb42c093fb78b2a9208275fee68e760e7d0
Rosencrantz/learnPython
/ex4.py
1,228
3.640625
4
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capactiy = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print "There are", cars, "cars available." print "There are only", drivers, "drivers available." prin...
3eb6198afa9481a86e43c80b29b1156c64108dc0
JI007/birthdays
/birthday search.py
2,316
4.3125
4
def birthday(): birthdays = {'Jan': ' ','Feb': ' ', 'Mar': ' ', 'Apr': ' ', 'May': 'Tiana (10), Tajmara (11) ', 'June': ' ', 'July': 'Jamal (7)', 'Aug': 'Richard (7) ', 'Sept': 'Nazira (16) ', 'Oct': ' ', 'Nov': ' ', 'Dec': ' '} birthday() # Welcomes the user to the program print("\n\n\t\tWelcome to th...
6d75e4824f163c52a0ddd62d308750ee12a60ac0
lvmodan/LPTHW
/ex42hasaisaEn.py
2,397
4.1875
4
#!/usr/bin/env python # coding=utf-8 # Animal is-a object class Animal(object): pass # dog is-a Animal class Dog(Animal): def __init__(self, name): self.name = name def bark(): print 'WANG~' * 3 def wave_tail(): print 'wave its tail happily' # cat is-a Animal class Cat(Animal)...
1b692fa53fdb6971ea7070de9cee5e145f6dbfe9
lvmodan/LPTHW
/composition/ex44ecomposition.py
574
3.734375
4
#!/usr/bin/env python # coding=utf-8 class other(object): def implicity(self): print 'other implicity' def override(self): print 'other override' def alter(self): print 'other alter' class person(object): def __init__(self): self.comp = other() def implicity(self)...
b1f664f7e369618ba3f52e49ea47472679e74ed1
dhruvil14/Python_Graphics
/spiral2.py
309
3.625
4
from turtle import * speed(0) shape("circle") shapesize(0) pensize(2) bgcolor("black") colors=["red","green","blue","yellow"] for j in range(100): #color(colors[j%4]) #forward(j) left(85) for i in range(3): color(colors[j%4]) forward(j) left(85) exitonclick()
ee6ae3789811b5fa4414a86b23b40d38b3151651
data-engineering-lon-1/BrIW-v1.0
/main/src/models/persistence/csv_parser.py
582
3.71875
4
def csv_parser(csv_file): with open(csv_file, "r") as r: for l in r: for idx, c in enumerate(l): if c == '"': if idx % 2 == 0: print("Even") else: print("Odd") def csv_parser2(csv_file): ...
a4fbd9503f9f7910d4012d23de9b2f0064aeb232
MoritzThomasHuebner/PythonMeeting
/EffectivePython/Chapter01/helper_functions.py
539
3.578125
4
my_values = {'red': ['5'], 'green': [''], 'blue': ['0']} red = int(my_values.get('red', [''])[0] or 0) print(red) red = my_values.get('red', ['']) red = int(red[0]) if red[0] else 0 print(red) green = my_values.get('green', ['']) if green[0]: green = int(green[0]) else: green = 0 print(green) def get_first...
fa41fbd340e8e22e31f2e91d041e9e03fea24d78
Hemant-1821/codevitaSolutions
/2014/CompilerDesign.py
1,750
3.578125
4
for _ in range(int(input())): string = input().strip() #print(string) stack = [] flag = True main,user = False,True count = 0 if string[0] == '{': #print(string[0]) stack.append('{') stack.append('S') else: flag = False for i in range(1,len(string)): ...
b85fbb716f5ce0a46785f21307deed672e3c11c2
Hemant-1821/codevitaSolutions
/2016/LogicPyramid.py
662
3.625
4
def element(count): first = 6 second = 28 if count == 1: return first elif count == 2: return second else: count = count-2 for h in range(0,count): next_ele = (second*2)-first+16 first = second second = next_ele return next_ele ...
682f1f19b39975a30ff5c4219de3807c1a7f9abc
akhilbansal/goodtime
/aa.py
1,544
3.796875
4
import datetime from datetime import date one_date = datetime.timedelta(days=1) bday = date(2018, 3, 31) dates = ['2017-12-25', '2018-01-01', '2018-01-15', '2018-02-19', '2016-03-31'] def convert_to_date(): lst = []; for x in dates: tempdt = datetime.datetime.strptime(x, '%Y-%m-%d').date() ls...
49d662db03d842f02c5fb9081fe4b4b7f9184966
conor-mcavoy/bssim
/comp.py
9,859
3.546875
4
import copy import matplotlib.pyplot as plt import math import random import grid import ship class Computer: def __init__(self): self.grid = grid.Grid() self.generate_ships() self.occupied = self.grid.occupied_squares() self.shots_taken = set() self.shots_sent =...
17d599492819d97489203b7dc6260fc5478afab3
hackerearthclub/LetUsCode
/Linkedlist/LinkedList.py
1,466
3.828125
4
class Node: def __init__(self, start, end, hole, processID): self.next = None self.start = start self.end = end self.hole = hole self.processID = processID class LinkedList: def __init__(self): self.head = None self.numnodes = 0 def insertFirst(sel...
df97a2008ef5f6576c0d100699bef3a4ce706400
Shamita29/266581dailypractice
/set/minmax.py
455
4.21875
4
#program to find minimum and maximum value in set def Maximum(sets): return max(sets) def Minimum(sets): return min(sets) """ setlist=set([2,3,5,6,8,28]) print(setlist) print("Max in set is: ",Maximum(setlist)) print("Min in set is: ",Minimum(setlist)) """ print("Enter elements to be added in set") sets = set(map...
7496ed2b48c81f5dcd147b0b9572896de3c7ae43
pory42/2020-Python-code
/ch04/11.py
672
3.703125
4
menu = '''버거, 콤보 번호로 주문하세요! 0. 주문 종료 1. 올인원팩 2. 투게더팩 3. 트리오팩 4. 패밀리팩 >>''' more = True while more: order = int(input(menu )) if order == 1: print ( '%s 주문' % '올인원팩') elif order == 2: print( '%S 주문' % '투게더팩') elif order == 3: print( '%s 주문' % '트리오팩') elif orde...
27acc0b257c22e8cfacc9ce78b6a8040eaddb64f
awesoritc/test
/deep-learning-from-scratch/Test.py
526
3.546875
4
import numpy as np import matplotlib.pylab as plt A = np.array([[1,2,3],[4,3,2]]) B = np.array([[9,8],[7,6],[5,4]]) C = np.array([[2,9],[8,3]]) print(A) print(B) # print(np.ndim(A)) # print(A.shape) print(np.dot(A, B)) print(np.dot(C, C)) """ def step_function(x): return np.array(x > 0, dtype=np.int) def sig...
8075de6255e4840f65a48f6331c37f9e529b6f37
jhourque/Alexa-Smartbus
/lambda/bus.py
3,300
3.65625
4
import json import urllib2 import requests class Bus: # Definition of bus class for smartbus """Bus class is defined by: - type (= bus, API could also be used for rers, metros, bus, tramways, noctiliens) - code (line number) - station (Slug of the station) - stations (list of all station deserved b...
b1acb4d50b48d5eda91a9e287055b65d545c0d92
zhpixel517/Python-Pickling
/pickle-dump.py
247
3.6875
4
import pickle # Pickling is a way to restore lost data from variables and such from files answer = input("Enter something: ") # Loads inputed data to a file called 'pickle-data' f = open('pickle-data' , 'wb') pickle.dump(answer , f) f.close()
11799ffe3db15d39de98de6aa76ac8d10abd7840
ChyiYaqing/PythonPrj
/TensorFlow/tensorflow_demo1/board.py
3,733
3.921875
4
# Import MNIST data import input_data # 1. Downloads Dateset mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) import tensorflow as tf # 2.Splits it into Training + Testing Data # Set parameters learning_rate = 0.01 # which define how fast we want to update our weights if the leanring rate is too big our ...
8ca2ea1de6c297cfc06513a07bd18c14e4322c87
mehransadeghi/Python_Stocks_2
/stock.py
6,551
3.5625
4
import requests from pyquery import PyQuery from iex import Stock from selenium import webdriver MAX_TICKERS=110 class Tickers: """ A class to fetch all tickers and store them in a file tickers.txt :type ticker_count: int :param ticker_count: The number of tickers to get """ def __init__(self, n): """ Cre...
6bb7f311bf751f88806e77e17d74d6977f16e264
navneeth824/Numerical-techniques1
/unit_3/interpolation derivative of value in table.py
1,855
4.25
4
# newton forward and backward interpolation derivative # calculating u mentioned in the formula def u_cal(u, n): temp = u; for i in range(1, n): temp = temp * (u - i); return temp; # calculating factorial of given number n def fact(n): f = 1; for i in range(2, n + 1): ...
3490d144c4cd81468544c77f7faa8bde3dc23a13
navneeth824/Numerical-techniques1
/unit_3/interpolation derivative of value not in table.py
2,082
4.15625
4
# newton forward and backward interpolation derivative # calculating u mentioned in the formula def u_cal(u, n): temp = u; for i in range(1, n): temp = temp * (u - i); return temp; # calculating factorial of given number n def fact(n): f = 1; for i in range(2, n + 1): ...
3165bc53048b76a1fc5c7bc58bef2663c595f69e
zmatteson/epi-python
/chapter_4/4_7.py
335
4.28125
4
""" Write a program that takes a double x and an integer y and returns x**y You can ignore overflow and overflow """ #Brute force def find_power(x,y): if y == 0: return 1.0 result = 1.0 while y: result = x * result y = y - 1 return result if __name__ == "__main__": print(f...