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
a183ee4f0290014736958868df4659075504909a
laurenmitchell/Aritficial_Intelligence
/stackClass.py
471
3.875
4
class Stack: def __init__(self): self.items = [] def push(self,numItem): #adding numItem to end of the array self.items.append(numItem) def pop(self): #popping off the item in the array if(len(self.items) > 0): return self.items.pop() else: ...
38cf00481779501ddd1e5dae056df623863f771f
acoder18/Practice-Python
/fractorial.py
110
3.71875
4
def fractorial(x): num = 1 for i in range(1, x+1): num = i * num print num fractorial(5)
ebb2bd90d3abff42d7c293d23e277e53bc628470
stuartses/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
474
3.703125
4
#!/usr/bin/python3 """ 2. Exact same object Check if object is a exact instant of class Corresponds to Task 2. Holberton School Foundations - Higher-level programming - Python By Stuart Echeverry """ def is_same_class(obj, a_class): """function that returns True if the object is exactly an instanc of the spec...
e565859face5705525c10fe91e6e9e5111088773
stuartses/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,552
4.53125
5
#!/usr/bin/python3 """1. Divide a matrix This module divides all elements of a matrix in a number Corresponds to Task 1. Holberton School Foundations - Higher-level programming - Python By Stuart Echeverry """ def matrix_divided(matrix, div): """Function that divides all elements of a matrix in a number Args...
89dd71454d9de8106e1a44f5cc110e6a07902937
stuartses/holbertonschool-higher_level_programming
/0x0A-python-inheritance/9-rectangle.py
1,164
4.09375
4
#!/usr/bin/python3 """9. Full rectangle Implements Area and _str_ Corresponds to Task 9. Holberton School Foundations - Higher-level programming - Python By Stuart Echeverry """ BaseGeometry = __import__('7-base_geometry').BaseGeometry class Rectangle(BaseGeometry): """Class Rectangle Creates a new Rectangl...
b00edcdc40657f72d82766fd72da4de8d4b7c8cc
stuartses/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
699
4.125
4
#!/usr/bin/python3 """0. Integers addition This module adds two input integer numbers. Corresponds to Task 0. Holberton School Foundations - Higher-level programming - Python By Stuart Echeverry """ def add_integer(a, b=98): """Functions that adds two integers Args: a (int): first argument. Could ...
5975a8af2820c7ddfb6c42f012ed9c043f0fc153
stuartses/holbertonschool-higher_level_programming
/0x0A-python-inheritance/7-base_geometry.py
692
3.734375
4
#!/usr/bin/python3 """7. Integer validator With integer validator Corresponds to Task 7. Holberton School Foundations - Higher-level programming - Python By Stuart Echeverry """ class BaseGeometry: """Class BaseGeometry Defines Geometry""" def area(self): """Defines area""" raise Excepti...
bb6af66704feac939cbf8d941cc5866911309082
stuartses/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
249
4.0625
4
#!/usr/bin/python3 def uppercase(str): for i in range(len(str)): asci = ord(str[i]) chareq = str[i] if asci > 96 and asci < 123: chareq = chr(asci - 32) print("{}".format(chareq), end='') print()
3489fe426a7545e3061f559cb893503bbeaa2701
AndriiTorchuk/CI
/bank_test.py
860
3.9375
4
""" Exercise 10_2 Bank account (Check for emptiness, Add new account, Info from your account). Test Drivev Development """ import unittest from account import Account from account import Bank class BankTest(unittest.TestCase): def test_bank_empty(self): bank = Bank() self.assertEqual({}, bank.acco...
47de3b8c495703c92ae42feb69c91fbee73d99cf
itoyan/nlp100
/ch01/ans06.py
491
3.578125
4
#-*- coding:utf-8 -*- ''' 06. 集合 ''' # デフォルトは単語に対してbi-gramを返す def findNgramSet(string, n=2): return [ string[i:(i+n)] for i in range(0, len(string)-n+1) ] phraseA = "paraparaparadise" phraseB = "paragraph" X = set(findNgramSet(phraseA)) Y = set(findNgramSet(phraseB)) union = X.union(Y) # 和集合 ...
5967d3db9debad4fe367e267106d43b2ed3d0159
mizanurrahman13/PythonAbc
/FreeCodeCamp.org/Dictionary.py
656
3.890625
4
monthConversions = { "Jan": "January", "Feb": "Februry", "Mar": "March", "Apr": "April", "May": "May", "Jun": "June", "Jul": "July", "Aug": "August", "Sep": "September", "Oct": "October", "Nov": "November", "Dec": "December", } print(monthConversions["Oct"]) print(monthC...
8db91bf4975ff8d8076e836df54e2b988fbb4244
christian235/Demo
/highsupp/highsupp.py
3,152
3.5625
4
#!/usr/bin/python3 # Example for serial communication to iseg HV devices # Needs Python 3 and python3-serial import os import serial import sys class HV: v_lim = 50 def __init__(self, port=None): self.port = port self.baudrate = 9600 self.bytesize = serial.EIGHTBITS self....
14bcfcbf4cdf843b74d864e4f5af52f371e9d81e
daniela-botball/rus-botball
/2015-regional/PythonTestClient/main.py
1,286
3.640625
4
# Created on Sat April 4 2015 from kovan import * import socket HOST_FOR_SERVER = '' # Symbolic name meaning all available interfaces HOST_FOR_CLIENT = 'localhost' PORT = 5107 # Arbitrary non-privileged port print "I am the Client!" def main(): """ Calls the TEST functions in this module. """ client_o...
f736f1ecf3deb17807eadfef0ee193ea0450650c
mukaddesau/HackerRankQuos
/LongestCommonSubsequence.py
2,430
3.84375
4
''' File Name : LongestCommonSubsequence.py Author : Mukaddes Altuntas Created On : 03/12/2020 Version : Pyhton 3.7.4 Copyright (c) 2020 Mukaddes Altuntas. All rights reserved. Description : This program finds the longest subsequences between two strings using dynamic programming. The subsequence does not hav...
5007d357e858c2ea43de67203e93014fb2d250d5
biletska25/Testing_sorting_algorithms
/practical_task1.py
3,438
3.890625
4
import time import random import copy def selection_sort(A): counter = 0 for i in range(len(A)-1): min = i for j in range(i+1, len(A)-1): counter += 1 if A[j] < A[min]: counter += 1 min = j A[i], A[min] = A[min], A[i] ...
8f7da9e1bbd880b1c06e8bda8321b033f23b0c2a
Anna-Kukulevskaya/python-project-lvl1
/brain_games/games/second_exercise.py
1,507
3.921875
4
from random import choice, randint import brain_games.engine import prompt def generating_numbers(): num1 = randint(1, 100) num2 = randint(1, 100) operators = ["+", "-", "*"] operator = choice(operators) print("Question:", num1, operator, num2) return num1, operator, num2 def calc(num1, ope...
3e4001ac5f9e8762f618fb489ebe7d1054991572
ulikww/coursera_training_python_hse
/2 неделя/Максимум последовательности.py
111
3.796875
4
n = int(input()) max_n = n while n != 0: n = int(input()) if n > max_n: max_n = n print(max_n)
891df3d8ef34c042f49eb1fe158b13b3e28f0820
cleviane/mvcad-cursos
/teste.py
79
3.671875
4
nome = input("Digíte o nome do participante: ") print(f"{nome.capitalize()}")
cbab7af4c178d09a7f877e2d6fbd3cf0bdbbee30
ethan-sui/AI-algorithm-engineer-knowledge
/一、工程基础/软件工程/算法与数据结构/力扣题目/leetcode_035.py
897
3.625
4
# 35、搜索插入位置 # 一、暴力法,遍历所有的可能,寻找位置,时间复杂度O(n),空间复杂度O(1) def searchInsert0(nums, target): if target == nums[-1]: return len(nums)-1 if target > nums[-1]: return len(nums) if target < nums[0]: return 0 for i in range(len(nums)-1): if target == nums[i]: return i ...
04861617907ea4603347ac6061e0a2be80eea4e8
mattlytle789/Chess-Project
/Backend/SpaceClass.py
9,058
3.515625
4
from SpaceIDsSingleton import * import numpy as np # class that will represent a singular space on the board class Space(): # initializing the space class def __init__(self, id): self.color = '' self.occupied = False self.piece = None self.ID = id # function to find av...
eb7175404f882052612ea1d3fd86e8991bf3d9dd
pvsneha/internship-in-dataanalystics-with-python
/intropython.py
319
4.03125
4
import math print(math.sqrt(25)) print(math.floor(2.9)) print(3**2) print(math.pow(3,2)) from math import sqrt print(sqrt(25)) print(5*8) print(5.0*8) a=input("enter a number") print(a) print(type(a)) a = int(input("enter a number")) print(a) print(type(a)) a=eval(input("enter an expression")) print(a)
9d2132e35375b64668d03b741349f3874d65366b
mckaraca/bil481odev1
/algorithm.py
135
3.6875
4
def search(a,b,array): for x in array: if((a!=b) & (a > 0) & (b > 0) & (x > a) & (x < b)): return True return False
4ff3c3cd3009d5a9984928b54a89748b7792bec5
MyrPasko/python-test-course
/lesson11.py
567
4.25
4
# String formatting name = 'Johny' age = 32 title = 'Sony' price = 100 print('My name is ' + name + ' and I\'m ' + str(age) + ' old.') print('My name is %(name)s and I\'m %(age)d old.' % {'name': name, 'age': age}) print('My name is %s and I\'m %d old. %s' % (name, age, name)) print('Title: %s, price: %.2f' % ('Sony'...
6be0f9ecbade3f07466bece9a477ae7a4100dca5
Knraith/UCDPA_Jonathan-Brophy
/main.py
2,223
3.71875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt loan_data = pd.read_csv("lending_club_loan_two.csv") #importing libraries and CSV #This is all Pie chart Code following sum_of_credit_grade = np.unique(loan_data['grade'])#Getting unique Credit Grade Values from CSV. Using this to loop through a...
d877f51c0223ba43ba5b8ade696309572632bd56
deniskidagi/100-days-of-code-with-python
/day8-functions-with-input.py
2,155
3.75
4
# def greet_with(name, location): # print(f"hello {name}") # print(f"How is it like to live in {location}") # # # greet_with("denis", "kitale") # # #functions with keyword arguments # greet_with(name="denis", location="Eldoret") # #Area calc # import math # test_h = int(input("Enter height of the wall: ")) # t...
0d45281fe80cd884293a01bdae66bca566e8f614
deniskidagi/100-days-of-code-with-python
/day10-functions-with-inputs.py
1,755
4.21875
4
#functions with outputs # def format_name(f_name, l_name): # print(f_name.title()) # l_name.title() # # # format_name("denis", "DENIS") #challenge days in months # # def is_leap(year): # if year % 4 == 0: # if year % 100 == 0: # if year % 400 == 0: # return True # ...
88fdbd5cdd7c37ea5f5a78e4e5b312ea276fab42
wannaffly/Algorithm-notes
/Leetcode/树/94.二叉树的中序遍历.py
2,403
4
4
# 中序遍历 先遍历左子树->根节点->右子树 # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def preorderTraversal(self, root): ret, stack = [], [root] while stack: node = stack.pop()#pop最后一个元素 if no...
20fcf8b497bda9ac4345732c5a55a81552c47f11
KaushikApp123/KaushikPython
/lists.py
1,585
3.765625
4
# if __name__ == '__main__': # n = int(input()) # dataList = [] # # for x in range(n): # commandList = input().split(" ") # command = commandList[0] # if (command == 'insert'): # index = int(commandList[1]) # value = int(commandList[2]) # try: # dataList.insert(i...
80ac376b838d3f9b73a153e462c5290287ef7ec9
Guochiuan/NLP
/HW-3/hw3_skeleton_char.py
6,130
3.984375
4
import math, random import collections ################################################################################ # Part 0: Utility Functions ################################################################################ def start_pad(n): ''' Returns a padding string of length n to append to the front of ...
4c987ce22ecdfc579c473e2d7d5820a9be1b6a13
cynthiahuallanca/Portfolio
/Python-challenge/Pybank/main.py
3,326
3.96875
4
#----------------- # SCOPE: # Define lists with Months, Total Profit and Losses(PL) and Change of profit and losses, each one by itself so we can work on them separely and then with the index method, being able to analize the results. #----------------- # Importing modules (OS to create file paths across operating...
97e39634679ffd53663137a3308f3e8aebd9fb04
Abhisheksoni1/python_spellchecker
/spellcheker_v2_set.py
1,022
3.921875
4
import re import time from collections import Counter start_time = 0 def spellcheck(inputfile): count = 0 dictionary = open("dictionary", 'r').split("\n") words = open(inputfile, 'r').read().lower() words1 = re.sub("[a-z]*\d[a-z]*"," ",words) word1 = re.findall("[a-z]+\'*[a-z]*\'*[a-z]*", words1...
d7261fd426a5258c90693c5f2e093f97bfa42a2b
vangampalli/python-challenge
/PyBank/main.py
1,986
3.734375
4
import os import csv budget_data = os.path.join("..", "python-challenge", "PyBank", "Resources", "budget_data.csv") month = [] money = 0 money_list = [] money_list_ints = [] differences = [] with open(budget_data, "r") as csv_file: csv.reader = csv.reader(csv_file, delimiter = ",") csv_header = next(csv_file...
8c41f0d0a19febc2130b1015003cf8d45327403b
thefaultinourcode/codeducation
/adventure.py
727
3.90625
4
import random print "Welcome to Unicorn Valley!" unicorn_fate = raw_input("Do you turn left of right?") if (unicorn_fate=='left'): print "A pretty unicorn approaches you!" elif (unicorn_fate=='right'): print "You trip over a pretty unicorn." else: print "A unicorn attacks you for not following instructions." pet...
909b98d7d41f8eee197aa9434187482a87dd0371
thefaultinourcode/codeducation
/bottles_of_beer.py
477
3.90625
4
#declaring how much alcohol is on the wall bottles = 99 #for loop to go through all of the songs for x in range(1,100): if(bottles==1): print bottles, "bottle of beer on the wall,", bottles, "bottle of beer. \nTake one down, pass it around,", bottles - 1, "bottles of beer on the wall." else: print bottles, "bot...
2d14f3dd10db9c4d786dcf4fe87ee1b7fa91e7bd
blueskyxzy/algorithms
/mergesortxzy.py
1,150
3.953125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- from datetime import datetime import testdata # 归并排序 该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。 def merge(arr, low, mid, high): arr1 = [] arr2 = [] m = mid - low + 1 n = high - mid for i in range(m): arr1.append(arr[low + i]) for j in range...
4fe41e41cbe4a74354bcba7e3400103d3b6f6d81
blueskyxzy/algorithms
/quicksort.py
1,277
3.671875
4
#!/usr/bin/env python # -*- coding: UTF-8 -* import random from datetime import datetime import testdata def quickSort(arr, low, high): # 随机选择基准元素的快速排序,达到期望时间复杂度O(nlgn) # 注意high是最大下标 if low < high: mid = getPartition(arr, low, high) # 对基准元素两边的数组快排 quickSort(arr, low, mid - 1) ...
98f2804297572f3b6f2803be4decfb6d7223fffe
skdong/ant
/ant/leetcode/sliding_puzzle.py
1,318
3.515625
4
import copy class Solution(object): def slidingPuzzle(self, board): """ :type board: List[List[int]] :rtype: int """ puzzle = [[1,2,3],[4,5,0]] i, j = 1, 2 times = 0 graphs = dict() graphs[str(puzzle)] = 0 stack = list([[i,j,puzzle, tim...
777d13111e69d02be1f4f5f4657d303d27c058d2
tinahong94/python_homework
/list_less_than_10.py
378
3.9375
4
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] list_less_than_10 = [] list_less_than_new_number = [] new_number = int(input("Give me a number: ")) for number in a: if number < 5: list_less_than_10.append(number) print (list_less_than_10) for number in a: if number < new_number: list_less_than_ne...
bbe9f6139741eac1dc594da7526f2bf812833270
tinahong94/python_homework
/primality.py
825
4.15625
4
number = int(input("Give me a number: ")) divisor = [x for x in range(1, number + 1) if number % x == 0] print(divisor) def get_primality(n): divisor.remove(1) # divisor.remove(number) if not divisor: print("This number " + str(number) + " is prime number") else: print("This number " +...
8438cf2ec4d7b2638131742cd043b4ede7930132
matthewshaffer19/250FinalProject
/inex.py
12,656
4.34375
4
# # Authors: Matthew Shaffer and Luc Zbonack # Description: # This code is designed to take in a csv file and aide the user in drawing conclusions about # the data within it. Initially, it allows the user to specify the CSV file to use. # Then it gives the user the option to summarize the data either with one or...
b8696ed188b4060d6976fe66c889fc4f7c0749f4
AustinAkerley/crypto
/crypto/src/legendre_symbol.py
849
3.984375
4
# Title: Has Square Root # Creator: Austin Akerley # Date Created: 12/28/2019 # Last Editor: Austin Akerley # Date Last Edited: 01/19/2020 # Associated Book Page Nuber: N/A # INPUT(s) - # a - type: int, desc: the element to check if it has a sqrt in the field {0,1,2...,modulus-1} # modulus - type: int, desc: the modul...
93ab3eb0a9802eb9120775ad3bbc9e8e18a769e6
AustinAkerley/crypto
/crypto/ecc/cryptanalysis/lenstras_algorithm.py
1,206
4
4
# Title: Lenstras Factorization Algorithm # Creator: Austin Akerley # Date Created: 12/31/2019 # Last Editor: Austin Akerley # Date Last Edited: 01/20/2020 # Associated Book Page Nuber: 329 # INPUT(s) - # n - type: int, desc: composite number where n = p*q, where p and q are both primes import random from math import...
2a5d1fc7de39f537e30b1e03adacf8b2a10e4c21
AustinAkerley/crypto
/crypto/src/unit_test/test_primality_test.py
2,610
3.75
4
#!/usr/bin/python3 # Title: Unit Test for Primality Test # Creator: Austin Akerley # Date Created: 04/04/2020 # Last Editor: Austin Akerley # Date Last Edited: 04/04/2020 # Associated Book Page Nuber: N/A import unittest from crypto.src.primality_test import primality_test class TestPrimalityTest(unittest.TestCase): ...
77ca970a77cb9727110bc8d61a9c1aab1d9de502
AustinAkerley/crypto
/crypto/src/unit_test/test_mod_sqrt.py
1,723
3.515625
4
#!/usr/bin/python3 # Title: Unit Test for Modular Square Root # Creator: Austin Akerley # Date Created: 12/28/2019 # Last Editor: Austin Akerley # Date Last Edited: 01/19/2020 # Associated Book Page Nuber: 169 import unittest from crypto.src.mod_sqrt import mod_sqrt from crypto.cryptanalysis.small_primes_generator imp...
69e948481b44c1eb37690c7b87a5372697dd07da
adammorley/python
/reLearn/lambda.py
114
3.71875
4
#!/usr/bin/python3 f = lambda a, b: a-b print(f(5,2)) def subt(a, b): return a-b print(f(5,2)==subt(5,2))
87ceacf8750b9966d438beeb9d2aa6bb3df1ce0a
adammorley/python
/reLearn/mapFilterReduce.py
474
3.609375
4
#!/usr/bin/python3 from functools import reduce pets = ['alfred', 'tabitha', 'william'] upets = [] for pet in pets: upets.append(pet.upper()) print(upets) people = ['sally', 'sue', 'joe'] upeople = list(map(str.upper, people)) print(upeople) nums = [12, 35, 64, 22] def filterLow(num): return num > 20 hig...
318209abb0adae8ff5b9ea5425a17a3e833a59c0
adammorley/python
/reLearn/problems/minrotate.py
442
3.96875
4
#!/usr/bin/python3 from typing import Iterable def findMin(nums: Iterable[int]) -> int: if len(nums) == 1: return nums[0] mid = int(len(nums) / 2) if len(nums) < mid and nums[mid+1] < nums[mid]: return nums[mid+1] left = findMin(nums[0:mid]) right = findMin(nums[mid:]) if left...
fc1132c7cfd466ac02081173a5f031327281bc9d
adammorley/python
/factorial.py
268
3.71875
4
#!/usr/bin/python3 from functools import lru_cache @lru_cache(maxsize=256) def factorial(n): assert n > 0, 'positive ints only for now' if n == 1: return 1 return n * factorial(n-1) print(factorial(3)) print(factorial(5)) print(factorial(67))
9eba6d519112d51f7b54e0a92d8df1f0e2fd863d
Josephine-Tsai/sc-projects
/stanCode_Projects/breakout_game_starter/draw_line_2.py
1,225
3.703125
4
""" File: draw_line.py Name: Josephine ------------------------- This file uses campy module to draw lines and dots on a GWindow object. """ from campy.graphics.gobjects import GOval, GLine from campy.graphics.gwindow import GWindow from campy.gui.events.mouse import onmouseclicked # This constant control...
c0f67d2ae269111be857a7e56eafe88a00cbbd22
jplotkin21/examples
/example_scipy_minimize.py
2,943
3.65625
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """example script demonstrating usage of scipy.optimize.minimize""" from scipy.optimize import minimize, LinearConstraint import numpy as np import logging import matplotlib.pyplot as plt logging.basicConfig(level=logging.INFO) def f_oned_quadratic(x, *args): """...
22f21a75f4db518e796748c6d5bcc9a18db42a41
aqua270120/sandbox
/CP1404-Practical/prac4/lists_warmup.py
402
3.8125
4
def main(): #Change the first element to number 10 numbers = [3, 1, 4, 1, 5, 9, 2] for n, i in enumerate(numbers): if i == 3: numbers[n] = 10 print(numbers) for i in range(len(numbers)): if numbers[i] == 2: numbers[i] = 1 print(numbers) x = number...
4dca888ffe5a6b2177debc2e0d8136e320d66da2
Bayesd/exercise0_python
/get-value-from-dict/get_from_dict.py
284
3.953125
4
def get_age_from_person(person): age = person["age"] return age my_person = { "name": "Sarah", "age": 29 } age = get_age_from_person(my_person) print(age) # The correct answer here should be `29` #alternativt, om man vill kringgå metoden print(my_person["age"])
f0216033833cbb1343ebdf54bc4b50ed3b60f5aa
Asano-H/Hana
/pyramid.py
302
3.84375
4
print("整数を入力してください:",end="") inp=int(input()) i=1 while i<=inp: j=1 k=1 while j<=inp-i: print(" ",end="") j=j+1 while k<=i*2-1: print("*",end="") k=k+1 print(" ") i=i+1 """ 入力された段数のピラミッドを作成するプログラム """
04324df563ff3d83864d012ba0fb435761ccaf17
Asano-H/Hana
/strip.py
407
4.1875
4
a="abcabca" print(a) print(a.strip("a")) #両端の削除 print(a.lstrip("a")) #左端の削除 print(a.rstrip("a")) #右端の削除 print(" abc".strip()) #空白を削除 """ strip関数 .strip(削除したい文字列) 厳密には、削除ではなく特定の文字を取り除いた新しい文字列を返す処理 削除する文字列を指定しない場合、空白を削除 """
b89f70a801da804ddcaf01c51a84f96f51941910
Asano-H/Hana
/min.py
245
3.6875
4
def main(): print("4つの数値を入力してください") data=[input(),input(),input(),input()] print("最小値は",min(data),"です") if __name__=="__main__": main() """ 最小値を計算する関数 min(リスト名) """
d5a8343f17c249238b557a379e2671179b0b2dcb
Asano-H/Hana
/comment2.py
214
3.5625
4
str="Hello!"*3 print(str) """ 複数行にわたるコメント。 シングルクォーテーション[']、もしくはダブルクォーテーション["] を3つで対象とする範囲を囲む """
8833c717c78370f626f4db1ac3b8fd4cd853f17d
tomarpremveer/Python-codes
/doublylinkedlist.py
588
3.96875
4
class Node: def __init__(self, value): self.next = None self.prev = None self.val = value class dblLinkedList: def __init__(self): self.head = None def insertHead(self, value): new_node = Node(value) if self.head is None: self.head = new_node else: new_node.next = self.head self.head.prev =...
6443358e9f686439dbf524c13c6d02b692b6f472
tomarpremveer/Python-codes
/g.py
951
3.9375
4
class AdjNode: def __init__(self,data): self.value=data self.next=None class Graph: def __init__(self,vertices): self.v=vertices self.graph=[None]*self.v def add_edge(self,src,dest): node=AdjNode(dest) node.next=self.graph[src] self.graph[src]=node ...
e23e20632d635370cf05b8e1f6c0079cf1e173c3
FedoseevAlex/algorithms
/tests/insert_sorting_test.py
1,750
4.1875
4
#!/usr/bin/env python3.8 from unittest import TestCase from random import shuffle from algorithms.insert_sorting import increase_sort, decrease_sort class InsertionSortTest(TestCase): """ Test for insertion sorting functions """ def test_increasing_sort_static(self): """ Testing ins...
a9d418c426211f1ed3390adf88066f5fcd866af9
srikanthpragada/PYTHON_03_AUG_2021
/demo/assignments/09-AUG/largest_of_5_numbers.py
171
4.25
4
# Print largest of 5 numbers largest = 0 for i in range(5): n = int(input("Enter a number :")) if n > largest: largest = n print(f"Largest = {largest}")
8602210ddc9c1daa351cfa19a5a505c4678f9b43
srikanthpragada/PYTHON_03_AUG_2021
/demo/ds/enumerate_demo_2.py
126
3.546875
4
years = [1972, 1980, 1991, 1995] langs = ["C", "C++", "Python", "Java"] for i, n in enumerate(langs): print(n, years[i])
29847749ede6139ce34c257e2aed969f03a0bd13
srikanthpragada/PYTHON_03_AUG_2021
/demo/libdemo/list_customers_2.py
1,097
4.125
4
def isvalidmobile(s): """ Checks whether the given string is a valid mobile number. A valid mobile number is consisting of 10 digits :param s: String to test :return: True or False """ return s.isdigit() and len(s) == 10 def isvalidname(s): """ Checks whether the given name contai...
015ee12599e609bdabecf2491b64461a948f01e8
srikanthpragada/PYTHON_03_AUG_2021
/demo/libdemo/thread_demo.py
519
3.765625
4
import threading from threading import Thread print(threading.main_thread()) print(threading.current_thread()) def print_numbers(start, stop): for n in range(start, stop): print(f"Child2 {n}") class PrintThread(Thread): def run(self): for n in range(1, 11): print(f"Child1 {n}") ...
9023a84624a37ae19ffc3c37c30021c014da08ac
srikanthpragada/PYTHON_03_AUG_2021
/demo/libdemo/list_countries.py
298
3.53125
4
import requests response = requests.get("https://restcountries.eu/rest/v2/all") if response.status_code != 200: print("Sorry! Could not get details!") exit(1) countries = response.json() # Get JSON converted to dict for c in countries: print(f"{c['name']:55} {c['capital']}")
2d01ac6fd5555aa4f8b985d532e52a34a2e9f0ce
srikanthpragada/PYTHON_03_AUG_2021
/demo/libdemo/get_vizag_weather.py
389
3.515625
4
import requests city = "Visakhapatnam" yourid = "" response = requests.get( f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={yourid}") if response.status_code != 200: print(f"Sorry! Could not get details for city - {city}!") exit(1) details = response.json() # Get JSON converted to dict ...
4cc5dd9a4d3131ab88953c41a6e55405d9ac8f63
HamiltonCory/LyricsGenerator
/lottery.py
333
3.703125
4
import random # Generate tokens # Inputs Tuple def getRandomWord(input): print ("Starting lottery") numTotal = 0 for tuple in input: numTotal = tuple[0].size pick = random.seed(numTotal) for tuple in input: pick = pick - tuple[0].size if pick <= 0 ...
e8bc32aaf7eb827e289611e051a0c703e1beb31e
xLonsv1r/web-course
/flaskLab 1/taskClasses.py
1,691
3.90625
4
from abc import ABC, abstractmethod import random class AbstractBuilding(ABC): @abstractmethod def buildingHeight(self): pass class OfficeAbs(AbstractBuilding): def __init__(self, name, n): self.name = name self.n = n def buildingHeight(self): return self.n * 0.05 ...
5fa4791ec2dc8f607fa5ab8b76ac58542932baae
progh2/dgspythonstudy2017
/0507_class/SeoulLoveStory.py
1,322
3.90625
4
class TheGirl: lastname = "Allina" def __init__(self, name): self.fullname = name + self.lastname def fun(self, where): print("%s는 술 먹으러 %s에 갔네" % (self.fullname, where)) def love(self, other): print("%s, %s 사랑에 빠졌다<3" % (self.fullname, other.fullname)) ...
67e2193bc6622bcb1cfc8742192d623e64aef65f
sanbeam/scripts
/python/pickler/pickler.py
467
3.515625
4
#!/usr/bin/python import pickle def pickle_save (list, file): try: with open(file, 'wb') as pickle_file: pickle.dump(list, pickle_file) except: print("Sorry cannot open the file: pickle error") finally: pickle_file.close() def pickle_load (file): try: with open(file, 'rb') as pickle_file: list = pi...
c9c9ab8506f8a33664aade8b41601aac7f5f7df0
sanbeam/scripts
/python/course3/week2/reno.py
88
3.65625
4
import re x = "My Favourite numbers are 2 and 29 " y = re.findall("[0-9]+", x) print(y)
fd5b7ad897b16403c7985e92e02f6de39e926b65
leolimasa/fruitpunch
/fp_py/src/main/fruitpunch/searchable.py
2,593
3.734375
4
''' Created on Feb 16, 2013 @author: leo ''' class Searchable(object): ''' Allows classes that have a "children" array to be searched by using some convenience methods. ''' def find_by(self, attr, value=None): ''' Returns the first child that has an attr that is equal to value. ...
559a526cf95fd9089410172044a19491e55a77db
AvishDhirawat/Python_Practice
/bmi_calc using funcn.py
412
4.125
4
#Author - Avish Dhirawat def bmi_calc(name,weight,height): bmi=weight/(height**2) print ("BMI : ") print (bmi) if bmi<25: print (name + " is Under Weighed") elif bmi>25: print (name + " is Overweighed") else : print (name + " is Equally Weighed") a = input("Ent...
020e8491abac3c2cb707c4d612d8988c84593331
AvishDhirawat/Python_Practice
/PY_File_Move.py
616
3.671875
4
#!/usr/bin/env python3 import os import shutil folername = input("Enter folder from which you want to extract the files : ") curr_path = os.getcwd() next_path = os.getcwd()+"/"+folername if os.path.exists(next_path): print("Destination Path : ", curr_path) print("Source Path : ", next_path) number = 0 ...
db5aa9c6d24a9a875e436f7f50fe8693ef77d830
AvishDhirawat/Python_Practice
/BS.py
285
3.984375
4
arr1= [1, 3, 4, 5, 7] arr2= [2, 3, 5, 6] union = [] inter = [] for i in range(len(arr1)): for j in range(len(arr2)): if(arr1[i]==arr2[j]): inter.append(arr1[i]) else: union.append(arr1[i]) print("union : ", union) print("inter : ", inter)
6b7c9e4657b43ee97a0fb3b37e9608fa0a7792b0
AvishDhirawat/Python_Practice
/BreakingTheRecords.py
689
3.53125
4
#!/usr/bin/env python3 import math import os import random import re import sys # Complete the breakingRecords function below. def breakingRecords(scores): max_score = scores[0] max_count = 0 min_score = scores[0] min_count = 0 for i in range(1, len(scores)): if(scores[i] > ...
69708580ffc68f1cb20073cda01bcd97b1ccf089
xfx1993/goto1000
/test3.py
1,003
4
4
def wordsTyping( sentence, rows, cols): """ :type sentence: List[str] :type rows: int :type cols: int :rtype: int """ size = len(sentence) wordsize = [len(w) for w in sentence] if max(wordsize)>cols: return 0 index =0 cursize=0 count = 0 currow=0 while Tr...
a2b110889bcf8a594ee17c37b709429dfb64ba09
xfx1993/goto1000
/86.py
1,203
4.03125
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None head = ListNode(4) node1 = ListNode(2) node2 = ListNode(1) node3 =ListNode(3) head.next= node1 node1.next = node2 node2.next = node3 def insertionSortList( head): """ :type head: ListNode ...
db1db54957f37ce7b71f1e818dfb65bde9a87ec7
xfx1993/goto1000
/test92.py
323
3.6875
4
def minFallingPathSum(arr): """ :type arr: List[List[int]] :rtype: int """ num1=0 num2 =0 for i in range(len(arr)): if i%2==0: num1+= arr[i][0] num2 += arr[i][1] else: num1 += arr[i][1] num2 += arr[i][0] return min(num1,num2...
ad2aacd36487add590787b3e86446f6d2e214efd
xfx1993/goto1000
/test34.py
609
3.765625
4
def isScramble( s1, s2): """ :type s1: str :type s2: str :rtype: bool """ memo = dict() def createscramble(s1,s2): if sorted(s1)!=sorted(s2): return False if s1==s2: return True size = len(s1) for i in range(size-1): if ...
a6dd527832c75e0baeafa07e9bd22f5b9dd3ac7a
xfx1993/goto1000
/test5.py
1,303
3.796875
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None head = ListNode(1) node1 = ListNode(2) node2 = ListNode(3) node3 = ListNode(4) node4 = ListNode(5) head.next = node1 node1.next = node2 node2.next = node3 node3.next = node4 def revers...
bc63e770f7ffd8c1fe49238199528b179278300a
rentes/hacker-rank-python
/basic_data_types/lists.py
755
3.875
4
if __name__ == '__main__': N = int(input()) list = [] while N > 0: line = input() command = line.split()[0] if command == "insert": param1 = int(line.split()[1]) param2 = int(line.split()[2]) list.insert(param1, param2) elif command == "rem...
eabf184488a29b474ad5aa4d3cdd828d2bba8603
Dale-Xu1/KeyboardTrackpad
/trackpad/Keyboard.py
1,213
3.546875
4
import tkinter as tk from PIL import Image, ImageTk class Keyboard(tk.Canvas): def __init__(self, keys): super().__init__() # Get image image = Image.open('keyboard.jpg') self.image = ImageTk.PhotoImage(image) # Set canvas dimensions width = self.image.width() ...
cd3c41db2096d969d750df54b0b8c2eb4a6b7ab6
aldotele/rock_paper_scissors
/rps_game/helper/funny_names.py
467
3.625
4
import random class FunnyNameGenerator: # a name is created with a random combination of the following attributes adjectives = ["Bad", "Crazy", "Baby", "Big", "Lazy", "Friendly", "Shy"] animals = ["Unicorn", "Bird", "Shark", "Leopard", "Dog", "Cat", "Whale", "Hippo"] @staticmethod def compose_nam...
5b375696dcdcb57a94d5745f93c1bb4244a2acbb
dhakksinesh/Python-Programs
/Basics/fibonacci-series.py
139
3.96875
4
def fibonacci(n): a=0 b=1 print(a) while b<n : print(b) temp=b b=b+a a=temp fibonacci(100)
b7b7820e346c7aa3d8909f86d62edd469aee4324
Dilaxn/Hacktoberfest2021-2
/Fibonacci_sequence.py
312
4.1875
4
n = int(input("Number of terms? ")) a,b = 0, 1 c = 0 if n <= 0: print("Only positive integers are allowed") elif n == 1: print("Fibonacci sequence till",n,":") print(a) else: print("Fibonacci sequence is:") while c < n: print(a) nth = a + b a = b b = nth c += 1
22030ee8f5c901bbfb07b1f95c3238e5e897b74e
Dilaxn/Hacktoberfest2021-2
/Python-programs/Newton Raphson Method.py
328
3.546875
4
def f(x): return x**4-x-10 def f1(x): return 4*x**3-1 #initial guess x0=float(input()) #tolerance - Something like 1e-5, 1e-3, etc e=float(input()) c=0 print('x0\tf(x0)\tf1(x0)\tx1') while c<5: c+=1 x1=x0-f(x0)/f1(x0) print('%.3f\t%.3f\t%.3f\t%.3f'%(x0,f(x0),f1(x0),x1)) x0=x1 #Converged root pr...
5ad3e712911e9a843c11f17c5fcb031224007824
andre-deregle/LITS-PY
/game.py
10,388
3.875
4
#!/usr/bin/python # -*- coding: latin-1 -*- import os, sys import random cells = {} field_keys = [] def start(): output = True num = raw_input("\nWELCOME TO THE GAME! ARE YOU READY? ENTER THE NUMBER:\n1. Menu;\n2. Exit.\n") while(output): if num == "1": main_menu() output = False elif num ...
5da9150e4cc44b42e3966f8916468da266471c3e
sardination/cs136-finalproject
/trades/combinatorial_auction.py
652
3.53125
4
from mechanism import Mechanism class CombinatorialAuction(Mechanism): """ Implements the combinatorial auction trade mechanism """ def __init__(self, teams, config): super(CombinatorialAuction, self).__init__(teams, config) def run_year(self, year): """ Execute a VCG com...
023c32ba204e09f232db6d6c0cd9f8377c799506
JoelSVM/HiperCalculadora
/OperacionesBinaria.py
1,642
3.71875
4
def Operaciones_Binarias(numeros,numeros2,opcion): suma=0 suma2=0 cont=0 n=1 conversion="" pase="true" if len(numeros)>=len(numeros2): t=len(numeros) if len(numeros)<len(numeros2): t=len(numeros2) j=len(numeros) while pase=="true": while len(numeros...
8f00d4504d1cbe2b361d93c704c17718124da9fa
JoelSVM/HiperCalculadora
/Operaciones octales.py
1,199
3.609375
4
# -*- coding: cp1252 -*- def Operaciones_Octales(bits,bits2,op): aList=[] bList=[] n=len(bits) h=len(bits2) valor=0 valor2=0 resultado=0 conversion="" k=0 c=0 q=0 w=0 e=0 for i in range(len(bits)): aList.append(8**(n-1)) bList.append(8**(h-1)) ...
03b28b82a677e3b021e854a796f9fff6337a6cc6
ai1213/study_python
/reduce.py
519
3.875
4
import functools,random #2値を比較して条件に合致したほうの値を返す(今回は大きいほう) def get_bigger(a,b): if(a>b): return a else: return b #ランダムな数値をリストに詰める random_list =[] for i in range(10): random_list.append(random.randint(0,100)) #リストの中で最も条件に合致する要素を返す biggest = functools.reduce(get_bigger,random_list) print(...
4e16c4c32161ebacb35ad571a0ecced135993989
ai1213/study_python
/dentaku.py
1,066
4.09375
4
#フレームワーク(手を加えない) class Calc: #初期化でカスタマイズ用の関数定義を受け取り登録する def __init__(self,operation_list): self.operation_dict = {} for operation_tuple in operation_list: (operation,method) = operation_tuple self.operation_dict[operation] = method def run(self): while True: print('please...
38a5b0b72c9bf082302ac3699311e8bfc1dd355d
Kovalevskaya/NM
/mb.py
835
3.59375
4
#coding=utf-8 #Метод бисекций import math import matplotlib.pyplot as plt import numpy as np func = lambda x: (1 + x**2)*math.exp(-x) + math.sin(x) a1, b1 = 0.0, 10.0 acc = 0.001 def bic(a, b, f): root1 = a if f(a) == 0 else 0 root2 = b if f(b) == 0 else 0 roots1 = 0 roots2 = 0 x = (a + b)/2 while abs(f(x)) >...
c423e5fc44305bba959e3bcaffb73d36fafd49ce
ChoneungSon/Algorithm
/알고리즘 수업 정리/스택_03.py
216
3.609375
4
def f(n, k): global max_value if n == k: print(max_value) return else: if A[n] > max_value: max_value = A[n] f(n+1, k) max_value = 0 A = [1, 3, 2] f(0, len(A))
21bf6b2a220b73eb228e8afe58b6a0b7a4cb36e5
ChoneungSon/Algorithm
/스터디/200906/괄호 변환_손초능.py
986
3.53125
4
def balance(p): q = [] for i in p: if not q: if i == ')': return False q.append(i) else: if q[-1] == i: q.append(i) elif q[-1] != i and q[-1] == ')': return False else: q.pop() if q: return False ...
8b39354a8ba699fb36bda3932611505f6f145691
jhonsbg/currency-converter
/currency.py
785
3.984375
4
def calculo_conversion(tipo_pesos, valor_dolar): pesos = input("¿Cuantos pesos " + tipo_pesos + " tiene? ") pesos = float(pesos) dolares = pesos / valor_dolar dolares = round(dolares, 2) dolares = str(dolares) print("Tienes $" + dolares + " dólares") def run(): menu = """ Bienvenido al...
3da59a6ef09ad69ad0197d877961e6521add726f
Obichukwu/linkedin-python-data-structure
/run_deque.py
478
4.15625
4
from deque import Deque def is_palindrome(word): deq = Deque() for ch in word: deq.add_rear(ch) #deq.items = word.split() while deq.size() >= 2: front = deq.remove_front() rear = deq.remove_rear() if (front != rear): return False return True def test_...
f872c9f2b9793be717ef86d3a43965065edee9d5
TrellixVulnTeam/estruturas-de-dados_2JT6
/Louça.py
5,041
3.609375
4
class Nodo(): def __init__(self,dado): self.__dado = dado self.__prox_nodo = None def get_dado(self): return self.__dado def set_dado(self,novo): self.__dado = novo def get_prox_nodo(self): return self.__prox_nodo ...
18133d69347e7550e9cf78628e9c7623a1f963d0
OriaTori/BasicPython
/toto2.py
1,241
3.953125
4
#!user/bin/env python3 # -*- coding: utf-8 -*- import random try: numb = int(input("How many numbers will you want? ")) maxNumb = int(input("Put max value of this number: ")) if maxNumb < numb: print("You want to choose %s numbers from %s, which is not allowed because the numbers should be unique....
935d86fd71e43cad554f49a67ffc772391adaf3f
yhoo0007/PiRobotArm
/python/motor.py
3,690
3.578125
4
import math from pprint import pformat class Motor: def __init__(self, name, config, motor_controller): ''' Motor class which controls and keeps track of a motor on a motor controller. :param config: A dictionary object with the keys: controller_channel, name, serial_port, init_ang...