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
ddca4966ef786c62c956e13f404677767e1953f0
DoStini/FEUP-FPRO
/RE/RE05/ex_01.py
349
3.921875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 21 11:43:51 2019 @author: morei """ def rm_letter_rev(l, astr): rv = "" len_ = len(astr) for x in range(len_): if l not in astr[len_ - 1 - x].lower(): rv += astr[len_- 1 - x] return rv print(rm_letter_rev("s", "A style ...
f7725cca85fe22a3dbbf3dcff54f752b08113ee8
bbatjargal/ready-to-go
/web-scrapers/mechanicalsoup_openpyxl/pass_encode.py
247
3.53125
4
import getpass def simple_encode(vl): result = "" for ch in vl: result += chr(ord(ch) - 15) return result password = getpass.getpass("Please enter your password: ") with open("password", "w") as f: f.write(simple_encode(password))
1804f578c7ff417744edc804043b2016d8bcde4a
paulocuambe/hello-python
/exercises/lists-execises.py
554
4.21875
4
my_list = ["apple", "banana", "cherry", "mango"] print(my_list[-2]) # Second last item of the list my_list.append("lemon") if "lemon" in my_list: print("Yes, that fruit is in the list.") else: print("That fruit is not in the list.") my_list.insert(2, "orange") print(my_list) new_list = my_list[1:] print(n...
45ab566c204a9a593871d670c1c0e206fa3949fd
paulocuambe/hello-python
/exercises/dictionaries/count_letter.py
367
4.125
4
""" Count how many times each letter appears in a string. """ word = "lollipop" # Traditional way trad_count = dict() for l in word: if l not in trad_count: trad_count[l] = 1 else: trad_count[l] += 1 print(trad_count) # An elegant way elegant_count = dict() for l in word: elegant_count[l] ...
6a7c5955e2c3fe74786c663c3e5de312fad98460
paulocuambe/hello-python
/practice/sets.py
197
4.03125
4
my_set = {"Paulo", "Eliana", "Milena", "Guida"} print(my_set) some_list = ["Luciano", 1, 12, 1] # Create a set out of a list new_set = set(some_list) print(new_set, type(new_set), type(my_set))
3ce28a5ff5d7c9f5cf2daa6a5f6f5ff955e29017
paulocuambe/hello-python
/exercises/oop/first.py
507
4.15625
4
class Animal: name = "" def __init__(self, name): self.name = name print(f"\n----{self.name} Is in the creation process.----\n") def walk(self): """ Walk a tiny bit """ print(f"{self.name} is walking...") def __del__(self): print(f"\n----{self.n...
6d44a9e3a466e1274ccdd2aa95a756a1372991d2
paulocuambe/hello-python
/exercises/loops/min_max.py
512
4.125
4
maximum = minimun = None count = 0 while True: user_input = input("Enter a number: ") if user_input == "done": break try: number = float(user_input) if count == 0: maximum = number minimum = number elif number > maximum: maximum = number ...
07ef0a160a6d5ab69f0bc421b443083f30a20454
unswo/rosalind.info
/python_village/INI5/read_write.py
433
3.609375
4
'''Problem Given: A file containing at most 1000 lines. Return: A file containing all the even-numbered lines from the original file. Assume 1-based numbering of lines.''' file = 'rosalind_ini5.txt' with open(file) as y: z = y.readlines() # remove newlines etc z = [z.rstrip() for z in z] # starts at l...
133b1bae43ca4008d25cbfc2069aaf2855afc611
ramsestein/Aprendizaje_automatico
/red_neuronal.py
4,517
3.546875
4
#------------------------------------------------------------ # -------------------------- # | Red Neuronal en Python | # -------------------------- #------------------------------------------------------------ #Importamos las librerias necesarias #------------------------------------------------------------ ...
062a42d6ae18db6de60ed1562dfea83e9945f242
Kimiaoo/unsw
/20T2 COMP9414/Tutorial/hunter.py
6,958
4.15625
4
# -*- coding: utf-8 -*- """ Created on Fri May 17 (alfred); Sat May 18, 2019 (wobcke) @author: wobcke (updated from alfred) A simple agent hunting for food on a square grid of size grid_size. The grid is the upper right quadrant with squares numbered (0..grid_end) Food is initially generated in th...
3c83b5b43ef9e60ecc2038668a20079b1623de57
gypsyx/algos-toolbox
/week2/stress_test.py
3,962
3.546875
4
import sys from week2 import lcm_4 as lcm from week2 import fibonacci as fib from week2 import fibonacci_last_digit_2 as fibld from week2 import fibonacci_huge_5 as fibh from week2 import fibonacci_sum_last_digit_6 as fibsumlast from week2 import fibonacci_partial_sum_7 as fibpartial from week2 import fibonacci_sum_squ...
d84615405fb2f232341d8432e1733d21bb785c40
gypsyx/algos-toolbox
/week2/fibonacci_sum_squares_8.py
1,145
3.734375
4
# Uses python3 # Compute the last digit of f0^2 + f1^2 +...+ fn^2 . from sys import stdin def fib_mod_fast(n, m): period = [0, 1] if n <=1: return period[n] prev = 0 cur = 1 pmod = 0 cmod = 1 for i in range(2, n+1): prev, cur = cur, (prev+cur) pmod, cmod = cmod, (cur % m...
f2de7d8b20a768e9fa249a3375ad4fc4c835488e
manisha89/ANLY560FALL2018_manisha
/assignment_2_python_manisha.py
1,047
3.796875
4
## Accessing mysql database from python #import modules import pymysql #open a database connection db = pymysql.connect("localhost", "root", "mysql*11", "sakila") # prepare a cursor object cursor = db.cursor() ## Homework Query # sql query sql = """ select F.title, F.description, A.first_name, A.last_name from sa...
1ebd6dce05a1d0b7b63a5f1a93c144c83327f79a
bolicoding/python
/while-loops.py
474
3.96875
4
""" nums = list(range(1, 100)) while len(nums) > 0: print(nums.pop()) def guessing_game(): while True: print('What is your guess?') guess = input() if guess == '42': print('You correctly guessed it!') return False else: print(f"No, {guess} isn't the answer, please try again\n") ...
ade23f11333761c715b5a4421c65663e03e85d46
FarzamTP/Logistic-Regression
/main.py
3,487
3.75
4
""" @author: Farzam.Taghipour https://github.com/FarzamTP/Logistic-Regression """ from __future__ import print_function from LogisticRegression import LogisticRegression from sklearn.linear_model import LogisticRegression as skLR import numpy as np # reads file and generates X, y. def read_data_from_file(file_path)...
acf04a48978f75d8a402aced9d54ae46ffb4c6b8
jonnyf89/AirlineManagementSystem
/aircraft_unit_test.py
956
3.84375
4
'''unit test class for my aircraft class''' import unittest from aircraft import Aircraft class AircraftTestCase(unittest.TestCase): def setUp(self): print ("Before the Test") self.aircraft1 = Aircraft('type', 'metric', 'manufacturer', 2000) #usually aircraft objects are populated from the csv f...
67970e2638bdf4723414e6f037174ddee5280126
jonnyf89/AirlineManagementSystem
/aircraftAtlas.py
1,498
3.65625
4
'''AircratAtlas class holds information on aircrafts''' '''it takes a csv file as an input and uses this to populate a dictionary object with relevant data about each aircraft type''' import csv from aircraft import Aircraft import sys class AircraftAtlas: __aircraftDict = {} #this ...
ecdc7b71d10cdd7198ee7203ce9bbfb5a0fd50cc
robfalck/aoc2019
/aoc2019/day4/part1.py
789
3.6875
4
import numpy as np input_range = '347312-805915' def contains_repeated_number(sn): if '00' in sn or '11' in sn or '22' in sn or '33' in sn or '44' in sn or '55' in sn or '66' in sn or '77' in sn or '88' in sn or '99' in sn: return True return False def is_non_decreasing(sn): diff = np.diff(np.a...
f25fbe617717ad8b7950e9114dcc0ba96d61c174
MrinaliniTh/Algorithms
/leetcode/leetcode_844_backspace_string.py
978
3.75
4
# Using Stack class Solution: def backspaceCompare(self, s: str, t: str) -> bool: s_stack = [] t_stack = [] for st in s: if st == "#": if s_stack: s_stack.pop() else: s_stack.append(st) for ts in t: ...
458dc41c2e68eca949d2d0cccdc7bf640bbc9acc
MrinaliniTh/Algorithms
/AV/heap/kth_smallest.py
270
3.59375
4
import heapq def kth_smallest(nums, k): heap = [] for num in nums: heapq.heappush(heap, num) res = [] while k > 0: res.append(heapq.heappop(heap)) k -= 1 print(res) return res[-1] print(kth_smallest([10, 3, 5, 1, 9], 2))
dfdf80e0833acbe77369e5f75e6a94436b24782a
MrinaliniTh/Algorithms
/Interview_question/camel_case_to_snake_case.py
270
4.0625
4
def camel_case_to_snake_case(word): temp = word[0].lower() for i in range(1, len(word)): if word[i].isupper(): temp += "_" + word[i].lower() else: temp += word[i] return temp print(camel_case_to_snake_case("MacOS"))
6a84f801794e052900cb52c8307a4ce612e7da56
MrinaliniTh/Algorithms
/Interview_question/sum_of_digits_in_string258.py
404
4.03125
4
# input: "abc345gh8mm3" # output: 3+4+5+8+3 = 23 => 2 + 3 = 5 def add_digits(words): num = "" for s in words: try: if int(s): num += s except Exception: continue num = int(num) while num >= 10: question = num // 10 remainder = num ...
3a206b6d03c9123f1f58c710485c3859ce052d9d
MrinaliniTh/Algorithms
/DP/0-1-knapsack.py
1,914
3.5625
4
# find maximum profit from knapsack # Using recursion or top down approach def find_max_profit_from_knapsack(weight, val, capacity, size): if (size == 0 or capacity == 0): return 0 if weight[size-1] <= capacity: return max(val[size-1] + find_max_profit_from_knapsack(weight, val, capacity - weigh...
acc5030ec51660fbcd461e223c671600d30f5427
MrinaliniTh/Algorithms
/tree/binary_tree/binary_tree_creation.py
1,023
4
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None class BinaryTree: def __init__(self): self.tree = None def creation(self, val): if self.tree: self.add(self.tree, val) else: self.tree = Node(val) ...
baa7bcd8f41cf184cb2ab6148d5783ca8dfaa283
MrinaliniTh/Algorithms
/Arrays/Product_without_self.py
994
3.921875
4
# Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements # of nums except nums[i]. # Iterative approach: Space O(n), Time O(n) # Take a product from left side # Take a product from right side # multiply with the left and right product # E...
fbf4641cfca837d1e8a8d24462319829cebd04bf
MrinaliniTh/Algorithms
/tree/binary_tree/path_sum_112.py
1,042
3.953125
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None class BinaryTree: def path_sum(self, root, target): if not root: return False if not root.left and not root.right and target- root.val == 0: return True ...
065e57819d9fe342863841faeb2a72bcdf1d40a9
MrinaliniTh/Algorithms
/Arrays/largest_subarray_sum.py
494
3.765625
4
def largest_subarray_sum(array): max_so_far = float("-inf") max_ending = 0 start = end = beg = 0 for i, num in enumerate(array): max_ending += num if max_ending < 0: max_ending = 0 beg += 1 if max_so_far < max_ending: max_so_far = max_ending ...
fccfaac6346eaf23b345cd2117cda259fd83ff80
MrinaliniTh/Algorithms
/link_list/bring_last_to_fast.py
1,663
4.15625
4
class Node: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.head = None def create_link_list(self, val): if not self.head: self.head = Node(val) else: temp = self.head while temp...
c8e2b64efd171f0c172878b55b173314ebe3d78b
MrinaliniTh/Algorithms
/link_list/link_list_cycle.py
1,329
4
4
# Given head, the head of a linked list, determine if the linked list has a cycle in it. # There is a cycle in a linked list if there is some node in the list that can be reached # again by continuously following the next pointer. Internally, # pos is used to denote the index of the node that tail's next pointer is co...
be31866a850c663ca1be784775644c88cbd95826
ShailendraKK/Competative-Programming-preparation
/Array/Finding the majority using the linear search aproach/Majority_sorted_tc_O(n)_sc_O(1).py
273
3.640625
4
def main(): arr = [1,2,2,2,5] run = 1 for i in range(len(arr)-1): if(arr[i]!=arr[i+1]): if(run>(len(arr)/2)): print(arr[i]) run = 1 else: run = run + 1 if __name__ == "__main__": main()
536f849236a984329df99fb2c2e286e3329c6ad4
juliettegodyere/MIT-Electrical-Engineering-and-Computer-Science-Undergraduate-Class
/Year 1/Intro to Computer Science & Programming/Problem Sets/ps0/ps0.py
259
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 2 18:13:11 2021 @author: nkworjuliet """ # import math x = int(input("Enter a value....")) y = int(input("Enter a value....")) pow = x**y print(pow) log = int(math.log(x, 2)) print(log)
ff5f57309f77dc1a51f243b5fd3191808dd22cec
chaudhary003/python
/BinaryTree.py
759
3.734375
4
class BinaryTree: def __init__(self,data): self.data=data self.lTree=None self.rTree=None def setData(data): self.data=data def getData(): return self.data def setLTree(lTree): self.lTree=lTree def getLTree(): return self.Ltree def setRTree(rTree): self.rTree=rTree def getRTree(): return self.r...
93dcf4877095aad25142a725e73282a0214b3f86
chaudhary003/python
/staircase.py
151
4
4
def staircase(n): for i in range(1,n+1): print(("#"*i).rjust(n," ")) def staircase2(n): for i in range(1,n+1): print(("#"*i).ljust(n," "))
7d874984e115d16c556701f42354662a337157df
chaudhary003/python
/test.py
202
3.734375
4
import List_Operation print("hello") lis=[10,20] print(List_Operation.is_empty(lis)) i=1000 print(type(i)) if(i<100): print("number is less than 100") else: print("number is greater than 100")
bbf13b932be04da50b1fe9b7a90469a6d0282634
tchuanromanee/python-sandbox
/conditionals.py
217
3.984375
4
def main(): x, y=100, 100 #x = 10, y = 100 if (x < y): msg = "x is less than y" elif (x > y): msg = "x is greater than y" else: msg = "x is equal to y" print(msg) main()
b4f421b8269c859852a8bde7e988bab8f2d85d39
mlhenson/Milestone-Project-1
/main.py
7,882
4.3125
4
# Milestone Project 1 for 2021 Complete Python Bootcamp # Tic-tac-toe game for two human players # Board should be printed every time a player makes a move # Accept input of player position then place a symbol on the board # Use the numpad to match numbers to a grid import random # Functions # Clear the board def cle...
ca29f9bb35563f1962df52f5be08ab0521db36b6
zhujixiang1997/6969
/7月12日/练习07.py
236
3.53125
4
sum=0 for banji in range(1,4): print('欢迎%d班同学!'%banji) for chengji in range(1,6): input('请输入第%d名同学成绩:'%chengji) sum+=chengji print('%d班同学总成绩是:%.2f'%(banji,sum))
25c16516725c262adea8aa125fd28b7305d2ac4f
zhujixiang1997/6969
/7月11日/作业02.py
392
3.828125
4
''' 2.写一段代码判断一个人的体重是否合格: 公式:(身高-108)*2=体重,可以有10斤左右的浮动 ''' weight = eval(input('请输入体重(单位斤):')) height = eval(input('请输入身高(单位cm):')) if (height - 108)*2 >= weight - 10 and (height - 108)*2 <= weight+10: print('恭喜你的体重合格!') else: print('兄dei,不行呀!')
f6ffc7845a7a3e8c06bd5f49b01cf83115bda42f
zhujixiang1997/6969
/7月11日/判断语句.py
496
4.21875
4
''' 判断程序的过程:从上到下,从左到右依次执行 判断语句:if 判断条件: 满足条件后执行的代码块 当所有条件都不满足就执行else语句,else语句只能放在最后,可以不写 判断i语句必须是if开始 chr()字符 会将数字转换成对应的ASCCII ASCII a=97 b=98 A=65 B=66 ''' a=float(input('请输入:')) if a==10: print(a,'等于10') elif a<10: print(a,'小于10') else : print(a,'大于10')
729c885efa255aac3193f06ee512db56bb35ad24
zhujixiang1997/6969
/7月12日/作业03(小星星).py
662
3.953125
4
# for x in range(1,6): # for y in range(1,6): # print('*', end='') # print() # # num2=0 # while num2<=5: # num=1 # while num <= 5: # print('*', end='') # num += 1 # print(end='\n') # num2+=1 for x in range(1,6): for y in range(1,6): print('*', end='') ...
12188e2e3aab8ce6b85fbf97f24cca2e6790b6a8
zhujixiang1997/6969
/7月11日/类型转换.py
433
4.1875
4
''' 数字可以和数字直接运算 整数和字符串不能够运算 只有同类型的数据才能运算 字符串的加法运算:是拼接 整数和字符串做加法运算,除非字符串的内容是数字 我们可以将字符串转换为整数 转换方式:int(要转换的数据/变量) 将整数转换为字符串str() ''' # a=10 # b='20' # print(a+b) # a=10 # #b=int('20') # b='20' # c=int(b) # print(a+c)
5040168d3f9ce73c87a1e708bce3553ad25f0ace
gsvette/cruise-challenge
/level1.py
2,800
3.71875
4
#!/usr/bin/python def move(pos0,n): "The position (x, y) is updated based on input u(n)." u = [[1,2],[2,1],[2,-1],[1,-2],[-1,-2],[-2,-1],[-2,1],[-1,2]] pos1 = [0,0] pos1[0] = pos0[0] + u[n][0] pos1[1] = pos0[1] + u[n][1] return pos1 def isValidPos(pos,mn): "Returns 1 if pos is withi...
e18e5784b1c1945159bf032487a2657de8e4e00e
Yanjaiyin/appium_xueqiu_9-master
/src/statementandmethod/method/kwparameters.py
428
3.828125
4
#!/usr/bin/env python #coding=utf-8 def add(x,**kwargs): total = x for arg, value in kwargs.items(): print "adding ", arg total += value return total print add(10, y=11, z=12, w=13) print "*"*80 def add(x, kwargs): total = x for arg, value in kwargs.items(): print "addi...
60d1981b5be71134761f9634a1eec8625b1942c8
Yanjaiyin/appium_xueqiu_9-master
/fangcheng_python/src/classmodule/classexample5.py
943
3.578125
4
#!/usr/bin/env python #coding=utf-8 from classmodule.classexample4 import Student from classmodule.classexample2 import Person class SeniorStudent(Student): def __init__(self,name, sex, province, grade): #super(StudentSenior, self).__init__(name, sex, province,grade) Student.__init__(self,name, ...
28c39ab6a8a763a1a47737fb5c9d6758dc4c7c81
Yanjaiyin/appium_xueqiu_9-master
/src/statementandmethod/method/add.py
277
3.609375
4
#!/usr/bin/env python #coding=utf-8 def add_method(x,y): ''' :param x: :param y: :return: value or None if one of parameter is not digit ''' try: return x+y except Exception,e: print e return None #print add_method(10,11)
3450371670254e9e035c4be04348cd4dfea923b0
Yanjaiyin/appium_xueqiu_9-master
/fangcheng_python/src/classmodule/classexample6.py
1,112
3.953125
4
#!/usr/bin/env python #coding=utf-8 class Person: total_person=0 def __init__(self, name, sex, province): print("Init the class") self.name = name self.sex = sex self.province = province Person.total_person += 1 @staticmethod def set_new_name(new_name): ...
adbedfc65e752b49a79a310da21816dd2e0059be
Yanjaiyin/appium_xueqiu_9-master
/src/modules/reexample2.py
100
3.546875
4
#!/usr/bin/env python #coding=utf-8 import re m = re.match('hello', 'hello world!') print m.group()
b91d872e85f132e53340fe85a2098e959357658c
Yanjaiyin/appium_xueqiu_9-master
/src/statementandmethod/loop/loop4.py
344
3.5625
4
#!/usr/bin/env python #coding=utf-8 ''' for first_number in xrange(1,10): for second_number in xrange(1,first_number+1): print first_number,"*", second_number,"=",first_number*second_number,"", print "\n" ''' wid=1 while wid <= 5: len=1 while len <= wid: print "*","", len+=1 ...
38d2645c6427ca5efb072ab18c0dc0b704c4bcda
jjhangu/algopython
/combsort.py
500
3.53125
4
arr = [8, 4, 1, 56, 3, -44, 23, -6, 28, 0] def combsort(arr): gap = len(arr) swapped = True while gap !=1 or swapped: gap= int(gap//1.3) if gap==0: gap =1 swapped = False for i in range(0, len(arr)-gap): if arr[i] > arr[i+gap]: swap...
b3f14159120e16453abdbd43687885956393e811
TaylorWhitlatch/Python
/tuple.py
967
4.3125
4
# # Tuple is a list that: # # 1. values cannot be changed # # 2. it uses () instead of [] # # a_tuple = (1,2,3) # print a_tuple # # # Dictionaries are lists that have alpha indicies not mumerical # # name = "Rob" # gender = "Male" # height = "Tall" # # # A list makes no sense to tie together. # # person = { # ...
4969adae89dd2bacefd3983b202abaa18c82410d
TaylorWhitlatch/Python
/triangle.py
166
4.03125
4
height = int(raw_input("Enter tri height")) for i in range(1,height): spaces = (height - i) * " " stars = (i * 2 - 1) * "*" print spaces + stars + spaces
7e512dfc27cf3c632dea5db8e25eb4e472f2d9c7
TaylorWhitlatch/Python
/exercises.py
177
3.703125
4
i = 1 j = 1 for i in range (1, 11): print ("\n** %ss Multiplication Table **" % (i)) for j in range (1, 11): x = i * j print("%s X %s = %s" % (i, j, x))
73a8f1afaaf21f217b09e25566e7ae753dd3f28c
Aklim21/Advent_of_Code
/AOC_d004p2.py
2,383
3.796875
4
# --- Part Two --- # An Elf just remembered one more important detail: the two adjacent matching digits are not part of a larger group of matching digits. # Given this additional criterion, but still ignoring the range rule, the following are now true: # 112233 meets these criteria because the digits never decrease a...
a42a66932d55b02ff4d39db9fcfee8fd9b54b27a
BrunoIS77/PYTHON-Problemas
/MODULO1/hello.py
189
4.0625
4
nombre = input("What is your name?\n") nombre = nombre.capitalize() if nombre == 'Emmay': nombre = 'Emma' elif nombre == 'Rodrigoy': nombre = 'Rodrigo' print("Hola", nombre)
09e50583f004ad2f59d7d3749d1d42667c046315
wolfshirts/Wordulator
/wordulator.py
859
3.71875
4
import tkinter as tk from word_functions import wordfunctions class App: def __init__(self, master): frame = tk.Frame(master) frame.pack() self.wordLabel = tk.Label(frame, text='Enter a word or words.') self.wordLabel.pack(side='left') self.txtEntry = tk.Entry(frame) ...
aa15c53b44aa7e3cbdc497160964c3566a70c071
cksgnlcjswo/open_source_sw
/midterm/account.py
739
4.15625
4
""" version : 1.5.0 작성자 : 김찬휘 이메일 : cksgnlcjswoo@naver.com description : account 클래스 수정사항 : pythonic-way 적용 """ class Account: def __init__(self, ID, money, name): self.ID = ID #bank number self.balance = money #left money self.name = name def getID(self): return self.ID ...
02694416079de92aaa625ef6ca805251a75be11b
FouedDadi/holbertonschool-web_back_end
/0x00-python_variable_annotations/8-make_multiplier.py
425
3.71875
4
#!/usr/bin/env python3 """[float as arg and returns a function (multiplies a float by multiplier)]""" from typing import Callable def make_multiplier(multiplier: float) -> Callable[[float], float]: """[type-annotated function] Args: multiplier (float): [argument float] Returns: callable[...
8e0a6e501fb12d331001c4c176385478570cf5cf
sophiasagan/HackerRank
/Easy/validating_uid.py
423
3.859375
4
import re for _ in range(int(input())): uid = input() uid = "".join(sorted(uid)) if (re.search(r"[A-Z]{2}",uid) and #2 uppercase alphabets re.search(r"\d{3}",uid) and #3+ digits not re.search(r"[^A-Za-z0-9]",uid) and #no nonalphanumeric not re.search(r"(\w)\1",uid) and #no repetition...
b54b5717bcfa53074bb39ee8729e30147f10acf8
mariamv96/Cosmic-Strings
/mcanny1.py
3,087
3.625
4
""" ------------------------------------------------------------------------------- AUTHOR: Maria Martin Vega ------------------------------------------------------------------------------- CANY GRADIENTS ABSTRACT: We define a function that receive maps and return gradients. --------------------------------------------...
79004d747935ebfc19599a9df859400c47120c7e
PavanMJ/python-training
/2 Variables/variables.py
832
4.1875
4
#!/usr/bin/python3 ## All the variables in python are objects and every object has type, id and value. def main(): print('## checking simple variables and their attributes') n = 12 print(type(n), n) f = 34.23 print(type(f), f) print(f / 4) print(f // 4) print(round(f / 4), end = '\n...
f006ee2dc80b32537b6317671e9a916b1425e00a
PhilipHoltzman/ComputerLogic
/ch6Q7.py
994
3.9375
4
# Philip Holtzman # Computer Logic # Week 4 assignment, ch.6 problem 7 # calculate average def calcAverage(num1,num2,num3,num4,num5): average = (num1+num2+num3+num4+num5) / 5 return average # determine grade def determineGrade(average): if average <= 59: print("Your grade is a F...") elif average >= 60 an...
0b068b41a0dd8ad9ebc7796244b01b5860c3fea8
fireblade7/python
/PyTest/robots_txt.py
383
3.515625
4
import urllib import io def get_robots_txt(url): if url.endswith('/'): path = url else: path = url + '/' print(path) req = urllib.urlopen(path + 'robots.txt', data=None) print(req.headers) #print(req.read()) return req.read() ...
fe789098e54d1a7a59573d36fc03a4da0159b552
vuminhph/randomCodes
/reverse_linkedList.py
969
4.1875
4
class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self, value): self.head = Node(value) def add_node(self, value): ptr = self.head while ptr.next != None: ptr = ptr.next ptr.next = Node(va...
94ab70593b09ec5160ac0eb23078fe3cc353ad37
vuminhph/randomCodes
/encoder.py
346
4
4
def hexEncoder(): string = input('String: ') code = '' for char in string: code += hex(ord(char))[2:] + ' ' print(code) return code def hexDecoder(code): code = code.split(' ')[:-1] string = '' for char in code: string += chr(int(char, 16)) print(string) code = hex...
3b0f9952380c754e681d6419388de5c571227b36
vuminhph/randomCodes
/Algorithms/BackTracking/Hamiltonian_cycle.py
1,282
3.75
4
def main(): # graph = [[0,1,0,1,0], # [1,0,1,1,1], # [0,1,0,0,1], # [1,1,0,0,1], # [0,1,1,1,0]] graph = [[0,1,1,1,0,0], [1,0,1,0,1,1], [1,1,0,1,1,0], [1,0,1,0,1,0], [0,1,1,1,0,1], [0,1,0,0,1,0]] path = [] if fou...
ebed4a1422dd1a65af3070110506913012b23daf
vuminhph/randomCodes
/fizz_buzz.py
376
3.625
4
def fizz_buzz(n): string_repr = [] for i in range(1, n + 1): if i % 15 == 0: string_repr.append('fizzbuzz') elif i % 3 == 0: string_repr.append('fizz') elif i % 5 == 0: string_repr.append('buzz') else: string_repr.append(str(i)...
7732f88ac6f8fe5c1bae9b3ee4fa71ac6bf7edae
vuminhph/randomCodes
/k_largest.py
152
3.765625
4
def k_largest(nums, k): nums.sort() print(nums) return nums[len(nums) - k:] nums = [5, 16, 7, 9, -1, 4, 3, 11, 2] print(k_largest(nums, 3))
9e880918d7077dc5fe4bfe5f1200314ca6a586b1
vuminhph/randomCodes
/Algorithms/BackTracking/cryptarithmetic.py
5,068
3.546875
4
SIZE = 10 def main(): # str1 = 'SEND' # str2 = 'MORE' # sum_str = 'MONEY' str1 = 'FDB' str2 = 'CEGA' sum_str = 'DCCB' letter_list = get_letters_list(str1, str2, sum_str) mappings = {letter : -1 for letter in letter_list} if solve_puzzle(str1, str2, sum_str, 0, mappings): pr...
8b604891ee45818bf892962380537dcfd2dc4ba9
vuminhph/randomCodes
/Techniques/TurtoiseHare/find_duplicate.py
429
3.921875
4
# find duplicate number in an array with elemements in range(1,n) # array has length n -1 def find_duplicate(arr): turtoise = arr[0] hare = arr[0] while turtoise != hare: turtoise = arr[turtoise] hare = arr[arr[hare]] ptr1 = arr[0] ptr2 = turtoise while ptr1 != ptr2: ...
835dbebd24704166db171f78d37c339a3619554b
szad670401/PLATE_seg
/digits.py
4,336
3.609375
4
#!/usr/bin/env python ''' SVM and KNearest digit recognition. Sample loads a dataset of handwritten digits from 'digits.png'. Then it trains a SVM and KNearest classifiers on it and evaluates their accuracy. Following preprocessing is applied to the dataset: - Moment-based image deskew (see deskew()) - Digit image...
3e687af4cfa19d5338f1002028e4151b5cba4cf4
Terrabits/qtrf
/qtrf/helpers.py
250
3.6875
4
def type_or_none(Type, value): if value is None or value == '': return None # else return Type(value) def float_or_none(value): return type_or_none(float, value) def int_or_none(value): return type_or_none(int, value)
eba2fecce7125af35fb7a609b6a3a7ffcc48d928
tom-walter/data_viz_tools
/Stacked_Bar_Chart.py
2,612
3.921875
4
""" Stacked Bar Chart Function Created on 03.03.2021 @author: Tom-Walter """ import numpy as np import matplotlib.pyplot as plt def plot_stacked_bar(data, series_labels, category_labels=None, show_values=False, value_format="{}", title=None, y_label=None, colors=None, grid...
f9c2df6fb7dca23432ffbd0acd211e580fabc900
soallpeach/sample
/prime/prime_checker.py
305
3.8125
4
import sys file_name = sys.argv[1] def is_prime(n: int) -> bool: for m in range(3, n - 1): if n % m == 0: return False return True with open(file_name) as input_numbers: for line in input_numbers: number = int(line) print(1 if is_prime(number) else 0)
edbab399786c050d2859b7c408a0fef8155dbd69
ValenTorresFR/ValenTorresFR
/calculo_salario.py
1,953
4.0625
4
horas = input('Cuantas horas trabaja su empleado: ') # Este codigo fue realizado por Valentín Torres Porcel el día 28/8/2021 (Ventiocho de Agosto de 2021) tarifa = input('Cuál es la tarifa por hora?: ') calificacion = float(input('Introduzca calificación: '))...
c4cad7dd1e0fbd6ce87a64cbe613d1c4c1384a20
dmitrijsg123/Problem_Solving
/Week_4_homework.py
404
4.40625
4
# Enter positive integer and perform calculation on it - divide by two if even and multiply by three and add one if odd a = int(input("Enter Positive Number: ")) while a != 1: # while 'a' not equal to one if (a % 2) == 0: # if 'a' is even a = a/2 elif (a % 2) !=...
9b0438efb0e0b39bd05610feb5438fb0991f292b
johnmwalker/Basic-2D-Physics-Game-in-Python
/Physics.py
16,873
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 18 14:50:12 2016 @author: John """ import Search import numpy as np import matplotlib.pyplot as plt import Body import Solver import math import Simulation import Vector class NewtonCooling(object): '''Contains methods for use in calculating cooling c...
8514f8850b3e563160e01cd34d14a4a12861b909
bkoehler2016/cs-module-project-hash-tables
/applications/no_dups/no_dups.py
519
3.984375
4
def no_dups(s): # Your code here d = dict() # loop over and split and if not just set it to word for word in s.split(): if word not in d: d[word] = word # return join word and values return " ".join((word for word in d.values())) if __name__ == "__main__": pr...
f885943d41b2204919f4b54f4bd749f040b44c84
danielraf23/pythonProject
/DanielRaf/EX_1.5.py
200
3.921875
4
salary=int(input("what is your current salary?")) raise_precantage=float(input("What is your raise precentage?")) a=raise_precantage/100 salary_raise=salary*a b=(salary_raise+salary) print(b)
a83a1d0e35bed07b1959086aff1ef4f7a872520e
rpayal/PyTestApp
/days-to-unit/helper.py
1,232
4.40625
4
USER_INPUT_MESSAGE = "Hey !! Enter number of days as a comma separated list:unit of measurement (e.g 20, 30:hours) " \ "and I'll convert it for you.\n " def days_to_hours(num_of_days, conversion_unit): calculation_factor = 0 if conversion_unit == "hours": calculation_factor = 24 ...
3ff50c38168cd3f12bb8893358790ef1782da28c
Jayshri-Rathod/more-excercise
/question8.py
368
3.671875
4
list1 = [1, 5, 10, 12, 16, 20] list2 = [1, 2, 10, 13, 16] i=0 new_list=[] while i<len(list1): j=0 while j<len(list2): same=list1[i] same1=list2[j] if same not in new_list: new_list.append(same) if same1 not in new_list: new_list.append(same1) j+=1...
fb9321060c3d6bf2a5f11f007c470988eaf80209
varnitsah/language-processing-tasks
/anagram and utf8 encoder/anagram3.py
448
3.546875
4
#Varnit Sah 9083888794 #vsah@usc.edu from sys import argv str = argv[1] list1= [] def permute(rstr, prefix): n = len(rstr) if (n == 0): list1.append(prefix) else: i=0 while i < n : permute(rstr[0:i] + rstr[i+1:n], prefix + rstr[i]) i =i + 1 target="anagram_...
a7c073fe3144d022bdc6d59b516b4ddefc3bb737
hanlongzhang/Python
/GetIndexAndchar.py
144
3.734375
4
s='qwertyuioplkjhgfdsa' for i in range(0,len(s),2): print s[i] for (index,char) in enumerate(s): print "index=%s,char=%s" %(index,char)
34ecd463ea8809fa9b191238f96e460231114586
hanlongzhang/Python
/if.py
133
4.03125
4
#!/usr/bin/python age=20 if age >=18: print 'you age is', age print 'adult' else: print 'you age is', age print 'teenager'
9d841c4dc56e323aff0a9fd0ab9329052a9dc858
hanlongzhang/Python
/Hollow_triangle.py
288
3.828125
4
#coding:utf-8 rows = int(raw_input("input line:")) for i in range(0,rows): for k in range(0,2*rows-1): if (i!=rows-1)and(k==rows-i-1 or k==rows+i-1): print "*", elif i == rows-1: if k%2 == 0: print '*', else: print "!", else: print "$", print "\n"
f7bbff1561915eee87a64b07150dbc0a78a8bedf
hanlongzhang/Python
/Threading.py
696
3.671875
4
import threading import time exitFlag = 0 class myThread(threading.Thread): def __init__(self,threadID, name,counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter def run(self): print "Starting"+self.name print_time(self.name,self.counter,5...
d9016532d0e891e5fbff5c6a6e51360b4ab303c1
hanlongzhang/Python
/Time.py
272
3.703125
4
import time; ticks=time.time() print "The Current Time is :",ticks localtime = time.localtime(time.time()) print "The local timing is :",localtime i=1 while i : localtime1 = time.asctime(time.localtime(time.time())) print "The local timing is :",localtime1
e5eb91fd7044349926e8f50c759141f8892e6c8e
magn753/ct-kea-2021-gr9
/RandomGenerator1.py
1,916
3.5
4
#import the Faker function in order for the randomiser to work import random import faker import string Denis = faker.Faker() #randoming name def FirstName(): return Denis.name().split(" ")[0] #randoming last name def LastName(): return Denis.name().split(" ")[-1] #randoming studentID def ID(): ...
4eb22cc8b36bf60c9c4d49f7ca7431c4da17a383
dylanrohauer/hello_world
/testforum.py
485
3.90625
4
# test forum for python inputs! print("Please enter a number from 1 to 9: ") num = int(input()) answ = "Your number is " if num == 1: print(answ + "one") if num == 2: print(answ + "two") if num == 3: print(answ + "three") if num == 4: print(answ + "four") if num == 5: print(answ + "five...
46518acadba3ef22535d7a0bb991bc4061440200
melissasmashey/python-challenge
/PyPoll/main.py
2,273
3.65625
4
import os import csv #Bring in CSV File and Read in election_data_csv = os.path.join("./Resources/election_data.csv") # Open and read csv with open(election_data_csv, newline="") as csv_file: csv_reader=csv.reader(csv_file, delimiter=",") csv_header= next(csv_file) #Variables candidate = [] candidate...
67af859321f3684327dde2933b8100ac5a91682d
l-c-sanchez/louiseweiss
/scripts/shortest_path.py
5,139
3.71875
4
""" This script read a Tilemap from a json file and transform it in a map with boolean values: True if the player can go on the specific case. """ import base64 import json import struct import sys from enum import Enum def map_from_json_tilemap(fname): """ :param fname: name of the json file containing th...
6615cf2ec0309bead2e40f67922a8d125861a9f5
vitor-bruno/exercicios-coursera
/fatorial_2.py
297
4.09375
4
def fatorial(n): m = n - 1 while m > 0: n *= m m -= 1 if n == 0: n = 1 return n n = int(input('Digite um número inteiro: ')) while n > 0: print(f'O fatorial de {n} é {fatorial(n)}\n') n = int(input('Digite outro número inteiro: '))
7a8154589cb8393431806c1242c791a93c6fec24
vitor-bruno/exercicios-coursera
/conta_char.py
362
3.640625
4
def conta_letras(frase, contar='vogais'): vog = con = '' frase = frase.lower().replace(' ','') assert contar == 'vogais' or 'consoantes' for letra in frase: if letra in 'aeiou': vog += letra else: con += letra if contar == 'vogais': return le...
6d97ca96509585be2ca93ee1235b09af25df2636
vitor-bruno/exercicios-coursera
/jogo_nim.py
2,948
3.765625
4
def computador_escolhe_jogada(n, m): jogada = 1 restante = n - jogada while (not restante % (m + 1) == 0) and jogada < m and jogada < n: jogada += 1 restante = n - jogada return jogada def usuario_escolhe_jogada(n, m): jogada = int(input('Quantas peças você vai tirar? '))...
95ad05d636119c7e8823fd693add788061215a5e
MrShores/MrShores-Google-FooBar
/python/google_codes.py
366
3.578125
4
# coding: utf-8 # In[1]: x = ["foo", "bar", "oof", "bar"] # In[6]: def answer(x): distinct = [] for str in x: if str not in distinct: distinct.append(str) distinct.append(str[::-1]) return len(distinct) / 2 # In[7]: answer(x) # In[8]: x1 = ["x", "y", "xy", "yy", "...
71c123dceccd943d49bb336bc2f89d227666d13f
victorleandroof/aulas-python-machine-learning
/5.py
81
3.671875
4
def fat(n): if n == 0 or n == 1: return 1 return n * fat(n -1) print(fat(5))
4b3f69a909428f260a7983b5f6646b1ee24ae42f
weeshree/ML-AndrewNg
/ex1/ex1_multi.py
1,541
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 19 20:18:23 2018 @author: weesh """ import numpy as np import pandas as pd import matplotlib.pyplot as plt def featureNormalize(X): ''' Normalizes all columns besides first of X ''' mu = np.mean(X[:,1:], axis=0); sd = np.std(X[:,1:], axis=0); X[:,1:] = X[:,1...
16b48fbab268284d1927bd40b455fe9194308b61
jjhelmus/nmrglue
/nmrglue/fileio/simpson.py
12,840
3.578125
4
""" Functions for reading and writing files created by the `SIMPSON simulations program <http://www.bionmr.chem.au.dk/bionmr/software/simpson.php>`_. """ import math from warnings import warn import numpy as np def read(filename, ftype=None, ndim=None, NP=None, NI=None, spe=None): """ Read a SIMPSON file. ...
14a30c249046917426f8b78a81996e214e1ae5b5
Ivan1931/attack-of-leet
/15/3sum.py
1,152
3.53125
4
from collections import defaultdict class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if len(nums) <= 2: return [] cache = defaultdict(list) for idx, i in enumerate(nums): for jdx,...
10601a602793dcc90ab0abb818d8a44f25d2a8f1
Ivan1931/attack-of-leet
/295/mds.py
3,656
4.0625
4
from heapq import heappop, heappush class MedianFinder: def __init__(self): """ initialize your data structure here. """ self.lowerheap = [] self.higherheap = [] self.items = 0 def _pop_lower(self): return -heappop(self.lowerheap) def _pop_higher(se...
18eb988a4436174278c767153f5e4f3725115fd2
AnshBhatti/Algorithms-and-Programming-Paradigms
/floyd_warshalls.py
657
3.90625
4
import numpy as np print("Floyd-Warshall Algorithm") x=int(input("Number of vertices: ")) y=int(input("Number of edges: ")) adj_matrix=np.full((x,x),100000,dtype=int) for a in range(y): z=list(map(int,input().split())) adj_matrix[z[0]][z[1]]=z[2] adj_matrix[z[0]][z[0]]=0 adj_matrix[z[1]][z[1]]=...