blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8f0e981f963c831ae4b46030d018120d7886a4f4
KWATRA55/Software-Developer-Salary-Prediction-Web-App-With-Machine-Learning-And-Streamlit
/data_cleaning.py
3,449
3.515625
4
# developer salary prediction web app #import libs from logging import error import pandas as pd from scipy.sparse.construct import random import streamlit as st import matplotlib.pyplot as plt from sklearn.preprocessing import LabelEncoder import sklearn from sklearn.linear_model import LinearRegression fr...
c342997b53f1ba22c3ae7c82277c1f515bcee8ab
KobeArthurScofield/Little-Py-HW
/draw01.py
2,497
3.65625
4
#charset: UTF-8 # Turtle Draw Image 1 # Kobe Arthur Scofield (Lin Yaohua) # 2018-03-15 # Build 8 # Python: Anaconda3_64 5.0.0.0 (Python 3.6.2) # IDE: MSVS2017_Community 15.6.2 # Final edit: VSCode 1.21.1 import turtle import math # Sin function required # import time ttdraw = turtle # Something se...
0d8bea73e25487a7f5a4eda9870d45cd01cc25ba
nicolelorna/Bank-account2repo
/Bank/account.py
7,436
4.03125
4
from datetime import datetime class Account: def __init__(self, first_name, last_name, phone_number): self.first_name = first_name self.last_name = last_name self.phone_number = phone_number self.balance = 0 self.deposits = [] self.withdrawals = [] s...
4f4d2f55df96cbce51d8c588f769d092b172fffb
jedzej/tietopythontraining-basic
/students/saleta_sebastian/lesson_02_flow_control/the_number_of_zeros.py
234
3.890625
4
def get_number_of_zeros(): a = int(input()) zeros = 0 for i in range(1, a + 1): i = int(input()) if i == 0: zeros += 1 print(zeros) if __name__ == '__main__': get_number_of_zeros()
92d121b1e29d7cdb9fa5637fd0ed95ac1c1ec75c
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/ds/tuple_demo.py
369
3.78125
4
t1 = (1, "Abc", False) for v in t1: print(v) print(t1) print(t1[0]) t2 = (10,) print(type(t2)) v1, v2, v3 = t1 # Unpacking print(v1) print(v2) print(v3) nt = ((10, 20), (1, 2, 3)) print(nt[1]) person = ("Srikanth", ["Java", "Python"]) person[1].append("C#") # List is mutable so can be modified print(per...
17318c45ebe8f113598b71797de5c8743124adec
bangbadak/python
/exam036.py
575
3.84375
4
import random import turtle def draw_maze(x,y): for i in range(2): t.penup() if i==1: t.goto(x + 100, y + 100) else: t.goto(x, y) t.pendown() t.forward(300) t.right(90) t.forward(300) t.left(90) t.forward(300) def turn_left(): t.left(10) t.forward(10) def turn_right(): t.right(10) t.forw...
47b6097144a0f68ae55da3d2c5cdc21d0d3a4e9b
gleissonneves/software-development-python-study
/curso_em_video/modulo_2/desafios/d2.py
616
4.1875
4
""" Mostrar a base de conversão Requisitos o usuario deve escolher a a base de conversão do sistema 0 - binario 1 - octal 2 - hexadecimal """ num = int(input('Digite um número: ')) print(""" Conveta o numero para uma das opções abaixo 0 - binario 1 - octal 2 - hexadecimal """) esc...
9128d3269b64ed702e9d8786c91470546f6ba084
nmarriotti/Tutorials
/python/Threading/main.py
456
3.5625
4
import time from threading import Thread def print_stuff(threadName, delay): count = 0 while count<10: time.sleep(delay) count += 1 print("{} count is {}".format(threadName, count)) print("{} completed".format(threadName)) def main(): t = Thread(target=print_stuff, args=("Threa...
f155c5e3d7d3c324ef03e714a252d433f2fd3c43
zubairwazir/code_problems
/cracking_the_code/chapter4/route_between_nodes.py
989
3.875
4
from graph import Graph from collections import deque def search_bfs(start, end): if start == end: return True q = deque() q.append(start) while q: node = q.popleft() node.visited = True for ngb in node.neighbors: if node == end: return True...
e25f9a06276a5fa96a942fe87aa1579434136939
paragshah7/Python-CodingChallenges-LeetCode
/AlgoDSEducative/EducativePythonSolutions/4_find_product.py
412
3.875
4
def find_product(lst): """ Do not use division """ prod = 1 lst1 = [1] for num in lst[:-1]: prod = prod*num lst1.append(prod) print(lst1) prod = 1 lst2 = [1] * len(lst1) for i in range(len(lst1)-1, -1, -1): print(i) lst2[i] = lst1[i] * prod ...
c5e2a62e2c6537a677f09fe380c1cbffb0fdc774
shubham14101/Pacman-Bot
/pacman_bot/algorithms/breadthfirst.py
1,257
3.75
4
from abstracts.searchproblem import SearchProblem from utility.datastructures import Queue from utility.auxilliary import traverse_path def search(searchproblem: SearchProblem, *args, **kwargs) -> [list, None]: """ Breadth First Search - shallowest node first. Made in accordance to pseudo-code in textbook - Fig 3....
a7c79c9e181c1eb6a64521898f3b744da2d8bb08
Aledutto23/Sistemi-e-Reti
/hello-word.py
627
3.859375
4
#Python è un linguaggio orientato agli oggetti. In Python tutto è un oggetto numero = 7 # è un oggetto ovvero una istanza della classe int #FUNZIONI def lamiafunzione(argomento1,argomento2): #codice della funzione indentato return argomento1+argomento2 print(f"la somma è: {lamiafunzione(4,6)}") #...
c77565e14d780fa4f81b1fdc7feba7972f21cb03
ZoranPandovski/al-go-rithms
/bit_manipulation/CountingBitsOfNosInArray/counting_bits.py
431
3.859375
4
def count_bits(num: int) -> None: arr: list[int] = [0] * (num+1) if (num == 0): print(arr) arr[1] = 1 for i in range(1, num+1): if((i&1) == 1): arr[i] = 1 + arr[i-1] elif ((i&(i-1)) == 0): arr[i] = 1 else: arr[i] = arr[int(...
f7061b181c23eb42fe4b038cebbdb3349a787289
ctc316/algorithm-python
/Lintcode/Ladder_29_F/892. Alien Dictionary.py
1,771
3.71875
4
class GraphNode: def __init__(self, val): self.val = val self.neighbors = set() self.inDegree = 0 def __lt__(self, other): return self.val < other.val class Solution: """ @param words: a list of words @return: a string which is correct order """ def alienOr...
6126ed4a24aa0b4af1b2f656fdb1d28e8ee7cf63
KAY2803/PythonPY1001
/Занятие3/Лабораторные_задания/task1_6/main.py
407
3.59375
4
if __name__ == "__main__": def extra_money(a, b): # расчет недостающей суммы денег month = 1 scholarship = a * 10 expenses = [b] while month < 10: b = b + (b * 0.03) expenses.append(b) month += 1 money = sum(expenses) - scholarshi...
3b1a7e42072ead0b2cc8c24d24c4e90fa2c612dc
andtarov/test_tasks
/task_6.py
1,799
4.0625
4
from collections import namedtuple import sys Thing = namedtuple('Thing', 'cost weight') def create_thing(num): while True: try: cost = float(input(f'Enter cost of {num} thing: ')) except ValueError: print('Please enter a NUMBER!') else: while True: try: weight = int(input(f'Enter weight ...
afa0216426f30b97d87454cfb8a6230f9e47e7bd
pyzeon/Streamlit
/12 Inputs/input_box.py
528
3.53125
4
import pandas as pd import streamlit as st import altair as alt df = pd.read_csv("../data/ted.csv") day = st.text_input("Day of the Week", "Sunday") if day is not None: dff = df[df["published_day"] == day] chart = ( alt.Chart(dff) .mark_bar() .encode( x="published_year:O",...
13886a6f800c7ddc7c3839244930f9486c6c961a
Jujubeats17/portfoilio
/social-network.py
773
3.8125
4
class User: def _init_(self, name): self.user_name = name self.age = 0 self.interests = [] self.friends = [] def Change_username(self,name): self.user_name = name def age(self,age): self.age=age def interests(self,interests): self.interests=int...
c6fec3c93c66219b92f86d70c974e4b8f9e81946
kaevowen/archive
/algrt/bubble_sort.py
367
3.53125
4
def bubble_sort(n, k): for i in range(k): for j in range(k-i): if n[j] > n[j+1]: n[j], n[j+1] = n[j+1], n[j] return n if __name__ == '__main__': from random import sample from timeit import Timer a = [i for i in range(1,10000)] a = sample(a,9999) t = Timer(lambda: bubbl...
05a78583d672c8b11dff738b651bc2aeb1a5989b
mcxiaoke/python-labs
/archives/learning/module/demo.py
916
3.609375
4
# -*- coding: UTF-8 -*- __author__ = 'mcxiaoke' import m2 from m1 import cal # print(cal.add10(123)) print(cal.hello("python")) print(m2.mul.fib(100)) # while True: # try: # x = int(raw_input("Please input a number:")) # print "number you input is ", x # break # except ValueError as e...
e068f66f6e5b681381d8364b41296cf301e03f68
cherryctr/17211107_cherrycitra_Belajar_Python
/Pertemuan_3/latihan_1/identitas.py
426
3.78125
4
x = 5 y = 7 z = 8 print('Nilai X sama dengan Y :', x is y) print('Nilai X sama dengan Z :', x is z) print('Nilai X Berbeda Dengan Z :', x is not z) print('\n') i = 'CherryCitra' j = 'CherryCitra' print('Nilai I sama dengan J', i is j) print('Nilai I Berbeda Dengan J :', i is not j) print('\n'); e = ['a','b','c'] ...
0f6755e4382d093bf5e3ea710dad9a690c208c25
imanmaknojia/python3
/towin2.py
275
3.84375
4
i=0 while i<2: d = 6 r = input("press r to roll") if r=="r": print("you got:", d) d = d/3 r = input("press r to roll") if r== "r": print("you got:", d) d = d+1 r = input("press r to roll:") if r== "r": print("you got:",d) i=i+1 print("HURRAYYY! YOU WON THE GAME")
3207cd0a8a085a138737a13e1bf96c19f3408b27
webclinic017/event-driven-backtester
/compliance.py
2,792
3.5625
4
from abc import ABCMeta, abstractmethod class AbstractCompliance(object): """ The Compliance component should be given every trade that occurs in the syste. It is designed to keep track of anything that may be required for regulatory or audit (or debugging) purposes. Extended versions can writ...
2e1dbef27fba64d761cde10032b82eeaeba58dcb
ronliang6/A01199458_1510
/Lab07/test_find_an_even.py
707
3.734375
4
from unittest import TestCase import exceptions class Test(TestCase): def test_find_an_even_one_even(self): actual = exceptions.find_an_even([0]) expected = 0 self.assertEqual(actual, expected) def test_find_an_even_multiple_even(self): actual = exceptions.find_an_even([4, 2, ...
9074584e5e2299774f5914205a2def231cd5d9e6
nihalgaurav/Python
/Python_Assignments/Assignment_13/Ques4.py
817
3.859375
4
#Ques 4. What will be the output of the following code: # Function which returns a/b # def AbyB(a , b): # try: # c = ((a+b) / (a-b)) # except ZeroDivisionError: # print "a/b result in 0" # else: # print c # Driver program to test above function # AbyB(2.0, 3.0) # AbyB(3.0, 3.0) # Output... # File "C:/User...
119f216ff2de18ee12b2cf14a4120aba1393f889
joselluis7/admin-scripts
/remove_empty_files.py
1,252
3.75
4
#!/usr/bin/python #This code remove empty file from a given dir #Passed as argument in command line interface import sys import os def remove(dir_path): failed, count, succeed = (0,0,0) for file_name in os.listdir(dir_path): if os.path.isfile(file_name) and os.stat(file_name).st_size == 0: ...
0c349b8cffaf4021216689da703d6ece42e8e372
kalerukoushik/Python
/JARVIS/tambola.py
2,022
3.546875
4
import random import time def game(): t1 = [1, 11, 21, 31, 41, 51, 61, 71, 81] t2 = [2, 12, 22, 32, 42, 52, 62, 72, 82] t3 = [3, 13, 23, 33, 43, 53, 63, 73, 83] t4 = [4, 14, 24, 34, 44, 54, 64, 74, 84] t5 = [5, 15, 25, 35, 45, 55, 65, 75, 85] t6 = [6, 16, 26, 36, 46, 56, 66, 76, 86] ...
68892046f791c8d7a30ebf22be174023a0a7bcec
TomaszKosinski/MITx-6.00.1x
/ProblemSet1/Problem3/FindLongestSubstringInOrder.py
488
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- s = 'abcdefghijklmnopqrstuvwxyz' maxLen = 1 maxBeginning = 0 for i in range(len(s)): print(s[i]) currentMax = 1 currentBeginning = i for j in range( i+1, len(s)): if s[j-1] > s[j] : break currentMax += 1 if currentMax > max...
12dced039db26b3b9217d3f30062f2cae01cfebf
ThankMrSkeletal2016/Python-Zombie-Game
/Python Zombies/enemies.py
768
3.765625
4
import random class Enemy: """A base class for all enemies""" def __init__(self, name, hp, damage, gold): """Creates a new enemy :param name: the name of the enemy :param hp: the hit points of the enemy :param damage: the damage the enemy does with each attack :param go...
1969dfd844166fb1a431e448f6df77c64ca438b6
Matos-V/exercicios_python
/code/desafio024.py
98
3.875
4
nome = str(input('Qual a sua cidade: ')).strip() santo = nome[:5].upper() == 'SANTO' print(santo)
286f1ac0349a9cb0fa61335b92ed68b09971e660
vuhienminh/vuhienminh-fundamental-C4E25
/session04-assignment/ex2.py
365
3.90625
4
prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } for k in prices.keys(): print(k) print("price: ", prices[k]) print("stock: ", stock[k]) total = 0 x = prices[k] * stock[k] print("stock multiples by price", x) ...
6f07914f499f2a02ba5e78a24f645bf584c76ebf
mfrankovic0/pythoncrashcourse
/Chapter 7/7-2_restaurant_seating.py
165
3.90625
4
table = int(input("Hello, how many in your group?: ")) if table > 8: print("There's going to be a 5 to 10 minute wait.") else: print("I have a table ready!")
7785021e765bdc96f7e74346c57092c53bdb2964
renowncoder/computing-basics
/2-python/labs/lab2.py
1,709
4.0625
4
''' Python Lab 2 The purpose of this lab is to give you exposure to looping and control flow, two very basic concepts in the design of programs. ''' ''' Exercise 1: GPA Mean In this exercise, you will write a function to calculate the average GPA of three students. Each student is represented as a dictionary...
32f9bb290231547294e2d92c0d61f491669eac56
amrithamat/python
/pythonprogrms/pythondatastructures/listprograms/pairs.py
197
3.53125
4
lst=[1,2,3,4,5,6,7] #value=6 (4,2) sum=6 for i in lst: for j in lst: sumtotal=i+j if(sum==sumtotal): print((i,j)) break #more running time #not efficient
76221655977106d269aae8549ac2397923ea5a37
wangjksjtu/python_NumTheory
/NumTheory.py
11,190
3.765625
4
# This is a function-file which is related to the common algorithms in number theory. # Date1: 2017-05-04 # Date2: 2017-05-10 # Date3: 2017-05-18 import random def isPrime(n): if (n < 2 or (type(n) != type(1) and type(n) != type(1L))): return False if (n == 2): return True else: for...
ce729709e73209dc956788aa393664c6342cacef
pythonnortheast/slides
/2015/oct/code/random_search.py
577
3.921875
4
#!/usr/bin/env python """ Random search. Generates an independent random solution at each step. Does not care about repetitions. Prints best solution found so far. """ import string import random TARGET = "CHARLES DARWIN" CHARACTERS = string.ascii_uppercase + " " def evaluate(solution): return sum(1 for s,t in zip...
50603f7cb5059514ef9b0aa5e06d7e90d07523d0
rickydhanota/SList_SLL
/sll.py
3,815
4.21875
4
# class Node: # def __init__(self,val): # self.val=val # self.next=None # class SLL: # #What does this method do exactly? We're saying the pointer is None # def __init__(self): # self.head=None # def add(self,val): # n=Node(val) #This line creates a new instance of our n...
a3a1b2c5a4740807f5bf916d46562feab4250ea9
acttx/Python
/Comp Fund 2/Lab5/linkedList.py
4,977
4.25
4
class Node(): """ This class represents the Node of the LinkedList. The instance variables are public for simplicity. There is no need for getters or setters. The instances variables of this class include: 1. self.data: holds the data for the Node. 2. self.next: holds the pointer to the nex...
9c5f7f38d13c129275aaf7940f1b5514d9505501
alexandrudaia/Data-Engineering-Python-for-web-data
/Regular Expressions/FineTuning.py
695
4.125
4
#WE CAN REFINE re.findall() and to determine what portion #of match is to be extracted by using parentheses import re text='From stephen.marquard@uct.az.za Sat Jan 04:02:2018' y=re.findall('\S+@\S+', text) #print(y) #S means non white space and + at least one non white space #means get text that has ...
b19d248c92af7080075376fca20b4700a22ab7be
oran2527/holbertonschool-interview
/0x1F-pascal_triangle/0-pascal_triangle.py
438
3.6875
4
#!/usr/bin/python3 """ Pascal """ def pascal_triangle(n): """ Pascal """ matrix = [] if n <= 0: return matrix for i in range(1, (n + 1)): row = [] for j in range(i): row.append(1) matrix.append(row) for i in range(len(matrix)): for j in range(i...
fd8773ba6fff0e289c8db3a3be0a0dcdfbf8bc26
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_135/3416.py
1,346
3.5
4
tests = input() answers = [] for a in range(tests): firstAnswer = input() firstRowS = raw_input().split() secondRowS = raw_input().split() thirdRowS = raw_input().split() fourthRowS = raw_input().split() countableRow= [] for c in range(len(firstRowS)): if firstAnswer == 1: countableRow.append(int(firstRowS[...
6a16b42f89cbead691d5c8d1f8f00c3e7cd0101f
ibecon2019profetoni/entorno_virtual_Python37
/mini_apps/tabla_multiplar.py
519
3.84375
4
""" TABLA DE MULTIPLICAR -------------------- El usuario nos inserta un número entero y le printamos. La tabla de multiplicar de ese número. """ from imc import escenario_titulo def tabla_multiplicar(tabla): for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: print(tabla, "*", i, "=", i * tabla) i...
68ec23d2dd1feb3fd8f6a2fac51cc52e0945f26c
jakpop/python-exercises
/cwiczenia1/zad2.py
668
3.53125
4
import random def zad2(): size = int(input()) lista = [1, 5, 222, "a", "222", True, False] lista2 = [] for i in range(size): lista2.append(random.choice(lista)) podziel(lista) def podziel(lista): list_int = [] list_string = [] list_boolean = [] for i in range(len(lista))...
f876811877f7909fc26e9064bcecf558618761dc
ywcmaike/OJ_Implement_Python
/offer/18. 删除链表的节点.py
1,465
3.875
4
# author: weicai ye # email: yeweicai@zju.edu.cn # datetime: 2020/7/13 下午4:46 # 给定单向链表的头指针和一个要删除的节点的值,定义一个函数删除该节点。 # # 返回删除后的链表的头节点。 # # 注意:此题对比原题有改动 # # 示例 1: # # 输入: head = [4,5,1,9], val = 5 # 输出: [4,1,9] # 解释: 给定你链表中值为 5 的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -> 1 -> 9. # 示例 2: # # 输入: head = [4,5,1,9], val = 1 # 输出: [4,5,...
3503f0b75729714b2895a67e4a52778d9b81a435
miller9/another_python_exercises
/Extra/u_Working_in_and_saving_data_with_panda.py
3,063
4.34375
4
import pandas as pd print (""" After the import command, we now have access to a large number of pre-built classes and functions. This assumes the library is installed, in our lab environment all the necessary libraries are installed. One way pandas allows you to work with data is a dataframe. Let's go through th...
e08c999583b1fa6222d3a1548b9b6296b0820403
bgmnbear/learn
/Python/SICP/2.7.py
5,022
3.65625
4
# Universal method print(repr(12e12)) print(repr(min)) from datetime import date today = date(2018, 2, 21) print(today.__repr__()) print(today.__str__()) # Plural def add_complex(z1, z2): return ComplexRI(z1.real + z2.real, z1.imag + z2.imag) def mul_complex(z1, z2): return ComplexMA(z1.magnitude * z2.mag...
10c1c6907258ca9054aea3dfa6fa334f045e5be1
cham0919/Algorithm-Python
/프로그래머스/깊이_너비우선탐색/타겟_넘버.py
690
3.578125
4
"""https://programmers.co.kr/learn/courses/30/lessons/43165?language=java""" numbersList = [ [1, 1, 1, 1, 1] ] targetList = [ 3 ] returnList = [ 5 ] def dfs(numbers, target, sum, depth): if depth == len(numbers): if sum == target: return 1 else: return 0 ...
8ab70a4cbcb412efad5878b02af26f46821ed350
januarytw/Python_auto
/class_0524/class_1.py
1,103
3.9375
4
__author__ = 'Administrator' #交接作业 #把list_1车标里面的子列表的元素都一个一个输出来 #函数:内置函数 # type:len int range str list # list:insert append extend pop sort reversed # print input upper strip split lower # 特点: # 1 可以直接调用 # 2 可以重复调用 #函数 关键字def 函数名/方法名 (): # 代码 ,你这个函数要要实现的功能 #函数名的药酒:见名知意 小写字母 不同字母用下划线隔开 #定义函数 def print_str(name,age...
7b5570f2309a02ebf7c80a72bd5b248de77b5df6
lxw15337674/leetcode
/LeetCode/0010/best.py
528
3.578125
4
def isMatch(s, p): for a in range(len(s)): for b in range(a, len(p) - a - 1): # print(b) # print(b, s[b], p[a]) if s[b] != p[a] and p[a] != '.': # answer = isMatch(s[b:], p[a + 2:]) return print(s[b:], p[a + 2:]) # answer = isMatch(...
2b030ba383ab45a5f798f781c1e71296d6d3cd47
rennzorojas/python-course
/condicional02.py
587
3.75
4
DNI = input("ingresar el DNI:") dpt = input("ingresar la Dept:") sue = float(input("ingresar Sueldo:")) ts = input("ingresar Tiempo de Servicio:") #float soporta números decimales # : equivale a ENTONCES # if = verdadero # elif = verdadero # else = falso # and ambas se deben cumplir # or una sola se cumple if dpt == ...
4e0579b756f21bd9122bdea06b445833a1c40459
jorgepdsML/DIGITAL-IMAGE-PROCESSING-PYTHON
/CLASE2_PYTHON/FOLER_PYTHON_2/programas_opcionales/Ejercicios/EJEMPLOS_2/ejemplo_2_3.py
377
3.96875
4
#Ingresamos la altura: h = int(input("Ingrese la altura: ")) #Espacios vacios a partir de la altura ingresada: v = int(h-1/2) #Variable para el incremento de cantidad de #asteriscos de manera impar: n = 1 #Bucle de 'h' secuencias para al altura: for i in range(h): print (" "*v+"*"*n) v -= 1 n += 2 ...
e48e72b1116ef9cb26900ce0cafaeaa48601271e
aisus/NumericalMethods
/labs/src/Functions/task_one_function.py
134
3.625
4
def value(x): return float(x ** 3 - 2.1 * (x ** 2) - 2.6 * x + 1.7) def derivative(x): return 3 * (x ** 2) - 4.2 * x - 2.6
99e533555770545b978ca408760bbb157b4cc2b0
CapsLockAF/python-lessons-2021
/HW3/t1.py
436
4.15625
4
# Дано натуральне число. Визначити, чи буде це число: парним, кратним 4. natNum = int(input("Enter natural number: ")) val = 4 if natNum < 1: print(natNum, "is not a natural number") elif natNum % 2 != 0: print(natNum, "is not a paired natural number") elif natNum % val == 0: print(natNum, "is a multiple o...
7327a4fdaee01003899e91b45a48daa7ad7edb02
ref-humbold/AlgoLib_Python
/tests/sequences/test_longest_increasing_subsequence.py
1,781
3.75
4
# -*- coding: utf-8 -*- """Tests: Algorithm for longest increasing subsequence""" import unittest from assertpy import assert_that from algolib.sequences import find_lis class LongestIncreasingSubsequenceTest(unittest.TestCase): @staticmethod def test__find_lis__when_increasing__then_all_elements(): ...
a66d5cce4409e6f2bfe436c6e69884b4a787333e
Zirmaxer/Python_learning
/Bitroot/Test7.1.py
827
4.03125
4
''' Створіть базовий клас Animal із методом talk. Потім створіть два підкласи: Dog і Cat з їхніми власними реалізаціями методу talk. Наприклад, у Dog може бути print 'woof woof', а у Cat – print 'meow'. Також створіть просту функцію, яка приймає на вхід екземпляр класу Cat або Dog і виконує метод talk для вхідного пара...
4c271973ccc60316a875a0c2acf704111c9df04e
harrifeng/Python-Study
/Leetcode/Flatten_Binary_Tree_to_Linked_List.py
2,585
4.28125
4
""" Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 click to show hints. Hi...
8874b124149445715568206412999f410a6f012c
Rayna-911/LeetCode
/LC/python/Divide Two Integers.py
740
3.59375
4
class Solution: # @return an integer def divide(self, dividend, divisor): if (dividend > 0 and divisor < 0) or (dividend < 0 and divisor > 0): if abs(dividend) < abs(divisor): return 0 sum = 0 cnt = 0 res = 0 a = abs(dividend) b = abs(d...
2c949de61323165e9756262c9f0d6c510a1cfb0b
EmjayAhn/DailyAlgorithm
/18_programmers/programmers_05.py
386
3.59375
4
# https://school.programmers.co.kr/learn/courses/30/lessons/120829 # programmers, 코딩테스트 입문 def solution(angle): answer = 0 if angle == 180: answer = 4 elif angle > 90: answer = 3 elif angle == 90: answer = 2 elif angle < 90: answer = 1 return answer if __name__ == '__main__': test_set = [70, 91, ...
004eefcec99ac695693d97e31007d74d3272f8b4
1kunal1997/Scripts-from-Computational-Physics
/p3_hw9.py
1,089
3.6875
4
#!/usr/bin/python3 # # Counting Simulation - Plots a histogram of calling a photon counting simulation 1000 times, and overlaying a poisson distribution over it # # 02June2018 - Kunal Lakhanpal # from pylab import * import numpy as np import scipy.misc # Values for poisson distribution N = 1000 p = 0.002 mean = N*p ...
74e59840f6671e24fb3edd94ae2c8d366215a52c
gemmiller/Python-Practice
/cs104lab4/lab4_checkpoint1.py
270
3.734375
4
# @returns a string with the first and last charaters switched def switcharoo(word): #strings are imutable so we well break it in to a list chars = list(word) firstchar = chars[0] chars[0] = char[len(chars)-1] chars[len(chars)-1] = firstchar return ''.join(chars)
7132100d6b2e8b5d5f0db5b076d83ab0d24d0391
bingwin/python
/python/leetcode/中级算法/排序和搜索/find_peak_element.py
1,857
3.921875
4
# -*- coding: utf-8 -*- # Python中默认的编码格式是 ASCII 格式,在没修改编码格式时无法正确打印汉字,所以在读取中文时会报错。 # 峰值元素是指其值大于左右相邻值的元素。 # # 给定一个输入数组 nums,其中 nums[i] ≠ nums[i+1],找到峰值元素并返回其索引。 # # 数组可能包含多个峰值,在这种情况下,返回任何一个峰值所在位置即可。 # # 你可以假设 nums[-1] = nums[n] = -∞。 # # 示例 1: # # 输入: nums = [1,2,3,1] # 输出: 2 # 解释: 3 是峰值元素,你的函数应该返回其索引 2。 # 示例 2: # # 输入:...
727abdf7d6f12b1328566693ac19cefa7e90a084
dhina016/Student
/22-aug/43-22-08-01.py
389
3.640625
4
n=int(input()) #prime number or not for i in range(2,n): if (n%i)==0: print(n,'is not a prime number') break else: print(n,'is a prime number') #armstrong or not s=str(n) strl=(len(s)) l=list(s) r = list(map(int, l)) for i in range(len(r)): r[i]=r[i]**strl a=sum(r) if a==n: print(n,'is...
980d9d74caada718dcdb8ea498fed3b07da35ba2
rajsingh7/AppliedAI-2
/Excersises/NeuronNetwork/NeuronNetwork.py
15,943
3.703125
4
import numpy as np import math #using example from: https://www.neuraldesigner.com/learning/examples/iris_flowers_classification """ I used this structure because that way I could follow the tutorial. I wanted to try out some more structure but didn't have the time The iris structure consists of: An 4 neuron inputla...
f8a3e3c67ca92d95397d3c013fe4d489896c027c
chenguang281/homework
/First_homework(20190630)/homework_code_03.py
1,340
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import random host = """ host = 时间名词 主语名词 形容词 动词 事务名词 时间名词 = 上午、下午、昨天、晌午、半夜、去年、明天 主语名词 = 学生、群众、老头、妇女、同志、叔叔 形容词 = 很快地、迅速地、悄悄地、静静地 动词 = 打、追着、敲着、吆喝、盯着 事务名词 = 蜗牛、猎豹、奥托、棒球、战斗机、冥王星 """ # 该方法主要是将文本转换成字典类型的数据 def create_grammar(grammar_str, split='=', line_split='\n', code_spli...
82d47b1d2f42d30c9e56f632869b0c475527c85d
imcglo12/Dungeons-and-Monsters
/FirstMenu.py
457
3.953125
4
#This function will display the initial menu options #Imports import MenuSelection as ms #The function def main_menu(): count_1 = 10 while count_1 > 0: option_1 = input("\n\n Please choose an option below\n\n"\ " 1) Create New Character\n"\ " 2) ...
670b03565dd1083b399edfc883232ecff4814b3f
HarryHenricks/CP1404-Labs
/prac_09/files_to_sort.py
708
3.59375
4
import os, shutil def main(): print("Starting directory is: {}".format(os.getcwd())) directory = os.chdir('FilesToSort') print("Files in {}:\n{}\n".format(os.getcwd(), os.listdir('.'))) folder_name = '' folder_name_dict = {} for filename in os.listdir('.'): head, sep, tail = filename.p...
46ce6c21e84362d2f1950a2946c3b5c60de8a5c6
tashachin/coding-challenges
/single-riffle.py
1,390
4.28125
4
def is_single_riffle(half1, half2, shuffled_deck): """Checks to see if the input deck is a single riffle of two other halves.""" # right now i don't really understand what the input is # output must be a boolean, though # smaller function that checks if everything in one half is in the shuffled_deck ...
e46432bd59fb721f5a4e579718f5884e0c17b141
Whirt/MagicPortal
/21March18_Esercitazione_Python/Es1.py
744
3.921875
4
# Esercizio Bubble Sort # Bubble sort # alla prima iterazione, scandisco l'array e swappo tutti gli elementi # col successivo se più grandi, e così succede che il più grande viene # definitivamente confinato alla fine. # alla seconda iterazione, scandisco l'array fino al penultimo elemento # e ripeto così definitiva...
76031b975f172e86dd4ae8054f8b84b3802013ff
Ahmed-Abdelhak/Problem-Solving
/Algorithms/BinarySearch/BinarySearch.py
1,415
4
4
class BinarySearch: def __init__(self, el, items): self.__el = el self.__items = items self.__left = 0 self.__right = len(self.__items) - 1 def serach_recursive(self): return self.__search_recursive(self.__el,self.__items,self.__left,self.__right) ...
2e59d7e91adce22bda1baa2a364a5bb9919c0558
Prashant-Surya/Project-Euler
/6.py
252
3.640625
4
""" Difference between sum of squares and square of sums of first 100 natural nums. """ n = 100 sum_of_squares = n*(n+1)*(2*n+1)/6 square_of_sums = (n*(n+1)/2)**2 print sum_of_squares print square_of_sums print abs(sum_of_squares - square_of_sums)
717b04854c5200d7dc3b0641f4b96e8206c7d51e
alexshaoo/Visualizations
/Circle.py
4,618
4.0625
4
import math import pygame from Data import Data # Euclidean distance between two points def distance_between(pos1, pos2): """Calculates the Euclidean distance between two positions :arg pos1: The first position :arg pos2: The second position :return: The distance between the two positions ...
0ef8a03d1ba401ccb0205e061c46b56bf46d9ec7
MonkeyNi/yummy_leetcode
/slide_window/5739.py
651
3.671875
4
class Solution: """ 这个问题实际上就是找符合条件的最长子序列,记录最长长度就可以 Sliding window, O(n) """ def maxFrequency(self, nums, k): if not nums: 0 nums = sorted(nums) res = 1 start = 0 for end in range(len(nums)): k += nums[end] if k < nums[end] *...
1ad6bb5809579653a8bef426ea35b69a22c8e9d6
dtokos/FLP
/project-euler/17_Number-letter-counts.py
2,034
3.75
4
# coding=utf-8 # Number letter counts # Problem 17 # https://projecteuler.net/problem=17 # # If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, ...
cd2613a91cd256d89c8246fe039aca7641ce0830
AlexandreGaultier/AutodidactePython
/Casino.py
1,282
3.96875
4
import random import math choice = -1 mise = -1 money = 500 print("") print("Bienvenue au casino") print("Vous avez 500$") while money > 0: print("") print("---------------------") print("Choississez un nombre entre 0 et 49 inclus :") choice = int(input()) print("") while choice > 49 or choi...
06b2da5158ea9ecc0ca20d4a363d88eb40e5b03b
tanvidev/python
/assignment2/Arithmetic.py
450
3.984375
4
def add(num1, num2): ans = num1 + num2; print "Addition is - ", ans; def sub(num1, num2): if(num1 > num2): ans = num1 - num2; else: ans = num2 - num1; print "Subtraction is - ", ans; def mult(num1, num2): ans = num1 * num2; print "Multiplication is - ", ans; def div(num...
ff58c4d0f9d4b3f1e767dd917f41053e025e7339
anstadnik/univ
/sem_2/ookp/proj/wall.py
633
3.515625
4
import pygame as pg class Wall(): """Class for walls and glasses""" def __init__(self, t, beg, end): """TODO: to be defined1. """ self.type = t self.beg = beg self.end = end def draw(self, screen: pg.Surface): """TODO: Docstring for draw. :f: TODO ...
78ed8b294d3ec5b2a77ecbe0039dc6984b1a5f50
duduhali/HasAI
/test_2.py
2,213
3.71875
4
import re from functools import reduce '''返回切分后的词 >>>tokenize('Bob dropped the apple. Where is the apple?') ['Bob', 'dropped', 'the', 'apple', '.', 'Where', 'is', 'the', 'apple', '?'] ''' def tokenize(sent): return [x.strip() for x in re.split('(\W+)?', sent) if x.strip()] '''Parse stories provided in the bAbi t...
7d3b6308f65e4883fbb0b652f54015fb392d69c9
VladUO/cis422-proj-1
/tsp_tests.py
2,674
3.703125
4
""" Tests for tsp.py solution To run the tests on this file do the following: Basic test: $ python3 tsp_tests.py Verbose test to see each test function's success or failure: $ python3 -m unittest -v tsp_tests.py Test with performance profiling: $ python3 -m cProfile -s cumtime tsp_te...
bdb6b854b0decd950fb75388762fc3ad2a42ebf1
amar-chheda/uber_driver_sentiment_analysis
/ip_fetcher.py
1,570
3.5625
4
"""This function used to get various IP proxies which enables us to scrape the websites faster The function returns a list of 110 working porxies""" def ip_fetcher(): try: working_proxy = [] # you can sign-up on https://www.proxyrotator.com/ for free to get your own APIKey keys = ['API_KE...
0e276025f2221d4baca148ebf366ce69ba33857a
IgnacioCastro0713/exercises
/classroom/funciones.py
284
3.734375
4
''' José Ignacio Menchaca Castro 215818166 ''' val1 = 4 val2 = 6 def sum1(): return print(val1 + val2) def sum2(value_1, value_2): return print(value_1 + value_2) def divisibles(): for i in range(1, 26): if i % 7 == 0: print(i) sum1() sum2(val1, val2) divisibles()
d4c87a2d10a5cb26a90cc8c286970ba25534eddc
connor2033/Shape-Volume
/venv/volumes.py
1,141
4.375
4
from math import pi #cube function that asks for input, calculates and returns the volume. def cubevolume(): cubelength = int(input("Enter a side length: ")) c_vol = abs(cubelength**3) e_vol = round(e_vol,3) print("The volume of a cube with a side length of {} is: {}".format(cubelength,c_vol)) retu...
162a546454368327e05965b7ee408b350f3730e7
robinDetobel/Python_Werkcolege1
/main.py
2,100
3.6875
4
import math as m import random as r ''' #Oefening 1 a = int(input("Geef een getal ")) b = int(input("Geef een getal ")) print(a+b) print(int(a/b)) print(a%b) a += 1 b +=1 print(a + b) ''' ''' #oefening 2 straal = int(input("Geef de staal van een cirkel: ")) omtrek = 2 * 3.141592 * straal oppervlakte = straal * s...
e28ec22c3f6f03ae859f54851e45a283c4373067
VineetKhatwal/Python
/DataStructure/LeetCode/Ans17.py
644
3.734375
4
# Python3 implementation of the approach from collections import deque import itertools def letterCombinations(number): map = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] if not number: return None list1 = [] res = [] for i in number: list1.app...
0b8d68e377d886dafa1fa98cdc6c1b07730d0627
joestalker1/leetcode
/src/main/scala/KSimilarStrings.py
1,078
3.515625
4
from collections import deque class Solution: def kSimilarity(self, A, B): def neighbours(S): for i in range(len(S)): if S[i] != B[i]: break arr = list(S) for j in range(i + 1, len(S)): if S[j] == B[i]: ...
cad7e68d5517bb801b46664f1b812e4752cedce7
thegreaterswan/mydictionary
/basecode.py
1,822
3.8125
4
import json #import json module from difflib import get_close_matches data = json.load(open("PythonMegaCourse/dictionary/data.json")) #loads json file into data variable #this json file is a list of all of the keys in a dictionary def translate(w): #setting up a whole function block to complete the desired task ...
d481d94aa5e5ffe3c6e0e4c0a45b65efeaab56a8
greendar/mth1w202122
/numberOfDigits.py
214
3.75
4
# Program to determine the number of 7 digits in all the numbers from 1 - 1000 strOut = "" for i in range(1, 1001): strOut += str(i) n = 0 for digit in strOut: if digit == '7': n += 1 print(n)
305331b8df02965454cf65778c4660512e6d73f9
UiL-OTS-labs-backoffice/Compare-CodeIgniter-Language-Folders
/compare.py
2,435
3.703125
4
import os, re, collections class compare(object): ''' Compares two folders of language files from the babylab and reports missing translations ''' dirs = [] files = collections.OrderedDict() entries = collections.OrderedDict() def __init__(self): ''' checks which folders exists lists the files in tho...
022b2637c1f6a36cda1193937b197a7eadce7bd0
lizenghui1121/DS_algorithms
/剑指offer/13.数组的逆序数.py
1,085
3.703125
4
""" @Author: Li Zenghui @Date: 2020-04-03 21:38 """ class Solution: def InversePairs(self, data): # write code here def merge(arr_left, arr_right, result): res = [] while arr_left and arr_right: if arr_left[0] > arr_right[0]: res.append...
67473c2112b52883466c273fc62d2ec25f5c9453
Nickruti/HackerRank-Python-Problems-
/Data_Structures-Stacks-Equal_Stacks.py
3,818
4.375
4
''' You have three stacks of cylinders where each cylinder has the same diameter, but they may vary in height. You can change the height of a stack by removing and discarding its topmost cylinder any number of times. Find the maximum possible height of the stacks such that all of the stacks are exactly the same height...
a1ba35d4a2606815f09e812233b2523e5376c136
DvidGs/Python-A-Z
/9 - Funciones en Python/ejercicio 7.py
463
3.953125
4
# Ejercicio 7 # Crea una función que dada una palabra devuelva si es palíndroma. def is_palindrome(word): """ Devuelve si la palabra word es palídroma. Args: word: Palabra Return: isPalindrome: Booleno """ word = word.lower() l = [] isPalindrome = True for c in word...
374b6e5e6ab79f9b312dbaf89485676128542a0d
jdmichaud/knapsack
/knapsack.py
713
4.09375
4
import sys def knapsack(entries, capacity, indent=0): max_weight = 0 max_content = [] for entry in entries: weight, content = knapsack([x for x in entries if x != entry], capacity - entry, indent + 1) total_weight = entry + weight if total_weight <= capacity and max_weight < total_weight: max_w...
2a0b6017f62ba8c73d03d4f71157a0d813a492df
maodunzhe/clean_code
/dfs/pathSum.py
1,503
3.828125
4
''' This method is wrong: 1. it's complicated than the correct one 2. two many pitfalls 3. not counting to the real leaf (root.left is None and root.right is None) ''' class Solution(object): def hasPathSum(self, root, total): return self.hasPathSumHelper(root, total, []) def hasPathSumHelper(self, root, total, n...
996de11e2bcf442170b8e8cb5dcae977d238cf27
sksam-Encoder/pythonCourse
/switchCase.py
551
4.125
4
# Function to convert number into string # Switcher is dictionary data type here def one(): return "one" def two(): return "two" def three(): return "three" def numbers_to_strings(argument1): switcher = { 1: one, 2: two, 3: three, 4: -1 } # calling function ...
31e534f4f90bfcd3f71f18fad47e5b4f1f97d33d
2kofawsome/2ksGames
/gameFiles/UsedToCreateWords.py
411
3.640625
4
#! python3.6 import pyperclip before=pyperclip.paste() newlist=before.split('\n') while True: blah=False for length in range(len(newlist)): if len(newlist[length]) < 6: print(newlist[length]) del newlist[length] print(length) blah=True bre...
86989b5798ea79358f7fe1a7a1f6e9ca266e65ac
Fleschier/Python
/My Python Programs/CH5/.idea/1627405072_E032.py
154
3.625
4
x=input('请输入一段英文:') import re p1=re.compile('\s+') p2=re.compile(r'([!,.?;:\'\"!])(\w+)') x=p1.sub(' ',x) x=p2.sub(r'\1 \2',x) print(x)
dc699336b14228475a94bfcd3bd1a0a60c3a9bf9
joaoaffonsooliveira/curso_python
/Fundamentos/tuplas.py
804
4.59375
5
# ANOTAÇÕES AULA ''' Até agora usamos variáveis simples. ex: lanche = hamburguer mas e se eu quiser acrescentar mais de um lanche? se eu fizer lanche = coxinha hamburguer é apagado daí surge a necessidade de criar variáveis compostas, ou também chamadas de tuplas. Na verdade já falamos de variáveis compostas quando es...
704cf0112f5c6d573b6c1973d6451aeaf72274e3
Prudhivi326929/python3
/string_for.py
170
3.921875
4
name = input("Enter your name: ") surname = input("enter your surname: ") #message = "Hello %s %s% {name, surname message = f"Hello {name} {surname}" print(message)
587f98d9eace94b5a499224a9270c90ba62faf20
v2krishna/PythonRoutines
/01_Basics/05_logicalOperators.py
183
4.25
4
""" Logical Operators and or not """ x = True y = False print("x and y is {}".format(x and y)) print("x or y is {}".format(x or y)) print("not of x is {}".format(not x))
07434f809ded8cae28ff408597c71112e494ca8b
SMDXXX/Practice-Materials
/helloworld.py
2,954
4.15625
4
print ( 'hello world') print ('***LOOP PRACTICE***') # for intergers in range for i in range (2): print('A') print('B') for i in range (2): print('A') print('B') print(" ...
c30539d6c8acbcd04179cd56c24e91cb5f086cfd
arvind0422/Binary-Decision-Diagrams
/BDD/Consensus.py
1,281
3.78125
4
""" This code helps one perform the consensus operation on two given vectors. Inputs: Two numpy vectors with data in PCN format. Outputs: A matrix with the consensus operator applied on the two vectors. Authors: Arvind, Shantanu, Sripathi """ import numpy as np import Check_void as CV def consensus(a, b):...