blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f334927c7bda7ec3866e9e2f00bc8cf1c2fecd7f
fjdurlop/TallerArduinoPython2020-1
/Tkinter/Tkinter/place.py
667
3.546875
4
######################### #Método PLACE ##################### from tkinter import * ventana=Tk() label1=Label(ventana,text="Curso básico ") label1.place(x=10,y=10) e1= Entry(ventana,bd=5) e1.place(x=85,y=10) label2=Label(ventana,text="Curso intermedio") label2.place(x=10,y=50) e2=Entry(ventana,bd=5) e2.place(x=85,y...
97133e4e8a6007bccf5990e471f6b9d4521d8bde
jasmine2000/ri-bio-project
/patent_parser/input.py
6,240
3.8125
4
import re import pdfminer from pdfminer.high_level import extract_text # HELPER FUNCTIONS def parse_for_keywords(line, keywords): ''' Used during main loop of parse_doc to find key terms such as 'CPC' Short algorithm that iterates over line once, keeping track of consecutive matching letters example ...
a769bb7ac8fafba68b01c9b1487a8239af0ab905
jz3707/python_learning
/ch03/finallyException.py
1,489
3.953125
4
#!/usr/bin/env python # coding=utf-8 # finally exception def FinallyTest(): """ try中raise IndexError之后except没能捕获这个exception 系统会将这个exception临时保存起来 当finally执行结束的时候,临时保存起来的exception会再次被跑出 但是如果finally中有return,break,那么临时保存的exception就会丢失 从而导致异常屏蔽 所以这个function的结果是: i am starting.... ...
1af06733acf3556d31e53d92850318a81763f64b
yl2612/realtime-hw2
/reducer.py
656
3.5
4
import sys import re def ignore_case(str1, str2): return re.match(re.escape(str1) + r'\Z', str2, re.I) is not None word_count_dict = {"hackathon":0, "Dec":0, "Chicago":0, "Java":0} for line in sys.stdin: line = line.strip() (word, count) = line.split("\t") for key in word_count_dict: ...
460b17d937e8d23d42176423121ce744e0a52ee4
nicolehomeier/algorithms
/number_game.py
852
4.125
4
import random # get a number to play with def game(): secret_num = random.randint(1,10) guesses = [] maxg = 5 print("It's the Number Game! You have {} guesses.".format(maxg)) while len(guesses) < maxg: try: guess = int(input("Guess my number, it's an integer between 1 and 10: ")) exc...
4d2763cdab8b5c36e1acc987cfb08cd9c98413b7
ellezv/code_kata
/src/title_case.py
618
3.921875
4
"""Implementation of Title Case Kata on Code Wars.""" def title_case(title, minor_words=''): """Return a string of capitalized words with the exception of optional minor words.""" if title == '': return '' else: title_list = title.lower().split() minor_list = minor_words.lower().sp...
802c08eab7a70431d33af566ec61a96957e6815d
ellezv/code_kata
/src/jaden_case.py
219
3.59375
4
"""Implementation of Jade Casing String Kata from Code Wars.""" def jaden_case(str_): """Return a capitalized string.""" jaden_arr = [word.capitalize() for word in str_.split()] return ' '.join(jaden_arr)
5a3982c3590115df2bd86a88e0fd6a7096e6ceb6
sernst/kuber
/kuber/_types.py
369
3.5625
4
import typing def integer_or_string(value: typing.Any) -> typing.Union[None, int, str]: """Conversion for int_or_string types.""" if value is None: return None if isinstance(value, int): return value if isinstance(value, str): return value try: return int(value) ...
12e53998942957bf6e241b81a07e57c9a8caa056
razzaqjavaria/PySprint
/pysprint/core/bases/algorithms.py
2,219
3.9375
4
import numpy as np def longest_common_subsequence(x1, y1, x2, y2, tol=None): """ Given two datasets with x-y values, find the longest common subsequence of them including a small threshold which might be present due to numerical errors. This function is mainly used when two datasets's y values nee...
8175831cca11e17d4971169f6314247e4f4e243b
Liu-YanP/DataStructure
/DFS.py
1,016
4.0625
4
# 图的深度优先算法 graph = { 'A':['B','C'], 'B':['A','C','D'], 'C':['A','B','D','E'], 'D':['B','C','E','F'], 'E':['C','D'], 'F':['F'] } #深度优先算法 def DFS(graph,start_node): ''' 算法思路:建立一个堆栈,首先将起始点放入堆栈。若堆栈不为空,每次 取出栈顶的点,然后将取出点的相邻节点(不重复的)放入堆栈。直达堆栈 为空 ''' stack = [] stack.append(start_node) #将起始点放入 seen ...
13270166b1c7fbae255d52ed2167f5f7d2242701
Liu-YanP/DataStructure
/Merge_sort.py
819
3.84375
4
#并归排序 def merge_sort(alist): n = len(alist) if n<=1: return alist #二分分解 num = int(n/2) left = merge_sort(alist[:num]) right = merge_sort(alist[num:]) #合并 return merge(left,right) def merge(left,right): '''合并操作,将两个有序数组left[]和left[]合并成一个大的有序数组''' #left与right的下标指针 l,...
db3b872dbe2282f464958469079aaf0e11867bbb
angelusualle/algorithms
/cracking_the_coding_interview_qs/6/generate_prime_numbers_test.py
469
3.515625
4
import unittest from generate_prime_numbers import is_prime, generate_prime_numbers class Test_Case_Generate_Prime_Numbers(unittest.TestCase): def test_generate_prime_numbers(self): ans = generate_prime_numbers(100) print(len(ans)) for answer in ans: self.assertTrue(is_prime(ans...
c769c1bdb9bb15be2fbcf2fc46cbefc247e84478
angelusualle/algorithms
/cracking_the_coding_interview_qs/2.5/sum_lists.py
2,494
3.78125
4
class Linked_List(): def __init__(self, head): self.head = head class Node(): def __init__(self, data): self.data = data self.next = None # O(n) time and O(n) space def sum_lists_fwd(linked_list1, linked_list2): node1 = linked_list1.head node2 = linked_list2.head result = [...
a5803f601a9035dcad9098a3885b88dfe5eb3e83
angelusualle/algorithms
/cracking_the_coding_interview_qs/17.13/insert_spaces.py
832
3.609375
4
# O(n^2) time and O(n) space through memoization def insert_spaces(text, dictionary, cache={}): if not len(text): return (0, '') if text in cache: return cache[text] best = (float('inf'), None) for i in range(1, len(text) + 1): sub_sequence = text[0:i] if sub_sequence in ...
f5380d04aa55a74cba5da4ca1b0c4f27378bec6e
angelusualle/algorithms
/cracking_the_coding_interview_qs/17.12/convert_to_doubly_linked_list.py
846
3.9375
4
class Node(): def __init__(self, val): self.n1 = None self.n2 = None self.val = val def convert_to_doubly_linked_list_(root, left=True): if root is None or (root.n1 is None and root.n2 is None): return root l = convert_to_doubly_linked_list_(root.n1) if l is not None: ...
9387e6172807cc8b18f72287152be8c0824d82e9
angelusualle/algorithms
/cracking_the_coding_interview_qs/16.8/int_to_english.py
1,926
3.59375
4
import math def int_to_english(num): ans = '' if num > 999.999999e9: raise Exception('Error: too big') if num < 0: ans += 'negative ' num *= -1 tri_places = {9: 'billion', 6: 'million', 3: 'thousand'} tens_places = {9: 'ninety', 8: 'eighty', 7: 'seventy', 6: 'sixty', 5: 'fif...
8eae9e9f37aff1001a876dbbfff3c271ebc6414d
angelusualle/algorithms
/cracking_the_coding_interview_qs/4.3/get_linked_lists_by_depth_from_binary_tree_test.py
1,679
3.75
4
from get_linked_lists_by_depth_from_binary_tree import List_Node, Tree_Node, Linked_List, get_linked_lists_by_depth_from_binary_tree import unittest class Test_Case_Get_Linked_Lists_By_Depth_From_Binary_Tree(unittest.TestCase): def test_get_linked_lists_by_depth_from_binary_tree(self): root = build_binary_...
5ea059516561a39961e4942109d6a78f814d8463
angelusualle/algorithms
/cracking_the_coding_interview_qs/4.12/count_value_paths.py
1,389
3.609375
4
from collections import defaultdict class Node(): def __init__(self, data): self.data = data self.left = None self.right = None # O(n) worst time where each node is visited once in time complexity. def count_value_paths(node, val): ans = [0] sums = defaultdict(int) count_value_...
2fbe17981fed9876aace45491b09eb5f1af133c9
angelusualle/algorithms
/general_interview_qs/heap_permutation/heap_permutation.py
322
3.546875
4
def heap_permutation(arr, size, n, ans): if (size == 1): ans.append(arr[:]) return for i in range(size): heap_permutation(arr,size-1,n, ans) if size % 2: arr[0], arr[size-1] = arr[size-1], arr[0] else: arr[i], arr[size-1] = arr[size-1], arr[i...
14d839bfc01b5bd6c23cfd50f3a36c28f4121bc3
angelusualle/algorithms
/cracking_the_coding_interview_qs/8.3/find_magic_index.py
450
3.65625
4
# O(log(n)) time and O(1) space def find_magic_index(arr): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if mid == arr[mid]: return mid elif mid > arr[mid]: low = mid + 1 else: high = mid - 1 """ # O(n) time and O(1...
010940bb4e4d1264cbaf6f7d589016976f604536
angelusualle/algorithms
/leetcode/python/problem5/get_longest_palindrome.py
666
3.640625
4
# O(n^2) where n is number of chars in string def get_longest_palindrome(s): best_start = 0 best_end = 0 for i,c in enumerate(s): y = i z = i y,z = expand(y,z,s) if y - z > best_end - best_start: best_start = z best_end = y y = i + 1 z ...
19e52df8573c768ae7e8cc478b2ec24b5fbe961f
angelusualle/algorithms
/leetcode/python/problem20/is_valid_parenthesis.py
592
3.859375
4
# O(n) time and space where n is length of s def is_valid_parenthesis(s): stack = [] for c in s: if c in [')', ']', '}']: if len(stack) == 0: return False elif c == ')' and stack[-1] != '(': return False elif c == ']' and stack[-1] != '...
bd11678e7ac8c3c5106f40d9f11393ac48e51c2b
angelusualle/algorithms
/advanced_algs/get_longest_increasing_subsequence/get_longest_increasing_subsequence.py
924
3.640625
4
# O(n^2) overall def get_longest_increasing_subsequence(nums): l = len(nums) # reverse adjacency list O(n^2) reverse_adjacency = {i:set() for i in range(l)} for i,n in enumerate(nums): for j,e in enumerate(nums[i+1:], i +1): if n < e: reverse_adjacency[j].add(i) # dynam...
5ab3f98b83d836ccb8c3d6118a733e58474dd62d
angelusualle/algorithms
/leetcode/python/problem24/swap_pairs.py
337
3.734375
4
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # O(N) time O(1) space def swap_pairs( head): next_ = head while next_ is not None and next_.next is not None: next_.val, next_.next.val = next_.next.val, next_.val next_ = next_.next.nex...
4b593881a50f6bd7fb8622792548b8e1c156a0cd
muneeb-250/beginners-python-projects
/PF-Lab Exercises/Lab 5/lab 5.3.py
138
3.71875
4
a=input("Enter your name: ") b=int(input("Enter the no. of first characters you want in lowercase: ")) print(a.lower()[0:b]+a.upper()[b:])
358b93db49ca872d54fa67fcca351a6aaa97abfe
muneeb-250/beginners-python-projects
/PF-Lab Exercises/Lab 10/10.1.py
432
4.15625
4
_list1_=[] _len_numbers=int(input('How many numbers you want to input in list ')) for i in range(_len_numbers): num=int(input('Enter numbers ')) _list1_.append(num) _list1_=tuple(_list1_) mini = _list1_[0] maxi = _list1_[0] for i in range(_len_numbers): if _list1_[i] > maxi: maxi = _list...
e9a323e340e0a2d4a65bd6394e56b43e95a907bd
ruchi004/Algorithms-with-python
/longest_common_substring.py
639
3.546875
4
x = 'abc' y = 'baba' def lcs(x,y,mat): print(x,y) maxlength = 0 #stores the maximum length of substring endindex = len(x) #stores ending index of lcs within x for indx , i in enumerate(x): for indy , j in enumerate(y): if i==j: mat[indx+1][indy+1] ...
f3509449512bf703191a698ee66699d1b20ca12a
seankreid/data-structures-and-algorithms
/array_binary_tree.py
1,035
3.84375
4
#!/usr/bin/env python3 # Sean Reid class ArrayBinaryTree(BinaryTree, DynamicArray): def __init__(self): self._root = 0 def root(self, node): self._str[0] = i def left(self, node, root): i = (root * 2) + 1 self._str[i] = node def right(self, node, root): i = (root * 2) + 2 self._str[i] = node ...
4912edbabed8ff8822be831825efeb81b1dc77b5
kramimus/projeu
/p19.py
558
4.125
4
#!/usr/bin/env python def is_leap_year(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) if __name__ == '__main__': non_leap_year = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] leap_year = non_leap_year[:] leap_year[1] += 1 # 0 = monday, 6 = sunday current_day = 365 % ...
b43e5e193b630f5410554fbd2bff848e501004fc
kramimus/projeu
/p44.py
1,242
3.5625
4
#!/usr/bin/env python3 import itertools import sys def get_pentagonal(i): return int(i*(3*i - 1) // 2) def next_pentagonal(): candidate_idx = 1 # lookahead f __index for checking the p_j + p_k sums, doing some # math, you can see that you only need to go about a factor of # sqrt(2) in n gen_a...
62584fdf56c358f89382bb7639276e5609215880
kramimus/projeu
/p27.py
361
3.640625
4
#!/usr/bin/etc python import prime def get_max_prime(a, b): n = 0 still_prime = True while prime.is_prime(abs(n * n + a * n + b)): n += 1 return n - 1 if __name__ == '__main__': ab_n = [] for a in range(-999, 1000): for b in range(-999, 1000): ab_n.append((get_max_...
57cc6c963948c2741ae8c81033a9251fbea96d90
Nekohasalready/AlgorithmDoneBook
/Binary_Search.py
1,507
3.859375
4
#Binary Search 二分查找 #执行用时:36 ms, 在所有 Python3 提交中击败了99.91% 的用户 #内存消耗:15.7 MB, 在所有 Python3 提交中击败了85.86% 的用户 ''' 普通的二分查找是在已经从小到大排序的数组中进行查找。因此只要设置好范围起点和终点,以起点<=终点为循环条件, 根据起点与终点计算中点位置,比较目标值与中点值的大小。 如果目标值<中点值,则下一次搜索左边域;如果目标值>中点值,则下一次搜索右边域。 在此过程中,如果搜索到则return mid;如果一直到最后也搜索不到则返回-1 ''' class Solution: def search(self, nu...
b75a53d6dc66fece09409b36898f67853e99b4d5
yanivharpaz/python101
/older_stuff/misc/limor03_iterable.py
562
3.953125
4
def take(count,iterable): counter = 0 for item in iterable: if counter==count: return counter += 1 yield item def run_take(): items = [2,4,6,8] for item in take(3,items): print(item) def distinct(iterable): seen=set() for item in iterable: ...
174047555f7a121c64f086392455cbfa55453e1c
yanivharpaz/python101
/older_stuff/misc/oop.py
695
3.671875
4
class Classroom: def __init__(self): self.pepole=[] def add_person(self, person): self.pepole.append(person) def remove_person(self, person): self.pepole.remove(person) def greet(self): for person in self.pepole: person.say_hello() class Person: def...
cdbe20b577bd0bcd82413d815b5a6c86ab788e75
yanivharpaz/python101
/older_stuff/misc/UnitTest.py
1,097
3.5
4
import os import unittest def analyze_text(filename): # with open(filename, 'r') as f: # return sum(1 for _ in f) lines = 0 chars =0 with open(filename, 'r') as f: for line in f: lines +=1 chars += len(line) return (lines,chars) class TextAnalysisTests(unitt...
1f0c1d5419037e698d4c43dfb8da1b255840a5d2
foTok/Integrated_Diagnosis_of_HS
/C130FS.py
16,311
3.5625
4
''' This file is used to simulate a simplified C130 fuel system. The fuel system is composed of 6 valves, 6 tanks and 6 pumps. \ The tanks store fuel used by four engines. \ The pumps feed the fuel in the tanks to the engines. \ And the valves are employed to keep the whole system balanced. \ So, the control system ha...
3cd21771a9ec463a02c4e75c6263b823bcdb6762
Dhiralp/Blockchain_arch
/Clients/main.py
838
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 26 10:29:18 2020 @author: dhiral """ import block as bl import os while(True): trans = 0 process = 0 for r,d,f in os.walk(os.getcwd()+"//Pending transaction"): trans = len(f) print("\n\nCurrently there are "+str(trans)+" pending transactions...
28b3e16c3d4185771c3408136f05b5dcd97584d5
sebbbastien/smc-python
/smc/administration/user_auth/servers.py
13,780
3.625
4
""" Authentication Servers represent server definitions used to authenticate remote users. If you need to use Active Directory for user authentication, you can use these modules to provision AD servers and LDAP domains. An example of creating an Active Directory Server instance with additional domain controllers (yo...
88ed4af382f7f2b7d383f4e347ea6553bafaf42f
malewis5/Data-Structures-and-Algorithms-Python
/sum_digits.py
643
4.03125
4
## Algorithm to sum together the digits in a number ## # Recursive Solution def sum_digits(n): if n < 0: ValueError('Inputs 0 or greater only!') if n <= 9: return n last_digit = n % 10 return sum_digits(n // 10) + last_digit # test cases print(sum_digits(12) == 3) print(sum_digits(552) == 12) print(s...
938aacdafdc5478ddfa2aea1e1dd95a9071179dd
ClaudionorOjr/Prova_Parte1
/q2.py
880
3.640625
4
lista = [] contador = 0 while contador < 25: x = int(input("Digite um valor para ser adicionado na lista:")) lista.append(x) if len(lista) == 1: menor = x maior = x posicao1 = contador posicao2 = contador if x > maior: posicao1 = contador maior = x if...
e8e6a0f80aadb763a420918e62c5e4adacde0dde
Piyush1403/TypingWizard
/TypingWizard.py
952
3.6875
4
##program to caluclate the accuracy and wpm of a rewritten text import time ogStr = "My name is Piyush Agrawal" print("This is the original text:") print(ogStr,"\n") length = len(ogStr) ogTime = time.localtime(time.time()) ogTime = (time.localtime(time.time()).tm_min*60)+(time.localtime(time.time()).tm_sec) reStr = ...
6955861994ab137bc92c0d92f2a73e20a58c9665
itaybou/SHA1-Cracker-Server-Client-Python3
/Client/io_handler.py
647
3.71875
4
import protocol def get_user_input(): hash_str = input('Welcome to {}. Please enter the hash:\n'.format(protocol.TEAM_NAME)) str_len = input('Please enter the input string length:\n') if len(hash_str) != protocol.MSG_HASH_LEN or not str_len.isdecimal(): raise ValueError("Illegal arguments given.")...
20af4271f97f4143fbe07d7913798cf7c2f84728
Lisafiluz/Advent_of_code_2020
/day6/day6.py
1,088
3.53125
4
def get_file_data(path): # Last line without new line (\n) with open(path, 'r') as file_handler: lines = file_handler.readlines() lines_without_spaces = [line[0:-1] for line in lines[0:-1]] lines_without_spaces.append(lines[-1]) return lines_without_spaces def get_sum_of_group(group_answe...
78a87ecfd6a8c49942ef461de4b3b2e352197c24
dashanbosamia/data-science
/pg2.py
380
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 20 18:20:22 2019 @author: dbosami2 """ import pandas as pd data=pd.read_csv('airquality.csv') data_melt=pd.melt(data, id_vars=['Month','Day'],var_name='measurement', value_name='reading') #print(data_melt) data_pivot=data_melt.pivot_table(index=['Month','Day'], colum...
2f6de6920856531dddec88701581df912ec9490b
melanie2201/Tarea-3-Software
/Billetera.py
2,668
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on Feb 1, 2017 @author: Melanie Gomes @author: Veronica Mazutiel ''' import sys class BilleteraElectronica: def __init__(self,identificador,nombre,apellido, cedula,pin): #Verificaciones de tipo try: assert(type(identificador) is...
f79854dcbd01d995c47c97b20f69bf132ba75563
asomeJay/algorithm
/Acm_icpc/Python/bj17351.py
1,469
3.703125
4
# 천하제일 코딩대회 선린고 bj17351 """ 1. Input() : N, string // Output : the number of 'MOLA' 2. DFS """ def index_chk(field__, r, c, n, list__, alpha_go): if (c + 1) >= n: pass elif field__[r][c+1] == alpha_go: DFS(field__, r, c+1, n, list__, alpha_go) if (r + 1) >= n: pass elif field...
0bc8f60140076d0cfcef7c9f21bd1cc7083871e7
BrennanDury/MBTITextClassifier
/Collector.py
3,151
3.5
4
""" Writes csv data by web scraping r/mbti. Each row in the natural language file has the text of a comment and the mbti personality dimensions and type of the commenter. """ import re import pandas as pd from pmaw import PushshiftAPI import datetime from datetime import timedelta import csv nl_file_name = 'MBTITextC...
a491eb0d1b0c227a776d907b3e3ca6464a2208a4
ianimaria/SD
/Tema 2/tema2.py
8,736
3.65625
4
class TreeNode(object): def __init__(self, val): self.val = val self.left = None self.right = None self.height = 1 class AVL_Tree(object): # aflam inaltimea arborelui def getHeight(self, root): if not root: return 0 return...
89fc8fb87da29f161bb27aece367293e2d96065b
pchordia15/Python
/functionAndmethod.py
2,280
4.125
4
#Write a function that computes the volume of a sphere given its radius. def volume(radius): return ((4.0/3)*3.14*(radius**3)) print(volume(1)) #Write a function that checks whether a number is in a given range (Inclusive of high and low) #Using print statement def ran_check(num,low,high): if num in range(low...
8235ec49c0475fbd6309e8df153576f68928bab0
aryabkova/aryabkova.github.io
/homework4.py
5,073
3.578125
4
import random class Warrior: name = '' health = 0 power = 0 def __init__(self, name): self.name = name self.health = random.randint(100, 150) self.power = random.randint(20, 30) def showHealth(self): return self.health def showPower(self): retu...
a2c4946387991e1e970e60ed0a135a3c0abb3e4d
Mithun691/SOC_2021
/Week2/TicTacToe_CounterAgent/MDP_generation.py
7,569
4.125
4
import copy import json from blockingPlay import blockingMove #It generates all the possible states, given num_X, num_O, pos and State #num_X = the number of X's to be added #num_O = the number of Os to be added #pos = the number of positions which are filled? #State is the current state of the board def getStates(nu...
1834b778775c495662185e93c8634baf252b6fbc
vishalkumarmg1/Trees-3
/Problem_2.py
745
4.03125
4
# 101. Symmetric Tree # Code: # Approach: Recursive twice with the root, In one check L-R and the other will check R-L. # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solut...
1b261f483c46bb87798b0bb2a32c620dd4a48ae5
subhamghimire/Practice-Python
/rockpaperscisor.py
227
3.78125
4
List = ["rock", "paper", "scissor" ] F = input("Enter 1st player input :rock or paper or scissor ") S = input("Enter 2nd player input :rock or paper or scissor") if F = "rock": if S = "paper": print("s is winner")
11f138c84ae5cdea4c428967987ecff8965fec30
Devanshi2660/Python_Programs
/Assignment 1/FirstLetter.py
217
3.890625
4
string = "The quick brown fox jumps over the lazy dog." print('The first letters are:',string[0]) for x in range (0, len(string)): if string[x] == " ": letter = string[x + 1] print(letter)
21e312fb985b44b82471eaf38c749c0f182951ea
sfGit2Hub/PythonLearn
/PythonDemo/static/iteration.py
742
4.21875
4
from collections import Iterable from collections import Iterator print('is Iterable:', isinstance('abc', Iterable)) print('is Iterator:', isinstance('abc', Iterator)) obj = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } for k in obj.keys(): print(k) for k, v in obj.items(): print(k, ':', v) for index, v...
5f2ddb7737e226d159805b34293d519fc9c8cb91
himeno4869/homework
/gradient.py
424
3.75
4
# -*- coding: utf-8 -*- import numpy as np def numerical_gradient(f, x): #偏微分の計算 h = 0.0001 grad = np.zeros_like(x) for index in range(x.size): temp_value = x[index] x[index] = temp_value + h fxh1 = f(x) x[index] = temp_value - h fxh2 = f(x) ...
2f549d451f113e41c4bc3ecaddacf356206815ec
himeno4869/homework
/homework02.py
2,084
4.3125
4
# -*- coding:utf-8 -*- import time def is_power(a,b,count): """再帰的にべき乗判定する関数 3番目の引数には0を代入""" if a%b == 0: count+=1 is_power(a//b, b, count) else: if a==1: if count == 1: print("{0} is the {1}st power of {2}".format(b**count, count, b)) elif c...
c87202d4a92003db909795f04247637e35417330
rpereira91/python-hash-map
/Item.py
555
4.03125
4
#dummy item class so I can practice inserting objects into the hashmap class Item(object): """docstring for Item.""" def __init__(self, key, value): self.key = key self.value = value #basic getter and setter methods def get_value(self): return self.value def get_key(self): ...
44bda291f1e7ef116a8b51817fbbe8dfb97380ee
sabiqxs/PythonLearn
/OOPLearning/classNstaticMethod.py
1,629
3.765625
4
''' regular Method = in a class automatically takes the instance as the first argument(self) classMethod menggunakan simbol @classmethod. in class automatically receive the class for the first argument(cls) in the instance staticMethod is not pass anything for the first argument ''' class Employee: num_of_employee...
29347aed8811ad4f08b097c76c5b07952adeb022
alhasib/UVA-online-judge
/uva10812.py
384
3.578125
4
import math n = int(input()) for i in range(n): a,b = input().split() if int(a) >= int(b): aa = int(a)/2 bb = int(b)/2 ab = aa + bb ad = aa - bb if math.floor(ab) == ab and math.floor(ad) == ad: print(str(int(ab)) + " " + str(int(ad))) else: ...
02a0d695cb14aaf6708a9f28782267a4dbc5d8b1
ua114/py4e
/course1/week7.py
1,316
4.0625
4
# Using loops # n = 5 # # while n>0: # print(n) # n = n - 1 # print('Happy new year') # def new_year(n): # while n>0: # print(n) # n = n -1 # print('Happy new year') # # x = input('Enter a number:') # x = int(x) # new_year(x) # while True: # n = input('>') # if n == 'skip': # ...
309e588e52efdfe1c7fb41287ff2aac5376dc8d8
ua114/py4e
/course1/week4.py
298
3.953125
4
# x = input("Enter a number:") # x = int(x) # if x >10 : # print("Enter a smaller number") # if x <0 : # print("Enter a larger number") # else : # print("Yes") y = input("How amazing am I on a scale of 1 to 10:") y = int(y) if y != 10: print("Try again") else : print('Yes')
d01c96c03491eb4685881a4476992b0cae75afc6
ryttings/DraftAnalysis
/Create_project.py
2,420
3.90625
4
#Returns a bunch of recursive lists with information about the draft def read_file(file): drafts = open(file,'r') sublist = [] lists = [] teams = [] games = [] word = '' lines = drafts.read() for char in lines: # - characters are used to separate words if char ...
2583f4c8f40216669592d6de80112615d84de38b
EmbeddedSoftwareChenlei/Learning
/LearningPy/new_guess.py
3,235
3.59375
4
# !/usr/bin/python # -*- coding: UTF-8 -*- import random import string allNum = [] #所有不重复的数字组合 numCount = {} #记录与正确答案相同的数字 # 检查是否有重复的字符 def checkDuplicate(inputNum): strNum = list(inputNum) solveNum = set(strNum) if len(strNum) == len(solveNum): return 0 return 1 # 判断输出1A1...
f5deaf4de415880852bfb957ab73c0fbf26678c6
ahsaantech/python
/function_example.py
339
3.859375
4
def a(): a=int(input("Enter any number")) b=int(input("Enter any number")) c=a+b print(c) again() def again(): cal=input("Enter y for contunue and n for exit ") if cal=='y': a() elif cal=='n': print("See you later") else: print("Please enter y and n ") ...
fdaa0ac840ab719aca3d63ba78751e825008c74d
martingehrke/projecteuler
/could_improve/p35s1.py
752
3.5
4
from collections import deque def isprime(n): n = abs(int(n)) if n < 2: return False if n == 2: return True if not n & 1: return False for x in range(3, int(n**0.5)+1, 2): if n % x == 0: return False return True def rotations(n...
2744757f6f459c4dceb65d17e39494c5ab420d44
martingehrke/projecteuler
/could_improve/p41s1.py
660
4.15625
4
#!/usr/bin/python2.7 import itertools, sys def isprime(n): # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n < 2: return False # 2 is the only even prime number if n == 2: return True # all other even numbers are not primes if not n & 1: return False # range starts with ...
d7a9df8dd3513cb12f1cd74c1258ee2f0e3444c8
ShirazSuleman/hashcode-2017
/Practice.Round/pizza.py
650
3.5625
4
class Pizza(object): def __init__(self, grid): self.grid = grid def __str__(self): result = '' for row in self.grid: result += (' ').join(row) + '\n' return result def get_cell_value(self, cell): return self.grid[cell[0]][cell[1]] def cut_cells(self...
4af8369a43f888bc0752506020b68cc12891eecd
tdthuan97/Myday001
/prime_numbers/prime_numbers.py
267
4.0625
4
def is_prime(n): if n < 2: return False for i in range(2, n): if n % i == 0: return False return True x = int(input("Let's print the prime numbers up to? ")) for i in range(2, x+1): if bool(is_prime(i)): print(i)
e6e69a5b8b57515b417b5925d32e1b82b2e757e8
tdthuan97/Myday001
/rock_paper_scissors/rock_paper_scissors.py
329
3.703125
4
p1 = input("Player 1? ") p2 = input("Player 2? ") test = (p1, p2) r = 'rock' s = 'scissors' p = 'paper' if p1 in (r, s, p) and p2 in (r, s, p): if(p1 == p2): print("Draw.") elif test in ((r, s), (s, p), (p, r)): print("Player 1 wins.") else: print("Player 2 wins.") else: print("...
b110719056dffa15723c475dcd877b199052ab24
matt448/pellet-dispenser
/test-scripts/keypadtest.py
1,830
3.53125
4
#!/usr/bin/python # # This is a test program to figure out how to read button presses # on matrix keypad. I am using the adafruit Membrane Matrix Keypad # Item ID: 419 (http://adafruit.com/products/419) # # Other key pads have different pin outs but any seven pin matrix # key pad should work as long as you know which...
616af8511673721245f6f2cbfe5f21d680cda02b
mroseehrlich/python-fundamentals
/lab4_Mia_Ehrlich.py
6,977
4.375
4
####################################################################################### # Mia Ehrlich # Lab 04 # This program introduces the Lame Game, displays a welcome message with a brief # description of the game and an option menu for gaming rooms. The menu options # use an input validation loop to ensure the use...
c0858a66b5c6111d4f9fe6b6940446be69b80cae
dzvid/aqs-sensor-node
/src/sensor_node/sensing_module/reading.py
1,304
4.03125
4
import time import datetime class Reading: """ Class that represents a reading collected by the Sensing Module. """ def __init__( self, pm25, pm10, temperature=None, relative_humidity=None, pressure=None, ): self.pm25 = pm25 self.pm1...
3909f027f534f62a21834e471358b79bf162590a
ICE-Laboratory/Condition_Monitoring
/Tensorflow/NumericalComp&Graph/build-graph.py
1,514
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 24 20:14:07 2020 @author: onur """ import tensorflow as tf #The tensorflow core r2.0 have enabled eager execution by default so doesn't need to write #In tensor 2.0 you have to use this in order to start a session (graph) #tf.compat.v1.disable_e...
3a048740ca1df1767db83f11b34fcdecbc5f5ea2
DauletY/CodeCoach-Python-ts
/ts1.py
525
4.1875
4
# num = int(input()) def EvenOrOdd(n): if(n == 0): return 0 if n % 2 == 0 and n % 2 != 0: return n + 3 else: return n + 2 def EvenOdd(n): if (n == 0): return 0 if n % 2 != 0: return n + 2 elif n % 2 == 0: return n + 2 def EvenOROdd(n): ...
de556ea523e5d7bbf4bf3d67cd0706cd0cf82c4d
DauletY/CodeCoach-Python-ts
/ts7.py
137
3.765625
4
names = ["David", "John", "Anna", "Johnathan", "Veronica"] res = list(filter(lambda x: x != 'David' and x != 'John', names)) print(res)
a3b6a49bed6c36554f0a23d102b534a08340f582
DauletY/CodeCoach-Python-ts
/ts40.py
119
3.546875
4
# Split generator txt = input() sp = txt.split(' ') def words(): for i in sp: yield i print(list(words()))
aabdfc518b0d089aa3952f92994b11d9ab070a7a
DauletY/CodeCoach-Python-ts
/ts17.py
140
3.828125
4
# Call it even x = 0 while x <= 10: if x % 2 == 0: print(x) x = x + 1 print() i = 3 while i >= 0: print (i) i -= 1
bd1def5e58a2d4ba0cc8343593977b2ba0a37226
avikbag/DataStructures
/week_4/postorder.py
2,667
3.5625
4
import math import sys parseTree = [] # global parse tree array def evaluate(): #argument takes index of 0 (start of the list) i = 0 stack = [] # stack while i < len(parseTree): if parseTree[i] == '+': x = stack[-2] + stack[-1] stack.pop() stack.pop() stack.append(x) elif parseTree[i] == '-': ...
3877e53de2b8c85975d845f4487c335f64a84b70
adaml73/PythonProjects
/summation.py
621
3.984375
4
i = int(input('enter i value ')) n = int(input('enter n value ')) ans = 0 selectType = input('selectType, 1, 2, or 3 ') def powerOne(i, n, ans): ans = (n * ( n + 1)) / 2 return ans def powerTwo(i, n, ans): ans = (n * (n + 1) * (2 * n + 1)) / 6 return ans def powerThree(i, n, ans): ans = ( n ** 2 ) * ((...
8576737666ba2b8ca3c4506baaef275a34e466cb
tesssny/Final-Project
/final.py
10,902
4.21875
4
""" sources: http://stackoverflow.com/questions/306400/how-do-i-randomly-select-an-item-from-a-list-using-python, https://inventwithpython.com/chapter9.html, http://stackoverflow.com/questions/14667578/check-if-a-number-already-exist-in-a-list-in-python, mary feyrer, Glen Passow (game tester), http://stackoverflow.com/...
9d4a9f404b41019a4d0a40fa57edd10c608f840c
anjan111/python_8pm
/002_Built-in-function/002-input.py
823
4.21875
4
# input with other built-in function ''' we can enter any datatype the result datatype is str ''' print "******** int **********" var = input("enter int : ") print "daata in var : ",var print(type(var)) print "memory loc : ",id(var) print "******** float **********" var = input("enter float : ") print "daata...
c18af0cba7a7ab6bc33408926db28b63f72dbfb7
khyathipurushotham/python_2
/functions.py
274
3.90625
4
colours= ["black", "white", "blue", "red"] print("black") print("white".upper()) print("black".lower()) print(len("black")) print(colours.index("blue")) print(colours) colours.append("green") print(colours) print(colours.pop(-1)) print(colours) colours.sort()
60d595894c9fd2b53d180d69c85b6776c9119e2c
yufang2802/CS1010E
/perfectNumber.py
472
3.875
4
def is_perfect(integer): total = 0 for i in range (1,integer): if (integer%i == 0): total = total + i if total == integer: return 1 if total != integer: return 0 integer = input("Enter number: ") while (int(integer) != 0): if (is_perfect(int(integer)) == 1): print(str(integer) + " is a perfect number...
a5ebd7ff1783a3dceea34f764e6e6bf3d6079baf
yufang2802/CS1010E
/pigLatin.py
485
4.03125
4
def changeWord(word): if word[0] == "a" or word[0] == "e" or word[0] == "i" or word[0] == "o" or word[0] == "u": return word + "way" else: return word[1:] + word[0] + "ay" def pigLatin(sentence): if len(sentence) == 1: return changeWord(sentence[0]) else: return...
bd931d6dbcddefe4edda19508276c60a6c82ad0b
yufang2802/CS1010E
/countCoprimes.py
254
3.84375
4
import math def count_coprimes(limit): count = 0 for i in range (2, limit+1): for x in range (2, limit+1): if (i < x and math.gcd(i,x) == 1): count+=1 print("Answer = " + str(count)) limit = input("Enter limit: ") count_coprimes(int(limit))
36da5801da337f0757435e0171a65e0a5a1c8ff6
yufang2802/CS1010E
/countNumbers.py
804
4
4
divisor1 = int(input("Enter divisor 1 ")) divisor2 = int(input("Enter divisor 2 ")) def countNumbers(divisor1, divisor2, limit1, limit2): count = 0 for x in range(limit1, limit2+1): if x%divisor1 != 0 and x%divisor2 != 0: count += 1 print("Answer = " + str(count)) return count def checkDivisors(divisor1, d...
fda856951fb1a3e7a686cd178f7fc778fe13ebfa
yufang2802/CS1010E
/assignment1.py
229
3.984375
4
from math import sqrt, sin def heron(a, b, c): p = (a + b + c)/2 area = sqrt(p*(p-a)*(p-b)*(p-c)) return area a = int(input("Enter a: ")) b = int(input("Enter b: ")) c = int(input("Enter c: ")) print(heron(a, b, c))
f0cedd29c05d45ea4c3e4b0b0dd688db8146d350
Surender1415/PySparkTemplate
/src/prototype.py
665
3.515625
4
import pyspark from pyspark.sql import SparkSession from pyspark.sql import functions as F # logFile = "/Users/surendranathreddykudumula/Softwares/spark-2.4.5-bin-hadoop2.7/README.md" spark = SparkSession.builder.appName("SimpleApp").master("local[*]").getOrCreate() # logData = spark.read.text(logFile).cache() df = s...
5fbc730038cb725ca97b994b6eb416f7dd7a5ce1
jfpazto/Cnyt-1
/Version2.py
2,601
3.8125
4
import math '''Esta libreria se encarga de realizar diferentes operaciones para los numeros complejos , las cuales son: Suma, Resta, Multiplicaion, Division, Conjugado, Modulo, Fase, Conversión entre representaciones polar y cartesiano''' def suma(arr1,arr2): '''Esta funcion recibe dos arreglos de la forma[a,bi] y ...
8587e4d8480ff7050c2fb5ce190394be1882d0fe
PatrickShaw/scheduling-simulator
/src/scheduler/scheduler.py
3,314
3.921875
4
from abc import abstractmethod from collections import deque from scheduler.process import Process class Scheduler: """ Handles when, which and for how long a process is executed by a simulated processor. """ def __init__(self): self._executing_process = None """The process that is c...
da819a41bbe89cd96e7902b39fa18357cc6825f7
FerisZura/RPG-Game
/Functions.py
1,342
3.859375
4
import random # accepts input for a number between 1 and the max number def integer_input(maxNumber): x = 1 while x == 1: userInput = input() if userInput.isdigit() == False: print("Invalid input") elif int(userInput) in range(1, maxNumber + 1): retur...
110df0657fa6cbcfa1148c10be28476330c95275
takao-fujiwara/mypy
/TryError.py
109
3.5
4
try: a = float(input('Enter a number: ')) except ValueError: print('You entered an invalid number')
c59c50540acc358a05729ef145a5f24c6fd6c347
cristian-bedoya/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
583
4.1875
4
#!/usr/bin/python3 """Module 2-read_lines """ def read_lines(filename="", nb_lines=0): """Reads n lines of a text file: - filename: name of the file """ with open(filename) as f: n_lines = 0 i = 0 for lines in f: n_lines += 1 f.seek(0) if nb_li...
6fb9188e6cc1be2890f722984f81e7ed3d940a2a
cristian-bedoya/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
129
3.765625
4
#!/usr/bin/python3 for c in range(ord('z'), ord('a') - 1, -1): print("{:c}".format(c if (c % 2 == 0) else (c - 32)), end="")
cff50e714949eff7bba9f54dda735465e8b4c4fa
cristian-bedoya/holbertonschool-higher_level_programming
/0x03-python-data_structures/0-print_list_integer.py
149
3.859375
4
#!/usr/bin/python3 def print_list_integer(my_list=[]): x = 0 while x < len(my_list): print("{:d}".format(my_list[x])) x += 1
e795328bce2f53433962b365a0ae40dcc518e49b
sehaj217/Pythonla
/tictactoe.py
2,655
3.96875
4
BOARD = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' '],] def check_win(token_list, token): count = 0 for tok in token_list: if tok == token: count = count + 1 if count == 3: print(f"{token} won the game!!!!") exit() def draw_board(...
7ac30b131f0ba68345407d125525d2350e964671
antoniorcn/alura
/OLD/ID-1496-REC/pacman_aula1.py
673
3.5
4
import pygame AMARELO = (255, 255, 0) PRETO = (0, 0, 0) pygame.init() screen = pygame.display.set_mode((1024, 300), 0) x = 0 y = 0 vel_x = 0.5 vel_y = 0.5 raio = 30 while True: # Calcular regras x += vel_x y += vel_y if x + raio > screen.get_width(): vel_x = -0.5 if x - raio < 0: v...
19755cc442363f946d4b2e9640acff99e2ba3772
KacperLech/lechanski
/2_string.py
712
4.0625
4
text = "Anna, pawel, TomEK" #Live preview - do zdalnego programowania ''' To jest komentarz blokowy ''' tab = text.split(", ") print(text) print(tab) print(type(tab)) name = "JANUSZ" print(name) nameLower = name.lower() print(nameLower) surname=input("Podaj swoje nazwisko: ") content=surname.isalpha() print(conten...
a87bc01148e81e0c4bebfb38507cc1f2782f6e61
KacperLech/lechanski
/1_podstaw.py
1,312
3.921875
4
print("cdv") print (2) print ('test') #potęga pow=2**10 print(pow) text="CDV" print(text * 2) #pobieranie danych z klawiatury name=input() print(name) print("Twoje imię:"+name) surname=input("Podaj swoje nazwisko: ") print("Imie: " + name + ", nazwisko: " + surname) lengthSurname=len(surname) #<class 'str'> print(t...