blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
4c8921d466f8d85e6327678bf2ea08fe613a2a68
piyus22/AlphaBionix
/Basic_code/element_wise_comparison.py
630
4.09375
4
#By- Piyus Mohanty #Write a NumPy program to create an element-wise comparison (greater, greater_equal, less and less_equal) of two given arrays import numpy as np a=np.random.randint(100,size=(3,4)) b=np.random.randint(100,size=(3,4)) print("array 1 contents are:",a) print("array 2 contents are: ",b) print("The greate...
e578a442efdd0a888a2d79c4b93bdbbe2b16e063
meniscus/AtCoder
/ABC/ABC068/B.py
258
3.671875
4
import math N = int(input()) # 実際Nもいらない for i in range(N) : if (N == 1) : # この実装が汚い。。。 print(1) break if (N < math.pow(2,i)) : print(int(math.pow(2,i-1))) break
b2b53a66d1c3fe3767626ddf3343e9c5a42ff3a4
meniscus/AtCoder
/ABC/ABC015/A.py
121
3.5625
4
# あ in_str1 = input() in_str2 = input() if len(in_str1) > len(in_str2) : print(in_str1) else : print(in_str2)
6a39d9c02444a887957b2e07fb3b9144abbb6283
meniscus/AtCoder
/ARC/ARC012/A.py
269
4.25
4
day = input() if (day == "Sunday" or day == "Saturday") : print(0) elif (day == "Monday") : print(5) elif (day == "Tuesday") : print(4) elif (day == "Wednesday") : print(3) elif (day == "Thursday") : print(2) elif (day == "Friday") : print(1)
13cbdc603f01aa7e0b9ff35950866f7a31648b42
meniscus/AtCoder
/ABC/ABC022/A.py
330
3.546875
4
import math # あ read_line = input().split() days = int(read_line[0]) under_limit = int(read_line[1]) upper_limit = int(read_line[2]) best_body_days = 0 weight = 0 for i in range(days) : weight += int(input()) if (under_limit <= weight and weight <= upper_limit) : best_body_days += 1 print(best_bo...
5ca98b1ff75d93592d2756824fc3eb5ce2395caf
meniscus/AtCoder
/ABC/ABC079/C.py
535
3.75
4
# きたない。。。。 def get_formula(a,b,c,d) : for f1 in range(2) : s = str(a) if (f1 == 0) : s += "+" else : s += "-" s += str(b) for f2 in range(2) : s2 = s if (f2 == 0) : s2 += "+" else : s2 += "-" s2 += str(c) for f3 in range(2) : s3 = s2 if (f3 ==...
44ffcc2491c3125de360b808bb77e39ec4a41d10
meniscus/AtCoder
/ABC/ABC103/B.py
193
3.734375
4
S = input() T = input() is_okay = False for i in range(len(T)) : if (S == T) : is_okay = True break T = T[1:] + T[0] if (is_okay) : print("Yes") else : print("No")
acca4b660e319e5e6ecf8a85a171c1253b86d0dd
meniscus/AtCoder
/ABC/ABC001/B.py
285
3.703125
4
meter=int(input()) kilometer = meter / 1000.0 if meter < 100 : ans=00 elif meter <= 5000 : ans = kilometer * 10 elif meter <= 30000: ans = kilometer + 50 elif meter <= 70000: ans = int((kilometer-30) //5 + 80) else : ans=89 s = '%02d' % ans s = s[0:2] print(s)
52ca8637ddfd548c38794cfd356ea32b617e6611
meniscus/AtCoder
/ABC/ABC011/C.py
756
3.671875
4
def main() : N = int(input()) NG1 = int(input()) NG2 = int(input()) NG3 = int(input()) NG = [NG1,NG2,NG3] if (N in NG) : print("NO") return count = 0 while True : if (N == 0) : break if (N-3 not in NG and N >= 3) : ...
0dc5e8f746b8b47a3713b3d966f932dffe8e0198
meniscus/AtCoder
/ABC/ABC086/B.py
129
3.640625
4
import math a,b = input().split() n = int(a + b) if (math.sqrt(n).is_integer()) : print("Yes") else : print("No")
44ea05fa94fab3758aba1b5e04d258abdfa13d02
meniscus/AtCoder
/ABC/ABC009/B.py
289
3.71875
4
# あ dish_count = int(input()) price_list = [] for i in range(dish_count) : price_list.append(int(input())) price_list.sort() price = price_list[-1] for current_price in price_list[::-1] : if (current_price != price) : price = current_price break print(price)
fa37bcbb0cc8facf64ace865e43b68a91fca7d1d
saurav-singh/CS380-AI
/Assignment 3/connect3.py
9,545
3.578125
4
import math import random import sys import time CONNECT = 3 COLS = 4 ROWS = 3 EMPTY = ' ' TIE = 'TIE' PLAYER1 = 'X' PLAYER2 = 'O' class Connect3Board: def __init__(self, string=None): if string is not None: self.b = [list(line) for line in string.split('|')] else: self....
6bafbfbbf5306c1daa9bf05643d7e75c6933f2eb
TonnyL/MyPythonLearnProject
/customized_class.py
7,745
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 定制类 # 看到类似__slots__这种形如__xxx__的变量或者函数名就需要注意,在python中是有特殊用途的 # __slots__我们已经知道怎么用了,__len__()方法我们也知道是为了能让class作用于len()函数 # 除此之外,python的class中还有很多这样有特殊用途的函数,可以帮助我们定制类 # __str__ # 我们先定义一个Student类 class Student(object): def __init__(self, name): self.name = name ...
92419ef8e44be3168761d2b5b043d4cc22f9b0cf
TonnyL/MyPythonLearnProject
/handle_error.py
6,259
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 错误处理 # 在程序运行过程中,如果发生了错误,可以实现约定返回一个错误代码 # 这样就可以知道是否出错,以及出错的原因 # 用错误码表示是否出错十分不便,因为函数本身应该返回的正常结果和错误码混在一起 # 造成调用者必须用大量的代码判断是否出错 # 在java中,可以使用try...catch...finally语句捕获错误 # 在python中也可以try...catch机制 try: print 'try...' r = 10 / 0 print 'result:', r except ZeroDivisi...
9cd1139f3d2331ef93f33c0167f986476fc25168
TonnyL/MyPythonLearnProject
/debug.py
3,044
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 调试 # 程序能一次运行成功的概率很小,总是会各种各样的错误 # 有的错误很简单,看看错误信息就能解决,有的bug很复杂,我们需要知道出错时,哪些变量的值时正确的 # 哪些变量的值时错误的,因此,需要以一整套的调试程序来修复bug # 第一种方法简单粗暴有效,就是直接print把可能出错的bug值打印出来 # def foo(s): # n = int(s) # print '>>> n = %d' % n # return 10 / n # # def main(): # foo('0') # # m...
66da83e7687f9d598add37baee9aecf6ff44c10a
shfhm/Practice-Python
/Check Power of 2.py
226
4.40625
4
#function that can determine if an input number is a power of 2 import math def sqrtt(x): i=math.sqrt(x) if i**2==x: print('the input is power 2 of %s' %(i) ) else: print('it\'s not the power 2')
6951253d9c50aa9b9c7f7382b3084128cd299c16
shfhm/Practice-Python
/Symmetric binary tree.py
1,151
3.953125
4
#symmetric binary tree. Given a binary tree, check whether it is a mirror of itself. #Runtime: 44 ms from collections import deque class treenode(object): def __init__(self, root): self.val=root self.left=None self.right=None class solution(object): def symmetric(self, root): ...
4ac23cb0e3f3a32bbbb9af3482a830619d358a0f
shfhm/Practice-Python
/Game-Guess.py
305
4.0625
4
__author__ = 'Sahar' from random import randint random_number = randint(1, 8) print(random_number) guesses_left = 3 while guesses_left >= 0: guess=int(input("gues a number: ")) if guess==random_number: print("you win!") break guesses_left = guesses_left -1 else: print ("you lose!")
c4d2a86f4345f182b2f795745239848eea347665
Cjmacdonald/AI-Revised
/AI-Spring2018-HW1/tictactoePy/MyAgent.py
6,901
3.59375
4
import random from Const import Const from Move import Move from State import State """This agent prioritizes consecutive moves by placing marks on spots that are next spots that already have marks on them otherwise it defaults to random playable spots""" class MyAgent: def __init__(self): pass def m...
2e70910939fedcde1d3c98da05618a8ff871abd0
diego-ponce/code_snippets
/code_challenges/sort_stack.py
1,380
4.15625
4
def pop_until(fromstack, tostack, val): ''' pops from fromstack onto tostack until val is greater than the last value popped. Returns the count of items popped. ''' count = 0 while fromstack: if fromstack[-1] < val: return count pop_val = fromstack.pop() tosta...
cf720b2093c9c009d76c3ea8c4bfba9f4f65f80c
sag-coder/python_test
/commend.py
642
3.828125
4
##insert i e: Insert integer at position . ##print: Print the list. ##remove e: Delete the first occurrence of integer . ##append e: Insert integer at the end of the list. ##sort: Sort the list. ##pop: Pop the last element from the list. ##reverse: Reverse the list. #input #12 #insert 0 5 #insert 1 10 #insert 0 6 #p...
dcd7e05257407fdddf7ff13f2fe19a2fe4f50c43
KUHZ/papercode
/vnode.py
1,023
3.84375
4
#video node import turtle import math p1 = math.sqrt(3) p2 = 1 + p1 vpos = []#position of Vnode class VNode(): def __init__(self,level,angle,radius,px,py): self.level = level self.radius = radius self.angle = angle #vision of video node self.px = px #position x ...
ae56bc91c4fe03e9d6e2066aa43858cf2b3c63b1
houxianxu/learnToProgramCoursera
/week4/a2.py
2,929
4.34375
4
#!/usr/bin/python3.2 def get_length(dna): """ (str) -> int Return the length of the DNA sequence dna. >>> get_length('ATCGAT') 6 >>> get_length('ATCG') 4 """ return len(dna) def is_longer(dna1, dna2): """ (str, str) -> bool Return True if and only if DNA sequence dna1 is lo...
31f8f6c8e86fa995259a94e0d0eb8f0f38aa002b
abdulbasit01/hello-pythonists
/final/basic.py
3,885
4.21875
4
#turtle graphics game import os import turtle import math#(when both object snake and their food touches each other then their distance is very small ) import random import time os.system("Main Tere Kabil Hoon ke nahi.mp3&") color_choice=["grey","red","yellow","blue","powder blue","brown","orange"] #launch turtle wi...
02940a7a9b30d9bf8c2587c9168544a40df35063
emmadeeks/CMEECourseWork
/week7/code/LV2.py
4,051
3.859375
4
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: LV2.py #Desc: Plots Consumer-resource population dybamics and runs the # Lotka-Volterra model for predator prey systems. This script is codifying the Lotka-Volterra model # for predator-prey system in two-dimensional space (e.g. on land). #Ar...
a54f2d23123a452a9a4b4ed7be2e1ea6cebf4b5b
emmadeeks/CMEECourseWork
/Week2/Code/lc1.py
2,225
4.65625
5
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: lc1.py #Desc: List comprehensions compared to for loops #Arguments: No input #Outputs: Three lists containing latin names, common names and mean body masses for each species of birds in a given list of birds #Date: Oct 2019 # Creates a list o...
3e953d2ae7128c97dcdad05b1f4dd97cbd58f77d
emmadeeks/CMEECourseWork
/Week2/Sandbox/comprehension_test.py
1,903
4.46875
4
## Finds list those taxa that are oak trees from a list of species #There is a range of 10 and i will run throough the range and print the numbers- remember it starts from 0 x = [i for i in range(10)] print(x) #Makes an empty vector (not vector LIST) called x and fils it by running through the range 10 and appendin...
0cca2868af0d5c598552626a20bdd749e57e2364
emmadeeks/CMEECourseWork
/Week2/Code/oaks.py
1,565
4.59375
5
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: oaks.py #Desc: Uses for loops and list comprehensions to find taxa that are oak trees from a list of species. #Arguments: No input #Outputs: Oak species from list #Date: Oct 2019 """ Uses for loops and list comprehensions to find taxa that are ...
da6312a74a8f3c722e9ec9abece7737a37cc83ca
shruti19/algorithms
/dp/longest_1s_sequence.py
876
3.890625
4
''' Given a binary array, find the index of 0 to be replaced with 1 to get maximum length sequence of continuous ones. Example: [0, 0, 1, 0, 1, 1, 1, 0, 1, 1] #=> position: 7 [0, 1, 1, 1] #=> position: 0 ''' def longest_1s_sequence(arr): length = len(arr) so_far_max_1s = 0 count_0 = new_start = 0 current_substit...
d3ec3a217a17c9ab7963663f0db285dfd80945e7
carinasauter/D04
/D04_ex00.py
2,018
4.25
4
#!/usr/bin/env python # D04_ex00 # Create a program that does the following: # - creates a random integer from 1 - 25 # - asks the user to guess what the number is # - validates input is a number # - tells the user if they guess correctly # - if not: tells them too high/low # - only lets th...
bcb342822398eb8de7542d6d833def1909d5e860
josue-arana/LeetCode_Challenges
/Queue_implementation_using_stacks.py
3,120
4.25
4
# ------ QUEUE IMPLEMENTATION USING TWO STACKS -------- # # By Josue Arana # Python Solution # ------- Personal Analysis --------- # # Time Complexity: push O(1), pop O(n), peek O(n), empty O(1) # Space Complexity: O(2n) ~ O(n) # ------- Leetcode Analysis --------- # # 17 / 17 test cases passed. # Status: Accept...
098556b0003a35c50a5631496c5d24c38a7c3e12
CODEvelopPSU/Lesson-4
/pythonTurtleGame.py
1,176
4.5
4
from turtle import * import random def main(): numSides = int(input("Enter the number of sides you want your shape to have, type a number less than 3 to exit: ")) while numSides >= 3: polygon(numSides) numSides = int(input("Enter the number of sides you want your shape to have, type a ...
1afc094e86c04fbbafa1dd7d910469975701b87d
JFelipeFloresS/hangman-python
/hangman.py
9,101
3.515625
4
import math from unicodedata import decimal from wordboard import * from getword import * import pygame pygame.init() win_width = 1200 win_height = 440 win = pygame.display.set_mode((win_width, win_height)) pygame.display.update() pygame.display.set_caption("Hangman") source_array = ["urban-dictionary", "vocabulary...
a1f1e5fc6243d15aea24089d9daeddd5afe444cf
MatteoZambra/dbn-pytorch
/deepbeliefpack/dataload.py
7,252
3.5625
4
import torch from torch.utils.data import DataLoader from torchvision.datasets import MNIST from torchvision import transforms class LoadDataset: """ Class LoadDataset. It serves the purpose of dowloading, preprocessing and fetching the data samples, divided in training set and testing set. Curr...
1e8206fcebc5ad8204a66de740ce76f7faae2ac7
Ninwk/coins
/coin_compare.py
2,279
3.703125
4
# coin_dir = [1, 1, 1, 1, 5] def sum_coin(co_list, fom, to): sum_co = 0 for i in range(fom, to+1, 1): sum_co += co_list[i] return sum_co def compare_coin(co_list, fom, to): """ :param co_list: 硬币列表 :param fom: 硬币列表起始位置 :param to: 硬币列表末尾 :return: 假币位置 """ # 硬币数 ...
4a7b9fdc7bb53519db54e26bb719bf42f9dc3a88
nikitosoleil/spos
/sem2/lab2/input/test.py
572
3.53125
4
for i in range(n): l.append(i) l = [] print l # comment s = "a\ns\td" + "q\"w\'e" s += 'z\'x\"c' class Test: def __init__(self): self.name = r"Nikita\n" def print_name(): print self.name f(a = 'b', # test c = 'c') a, b = b, a a, b = \ # test b, a a"asd" b"asd" br"asd" brr"asd" "...
b1a1148977a507874e0a6207c7fa2f96fddd3634
PaulGuo5/Leetcode-notes
/notes/0925/0925.py
482
3.640625
4
class Solution: def isLongPressedName1(self, name: str, typed: str) -> bool: it = iter(typed) return all(char in it for char in name) def isLongPressedName(self, name: str, typed: str) -> bool: #2 pointer i = 0 for j in range(len(typed)): if i < len(...
699784b89934f79c67bfbeec05b9c85ea1f2ab12
PaulGuo5/Leetcode-notes
/notes/1233/1233.py
890
3.703125
4
class TrieNode: def __init__(self): self.children = {} self.isWord = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): node = self.root for c in word: if c not in node.children: node.children[c] = TrieNode...
149d8d49621e091f522decd2c6285cfd9247c7f3
PaulGuo5/Leetcode-notes
/notes/0510/0510.py
963
3.8125
4
""" # Definition for a Node. class Node: def __init__(self, val): self.val = val self.left = None self.right = None self.parent = None """ class Solution: def inorderSuccessor(self, node: 'Node') -> 'Node': root = node while root.parent: root = root.p...
96d663f4c42eed9b518de30df4641407924a0490
PaulGuo5/Leetcode-notes
/notes/0079/0079.py
903
3.53125
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: if not board: return False def dfs(board, word, d, i, j): if i < 0 or i >= m or j < 0 or j >= n or board[i][j] != word[d]: return False if d == len(word) - 1: ...
8b203b94ff89a51de6000a59545ebd5deb0d8143
PaulGuo5/Leetcode-notes
/notes/0160/0160.py
1,614
3.71875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if not hea...
89912dfc338416f7a985cdd382c4da779d3e200b
PaulGuo5/Leetcode-notes
/notes/0489/0489.py
1,617
3.921875
4
# """ # This is the robot's control interface. # You should not implement it, or speculate about its implementation # """ #class Robot: # def move(self): # """ # Returns true if the cell in front is open and robot moves into the cell. # Returns false if the cell in front is blocked and robot sta...
644ed377fe62329bc292d81f1908370746abc72d
PaulGuo5/Leetcode-notes
/notes/1171/1171.py
991
3.609375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeZeroSumSublists1(self, head: ListNode) -> ListNode: dummy = ListNode(0) dummy.next = head pre, cur = dummy, dummy.next s = ...
06ca5f88badc833510d948f797ba3ffa9d1729b7
PaulGuo5/Leetcode-notes
/notes/0428/0428.py
1,306
3.640625
4
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: Node :rtype: str """ def wri...
f93b211cee00a0185c7f70fffcd2883a9973c7ca
PaulGuo5/Leetcode-notes
/notes/0863/0863.py
2,112
3.625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def distanceK1(self, root: TreeNode, target: TreeNode, K: int) -> List[int]: def buildParentMap(node, parent, parentMap): ...
564419f966715c913740af2744ed665b30c61305
PaulGuo5/Leetcode-notes
/notes/0276/0276.py
505
3.5
4
class Solution: def numWays(self, n: int, k: int) -> int: if n == 0 or k == 0: return 0 num_same = 0 # the number of ways that the last element has the same color as the second last one num_diff = k # the number of ways that the last element has differnt color from the second la...
e94a41481beeef420b3cad831090266fb7775f4b
PaulGuo5/Leetcode-notes
/notes/0415/0415.py
710
3.515625
4
class Solution: def addStrings1(self, num1: str, num2: str) -> str: return str(int(num1)+int(num2)) def addStrings(self, num1: str, num2: str) -> str: num1, num2 = list(num1)[::-1], list(num2)[::-1] if len(num1) < len(num2): num1, num2 = num2, num1 carry = 0 ...
c55fdc1ea3e7b95b97c8b67c65c70b51b30455c0
PaulGuo5/Leetcode-notes
/notes/0450/0450.py
1,629
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def deleteNode1(self, root: TreeNode, key: int) -> TreeNode: if not root: return None if root.val < key: ...
75680f7ad61eebf83e2bfd77ff485f05bf5d349c
PaulGuo5/Leetcode-notes
/notes/0241/0241.py
889
3.578125
4
class Solution: def diffWaysToCompute(self, input: str) -> List[int]: memo = {} def helper(s): nonlocal memo if s.isdigit(): return [int(s)] if s in memo: return memo[s] res = [] for i in range(len(s)): ...
9db57a02eacf67e84ed5fe85066bab851ced7dee
PaulGuo5/Leetcode-notes
/notes/0353/0353.py
1,593
4.03125
4
class SnakeGame: def __init__(self, width: int, height: int, food: List[List[int]]): """ Initialize your data structure here. @param width - screen width @param height - screen height @param food - A list of food positions E.g food = [[1,1], [1,0]] means the first f...
52c986eff0e4f4344b7cac878c78e9ac1d090dc1
PaulGuo5/Leetcode-notes
/notes/0606/0606.py
1,344
3.75
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def tree2str1(self, t: TreeNode) -> str: if not t: return "" res = "" def dfs(t): nonloca...
c7044b775497fb47b5523da21d9ea81b74c06af4
PaulGuo5/Leetcode-notes
/notes/0261/0261.py
1,177
3.53125
4
class Solution: def validTree1(self, n: int, edges: List[List[int]]) -> bool: if not edges and n == 1: return True if not edges and n > 1: return False def findRoot(x, tree): if tree[x] == -1: return x root = findRoot(tree[x], tree) tree[x] = root ...
e9cd76a7bab4ede9fd83c502936bba8886dbae58
PaulGuo5/Leetcode-notes
/notes/0520/0520.py
744
3.609375
4
class Solution: def detectCapitalUse1(self, word: str) -> bool: def isCaptical(c): return True if ord(c) >= ord("A") and ord(c) <= ord("Z") else False if not word: return True if isCaptical(word[0]): if len(word) > 2: tmp = isCaptical(word[...
822f9e35f09fd1753d62fe537b4714332118d983
User9000/100python
/ex79.py
266
4.0625
4
#python PAM while True: password=input("Enter password: ") if any(i.isdigit() for i in password) and any(i.upper() for i in password) and len(password) >= 5: print("Password is fine") break else: print("Password is not fine")
5b33ac0092e1896d53dfd8a3505aa9c8cee3c8e7
User9000/100python
/ex36.2.py
194
3.90625
4
def count_words(filepath): with open(filepath, 'r') as file: strng = file.read() strng_list = strng.split(" ") return len(strng_list) print(count_words("words1.txt"))
801628680f24f1ef38ca3223d958ccffbc501499
User9000/100python
/anyFunction.py
235
3.828125
4
#test the any function list1 = ['0','1','2','l'] if any(i=='2' for i in list1) and any(i=='1' for i in list1): print("found the number 2 and 1 are in list") lst = [-1, True, "X", 0.00001] print (any(lst))
aaf7c0d114a9c949659164425db1730be618abfe
Daksh-404/face-detection-software
/cvTut8.py
517
3.515625
4
import cv2 as cv import numpy as np faceCascade=cv.CascadeClassifier("haarcascade_frontalface_default.xml") img=cv.imread("girls.jpg") img_gray=cv.cvtColor(img,cv.COLOR_BGR2GRAY) faces=faceCascade.detectMultiScale(img_gray,1.1,4) for (x,y,w,h) in faces: cv.rectangle(img,(x,y),(x+w,y+h),(0,255,0),3) #t...
99e85c5259410181914a51738d33b51051e94769
LeafNing/Ng_ML
/ex6/plotData.py
662
3.953125
4
import matplotlib.pyplot as plt import numpy as np def plot_data(X, y): plt.figure() # ===================== Your Code Here ===================== # Instructions : Plot the positive and negative examples on a # 2D plot, using the marker="+" for the positive # examples ...
3935498828f083754296ad3cb7c587bf75c4870b
ArturAssisComp/ITA
/ces22(POO)/Lista1/Question_6.py
3,159
4.46875
4
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 6 ''' import sys import math #Functions: def is_prime (n): ''' Returns True if the integer 'n' is a prime number. Otherwise, it returns False. To determine if 'n' is not a prime number, it is enough to check if at least one of th...
d62805b6544a217f531eaf387853a7120c479d3f
ArturAssisComp/ITA
/ces22(POO)/Lista1/Question_7.py
1,115
4.125
4
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 7 ''' import sys #Functions: def sum_of_squares (xs): ''' Returns the sum of the squares of the numbers in the list 'xs'. Input : xs -> list (list of integers) Output: result -> integer ''' ...
590591e904740eb57a29c07ba3cf812ac9d5e921
ArturAssisComp/ITA
/ces22(POO)/Lista1/Question_4.py
1,580
4.15625
4
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 4 ''' import sys #Functions: def sum_up2even (List): ''' Sum all the elements in the list 'List' up to but not including the first even number (Is does not support float numbers). Input : List -> list (list of...
8cc600ad07e23adc4d7c9301bb46514e14af1dfa
ArturAssisComp/ITA
/ces22(POO)/Lista4/Questao1.py
1,292
3.78125
4
''' Author : Artur Assis Alves Date : 08/06/2020 Title : Simulador de Estradas ''' import abc #Classes: class VehicleInterface (): ''' Interface class for vehicles.''' def __init__(self, engine_class): self.engine = engine_class def description(self): return '{0}{1}.'.format...
58c1e655e91256c0e0aed84e0c61f4a7818434d9
zelenyid/amis_python
/km73/Zeleniy_Dmytro/9/task1.py
303
4.15625
4
from math import sqrt # Розрахунок відстані між точками def distance(x1, y1, x2, y2): dist = sqrt((x2-x1)**2 + (y2-y1)**2) return dist x1 = int(input("x1: ")) y1 = int(input("y1: ")) x2 = int(input("x2: ")) y2 = int(input("y2: ")) print(distance(x1, y1, x2, y2))
6a96dd141ed5a13b6db3c5ed99eaff71aa0b520e
PPL-IIITA/ppl-assignment-stark03
/Question9/q9.py
350
3.59375
4
from chooseFromBest import * def main(): """main function for question 9 , creates an object of class 'chooseFromBest' prints the formed couples , the changes are made in the log file 'logGifting.txt' durin the program""" c = formCouples() """here k is taken as 10 , any value can be taken.""" ...
0018b205b95c996cef5aebd214923a25ea765799
PPL-IIITA/ppl-assignment-stark03
/Question5/boyGenerous.py
1,589
3.671875
4
import operator from Boys import Boy class boyGenerous(Boy): """Boy class for boyType = 'Generous'""" def __init__(self, boy): """constructor , calls the parent constructor and initializes other attributes as:- happiness = happiness of the boy amountSpent = amount sp...
120b2ddee0cd72a20792ef669d58142fd7c9ce8b
touyou/CompetitiveProgramming
/codeforces/contest69/A.py
332
3.625
4
#! /usr/bin/env python def solve(n): len = 2^n sum = 0 for i in range(1, len-1): sum += i be = solve(n-1) ol = solve(n-2) sum = sum - (2^(n-1))^2 + be - ((2^(n-2))^2 - ol)*2 return sum def main(): n = int(raw_input()) ans = solve(n) print ans if __name__ == '__main__':...
e8e8e16d098d51ff7f49bb6e8d51e40e23e8bee9
shruti1502-hub/Detecting-Lanes-for-Self-Driving-cars
/FindingLanes.py
5,006
3.640625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import cv2 import numpy as np import matplotlib.pyplot as plt # # Edge Detection # To identify the boundaries in images-identifying sharp changes in intensity in adjacemt pixels or sharp changes in pixels # # At Edge- there is a rapid change in brightness # # Gradie...
b74253bc3566b35a29767cc23ceb5254cb303441
MailyRa/calculator_2
/calculator.py
1,093
4.125
4
"""CLI application for a prefix-notation calculator.""" from arithmetic import (add, subtract, multiply, divide, square, cube, power, mod, ) print("Welcome to Calculator") #ask the user about the equation def calculator_2(): user_input = (input(" Type your equation ")) num = use...
6a9febac0dcf6886c3337991eb7c5dde84ee281b
pdhawal22443/GeeksForGeeks
/GreaterNumberWithSameSetsOFDigit.py
2,055
4.15625
4
'''Find next greater number with same set of digits Given a number n, find the smallest number that has same set of digits as n and is greater than n. If n is the greatest possible number with its set of digits, then print “not possible”. Examples: For simplicity of implementation, we have considered input number as a ...
f3062465da0ac2bff8ce22f8dcff7bafd74057f7
pdhawal22443/GeeksForGeeks
/MaximumIntervalOverLap.py
1,068
3.9375
4
''' https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/ Consider a big party where a log register for guest’s entry and exit times is maintained. Find the time at which there are maximum guests in the party. Note that entries in register are not in any order. Example : Input: arrl[] = {1, 2,...
e70705f03982835e2c1c4a1a4a5e34fd34129ee0
richardfearn/advent-of-code-2020
/day4/parser.py
657
3.546875
4
def parse_input(lines): if isinstance(lines, str): lines = lines.strip().split("\n") passports = [[]] for line in lines: if line == "": passports.append([]) else: passports[-1].append(line) passports = [create_passport_from_lines(passport) for passport ...
6309ae5b9fd4a10573e61423afa5a7ef873a1531
richardfearn/advent-of-code-2020
/day9/__init__.py
1,677
3.53125
4
from collections import OrderedDict def is_valid(previous_numbers, number): for other in previous_numbers: complement = number - other if (other != complement) and (complement in previous_numbers): return True return False def part_1(numbers, preamble_length): numbers = conv...
73c52ebae85664b4145f09bf65d63bd2ed7fb090
ashwin4ever/Kaggle
/Competitions/digit_recognizer/digit_prediction_tf.py
2,238
3.765625
4
''' https://www.kaggle.com/c/digit-recognizer/data Digit Recognizer Kaggle This approach uses SVM to classify the digits Reference: https://www.kaggle.com/ndalziel/beginner-s-guide-to-classification-tensorflow/notebook ''' import numpy as np import pandas as pd import matplotlib.pyplot as plt import time impor...
9c843dcb57fce440936c61bd2a7b6cc7518cd748
notnew/sous-vide
/blinker.py
3,706
3.703125
4
from gpio import gpio from threading import Thread import queue import time class Blinker(): """ Blink an input pin on and off """ def __init__(self, pin_num): self.pin_num = pin_num self._messages = queue.Queue() self._thread = None self._hi_time = -1 self._low_time = 0...
d9de9c735a24f6256383bc7177d51ac9dfada273
ARTINKEL/Array-of-Integers-to-Array-of-Letters
/array-to-letters.py
514
3.84375
4
# Austin Tinkel # 11/29/2018 import string import random array = [] new_array = [] done = False counter = 0 def convert_array(array): for x in array: s = "" for _ in range(x): s += (random.choice(string.ascii_letters)) new_array.append(s) return new_array while (not done)...
99b88d0e90e10a4dce49beb5bbcedae95d246273
zhng1456/M-TA-Prioritized-MAPD
/ta_state.py
1,037
3.625
4
""" Created on Sat Apr 18 10:45:11 2020 @author: Pieter Cawood """ class Location(object): def __init__(self, col, row): self.col = col self.row = row def __eq__(self, other): return self.col == other.col and self.row == other.row def __hash__(self): re...
4c3c61ec0353feb7821188778870f572c0728265
dward2/BME547Class
/analysis.py
198
3.671875
4
# analysis.py import calculator seconds_in_hour = calculator.multiply(60, 60) second_in_day = calculator.multiply(seconds_in_hour, 24) print("There are {} seconds in a day".format(second_in_day))
1e0fefcd119ee2e1fe1587667b2bf410f1d22549
Cyzerx/Scripts
/Emails/scrap1.py
1,980
3.515625
4
# -*- coding: utf-8 -*- """ Python script to bulk scrape websites for email addresses """ import urllib.request, urllib.error import re import csv import pandas as pd import os import ssl # 1: Get input file path from user '.../Documents/upw/websites.csv' user_input = input("Enter the path of your file: ") # If input...
3cd646626ff4c5aa84e4161f76230552a076e25d
syedyshiraz/Hackerearth
/jadoo vs koba.py
280
3.59375
4
ch=str(input()) st='' for i in ch: if(i=='G'): st=st+'C' elif(i=='C'): st=st+'G' elif(i=='A'): st=st+'U' elif(i=='T'): st=st+'A' else: print('Invalid Input') st='' break print(st)
13833a9668f6038c37c212e04021c8173aa4f798
sklagat45/ml_Algorithms
/perceptron.py
1,847
3.90625
4
# P15/101552/2017 # SAMUEL KIPLAGAT RUTTO import numpy as np # initialise the weights, learning rate and bias np.random.seed(42) # Ensures that we get the same random numbers every time weights = np.random.rand(3, 1) # Since we have three feature in the input, we have a vector of three weights bias = np.random.rand...
e27c1d39c34b9dcb5391eb9ec24497ee34412e95
rizkisadewa/MachineLearningA-Z
/Part 2 - Regression/Section 6 - Polynomial Regression/polynomial_regression.py
2,302
3.515625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 22 10:28:44 2019 @author: rizky """ # Polynomial Regression # Import the Libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Import the dataset dataset = pd.read_csv('Position_Salaries.csv') # Make a matrix feature of the three indepen...
58c58dbaf3ad230ec20eded8beed69a34cb0d5bf
PawelKapusta/Python-University_Classes
/Lab10/queue_lib.py
544
3.75
4
class Queue: def __init__(self, elems=None): if elems is None: elems = [] self.items = elems def __str__(self): return str(self.items) def __eq__(self, other): return self.items == other.items def is_empty(self): return not self.items def is_full(self): return False def p...
4f52547a0a15a57c72290bf61d21eb11a18668f2
PawelKapusta/Python-University_Classes
/Lab8/task1.py
590
3.8125
4
def solve1(a, b, c): if a == 0: if b == 0: if c == 0: print("identity equation") else: print("No solutions") else: if c == 0: print("Solution: y = 0") else: print("Solution: y =", -c / b) else: if b == 0: if c == 0: print("Solution: x...
2d3272a23f8cb49bc5dfa00f5fb27286adff493e
PawelKapusta/Python-University_Classes
/Lab2/task14.py
624
3.921875
4
def replaceChar(word): return str(word).replace('.', '').replace(',', '') def theLongest(words): return max(words,key=len) line = "Python is a high-level programming language designed to be easy to read and simple to implement.\n" \ "It is open source, which means it is free to use, even for commercial ...
51a2e174e5c69fb89bdb07708a86c774c972a659
PawelKapusta/Python-University_Classes
/Lab3/task6.py
581
4.03125
4
output = "" try: firstSide = int(input("Write first side of rectangle: ")) secondSide = int(input("Write second side of rectangle: ")) except ValueError: print("Check your input, maybe you do not write a number") else: for index in range(2 * firstSide + 1): if index % 2 == 0: output ...
490b309f4fed53ab48b914a9a1b8c6fa8934e45f
PawelKapusta/Python-University_Classes
/Lab4/task7.py
259
3.875
4
returned = [] def flatten(seq): for item in seq: if isinstance(item, (list, tuple)): flatten(item) else: returned.append(item) return returned seq = [1, (2, 3), [], [4, (5, 6, 7)], 8, [9]] print(flatten(seq))
52fc107624d46f57e2b99394196053e444eb7136
PawelKapusta/Python-University_Classes
/Lab8/task4.py
387
4.15625
4
import math def area(a, b, c): if not a + b >= c and a + c >= b and b + c >= a: raise ValueError('Not valid triangle check lengths of the sides') d = (a + b + c) / 2 return math.sqrt(d * (d - a) * (d - b) * (d - c)) print("Area of triangle with a = 3, b = 4, c = 5 equals = ", area(3, 4, 5)) print("Area o...
8f8253c2114c5029661eb2660d200314bb7eacff
lucasrcz/Python-Exercises
/Python-01/exercicio 20.py
742
4.09375
4
# O mesmo professor do desafio anterior quer sortear a ordem #de apresentação do trabalho dos alunos. Faça um programa que #leia o nome dos quatro alunos e mostre a ordem sorteada import random from random import shuffle print('Bem vindo ao gerador de Listas Randômicas 1.0.') a1 = str(input('Digite o nome do segundo...
5614aa22786c0c72c3e4ec96a77904a54b67de3e
lucasrcz/Python-Exercises
/Python-01/exercicio 17.py
251
3.84375
4
from math import hypot oposto = float(input('Digite o comprimento do cateto oposto em M: ')) adj = float(input('Digite o comprimento do cateto adjacente em M: ')) print('O comprimento da hipotenusa é igual á {:.2f} M '.format(hypot(oposto, adj)))
023229ca86719b66aa7d8e1834631f284db9a88f
lucasrcz/Python-Exercises
/Python-01/Exercicio 28.py
259
3.984375
4
from random import randint print('Bem vindo ao jogo de adivinhação') n = int(input('Digite um número de 0 a 5: ')) m = randint(0, 5) if m == n: print('Você adivinhou o número, parabéns!') else: print('Você perdeu :(, tente novamente')
788b70df4320be219682ba0abd8697be77f8e3a6
Adinaytalalantbekova/pythonProject1
/homework_3.py
599
3.953125
4
letters = [] numbers = [] data_tuple = ('h', 6.13, 'C', 'e', 'T', True, 'K', 'e', 3, 'e', 1, 'G') for element in data_tuple: if(type(element)==str): letters.append(element) else: numbers.append(element) print(letters) print(numbers) numbers.remove(6.13) true = numbers.pop(0) letters.append(tru...
c2f0c2eb520f18c5235b3bef3ff87ca289723eb5
Adinaytalalantbekova/pythonProject1
/homework_2.py
773
4.03125
4
while True: number = int(input("Назавите код региона: ")) if number == 1: print('Бишкек') elif number == 2: print('Ош') elif number == 3: print('Баткен') elif number == 4: print('Жалал-Абад') elif number == 5: print('Нарын') elif number == 6: p...
fa1200aaf3d92da9b51a6c124967ab88c94378e5
Adinaytalalantbekova/pythonProject1
/lesson_2..py
922
3.765625
4
# Условные конструкции и Операторы сравнения, Булеаны, Циклы # !=, <,>, <=, >=, not, and, or count = 0 rounds = 12 while not count == rounds: count += 1 if count == 6: print('knock down, finish') continue print(count) # bool() # zero = False # one = True # number = 5 # user = int(inp...
cfa1a3bd23631be1d067659f5d8ebf674341cad5
soon-h/BaekJoon
/BaekJoonBasic/5622.py
234
3.890625
4
dial = ['ABC','DEF','GHI','JKL','MNO','PQRS','TUV','WXYZ'] word = input() time = 0 for unit in dial : for i in unit: for x in word : if i == x : time += dial.index(unit) +3 print(time)
f81eb55666cfbe6f99b59ddca4df58f3dfe04140
soon-h/BaekJoon
/BaekJoonBasic/2884.py
284
3.75
4
Hour,Min = input().split() Hour = int(Hour) Min = int(Min) if Min < 45: if Hour == 0: Hour = 23 Min = 60 - (45 - Min) print(Hour,Min) else: Hour -= 1 Min = 60 - (45 - Min) print(Hour,Min) else: Min -= 45 print(Hour,Min)
849402be8f503d46883dc5e8238821566b33598b
Rajatku301999mar/Rock_Paper_Scissor_Game-Python
/Rock_paper_scissor.py
2,350
4.21875
4
import random comp_wins=0 player_wins=0 def Choose_Option(): playerinput = input("What will you choose Rock, Paper or Scissor: ") if playerinput in ["Rock","rock", "r","R","ROCK"]: playerinput="r" elif playerinput in ["Paper","paper", "p","P","PAPER"]: playerinput="p" elif playerinput i...
f9ac9c75d756a1548225c139265206ffb70e3bfc
manzeelaferdows/week3_homework
/data_types.py
1,481
4.1875
4
str = 'Norwegian Blue', "Mr Khan's Bike" list = ['cheddar', ['Camembert', 'Brie'], 'Stilton', 'Brie', 'Brie'] tuples = (47, 'spam', 'Major', 638, 'Ovine Aviation') tuples2 = (36, 29, 63) set = {'cheeseburger', 'icecream', 'chicken nuggets'} dict = {'Totness': 'Barber', 'BritishColumbia': 'Lumberjack'} print(len(list))...
e36f1118cfbfd8ac36951fe666b499717c5a22b5
manzeelaferdows/week3_homework
/lotto.py
685
3.984375
4
import random #print(help(random)) lucky_numbers = input('please type in your 6 lucky numbers') lotto_numbers = [] for i in range(0, 6): number = random.randint(1, 50) while number in lotto_numbers: number = random.randint(1, 50) lotto_numbers.append(number) print(lotto_numbers) if lotto_numbers ==...
f4222eae8a9be74bd2a743bbb7ab0bb8c4300887
Gabyluu/Python-Proyectos
/#clasesObjetos.py
867
3.515625
4
#clasesObjetos.py class MixinsData(object); def__init__(self, user="anonimo", password="patito", port="1234", ost="localhost", db="sqlite3"); self.user = user self.password = password self.port = port self.ost = host self.db = db #metodos para recuperar datos de...
446c481634d6cf1cebf897533cfe9baaacce2c3e
plaetzaw/htx-immersive-01-20
/01-week/4-Thursday/lectureNotes/class.py
3,142
4.125
4
# Hello # Hello # Hello # count = 0 # while count < 3: # print('Hello') # count += 1 # alphabet = [1, 2, 3, 4, 5, 6, 7] # new_list = alphabet[2:5] # myVar = 1 # mvVar2 = 2 # def greeting(): # print("hello world") # if (myVar == 1): # print('Hello') # greeting() # def print_students(): # ...