blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cbf992b7f7eeefae39252a0406be9bc50af64620
jmobriencs/Intro-to-Python
/O'Brien_Lab5/Lab5-5.py
2,318
4.125
4
# John-Michael O'Brien # w1890922 # CISP 300 # 2/27/20 # This program calculates the cost of purchasing a meal # This program includes decisions and loops # Lab 5-5 Yum Yum Burger Joint # the main function def main(): endProgram = 'no' while endProgram == 'no': # loop to run program again ...
1126a543151da9ae36e32de62f0cd902e4bfcaf0
MichaelJWest/Project-Euler
/problem5.py
390
3.59375
4
#2520 is the smallest number that can be divided by each of the numbers from 1 to #10 without any remainder. #What is the smallest positive number that is evenly divisible by all of the numbers #from 1 to 20? def gcd(a, b): return b and gcd(b, a % b) or a def lcm(a, b): return a * b / gcd(a, b) multiple = 20 fo...
2087ee36c6e44e3282a16811ebbbd4fcb57d14b3
akshay-verma/Cracking-the-Coding-Interview
/parenthesis_check.py
453
3.859375
4
from stack import Stack def checkParenthesis(string): st = Stack() for char in string: if char == "(": st.push(char) elif char == ")": if st.isEmpty(): return False st.pop() return st.isEmpty() if __name__ == "__main__": string = "...
5f47ca63a9f093a4310e91dbd9a1d90084d09ba7
RMIT-RoboCup-Standard-League/PP1-Nao-Soccer
/image/home/nao/data/behaviours/util/Hysteresis.py
2,243
3.734375
4
# A utility class to help stop decisions from flicking between alternatives # Methods are chainable, e.g. hysteresis.adjust(x < 20).is_max() class Hysteresis(object): # Min and max can be set, but the initial value is always 0 def __init__(self, min_value, max_value, up_amount=1, down_amount=1): self....
fa161b979365810fb2e2747675a5f5e0fe2b3102
proximac3/Python-practice-problems
/11_flip_case/flip_case.py
738
4.15625
4
def flip_case(phrase, to_swap): """Flip [to_swap] case each time it appears in phrase. >>> flip_case('Aaaahhh', 'a') 'aAAAhhh' >>> flip_case('Aaaahhh', 'A') 'aAAAhhh' >>> flip_case('Aaaahhh', 'h') 'AaaaHHH' """ # split pharse to make it mutable split_p...
b0f64c7c7fb5b0a0c398fb1e1abaf3641a7bd79a
viniciusantigo/ExerciciosPython
/String/ex03.py
133
3.703125
4
'''3. Faça um programa que leia uma frase e a exiba toda em letras maiúsculas.''' frase = input('Frase: ').upper() print(frase)
6e34635af1640a6b149ebf82d6f32f7dd4a8dca5
jrinder42/Advent-of-Code-2020
/day25/day25.py
1,212
3.84375
4
''' Advent of Code 2020 - Day 25 ''' # Diffie-Hellman key exchange card_public_key = 0 door_public_key = 0 with open('day25.txt', 'r') as file: for line in file: line = line.strip() if card_public_key == 0: card_public_key = int(line) else: door_public_key = int(...
2ed09bc6f274af581b0d9d533b5db453f3254411
bobfishtincar/ticTacToeAI
/main2.py
1,558
3.609375
4
import functions import mark2 import mark1 import random import time numGames = 0 games1 = 0 games2 = 0 for i in range(0, 1): board = functions.createNewBoard() prevBoard = [n[:] for n in board] turn = True if random.randint(0, 1) == 0 else False while functions.isGameOver(board) == -1: pr...
e4f4980fa5a5169812e74840b1b36e1e16cf24c2
ys0823/Leetcode-Daily-Code
/Leetcode-ys/leetcode-99.py
1,035
3.703125
4
#---------题目描述--------------- #https://leetcode-cn.com/problems/recover-binary-search-tree/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def recoverTree(...
9bca7d8156ab235a27b770fa5c021aaa4311ba95
michdol/data_structures
/queue/queue.py
698
3.765625
4
class Queue(object): def __init__(self): print('asd') self.items = [] def is_empty(self): try: self.items[0] return False except IndexError: return True def enqueue(self, value): self.items.append(value) def dequeue(self): ...
e6f8044069d9992a3a0d9f6ebb877f2dd02acd86
RandomTripy/calculater-HW
/Calculater.py
485
4.03125
4
a = input ("Enter the number if you want a plus or divide whatever = ") b = input ("Okay.. well... enter the other number please") m = int(a) n = int(b) def plus(a, b): print(a + b) def minus(a, b): print(a - b) def multiply(a, b): print(a * b) def division(a, b): print(a / b) def quotient(a, b): print...
d2662059574d3981f7762e6e989a0ce6e013d82c
udhayacommits/j5
/tests/backends/hardware/j5/mock_serial.py
2,732
3.515625
4
"""A class that mocks serial.Serial.""" from typing import Optional class MockSerial: """This class mocks the behaviour of serial.Serial.""" expected_baudrate = 9600 def __init__(self, port: Optional[str] = None, baudrate: int = 9600, bytesize: int = 8...
af8b4148eb461dff6de7656e3169b3274d091522
cjduffett/Python-Projects
/Always Turn Left/MazeController.py
1,431
3.625
4
import sys from Maze import Maze # ---------------------------------------------- # Evaluates a set of mazes given an inout file # ---------------------------------------------- class MazeController: def __init__(self): self.num_mazes = 0 self.mazes = list() ''' Read the input file ...
24c65db81de0eda9e6667a0358333c1935fc0a80
hoang-ng/LeetCode
/LinkedList/92.py
1,233
3.984375
4
# 92. Reverse Linked List II # Reverse a linked list from position m to n. Do it in one-pass. # Note: 1 ≤ m ≤ n ≤ length of list. # Example: # Input: 1->2->3->4->5->NULL, m = 2, n = 4 # Output: 1->4->3->2->5->NULL # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.va...
9208234fb8798d8f6877d76f60f9e5b15d193ebf
FIRESTROM/Leetcode
/Python/203__Remove_Linked_List_Elements.py
1,363
3.890625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode """ dum...
615eb32d94050e94fcfb3a1bd7d53414adeb3f82
samarapa/python-programming
/basic/ex83.py
88
3.921875
4
num = [1,2,3,4,5,6,6,7,8] print(all(x > 2 for x in num)) print(all(x > 0 for x in num))
9db27cc66df86832fdeda49b708cc629dd09b3b7
to2bage/mixx
/lintcode/test/02.py
1,224
3.578125
4
class Solution(object): def threeSumClosest(self, nums, target): if not nums or len(nums) < 3: return 0 nums.sort() import sys minnum = sys.maxsize result = 0 for i in range(len(nums)-2): if i > 0 and nums[i] == nums[i - 1]: con...
eeb0ba7b2ebd9773fbf18748af109ea4347716ea
NeelBit/practica_python_pildorasInformaticas
/practicas condicional.py
1,074
3.65625
4
# ctrl + alt + b : para ejecutar python # python tiene concatenacion de operadores en condiciones: 0<edad<100 seria edad mayor que cero y menor que 100. Lee de izquierda a derecha, osea si edad no es mayor a cero, ignora el resto # concatenacion de comparadores de operacion! salarioPresidente = int(input("Ingrese sal...
6d1b3d1e5814dff1890ba2163a0bcc20754e8f7d
rdessart/pygame_engine
/window.py
2,010
3.65625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- import pygame # from pygame.locals import * from . import color class Window(): """Handle a graphical windows""" def __init__(self, caption: str = "Pygame"): """Default constructor""" self.window = None self._resolution = () pygame.d...
d30e419b2533c66b8cc99d8d6357f45d9bdac197
lalitkapoor112000/Python
/Average of three numbers bu formatting.py
140
4.03125
4
a,b,c=input("Enter three numbers seperated by comma:").split(",") avg=(int(a)+int(b)+int(c))/3 print(f"average of {a},{b},{c} is {avg}")
088f927f5484d27d5ad614e7bd50d35470096630
EDAII/Lista1_JoaoVitor_JoaoPedro
/busca_sequencial_sentinela.py
1,181
3.703125
4
import random import time def busca_sequencial_sentinela(lista, elemento): """ Reliza busca sequencial com sentinela do elemento passado por parametro lista -- lista de inteiros desordenada elemento -- elemento a ser buscado """ contador = 0 lista.append(contador) try: ...
ee6599aedebe2263dc1b7ac96e3050897145865a
SeymourCray/echo_server
/client.py
944
3.71875
4
#!/usr/bin/env python3 import socket HOST = '127.0.0.1' # The server's hostname or IP address PORT = 65432 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: try: s.connect((HOST, PORT)) # connect to server print('connection with server was success...
6f7e60c2cff4d1e2253a0951cb92e73002692551
Mi-Rage/Python_HyperSkill
/banking/storage.py
2,827
3.5
4
import sqlite3 class Storage: def __init__(self): self.conn = sqlite3.connect('card.s3db') self.create_table() self.current_acc_id = -1 def create_table(self): cur = self.conn.cursor() cur.execute( 'CREATE TABLE IF NOT EXISTS card (id INTEGER PR...
36a3effc827212796677f2b06cc7b43654ad88f3
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/bdhsan003/question2.py
292
4
4
#STUDENT NUMBER:BDHSAN003 def triangle(): triheight1=eval(input("Enter the height of the triangle:\n")) s=1 shape=triheight1 for i in range(0,triheight1): print(' '*(shape-1),end='') print('*'*(s)) shape=shape-1 s=s+2 triangle()
a0f589746ae73fed164de175ee3c23b3f5b86e6f
vkguleria/exercises
/test_defaultdict.py
1,207
3.765625
4
''' In this challenge, you will be given 2 integers, n and m. There are n words, which might repeat, in word group A . There are m words belonging to word group B. For each m words, check whether the word has appeared in group A or not. Print the indices of each occurrence of m in group A. If it does not appear, print ...
57e3eaf7fea13366184ba43045142b0bcd61fa8f
satot/daily_coding_problem
/887_egyptians.py
649
3.90625
4
import unittest def solve(a:int, b:int) -> list[str]: result = [] i = 1 while a > 0: i += 1 if 1/i > a/b: continue a = i * a - b b = i * b result.append("1/" + str(i)) return result class TestFunc(unittest.TestCase): def test1(self): a = ...
dc741bf1f67ba76a3d583b702a836dde55345d47
saurav595/millennialfinance
/Runcode.py
4,333
4.1875
4
from Menu import menu #for the menu options from Salary import Salarycalc #for the salary calculations like optimum rent, buy or rent, savings and retirement age from credit_score import Credit_Score_Analysis #for the credit score computations like credit check and credit score analysis from budget import budget #for c...
a91eda8be049d43e1b2d6bea45cac548480d81cc
nsrinivasapps/myprojects
/DataStructures and Algorithms/Sorting/MergeSort.py
1,095
4
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Oct 5 11:45:05 2018 @author: shrinivaass """ def merge(lefthalf,righthalf): i=0 j=0 sortedlist = [] while i < len(lefthalf) and j < len(righthalf): if lefthalf[i] < righthalf[j]: sortedlist.append(lefthalf[i]) ...
7acf283ad2d0b0e569c499adaf45f41c8940f0e1
dlime12/Data-Analysis-Python
/case_study2/clustering.py
3,765
3.5625
4
# Data Processing function for this specific dataset from prep_menC import * # Data modelling libraries import pandas as pd import numpy as np # Scaling the values so it suits for clustering from sklearn.preprocessing import StandardScaler # K-Means clustering from sklearn.cluster import KMeans # Silhouette score f...
c919a926f77111864311763534fbdc4e0d437ab4
vishsangale/codeKatas
/legacy_katas/CK6.py
352
4.03125
4
""" Replace all spaces with given characters Time complexity O(n) Space Complexity O(n) """ def answer(string, chars): out_string = [] for s in string: if s == " ": out_string.append(chars) else: out_string.append(s) return "".join(out_string) print an...
2b0c5f25a5e29f0344b544f2ad4440ae6286407a
mbentz80/jzigbeercp
/python/packages/scipy-0.6.0/scipy/cluster/vq.py
21,025
3.546875
4
""" Vector Quantization Module Provides several routines used in creating a code book from a set of observations and comparing a set of observations to a code book. All routines expect an "observation vector" to be stored in each row of the obs matrix. Similarly the codes are stored row wise in t...
b1c38fa2b1cef02bfe1207beb39133ee6e380346
diegohabarbosa/Basics-Projects
/CursoemVideo/Curso_de_Python/Mundo2_40hs/Exercícios/ex049.py
159
3.71875
4
#049 - Tabuada v.2.0 t = 0 n = int(input('Digite um número para ver sua tabuada: ')) for c in range(1,11): t = n*c print('{} x {} = {}'.format(n,c,t))
10ac6f1e2c9878d419ea076626ac4c0ddefdcfab
hiteshram/outbreak-dection
/place.py
1,150
3.671875
4
class Place: def __init__(self,id,name,desc,latitude,longitude): self.place_id=id self.place_name=name self.place_type=desc self.place_lat=latitude self.place_long=longitude def print_place_details(self): print('Place ID : ',self.place_id) print('Place N...
d75684380b4379fb7f06bf41a11be5f051ba24a2
jamiekimm/coffee
/haiku.py
534
3.53125
4
five1 = ['i like your hat', 'you are beautiful', 'you have a large neck'] seven = ['it is a very cute one', 'you shine like a shooting star', 'it is very big on you'] five2 = ['I wish i had one', 'shine bright today please', 'please make it smaller'] #five1 from random import randint random1 = randint (0,len(five1...
ae91a2ca2a1baf007355893878e9336fc5afa85b
ascurlock/Scurlock-Math361B
/IntroToProgramming/FibSeq2_Scurlock.py
1,527
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 11 20:38:40 2019 @author: Ashley """ #%% N = 100 m = 30 terms = [0] * N multiples_m = [] for n in range(N): if n == 0: terms[0] = 0 elif n == 1: terms[1] = 1 elif (n != 1) or (n != 2): terms[n] = terms[n-1] + te...
2fa22337467d63d04fd0a552a16d18b1d208f37a
EthanGraber/cluelist
/cluelist.py
15,339
3.78125
4
#TODO allow more room for input errors throughout the entire program (prevent crashes, allowed editing of guesses, etc) import os #Give program information on the general setting of the game num_players = input("How many players: ") num_cards = input("How many cards: ") #Declares all the lists and dictionaries needed...
8e4aa7531c8756afdb857b8cbc4bccc9da3d0b45
turo62/exercise
/exercise/codewar/uniq.py
292
3.625
4
import array def find_uniq(arr): num = max(arr) counter = arr.count(num) if counter == 1: unique = num else: unique = min(arr) return unique def main(): unique = find_uniq([ 0, 0, 0.55, 0, 0 ]) print(unique) if __name__ == "__main__": main()
dd9f4e68219d10db948c0c5e822e53ed94a981c2
WilliamTun/Design-Patterns
/creational/singleton/singleton.py
1,026
4
4
''' Singletons There are cases when we only want to initialise an object ONCE. Eg. a Database or spark framework. You want to be able to initialise this object lazily and ONLY when needed. ''' def singleton(class_): instances = {} def get_instance(*args, **kwargs): if class_ not in instances: ...
c95d31eea14d757296eade1b392a3f00bdd68adb
michaellinp/PythonGo
/面向对象高级编程/枚举类.py
2,113
4.09375
4
# 当我们需要定义常量时,一个办法是用大写变量通过整数来定义,例如月份: # # JAN = 1 # FEB = 2 # MAR = 3 # ... # NOV = 11 # DEC = 12 # 好处是简单,缺点是类型是int,并且仍然是变量。 # # 更好的方法是为这样的枚举类型定义一个class类型,然后,每个常量都是class的一个唯一实例。Python提供了Enum类来实现这个功能: from enum import Enum Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov...
2dc34de36504a2f45a7f31b5cffc05ae66c5c7f5
ryanlsmith4/wikipedia_graphs
/graph.py
7,868
3.90625
4
#!python import sys import random """ Vertex Class A helper class for the Graph class that defines vertices and vertex neighbors. """ from collections import deque class Vertex(object): def __init__(self, vertex): """initialize a vertex and its neighbors neighbors: set of vertices adjacent to s...
bdedfb83e968a40105ef1072b7b46a3767ce1646
jvrcavalcanti/Algorithms
/data_structure/binary_tree.py
2,227
4
4
class Node(object): def __init__(self, state): self.state = state self.left = None self.right = None def search(self, state): if state == self.state: return self.state if state > self.state and self.left is not None: return self.left.sear...
8a5733818d116716ba9fd043f81a21123049f2b2
wwtdsg/Datastruct-Algorithm
/fib.py
359
3.75
4
#! -*- coding:utf-8 -*- # 裴波娜契数列优化算法 # 建立一个数组,使用一个for循环读取,比递归调用效率明显快很多 def fib(n): if n == 1: return 1 else: temp = [1] temp.append(1) for i in range(n): temp.append(temp[i] + temp[i + 1]) return temp[n] print fib(10000)
533a4eaa6d779b11497f1718a044746e25ef6822
trigunawan89/30_seconds_of_code
/digitize.py
126
3.703125
4
#Converts a number to a list of digits. def digitize(n): return list(map(int, str(n))) a = digitize(123455) print(a)
b31d3502626508000253c1de74653e4d71b4c26f
ducanh166/doanducanh-fundamentals-c4e25
/Session03/homework/shop.py
863
4.03125
4
items = ["T-shirt", "Sweater"] loop = True while loop: order = input("Welcome to our shop, what do you want (C, R, U, D)? ") if order == "R" or order == "r": print("Our items: ", end = "") print(*items, sep=", ") elif order == "C" or order == "c": y = input("Enter ne...
e81ab019fc27d9c4530c7b5336d2f953dd2a11d8
VASUVG/Traning-Class-
/56.py
129
3.703125
4
Tide=input() for j in range(0,len(Tide)): if(Tide[j].isalpha() and Tide[j].isdigit()): print("No") else: print("Yes")
766c5d3fd0c6ff46ead10d45458c529744737eac
gmaru95/changwonai
/ares_of_shapes.py
228
3.671875
4
def func(shape, width = 1, height=1, radius =1): if shape == 0: return width * height if shape == 1: return 3.14* radius **2 print("rect=",func(0, width= 10, height=2)) print("circle=",func(1, radius=5))
b1ffb9c249161aed4c5e78744d5d33a27821c241
AdamZhouSE/pythonHomework
/Code/CodeRecords/2295/60885/241902.py
1,038
3.734375
4
def Node(val): return {'val': val} def find(root, val): if root['val'] == val: return root if 'left' in root: result = find(root['left'], val) if result: return result if 'right' in root: result = find(root['right'], val) if result: return...
e37258c7205631eb3dc4a62f15abc2dac01bd2a6
morluna/Elements-of-Software-Design
/Fraction.py
270
3.828125
4
class Fraction: def __init__(self,top,bottom): self.num = top self.den = bottom def __str__(self): return (str(self.num) + "/" + str(self.den)) def show(self): print(self.num, "/", self.den) def main(): twoFifths = Fraction(2,5) print(twoFifths) main()
5a9a99f9e9482f59a89cbc24133200af4a4d3887
madeibao/PythonAlgorithm
/py顺时针打印矩阵2.py
665
3.75
4
# 顺时针来打印矩阵。 class Solution(object): def clock_print(self,matrix): l, r = 0, len(matrix[0])-1 t, b = 0, len(matrix)-1 res = [] while True: # 从左面到右面。 for i in range(l,r+1): res.append(matrix[t][i]) t+=1 if t>b: break for i in range(t,b+1): res.append(matrix[i][r]) r-=1 if l>r: ...
a1c786b504c3378e19d098ef96b34f69bcabaa78
tamura0425/test
/git/Python/paiza1.py
113
3.609375
4
c = 0 a = int(input()) for i in range(a): b = int(input()) if b >= 5: c += b print(c)
5714fa959b533314eb05210e77646c7ef6b7f8f6
Lewis-11/Project-Euler
/46.py
572
3.96875
4
import math def isPrime(n): #check if n is prime if n==1 or n==0 or n<0: return False if n==2: return True elif n==3: return True else: for i in range(2,int(math.sqrt(n))+1): if n%i==0: return False return True for i in range(7,1000...
0c1d5b1895166b5df7421d225c227ec5bc09c535
sivasamba/sivapython
/Tasks/task13.py
362
3.890625
4
#the parameter weekday is true if it is a weekday,and the parameter vacation is true if we are in tuble. def sleep_in(weekday,vacation): if vacation or weekday!=True: return True elif vacation or weekday==True and vacation and weekday==False: return False else: return False print(s...
487f9b83b26c9fb4d91832143a81376efb94ba4b
sebkeil/Group20-VU
/amsterdam-airbnb/keras groundwork.py
709
3.65625
4
from keras.models import Sequential from keras.layers import Dense import pandas as pd # read in csv files X_train = pd.read_csv('train.csv') y_train = pd.read_csv('y_train.csv', names=['price']) X_test = pd.read_csv('test.csv') y_test = pd.read_csv('y_test.csv', names=['price']) # Create the model: model model = Se...
37141aafd4b8799145f41b8b92d3e911678c8d20
JorJeG/python
/9/OrderedDict/ordereddict.py
450
3.640625
4
from collections import OrderedDict knowed_words = OrderedDict() knowed_words['list'] = "Allow to store sets of information in one place" knowed_words['dictionary'] = "Allow to connect pieces of related information." knowed_words['function'] = "It is named blocks of code." knowed_words['class'] = "Classes that represe...
1da9da4de3c57a593b386148da46aeb54ccbe5dc
gouwangrigou/Python-
/8.12.py
246
3.5
4
def make_sandwish(items): sandwish = [] for item in items: sandwish.append(item) print(item) return sandwish my_sandwish = ['rou', 'dan', 'nai'] my_sandwish = make_sandwish(my_sandwish) print(my_sandwish)
48f6bbd6efc780d797c81f699fe2c76cdd521741
sayak-3848/codingbat
/List2/count_evens.py
351
4.21875
4
## Return the number of even ints in the given array. ## Note: the % "mod" operator computes the remainder ## eg. 5%2 is . def count_evens(nums): count = 0 for i in nums: if i%2 == 0: count = count + 1 return count print(count_evens([2,1,2,3,4])) print(count_evens([2,2,0]))...
93603fd85d9ffdbac3f50a7c92ac2f98afee347b
misa9999/python
/courses/python3/ch123-unkown/14_lesson/01_challenge.py
227
4.25
4
num = input('Type a number: ') try: if int(num) % 2 == 0: print(f'{num} is even') else: print(f'{num} is odd') except Exception as e: print(f"'{num}' isn't integer number") print(f'ERROR: {e}')
6f42662dade7bd028bfdbd33251e93007c71a053
bashikan/python
/moji.py
2,176
3.75
4
# moji='abc'+'def' # print(moji) # moji='-'*10 # print(moji) #14-1 # moji=input('文字列を入力:') # print(moji) #14-2 # moji=input('文字列を入力:') # print(len(moji)) #14-3 # moji=input('文字列を入力:') # mojik=len(moji) # if mojik>10: # for i in range(10): # print('{}'.format(moji),end='') # else: # print(moji) #14-...
850f434f7211f0d2d55093ef3d8de47f8ad1570e
yanbinkang/problem-bank
/ik_problems/linked_lists_stacks_queues/reverse_in_groups_of_given_size.py
1,248
4.0625
4
from sll import * """ question: reverse a linked list in groups of given size ref: http://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/ input: 1->2->3->4->5->6->7->8->None and k = 3 output: 3->2->1->6->5->4->8->7->None input: 1->2->3->4->5->6->7->8->None and k = 5 output 5->4->3->2->1->8->7->6-...
4053bc41df1df206bc90c0d982f46585e797ba49
kaitoukito/learnNumPy
/create.py
356
3.578125
4
import numpy as np # example1 x = np.empty([3, 2], dtype=int) print(x) # example2 x = np.zeros(5) # the default type is float print(x) y = np.zeros((5,), dtype=np.int) print(y) z = np.zeros((2, 2), dtype=[('x', 'i4'), ('y', 'i4')]) print(z) # example3 x = np.ones(5) # the default type is float print(x) x = ...
aec9ca45d353193542ad9edf15531c397e40dfac
xudong-sun/leetcode
/075_Sort_Colors.py
2,893
4.09375
4
''' Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. A rather straight forward solution is a tw...
5eea975f84adea741d3ca0e45daf18eb358b7c62
ScienceStacks/common_python
/common_python/classifier/old/multi_classifier.py
9,538
3.875
4
""" Classifier for data with multiple classes. The classifier is constructed from a binary classier, which is referred to as the base classifier. Classifier features are selected using a FeatureSelector instance. The base classifier must expose methods for fit, predict, score. Fitting is done by forward selection of f...
b86b2fa08fa4a5b43100ba9c2216e1ee64888ebd
gabriellaec/desoft-analise-exercicios
/backup/user_158/ch165_2020_06_22_04_26_00_987764.py
413
3.578125
4
def mais_populoso(dic): estados ={} for estado,municipios in dic.items(): total = 0 for municipio in municipios.values(): total += municipio estados[estado] = total maior_pop = 0 estado_pop ="" for estado, populacao in estados.items(): if populacao > maior...
c03b44ed15048a228572c191aa0ef8d3ff25f83d
gregcarrigan/DS_Misc
/1.1.3.py
709
3.75
4
import numpy as np # weight = float(input("How many pounds does your suitcase weigh? ")) # if weight > 50: # print ("Your suitcase weighs more than 50 lbs") # else: # print ("Your suitcase weighs less than 50 lbs") """ temperature = float(input('What is the temperature? ')) weather = input('What is the weather? (ra...
9e4057a88158cd6a45f84d1a4d2ba4d9e28ba5a4
sidheswar12/datastructure_python
/src/linklist.py
3,843
3.84375
4
#!/bin/python3 # Author: Sidheswar Ghosh class Node(object): def __init__(self, val): self.val = val self.next = None def get_data(self): return self.val def set_data(self, val): self.val = val def get_next(self): return self.next def set_next(...
c007acec1a623eb6ac7eda9da1a1810a39e534bf
irmakcakmak/great-circle-distance
/test/test_reader.py
916
3.546875
4
import unittest import reader class ReaderTest(unittest.TestCase): def test_read(self): records = [] for record in reader.read("test/resources/test_file.json"): records.append(record) self.assertEqual(len(records), 1) record = records[0] fields = [key for key in...
83e20ebc7211bfc68c218f93857acc924545aa72
fumdiali/python3
/file_opener.py
677
3.765625
4
#poorly commented code(not good practice ;]) import time name = input("Enter your name: ") print("Hello,{}.Enter file name to open..".format(name.capitalize())) file_name = input() try: file_handler = open(file_name) print("Okay,here comes the content of {}...".format(file_name)) except: print("Ooops!Sorry,{}! {...
3a0cb63200076b9a5b390489b129b18b2ed79030
Chilidawwg/Tasty_Python_Scirpts
/Word-generator/isEng.py
274
3.671875
4
def getDict(file): words = set() with open(file) as d: for w in d.read().split("\n"): words.add(w.lower()) return words def isEng(word): englishWords = getDict("dictionary.txt") if word in englishWords: return True return False print(isEng("boot"))
11508ef50995cc5017a237ce66c1e369184ebf1e
gurjaspalbedi/reinforcement-learning
/tic-tac-toe/tic-tac-toe.py
562
3.765625
4
#%% import numpy as np BOARD_SIZE = 3 ZERO_SYMBOL = 'X' ONE_SYMBOL = 'O' board = np.array([[0,0,0],[1,0,0,],[0,0,0]]) #%% def draw_board(board_list): for i in range(BOARD_SIZE): for j in range(BOARD_SIZE): print(ONE_SYMBOL, end=" " ) if board_list[i][j] == 1 else print(ZERO_SYMBOL, end=" " ) ...
20e659f80b670415700056fc1f3655c90d77cea3
Luke-k-dev/SportPyOBD
/convert.py
1,350
3.890625
4
class Temperature(): def __init__(self, amount, Unit): self.Amount = amount #interger amount in C Unit = str(Unit).capitalize() Unit = Unit[0:1] #print ("Unit is: "+ Unit) self.Units= Unit #c or f ###THIS IS FOR OUTPUT#### self.degsign ='DEG' def __str__...
2807ea098991491a7023f95d2f7c205ce26cdb01
Dross0/algorithms
/prime_numbers/prime_check/prime_check.py
503
4.03125
4
def is_prime(number): if (number <= 1): return False divider = 1 dividers_number = 0 limit = int(number ** 0.5) + 1 while divider <= limit: if number % divider == 0: dividers_number += 1 if dividers_number > 2: return False divider += 1 return True def main(): number = int(input("Введите число дл...
c920ad02a00e6ee744b96a56a9cb12fa98c355b9
Lirang6/RsaChallenge
/prime est v3.5/main.py
1,104
3.78125
4
import math import time import random import functions #### enter search data here: #### number = 22112825529529666435281085255026230927612089502470015394413748319128822941402001986512729726569746599085900330031400051170742204560859276357953757185954298838958709229238491006703034124620545784566413664540684214361293017...
ee0b4744a6b86ec38089abb6950be9d8c7f7645a
gokhantamkoc/learning-python
/src/basics/functions/recursive_function.py
1,656
4.96875
5
# We know that in Python, a function can call other functions. # It is even possible for the function to call itself. # These type of construct are termed as recursive functions. # Following is an example of recursive function to find the factorial of an integer. # Factorial of a number is the product of all the integ...
69c0543e99509fc9f41407225abc4d1eaf4aed0a
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/esokada/lesson03/slicinglab.py
1,457
3.6875
4
def exchange_first_last(seq): '''Return a sequence with the first and last elements switched.''' return seq[-1:] + seq[1:-1] + seq[:1] def every_other_removed(seq): '''Return a sequence with every other element removed.''' return seq[::2] def first_four(seq): '''Return a sequence with the first an...
29098584443828f3d0ed8aa6a9d8dc58beab06b6
manishawsdevops/pythonmaster
/Python Basics - Part I/typeconversion.py
143
4.125
4
#Type conversion birth_year = input('Whats is your born year') #Calculate the age age = 2021 - int(birth_year) print(f'Your age is : {age}')
17e4bc3d278d10b6ed181de58eec40a53a8c0a88
mlakkireddy/git-github
/decor.py
725
3.640625
4
import time l2=[] l3=[] def decorator(func): def inner(*args): start=time.time() result=func(*args) end=time.time() print(f"time to execute is:{(end-start)*1000}") return result return inner @decorator #sqr=decorator(sqr) def sqr(l1): #start=ti...
ce1bb360d3685873675ab7626cd0ff956401c33a
hz336/Algorithm
/LeetCode/Sort/insertion_sort.py
348
3.921875
4
def insertion_sort(lst): for i in range(1, len(lst)): j = i temp = lst[j] while j > 0 and temp < lst[j - 1]: lst[j] = lst[j - 1] j -= 1 lst[j] = temp print(lst) return lst input = [5, 4, 3, 2, 1] print(input) output = insertion_...
6339ce8a66db052f168a69d4deb9db260c888ba2
zhaolijian/suanfa
/leetcode/sword_to_offer27.py
803
3.75
4
# 二叉树的镜像 class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # 方法1 class Solution: def mirrorTree(self, root: TreeNode) -> TreeNode: if not root or (not root.left and not root.right): return root root.left, root.right = sel...
f98eea4588a9ce0ceee4acf5650d35f05f44aef5
F8F-Bearcat/Coursera_Discrete_Optimization
/Alg_Thinking_2/FastClosestPair.py
3,579
3.90625
4
''' For Algorithmic Thinking Part 2 - Coursera class This script implements the FastClosestPair function from Homework 3, Project 3 ''' import math import SlowClosestPair import cluster_class import random def closest_pair_strip(list_of_clusters, mid, dee): ''' Input: a list of points, the x location of the sp...
8cfa319a6d29983e196c090d41aa1abcc11f054d
t-veor/adventofcode
/2021/day09/day09.py
1,444
3.703125
4
#!/usr/bin/env python3 from collections import deque import sys if len(sys.argv) > 1: filename = sys.argv[1] else: filename = "input.txt" grid = [[int(j) for j in i] for i in open(filename).read().strip().splitlines()] grid_width, grid_height = len(grid[0]), len(grid) def adjacent(x, y): if x > 0: ...
6634084f93cf077802290f4e655e55c9ce90e955
QuinnLee/project_euler
/euler039.py
838
3.625
4
''' If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. {20,48,52}, {24,45,51}, {30,40,50} For which value of p ≤ 1000, is the number of solutions maximised? ''' ''' notes a + b + c = p sqrt(a^2 + b ^2) = c a + b + sqrt(a^2 + b ^2) ...
4c307b1f58e719cf19dca4ea9bbbbbbd58bc3616
aastha24/Programming-Assignments
/linked_list.py
1,455
4.375
4
class node(): def __init__(self,data): self.data = data self.next = None class linkedlist(): def __init__(self): self.head = None #Add a new node at beginning def push_data(self,new_data): new_node = node(new_data) new_node.next = self.head self.head = new_node #Add a new node at end def push_dat...
1431f830bdfff05c7757cb4f99e792aa3637463d
dodoman111/Python_practice
/Fraction 연산(분수연산)_class문.py
820
3.84375
4
class Fraction(object): def __init__(self,num,den): self.num = num self.den = den self.simplify() def toString(self): return str(self.num)+'/'+str(self.den) def add(self,other): if self.den != other.den: self.num = self.num * other.den ...
292e03f539ad14ad7209096aeb82f8e90ddeb91e
davidvgalbraith/radioastrolab
/lab1/report/central_limit.py
2,778
3.625
4
import random import math import numpy as np import matplotlib.pyplot as plt #gets the mean of a uniform random sample of size n def sample(n): mean = 0 samp = [] for k in range(0, n): point = random.uniform(-100.0, 100.0) mean += point mean /= n return mean def centralimit(): m...
694642cedfed44db0b0286b0ec4dbb6e4b50e77a
namntran/modern_python3_bootcamp
/Loops/1loops.py
529
4.15625
4
# i = 1 # while i < 5: # i += i #increment i by 1 # print(i) # print 1 to 5 # i = 0 # while i <= 5: # i += 1 # print(i) # from random import randint # use randint(a, b) to generate a random number between a and b from random import randint number = 0 #store random number in here, each time through i = 0 ...
dff278117ba17e88d833661d20ef39c07dfd3a42
yanghaotai/leecode
/leetcode/4.寻找两个正序数组的中位数.py
958
4.125
4
''' 4. 寻找两个正序数组的中位数 难度 困难 给定两个大小分别为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。 示例 1: 输入:nums1 = [1,3], nums2 = [2] 输出:2.00000 解释:合并数组 = [1,2,3] ,中位数 2 示例 2: 输入:nums1 = [1,2], nums2 = [3,4] 输出:2.50000 解释:合并数组 = [1,2,3,4] ,中位数 (2 + 3) / 2 = 2.5 示例 3: 输入:nums1 = [0,0], nums2 = [0,0] 输出:0.00000 示例 4: 输入:num...
a31b73e0813614bdd17791699573d754e05f83c1
MarcelKolodziej/PycharmProjects
/tekst/venv/powtarzaja_3_razy_w_liscir.py
464
3.5625
4
#Napisz program, który sprawdzi i wypisze na ekran, które liczby powtarzają się na liście dokładnie 3 razy from random import randint lista=[] for i in range(100): lista.append(randint(1,200)) print(lista[i],end=", ") lista.sort() print("po sortowaniu") for i in range(100): print(lista[i],end=", ") print...
6ee37ef67fc5981d9c64399fe24a0daeef3862be
VAR-solutions/Algorithms
/Other Algorithms/String/python/another_string_reverse.py
249
4.40625
4
def reverse(s): str = "" for i in s: str = i + str return str s = input("Enter the string: ") print ("The original string is : ",end="") print (s) print ("The reversed string(using loops) is : ",end="") print (reverse(s))
fa15e5876b54b7a1462fb72832641a601157ae95
martinmcbride/python-imaging-book-examples
/imageops/imageops-flip-image.py
282
3.796875
4
# Author: Martin McBride # Created: 2021-05-14 # Copyright (C) 2021, Martin McBride # License: MIT # Flip an image (reverse it vertically) from PIL import Image, ImageOps, ImageDraw image = Image.open('boat-small.jpg') result_image = ImageOps.flip(image) result_image.save('imageops-flip.jpg')
dec81590ef069e518ebde0c3b5042c37c178f33e
KathyVelito/BackendKat
/dia2/01-operadores-aritmeticos.py
1,206
3.734375
4
numero1 = 10 numero2 = 80 persona1 = "Eduardo" persona2 = "Ricardo" # SUMA # Nota: si las dos o mas variables son numericas entonces se realizara la suma, si por el contrario las variables son string (caracteres) se CONCATENARAN (se juntaran) # en el caso de JS si se puede sumar diferentes tipos de variables, en el c...
1bde53615eb0793f27714c40807dac0c00ed4774
keurfonluu/My-Daily-Dose-of-Python
/Solutions/9-find-the-non-duplicate-number.py
506
3.625
4
#%% [markdown] # Given a list of numbers, where every number shows up twice except for one number, find that one number. # Challenge: Find a way to do this using O(1) memory. # # Example # ``` # Input: [4, 3, 2, 4, 1, 3, 2] # Output: 1 # ``` #%% def singleNumber(nums): n = len(nums) i, idx = 1, 0 while i <...
04aac2588fe8d00eac24258c859c6b376fca881c
yhzhang95/LeetCodeDaily
/codes/No_0075.py
588
3.578125
4
# # @lc app=leetcode.cn id=75 lang=python3 # # [75] 颜色分类 # from typing import List # @lc code=start class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ count = [nums.count(0), nums.count(1), nums.count(2)] ...
69322814507de3a13d61f3d87ebb16ac0c822362
cn5036518/xq_py
/python16/day1-21/day009 函数入门/02作业题/练习3.py
543
4.09375
4
#!/usr/bin/env python #-*- coding:utf-8 -*- ''' 3,写函数,判断用户传入的对象(字符串、列表、元组)长度是否大于5。 ''' def greater5(arg): #arg或者obj作为形参的名字 if len(arg) >5: print('实参的长度大于5') return True # return len(arg) >5 #也可以 else: print('实参的长度小于等于5') return False s1 = 'jack' greater5(s1) #实参的长度小...
b409004615755554a2fd1d770c94986f313ddd37
chiranjivi9/flask-session
/app.py
1,533
3.546875
4
#flask app #implement a FLASK SESSION #creating a basic login page from flask import Flask, render_template, request, session, url_for, g, redirect import os app = Flask(__name__) app.secret_key = os.urandom(24) @app.route('/', methods= ['GET','POST']) def index(): if request.method=='POST': #if the method is P...
3dd5fd8dc656151fbb728d7f682fbb981060cba0
DJTwoTone/python_work
/looping_lists_and_dictionaries.py
1,079
3.5625
4
# ~ unconfirmed_users = ['alice', 'brian', 'candice'] # ~ confirmed_users = [] # ~ while unconfirmed_users: # ~ current_user = unconfirmed_users.pop() # ~ print("Verifying user: " + current_user.title()) # ~ confirmed_users.append(current_user) # ~ print("\nThe following users have been confirmed:") # ~ for con...
cadf985aad49d261ff8da6fbb2afcfb7f4dffa79
greatabel/puzzle_I_cracked
/3ProjectEuler/i1_25/i15lattice paths.py
1,182
3.71875
4
# Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. # 图在:p15question.gif # How many such routes are there through a 20×20 grid? # 太慢了,得换个非递归方法 # def p(x,y): # print(x,y) # result = 0 # if x == 0 and y =...
d5b1b61dfd4f963037619039c1f040e73a2b95a9
tjhobbs1/python
/Module2/intro_to_functions/test/test_function.py
394
3.84375
4
""" Program: test_function.py Author: Ty Hobbs Last date modified: 09/01/2019 The purpose of this program is to test the function camper_age_input. """ import unittest from main import camper_age_input class FunctionTestCase(unittest.TestCase): def test_increase(self): self.assertEqual(2, camper_age_in...
41a2ef2fcf7956e2fd966b68ee41f6ed4203b675
ereynolds123/dataStructuresAndAlgorithms
/multipleNumber.py
539
4.53125
5
"""A program to determine if an integer is a multiple of another integer""" #Get user inputs for integer and multiples n = int(input("Enter a number : ")) m = int(input("Enter a number to determine if previous number is an integer : ")) #Function takes two arguments, an integer and a multiple. If the integer divided...
800ea484e6e21dc52539f13453a703929da03a70
pomelloyellow/D-django
/lab2/lab2_2.py
300
3.734375
4
count = int(input(" : ")) mas = [] print("\n " + str(count) + " : " + "\n") for i in range(count): mas.append(str(input())) for i in range(count): if(len(mas[i]) >= 5 and len(mas[i]) <= 10): print(mas[i])
032823e4d5536446d4ceaf3b1e58c63951726837
MelindaIndriani17/praktikum3
/latihan2.py
165
3.96875
4
max = 0 while True: a = int(input("Masukkan bilangan = ")) if max < a: max = a if a==0: break print ("bilangan terbesar =", max)