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 |
|---|---|---|---|---|---|---|
4cc800c84d68024bfe3bd994e2422de91ffa2925 | leon-lei/learning-materials | /trevor_payne/type_class_tut.py | 492 | 3.875 | 4 | # Code being referenced from trevor payne youtube channel
# Traditional creation of a class with attribute
class MyClass(object):
def __init__(self):
self.x = 5
# TypeClass method in just 1 line of code
TypeClass = type('TypeClass', (object,), {'x':5})
m = MyClass() # 5
t = TypeClass() # 5
print(m... |
8cf9276d0d5f21b47f877e054a4f12105d98f221 | nicschumann/ml-classics | /torch-linear-regression.py | 2,070 | 3.765625 | 4 | import numpy as np
import torch
from torch.optim import SGD
import matplotlib.pyplot as plt
# This is a simple introduction to gradient-based function approximation
# of the kind used in deep learning. I'll be focusing on supervised, classification
# problems in this examples, as, in my view, these are the simplest ... |
085cb87ea8131a558fc3c161f158633ab2499001 | samelstob/notes | /management-notes/algorithms/src/fibonacci.py | 1,697 | 4.09375 | 4 | #!/usr/bin/env python3
"""
Base case - smallest instance - can be solved trivially - often the identity value
Recursive step - Work on a smaller instance of the problem towards the base case
"""
"""
Return the nth Fibonacci number
Naive implementation - follows the recursive mathematical definition
"""
def fib_naiv... |
dcf43b0e2a47335109ac7277e478c5cf601e70a9 | Lipones/ScriptsPython | /variáveis.py | 335 | 3.828125 | 4 | # -*- coding: utf-8 -*-
var1 = ("eu sou uma string") #tipo string
var2 = 47 #tipo int
var3 = 12.89 # tipo float
var4 = True #tipo boleana
var5 = False #tipo boleana
print(var1)
print(var2)
print(var3)
print(var4)
print(var5)
var6 = 15
var7 = "Felipe"
print('Meu número é: {}, e meu nome é: {}'.format... |
70b705fc1378b524560ac03c727748133b8919bd | Lipones/ScriptsPython | /estruturas de repetição2.py | 293 | 4.15625 | 4 | # -*- coding: utf-8 -*-
lista1 = [1,2,3,4,5]
lista2 = ["olá", "mundo", "!"]
lista3 = [0, "olá", "biscoito", "bolacha", 9.99, True]#comando for é utilizado para percorrer listas e exibir resultados
for i in lista1:
print(i)
for i in lista2:
print(i)
for i in lista3:
print(i)
|
7066407fa6b3b94aae60d05f484f28930e14c0d2 | signalwolf/Algorithm | /Python/default_dict.py | 1,015 | 3.703125 | 4 | # coding=utf-8
# default dict 与 dict 有什么不同
# 1. 对于未在dictionary中的元素的处理,Dict是直接报错,故而我们需要区分在dict中与不在dict中的情况:
dicts = {}
for i in xrange(10):
if i in dicts:
dicts[i] += 1
else:
dicts[i] = 1
print dicts
# output:
# {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1}
# 但是对于default dict来说,我们只需要直接... |
53603872764faa219613edff8c3e9cc02d952952 | signalwolf/Algorithm | /Chapter6 Graph/Dijkstra/dijkstras_find_shortest_path.py | 1,738 | 3.5625 | 4 | from heapq import *
from collections import defaultdict
def dijkstras(start, end, graph):
distance = [False] * (len(graph))
heap = [[0, start, [0]]]
while heap:
dis, curr, path = heappop(heap)
if distance[curr]: continue
if curr == end: return distance
distance[curr] = dis
... |
09ec92ec4d6eea8ac00b7c88519b880ac1412fce | signalwolf/Algorithm | /stack/单调栈_folder/255. Verify Preorder Sequence in Binary Search Tree.py | 868 | 3.796875 | 4 | # coding=utf-8
# stack 解决:
# recursion 解决:超时
class Solution(object):
def verifyPreorder(self, preorder):
"""
:type preorder: List[int]
:rtype: bool
"""
# print preorder
if len(preorder) <= 2: return True
base = preorder[0]
# no left condition
... |
1421aac5bb5d2864179392ec3580146803b0dc22 | signalwolf/Algorithm | /Chapter2 Linked_list/Insert a node in sorted linked list.py | 1,244 | 4.28125 | 4 | # https://www.geeksforgeeks.org/given-a-linked-list-which-is-sorted-how-will-you-insert-in-sorted-way/
# insert by position
class LinkedListNode(object):
def __init__(self, val):
self.val = val
self.next = None
def create_linked_list(arr):
dummy_node = LinkedListNode(0)
prev = dummy_node... |
5566516ea130bd9bd1f4039593da454556cefe95 | signalwolf/Algorithm | /Binary Search/BST.py | 1,524 | 3.546875 | 4 | # coding=utf-8
# 不要忘记了initial node 的方法
from random import randint
class BSTNode(object):
def __init__(self, val):
self.val = val
self.left= None
self.right = None
def insert_BST(root, val):
if root == None: return BSTNode(val)
if root.val > val:
root.left = insert_BST(roo... |
d4768e3324eb500a60c577623ccd4a58b1cbcf80 | sabal202/python_examples | /create_schedule/scheduler.py | 294 | 3.5 | 4 | class Teacher:
def __init__(self, name, lessons=None, rooms=None, ):
if rooms is None:
rooms = {}
else:
self.rooms = rooms
if lessons is None:
lessons = []
else:
self.lessons = lessons
self.name = name
|
a7ec92c6e9900261d5e73f0087b06257a5fb899b | sabal202/python_examples | /checkio/house-password.py | 1,087 | 3.6875 | 4 | # def checkio(data):
# import re
# matchObj = re.match("[a-zA-Z0-9^\.]+", data)
# if len(data) >= 10:
# if matchObj:
# if re.search("[a-z]+", data) and re.search("[A-Z]+", data) and re.search("[0-9]+", data):
# return (True)
# else:
# return (F... |
8cf070e385d27fbdba9687ef49fc01ed68884f69 | sabal202/python_examples | /examples/all_fibonacci_smaller_N_yield.py | 175 | 4.15625 | 4 | def fibonacci(max):
a, b = 1, 1
while a < max:
yield a
a, b = b, a + b # concurrent assignment
N = int(input())
for n in fibonacci(N):
print(n)
|
971d7cc255e81e7155724ee958827ba59487fe8d | aleksolberg/astar | /Astar.py | 3,924 | 3.671875 | 4 | from Map import Map_Obj
class Node:
def __init__(self, pos):
self.pos = pos
self.parent = None
self.g = -1 # Initial values that will be given later
self.h = -1
self.f = self.g + self.h
def __eq__(self, other): # Added to know whether two nodes are the same
... |
1130f75f5ac3e9f015a8eead5a0e839618cc0598 | en0/aoc2019 | /03/kunningklown/solution.py | 5,136 | 3.796875 | 4 | """
read file
split data on line return file_line1 file_line2
split data on comma for both lines
iterate through each instruction for each line to create wire1 wire2
if points go from (0,0) to (0,3) line = (0,0),(0,1),(0,2),(0,3)
if r,l,u,d add number
"""
class TraceCircuit():
def __init__(self):
self._x... |
b481d9881d698c414fb8a88f44a6bdd85671d9bc | femosc2/oop-python | /Upp1/Inlamning1/untitled folder/app/ControlMachine.py | 1,143 | 3.609375 | 4 | from Ticket import Ticket
from Scale import Scale
class ControlMachine():
""" Blueprint for the Control Machine at the airport """
def __init__(self):
""" Not used """
pass
def checkWeight(self, weightLuggage):
""" Checks the weight of the luggage, returns True if it passes
... |
0ad9cb3066e0626354e5467dac0573740a2168fb | femosc2/oop-python | /Upp1/Labb2/Software.py | 1,449 | 3.671875 | 4 | # Import dependencies
from Product import Product
# Software (subclass)
class Software(Product):
"""
Creates a blueprint for the software of a product
"""
def __init__(self, software_type=""):
"""
Creates the software
"""
# Subclass specific attribute
self.softw... |
12188861d62d65783b2763969ed05ab83908b540 | femosc2/oop-python | /Upp2/inlämning2/Rank.py | 446 | 3.75 | 4 | class Rank():
""" Blueprint for creating a new Rank """
def __init__(self, rank_name):
""" Creates a new rank object """
self.rank_name = rank_name
def return_rank_strenght(self):
if self.rank_name == "master" or "lord":
return 3
elif self.rank_name == "knight" or... |
8ae8f0fd054918231eedb1a106169b014789b354 | femosc2/oop-python | /Case/hippo.py | 380 | 3.625 | 4 | from animal import Animal
class Hippo(Animal):
"""
Klass för flodhäst
"""
def __init__(self, rating, type_of_food, name):
super().__init__(rating, type_of_food, name)
def __str__(self):
return "Hippo: {name}, rating {rating}, favourite type of food {food}".format(name... |
52e2808669a96dbc8f0938a9805dc89180bdf86e | femosc2/oop-python | /Upp1/Labb2/Inventory.py | 2,854 | 3.9375 | 4 | from Software import Software
class Inventory():
"""
"""
def __init__(self):
"""
Not used
"""
pass
def create_product(self):
"""
Creates a new product
"""
product = Software()
return product
def add_product(self, product):
... |
7e903e0392ac80ffcd43643ddc7d36621a9fe775 | YSreylin/HTML | /1101901079/0012/Estring4.py | 238 | 3.8125 | 4 | '''Write a Python program to get string from a given string where all occurrences
of its first clear have been changed to $, except the first char itself'''
a = input('Enter the string : ')
b = a[0]
c = a.replace(b,'$')
print(b + c[1:])
|
f7d29dd1d990b3e07a7c07a559cf5658b6390e41 | YSreylin/HTML | /1101901079/0012/list.example.py | 697 | 3.78125 | 4 |
#create a list
a = [2,3,4,5,6,7,8,9,10]
print(a)
#indexing
b = int(input('Enter indexing value:'))
print('The result is:',a[b])
print(a[8])
print(a[-1])
#slicing
print(a[0:3])
print(a[0:])
#conconteation
b=[20,30]
print(a+b)
#Repetition
print(b*3)
#updating
print(a[2])
a[2]=100
print(a)
#membership
print(5 in a)
... |
8fb03986099aed7dc09c0cf491a1d1dddd126c79 | YSreylin/HTML | /1101901079/0012/Estring17.py | 227 | 3.859375 | 4 | ''' write a Python function to get a string made of 4 copies of the last two characters of a specified string
(length must be at least 2)'''
a = input('Enter the string:')
for i in range(4):
b = a[-2:]
print(b, end='') |
cc2ca652d4ef4f7b5b6f4198f1e92a6f3a85ad63 | YSreylin/HTML | /1101901079/list/Elist10.py | 289 | 4.21875 | 4 | #write a Python program to find the list of words that are longer than n from a given list of words
a = []
b = int(input("Enter range for list:"))
for i in range(b):
c = input("Enter the string:")
a.append(c)
for j in a:
d = max(a, key=len)
print("\n",d,"is the longest one")
|
3152d5cdf0beb6f28a100f7c14655543999ee3eb | YSreylin/HTML | /1101901079/Array/array2.py | 212 | 4.0625 | 4 | #write a python program to append a new item in the end of 9array
import array
a=array.array('i',[2,4,5,7,4])
print('Original array:',a)
b=int(input("Enter the number to be last in array:"))
a.append(b)
print(a)
|
b9c46bb06471ba540e4792008841158f132020d9 | YSreylin/HTML | /1101901079/0012/01.py | 184 | 4.125 | 4 | #this program is to find the area of rectangle
l = input("Enter the lengdth: ")
l = int(l)
b = input("Enter the breadth: ")
b = int(b)
A = l*b
print("The area of the rectangle is",A) |
97d96de1162239c5e135bc9ce921625b5c88a080 | YSreylin/HTML | /1101901079/Array/array.py | 242 | 4.40625 | 4 | #write python program to create an array of 5 integers and display the array items.
#access individual element through indexes.
import array
a=array.array('i',[])
for i in range(5):
c=int(input("Enter array:"))
a.append(c)
print(a)
|
7d6b9fc6ddd4a6cc4145d1568965666b48b030ed | YSreylin/HTML | /1101901079/0012/04.py | 204 | 4.125 | 4 | #this program is used to swap of two variable
a = input('Enter your X variable:')
b = input('Enter your Y variable:')
c=b
d=a
print("Thus")
print("The value of X is:",c)
print("The value of Y is:",d)
|
e7d9eedfe9e1f50b497fc212e48e1f3dc2b0547f | YSreylin/HTML | /1101901079/0012/16 fibonacci.py | 153 | 4 | 4 | #this program is to fine Fibonacci
x = int(input("Enter any number :"))
a = 0
b = 1
for i in range(1,x+1):
c = a + b
b = a
a = c
print(c)
|
1a1d300c97c45ce4e321530f3a30d296fe165bf2 | YSreylin/HTML | /1101901079/0012/Estring6.py | 394 | 4.25 | 4 | '''write a Python program to add 'ing' at the end of a given string (length should be at least 3).
If the given string already ends with 'ing' then add 'ly' instead.
if the string lenth of the given string is less then 3, leave it unchanged'''
a = input("Enter the word:")
x = a[-3:]
if len(a)>3:
if x=='ing':
... |
a96926b1acfbe74f04f9bc936e6797353cc0e1d7 | Abel-Fan/uaif1901 | /01python基础/day01.py | 5,197 | 3.734375 | 4 | # python 动态类型、强类型语言。
# 输入工具
# input获取的数据都是字符串类型
# string = input("请输入你的名字")
# print(type(string))
# 输出工具
# print("123")
# print("123","456",end="")
# print("123",456,1+2)
# 格式化输出
# print("我叫%s,我的年龄是%d,我的数学成绩%0.2f"%('horns',19,56.05))
# print("我叫%s"%'horns')
# 转义
# print("n\nn")
# 前缀
# r 后面的字符串都是普通字符串 类似于Linux ''
#... |
30ed610558484eccbb2c0b54bd42d963b768ddf2 | BkrmDahal/python-utili | /hangman.py | 4,634 | 4.25 | 4 | import random # To generate random number to choose from list
cont = "" # variable, if programmer want to exit or play new game
while(cont!="end"): # If user input is 'end', END game
print('''Hang man
Rule:
1. You have six ... |
3dbddfaf78bc9f945caf87c2a491c10227336dbc | nlub93/2048 | /game.py | 7,192 | 3.546875 | 4 | '''
Implementation of the Game2048 class that will handle the 2048 game
'''
import numpy as np
from random import randint
import copy
class Game2048(object):
def __init__(self, grid_dim=4):
'''
Initializes the grid of the game and the list of possible moves
grid_dim -- int
... |
bd3bb50a21f4a97feff4d9c26d5d6cbe5fed2098 | TaviusC/cti110 | /P2T1_SalesPrediction_TaviusCousar.py | 353 | 3.6875 | 4 | #Sales Prediction Program Excercise
#02/13/2019
#CTI-110 P2T1 - Sales Prediction
#Tavius Cousar
#
#Get the projected total sales.
total_sales = float(input('Enter the projected sales: '))
#Calculate the profit s 23 percent of tottal sales.
profit = total_sales * 0.23
#Display the profit
print('The profit ... |
4373addc9af220054ff54a7d6abb1073bf7a602d | TaviusC/cti110 | /P3HW2_MealTipTax_Cousar.py | 1,327 | 4.25 | 4 | # CTI-110
# P3HW2 - MealTipTax
# Tavius Cousar
# 2/27/2019
#
# Enter the price of the meal
# Display tip choices
# Enter the tip choice
# Calculate the total price of meal (price of meal * tip + price)
# Calculate the sales tax (charge * 0.07)
# Calculate the total (charge + sales tax)
# if tip == '0.15', '0... |
59c807425fc3d05a2492fd09fdd09b70b2ff82a7 | ImayaDismas/python-programs | /boolean.py | 622 | 4.125 | 4 | #!/usr/bin/python3
def main():
boo = (5 == 5)
print(boo)
print(type(boo))
print('logical operator AND')
#logical operator AND
a = (True and True)
print(a)
b = (True and False)
print(b)
c = (False and True)
print(c)
d = (False and False)
print(d)
print('logical operator OR')
#logical operator OR
... |
1b44a10019818a4b46e1639dec3a484b723e38d4 | ImayaDismas/python-programs | /for.py | 230 | 4.03125 | 4 | #!/usr/bin/python3
def main():
s = 'this is a string'
for letter in 'enumerate(s)':#iterate the string
print(letter)
for number in [1, 4, 5, 6, 8, 74, 70]:#iterate a list
print(number)
if __name__ == "__main__": main() |
e1c13d16cc8226be2806f49d504c660e227022d1 | ImayaDismas/python-programs | /assignments.py | 266 | 3.96875 | 4 | #!/usr/bin/python3
#/usr/bin/python3 path to the python3 interpreter
def main():
a, b = 0, 1
a, b = b, a # swapping the values
print(type(a), a)
print(a, b)
c = (1, 2, 3, 4, 5)
print(c)
d = [1, 2, 3, 4, 5]# list
print(d)
if __name__ == "__main__": main()
|
09e2ea08b77fa1a4e33180cac2ed46e872f281fb | ImayaDismas/python-programs | /variables_dict.py | 455 | 4.3125 | 4 | #!/usr/bin/python3
def main():
d = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5}
for k in sorted(d.keys()): #sorted sorts the alphabetically
print(k, d[k])
#using a different definition of the dictionaries
a = dict(
one=1, two = 2, three = 3, four = 4, five = 'five'
)#usually are mutable
a['seven'... |
11e1f9dcee5c9250ea37e16c7912003943139f41 | ImayaDismas/python-programs | /dictionaries.py | 410 | 3.875 | 4 | #!/usr/bin/python3
def main():
d = {'one' : 1, 'two' : 2, 'three' : 3}
print(d)
print(type(d))
x = dict(four = 4, five = 5, six = 6)
print(x)
y = dict(one = 1, two = 2, three = 3, **x)
print(y)
print('three' in x)
print('three' in y)
print(x.get('three'))
print(y.get('three'))
print(x.get('three', 'not ... |
2a153e14aca29d5b55753a7d992db199081d65a5 | Heansum/pythonStudy | /chapter6/ex_1_3.py | 204 | 3.78125 | 4 | print("비가 오나요? 온다면1, 오지않는다면 0을 입력하세요")
isRaining = input()
isRaining = int(isRaining)
if isRaining == 1:
print("우비를 입는다.")
print("나간다.") |
35f2ce7350e8510a99b335f70126c0cacd60adc9 | Heansum/pythonStudy | /chapter3/ex9_ex).py | 321 | 3.671875 | 4 | a = 17
b = 10
Result = a > b
print(Result)
ResultReverse = a < b
print(ResultReverse)
oddSum = 1 + 3 + 5 + 7 + 9
evenSum = 2 + 4 + 6 + 8 + 10
print(oddSum >= evenSum)
ResultSum = oddSum >= evenSum
print(ResultSum)
print("입력하세요 = ", end="")
num = int(input())
print((num % 2) == 1)
print((num % 2) != 0)
|
7cd2437d4e5894f02f3632d4f9b7638d2db10890 | Heansum/pythonStudy | /chapter6/ex_6_3.py | 231 | 3.796875 | 4 | condition = range(1, 11)
add = 0
for i in condition:
add = add + i
print(add)
forward = 2
for backward in range(1,10):
result = forward * backward
print("{} * {} = {}".format(forward, backward, forward * backward))
|
f1638d73d41ec23d595bc7ecccd2e6929524980b | Heansum/pythonStudy | /chapter5/ex_3_1.py | 952 | 3.703125 | 4 | '''
리스트는 요소를 추가 또는 삭제할 수 있다.
- 요소 추가 : append, insert
- 요소 삭제 : pop
'''
# 4명의 시험 성적
numberList = [14, 75, 32, 94]
# 전학온 학생의 성적
# 맨 뒤에 데이터를 저장
numberList.append(77)
print(numberList)
# 특정 인덱스에 데이터를 저장
numberList.insert(0, 59)
print(numberList)
# 맨 뒤 데이터 제거
deleteNumber = numberList.pop()
print("삭제한 데이터 = %d" % delet... |
202e649cad1b451ff939ee6db797cf5118c804c7 | Heansum/pythonStudy | /chapter5/ex_1_9ex).py | 600 | 3.734375 | 4 | # 0123456789
text = "Life is too short, You need Python"
print(text[6])
print(text[13])
print(text[9])
print(text[15])
print(text[16])
print(text[-1])
print(text[-2])
print(text[-9])
text = "python is easy"
print(text[-4])
print(text[-3])
print(text[-2])
print(text[-1])
# 양수 인덱스 번호와 음수 인덱스 번호를 적절히 사용해서
# 아래와 ... |
33d1ece186e92fac381da05dbef7fb51f4c77438 | Heansum/pythonStudy | /chapter5/ex_1_7ex).py | 394 | 3.734375 | 4 | front = "<" * 5
back = ">" * 5
print(front + "Python Class" + back)
# 강사님
# star = "*" * 3
# line = "_" * 3
# starLine = (star + line) *4
dot1 = "***"
dot2 = "___"
dot3 = "|"
line = (dot1+dot2) * 4
print(line)
print("|\t\t\t\t\t\t|")
print("|- 홈으로\t\t\t\t|")
print("|- 자기소개\t\t\t\t|")
print("|- 네이버로 이동\t\t\t|")
print... |
f039292139c345b2345191ea8629d6d8d96c2879 | asaladino/calc-ml | /src/helpers/helper.py | 1,338 | 3.515625 | 4 | from random import seed
from random import randint
from numpy import array
from sklearn.metrics import mean_squared_error
from math import sqrt
# generate training data
seed(1)
def random_sum_pairs(n_examples, n_numbers, largest):
x, y = list(), list()
for i in range(n_examples):
in_pattern = [randin... |
e39b73bec26b68021f750e747b5ea6b81cfe0090 | VRossi18/Uri | /Arquivos.py | 366 | 3.625 | 4 | #r - somente leitura
#w - escrita
#a - leitura e escrita (adiciona conteudo ao final do arquivo)
#r+ - leitura e escrita
#w+ - escrita (apaga conteudo anterior do arquivo)
#a+ - leitura e escrita (abre o arquivo para atualizacao)
arq = open("teste.txt", "a")
# linhas = arq.readlines()
# for linha in linhas:
# prin... |
7d6556e9845cb1f2a9f7bf69bf734a04aeec96ea | VRossi18/Uri | /1071.py | 262 | 3.71875 | 4 | num1 = int(input())
num2 = int(input())
lst = []
if (num1 < num2):
for i in range(num1 + 1,num2):
if (i % 2 == 1):
lst.append(i)
else:
for i in range(num2 + 1,num1):
if (i % 2 == 1):
lst.append(i)
print(sum(lst)) |
dbd05a2d95b1fd0bec3dc5bcb7fbf87f770ad4e2 | VRossi18/Uri | /1103.py | 303 | 3.546875 | 4 | import time
from datetime import datetime
while True:
h1, m1, h2, m2 = input().split(" ")
if h1 == 0 and m1 == 0 and h2 == 0 and m2 == 0:
break
t1 = datetime.strptime(h1+':'+m1, "%H:%M")
t2 = datetime.strptime(h2+':'+m2, "%H:%M")
d = t1 - t2
print((d.seconds) / 60) |
97e2ed39d5bfd434dcd87c0f43d0fe867d337f19 | RushabhBhalgat/Matplotlib-Exercise | /exercise_07.py | 596 | 3.78125 | 4 | '''
Exercise Question 7: Read the total profit of each month and show it using the
histogram to see most common profit ranges
'''
import matplotlib.pyplot as plt
import pandas as pd
dataFrame = pd.read_csv("Data\\company_sales_data.csv")
total_profit = dataFrame["total_profit"].tolist()
profit_range ... |
bdae561934abd145138fc361718e66b4112c74e5 | RushabhBhalgat/Matplotlib-Exercise | /exercise_06.py | 625 | 3.984375 | 4 | '''
Exercise Question 6: Read sales data of bathing soap of all months and show it using a bar chart.
Save this plot to your hard disk
'''
import matplotlib.pyplot as plt
import pandas as pd
dataFrame = pd.read_csv("Data\\company_sales_data.csv")
month_number = dataFrame["month_number"].tolist()
bathings... |
59ac8e2a6965a1fb10465ec4a1fd25152702bc4a | prachichouksey/Backtracking-2 | /78_Subsets.py | 1,135 | 3.78125 | 4 | # Leetcode problem link : https://leetcode.com/problems/subsets/
# Time Complexity: O(2^n)
# Space Complexity: O(n) for Backtracking
# Did this code successfully run on Leetcode : Yes
# Any problem you faced while coding this : No
# Your code here along with comments explaining your approach
'''
1. Start fr... |
8d97616974e1f09e2d6ff45fc264d5446c4dc640 | Clonexy700/BDO-Boss-Counter | /time_converter.py | 283 | 3.625 | 4 | from datetime import datetime, date, timedelta
import math
class TimeConverter():
def compare_times(self, hour1 = 0, minute1 = 0, hour2 = 0, minute2=0):
time1 = int(hour1) * 60 + int(minute1)
time2 = int(hour2) * 60 + int(minute2)
return time1 > time2
|
b82b98937531d24d563758c09aa98449b1e53a2a | guillau4/nonono | /StartMenu.py | 755 | 3.625 | 4 | from tkinter import *
def generate():
pass
def create():
pass
mw = Tk()
mw.title('The nononogram game')
#You can set the geometry attribute to change the root windows size
mw.geometry("200x150") #You want the size of the app to be 500x500
mw.resizable(0, 0) #Don't allow resizing in the x or y direction
#Ch... |
32fb48458a86d023fae4338173132a9bbd93c03e | parismollo/Liris | /knearest.py | 1,275 | 3.671875 | 4 | from typing import List, NamedTuple
from collections import Counter
from resources.linear_algebra import Vector, distance
# Let's pick a number k like 3 and then classify some new data point, we will look for the k nearest labeled points and let them vote
# however this won't be able to deal with ties...
def raw_major... |
adc054c3860e1ae745d68e103d12f3057fa6d797 | mctomee/Python_project | /dummy1.py | 170 | 3.546875 | 4 | x = "Elso python kodom"
print(x)
y = input("Adj meg egy számot")
if int(y)%2 == 0:
print('A beadott szám páros')
else:
print('A beadott szám páratlan')
|
7f5e84a1662fae425a61b3d57035b809afb6eadb | cracer/ProbSyllabifier | /GeneticAlgorithm/evaluation.py | 8,967 | 3.875 | 4 |
import operator
class Evaluation:
"""
In order to optimize the categorization scheme a way to
understand the data is needed. This class is the framework
to get why some phones are in the wrong category.
"""
def __init__(self):
self.correct_list = [] # lists of all the correct syllabif... |
278144e8d19ad06065719defc62f8b4c2e29c786 | Mansalu/python-class | /003-While/main.py | 1,093 | 4.34375 | 4 | # While Loops -- FizzBuzz
"""
Count from 1 to 100, printing the current count. However, if the count is
a multiple of 3, print "Fizz" instead of the count. If the count is a
multiple of 5 print "Buzz" instead. Finally, if the count is a multiple of both print
"FizzBuzz" instead.
Example
1, 2, Fizz, 4, Buzz, Fizz, 7,... |
cec2c6c5fe4f5f32b3ca019a8fcf2650e086c1e9 | Mansalu/python-class | /005-Functions/lec.py | 294 | 4.09375 | 4 | # Functions
def DoSomething():
"""
This is a function that does something. Takes no arguments, and doesn't return anything.
"""
count = 0
while (count < 10):
count += 1
print("Did something..")
print("This is a program that does something")
DoSomething()
|
b97e865252382e9e0c08bbc3380c045240f8981b | Mansalu/python-class | /001-Variables/main.py | 397 | 3.65625 | 4 | # Variables -- Mad Libs Game
print('Hello this is a MadLibs Game')
Name1 = input('Enter a Username: ')
print("Hello " + Name1)
print('The game has begun')
storySegment1 = 'I was walking my little'
storySegment2 = 'when I saw another dog'
userNoun = input('Enter a noun: ')
userVerb = input('Enter a Verb: ')
pri... |
998e9b05be535148db1a1cb1d33529ed07eeb85b | straicat/data-mining-assignment | /data.py | 619 | 3.59375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def load_csv(csv, features_type=float, target_type=int):
"""加载csv。最后一列为目标列,其余为特征。
Args:
csv: csv文件名
features_type: 特征的数据类型
target_type: 目标的数据类型
Returns: 特征, 目标
"""
features = []
target = []
for i, line in enumerate(o... |
f6d169357159034a0109a8218e6257bcf64e9f6d | cabhishek/python-kata | /min_number_subset_sum.py | 683 | 4 | 4 | """
Objective: Given a sorted array of positive integers, find out the smallest integer which cannot be represented as the sum of any subset of the array
Output: The smallest number which cannot be represented as the sum of any subset of the given array
Examples :
Array {1,1,3,4,6,7,9} smallest Number : 32
Array {1,... |
d741d285f023ad8223a5c095775a8d0b225f4b4a | cabhishek/python-kata | /loops.py | 1,045 | 4.3125 | 4 | def loop(array):
print('Basic')
for number in array:
print(number)
print('Basic + Loop index')
for i, number in enumerate(array):
print(i, number)
print('Start from index 1')
for i in range(1, len(array)):
print(array[i])
print('Choose index and start position')
... |
a1d66f9acca5ecd0062f9842e07a5158b109587b | cabhishek/python-kata | /word_break.py | 1,280 | 4.28125 | 4 | """
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
For example, given
s = "leetcode",
dict = ["leet", "code"].
Return true because "leetcode" can be segmented as "leet code".
"""
def word_break_2(word, dict):
for ... |
6b690f1edce84b158cbef7b24ec8f5d806f78b27 | barcza/piskvorky1d | /piskvorky.py | 2,344 | 3.71875 | 4 | import ai
from copy import deepcopy
# defaultni predpoklad
symbol_komplu = "o"
symbol_hrace = "x"
def nastav_symbol_hrace():
#hráč si vybere, co chce být
symbol = input("Chceš být kolečko nebo křížek? ")
while (symbol != "x" and symbol != "o"):
print("Křížek nebo kolečko, nic jiného.")
sy... |
053f2b33d7f5e6ab265a623245f0e23711eed590 | rtyner/python-crash-course | /ch4/buffet.py | 243 | 3.859375 | 4 | foods = ('steak', 'chicken', 'fish', 'potatoes', 'cake')
print("Foods availabile:")
for food in foods:
print(food)
foods = ('steak', 'chicken', 'fish', 'vegetables', 'pie')
print("New foods availabile:")
for food in foods:
print(food) |
ccab03270c7cb9333c8827462203174d3317622e | rtyner/python-crash-course | /ch6/person.py | 229 | 3.75 | 4 | person = {
'first_name': 'bob',
'last_name': 'bobbert',
'age': '69',
'city': 'tampa',
}
print(person['first_name'].title())
print(person['last_name'].title())
print(person['age'])
print(person['city'].title())
|
3aa596df3435c3b64df43d7a8ef91e6a77e84b4e | rtyner/python-crash-course | /ch5/voting.py | 205 | 4.0625 | 4 | age = 19
if age > 18:
print(f"You are {age}, therefore you are old enough to vote")
print("Have you registered to vote?")
else:
print(f"You are {age}, therefore you are not old enough to vote") |
5f371d8f22ba55b0ebd1b9131767ad2b52117058 | rtyner/python-crash-course | /ch8/t-shirt.py | 243 | 3.921875 | 4 | def make_shirt(size, text):
"""accepts size and text to print on a shirt"""
print(f"The size of your shirt is: {size} and the message is {text}")
make_shirt('XL', 'positional arguments')
make_shirt(size='M', text='keyword argument')
|
ec077fa4521bd2584b13d15fe3b3866dd4ff4fde | rtyner/python-crash-course | /ch5/conditional_tests.py | 337 | 4.34375 | 4 | car = 'mercedes'
if car == 'audi':
print("This car is made by VW")
else:
print("This car isn't made by VW")
if car != 'audi':
print("This car isn't made by VW")
car = ['mercedes', 'volkswagen']
if car == 'volkswagen' and 'audi':
print("These cars are made by VW")
else:
print("Not all of these cars... |
4db22d53a9e97ccdb7196e3883ff6fdc28d47651 | rtyner/python-crash-course | /ch4/pizzas.py | 124 | 3.6875 | 4 | pizzas = ['sausage', 'pepperoni', 'cheese']
for pizza in pizzas:
print(pizza)
print("Pizza might be my favorite food") |
eb47f9288f38b310416f9c65b4cbd989a591f23c | stefano-gaggero/advent-of-code-2019 | /intcomputer.py | 14,661 | 4.1875 | 4 | # -*- coding: utf-8 -*-
import numpy as np
"""
Intcode computer v.9.0 ---------------------------------------------
---------------------------------------------------
v day2
An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at the first integer (... |
7ded592f81014e2d08ad78055ae07d605f693b30 | stefano-gaggero/advent-of-code-2019 | /2019-11.py | 4,235 | 4.3125 | 4 | import intcomputer as cmp
import numpy as np
import matplotlib.pyplot as plt
import operator
"""
--- Day 11: Space Police ---
Part 1:
You'll need to build a new emergency hull painting robot. The robot needs to be able to move around on the grid of square panels on the side of your ship, detect the color of ... |
005883b55d81dcccf7006211f46915e9ef903545 | stefano-gaggero/advent-of-code-2019 | /2019-09.py | 1,654 | 3.625 | 4 | import numpy as np
import intcomputer as cmp
"""
--- Day 9: Sensor Boost ---
Int Computer v.9.0
Part 1:
The BOOST program will ask for a single input; run it in test mode by providing it the value 1. It will perform a series of checks on each opcode, output any opcodes (and the associated parameter modes) tha... |
d373a26973f252e8fb0c0899e3c58a000febba51 | andrea2111/programmeringskurs-arbis-19 | /hangman.py | 682 | 3.9375 | 4 | import random
print ("Welcome to Hangman!")
wordlist = ["apple", "house", "python", "download", "secret"]
word = random.choice(wordlist)
turns = 10
guesses = ""
while turns > 0:
failed = 0
for char in word:
if char in guesses:
print (char, )
else:
print ("_", )
... |
eac124e0bdbb8de511f0857e01877b2dfa76b8a7 | andrea2111/programmeringskurs-arbis-19 | /ny_hangman.py | 765 | 3.78125 | 4 | import random
words = ["house", "blaze", "jelly", "check"]
clue = ["?", "?", "?", "?", "?"]
lives = 7
correct_word = random.choice(words)
print("Här är det hemliga ordet: ")
def check_guess(guess, correct_word, clue):
global lives
if guess not in correct_word:
print()
print("Fel!")
lives -= 1
el... |
de848d25b4b3e7b1f78e07e67a778db45e9cc2f5 | stephanbos96/programmeren-opdrachten | /school/les4/finalassigment.py | 870 | 3.625 | 4 | def standaardprijs(afstandKM):
if eval(afstandKM) <50:
prijs = 0.80*eval(afstandKM)
elif eval(afstandKM) >= 50:
prijs = 15 + (eval(afstandKM)) * 0.6
return prijs
def ritprijs(leeftijd, weekendrit, prijs):
if weekendrit.lower() == 'ja':
if eval(leeftijd) < 12 or eval... |
62bef3e72ed9c8657733962cbcf843797c95afaf | stephanbos96/programmeren-opdrachten | /school/les5/5.5.py | 245 | 3.53125 | 4 | def gemiddelde(randomzin):
total = 0
avg = randomzin.split()
for i in avg:
total += len(i)
ave_size = float(total) / float(len(avg))
print(ave_size)
gemiddelde(input('Typ hier een willekeurige zin in: '))
|
3b2cde9890b4f8995844880d7ae9d3116d0b6906 | matthewblue177/cheese | /cheeseOrder.py | 1,244 | 3.984375 | 4 | # Price per pound $10
# Min amount - 5 pounds
# Max ammound - 100 pounds
import time
def cheeseOrder(cheese):
int(cheese)
total = int(cheese) * 10
return str(total)
valid = 0
while valid == 0:
cheeseAmount = input ('How much cheese would you like in lbs? : ')
if int(cheeseAmount) < 5:
prin... |
914e014705649ee5bc06ce54ae0e87731f4c6a4f | vittoriocolombo11/deep_learning | /CNN_art_movement_classification/Web_scraping/help_functions.py | 2,796 | 3.53125 | 4 | import unicodedata
import re
import os
def artist_name_cleaner(txt):
"""
A function that cleans the name of the artists
Input: str
Output: str
"""
# here I deal with numbers, special charachters and other noise
step1 = re.sub("[0-9]","", txt).replace("Dezember", "")
step... |
08f01c99705b6f17b420406778577ffe50dd740f | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/Tim/classesDemoSub.py | 279 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 19 19:19:47 2019
@author: TimLaptop
"""
class Sphere(C):
def Circumfrence(self):
pass
def Area(self):
return 4*self.Radius**2*Sphere.pi
def Volume(self):
return 4*self.Radius**2*Sphere.pi/3
|
bd513b735177df6635a633a82f11da4875e33818 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/eoner/lesson03/list_lab.py | 3,530 | 4.1875 | 4 | #!/usr/bin/env python3
# Create a list that contains “Apples”, “Pears”, “Oranges” and “Peaches”.
# Display the list (plain old print() is fine…).
# Ask the user for another fruit and add it to the end of the list.
# Display the list.
# Ask the user for a number and display the number back to the user and the fruit cor... |
2f944815a0bcb8b2c9dc397e9c0065e16012f814 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/eoner/lesson04/mailroom02.py | 4,378 | 3.828125 | 4 | #!/usr/bin/env python3
import sys
import os
donors = {'William Gates': [65784.49, 1000.50], 'Mark Zuckerberg': [163.10, 30000, 20000.30], 'Jeff B': [
877.33], 'Paul Allen': [767.42, 780, 444.20], 'Shantanu Narayen': [1000, 500.33, 3434,34]}
# ex append donors['Mark Z'].append(2435353.23)
# len(donors['Mark Z'])
#... |
806a233934191291a50ee7246b36b6f630d5b1f3 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/ben_carter/lesson02/gridprinter.py | 650 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 22 19:43:56 2019
@author: bclas
"""
def grid_print(x,y):
"""Fuction takes a two arguments x, for the size of the cells and y for how
many cells tall/wide the grid should be. and prints said grid.
"""
height = y
width = x
row_width = ("+" + "-" * wi... |
46014b4658b2f2d42756056a77ac518bb7e1cfd3 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/matthew_denko/lesson09/cli_main.py | 6,077 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 4 18:18:52 2019
@author: matthewdenko
"""
# mailroom OOO description ----------------------------------------------------
"""Goal: Refactor the mailroom program using classes to help organize the code.
The functionality is the same as the earlier ... |
c2b5e80c4735d3a1bca3c5255f2694f649d73aa4 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/joejohnsto/lesson05/except_lab.py | 309 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 5 18:54:41 2019
@author: joejo
"""
def safe_input(prompt: str):
try:
user_input = input(prompt)
except KeyboardInterrupt:
return None
else:
return user_input
if __name__ == "__main__":
safe_input("gimme some input: ") |
89573fb8b24671dd322e22c6dfcfabea58d578ed | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/kclark75/assignment07/untitled0.py | 570 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 1 18:43:13 2019
@author: kenclark
Class: Python 210A-Fall
Teacher: David Pokrajac, PhD
Assignment -
"""
from math import pi
class Circle(object):
def __init__(self, r):
self.radius = r
def area(self):
return se... |
144ec22d3a30e82f7189eafcfe914c1273b5e318 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/bishal_gupta/lesson03/stringformat_lab.py | 2,174 | 3.84375 | 4 | #!/usr/bin/env python3
"""
Created on Tue Oct 29 17:24:46 2019
@author: Bishal.Gupta
"""
#Task one
#Input string: ( 2, 123.4567, 10000, 12345.67)
#Expected Output string: file_002 : 123.46, 1.00e+04, 1.23e+04
def string_format_using_format(n):
#print ('file_{:03}) : {:.2f}, {:.2E}, {:.2E}' .format(2, 123.4567,... |
2eb736cd7710cb8cb0d40559fb7998c404f4369f | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/jammy_chong/lesson02/Grid_printer.py | 1,447 | 3.765625 | 4 | #Part 1
def grid_printer():
horizontal_line = '+ - - - - + - - - - +\n'
vertical_line = '| | |\n'
print((horizontal_line + vertical_line*4)*2 + horizontal_line)
#Part 2
def print_grid(n):
#repetition factor considering even integer
f = int(n/2)
dash = '- '*f
empty_str = '... |
459296454fc77306edd0e7f07141b200422f5e9b | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/Tommy Aguilu/Circle Homework.py | 1,156 | 3.921875 | 4 | import math
class C:
def __init__(self,r):
self.Radius=r
def Circumference(self):
return self.Radius*math.pi
def Area(self):
return self.Radius**math.pi
def Diameter(self):
return self.Radius*2
class Sphere(C):
def Volume(self):
return ((4/3)*mat... |
2dacaa57afbcab6d50addc6ce02b478978d0e5be | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/joejohnsto/lesson05/comprehension_lab.py | 2,795 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 5 19:30:50 2019
@author: joejo
"""
# List Comprehension
feast = ['lambs', 'sloths', 'orangutans',
'breakfast cereals', 'fruit bats']
comprehension = [delicacy.capitalize() for delicacy in feast]
assert comprehension[0] == 'Lambs'
assert comprehension[2] ... |
a86e0a0a983e97e66226b3254d26da64e24ce6e0 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/eoner/lesson03/trigram.py | 1,861 | 3.78125 | 4 | path = 'sherlock.txt'
list_text = []
# list of excepted characters
white_list= list("1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'")
dictionary_output = {}
#import file, clean up line breaks
def import_text():
with open(path,'r') as f:
text = f.read().replace("\n", " ")
return text
... |
0c04919a425328f8a1dfcf7e612a6d8f1780e61d | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/matthew_denko/lesson03/slicing_lab.py | 1,731 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 28 15:08:38 2019
@author: matt.denko
"""
"""Write some functions that take a sequence as an argument, and return a copy of that sequence:
with the first and last items exchanged.
with every other item removed.
with the first 4 and the last 4 items... |
33105a87ecb8bafa945500eca2c335ddfd792a40 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/K_Shaffer/lesson02/series.py | 2,828 | 3.9375 | 4 | '''
Series
Dev: K. Shaffer
Date: 10/20/18
'''
def fibonacci(n):
valCounter = 2
fibNum = 0
# Returns first two hardcoded sequence values and zeroith term used in reccursion
if n == 1 or n == 0:
fibNum = 0
if n == 2 or n == 3:
fibNum = 1
# Reccursive call to step through the ser... |
a76f7b7ffa78882b847d3c849913fddab3d44803 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/eoner/lesson03/strformat_lab.py | 2,525 | 3.921875 | 4 |
# Task One
# ( 2, 123.4567, 10000, 12345.67) > 'file_002 : 123.46, 1.00e+04, 1.23e+04'
t = (2, 123.4567, 10000, 12345.67)
def task_one(t):
return ("file_{:03d} :{:9.2f}, {:.2e}, {:.2e}".format(*t))
print(task_one(t))
# Task Two
def task_two(t):
return f"file_{t[0]:03d} :{t[1]:9.2f}, {t[2]:.2e}, {t[3]:... |
c51a2d5a7e54f0b5ec40a8da18a21f62f5fa9479 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/Tommy Aguilu/list_lab.py | 1,915 | 4.03125 | 4 | ### Author - Tommy Aguilu
### Version 1.0
### Class - Python 210A
#task1
fruits = ["apples", "pears", "oranges", "peaches"]
def fruit_loops(x):
b=0
for i in x:
print(((str(b+1)+".")+ x[b]))
b+=1
def fruit_sort(x):
print("Fruits starting with p")
for i in x:
if i[... |
c44d92d408d409101a971d72985d65841f5b0874 | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/Tim/Tim/lesson03/slicingSequences.py | 1,449 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 28 16:17:40 2019
@author: TimLaptop
"""
import copy as copy
def exchange_first_last(seq):
return copy((seq[-1] + seq[1:len(seq)-1] + seq[:1]))
def remove_every_other_item(seq):
new_seq = seq[0::2]
return new_seq
def remove_firstFour_lastFour_everyOther(s... |
3ab9ecbc514eef531f93ace9329960feaf51e60a | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/eoner/lesson01/break_me.py | 668 | 4.03125 | 4 | # Eddie Oner Python | PYTHON 210 A Lesson 01 | Activity: Python Pushups Part 1 of 2
# Each function, when called, should cause an exception to happen
# Each function should result in one of the four most common exceptions you’ll find.
# for review: NameError, TypeError, SyntaxError, AttributeError
def NameError():
... |
bcc3fc02a7a482d4f67e0a3969686b1ef296ee0a | UWPCE-PythonCert-ClassRepos/Python210_Fall2019 | /students/Tommy Aguilu/Mailroom4_Test.py | 1,853 | 3.71875 | 4 | donor_raw = {"Mark Zuckerberg" : [32432, 38475, 7845], "Jeff_Bezos" : [23424, 234324, 444432, 222341], "Paul Allen" : [23424, 234324, 44432, 2341], "Melinda Gates" : [3432, 26524, 44432, 22741]}
#key = donor, values = all donations
donor_processed = []
def list_reader(list1):
print("Donor Name | Tota... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.