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
198e4ddbc1806f23914f817654e4d463017b82c1
odioman/modernartgenerator
/modernartgenerator.py
746
3.953125
4
from turtle import * from random import * color(150, 0, 150) def randomcolor(): red = randint(0, 255) green = randint(0,255) blue = randint(0,255) color(red, green, blue) def randomplace(): penup() x = randint(-100, 100) y = randint(-100, 100) goto(x, y) pendown() shape("turtle"...
0e37e55dd1d2c5518f1ad8f36441389695a2b15d
sannepost2001/test
/5distancetraveled.py
234
3.796875
4
milesperhour = 70 six = 6 ten =10 fifteen = 15 print("distance after 6 hours ", milesperhour*six, "miles") print("distance after 10 hours ", milesperhour*ten, "miles") print("distance after 15 hours ", milesperhour*fifteen, "miles")
f3e7c0adaad9c82f80d2dd4bca53b25a621704cb
kgashok/graphs-dict
/graphtheory/spanningtrees/boruvka.py
3,180
3.578125
4
#!/usr/bin/python from graphtheory.structures.edges import Edge from graphtheory.structures.unionfind import UnionFind class BoruvkaMST: """Boruvka's algorithm for finding a minimum spanning tree. Attributes ---------- graph : input undirected graph or multigraph mst : graph (MST) _uf : ...
a3355603d6c1dd85348b128fbbb85bd18913e88b
kgashok/graphs-dict
/graphtheory/planarity/halin.py
7,122
3.5625
4
#!/usr/bin/python from graphtheory.structures.edges import Edge class HalinGraph: """Halin graphs detection. Attributes ---------- graph : input graph outer : set of nodes from the outer face Notes ----- Based on: https://en.wikipedia.org/wiki/Halin_graph h...
4c1232202cfb8831948175956d0b448d08d74259
prash21/FIT2004_3
/trie.py
22,220
3.75
4
# FIT2004 ASSIGNMENT 3 # PRASHANT MURALI - 29625564 import sys # TASK 1 class TrieNode(): """ This TrieNode class is essentially an implementation for the node. """ def __init__(self): """ Initializer for the class. Time complexity: Best: O(1) ...
4e9d79256572884bb58015356419730009e3b2d7
Sed21/CSES
/bit_strings.py
700
3.984375
4
""" Time limit: 1.00 s Memory limit: 512 MB Your task is to calculate the number of bit strings of length n. For example, if n=3, the correct answer is 8, because the possible bit strings are 000, 001, 010, 011, 100, 101, 110, and 111. Input The only input line has an integer n. Output Print the result modulo 10^9...
59f3b2640c5a282796f83ecb49824498c142d12a
hsl39/PythonTicTacToe
/start.py
376
3.5
4
import board class Game: def __init__(self): #Thats alot of boards self.board = board.Board() # 0- Player 1 1- Player 2 self.turn = 0 def startGame(self): print("Welcome to Tic Tac Toe!") def getPlayerName(self): x = board.Board() x.print...
9ecc689f82aa08b813199da38f2fc24e94fa2977
guodonghe/python100
/python1.py
399
3.8125
4
# 斐波那契数列 # 实现一 ''' def fib(max): n,a,b = 0,0,1 while n < max: a,b = b,a+b print (a,end=" ") n += 1 fib(10) ''' # 实现二 import sys def fib(max): n,a,b = 0,0,1 while n < max: a,b = b,a+b yield a n += 1 f = fib(10) while True: try: print(next(f)...
68de13c36638ccb920b609a7c4ad9ef67a47053b
nthuepl/CodeGenerator
/python/sdcc/runflash.py
2,175
3.703125
4
''' This is the Python program for programming the flash followed by calling the code and returning example: python runflash.py testhello.bin '' ''' import CG_Comm import struct import sys if len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == '--help' or \ len(sys.argv) >= 3 and sys.argv[1][-4:] != '.bi...
b97a2cd777f7f27716fbd6fcd40d2fea1464b2d5
enaj1125/I_Submission
/src/social_graph.py
2,443
3.78125
4
import csv import sys class Node(object): """ Node class representing each user """ def __init__(self, name, degree): self._degree = degree self._name = name self._visited = False self._neighbor_list = [] def add_neighbor(self, node_id): if not node_id i...
e9649cb521f4196efde0276015cf6dd313084475
JordanSiem/File_Manipulation_Python
/ExtractAllZipFolders.py
1,640
4.34375
4
import os import zipfile print("This executable is used to extract documents from zip folders. A new folder will be created with the zip folder " "name + 1. This program will process through the folder structure and unzip all zip folders in subdirectories.") print("") print("Instructions:") print("-First,...
361e6b540fb6463d0a5623230e4559509eaace98
Julia-Bauer/algoritimos2
/Atividades/Atividade6/dicionario.py
254
3.875
4
nome = input("Nome do aluno:") nota01 = float(input("Nota 01:")) nota02 = float(input("Nota 02:")) notaFinal = (nota01 + nota02)/2 aluno = { "nome" : nome, "nota01" : nota01, "nota02" : nota02, "notaFinal" : notaFinal } print(aluno)
51c33b5c3ed2c2eb74739cf359e12e02670dda73
Julia-Bauer/algoritimos2
/Atividades/Atividade6/tupla.py
165
3.71875
4
tupla = ("zero", "um", "dois", "três", "quato", "cinco", "seis", "sete", "oito", "nove") escolha = int(input("Digite um número de 0 a 9:")) print(tupla[escolha])
ec3e617bddad84ff04e63a4772db1025fd027d29
Julia-Bauer/algoritimos2
/Atividades/Atividade7/retangulo.py
920
4.09375
4
#Construa um algoritmo para implementar a classe Retângulo que possui os atributos: altura e largura. #A classe deve ter os seguintes métodos: #Método construtor #Método que calcula a área do retângulo ( altura * largura) e retorna o resultado #Método que imprime os valores dos atributos da classe. clas...
94f7cc21189c9a90ef03db7f6be9b56325bc32c0
RamiNaim/System-Software
/Lab1/Task-1/Bird.py
796
4.03125
4
"""Класс, описывающий птицу""" """Каждая птица имеет название(name), размер(size), окрас(brightColor), лог.переменную, отвечающую за водоплавание(waterfowl)""" """лог.переменную, отвечающую за обитание в дикой среде России(wildInRussia), и специальный атрибут, необходимый для определения некоторых птиц(sprecialQuality)...
10270d1d04a1e1ded4c08ac1cd15a528f93970de
szewczykmira/exercism
/python/allergies/allergies.py
561
3.5625
4
class Allergies: ALLERGIES_SCORE = ['cats', 'pollen', 'chocolate', 'tomatoes', 'strawberries', 'shellfish', 'peanuts', 'eggs'] def __init__(self, score): self.score = '{0:08b}'.format(score)[-8:] @property def allergens(self): return zip(self.ALLERGIES_SCORE, s...
3a5954d8ce65bd19711f18454a193260d7999f3b
szewczykmira/exercism
/python/say/say.py
1,989
3.578125
4
from collections import namedtuple InWords = namedtuple('InWords', ['unit', 'teens', 'decimal']) IN_WORDS = { 1: InWords('one', 'eleven', 'ten'), 2: InWords('two', 'twelve', 'twenty'), 3: InWords('three', 'thirteen', 'thirty'), 4: InWords('four', 'fourteen', 'forty'), 5: InWords('five', 'fifteen',...
81a8b578efd07d5a54d64529bfbbbd8dd2f3c6b8
szewczykmira/exercism
/python/queen-attack/queen_attack.py
1,050
3.84375
4
def diagonal_to(elem): elem_row, elem_col = elem result = [] for i in range(8): diff = i - elem_row col_1 = elem_col + diff col_2 = elem_col - diff if col_1 in range(0, 8): result.append((i, col_1)) if col_2 in range(0, 8): result.append((i, co...
98e06e8ecbaf14b7d0c8830c4f17dfc1fdbbec22
huyhieu07/nguyenhuyhieu-fundamentals-c4e16
/buoi04/hw04 /moneyy.py
205
3.625
4
n = str(int(input("nhap so tien cua ban: "))) moneyy = list(n) #cat thanh chuoi 123456... for i in range(len(moneyy)-3, 0, -3): moneyy.insert(i, ',') print("so tien cua ban: $", *moneyy, sep='')
6a0c3739dc19688b2cdeee93e9dcc671125711e5
huyhieu07/nguyenhuyhieu-fundamentals-c4e16
/buoi02/yob.py
402
4
4
yob = int(input("your year of birth?")) age = 2018 - yob print("your age:", age) if age < 10: #conditional statement #bieu thuc dk print("baby") print("hi") elif age <= 18: #10 -18 tuoi print("teenager") elif age ==24: #so sanh gia tri chinh xac print("lay ck thoi") else: ...
690fe23f1caed267ea79d1e784ab187c86d0089e
dbstmd4857/0928
/test01.py
333
3.84375
4
a = [1 ,2 ,3 ,4] b = [5 ,6 ,7 ,8] c = [9 ,10, 11, 12] d = a + b + c for index in range(len(a)): print (a[index]) print() for index in range(len(b)): print (b[index]) print() for index in range(len(c)): print (c[index]) print() for index in range(len(d)): print (d[in...
ebbf0cf2feea1df75e5951b95c8d0635169f6304
EliForester/league-builder
/league_builder.py
2,325
3.796875
4
import csv import sys player_list = 'soccer_players.csv' team_list = [{'Team': 'Dragons', 'Time': 'March 17, 1pm'}, {'Team': 'Sharks', 'Time': 'March 17, 3pm'}, {'Team': 'Raptors', 'Time': 'March 18, 1pm'}] letter_contents = '''Dear {}, Your child {} has been selected to participate in Battle Royale as part o...
226ea2473b51fd36b5d8d0f7d08b6481e4aa89d1
aleherrrera/Evaluacion
/ManejadorPedidos.py
1,287
3.53125
4
import csv from Pedido import Pedido class ManejadorPedidos: __pedidos=[] __cantidadDias = 30 def __init__(self): self.__pedidos = [] self.__cantidadDias = 30 def cargarPedidos(self): archivo = open('VentasMensuales.csv') reader = csv.reader(archivo,delimi...
f4c7be0770b060138b470ee5eb8ab1a37182046c
coolshop-com/coolshop-application-assignment
/ugly_code.py
1,280
3.5
4
def pretty_function(string_to_count): raise NotImplementedError() def Ugly_Function(string_to_count): Cpy_Of_String = str(string_to_count) Result = {}#holds result for c in Cpy_Of_String: if (c in Result.keys()) == False: Result[c] = [c] elif (c in Result.k...
3881228ff24bafeeb7aafee26a8e7f5300deda2c
arnabmid88/DataScienceProjects
/WealthDistribution/GetDataSet.py
1,655
3.65625
4
# -*- coding: utf-8 -*- import csv import matplotlib.pyplot as plt import numpy as np from operator import itemgetter from itertools import groupby def getDataSetUsingCSV(path, country="United States"): """Extract the data for the country provided. Default is United States.""" with open(path, 'r') as csvfile: ...
3eb73e362476bba7b426272d6bac923cae4040f5
Anisha-Kakwani/PythonForEverybody
/Tuples.py
778
4.0625
4
# Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 # On...
856a1c9706ca4bd04231a6062e919502de66d5dd
unhm-programming-team/physics-simulator
/Old/Vector and MassObject.py
9,213
3.984375
4
class VectorObject: """ An object which stores its x,y position as a displacement vector. It has a width and height, and 'bounds' based on those values. In addition to displacement, it has vectors for velocity and acceleration. When it updates, it converts acceleration to velocity and velocity int...
0272227aa2a06204909bfabba3ebad0598ca6a00
AlbertSadovnikov/CarND-LaneLines-P1
/P1.py
4,037
3.65625
4
import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 as cv import os import sys def draw_lines(img, lines, color=[255, 0, 0], thickness=2): """ NOTE: this is the function you might want to use as a starting point once you want to average/extrapolate the line seg...
ff0f4dcac843070054999a5cb4471f4911bdf785
dorigum/myStudy
/myPythonStudy/P181.py
399
3.765625
4
# python 자료형 : 튜플, 인덱싱, 슬라이싱 a = ('한국', '중국', '일본') print(a[0]) # (a) -> 한국 print(a[1:]) # (b) -> ('중국', '일본') : 튜플은 소괄호로 묶여서 출력된다 a[1] = '미국' # (c) -> TypeError: 'tuple' object does not support item assignment # 오류 발생 : 추가, 삭제, 변경 등이 불가능한 [읽기 전용] 객체 print(a)
8f45bf52bcda424cd6fb87f2321bbc17130c5318
ClassicRevive/classic
/python3/poker_021.py
1,128
3.875
4
#!/usr/bin/env python ''' calculate probability of each rank of hand occuring given all hands''' import sys # define dictionaries of rank names and rank counters ranknames = {"rank0": "nothing", "rank1": "one pair", "rank2": "two pairs", "rank3": "three of a kind", ...
d1535f2e52a66330fa5c714e00a5769a01efc251
ClassicRevive/classic
/python2/list-cruncher.py
714
3.578125
4
#!/usr/bin/env python a = [] # this code will take the minimum 10 values inputted, # and create a list of them in order s = raw_input() i = 0 while s != "end": while i < 10: a.append(int(s)) s = raw_input() i += 1 # print i # at this point, the list has 10 ele...
d555915e6d1158f2e2b1444f2183eb290bff490f
ClassicRevive/classic
/python3/misc/linear-search.py
1,026
3.921875
4
list1 = ["they bought a car, in car. nashville car", "hello world car nashville tbone", "this is such a hard program to make like damn bruh car -_-"] def word_search(doclist, keyword): """ parse through the doclist assigning i as index and doc as a value in doclist. clean the values by fir...
635a3ca65719c631d10e36bfce1400454ba05095
ClassicRevive/classic
/python2/my_other_scripts/highest-lowest.py
645
3.84375
4
#!/usr/bin/env python import random a = [] n = input("indicate length of list: ") i = 0 while i < n: a.append(random.randrange(10000)) i += 1 print a j = 0 while j < len(a): # find the position of the smallest number in a[j:len(a)] # swap this number with the number at the jth po...
d90179d06af281faf78b5e9c267b6045de08b339
ClassicRevive/classic
/python2/my_other_scripts/sequence_012.py
324
3.609375
4
#!/usr/bin/env python from time import sleep i = 0 x = 0 nul = 0 one = 0 two = 0 while i < 50: x = (x + 1) % 3 if x == 2: two += 1 elif x == 1: one += 1 elif x == 0: nul += 1 print x i += 1 sleep(0.2) print "null count:", nul print "one count:", one print "two count:", t...
e9637497820c88794e6b8444cf969fec5366f832
AleksandraAleksandrova/ScriptLanguages
/class_special_deff_words.py
331
4
4
class Person: def __init__(self,name,age): self.age = age self.name = name def __add__(self, other_obj): return self.name + other_obj.name def __str__(self): return "My name is {}" .format(self.name) p1 = Person("Goshko", 15) p2 = Person("Peshko", 14) ...
83ddf35428f6563acd7fbda523d5136da0795ad6
pscr-university-of-colorado-boulder/Receiver_MPTCP
/journal/observation/ofo.py
301
3.546875
4
import sys if(len(sys.argv)<2): print ("Usage error") exit(0) filename=sys.argv[1] fd=open(filename,"r") Lines = fd.readlines() ofo=[] # Strips the newline character for line in Lines: ofo.append(int(line.split("\n")[0].split(" ")[-1])) print ("avg:",sum(ofo)/len(ofo),"max:",max(ofo))
9bc06a358cbbfe11f8955f386b894eeeab8bdd20
kulbitmc/1sem
/lab4_part2.py
8,520
3.625
4
class Target: def __init__(self, params): self.x = params['x'] self.y = params['y'] self.r = params['r'] self.alpha = params['alpha'] self.v = params['v'] self.color = params['color'] class Circle(Target): def __init__(self, params): super().__init__(par...
560938c421acd706cfb48f18e6d357cf0be9491c
kulbitmc/1sem
/lab2/part2#1.py
181
3.734375
4
import turtle turtle.shape('classic') from random import * n = randint (50, 100) for i in range (n): turtle.forward (randint (0, 100)) turtle.left (randint(0, 360))
b4a1ad20600f10ee450347ce0c8f8c4341b20123
davidkellis/py2rb
/tests/basic/del_slice.py
92
3.75
4
mylist = [1,2,3,4,5] del mylist[1:3] for x in range(0,len(mylist)): print(mylist[x])
2dc01f62020a8487c74a689ba41d48c55914f913
davidkellis/py2rb
/tests/basic/for_in2.py
539
4.375
4
# iterating over a list print('-- list --') a = [1,2,3,4,5] for x in a: print(x) # iterating over a tuple print('-- tuple --') a = ('cats','dogs','squirrels') for x in a: print(x) # iterating over a dictionary # sort order in python is undefined, so need to sort the results # explictly before comparing output...
6f72ddf6e20d18fc83964cdf2059e88f29fe9325
davidkellis/py2rb
/tests/deep-learning-from-scratch/step_function.py
445
3.578125
4
# coding: utf-8 import numpy as np def step_function(x): return np.array(x > 0, dtype=np.int) X = np.arange(-5.0, 5.0, 0.1) Y = step_function(X) def print_array(data): datas = [] for i in data: if float("%.3f" % abs(i)) == 0: datas.append(float("%.3f" % abs(i))) else: ...
1a99387d36d51f8d4d282e7c324cb9dca821139e
davidkellis/py2rb
/tests/strings/replace2.py
318
3.671875
4
txt = "the quick brown fox jumped over thethe lazy dog" txt2 = txt.replace("the","a") print(txt) print(txt2) print(txt.replace("the", "a", 0)) print(txt.replace("the", "a", 1)) print(txt.replace("the", "a", 2)) print(txt.replace("the", "a", 3)) print(txt.replace("the", "a", 4)) print(txt.replace("the", "a", 50))
33900582a627b528eaf2c3e702a1e0923eed6d61
davidkellis/py2rb
/tests/numpy/full.py
287
3.546875
4
# coding: utf-8 import numpy as np def print_matrix(data): data_i = [] for i in list(data): data_j = [] for j in i: data_j.append(int("%d" % j)) data_i.append(data_j) print(data_i) x = np.full((2, 2), 5, dtype=np.int64) print_matrix(x)
eafa36dc200d66a2e2da351665132cc5be50b741
davidkellis/py2rb
/tests/numpy/max_min.py
1,060
3.78125
4
# coding: utf-8 import numpy as np def print_matrix(data): data_i = [] for i in list(data): data_j = [] for j in i: data_j.append(j) data_i.append(data_j) print(data_i) def print_array(data): datas = [] for i in data: datas.append(i) print(datas) x...
38e75a90ff06993593cf5da07f636de9557337f4
davidkellis/py2rb
/tests/decorator/function3.py
317
3.65625
4
class wrapper: def __init__(self,fn): self.fn = fn def __call__(self,*args): return "(" + self.fn(*args) + ")" def mydecorator(x): print("decorating " + str(x)) return wrapper(x) @mydecorator def describe(): return "world" describe = mydecorator(describe) print(describe())
8ceb2df22005a51c9c8e39c30e89fcf18e926dd5
davidkellis/py2rb
/tests/basic/dictionary3.py
158
3.6875
4
foo = dict() foo['a'] = 'b' foo['c'] = 'd' print(foo['a']) print(foo['c']) bar = dict([('a', 1), ('b', 2), ('c', 3)]) if 'a' in bar: print("a in bar")
949454346aaf7531697d27f5b9902281487df60f
davidkellis/py2rb
/tests/basic/with.py
164
3.703125
4
with open("hello.txt", 'w') as f: f.write("Hello, world!") with open("hello.txt", 'r') as f: print(f.read()) with open("hello.txt", 'r'): print('ok')
02d04343749d620dc33a0ecd17e8044ca6bb7d22
ArtOliinyk/python-laboratory
/laboratory1/task2.py
1,724
4
4
print('========================================') print('Лабораторна робота №1') print('Програмування лінійних алгоритмів') print('Автор: Олійник Артем, КМ-91 (16 варіант)') print('========================================') print("Скласти програму, що визначає, чи пройде графік функції у = ах2 + b х + с") print("через ...
fa1b22e0a1939c666e87124903d9a2a1a53189e2
KacperSiuda/IOPython
/IO2/IO2/IO2.py
451
3.6875
4
def main(): text = input() print(BracketPair(text)) def BracketPair(text): iparens = iter('()') parens = dict(zip(iparens, iparens)) closing = parens.values() stack = [] for i in text: d = parens.get(i, None) if d: stack.append(d) elif i in closing: ...
4998cf3e23057be1219fb3fca9f025674587831c
abeckham17/numerical_analysis
/helper_functions.py
13,355
3.84375
4
import numpy as np import pandas as pd from scipy import interpolate def jacobi(A, b, x0, tol, n_iterations=300): """jacobi(A, b, x0, tol, n_iterations=300) Performs Jacobi iterations to solve the line system of equations, Ax=b, starting from an initial guess, ``x0``. Returns: x, the estimated sol...
0576726df89f10049768054c82dd86a500915049
hsinhuibiga/August
/Power of Four.py
301
3.59375
4
#Power of Four class Solution(object): def isPowerOfFour(self, num): """ :type num: int :rtype: bool """ if num <= 0: return False if num == 1: return True if num % 4 == 0: return self.isPowerOfFour(num / 4) return False
abe4042fd790dfd2d0ad02e9e09b9253e01e7ab2
vmesel/slides
/socket/codigos/starwars.py
478
3.5
4
# Conecto a um WiFi para poder liberar o acesso a internet do MicroPython import network sta_if = network.WLAN(network.STA_IF) sta_if.scan() sta_if.connect("<AP_name>", "<password>") sta_if.isconnected() # Abro o socket e inicio uma conexão com o server ASCII de Star Wars import socket addr_info = socket.getaddrinfo("...
4d169b6eba3a8f5ea72a7fdb493d8cd49cf6c635
deadbok/ANNbug
/ANNbug/gentest.py
5,509
3.625
4
''' Genetic algorithm test. @since: Jun 16, 2012 @author: oblivion ''' from genetic import binchromo from genetic import algorithm import copy GENES = {'0000': '0', '0001': '1', '0010': '2', '0011': '3', '0100': '4', '0101': '5', '0110': '6', '0111': '7'...
67b2946a8be4d7a14667c3a3c2e33248bd6c7bb6
Pulssi/Twitter-Word-Cloud
/word_cloud.py
2,464
3.53125
4
''' Word cloud maker for twitter Input twitter screen name and get a word cloud from their latest tweets Latest tweets include 3200 tweets including retweets from their timeline This is meant to be used for tweets that are written in English ''' from api_keys import API_KEY, API_SECRET from nltk.token...
a01e7712caf327b6d806d2d60857b93ee5e125e7
piotor87/verkko
/misc/sqlite.py
4,783
3.59375
4
""" Utilities for interacting with sqlite3. """ import cPickle as pickle class SQLiteDict(object): """On-disk key-value store with SQLite. This class operates similar to the 'shelve' module, but uses sqlite3 as a backend for better locking ability and possible performance. Arbitrary python objects s...
c6bab1599847bade1f1f894d7819c0c1c85ae573
fezzle/adventofcode2018
/day11.py
2,717
3.734375
4
#!/usr/bin/env python3.6 import math def power_level(x, y, grid_input): rack_id = (x) + 10 power_level = rack_id * (y) power_level += grid_input power_level *= rack_id power_level = int(power_level / 100) % 10 power_level -= 5 return power_level # def vs(a, b): # print("got:{} expecte...
daecf43082ccdca104974cb6299a019c74572610
LukeO1/HackerRankCode
/CrackingTheCodingInterview/MergeSortCountingInversions.py
1,699
4.125
4
#!/bin/python3 """Count the number of inversions (swaps when A[i] > B[j]) while doing merge sort.""" import sys #Use global variable to count number of inversions count = 0 def countInversions(arr): global count split(arr) return count def split(arr): #If arr has more than one element, then split ...
6f2b150bf829b05a007a3409dea1d72111059997
nmb436/Projects
/timezone_2.py
957
3.5
4
import datetime from datetime import datetime import time import pytz from pytz import timezone from dateutil.tz import tzutc, tzlocal utc = datetime.now(tzutc()) portland = utc.astimezone(tzlocal()) portland_time = portland.strftime("%H : %M") portland_hour = portland.strftime ("%H") new_york = utc.a...
b25c2afc65fc0e03da050bf3362a5cf04474214a
t-christian/Python-practice-projects
/characterInput.py
2,249
4.34375
4
# From http://www.practicepython.org/ # Create a program that asks the user to enter their name and their age. # Print out a message addressed to them that tells them the year that they will turn 100 years old. # Stupid library to actually get the date # TODO: figure out how to properly use datetime import datetime #...
a87d276906b807aa7551de540a16261bc6d3972a
Aausuman/Advanced-Python
/a2.py
2,732
3.671875
4
# # Assignment 2 # # Student Name : Aausuman Deep # Student Number : 119220605 # # Assignment Creation Date : February 10, 2020 import re def moolah(s): # returns a list of every Euro amount (as a string) that is mentioned in the input amounts = [] regexp = re.compile(r'EUR\s?\d+(\.\d+)?') for match i...
c237a63c1943282e5c76c495ca3d5c6956091789
shinkarenkoalexey/Python
/ Additional/test3.py
674
3.703125
4
dict1 = { "яблоко": "malum, pomum, popular", "фрукт": "baca, bacca, popum", "наказание": "malum, multa" } k = dict1.get("яблоко") + ", " + dict1.get("фрукт") + ", " + dict1.get("наказание") k = k.split(", ") result = dict.fromkeys(k, []) ss = [] for i in result.keys(): for j in dict1.keys(): if ...
d99eb536ba6f68e46e4fd68fcc1dbb45fe45cff5
shinkarenkoalexey/Python
/Labs/lab4/6.py
421
3.5625
4
s = int(input("Номер символа...")) h = int(input("Высота...")) s = chr(s) s1 = " " d = h x = 0 for j in range(0, h+1): if j != h: while j > 0: j -= 1 if x != h: print('{}{}||{}{}'.format(s1*d, s*x, s*x, s1*d), end='') print(end='\n') x += 1 ...
ad632e4f5394c1bcc3b3a72b67e71e261652943d
shinkarenkoalexey/Python
/Labs/lab1/2.py
207
3.71875
4
a = int(input("Первое число ")) b = int(input("Второе число ")) print("{} + {} = {}\n{} - {} = {}\n{} * {} = {}\n{} / {} = {}".format(a, b, a+b, a, b, a - b, a, b, a * b, a, b, a / b))
242359a36c0b478e0f52b9f9ead44a98fd817049
shinkarenkoalexey/Python
/Labs/lab6/1.py
508
3.734375
4
import re def match(letter: str, word: str): word = re.findall(r"\D", word) letter = letter.split(", ") c = 0 for i in letter: if i in word: c += word.count(i) if c >= len(word): print("Возможно") else: print("Невозможно") ll = "е, т, ш, о, д, и, ч, к, а, ...
4a3a05191de3c398be4a694b6012962b96c0ed76
shinkarenkoalexey/Python
/Labs/lab3/4.py
129
3.71875
4
x = 0 while x >= 0 or x <= 0: x = int(input("Введите число")) if x != 16: print("&") else: break
7542779a4d30f05ca4a9200edca9d2d709147505
shinkarenkoalexey/Python
/Lecture/lec4.py
2,941
3.984375
4
from random import randint """ Создайте список из пяти любых чисел. Спросите у пользователя число. Проверьте, есть ли данное число в списке, выведите соответствующие сообщение ("Поздравляю, Вы угадали число!", "Нет такого числа!" и т.п.). """ print("Первое задание:\n") def guess(n: int): # n - Количество попыток ...
ee0671c08bc8221937dd11984935e0c42c83ddc1
shinkarenkoalexey/Python
/Labs/lab5/task7/7_2.py
591
3.65625
4
import p7_1 import math def disc(a: float, b: float, c: float): x1 = 0 x2 = 0 d = p7_1.subtraction(p7_1.multiplication(b, b), p7_1.multiplication(4, p7_1.multiplication(a, c))) if d < 0: print("Нет корней") elif d > 0: x1 = p7_1.division(p7_1.plus(-b, math.sqrt(d)), p7_1.multiplicati...
cc2878d4cba5e5d8c7fae61927b3ffc1ba89a0ab
shown440/Flask_API_A_to_Z
/Real_Life_API/Employee_api_orm/using_flask_orm/zz_date_convert.py
776
3.5625
4
from datetime import datetime #datetime_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p') ############################################################### # date = 'Jun 1 2005 1:33PM' # datetime_object = datetime.strptime(date, '%b %d %Y %I:%M%p') ####################################################...
5993066ee0332df6de363bc859b80fee04f1d8a9
shown440/Flask_API_A_to_Z
/flask_API_intermidiate/2_A_Full_Python_Refresher/18_programming_excercise.py
293
3.859375
4
def who_do_you_know(): people = input("Enter the names of peoples you know: ") people_list = people.split(",") return people_list def ask_user(): person = input("Enter a name: ") if person in who_do_you_know(): print("You know the {}".format(person)) ask_user()
5545cf0658563beff3ac946162b00633514da543
shown440/Flask_API_A_to_Z
/flask_API_intermidiate/5_Storing_Resources_in_SQL_DB/5_14_get_post_put_delete/Code_part/sqlite3_db.py
698
4.03125
4
import sqlite3 connection = sqlite3.connect("data.db") cursor = connection.cursor() # int=INTEGER. but if we need auto incremented id then we have to write INTEGER create_table_users = "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username text, password text)" cursor.execute(create_table_users) print("u...
57b886f468a397e4c4fc80b3e357f5ea1b4d5e9c
bvispo/lab-vikings
/vikingsClasses.py
2,955
3.5
4
# Soldier class Soldier: #constructor function: def __init__(self, health, strength): self.health = health self.strength = strength #método attack: def attack(self): return self.strength #método receiveDamage: def receiveDamage(self, damage): self.damage = dam...
7c9ec57ae7dc314826604b9eb864413053023db8
githubflub/data-structures-and-algorithms
/heap_sort.py
2,167
4.34375
4
''' 1. Create an unsorted list 2. print the unsorted list 2. sort the list 3. print the sorted list ''' def main(): myList = [4, 3, 1, 0, 5, 2, 6, 3, 3, 1, 6] print("HeapSort") print(" in: " + str(myList)) # sort list myList = heapSort(myList) print("out: " + str(myList)) def he...
bb7d0613fa4cbd31e63c3bfd3a5fe6703a3ba406
hsbacot/dat-chapter-1
/labs/exercise_1/solution.py
110
3.71875
4
numbers = [22, 33, 44, 55, 66, 77, 88, 99, 111] for num in numbers: if num % 33 == 0: print(num)
547d835db16b4f8224963b0fec58f77e0de0eb7f
VishalChak/machine_learning
/pySpace/test_1_.py
1,043
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat May 26 22:38:43 2018 @author: vishal """ class Node: def __init__(self): self.left = None self.right= None self.data = None def insert(root, temp): if root.data <= temp.data: if root.right == None: r...
0eaf442492fc997bfde26768bb105686c8a0195e
VishalChak/machine_learning
/pySpace/NumPy.py
1,455
3.546875
4
import numpy as np class NumPy: def __init__(self): pass def example(self): a= np.arange(15).reshape(3,5) print("example") print(a) print("Shape : ", a.shape) print("Ndim : ", a.ndim) print("dType : ", a.dtype.name) print("ItemSize : ", a.itemsize) print("Size : ", a.size) print("type : ", type...
1c2961ee3820af9880ec24b6dd184690f7c91761
VishalChak/machine_learning
/pySpace/DutchNationFlag.py
649
3.75
4
class Dutch: listFlag = [] n = 0 def insert(self): for i in range(self.n): self.listFlag.append(int(input())) def printList(self): print ("Dutch Nation Flag is : : ") for i in range(self.n): print(self.listFlag[i]) def arrangeFlag(self): i = 0 j = self.n-1 while i< j: while self.listFlag[i...
067adf5c4bcfc2da919275e780612c7f5040481a
VishalChak/machine_learning
/pySpace/office/searching.py
564
3.96875
4
def linear_search(arr, x): for i in range(len(arr)): if x == arr[i]: return i return -1 def binary_search(arr,x,left, right): if left <= right: m = (left+right)//2 if arr[m] == x: return m elif arr[m] < x: return binary_search(arr,x,m+1, r...
57bb606d2d60d11fbf1a58c46fdc338d5fff73b0
VishalChak/machine_learning
/pySpace/prectice/sorting
1,189
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 13 23:14:29 2018 @author: vishal """ arr = [1,2,3,4,5] print(len(arr)) print(arr[4]) def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while (j >=0 and key < arr[j]): arr[j...
42808cbaaf9e625663cdf22d5a63c69130bcd2da
VishalChak/machine_learning
/pySpace/BinarySearch.py
703
3.8125
4
class BinarySearch: a = [] x = 0 def insert(self,n): for i in range (n): temp =input("Enetr : ") self.a.append(temp) def listSort(self): self.a.sort() def printList (self): for i in range(len(self.a)): print(self.a[i]) def Bsearch(self,start,end): if start<=end: mid = (start + end )//2 if i...
f3e2e7a1f9a7279d37cdede220ac4f09d6f33542
VishalChak/machine_learning
/pySpace/office/string_operation.py
1,060
4.03125
4
# -------------------------------------# def remove_duplicate(arr): arr_dict = {} for val in arr: if val not in arr_dict: print(val) arr_dict[val] = 0 names = ['vishal', 'vishal', 'babu', 'chak', 'chak'] #remove_duplicate(names) # -------------------------------------# # rev_s...
34de070e4c87bf4de63d5c0d80754a62cc9fa725
VishalChak/machine_learning
/pySpace/Num2Word.py
1,022
3.640625
4
from Stack import * class Num2Word: num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \ 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \ 11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \ 15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eight...
e9e50f5f8f47e36df2d4e5eb562d4adf3f9f061b
Pavan7411/Revising_python
/mf.py
1,880
4.25
4
def line_without_moving(): import turtle turtle.forward(20) turtle.backward(20) def star_arm(): import turtle line_without_moving() turtle.right(360 / 5) def hexagon(): import turtle #import turtle module for the below code to make sense x=50 #length of polyg...
83b109bf6219348908a8f0e43b2fab2f69348b4e
Pavan7411/Revising_python
/Loop_7.py
519
4.625
5
import turtle #import turtle module for the below code to make sense turtle.shape("turtle") #changing the shape of the turtle from arrow to turtle x=10 #size of circle n=40 #n sided regular polygon th = 360/n #th is the external angle made by sides ...
73a12e7f11ed70feddd44a4cc22a0129dbf2980d
Pavan7411/Revising_python
/Loop_6.py
395
4.40625
4
import turtle #import turtle module for the below code to make sense turtle.shape("turtle") #changing the shape of the turtle from arrow to turtle x=40 #size of square for j in range(36): #for loop for drawing multiple squares for i in range(4): #for loop for drawing a squ...
1581d23223e2c5f9587b73f3c26a3bdb0341c25b
Thodoris2174/pe2
/peu2.py
205
3.8125
4
sum = 0 listfib = [ ] def printlist() : for number in range (n) : listfib.append(number) def fiboEvenSum () : for i in listfib : if i % 2 == 0 : sum += i print fiboEvenSum(10)
9c2d48be637f927d17712182c68cd5c7fc1754ad
dhmodh/Python
/Power_Of_Hanoi.py
163
4.09375
4
def hanoi(x): if x == 1: return 1 else: return 2 * hanoi(x-1) + 1 x = int(input("Enter the Number of Disks :- ")) print('Number of Steps :- ', hanoi(x))
e0ffdbf1f9047f90e0db888fd025993194e28ef2
dhmodh/Python
/nested_list.py
142
3.984375
4
my_list = [1, 2, [3, 4, 5]] #3rd Element's second element result = my_list[2][1] print(result) #3rd element result=my_list[2] print(result)
773aefe68ba6a90b89b1374b610a33e00acbc8c8
dhmodh/Python
/Spiral_Matrix.py
392
3.75
4
def rot_right(a): return zip(*a[::-1]) def sp(m, n ,start = 1): if n == 0: yield() else: yield tuple(range(start, m + start)) for row in rot_right(list(sp(n - 1, m, m + start))): yield row def spiral(m): return sp(m, m) number = int(raw_input("Enter number for Spiral pattern:- ")) print "Spiral Mat...
5469f546d302a74e890cdd3622f5cbe5a20540c2
dhmodh/Python
/variable_scope.py
192
3.78125
4
def my_func(): x = 10 #This x is local in my_func() print("value inside Function:- ", x) x = 20 #This x is defined in Global scope my_func() print("Value Outside Function:- ", x)
c334db4312c676c72c40f855bff599d8f16a2dbb
MammothStack/Lyteflow
/lyteflow/kernels/split.py
10,133
3.671875
4
"""Module for splitting an input into multiple outputs This module contains all PipeElements that handle a single input, but multiple outputs. This occurs because the input is split along some axis into 2 or more objects or the same object is duplicated. """ # Standard library imports import warnings # Third party ...
f3ce4ceab4878cb36ad83d1d4ce9d18a0fb1d783
sbhanda/f20-term-proj
/tp_classes.py
7,520
3.609375
4
# Name: Saumya Bhandarkar (ssbhanda) # Assignment: TP3 # Description: this file holds all the defined classes from cmu_112_graphics import * import basic_graphics, math, random ########################### ALL DEFINED CLASSES ############################# # defines the Ramp class class Ramp(object): im...
a550f2a4c1038757298db9b19afc9c0d55348d16
liushengxi13689209566/Programming-language-learning
/Python/dataType_variable.py
563
3.78125
4
#!/usr/bin/env python # coding=utf-8 print(''' kbmkoetb biothoh bjnutio ''') x= b"ABC" print (x) b= ['111',333] a = ['liu',888,'xi',b ] print (a) a.append(" 最 帅 " ) print (a) a.insert(0 ,'刘生玺') #a.pop() print ("a[0] == ",a[0]) print ("a[1] == ",a[1]) print ("a[-1] == ",a[-1]) print (a) a.po...
5c88f3c0963bc2ecfa8e0c550567a9d43c018dd1
spencer-mcguire/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
1,118
4.34375
4
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' def count_th(word): # return how many times 'th' exists in a give...
30477bbf47c488494aeafc994ce5f59ba9db02d5
chrishoran8/Exam3
/Exam3/Exam3.py
5,650
4.09375
4
##PLEASE FILL OUT THE BELOW DETAILS ##Student Name: ##Course Number: ##Student Number: ##complete each task which is shown as a comment. #complete each task directly below the comment #each task shows a task number, and number of marks awarded #on each task requiring an output, ensure the task goes on a separate li...
468a247525001a9a7866002984e9cb3e06b06684
andrewtmmaher/noughts-and-crosses
/noughts_and_crosses/game.py
5,281
3.609375
4
from noughts_and_crosses.exceptions import PlacementException class NoughtsAndCrosses(object): EMPTY_POSITION_COUNTER = 0 COUNTER_REPRESENTATION = { -1: 'o', 0: ' ', 1: 'x' } BOARD_TEMPLATE = ( ' {} | {} | {} ' '\n-----------' '\n {} | {} | {}' ...
532d52f905a3e389fc797d43ae96655eb0492cec
TheFifthMan/python-code
/bulit-in-libraries/date-types/orderdict_ex.py
153
3.515625
4
from collections import OrderedDict d = OrderedDict() d['a']= 'A' d['b'] = 3 d['s']= 1 d['d']='B' d['c']='C' for k,v in d.items(): print(k,'=>',v)
0156e4fbe96fd2c5fc63e6a95c56b04a635db9d2
TheFifthMan/python-code
/bulit-in-libraries/modules/exceptions.py
346
3.515625
4
class Error(Exception): pass class InputError(Error): def __init__(self,message): self.message = message def __str__(self): return self.message def test_exception(): i = 1 if i == 1: raise InputError("the number can't equal to 1") try: test_exception() except Inp...
24ac6faa94c8a4fb7b3dc3dd118c012b370de2b6
TheFifthMan/python-code
/bulit-in-libraries/random/demo.py
1,593
3.875
4
# coding: utf-8 import random ''' # 生成0 - 1 之间的随机小数 for i in range(100): print("0 ~ 1: ",random.random()) # 生成其他的随机小数 for i in range(1,100): print("1 ~ 100 :",random.uniform(1,100)) # 随机数生成的算法 : min + (max -min) * random() # 如果你要生成整数 for i in range(100): print("1 ~ 100: ",random.randint(1,100)) ''' # ...
92b4f6d127a5ab6bd50f08c4c3d7b9c4ed1cc868
ldorourke/CS-UY-1114
/O'Rourke_Lucas_Polynomials.py
1,647
4.15625
4
''' Lucas O'Rourke Takes a second degree polynomial and prints out its roots ''' import math a = int(input("Please enter value of a: ")) b = int(input("Please enter value of b: ")) c = int(input("Please enter value of c: ")) if a is 0 and b is 0 and c is 0: print("The equation has infinite infinite number of solut...
424d6d3eb20d8f63c689fe1f7160979870c7acbc
Rinkikumari19/codechef_questions
/count_vowel_consonant.py
516
3.625
4
s1 = "aeiouAEIOU" s2 = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz" user = input("enter your number ") i=0 vowel=0 cons = 0 while i<len(user): index=0 while index<len(s1): if user[i]==s1[index]: vowel=vowel+1 else: print("",end = "") index=index+1 b=0 whi...