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
de7e65a78aeb655fb91579b349f8f2c2c697e0aa
Phoenix795/lesson1
/ld.py
986
4.1875
4
# step 5(Комплексные типы данных: списки) my_list = [3,5,7,9,10.5] print('My list: ', my_list) my_list.append('Python') print('Length of my_list: ', len(my_list)) print('First element: ', my_list[0]) print('Last element: ', my_list[-1]) print('From second to fourth element: ',my_list[1:4]) print('My list: ', my_list) d...
c820d7de678e940a72a011cdbbdfb2e8e8a00bdd
jungminchul/python
/study/print/Mystudy.py
193
3.5625
4
a = "jeongmincheol" print(a) a = 4 if a > 1: print("a is good") a = 4 if a > 5: print("a is good") for a in [1,2,3]: print(a) i = 0 while i < 6: i=i+1 print(i) #함수
f45ed70bee0e22da133cbceebd60400f608ac286
KU-SKE17/sos8th
/problems/00_keyed-iter.py
1,508
3.9375
4
# x = input('Enter the first key-value pairs separated by comma (,): ') # y = input('Enter the second key-value pairs separated by comma (,): ') # z = input('Enter the last key-value pairs separated by comma (,): ') # lx = list(x.split(',')) # ly = list(y.split(',')) # lz = list(z.split(',')) # xyzDict = { # lx[0...
47c202b21eaf0a79a2fadfd79a291094dab48c56
ImBerkayKaplan/PasswordCrackingTechniques
/src/PermutationAttack.py
445
3.75
4
from itertools import permutations # TODO 1: Update the file name infile = open("dictionary.txt", "r") line = infile.readline() while line: line = line[0:len(line)-1] # Get all permutations of the string in the line. perms = [''.join(p) for p in permutations(line)] for i in range (len(perms)): ...
ab1a214f4284fc8e202084f52a9f6e746aacd76d
Kuseraga-git/tp1IOT-Canteloup
/tp_crypto.py
647
3.625
4
#!/usr/bin/env python3.5 #-*- coding: utf-8 -*- import requests def user_input() : user = input("Entrez la crypto-monnaie dont vous voulez connaitre le prix") def disp_price(user): req = requests.get('https://min-api.cryptocompare.com/data/price?fsym='+monnaie+'&tsyms=BTC,USD,EUR').json() prix = str(req...
8f03eeada8c7004aed055398d5912845fa73990d
colemai/coding-challenges
/gap_challenges/gap-1-decompression.py
2,556
3.921875
4
#!/usr/bin/env python3 """ Author: Ian Coleman Challenge: Decompress a compressed string as per https://techdevguide.withgoogle.com/paths/advanced/compress-decompression#code-challenge """ import pdb from sys import argv def get_input(input_file): """ Get input and output it as string """ with open(input_file) a...
c22a3a2358c43fa2010303fa125199b77168d3b5
colemai/coding-challenges
/leetcode_challenges/L267-PalindromeP2.py
2,627
4.28125
4
#!/usr/bin/env python3 """ Author: Ian Coleman Input: Output: Challenge: Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. For example: Given s = "aabb", return ["abba", "baab"]. Given s = "abc", return []. """ from...
fca0fcf22ae4e3052bb789f030cf08697048a4c7
yusufaisal/Single-source_shortest_problem
/Main.py
8,632
3.953125
4
from copy import deepcopy class Route: def __init__(self,route,cost): self.cost = cost self.route = route class childNode: def __init__(self,node=None,weight=None): self.node = node self.weight = weight self.next = None class node: def __init__(self,label=None): ...
6d70442cf637c0ca21aa5d2d3bc6f24030c459a5
envisioncheng/python
/pyworkshop/1_intro_python/chapter6/exercise.py
2,675
3.984375
4
# if, elif, else def test_number(number): if number < 100: print("This is a pretty small number") elif number == 100: print("This number is alright") else: print("This number is huge!") test_number(5) test_number(99) test_number(100) test_number(8675309) # multiple conditions def ...
a001f7dac86ba8504f9473af6c5b5b9fffe10bbe
envisioncheng/python
/pyworkshop/1_intro_python/chapter4/dicts_exercise.py
381
3.90625
4
# Remember, dictionaries don't have numerical indexes # like lists, so if you try to use an index number... # Unless 0 happens to be a key. my_dict = {"key": "value"} my_dict[0] my_dict["hello"] = "world" my_dict["foo"] = "bar" my_dict my_dict["hello"] my_dict.get("hello") my_dict["baz"] "baz" in my_dict my_dict.get("...
afc794d1882bbfb28ea270f7b4a723762b3a246c
envisioncheng/python
/pyworkshop/1_intro_python/chapter5/exercise.py
553
4.21875
4
# Part 1 10 > 5 5 > 10 10 > 10 10 >= 10 5 < 10 5 < 5 5 <= 5 5 == 5 5 != 10 # Part 2 5 == True # The number 5 does not equal True, but... if 5: print("The number 5 is truthy!") # The number 5 is truthy for an if test! # Part 3 1 == True 0 == False # Part 4 True or False [] or [1, 2, 3] "Hello" or None True a...
64a508e8e927bfc8b94c3840907acd0bd9422d40
SatchelofSparkles/portfolio
/Fibonacci.py
307
4.0625
4
#successful Fibonacci value def Fibonacci(): Fib = [0, 1] count = 1 a = 0 b = 1 while count <= 50: count = count + 1 a, b = b, a+b Fib.append(b) index = input('Which Fibonacci number do you want to know? ') print('The', index, 'th Fibonacci number is', Fib[int(index)]) Fibonacci()
3d3f78e51fad0df8b155af108008581ceca5f42a
vicenteneto/interview-questions
/chapter_1/tests/test_check_permutation.py
759
3.59375
4
import unittest from chapter_1.check_permutation import check_permutation, check_permutation_without_sorting_string class TestCheckPermutation(unittest.TestCase): TEST_DATA = [ ('', '', True), (' ', ' ', True), ('asd', 'ads', True), ('asd', 'dsa', True), ('test', 'tests', ...
0c0e23c15708325ec523a31bd9b7bea1044ad2e4
prameya21/python_leetcode
/Valid_Palindrome.py
800
4.25
4
''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false ''' class...
92cc8732044e9fc0a64a3d7de55ec4393b6b4beb
kangwonlee/16pfa_kangwonlee
/ex29_if/ex29.py
714
4.1875
4
# -*-coding:utf8 # http://learnpythonthehardway.org/book/ people = 10 cats = 30 dogs = 15 if people < cats: print("Too many cats! The world is doomed!") if people > cats: print("No many cats! The world is saved!") if people < dogs: print("The world is drooled on!") if people > dogs: print("The worl...
2b3a658cfb20d44f4bc11b729262fa8115cdde20
LeRoiFou/john_exceptions
/004_raise.py
1,334
4.0625
4
""" Les exceptions : créer sa propre exception La classe parente 'Exception' dispose d'un nombre indéfini de paramètre. Dans l'exemple ci-dessous, en créant sa propre exception, on déclare un constructeur disposant de deux attributs d'instance à savoir le message d'erreur et le code d'erreur trouvé qui seront a...
b70ecee915d7c36c55d4ed34fe008e657b7bd36a
kt8128/atcorder
/ABC144/C.py
542
3.59375
4
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): a = [] if n % i == 0: a.append(i) # divisors.append(i) if i != n // i: a.append(n//i) # divisors.append(n//i) else: a.append(i) ...
904a3def3bdaa18d6c6904773f916ed2734592fa
kt8128/atcorder
/第二回全国統一プログラミング王/A.py
76
3.625
4
n = int(input()) if n % 2 == 0: print(int(n/2-1)) else: print(n//2)
170ce5f219379006fa93d76c339f3169c79b77a1
mudin/leetcode
/problems/19. Remove Nth Node From End of List/solution.py
543
3.59375
4
# 19. Remove Nth Node From End of List # https://leetcode.com/problems/remove-nth-node-from-end-of-list/ class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def removeNthFromEnd(self, head, n): D = ListNode(0) D.next = head ...
cfd5c6be61799f3807c1536f7340172ff3957dc6
mudin/leetcode
/problems/138. Copy List with Random Pointer/solution.py
1,767
3.78125
4
# 138. Copy List with Random Pointer """ # Definition for a Node. """ from collections import defaultdict class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random class Solution: # O(n) time, O(n) space, ...
b3c2dcb43b6b6d31d907029295fd0da48b8a8a33
michalkonecny/PLC-code
/lab7-vars/python/vars.py
916
4.09375
4
import sys # needed for IO def printA(): print(a) # using a global variable before its declaration # OK because python variables are non-linearly scoped def setA(): # print(a) # ERROR - local variable 'a' referenced before assignment # a refers to the local variable below thanks to n...
aa7239b900de06b29844ffb1c5659c493cc75dcb
SjayTheGift/Coding-Bat-Python-Answers
/List 1.py
1,111
3.609375
4
#List-1 > make_pi def make_pi(): return [3,1,4] #List-1 > common_end def common_end(a, b): return a[0] == b[0] or a[-1] == b[-1] #List-1 > sum3 def sum3(nums): return sum(nums) #List-1 > rotate_left3 def rotate_left3(nums): return [nums[1],nums[-1],nums[0]] #List-1 > reverse3 d...
7a51dc9400929b37b85e8f78718692e94783f7be
skugele/courses
/COMP7712/scripts/pa2.py
599
3.671875
4
import re from graph import Graph, is_dag, topological_sort, find_longest_path_distance n_vertices = None edges = [] print("Specify a graph. (A blank line stops input)") while True: value = input() # Stop input line only contains white space if re.match('^\s*$', value): break if n_vertices ...
6618e64f24fe7e3ef2e02b44c3dce24d5f942f35
skugele/courses
/COMP7712/scripts/polynomial.py
3,025
3.734375
4
import re class Polynomial(object): """ A class for representing arbitrary real coefficient polynomials """ def __init__(self, spec): self._spec = spec self._terms = [] if not spec: raise ValueError('A polynomial specification must be defined') if type(sp...
c59f710a1208a68a0c3c30312ec0437399aae175
skugele/courses
/COMP7712/scripts/pa1_3.py
526
3.828125
4
from functions import interpolate # Solution to PA1 (3) if __name__ == '__main__': try: coord_list = input('Please specify a set of points: ').split(' ') pts = [] for x, y in zip(coord_list[0::2], coord_list[1::2]): pts.append((float(x), float(y))) print('Interpolating...
ff56521470072f363b358a24dc2ce57c19a137df
schakalakka/Ant-Colony-Optimization
/cities_of_europe.py
746
3.734375
4
import numpy as np import pandas as pd from antcolony import AntColony # read csv and prepare to be a normal numpy distance matrix distances = pd.read_csv('europe.csv', delimiter=',') distances = distances.replace('-', np.inf) # diagonal should be infinity distances = distances.apply(pd.to_numeric, errors='coerce')...
c86d7d50bc4a2df077510f07bd9ce152b00e48e9
kanekyo1234/AtCoder_solve
/ABC/144/D.py
536
3.515625
4
import math a,b,x=map(int,input().split()) """ 平面で考える  こぼれるときに水が台形になってるなら三角形にする (直角)三角形の長さを求めてhttps://keisan.casio.jp/exec/system/1259903491 にある計算をする """ s=x/a#平面化 if a*b==s: print(0) exit() if a*b/2 < s: #台形 a1=a b1=b-(s/a*2-b) else: #三角形 a1= s*2/b b1=b #print(a1,b1) ans=math.atan(b1/a1)...
9754d78a4f6783fd99df58c2c21addfcdb46a49a
kanekyo1234/AtCoder_solve
/AGC/22/A-1.py
196
3.546875
4
"""s=int(input()) if s=="zyxwvutsrqponmlkjihgfedcba": print(-1) exit() if s<26: for i in range(26): if s.count(chr(97+i))==0: print(s+chr(97+i)) """
6c6e494682ad00ce80a766640a9546f92fab051c
kanekyo1234/AtCoder_solve
/ABC/152/E.py
294
3.515625
4
import fractions mod=10**9+7 n=int(input()) a=list(map(int,input().split())) def lcm(x, y): return (x * y) // fractions.gcd(x, y) count=a[0] for i in range(n-1): count=lcm(count,a[i+1]) ans=0 for i in range(n): ansa=count//a[i] ans+=ansa print(ans%mod) """ mathtukae """
27fd7457caf11e26144eb02c78e9ce54ec5603ce
kanekyo1234/AtCoder_solve
/A other/三井住友信託銀行プログラミングコンテスト2019/B.py
195
3.59375
4
import math a=int(input()) if (a/1.08)%1==0: print (math.ceil(a/1.08)) else: m=math.ceil(a/1.08) if a==math.floor(m*1.08): print(math.floor(m)) else: print(":(")
d3423f6b010d605006f40d89a29d5ae6632f82be
kanekyo1234/AtCoder_solve
/ABC/29/C.py
159
3.671875
4
n=int(input()) pas=['a','b','c'] def dfs(a,ans): if a==n: print(ans) return for i in range(3): dfs(a+1,ans+pas[i]) dfs(0,'')
797d56b00e6fdafa6c788f9bda6049cf7c1d3ca4
kanekyo1234/AtCoder_solve
/ABC/146/A.py
216
3.671875
4
a=input() if a in "SAT": print(1) if a in "SUN": print(7) if a in "MON": print(6) if a in "TUE": print(5) if a in "WED": print(4) if a in "THU": print(3) if a in "FRI": print(2)
ab33c2f56b55409cb31a6b04e52c98e2cdf9b77c
kanekyo1234/AtCoder_solve
/SoundHound/A.py
107
3.609375
4
a,b=map(int,input().split()) if a+b==15: print("+") elif a*b==15: print("*") else: print("x")
11dfd45f3a1ef11401d325ac2eaf5e41a75d404d
kanekyo1234/AtCoder_solve
/ABC/157/D-1.py
2,490
3.671875
4
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x):#要素xが属するグループの根を返す if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x...
4d4403138765bcb9ab61d8163e6e96f90211e659
kanekyo1234/AtCoder_solve
/ABC/150/B.py
113
3.625
4
n=int(input()) s=str(input()) count=0 for i in range(n-2): if s[i:i+3]=="ABC": count+=1 print(count)
60801a9000ab65f97c39f12d6386ad8bcc159f17
Nojdaz/Linneuniversitetet-Introduction_to_programming-Assignment-1_Python_
/G/area.py
103
4.09375
4
radius = input("Enter the circle radius: ") A = 3.14*float(radius)**2 print("This circles area is:", A)
f6e0d41c84821329aeeb962ad6193923ef5ff93b
Krishna2201Sriram/CSCE-606-thinkSmart
/DistrictSchoolPerformancePrediction/spring 2021/thinkSmart_SWE_CSCE606_2021_Spring-20210503T230755Z-001/thinkSmart_SWE_CSCE606_2021_Spring/source_code0.01/src/learn.py
3,516
3.609375
4
def openTrainedModel(modelPath="../models/dummy.txt"): try: f = open(modelPath,"rb") return f # Do something with the file except IOError: print("The {} not accessible".format(modelPath)); return None def retFileName(pathToFile="../data/dummy.csv"): parsed = pathToF...
d2fddd3ed47aca2b560c00dc859c3d1550f34592
Dharaneeshwar/CodeVita
/Bottle Necks – TCS CodeVita.py
1,777
4
4
""" The program must accept the radii of N bottles as the input. Once a bottle is enclosed inside another bottle, it ceases to be visible. A bottle X is enclosed inside another bottle Y only if the following conditions are fulfilled. 1) The bottle X itself is not enclosed in another bottle. 2) The bottle Y does not enc...
ac9e7463f52e1e1a253118b2a6ccb51437a252b2
kritagyakhandelwal314e/python-programming-exercise
/find_x.py
254
3.6875
4
def find_x(matrix, x): for li in matrix: for element in li: if x == element: return True return False matrix = [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] ] print(find_x(matrix, 4))
40ef539cdfbee1f1bcf40e266e7152eee4478f75
Maschenka77/100_Day_Python
/day_8_paint_calc.py
315
3.8125
4
import math def paint_area_calc(width, heigth): coverage = 5 cans = (width * heigth)/coverage return math.ceil(cans) wall_width = int(input("Wall width in meter: ")) wall_heigth = int(input("Wall heigth in meter: ")) cans = paint_area_calc(wall_width, wall_heigth) print(f"You need {cans} cans of paint.")
24dad66dd22395fc2a92f2a403de09dcb82fbfe4
Maschenka77/100_Day_Python
/day_2_tip_project_calculator.py
625
4.21875
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 #Tip: You might need to do some research in Google to figure out how to do this. print("Welcome to the tip calculator!") total_bill = float(input("What is t...
0cddb936c2d2bc2dd0bb6c0171912a9fc31fcdc7
Maschenka77/100_Day_Python
/day_9_project_secret_auction.py
902
3.9375
4
import os def name(): name = input("Whats your name? ") return name def bid(): dollars = input("How much do you want to bid? $") return dollars def find_min(bidders_dict): values = [] #loop through dictionary for key, value in bidders_dict.items(): #append values to value list to compare them ...
077bf9f77c40b692b7a539d83b2d86ac608613e4
oscar-dev19/Py4E
/chapter_6/letter_count.py
271
3.890625
4
""" A program that counts the number of times a given letter is in a given word Author: Oscar Lopez """ def letter_count(word, letter): count = 0 for char in word: if char == letter: count += 1 return count print(letter_count('Shawn', 'h'))
99d0566b020d9cdaa01d39e4ca71f9430e0bfca6
oscar-dev19/Py4E
/chapter_8/find_sender.py
524
3.78125
4
""" A program that will read through mbox.txt and list the senders. Author: Oscar Lopez """ senders = [] email_count = 0 try: fopen = open('mbox.txt') except: print('ERROR: mbox.txt does not exist.') for line in fopen: if line.startswith('From'): email_count += 1 words = line.split() ...
ad19418e935805036dc8699f88c34e8625571117
scyberboy/adventofcode_2020
/day_03.py
2,220
3.578125
4
import sys import re my_name = sys.argv[0] print("my_name:", my_name) day_nr = re.search(r"\d+", my_name).group() print("day_nr:", day_nr) def read_input(): _all = list() for line in sys.stdin: _all.append(line.strip()) return _all def find_sol_a(input_data): _inc_hor = 3 _inc_ver = 1 ...
55e4e8929aedc8103ed0ddb4d286db56648a11f3
Chen-Yiyang/Python
/Practical 2/q02_triangle.py
492
4
4
# Validating triangles and computing perimeter # by Yiyang 29/01/18 # check validity def _check(a, b, c, p): if p - a <= a: return False elif p - b <= b: return False elif p - c <= c: return False else: return True # initialisation a = int(input("Enter side 1: ")) b = i...
a93e82f155608f094b8282bc1660503245c3b0fa
Chen-Yiyang/Python
/Practical 2/q11_find_gcd.py
227
3.65625
4
# Computing the greatest common divisor # by Yiyang 29/01/18 N1 = int(input()) N2 = int(input()) if N1 > N2: N1, N2 = N2, N1 # swap N1 and N2 while (N2 % N1 != 0): N2 = N2 % N1 N1, N2 = N2, N1 print(N1)
196030f736d62d1bc1ee76da79251429274ffa1b
Chen-Yiyang/Python
/Practical 2/q06_kilograms_to_pounds.py
161
3.75
4
# Conversion from kilograms to pounds # by Yiyang 29/01/18 print("Kilograms\tPounds") for i in range(10): print("{0}\t\t{1:.1f}".format(i+1, (i+1) * 2.2))
942a6654583ce2653fdfe106f05ca582095a68ae
Chen-Yiyang/Python
/Practical 3/q6_display_matrix.py
258
3.8125
4
# Displaying matrix of 0s and 1s # by Yiyang 03/02/18 import random # for random numbers matrixSize = int(input()) for i in range(matrixSize): for j in range(matrixSize): print(random.randint(0,1), end = ' ') print() # i.e. '\n'
f0e3dc7f546b2f4dcff01d4bb2566a699daa310a
Chen-Yiyang/Python
/Practical 3/q2_display_pattern.py
1,106
3.984375
4
# Displaying patterns # by Yiyang, 04/02/18 # main ideas: # build a string of 'n n-1 n-2 ... 2 1' first # print it by line, and use the space between num. in the str to see if the num. shld be printed or replaced by ' ' def building_pattern(n): # WRONG METHOD: # numStr = "" # for i in range(n): # nu...
8f354486bd5a1696083f406ffb63e21fe5c982f7
agchou/product-recommender
/pyscript/util.py
1,664
3.5625
4
import math alphabet = ['b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] symbols = ['~','=','@','#','<', '>','$','%','^','&','*','(',')','_','+','{','}','/','|'] def reducer(num,arr, modulos=[]): modulos.append(num%len(arr)) if num/len(arr) > 0: r...
5715816ac18a48275018698cfccf2f2ac803b9b2
Anatje/genetic_algorithms
/code/traveling_salesman/traveling.py
5,258
4.1875
4
"""Traveling Salesman setup Preparation for hackathon 2019-01-18. Contains a start of the traveling salesman problem. creates (random) locations, shows how a random route looks, and can bruteforce the shortes route. Example: python traveling.py --help python traveling.py --example python traveling.py ...
3eef0059e052173dbcd9c24a7c66023f01826c85
Kateryna-hub/study
/Lesson_4/Lesson_4_Social.py
5,294
3.75
4
from datetime import datetime import sys from abc import ABC, abstractmethod class AuthorizationMixin: _list_of_users = [{'Surname': 'Petrov', 'login': 'ivan123', 'password': '1Qaz@wsx', 'data': '2020-11-10 23:22:21'}] _posts = [{'user': 'Petro1', 'title': 'post1', 'content': 'some kind of text', 'data creat...
328e6e78a080c516fe492d5d2e12e3a32b9d6a48
Kateryna-hub/study
/Lesson_2/Lesson_2_Shop.py
995
3.859375
4
class Store: total_goods_sold = 0 def __init__(self, name, num_goods_sold): self.name = name self.num_goods_sold = num_goods_sold Store.total_goods_sold += num_goods_sold #increase the amount of goods by specified value or by default = 1 def increase_sales(self, number_goods = ...
6b5886d4846074078b7ecfc93cd11eddb7128132
Pulkit008/HackerRank-Practice
/Python/12. Python Functionals/01. Map and Lambda Function.py
131
3.796875
4
cube = lambda x: x**3 def fibonacci(n): l = [0,1] for i in range(2,n): l.append(l[i-2] + l[i-1]) return l[0:n]
3323f2bf23dbf15609e5bb7c0c7494f61ec36d0b
Pulkit008/HackerRank-Practice
/Python/11. Built-Ins/06. ginortS.py
403
3.734375
4
# Either print(*sorted(input(),key=lambda a: ((1,a) if a.islower() else (2,a)) if a.isalpha() else ((3,a) if int(a)%2==1 else (4,a))),sep='') # or def ck(a): if a.isalpha(): if a.islower(): return (1,a) else: return (2,a) else: if int(a)%2==1: return ...
bec1a799c4645b70bf025b34e2f092c1185ff380
Pulkit008/HackerRank-Practice
/Python/02. Basic Data Types/03. Nested Lists.py
376
3.515625
4
student=[] mar=[] if __name__ == '__main__': for _ in range(int(input())): s=[] s.append(input()) s.append(float(input())) mar.append(s[1]) student.append(s) m=min(mar) mar.remove(m) while min(mar)==m: mar.remove(m) m=min(mar) student.sort() for i in range(len(student)): ...
42ddcaa64fba47f59c90b9dfe3be38d0d019e972
Pulkit008/HackerRank-Practice
/Python/03. Strings/01. sWAP cASE.py
91
3.796875
4
def swap_case(s): return ''.join([x.upper() if x.islower() else x.lower() for x in s])
034fee49964863b68ee01cda410c9d42bcaa3b08
annytcui/hello-world-practices
/CountDown.py
227
4.0625
4
import time print "This is a countdown timer!" seconds = int(raw_input("How many seconds do you want to count down? ")) print "Ok. Let's start!" for i in range(seconds, 0, -1): print i time.sleep(1) print "Blast Off!"
8750a32c9efcbd9d144ebc74aa67291d9cd28265
annytcui/hello-world-practices
/PwSignIn.py
1,452
3.625
4
import easygui, random from timeit import default_timer as timer password = "Markanny2016" easygui.msgbox("You need to type in a password to enter this program!") choice = easygui.choicebox("To learn about the password, you need to answer 30 simple multiplication questions. If you get all of them right in 60 seconds, ...
e3dbe40cb9a6ddc0ee77a96294ec67a3002cc7d6
annytcui/hello-world-practices
/YourFullName.py
164
3.921875
4
FirstName = raw_input("Please enter your first name: ") LastName = raw_input("Please enter your last name: ") print "Your full name is "+FirstName+" "+LastName+"."
367ad8c695d3cbab0e94f5c94afa63a57e0efa1b
markel-au/exercise6.py
/loveforprogramming.py
138
3.71875
4
#! /bin/python3 active = True while active: why = input("Why do you like programming:") if why == 'q': active = False
1f3d81a796588a17af56ae86b104939c4d191092
nafis195/CPSC-452-Final-Project
/s.py
5,720
3.5625
4
import socket import threading import select listenPort = 1234 # The socket the server uses for listening listenSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Associate the listening socket with # port 1234 listenSock.bind(('', 1234)) # Start listening with a connection backlog queue # of 100 listenSock...
44cc85fd4c14bfc26148cd4b501e71713596ac5d
mayfly227/day
/chapter04/class_var.py
190
3.671875
4
class A: aa = 1 def __init__(self,x,y): self.x = x self.y = y a = A(2,3) A.aa = 12 a.aa = 100 #实例找不到,就会向上查找 print(a.x,a.y,a.aa) print(A.aa)
36174a9f2283460d2c0c99141cb4ffbb3869f2d8
mayfly227/day
/chapter06/dict_subclass.py
499
3.984375
4
# 不建议继承list和dict # 有时候不会用调用继承的重写方法 from collections import UserDict,defaultdict class MyDict(UserDict): def __init__(self,**kwargs): super().__init__(**kwargs) def __setitem__(self, key, value): super().__setitem__(key,value) # 当找不到Key的时候调用 def __missing__(self, key): print(...
a77eafb26f5a7fde4f5b2c728635e5811d49ca6e
mayfly227/day
/chapter11/thread_sync.py
539
3.9375
4
import threading from threading import Lock,RLock # 锁会引响性能 # lock = Lock() lock = RLock() t = 0 def add(): global t for x in range(1000000): lock.acquire() lock.acquire() t = t+1 lock.release() lock.release() def desc(): global t for x in range(1000000): ...
d7e6b250543ee96a0f937a7e8e464d393fb2d1b0
mayfly227/day
/chapter11/gil.py
632
3.59375
4
# gil global interpreter lock (cpython) # python中一个线程对应于c语言中的一个线程 # gil使得同一个时刻只有一个线程在一个cpu上执行字节码, 无法将多个线程映射到多个cpu上执行 import dis,threading from threading import Lock lock = Lock() x = 0 def add(): global x for x in range(1000000): lock.acquire() x = x+1 lock.release() def desc(): ...
f884549ee90b60b3861f7fc9df1901c712933fa4
TimBossuyt/5WWIPython
/06-Condities/Test.py
491
3.890625
4
#True en False moeten met hoofdletter #Logische operatoren !!!!!! # not inverteerd #getal % 2 == 1 om te testen even / oneven getal = int(input('Geef getal: ')) if getal < 0: if getal % 2 == 0: print('Negatief even getal') else: print('Negatief oneven getal') elif getal > 0: ...
2957388616fd1b2594f5b12c92c1f8a86d421615
TimBossuyt/5WWIPython
/07-Uitbreiding-lussen/Chaos.py
464
3.671875
4
populatiedichtheid = float(input('Populatiedichtheid: ')) vruchtbaarheidsparameter = float(input('Vruchtbaarheidsparameter: ')) aantal_tijdstippen = int(input('Aantal tijdstippen: ')) populatie = populatiedichtheid print(populatie) for i in range(aantal_tijdstippen - 1): populatie = vruchtbaarhe...
88bb68c4e9d3f2430f0188d14851fd1becea5fe0
TimBossuyt/5WWIPython
/05-EenvoudigeFuncties/Absolute waarde.py
388
3.5
4
#invoer willekeurig_1 = float(input('Geef het eerste willekeurig getal ')) willekeurig_2 = float(input('Geef het tweede willekeurig getal ')) #berekening verschil_1 = abs(abs(willekeurig_1) - abs(willekeurig_2)) verschil_2 = abs(willekeurig_1 - willekeurig_2) #uitvoer uitvoer = '{:.4f} \N{LESS-THAN OR ...
328d0558512ac2d0a8ecf13d16b2f75a65649bf5
TimBossuyt/5WWIPython
/06-Condities/Uitbreiding/Atoommodel van Bohr.py
628
3.953125
4
aantal_elektronen = int(input('Geef het aantal elektronen tussen 1 en 156: ')) #berekening if aantal_elektronen - 124 > 0: schil = 'Q' elif aantal_elektronen - 92 > 0: schil = 'P' elif aantal_elektronen - 60 > 0: schil = 'O' elif aantal_elektronen - 28 > 0: schil = 'N' elif aantal_...
c7d718d8b7e5848d370fa464925a976c9d597377
TimBossuyt/5WWIPython
/07b-While-lus/BlackJack.py
403
3.671875
4
kaart = int(input('Geef een kaart: ')) totaal = kaart while totaal < 21 and kaart != 0: kaart = int(input('Geef een kaart: ')) totaal += kaart if totaal == 21: uitvoer = 'Gewonnen!' print(uitvoer) elif totaal > 21: uitvoer = 'Verbrand ({})' print(uitvoer.format(totaal)) el...
27ba21937c8bf4c75c79bea0b18623a0aac7af73
Omkarj21/Python_Pandas
/script01.py
10,068
3.703125
4
import pandas as pd import re dfcsv = pd.read_csv('pokemon_data.csv') # Read CSV dfxlsx = pd.read_excel('pokemon_data.xlsx') # Read Text dftxt = pd.read_csv('pokemon_data.txt', delimiter="\t") # Read Text print("DataFrame csv : ", pd.DataFrame(dfcsv)) dtfrm = pd.DataFrame(dfcsv["Name"][0:5]) print("Name Column Dat...
9b406f03b4b2229169e518f208aabcbf23398ac3
LeeHadad/refactor
/algo/algorithms/algorithms/searching/depth_first_search.py
1,111
3.921875
4
""" Depth First Search ------------------ Recursive implementation of the depth first search algorithm used to traverse trees or graphs. Starts at a selected node (root) and explores the branch as far as possible before backtracking. Time Complexity: O(E + V) E = Number of edg...
fb5ec26dd654e934f3fc1eaa98f1c601c8851d3f
LeeHadad/refactor
/algo/algorithms/tests/test_data_structures.py
24,999
3.65625
4
from random import shuffle import unittest from algorithms.data_structures import ( binary_search_tree, digraph, queue, singly_linked_list, stack, undirected_graph, union_find, union_find_by_rank, union_find_with_path_compression, lcp_array ) class TestBinaryS...
b3d570e27725fe364482d06c285e81f51e034b02
LeeHadad/refactor
/algo/algorithms/algorithms/dynamic_programming/lcs.py
1,305
3.890625
4
""" Longest Common Subsequence -------------------------- Implements the dynamic programming solution to the longest common subsequence algorithm. Pseudo Code: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem """ def build_lengths_matrix(str1, str2): """ XX...
a2e02492972038a37bdb67f467f1f29d57eabfaf
LeeHadad/refactor
/algo/algorithms/tests/test_searching.py
6,576
3.84375
4
""" Unit Tests for searching """ import unittest import math from algorithms.searching import ( binary_search, bmh_search, breadth_first_search, depth_first_search, kmp_search, rabinkarp_search, ternary_search ) class TestBinarySearch(unittest.TestCase): """ Tests...
932e1b03400efd0c77221bc047e7e402323d44f4
cmkobel/AiB
/project_5_Neighbor_Joining/phylip_like_parser.py
1,068
3.5625
4
# Author: Carl Mathias Kobel 2018 def parse(input_file): """ Parses a phylip like file into a dict with all the contents present. """ with open(input_file, 'r') as file: raw = [line.strip().split() for line in file] # Read in the complete file. rv = {'N': raw[0][0], 'taxa':...
90549f1d2e3430dbb25dd8581ef00725c4b6a3f3
Forevas/LeetCode
/Algorithms/medium/4Sum.py
3,138
3.796875
4
''' Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate quadruplets. For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0. A solu...
c4f64ced559f40a32097b0a83ee3609a0417dea3
ariel98po/SC101-projects
/SC101/SC101_week3/stack_print.py
261
3.734375
4
def main(): stack = [] while True: line = input('Give me a line:') if line == '-1': break stack.append(line) print_stack_out(stack) def print_stack_out(s): while len(s) != 0: print(s.pop()) if __name__ == '__main__': main()
ffdf577cd191a20107cb8d4beeb1f64337c685e5
ariel98po/SC101-projects
/SC101/SC101_week5/subsets.py
864
4
4
""" File: subsets.py Name: ------------------------- This file prints all the sub-lists on Console by calling a recursive function - list_sub_lists(lst). subsets.py is a famous LeetCode Medium problem """ def main(): """ LeetCode Medium Problem """ list_sub_lists(['a', 'b', 'c', 'd', 'a']) def list_...
34d5c0b230f58f7bbf9cde5ff9d37d1bdde02f87
tonyyzy/ProjectEuler
/51-75/57.py
265
3.75
4
numerator = 3 denominator = 2 total = 0 for i in range(1000): if len(str(numerator)) > len(str(denominator)): total += 1 a = numerator + denominator b = numerator + denominator * 2 numerator = b denominator = a print(total)
10aa7decba1648b2f7be7da83be67a1997f34e82
tonyyzy/ProjectEuler
/4-25/10.py
280
3.640625
4
import math def check_prime(a): root = math.sqrt(a) root = math.floor(root) for i in range(2, root +1): if a%i == 0: return False return True a = 0 for i in range(2, 2000001): if check_prime(i) == True: a += i print(a)
63d53aca1510932c8d6ab3f26f1fa22c6bda738e
ashahhar/Python
/sortA1VsA2.py
346
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 02 10:55:18 2016 @author: Rush """ A1= [2, 1, 2, 5, 7, 1, 9, 3, 6, 8, 8] A2= [2, 1, 8, 3] A3=[] A1.sort() for i in A2: for j in range(0, len(A1)): if i ==A1[j]: A3.append(A1[j]) #print A3 for i in range(0, len(A1)): if A1[i] not in A3: ...
2bad1035d8b78d9360ab20ab9ff1ed97b13d5f8b
runtangr/python_test
/test_view_str.py
221
3.75
4
#/usr/bin/env python # -*- coding:utf-8 -*- j = 0 num = input("请输入一个字符串:") # for i in num: # print(i[j]) length = len(num) while 1: if j == length: break print(num[j]) j+=1
fb07291856b2c61b15be9c150d4ba0463c7b485a
runtangr/python_test
/day3/test_str_to_dict.py
181
3.578125
4
#!usr/bin/env python # -*- coding:utf-8 -*- import pickle dic = {'k1':'v1','k2':'v2'} f = open('str_to_dict.txt','wb') f.write(pickle.dumps(dic)) f.close() print(dic)
111ad57ad6910a857918e83eec03fcf67e84446d
chadsantiago/Flames
/flames/duplicate.py
710
4
4
def remove_duplicate(name1_list, name2_list): # find the matching letters in both names duplicates = set(name1_list) & set(name2_list) # create a list for the matching letters duplicates = list(duplicates) # concatenate both names # set * as a border mark name_list = name1_list + ["*"] +...
787a3b062eee62dff17d9124918fe9a6b0d557a4
samer-yahia/Coding_Bootcamp
/Python/intro_to_OOP/user_with_bank_account/bank_account.py
1,782
4
4
class BankAccount: # Attributes bank_instances = [] def __init__(self, balance, int_rate): self.balance = balance self.int_rate = int_rate BankAccount.bank_instances.append(self) #Methods #Method will add the amount given to balance def deposit(self, amount): self.balan...
a3f8bf5f9432406494cb7a58af7e2c67acab05f8
Arunkumaranke/GUVI
/hello.py
69
3.859375
4
bu=int(input()) while(bu!=0): print("Hello\n") bu=bu-1
7b79fea7681a77403baa70bf4a40ac935c32d1aa
19025782-DevinLianDiLin/C300Python
/main code.py
1,439
3.9375
4
import ItemInformation # Information about the Item item1 = ItemInformation.Item(23456, "S", "Item A") item2 = ItemInformation.Item(23457, "M", "Item B") item3 = ItemInformation.Item(23458, "L", "Item C") item4 = ItemInformation.Item(23459, "C", "Item D") item_idList = [item1.id, item2.id, item3.id, item4.id] item_lo...
b7abe00038b12c7319582833aa61039006a2482d
EricOropezaelwood/Arcade-Fights
/Smooth Sailing/sortByHeight.py
423
3.96875
4
# Author: Eric Oropezaelwood """ Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! """ def sortByHeight(a): trees = sorted([c fo...
f823f1c9a8d501e06fafb5f4b4e58a96e3a2ef47
jorgehatccrma/TweetDreams
/src/python/tree.py
1,594
4.0625
4
# The tree can be implemented easily by abstracting the class Node # See the example at the bottom import common class Node(object): def __init__(self, tweet, parent=None): self.tweet = tweet self.children = [] self.parent = parent def addChild(self, obj): if type(obj) is not...
c06658cff13e69eac8292bd8219debb0d22deb9d
kkl918/Python_Algorithm
/Ex3.py
454
3.546875
4
# 檢測正整數n是否為2的冪次 # n=4 -> True, n=5 -> False class Solution: def checkPowerOf2(self, n): ans = 1 for i in range(31): if ans == n: return True ans = ans << 1 return False if __name__ == '__main__': sol = Solution() nums1 = 16 nums2 = 17 print('Input : ' + str(nums1)) print('Result : ' + str(sol...
9d0dec604ab6ca5aefcec6aca0a3766082e1419d
Aravind-39679/tri.py
/triangle.py
658
4.125
4
t=True while(t): A=int(input('Enter first side of the triangle:')) B=int(input('Enter second side of the triangle:')) C=int(input('Enter third side of the triangle:')) if(A+B>C and B+C>A and A+C>B): print("It is a triangle") if(A==B==C): print('It is an equailateral t...
76f3542e7ddea3b6cf90a40eb26c3e56ac8ba795
yairKoskas/ProjectEuler
/PE41.py
821
3.6875
4
import itertools import math import time start_time = time.time() sevens = [1,2,3,4,5,6,7] def isPrime(n): maxD = int(math.sqrt(n)) for i in range(2,maxD): if n%i == 0: return False return True def numFromDig(digits): digits = list(digits) sum = 0 for i in range...
4b348f12aa8a442b1048e84be6f982503ac908c8
wentingsu/Su_Wenting_spring2017
/Assignment3/Q2_Part1/Q2_PART+ONE.py
2,102
4.09375
4
# coding: utf-8 # ## EMPLOYEE COMPENSATION ANALYSIS # ### Q2_PART ONE # * Use 'employee_compensation' data set. # * Find out the highest paid departments in each organization group by calculating mean of total compensation for every department. # * Output should contain the organization group and the departments in e...
5cf854f23df871017b28ef6555b776680e8a381e
Noguerol123/aulaspython
/app/listas.py
356
3.953125
4
listas={} lista = {'leonardo', 'jonas', 'murilo','ronaldo','karol'} #Tamanho da lista print(len(lista)) #Pegando um dado da lista print(lista[1]) #Pegando intervalo print(lista [1:4]) print(lista[3:1-1]) for n in lista:#executa varias vezes até acabar a solução - listagem print(lista) for n in range(0,5):#for...
a5692419f929c72f0252ca889cc673d3cfb54699
dgtgghdgu/new
/BBFXPY/hashmap.py
1,730
3.734375
4
# -*- conding:Utf-8 -*- def new(num_buckets = 256): '''Initializes a map with the given number of buckets''' aMap = [] for i in range(0,num_buckets): aMap.append([]) return aMap def hash_key(aMap,key): ''' Given a key this will create a number and then convert it to an index for the aM...
de25cb93593c623e06e4a31ae4fb0f16db250fe4
dgtgghdgu/new
/BBFXPY/ex6.py
599
3.8125
4
x = "There are %d types of people." % 10 binary = 'binary' do_not = "don't" y = "Those who know %s and those who %s." %(binary,do_not) print(x) print(y) print("我说:%r" % x) print("我还说:%s." % y) hilarious = False #变量hilarious 变量赋值 joke_evaluation = "Isn't that joke so funny?! %r" #带转义符的字符串赋值给变量joke_evaluation print(j...
467ae7bc9f88519b8b3321af23b49c3026ab287f
jang010505/Algorithm
/BOJ/8723.py
136
3.671875
4
a, b, c=map(int, input().split()) if a==b and b==c: print(2) elif a*a==b*b+c*c or b*b==a*a+c*c or c*c==a*a+b*b: print(1) else: print(0)