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
d0dff41d253ddeeecd09a2dc68948c5754c080c7
ticotheps/practice_problems
/edabit/hard/alphanumeric_restriction/alphanumeric_restriction.py
2,706
4.375
4
""" ALPHANUMERIC RESTRICTION Create a function that returns True if the given string has any of the following: - Only letters and no numbers. - Only numbers and no letters. If a string has both numbers and letters, or contains characters which don't fit into any category, return False. Examples: - a...
46d77997d86c15ac35859e8639710997dc6b1d63
ticotheps/practice_problems
/edabit/easy/time_for_milk_and_cookies/time_for_milk_and_cookies.py
2,939
4.6875
5
""" Is it Time for Milk and Cookies? Christmas Eve is almost upon us, so naturally we need to prepare some milk and cookies for Santa! Create a function that accepts a Date object and returns True if it's Christmas Eve (December 24th) and False otherwise. Objective: - Write an algorithm that takes in a single in...
b5fffaa362ff149c7af4efe698437df619d88156
ticotheps/practice_problems
/edabit/hard/grade_percentage/grade_percentage.py
3,016
4.25
4
""" YOU FAILEDPASSED THE EXAM Here is what you see after you take your exam: `Your Score: 85% You FAILEDPASSED the Exam. Required Score 85%` The challenge is to fix all of the bugs in this incredible messy code, which the code in the image might've actually looked like (probably not)! The code given will output the...
aeeafce1e20575ffba77b35953aec7f1c4482267
ticotheps/practice_problems
/algo_expert/hard/reverse_linked_list/reverse_linked_list.py
1,639
4.28125
4
""" REVERSE LINKED LIST Write a function that takes in the 'head' of a singly linked list, reverses the list in place (i.e. - doesn't create a brand new list), and returns its new 'head'. Each 'LinkedList' node has an integer, 'value', as well as a 'next' node pointing to the next node in the list or to 'None'/'null'...
b966460ec9ba403ba6a80cb5d04a63aea5f50942
ticotheps/practice_problems
/euler_project/challenge_15/challenge_15.py
2,590
3.71875
4
#----------UNDERSTANDING THE PROBLEM---------- # - Objective # - Write an algorithm that returns the total number of possible routes that can be # taken from the top-left corner of a 20x20 grid to the bottom-right corner of # that same grid while ONLY moving in the following directions: down, right. # - Def...
b5e10fb640d77e29d606f4706961b8079da95eb4
ticotheps/practice_problems
/euler_project/challenge_4/challenge_4.py
3,143
4.3125
4
def check_palindrome(num): # Convert 'num' into a string & store in a var called 'numStr'. numStr = str(num) # print(f"numStr = {numStr}") # Split 'numStr' into a list of chars & store in a var called # 'numStrCharsList'. numStrCharsList = list(numStr) # print(f"numStrCharsList = {numSt...
2f9330e368ccbc1a804c46e988b03651955400d7
ticotheps/practice_problems
/edabit/hard/recursive_length_of_string/recursive_length_of_string.py
3,382
4.125
4
""" RECURSION: LENGTH OF A STRING Instructions: - Write a function that returns the length of a string. Make your function recursive. Examples: - length('apple') -> 5 - length('make') -> 4 - length('a') -> 1 - length('') -> 0 """ """ ----- 4 Phases of The U.P.E.R. Problem-Solving Framework ----- ...
2affee6e0667d914aefb50af1c0db67fd6791b84
ticotheps/practice_problems
/edabit/easy/sum_of_all_evens_in_matrix/test_sum_of_all_evens_in_matrix.py
828
3.546875
4
import unittest from sum_of_all_evens_in_matrix import sum_of_evens class Test(unittest.TestCase): def test_sum_of_evens(self): self.assertEqual(sum_of_evens([ [1, 0, 2], [5, 5, 7], [9, 4, 3] ]), 6) ...
f44ecd127c69d721f86d1ec807b393199d844ea8
Umar-RS/TextExtractor
/pythonTask.py
2,476
3.609375
4
# Import libraries import requests import argparse from bs4 import BeautifulSoup class TextExtractor: def __init__(self, url): self.url = url def check_prefix(self): prefix = "https://" if prefix not in self.url: return f"{prefix}{self.url}" # if user fails to include the ...
b22be83255fa5eebd25f118de8202955b4a1ae4f
cczhong11/my-python-util
/time_util/datetime_util.py
2,120
3.53125
4
import datetime from pytz import timezone from typing import Tuple def parse_time(date, pattern="%Y-%m-%d", tz="America/Los_Angeles")->datetime.datetime: ''' @input: string date and its pattern @output: datetime obj ''' tzi = timezone(tz) return datetime.datetime.strptime(date, pattern).replac...
201563f18e305f513fb40b519ca71d19f4402574
himanis021/PythonCoding
/string.py
237
3.734375
4
c = ''' Hi jack, how are you? regards himani ''' print(c) ch = 'Python for beginners' print(ch[0]) print(ch[-1]) print(ch[0:5]) # goes from 0-4 characters- Pytho as 01234 print(ch[:4]) print(ch[1:-1]) print(ch[-1:1])
0921a89af8524ce6e1e361cea8a7d23c182eeb87
beebyte/irisett
/irisett/webapi/require.py
3,225
3.5
4
"""A set of functions used to validate HTTP input data. These functions are primarily used to valid that arguments sent in http requests are what they are supposed to be. """ from typing import Union, Any, Dict, List, cast, Optional, SupportsInt from irisett.webapi.errors import InvalidData def require_str(value: ...
97e1ad5cc88389f23dcb48e306f4c55d634a005d
iMohannad/Random_Recording_Algorithm
/Python/recording_alg.py
5,197
3.78125
4
import math import random import sys """ wmax(k) is the largest integer w <= WMAX such that two conditions are satisified: 1. di < k, 2. pw(k) in Dw' Parameters ---------- k : int an integer k to be represented in random representation WMAX : int WMAX is the integer calcula...
9a63d8ce5074f9f7c9a70c0129a1b8ccb450a4f0
reed-college/disk-zero
/disk_zero.py
1,443
3.90625
4
import subprocess import os ''' This program will unencrypt hard drives so that they can be deleted in terminal. It outputs a list of all of the drives it recognizes, and allows the user to input the drive of interest. Then it runs the proper terminal command to remove the UUID from the drive so that it can be zeroe...
7be215b3f435fdcaff2c0c603e4b27dbbcefe3b5
Estefa29/Ejercicios_con_Python
/Clase_08_05_21/CestaProductos.py
240
3.6875
4
Cesta={} centinela='si' while centinela=='si': clave=input('introduzca el producto a comprar: ') valor= input(clave+ ':') Cesta[clave]=valor print(Cesta) centinela= input("si desea continuar /si, sino No: ") print(Cesta)
f0cf1fc2e0534754744809f4b9549b582f6fc67c
Estefa29/Ejercicios_con_Python
/listas.py
579
3.9375
4
listas=["renault","chevrolet","mazda"] for i in listas: print(i,end="") for i in range (len(listas)): print(listas[i],end="") for i in range (len(listas)-2): print(listas[i],end="") auxiliar=listas [:2] print (auxiliar) listas.insert(3,"audi") print (listas) auxiliar=listas [1:] ...
551db727d450968b218c0d7bcc5076a4af569724
Estefa29/Ejercicios_con_Python
/main.py
3,193
4.25
4
# print("Hello world") # algoritmo para saber cual de los 3 números es el mayor # number1 = int(input("Ingrese primer número: ")) # number2 = int(input("Ingrese segundo número: ")) # number3 = int(input("Ingrese tercer número: ")) # # operadoares lógicos &&(and), ||(or) # if number1 > number2 and number1 > number3: # ...
b47f70ee1b356085e3a8bb4e0756e1bf5f4e0619
Estefa29/Ejercicios_con_Python
/Vectores y matrices/ejercicios_matrices.py
8,999
4.03125
4
# Realice un algoritmo que permita diseñar un sudoku, donde se debe de ingresar # inicialmente la posición aleatoria de los valores con los cuales se va iniciar, # luego deberá comenzar el juego y validar las jugadas, si excede el valor total por # columnas o filas deberá emitir un mensaje de error. import numpy as...
1012c13a5614b427c8a9052b73fecc3235947750
ramnathpatro/OOPs
/Data Management.py
1,020
3.65625
4
""" ****************************************************************************** * Purpose: Data Management * * @author: Ramnath Patro * @version: 1.0 * @since: 26-3-2019 * ****************************************************************************** """ from oops.oops_utility import object ref = object impor...
8af1196d576fdc5bac1efa1bf73520f4ebdd60c6
ramnathpatro/OOPs
/Regular_Expression.py
2,153
4.21875
4
""" ****************************************************************************** * Purpose: Regular Expression * * @author: Ramnath Patro * @version: 1.0 * @since: 26-3-2019 * ****************************************************************************** """ import re def regex(string): constant1 = 0 wh...
efc3c599d169e95d28fa08936fbf43feacf5424b
devfuner/scratch
/su_sudoku.py
1,713
3.9375
4
import operator import random from random import randrange #게임 룰 #어느 곳에 넣을 지 선택 #숫자 넣기 #9칸 안에 숫자(1, 2, 3)가 들어가야한다. #한줄에 서로 다른 숫자가 들어가야한다. from functools import reduce print('=======================') print(' sudoku ') print('=======================') board = ['' , ' ', ' ', ' ' , ' '...
f433fda6480fe3cac5afcb580f10457da4a1d65f
Nchia-Emmanuela/Average_Height
/Average height.py
587
4.15625
4
Student_Height = input("Enter a list of students heights :\n").split() print(Student_Height) # calculating the sum of the heights total_of_height = 0 for height in Student_Height: total_of_height += int(height) print(f"total heights = {total_of_height}") # calculating the number students number_of_students = 0 fo...
984076bf400be069adbf3cd9741478d17b3a669a
thisisvarma/python3
/blog_learning/inputOutputImport/squareRootOfComplexNum.py
208
3.984375
4
import cmath num=eval(input("Enter some complex number(Ex: a+bj) : ")) squareRootNum= cmath.sqrt(num) print("Square root of given number {} is : \ {}+{}j ".format(num,squareRootNum.real,squareRootNum.imag))
013e0da50a03e405f35a47ed2d814271f7ba4a87
thisisvarma/python3
/set_comprehension.py
164
4
4
print("----------- set Comprehension --------------") print(''' Syntax: {Expression for x in Seq Condition} ''') s={x*x for x in range(1,6)} print(s)
31d72530ba1b711b4adef7311846b1cec83c5af0
thisisvarma/python3
/blog_learning/flowControlStatements/primeNumberInRange.py
430
3.96875
4
lower=eval(input("Enter lower limit value in range : ")) upper=eval(input("Enter upper limit value in range : ")) primelist=[] for num in range(lower,upper+1): if num > 1: for i in range(2,num): #finding factors if (num % i) == 0: break else: primelist.append(num) else: print(num ,"is prime number"...
a8d3aab468d7495659c15bfe709d93d9a437a1f3
thisisvarma/python3
/blog_learning/operators/membershipOperator.py
475
4.1875
4
print("\n ****** membership Operator examples **** ") print(''' in --> True if value or variable presents in list, string,tuple or dict not in --> True if value or variable not presents in list, string, tuple or dict ''') x=input("enter string what ever you like : ") y="aeiou" print("'H' in x is : ",'H' in x) ...
44b22710d75322259f8d2cb0c942a95e243edef4
thisisvarma/python3
/blog_learning/operators/bitWiseOperator.py
198
4.03125
4
print("\n ***** bitwise Operator example *****") print(''' & --> BitWise AND | --> BitWise OR ~ --> BitWise NOT ^ --> BitWise XOR >> --> BitWise right shift << --> BitWise left shift ''')
321d8e8034504d725070df509734088103708b85
Platypudding/Rando-stuff
/Gram-Ounce Calculator.py
940
4.1875
4
#Converts grams into ounces or vice versa def convert_gram(gram): ounce = gram / 28.35 print("Grams:", gram, "\n" + "Ounces:", ounce) def convert_ounce(ounce): gram = ounce * 28.35 print("Ounces:", ounce, "\n" + "Grams:", gram) gramounce = input("Input g to convert from grams, o to convert from ounce...
dd624639c604553ae3015e29b154d46467b4b46f
matheuscordeiro/Codility
/Lessons/Stacks and Queues/Brackets/solution.py
450
3.671875
4
#!/usr/local/bin/python3 def solution(S): characters = {'{': '}', '(': ')', '[': ']'} stack = [] position = -1 for char in S: if characters.get(char): stack.append(char) position += 1 elif not stack or characters[stack[position]] != char: return 0 ...
956116f1b74b7e21e8b83bad7e3664b732bdb4ab
AkashPatel18/CODING-QUEST
/two-sum/n2.py
256
3.734375
4
def twosum(arr,target): for i in range(n): for j in range(i,n): if arr[i] + arr[j] == target: return i,j if __name__=="__main__": arr = [8,7,6,5] target = 13 n = len(arr) print(twosum(arr,target))
cc65ff76ffc9795b8d5e8ce17a8cf9ce98ee5b7f
AkashPatel18/CODING-QUEST
/Longest Substring Without Repeating Characters/O(n).py
595
3.734375
4
def SubsequenceLength(s): #Codee here lastseen = {} startIndex = 0 longest = [0, 1] if s == "": return 0 for i, char in enumerate(s): if char in lastseen: startIndex = max(startIndex, lastseen[char] + 1) print("this is starttinsg index",startIndex) ...
d53eff888bd61bdf36303c232a8300f871de7654
NicciSheets/python_battleship_attempt
/ship.py
1,690
4.25
4
SHIP_INFO = { "Battleship": 2, "Cruiser" : 3, "Submarine" : 4, "Destroyer" : 5 } SHIP_DAMAGE = { "Battleship": 0, "Cruiser" : 0, "Submarine" : 0, "Destroyer" : 0 } # returns a list of all the keys in the dictionary, which you can then use to return a certain ship name from the SHIP_INFO dictionary ...
6d700b6b5f6ca80d260cbff864459cf49ca69cb1
keen-s/alx-higher_level_programming
/0x06-python-classes/101-square.py
2,387
4.5625
5
#!/usr/bin/python3 """Write a class Square that defines a square by: (based on 5-square.py) """ class Square: """Square class with a private attribute - size. """ def __init__(self, size=0, position=(0, 0)): """Initializes the size variable as a private instance artribute """ ...
a03aeb43518398979ee72d6c70a02ee8878246db
keen-s/alx-higher_level_programming
/0x0c-python-almost_a_circle/tests/test_models/test_rectangle_4.py
649
3.6875
4
#!/usr/bin/python3 """Test model for the rectangle class""" import unittest from models.rectangle import Rectangle from models.base import Base class TestRectangle(unittest.TestCase): """Testing the area of the rectangle""" def test_area(self): """Tests the area of the rectangle""" r1 = Recta...
a4e703bbe075ad28cc25a7e03d6405152079580a
keen-s/alx-higher_level_programming
/0x0A-python-inheritance/7-base_geometry.py
673
3.96875
4
#!/usr/bin/python3 """Integer validator """ class BaseGeometry: """An empty class""" def area(self): """Raises an exception because... area is not implemented """ raise Exception("area() is not implemented") def integer_validator(self, name, value): """Validates t...
84059ceca8bf9da2d3a7b82f62501c53c99e215d
laurennpollock/comp110-21f-workspace
/exercises/ex01/numeric_operators.py
940
4.1875
4
"""Practicing numberic operators.""" __author__ = "730392344" left_hand_side: str = input("Left-hand side: ") right_hand_side: str = input("Right-hand side: ") int(str(left_hand_side)) int(str(left_hand_side)) exponentiation = int(left_hand_side) ** int(right_hand_side) division = int(left_hand_side) / int(right_hand_...
9835ccfe8458dbffd844eedc273984aed6025e9c
Knorra416/daily_coding_challenge
/July_2019/20190722.py
856
4.375
4
# There exists a staircase with N steps, # and you can climb up either 1 or 2 steps at a time. # Given N, write a function that returns the number of unique ways you can climb the staircase. # The order of the steps matters. # For example, if N is 4, then there are 5 unique ways: # 1, 1, 1, 1 # 2, 1, 1 # 1, 2, 1 # 1,...
373c78002e9c7b7dbc573e7069b4b264a9b865fd
MagdalenaKotynia/matches-game
/minimax.py
450
3.625
4
def minimax(game_tree, depth, is_max_player): if depth == 0: return game_tree.value if is_max_player == 1: best_value = -1 for child in game_tree.children: value = minimax(child, depth - 1, -is_max_player) best_value = max(best_value, value) return best_value else: best_value = 1 for child in gam...
ebef5dab76e79c68e8feb71c5e14107686ea3313
BonganiElvis/mypracs
/prac1.py
1,847
3.546875
4
#!/usr/bin/python3 """ Python Practical Template Keegan Crankshaw Readjust this Docstring as follows: Names: <Bongani Gqweta> Student Number: <GQWBN002> Prac: <Prac_1> Date: <04/08/2019> """ # importing Relevant Librares from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) button1=16 button2=32 LED1...
710671444cde85b842e8ac852d0966f82051f107
gaw0305/TicTacToe
/tictactoe.py
38,487
4.15625
4
''' tictactoe.py A program that implements a 4x4x4 tic-tac-toe game with AI. Authors: Grace Whitmore and Alby Himelick CS 111, Winter 2011 date: 14 March 2011 ''' from cTurtle import * from random import * from math import sqrt from copy import deepcopy ''' The definition for a Board data type. The Board class...
6718a6008d1870df1b20f67a1dd3b948375c6885
king-Daniyal/assignment-1-py
/do.py
550
4.15625
4
#(print) this is the feature which prints the word given ahead of it print("hi, i am a text") # this is the function the word inside of the "" will come as output # lets try numbers print(2020, "was bad") # this works with numbers and text but the "" shall not be included with the number because it is of no use pr...
73db52476f91e787f5441b81ac790ea4fe0916d0
NickCorneau/PythonAlgorithms
/deep_reverse.py
693
4.375
4
# Procedure, deep_reverse, that takes as input a list, # and returns a new list that is the deep reverse of the input list. # This means it reverses all the elements in the list, and if any # of those elements are lists themselves, reverses all the elements # in the inner list, all the way down. # Note: The proc...
0a71411489969e39e5deab6eaee9d4ce810b1b01
fishcat7/password-try
/password.py
283
3.765625
4
password = 'a123456' x = 3 print('最多輸入三次密碼') while x > 0: x = x - 1 code = input('請輸入密碼:') if code == 'a123456': print('登入成功') break else: print('密碼錯誤! 還有', x, '次機會') if x <= 0: print('登入失敗') break
e72570af92bee05fe2f164cd5adb5e23402e472c
azka-saddiqa/BSEF15M502
/SJF_.PY
2,890
3.546875
4
process= {} #for process arrival and burst time time={} #for the turn-arround time and waiting time of respective process arrival_time_list=[] burst_time_list=[] num_of_process=0 start_time=0 #----------------------------------------------------------------------------------------- def getInput(itera): for i in ran...
6569a2d84ebf11f286b08002e80575648f349594
Dariod9/ect
/1Ano/labi/TesteSQL/GuiaoSQL/18_11.py
324
3.859375
4
import sqlite3 as sql import sys def main(argv): db = sql.connect(argv[1]) # estabelecer ligação à BD # realizar operações sobre a BD a=0 result = db.execute("SELECT nome FROM data2") for row in result: print (row) a=a+1 print(a) print("contactos") db.close() # terminar ligação main(sys.argv)
95878720dcf7eb7aa318308fc3ea06963c892f9d
Dariod9/ect
/1Ano/labi/TesteSQL/GuiaoSQL/18_13.py
347
4
4
import sqlite3 as sql import sys def main(argv): db = sql.connect(argv[1]) inp=argv[2] # estabelecer ligação à BD # realizar operações sobre a BD result = db.execute("SELECT empresa FROM pessoas WHERE nome LIKE ? OR apelido LIKE ?", (inp,inp) ) for row in result: print (row) db.close() # terminar ligaç...
6f0840dea7e748ffd604d90c09f2466aead25b63
Dariod9/ect
/1Ano/labi/TesteSQL/GuiaoSQL/18_12.py
329
4
4
import sqlite3 as sql import sys def main(argv): db = sql.connect(argv[1]) # estabelecer ligação à BD # realizar operações sobre a BD frase=input("Nome ? ") result = db.execute("SELECT * FROM data2 WHERE nome LIKE ?", (frase,) ) for row in result: print (row) db.close() # terminar ligação main(sys.argv...
31f806e81c2d006c08394eac689a727a1b14117c
Dariod9/ect
/3Ano/IIA/aula8 ou 9/ex4tp.py
146
3.75
4
def main(): x=1 y=3 z=4 if x< y < z: print("True") else: print("False")
23c2c47687b7796369a8470e44999bf0b579b55b
vicgalle/ARAMARL
/engine.py
19,892
3.765625
4
""" This module implements several environments, i.e., the simulators in which agents will interact and learn. Any environment is characterized by the following two methods: * step : receives the actions taken by the agents, and returns the new state of the simulator and the rewards perceived by each agent, amongst o...
e5af2e88d67154e4bbda0fe9112149946a968ac9
luoest/gobang-step-by-step-
/step2_createChessAndMove.py
955
3.515625
4
from tkinter import * tk = Tk() frame = Frame(tk, padx = 20, pady = 20, bg = 'burlywood4') frame.pack() cv = Canvas(frame, width = 510, height = 550, bg = 'burlywood') for i in range(16): cv.create_line(30, 30*i+80, 480, 30*i+80) for i in range(16): cv.create_line(30*i+30, 80, 30*i+30, 530) color = ['white', ...
81b0f1a6ca2b9a9c02233da8e0cd5f1a84a5d80e
Michaelcr79/python
/python_class_else.py
155
3.9375
4
answer="Maybe".lower() if answer=="yes": print("Play Again") elif answer=="no": print("Quitting game") else: print("Please enter a Yes or No")
b720a2352bb4b4a58e15f3835052ecaf4149141f
AhsanVirani/python_basics
/Basic/Classes/classes_variables.py
841
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon May 11 23:50:40 2020 @author: asan """ class Employee: num_emps = 0 raise_amount = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company...
7cf8abf975c0d5317999a2daec0bb0fa4e6cbb8d
AhsanVirani/python_basics
/Basic/Classes/classes_instances_1.py
1,042
4.15625
4
# -*- coding: utf-8 -*- """ Created on Fri May 8 06:57:49 2020 @author: asan """ # Creating and instanciating classes # Tut 1 class Employee: def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company....
70d8e31b35c73a792f4c6c8160db16f8019bdb7f
kirtanlab/pure_mess
/MODULE15/15.3/main.py
1,754
4.125
4
#Program 1 print("\n**\n ** \nProgram No: 0 : Program to find sum of square of first n natural numbers\n **\n**") def squaresum(n) : sm = 0 for i in range(1, n+1) : sm = sm + (i * i) return sm n = int(input("\nEnter the Input: ")) print(squaresum(n)) #Program 2 print("\n**\n ** \nProgram No: 1 : program to sp...
9108566d5938a5d003825c2f0c44e93b6fce469f
mmastin/code-challenges
/searching.py
3,033
3.609375
4
def search_first_key(A: List[int], k: int) -> int: left, right, result = 0, len(A - 1), -1 #A[left:right + 1] is the candidate set while left <= right: mid = (left + right) // 2 if A[mid] > k: right = mid - 1 elif A[mid] == k: result = mid right = ...
e57436a796d4b160039b1dd30d84d2af3b284a6d
nickruta/DataStructuresAlgorithmsPython
/linked_list_ordered_singly.py
4,273
4.28125
4
""" Using the PEP 8 Style Guide for Python Code: https://www.python.org/dev/peps/pep-0008/ and python linters """ class Node: """The basic building block for the linked list implementation is the node. Each node object must hold at least two pieces of information. First, the node must contain the list ite...
5abae9ce6ec3065280f6799fd1cab57c79a2d629
nickruta/DataStructuresAlgorithmsPython
/selection_sort.py
1,638
4.21875
4
""" Using the PEP 8 Style Guide for Python Code: https://www.python.org/dev/peps/pep-0008/ and python linters """ def selection_sort(a_list): """The selection sort improves on the bubble sort by making only one exchange for every pass through the list. In order to do this, a selection sort looks for the l...
54b21b663d39ba278a80a5540e2c34e1a5164597
bburns/Hydrogen-Orbitals
/src/python/libGeneral.py
1,644
3.515625
4
""" libGeneral Various useful routines """ import time class EmptyObject: """ Define an empty class for passing arguments - if you need to pass multiple arguments to a callback function, just create one of these and add the properties needed. """ pass def now(): ...
669d268bf3c7029a27e490afb8875a914da1fd6c
igrapel/Python
/Scraping/wordDefinition.py
721
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Dec 4 13:02:32 2020 @author: 323917 """ import requests from bs4 import BeautifulSoup word_list=[] meaning_list=[] numWords = int(input("How many words to list????")) for word in range(numWords): w = input("Enter a word: ") word_list.append(w) URL = "https:/...
7ee068dfce279af52a6397d7a5d7868e63a2bd34
deClot/Serias_for_Origin
/modules/comments_clear.py
386
3.578125
4
def comments_separation_index (element): for i in range(len(element)): if element[i].isdigit() == False: if i == len(element)-1: return 'none' else: continue else: return i def comments_separation (element, i): return element[i...
b5166b830c1790d43c3e894164f5292d5ca65390
aadharna/UntouchableThunder
/generator/levels/zelda2018NeuripsGenerator.py
10,061
3.546875
4
#!/usr/bin/env python # coding: utf-8 import math import functools import numpy as np class Cell: def __init__(self): self.walls = [True, True, True, True] self.marked = False def unlockDirection(self, direction): if direction['x'] == -1: self.walls[0] = False ...
aea88889b9c71790e1a62ee99ff58ea1e141010f
sushant-jain/gateRpi
/test.py
534
3.609375
4
import RPi.GPIO as GPIO ## Import GPIO Library import time ## Import 'time' library (for 'sleep') pin = 32 ## We're working with pin 7 GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering GPIO.setup(pin, GPIO.OUT) ## Set pin 7 to OUTPUT GPIO.output(pin, G...
97870b52a883645fd4d37787866c1feb04588d6b
LOGserch/HOMEWORKS-ED
/carpeta-tareas/Arrays.py
1,436
3.9375
4
#Array es ADT(es un tipo de dato abstracto) que almacena elementos con indice: #operaciones de Array: #Array()--constructor #get_length()--tamaño #get_item(index)--elem #set_item(index,v) #clearing(varol) class Array: def __init__(self,n):#self es referencia a la propia clase self.__data=[] for...
7512b9686a22f6c9f33f3355f858b6708c0fbfc0
LOGserch/HOMEWORKS-ED
/carpeta-tareas/listas_doblemente_ligadas.py
3,157
3.671875
4
""" listas doblemente ligadas ****************************** get_size() .... insert(value) .... find_from_head(value) .... find_from_tail(value).... remove_from_head(value).... remove_from_tail( value) .... ins...
4093809df541b3c4eb5963d69890fe265c21b8d5
HieuPham1299/PongGame
/ball.py
792
3.8125
4
from turtle import Turtle class Ball(Turtle): def __init__(self): super().__init__() self.penup() self.shape("circle") self.color("white") self.shapesize(stretch_wid=1, stretch_len=1) self.x_move = 6 self.y_move = 6 def horizontal_collision...
d588e32a574ec0f53255706fdaad7c88babaf6c1
joaqFarias/poo-python
/metodos-encadenados.py
1,572
3.984375
4
class User: # aqui está lo que tenemos hasta ahora def __init__(self, name: str, email: str) -> None: self.name = name self.email = email self.account_balance = 0 # agrega el método deposit def make_deposit(self, amount: int) -> None: # toma un argumento que es el monto del depósit...
1d413958b209f5a73ca3d48e87b80037ebd6c4fd
Suhasnama/Pythonprograms
/cmc.py
8,680
4.21875
4
# version - 2.x # points.py # # Classes and objects # import math #********************************************************* # class Point starts here # class Point(object): # Documentation string """ The class Point represents a 2D point ...
13a84da01bd2034300ebae65109c0274d3428754
webufoqiu/kI
/ML/course/logstic_regression_course.py
2,980
3.9375
4
""" Linear Regression: 实现了回归,其中包括线性函数的定义,为什么要用线性函数,loss的意义,梯度下降的意义,stochastic gradient descent Use Boston house price dataset. 北京2020年房价的数据集,为什么我没有用北京房价的数据集呢? Boston: room size, subway, highway, crime rate 有一个比较明显的关系,所以就观察关系比较容易 北京的房价:!远近,!房况 ==》 学区!!!! => 非常贵 海淀区 Harder than deep learning: 1. compiler 2. progr...
d62375bba304a6faca83029a40539214f630cf3d
webufoqiu/kI
/C1/example_02_water_pouring.py
1,021
3.765625
4
def water_pouring(b1, b2, goal, start=(0, 0)): if goal in start: return [start] explored = set() froniter = [[('init', start)]] while froniter: path = froniter.pop(0) (x, y) = path[-1][-1] for (state, action) in successors(x, y, b1, b2).items(): if...
40ceb63c34c2efd84a0f8431c05a3e2905fed1ee
NiceStudentAccount/FirstSemester
/Ejercicios 1-30/13.py
486
4.0625
4
print('---------------PROBLEMA 13---------------') #FUNCION: devuelve True si el numero hace parte de la secuencia de fibonacci #ARGUMENTOS: mumero a evaluar def esAureo(numero): n1 = 0 n2 = 1 n3 = 1 for x in range(numero+1): n1 = n2 n2 = n3 n3 = n1+n2 if numero == n3: ...
e7e36ac27cb44a4985d4c344289c145b0cb76bd2
NiceStudentAccount/FirstSemester
/Ejercicios 1-30/30.py
414
4.09375
4
print('---------------PROBLEMA 30---------------') def reorganize(array): counter = 0 while counter < len(array): if array[counter] == 0: array.remove(0) array.append(0) counter += 1 return array numbers = list() for x in range(int(input('Amount of items: '))): ...
f683d5c7c996024aa27e0e7ebd301f5bcc98ffe7
NiceStudentAccount/FirstSemester
/Ejercicios 31-50/35-42.py
4,673
4.125
4
print('---------------PROBLEMA 35-2---------------') #----------------FUNCIONES DE LECTURA----------------- #función que revisa si se ejecutó el programa por segunda vez y recibe los conjuntos o conserva los #los conjuntos anteriores def recheckArray(isFirst, conj1, conj2): if isFirst == False: if int(inpu...
a444a70cf57794550949e876c1b8895ef35021cd
NiceStudentAccount/FirstSemester
/Ejercicios 1-30/9.py
824
4
4
print('---------------PROBLEMA 9---------------') #FUNCION: determina si un número es múltiplo de la suma do otros dos números. #ARGUMENTOS: numero producto, sumando 1, sumando2 def esMultiplo(multiplo, sumando1, sumando2): #se suman los sumandos y si no son divisibles por el primer numero, este no es multiplo ...
03cfbbc09dd9a34259933376cc528e058d4379d8
NiceStudentAccount/FirstSemester
/Ejercicios 1-30/4.py
967
3.859375
4
print('---------------PROBLEMA 4---------------') #FUNCION: Determina el cerramiento mas económico #ARGUMENTOS: ancho del corral, largo del corral, precio del metro de madera, #precio del metro de alambre y precio del metro de varilla. def materialMasEconomico(precio_madera, precio_alambre, precio_varillas): ...
77f56c9b3d8f7c492e449deb73cf49b74625e577
Artemprod/pythom_basic
/homework_1_task_1.py
230
3.875
4
first_var, second_var, third_var = [3, 10, 5] print(first_var, second_var, third_var) input_var_1 = int(input('input number: ')) input_var_2 = int(input('input second number: ')) result = input_var_1 / input_var_2 print(result)
b35122c5106cce0a2048ced60103b933e251f01f
Arx-Game/arxcode
/server/utils/picker.py
1,430
3.8125
4
import random class WeightedPicker(object): def __init__(self): self.choices = [] def add_option(self, option, weight): """ Adds a option to this weighted picker. :param option: The option to add to the picker, any valid Python object. :param weight: An integer value t...
700c4ffbd0b0ea8e7aae4aa88f07f2ac5fd558f6
Arx-Game/arxcode
/typeclasses/wearable/cmdset_wearable.py
3,702
3.578125
4
""" This defines the cmdset for the red_button. Here we have defined the commands and the cmdset in the same module, but if you have many different commands to merge it is often better to define the cmdset separately, picking and choosing from among the available commands as to what should be included in the cmdset - t...
83a5c7611f4289ae10392c8f09a87212e2c9b148
knarain18/project_euler
/Project Euler Problem 1.py
202
3.625
4
x=0 nums = [] while x < 999: x = x + 1 if x%5 == 0: nums.append(x) elif x%3 == 0: nums.append(x) else: continue print(nums) b = sum(nums) print(b)
87c63f83deacbd8a5faf5b6b0b4929cf29d8f4d9
nastiazaya/work-TDD
/bmiFun.py
545
3.890625
4
def bmiAnswer(wieght,height): if wieght<0 or height<0: #Checks if the variables are negative return False return int(wieght/height**2*10000) #Formula for finding BMI def BMI(wieght,height): #Returns the weight level bmi=bmiAnswer(wieght,height) if bmi is False: return 'You are having tr...
f79779552f08aa87ba39aec769b546d8b81c2a8d
Denysios/dz8
/lesson8_task1.py
783
3.6875
4
class Date: def __init__(self, dmy): self.dmy = dmy @classmethod def method1(cls, dmy: str): lst = [int(i) for i in dmy.split('-')] dt, mon, year = lst[0], lst[1], lst[2] return dt, mon, year @staticmethod def method2(dt: int, mon: int, year: int) -> str: d...
d66099c0b038990fc48c482d5a97bcbb528e1998
jitendrabhamare/Python-Data-Structures-Algorithms
/dijkstra_shortest_path_algo.py
2,268
3.796875
4
from ast import literal_eval from queue import PriorityQueue ### Load input file and create graph data-structure def load_graph_data(input_file): path_graph = {} with open(input_file) as file: for line in file: line_content = line.split() path_graph[int(line_content[0])] = [lite...
ae3a54e1e863ff55f190e04bc4be0d5f8cec612f
lz1irq/initlib
/initlib/db.py
1,721
3.78125
4
import sqlite3 class BookDB(object): def __init__(self, db_path): self.conn = sqlite3.connect(db_path) self.conn.row_factory = self._dict_factory self.db = self.conn.cursor() def get_book(self, isbn): self.db.execute('SELECT * FROM books WHERE isbn = :isbn', (isbn,)) r...
288be82199adb1165555662bdf05b0f218def50e
galzchan/CP3-Sathita_Chom
/Exercise9_Sathita_C.py
423
3.9375
4
usernameInput = input("Username : ") passwordInput = input("Password : ") max_attempts = 5 count = 1 while usernameInput != "admin" or passwordInput != "1234": print('Incorrect username or password, you have %d attempts left to try.' % (max_attempts - count)) if count == 5: exit(0) count = count + 1...
53507876d1b477394c331420da202b3ef0d1a106
sandeepnavale/Algorithms
/Programs/BinarySearch.py
559
3.90625
4
def find_in_sorted(nums, target): """Binary search.""" start, end = 0, len(nums)-1 while start < end: mid = (start+end)//2 if nums[mid] == target: return mid elif nums[mid] < target: start = mid+1 else: end = mid-1 return -1 assert fin...
162fecda4f30eaa9925d17ffdae75dbd6056ecaf
sandeepnavale/Algorithms
/Programs/FindSqrt.py
479
4.0625
4
# Find square root of an number # Uses Bin Search import sys def sqrt_search(x): start = 0 end = sys.maxsize while start < end: mid = start + (end - start)/2 midsqr = mid * mid # print("Start",start,"mid",mid,"End",end) if(x == midsqr): return mid elif x <...
2977b1242d6e1c6affff8716d05b810d4edf875d
sandeepnavale/Algorithms
/Sorting/MergeSort.py
1,221
4.0625
4
# Merge sort def merge(a, b): """Merge two lists sorted in descending order.""" return [max(a, b).pop(0) for _ in a + b] assert merge([], []) == [] assert merge([1], [0]) == [1, 0] assert merge([7, 5, 1], [2]) == [7, 5, 2, 1] print('All passed!') merge([1, 2, 3], [4, 5, 6]) def mergesort2(seq): mid = l...
e60ebbf0d206feff241cc68e7f498fb85b57d2dc
sandeepnavale/Algorithms
/Programs/Codility2.py
1,221
3.890625
4
# /* # * Write a function that, given two strings S and T consisting of N and M characters, respectively, # * determines whether string T can be obtained from string S by at most one insertion or deletion # * of a character, or by swapping two adjacent charcters once. The function should return a string: # * - "INS...
51c626108fa0391d609b2f087bd415c93030e1e3
sandeepnavale/Algorithms
/DynamicProgramming/CoinChange.py
1,167
3.875
4
# https://www.youtube.com/watch?v=jaNZ83Q3QGc """ Problem Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued //coins, how many ways can we make the change? The order of coins doesn’t matter. For example, for N = 4 and S = [1, 2, 3], there are fou...
f0af5f3c544a666c2655174037ab095fd3983e24
sandeepnavale/Algorithms
/DataStructures/Heap/Heap.py
1,242
3.921875
4
class heap(object): HEAP_SIZE = 10 def __init__(self): self.heap = [0]*heap.HEAP_SIZE self.currentPosition = -1 def insert(self,item): if self.isFull(): print('Heap is full') return self.currentPosition += 1 self.heap[self.currentPosition] = i...
d88834a0a56ce98fdac84aa5002dd13d3f03c3f5
krisszcode/2ndweekdojo
/min.py
152
3.671875
4
numbers= [-5, 23, 0, -9, 12, 99, 105, -43] min=numbers[0] for i in range(len(numbers)): if numbers[i]<=min: min=numbers[i] print(min)
43c392191bad2784d0ec94e87ea54bcd70a3cdb0
dnahid/Currency-Converter
/currency_converter.py
5,868
3.5
4
# Developed by Nahidul Islam import json import urllib.request from tkinter import * class CurrencyLoader: """ Load Currency Data """ # Load currency data from fixer api or from a json file. @staticmethod def get_currency_rate(): try: with urllib.request.urlopen( ...
594de495eae6840264e172e186b36af909ab5b6e
FruitCakeS/tmp
/enemy_gun.py
233
3.65625
4
def distance(x1,y1,x2,y2): return ((x1-x2)**2 + (y1-y2)**2)**0.5 print(distance(0,3,4,0)) def enemy_gun(x1,y1,x2,y2): if distance(x1,y1,x2,y2) <=10: return "machine_gun" else: return "sniper_rifle" print(enemy_gun(0,3,4,0))
8d715b5244502b202be141f5190a8b8032aef202
Leonardo-Alejandro-Juarez-Montes/CLUB_PRO_2020
/EjercicioPOO_21_03_20.py
658
4.15625
4
print("EJERCICIO NUMERO 1") n= 1 + int(input("Introduce el numero de filas weon: ")) for y in range(n): print("* "*y) print(" ") print ("EJERCICIO NUMERO 2") l=int(input("Introduce el numero de filas pd:te quiero :3: ")) for y in range (l,0,-1): print("* "*y) print(" ") print("EJERCICIO NUMERO 3") m= 1 + int...
33241368c6138946a0191a45fba362de43d4c5bd
itbc-bin/1920-owe1a-afvinkopdracht2-FemkeNijman
/10.py
427
3.921875
4
koekjes = input("Hoeveel koekjes wil je maken?") suiker = 0.3125 boter = 0.020833333333333332 bloem = 0.057291666666666664 suikernodig = suiker * float(koekjes) boternodig = boter * float(koekjes) bloemnodig = bloem * float(koekjes) print("Voor het maken van", koekjes, "koekjes, heb je dit nodig:") print(...
7f90b71724de67afb7063ca39433b138d939ab1a
j-alicia-long/DSnA
/Algorithms/Problems/interview_scheduler.py
3,091
3.59375
4
# Mastercard interview 10/23 # Candidate class class Candidate: def __init__(self, name, speciality, school): self.name = name self.speciality = speciality self.school = school self.schedule = {} def getIntervieweeSchedules(input): candidate_info = [] names = input[0].split(",")[1:] specia...
09bdf651f7d7d4659da6cafd47840501db3541a6
AvinashBolineni/tcs_digital_17_18_07_21
/hacker_rank.py
1,509
3.515625
4
#!/bin/python3 import math import os import random import re import sys def calculate_health(d,first,last): # print(genes) # print(health) d += "0" sum = 0 for i in range(0,len(d)-1): if (d[i] == d[i+1]): temp = d[i]+d[i+1] if temp in genes: ...
a3620b4b22b61a4e05386afedb3e42ebab83fc65
TimTomApplesauce/CIS1415
/PigLatin.py
389
4.1875
4
def to_pig_latin(usr_str): split_str = usr_str.split(' ') for word in split_str: first_letter = word[0] word = word[1:] print(word + first_letter + 'ay', end =' ') print() return user_string = input("Please enter a sentance to convert to Pig Latin:\n") pr...
64c79f744ee730d0c6876f40b941390488ce6ca3
TimTomApplesauce/CIS1415
/CatchyNumber.py
1,264
3.703125
4
def char_to_num(chunk): i = len(chunk) dex = 0 while i > 0: if chunk[dex] == 'A' or chunk[dex] == 'B' or chunk[dex] == 'C': print('2', end='') elif chunk[dex] == 'D' or chunk[dex] == 'E' or chunk[dex] == 'F': print('3', end='') elif chunk[dex] == 'G' o...
4e014d0e40339a9055bc12a6a58ee71cf52051d7
roshanmadhushanka/FYP-ResearchSupport
/JS.py
445
3.546875
4
from bs4 import BeautifulSoup from urllib.request import urlopen print("Opening URL") page = urlopen("https://www.youtube.com/watch?v=sYckquWBxjo&index=2&list=PLC3y8-rFHvwg5gEu2KF4sbGvpUqMRSBSW") print("Convert to soup") soup = BeautifulSoup(page, "lxml") print("Tags") li_tags = soup.findAll(name='li', attrs={'class...
f163950319da9ac651a2df52854f8b0d0887f5b9
victenna/Flowers
/Flowers2.py
981
3.578125
4
import turtle wn=turtle.Screen() wn.bgcolor('yellow') turtle.tracer(0,0) def petal(t,r,angle): for i in range(2): t.circle(r,angle) t.left(180-angle) def flower(t,n,r,angle): for i in range(n): petal(t,r,angle) t.left(360/n) sam=turtle.Turtle() sam.speed(0.0) sa...