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
daa6a608437bc2872e9554c732efb464b6669676
a100kpm/daily_training
/problem 0009.py
1,455
3.90625
4
'''Good morning! Here's your coding interview problem for today. This problem was asked by Airbnb. Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] shou...
275789a5c9fb66ceb5cf27c57f573a310aebca1a
a100kpm/daily_training
/problem 0248.py
642
3.5
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Nvidia. Find the maximum of two numbers without using any if-else statements, branching, or direct comparisons. ''' # ============================================================================= # TRAVAIL SUR LES BITS (not ...
ba7ce38235fcbdc74e1749cff80c6781b021da28
a100kpm/daily_training
/problem 0256.py
1,310
4
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Fitbit. Given a linked list, rearrange the node values such that they appear in alternating low -> high -> low -> high ... form. For example, given 1 -> 2 -> 3 -> 4 -> 5, you should return 1 -> 3 -> 2 -> 5 -> 4. ''' class L...
061785463b5a8266b0733e10554b78b4b1eb00e8
a100kpm/daily_training
/problem 0276.py
1,225
3.765625
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Dropbox. Implement an efficient string matching algorithm. That is, given a string of length N and a pattern of length k, write a program that searches for the pattern in the string with less than O(N * k) worst-case time c...
ccc4fdb1d5e90b7c9c803024c7385fe499157df4
a100kpm/daily_training
/problem 0103.py
1,416
3.984375
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Square. Given a string and a set of characters, return the shortest substring containing all the characters in the set. For example, given the string "figehaeci" and the set of characters {a, e, i}, you should return "aeci". ...
629fcb0115f3ddde87878aea83385ec99b379dcf
aws/amazon-sagemaker-examples
/sagemaker-script-mode/generate_synthetic_housing_data.py
2,386
3.875
4
from random import choice import numpy as np import pandas as pd NUM_HOUSES_PER_LOCATION = 1000 LOCATIONS = [ "NewYork_NY", "LosAngeles_CA", "Chicago_IL", "Houston_TX", "Dallas_TX", "Phoenix_AZ", "Philadelphia_PA", "SanAntonio_TX", "SanDiego_CA", "SanFrancisco_CA", ] MAX_YEAR =...
53d055889121449e104cca301aa56a9bd32dd5ea
chencath/DEDA_Class_2017
/DEDA_Class_2017_Python_Introduction/DEDA_Class_2017_Python_Introduction_t.py
5,573
4.0625
4
""" Python Basic Syntax and Data Structure Introduction """ """ numeric operation """ """ try basic operations: +, -, *, /, %, **, // """ a = 5 b = 3 a *= 2 # 10 round(a / b, 4) # 3.3333 c = '10' d = '20' e = c + d # '1020' f = int(c) + int(d) # 30 """ try comparision operations: ==, <, <=, >, >=, != """ """ s...
3b87403cb069c85f392620220b2a0faf463f854a
DamiAdeeso/assignment-2
/assingment2-Q1.py
431
4
4
user_input =input("Enter your number in range 1-7: ") if user_input == "1" : print("Monday") elif user_input == "2": print("Tuesday") elif user_input == "3": print ("Wednesday") elif user_input == "4": print ("Thursday") elif user_input == "5": print("Friday") elif user_input == "6": ...
57d9ed9925e004ae35500e31490ea20c84f2f072
Dinah-w/Thesis
/singlecontroller.py
2,242
3.734375
4
"""Custom topology example Two directly connected switches plus a host for each switch: host --- switch --- switch --- host Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command line. """ from mininet.topo import Top...
e3704481c48e11603b5fe3ef142fcec3cb665deb
Karvenko/MADE-Projects
/Algorithms/16 Geom/task_a.py
993
3.671875
4
"""Task A Solution""" class Point: def __init__(self, x, y): self.x = x self.y = y class Vector: def __init__(self, a, b): self.x = b.x - a.x self.y = b.y - a.y def scalar_product(self, other): return self.x * other.x + self.y * other.y def vector_product(self...
b64488d7e0bb1e03c9d730665bca17216f5af841
Karvenko/MADE-Projects
/Algorithms/03 Search/task_e.py
1,198
3.609375
4
"""Task F solution""" import math class Xerox: """Class to store xerox info""" def __init__(self, n_pages, t_x, t_y): self.n_pages = n_pages self.t_x = min(t_x, t_y) #Always fastest self.t_y = max(t_x, t_y) #Always slowest def get_value(self, n): """Calc copy time if n pa...
8fef8bb3c63180e0bc1f8fea6d0a6cfe28e4c8a9
Karvenko/MADE-Projects
/Algorithms/02 Sort/task_d.py
1,123
3.8125
4
"""TAsk D solution""" def anagram_count(child_array, gr_array): """Anagram counter""" counter = 0 child_counter = [0] * 128 #counting child's chars for ch in child_array: child_counter[ord(ch)] += 1 for i, ch in enumerate(child_counter): #filling with negative if ch == 0: ...
d26b0a052178976dab15f3997b05155b15c6fdcf
Wei9023/coding
/2.py
1,835
3.953125
4
sum=0 i=0 while i<10: sum=sum+i print sum i=i+1 a="vv is beautiful" b="she smiles a lot" math_string="3+4*2" expression_string="a+' '+b+' i love u'" print a+b print eval(math_string) print eval(math_string+"1") print eval(expression_string) print math_string.find("+") number=input("enter a non-negative int...
66ec721d8333218a176ede51cba923db3dc15241
IvanSan-One/python_lesson_2
/while.py
531
3.96875
4
# Цикл while -------------- #-------------------------- for i in range(1,6): print(i,0) # Простейший while # i = 0 # # while i < 10: # print(i) # i = i + 1 # if i == 5: break # # # # # answer = None # # # # while answer != 'Volvo': # # answer = input('Какая лучшая марка автомобиля?') # # print('Вы...
b19700257c64b4e6159a41f038b2ac3823aa6c7c
santoshsoren/Klodone
/Python/Assinment 1 & 2/ReverseString1.py
145
4.15625
4
def reverse(strg): str = "" for i in strg: str = i+str return str st = input("Enter string: ") print(reverse(st))
9d7b1632f6de7706e5ff6ce29567bd85209f3a2b
santoshsoren/Klodone
/Python/Assinment 1 & 2/checkprime.py
213
4
4
def check_prime(num): for i in range(2,num): if num%i==0: print("not prime") break else: print("prime") n = int(input("Enter number: ")) check_prime(n)
4757a8bd3aa84987d79eeacba4a3b2e9297a6f39
santoshsoren/Klodone
/Python/Assignment 5/tictoe.py
2,793
3.9375
4
board = ["-","-","-", "-","-","-", "-","-","-"] play = True winner = None player = "X" def display(): print(board[0]+" | "+board[1]+" | "+board[2]) print(board[3]+" | "+board[4]+" | "+board[5]) print(board[6]+" | "+board[7]+" | "+board[8]) def game(): display() w...
fc523075ae20828ed0beee6a4ea6510207091f52
PiggyAwesome/onion-bruteforcer
/onion.py
2,686
3.5625
4
""" Bruteforce .onion links to find dark web sites. This program is not recommended to be used, because it provides no security or protection, when trying the links. Author: PiggyAwesome """ import requests, random, string, os, tkinter.messagebox; def coloured(r, g, b, text): return "\033[38;2;{}...
329341d44d5d8ad2f5afc8eccf0ca5a3250ec77c
barisoztas/project_jobs
/project_jobs/centroid_initialization.py
2,803
3.921875
4
from math import sqrt, floor import numpy as np def random(ds, k, random_state=42): """ Create random cluster centroids. Parameters ---------- ds : numpy array The dataset to be used for centroid initialization. k : int The desired number of clusters for which cen...
33a8436968201e21534d48054ab4ee35a274051e
AyadiGithub/Cryptocurrency-Price-Webapp
/Crypto_Prices.py
3,519
3.625
4
""" Cryptocurency Daily Prices Webapp - Using streamlit and Yahoo Finance """ import yfinance as yf # Yahoo finance to get stock data import streamlit as st # Streamlit to create the webapp from PIL import Image # Import Pillow to add icons from urllib.request import urlopen # To add URLS # De...
625c3d016087f104ed463b41872b3510d000a04c
Abhishek4uh/Hacktoberfest2021_beginner
/Python3-Learn/Decorators_dsrathore1.py
1,775
4.625
5
#AUTHOR: DS Rathore #Python3 Concept: Decorators in Python #GITHUB: https://github.com/dsrathore1 # Any callable python object that is used to modify a function or a class is known as Decorators # There are two types of decorators # 1.) Fuction Decorators # 2.) Class Decorators # 1.) Nested function # 2.) Function...
6140f167e4b36093bacd15f2728626d93f4d5856
ermidebebe/Twitter-Data-Analysis
/extract_dataframe.py
6,023
3.765625
4
import json import pandas as pd from textblob import TextBlob import sys sys.path.insert(0, '\\') def read_json(json_file: str) -> list: """ json file reader to open and read json files into a list Args: ----- json_file: str - path of a json file Returns ------- length of the jso...
bda941a3ce5a1f5b99d38b11bf152c5f135f16fb
BABIKA06/KloudOne-Assignments
/python programs/Program to calculate using various operations.py
643
4.0625
4
'''To calculate using various operations''' def add(x,y):return x+y def sub(x,y):return x-y def mul(x,y):return x*y def div(x,y):return x/y print("select operation") print("1.addition:") print("2.subtract:") print("3.multiplication:") print("4,division:") choice=input("enter choice(1/2/3/4):") n1=int(input...
833826eace958c62e746f6d4ed6da66b8f6ea628
Ryuya1995/leetcode
/q37_Sudoku_Solver.py
2,483
3.71875
4
import random class Solution: def readSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ line = [set(['1', '2', '3', '4', '5', '6', '7', '8', '9']) for _ in range(9)] row = [set(['1', '2', '3', '4', '5', '6', '7', '8', '9']) for _ in range(9)] ...
767d87d1bd06d44052f3e398a08cefbff0d21e90
Ryuya1995/leetcode
/q23_Merge_K_Sorted_Lists.py
623
3.890625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ from queue import PriorityQueue dum = curr...
99111347c5b26ff1134c055226d8244448af788a
Ryuya1995/leetcode
/q53_Maximum_Subarray.py
744
3.515625
4
class Solution: def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ # if nums: # left = 0 # right = len(nums) # ans = nums[0] # while left<right-1: # ans = max(ans,sum(nums[left:right])) ...
8fe069fdbf743224d3c83d6f56dca532ec6187dd
George-Emmanuel/useful_snippets
/parenthesis_checker.py
390
3.5625
4
def test(t): res = [] for i in t: if i in ["("]: res.append(i) else: if not res: return False j = res.pop() if j == '(': if i != ")": return False if res: return False return True ...
2989e4064db8475c6395203c74362166be3ac569
George-Emmanuel/useful_snippets
/knapsack_dp.py
532
3.734375
4
def knapsack(Capacity, weights, profits, n): if n == 0 or Capacity == 0: return 0 if weights[n - 1] > Capacity: return knapsack(Capacity, weights, profits, n - 1) else: return max(profits[n - 1] + knapsack(Capacity - weights[n - 1], weights, profits, n - 1), knapsa...
6a5e169d426a7ae82f1ada99a7972f16ff0df1cf
renjithrp/smart-winds
/db.py
2,029
3.625
4
import sqlite3 from sqlite3 import Error from config import DATABASE_NAME CREATE_TABLE_QUERY = """ CREATE TABLE IF NOT EXISTS data ( id integer primary key autoincrement , spool_width NUMERIC, spo...
cd41ed5956ca5f391dd9c01d168df6fc7dfca52d
teranpeterson/LeetCode
/Puzzles/21. Merge Two Sorted Lists.py
1,123
3.890625
4
# SOLVED # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeTwoLists(self, l1, l2): ret = ListNode("x") nxt = ret while l1 != None or l2 != None: if l1 == None: n...
e85f405145f14d6dc5680b655c2b358e7bfc66f2
teranpeterson/LeetCode
/Daily Challenge/Gas Station.py
679
3.515625
4
from typing import List class Solution: def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int: l = len(gas) for i in range(l): if gas[i] >= cost[i]: j = i tank = gas[j] while True: print("Tank: " + str(ta...
ac2c092e55c1039958e82262ccb061a399d79560
teranpeterson/LeetCode
/Puzzles/2. Add Two Numbers.py
2,003
3.859375
4
# SOLVED # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: self.print_node(l1) self.print_node(l2) res = None start = None ...
9daa24ea3f2a15aacb149a4b4f76b65ed5b1fc18
teranpeterson/LeetCode
/Daily Challenge/Largest Time for Given Digits.py
203
3.5625
4
from typing import List class Solution: def largestTimeFromDigits(self, arr: List[int]) -> str: out = "" for n in sorted(arr): print(Solution().largestTimeFromDigits())
a7fb7c06e157aa027584565bb5dd36ab23a9abeb
teranpeterson/LeetCode
/Puzzles/633. Sum of Square Numbers.py
389
3.53125
4
import math class Solution: def judgeSquareSum(self, c: int) -> bool: n = math.floor(math.sqrt(c)) for i in range(n, -1, -1): x = i*i m = c - x if math.sqrt(m).is_integer(): return True return False print(Solution().judgeSquareSum(5)) pri...
d29b902b56c3dcd3f132d6a3d699b061ccdb3bb6
michaeldton/Fall20-Text-Based-Adventure-Game-
/main.py
1,859
4.21875
4
import sys from Game.game import Game # Main function calls the menu def main(): menu() # Quit function def quit_game(): print("Are you sure you want to quit?") choice = input(""" 1: YES 2: NO Please enter your choice: """) if choic...
15049df575ac57d2943460b74d4880421f8e232f
KimTaesong/Algorithm
/CodingTest_Study1/week28/단어변환.py
1,917
3.578125
4
from collections import deque from collections import defaultdict def solution(begin, target, words): # 2개의 단어가 서로 한글자만 다른 단어인지 판별 def available(w1, w2): wrong = 0 for i in range(len(w1)): if w1[i] != w2[i]: wrong += 1 if wrong > 1: retur...
25d3a30c2c2175089eb20f50f3afcbb637aca25f
KimTaesong/Algorithm
/CodingTest_Study1/week19/위장.py
295
3.578125
4
def solution(clothes): answer = 1 cloth = dict() for i in clothes: if i[1] not in cloth: cloth[i[1]] = 1 else: cloth[i[1]] += 1 for key, value in cloth.items(): print(key, value) answer *= (value+1) return answer - 1
097110b29c516d5fe5bd7277e88d7d348b0e2a5c
KimTaesong/Algorithm
/programmers/Algorithm/Level1/문자열내마음대로정렬하기.py
192
3.671875
4
strings = ["sun", "bed", "car"] n = 1 def solution(strings: str, n: int): strings.sort() answer = sorted(strings, key=lambda x: x[n]) return answer print(solution(strings, n))
e374af25c6772cf100306a014a026da5429fac81
zqh-hub/python_base
/抽象/抽象-02-分配参数.py
196
3.953125
4
# 分配参数 def add(x, y): print(x + y) # par = (1, 2) # par = [1, 2] par = 1, 2 add(*par) par = {"name": "coco", "age": 12} def hello(name, age): print(name, age) hello(**par)
570fb365c121fcf6d5dbb573410de4b947539441
zqh-hub/python_base
/列表/列表_01_通用操作.py
758
4.3125
4
# 序列:列表、元组、字符串 # 容器:序列、映射(如:字典) # 通用序列操作:索引、切片、相加、相乘、成员资格 # 索引 print("hello"[0]) print("hello"[-1]) # res = input("year:")[3] # print(res) # 切片 tag = '<a href="http://www.python.org">Python web site</a>' print(tag[9:30]) print(tag[9:-21]) nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(nums[7: 10]) print(nums[-3:]) prin...
d8d7630116e78568e5c239ba9c3687c4305fac91
zqh-hub/python_base
/抽象/抽象-04-抽象基类.py
401
4.0625
4
from abc import ABC, abstractmethod class A(ABC): # 抽象类不能被实现,只能被继承 @abstractmethod def read(self): pass class a(A): def read(self): # 抽象基类中的抽象方法必须实现 print("a") # 在这种情况下,使用isinstance()最妥当 aa = a() res = isinstance(aa, a) # True print(res) res = isinstance(aa, A) # True print(res) ...
5d5daa712f1deb7277f2a1d66ad2afe48f4f6ddc
da-w-xu/Euler
/IsPandigital.py
594
3.515625
4
import itertools def GetPandigitals(n): """ Get all pandigitals with len n """ l = list( itertools.permutations(range(1,n+1)) ) p = [] for i in l: x = 0 for k in i: x *= 10 x += k p.append(x) return p def IsPandigital(n): n = int(n) l = len(str(n)) panset = [] for i in range...
6eb51dca1f78be3409ee732a9e7a122a3a47df00
da-w-xu/Euler
/IsPrime.py
242
3.921875
4
from math import sqrt def IsPrime(x): x = abs(int(x)) if x < 2: return False if x == 2: return True if not x & 1: return False for a in xrange(3,int(sqrt(x))+1,2): if x % a == 0: return False return True
873e9e23eb07cf613f0c40f638ebfdedb25d7db6
da-w-xu/Euler
/euler6.py
236
3.609375
4
def SumSquaresFirstN(n): sum=0 for i in range(1,n+1): sum += i*i return sum def SquareSumsFirstN(n): sum=0 for i in range(1,n+1): sum += i sum *= sum return sum print SquareSumsFirstN(100)-SumSquaresFirstN(100)
d770011ac09cf8880cf245995f150112d1d3b1fc
LopesAbigail/UFABC-BCC-2021
/CSV/statistic-conditional-median.py
651
4.1875
4
# Ler a planilha # Receber do usuario a turma # Calcular a media e a mediana da turma recebida no passo anterior # Se a media for maior ou igual a mediana, imprima a palavra Media # Caso contrario, imprima a palavra Mediana import pandas as pd import numpy as np df = pd.read_csv( "https://www.dropbox.com/s/jqfici...
69eae8a14e98c0d3ef42e1ca8fa10879fbb17a87
LopesAbigail/UFABC-BCC-2021
/CSV/conditional-mean-adjustment.py
1,072
3.625
4
# Ler o link da planilha # Receber do usuario o nome de um dos exames (Exame 1, Exame 2,...) # Adicionar uma nova coluna com nome Ajuste com as notas do exame recebido no passo anterior, ajustadas de acordo com as seguintes regras: # • Se a media do exame for < 50, a nota ajustada tera um acrescimo de 20% da nota origi...
9c1cf6035902fdd1ff3133ae702ab1aa6b239e71
LopesAbigail/UFABC-BCC-2021
/Test-Final/P1-05.py
247
3.875
4
# Prova Final - ex05 x = int(input()) y = int(input()) multiplos_3 = 0 for i in range(x, y+1): if i % 3 == 0: print("Múltiplo de 3") multiplos_3 += 1 else: print(i) print("Total de múltiplos de 3:", multiplos_3)
f6c5b9ae9be92219d025cf496286b9413eb8f434
stoneskin/mlcccCoding
/2018-03-11/10-Inheritance/shape.py
709
4.21875
4
# https://www.programiz.com/python-programming/inheritance class Shape: def __init__(self, name: str=""): self.name = name def printInfo(self): print("in shapes, Name=", self.name) class Polygon(Shape): def __init__(self, no_of_sides,name:str="Ploygon"): self.name=name; Sha...
43c1e23b9495c2f2fbf0ac72378396df19739f5d
Thennarasu005/python-codes
/list.py
184
3.796875
4
n = input("enter the list range:") l = [input("Enter the list elements:") for _ in range(n)] print "The list is:",l sum = 0 for i in range (0,n): sum = sum + l[i] print "sum:",sum
cf210a8f0f39960bdbb3fce3c436f2f70e6e4fa5
finbourne/lusid-python-tools
/lusidtools/pandas_utils/lusid_pandas.py
4,900
3.59375
4
import pandas as pd from flatten_json import flatten import logging logger = logging.getLogger() def lusid_response_to_data_frame( lusid_response, rename_properties: bool = False, column_name_mapping: dict = None ): """ This function takes a LUSID API response and attempts to convert the response into a ...
18908fcabb75aa391abfb5c7f41ed065b71da1f8
abid-mehmood/SP_Assignments
/Assignments/Assignment02/Problem03/Problem 03.py
1,129
3.921875
4
""" Bilal Waseem BCSF14M511 System Programming Task 3: 2x2 matrix in 8x8 """ def matrix8x8(): matrix = [[1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 4, 3, 7, 1, 2], [3, 4, 5, 6, 4, 7, 8, 9], [2, 2, 2, 2, 2, 2, 2, 2], [4, 1, 5, 1, 5, 1, 5, 3], [3, 5, 7, 2, 5, 6, 4, 6], [3, 4, 5, 6, 7, 4, 5, 6], [4, 5, 1, 3, 4, 5, 6, 7]] ...
453b791cbab5a55eb8d017528fac0e33d9a2578f
WillV9/C-E-V-PYTHON
/Ex00.py
723
3.984375
4
# Desafio 41 # Crie um programa que classifique the age category of athletes base in their Year of Birthday.. from datetime import date actual = date.today().year print('Hello There the San Mateo Swimming Association Try outs will be happening in April 2020:') print('Are you interested in Join Team ...
04f17f2d3bfc9927dc583aa676efa2b0a60b90f0
WillV9/C-E-V-PYTHON
/Ex20.py
1,057
3.921875
4
# DESAFIO 106 # Make a mini-system that use Interactive Help from Python. The user will type the COMAND and the manuel will appear # Whenever the user type the word END, the program should finish |USE COLORS| c = ('\033[m', #_0 - no collors '\033[0;20;41m', #_1 - red...
5444464543b78e950782e01b8a3ea32a9b3161e4
WillV9/C-E-V-PYTHON
/ex09.py
826
3.578125
4
# DESAFIO 91 # Crie um programa onde 4 JOGADORES jogue um DADO e tenham resultados ALEATORIOS. guarde esses resultados em um # DICIONARIO. no final coloque esse dicionario em ORDEM, Sabendo que o Vencedor tirou o maior numero no DADO from random import randint from time import sleep from operator imp...
7bb5edd591966aeb095c7e3bb7937f5480ab6a2c
C-TAM-TC1028-001-2113/tarea-1-ScarletGtz
/assignments/19Editorial/src/exercise.py
274
3.6875
4
def main(): pal = int(input("Dame el número de palabras:")) pag = pal / 475 pag2 = int(pag) if (pag - pag2) > 0: pag2 = pag2 + 1 costo = pag2 * 60 * 0.90 print("El costo de la publicación es:", costo) if __name__ == '__main__': main()
58ced433cfd7ea3f643e84ff3dab41f2e89fd026
chaitanyatyagi/Hangman
/hangman.py
1,919
3.953125
4
import string from images import IMAGES from words import choose_word def is_word_guessed(secret_word, my_word): if secret_word==my_word: return True return False def get_guessed_word(secret_word, letters_guessed): index = 0 guessed_word = "" while (index < len(secret_word)): if s...
2845ba5c494ccfd2118ccd7e29b9fc324da67a26
sudharshan912/SIMPLE-CALCULATOR
/calculator.py
5,585
3.96875
4
from tkinter import * root = Tk() root.title("MY CALCULATOR") Number = Entry(root, width=60, borderwidth=5) Number.grid(row=0, column=0, columnspan=4) Doneby = Label(root, text="Done by :R M Sudharshan", pady=30) # FUNCTIONS value = 0 # internal calculation value final = 0 # equal to value pro...
69a27e7b2d556f1ef71904db9fa687f4689d2429
mokcheungyam/learning_logs
/code/c5.py
17,299
3.609375
4
# 实例化一个小型的卷积神经网络 from keras import layers from keras import models model = model.Sequential() model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1))) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (3, 3), activation='relu')) model.add(layers.MaxPooling2D((2, 2))) model.add(...
6eadcd307e72e4e3feef8847f62db9a23333c5c5
gabriel-tavares/python-exercicios
/lista I/exercicio-05.py
906
3.546875
4
#Solicite o preo de uma mercadoria e o percentual de desconto. Exiba o valor do desconto e o preo a pagar. print 'Selecione o produto' print 'a - produto 1' print 'b - produto 2' print 'c - produto 3' selecao = raw_input('Letra do produto: ') a = 15.50 b = 9.80 c = 7.40 desconto = 7.5 if selecao ==...
40aac15a09692b7433e05d03f9bad91b31244950
viraditty09/PBO
/PBO_ 18130/tugas_3.1.py
325
3.640625
4
# input--> berfungsi untuk menerima baris input dari user dan mengembalikan dalam bentuk string # int--> berfungsi untuk menkonversi bilangan maupun string angka menjadi bilangan bulat a=int(input("masukan nilai A: ")) b=int(input("masukan nilai B: ")) a +=3 print(a) b -=10 print(b) a *=4 print(a) b **=2 print(b) ...
1131eb9d56e6756493a58aeff49faa0a4828d920
viraditty09/PBO
/PBO_ 18130/latihan_6.6.gaji.py
845
3.59375
4
#pembuatan fungsi def hitung_gaji(): nama=(input("masukan Nama anda:")) gol=(input("masukan golongan")) if gol=="1": gaji=1000000 tunjangan=250000 total=gaji+tunjangan print(f"Total gaji yang anda terima{total}") elif gol=="2": gaji=2000000 tunjangan=500000 total=gaji+tunjangan print(f"Total gaji ya...
78e8c42d123d11cf049b7395c499e9f029692e46
saalaa/lettersmith_py
/lettersmith/stringtools.py
561
3.625
4
import re def strip_html(html_str): """Remove html tags from a string.""" return re.sub('<[^<]+?>', '', html_str) def truncate(text, max_len=250, suffix="..."): """ Truncate a text string to a certain number of characters, trimming to the nearest word boundary. """ trimmed = text.strip()...
85a35906aa6aa757eba1b424d2fc7599f8d37b8d
vanticz/LeetCode
/solutions/4.Median_of_Two_Sorted_Arrays/median-of-two-sorted-arrays.py
1,306
3.546875
4
# Source : https://leetcode.com/problems/median-of-two-sorted-arrays/ # Author : Zeming (Vantic) Zhou # Date : 2016-11-28 class Solution: def findKthBiggest(self, arr1, arr2, k): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ len1 = len(arr1) ...
4fcb58b6954973f971740c5fc366d9f9f772a4c2
dstan82/tictactoe
/tictactoe.py
3,156
3.9375
4
# Tic Tac Toe Game from os import system # clear screen Function def clear(): ''' DOCSTRING: Clear screen function ''' system('clear') # draw table function def ttt_table(): ''' DOCSTRING: Function for printing the tic tac toe table ''' print(' | | ') print(f" {positions[7]...
d60644bc12491db4d49fb4380aaa8dcad67dc835
tonyklose1984/Practices01
/LEGB.py
498
3.578125
4
# x = 1 # def foo(): # x = 2 # def innerfoo(): # #x = 3 # print 'locals',x # innerfoo() # print 'enclosing function locals',x # # foo() # print 'global',x # a = 1 # def foo(): # a = 2 # print a # print a # foo() # # a = 1 # # def foo(): # a = 2 # def bar(): # pri...
17d0baf8412f7a76c543b2e54f5db1cfe3f732d8
amygdalama/dive-into-python3
/6-closures-and-generators/tests.py
523
3.5
4
import pluralize TESTS = (('cheetah', 'cheetahs'), ('fax', 'faxes'), ('waltz', 'waltzes'), ('coach', 'coaches'), ('candy', 'candies'), ('day', 'days'), ('cat', 'cats')) if __name__ == '__main__': print('singular' + '\t' + 'plural' + '\t' + 'prediction') ...
65eb0078c5d4092eca14fc5499b01633f0a02f49
dpflann/review
/epi/base_converter.py
937
3.6875
4
import math # convert string-represented number s in base b1 into a string in base b2 def base_converter(b1, s, b2): base_10 = 0 char_to_number_dict = { "0" : 0, "1" : 1, "2" : 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "A" : 10, "B" : 11, "C" : 12, "D" :13 , "E" : 14, "F" : 15 } number_to...
89e64add1e480df290afa200a6f884bc66237af9
dpflann/review
/epi/subset_zero_mod_n.py
854
3.546875
4
import itertools as it def powerset(iterable): "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" s = list(iterable) return it.chain.from_iterable(it.combinations(s, r) for r in range(len(s)+1)) def find_indicies(A): n = len(A) for i in range(0, n): mod_A = A[i] % n if mod_A == ...
f9714a9d428132b863318e63116ec306ec7397f8
dpflann/review
/epi/previous.py
255
3.609375
4
def previously_occurred(sequence): for i in range(0, len(sequence)): for j in range(0, i): if sequence[i] == sequence[j]: return sequence[i] return None print "[1,2,3,4,5,6,13,4,5] --> ", previously_occurred([1,2,3,4,5,6,13,4,5])
30fbc6eb69479af5bd4990bfa22a3f553b52ee44
dpflann/review
/epi/xy_aligned.py
657
3.65625
4
# Given a set of four points, determine if they form an xy-aligned rectangle class Point: x = None y = None def __init__(self, x, y): self.x = x self.y = y def is_xy_aligned(points): xs = set([]) ys = set([]) for p in points: xs.add(p.x) ys.add(p.y) return len(xs) == 2 and len(ys) ...
2fa73c79046cdf4e52c3ff336eded26d5f1b0489
shyams1993/shyams1993-palindrome-or-not-v2
/palindrome_v2.py
143
4
4
word = str(input("Enter word")) print(word) revword=word[::-1] print(revword) if revword == word: print("YES") else: print("NO")
8f64036db06c709e1c1e7ebd30748d3826c65292
dianedef/P3-Aidez-MacGyver
/models/item.py
561
3.71875
4
"""This module defines classes and functions related to the item in the game.""" class Item: def __init__(self, name, position): """This function initialize an Item with a name, a position and a status (catched or not)""" self.name = name self.position = position self.statu...
95a9fd1fe258db98fa3100476eb3e26cff324067
liyunfan13/MineSweeper
/solver.py
5,883
3.578125
4
from copy import deepcopy from block_structure import blockStructure # test board = [ [0, 0, 0, 0], [0, 1, 0, 1], [0, 1, 0, 1], [0, 0, 1, 0] ] chain = [] safeList = [] explored = [] mines = [] totalMines = 5 size = 16 width = len(board[0]) height = len(board) # param x: x-coordina...
b73205809e7c5ee995c02d824b268adb6e5040b9
rahulpp1234/mypythonprograms
/count_letter.py
243
4.09375
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 30 14:04:04 2020 @author: Rahul """ name=input("enter a string: ") list(name) for i in name: count1 =name.count(i) print('count of ',i,"is",count1)
2562a6d08643c1a54e9f11bd237b3a908fbcae49
shadimohagheghi/Strategic-Network-Formation
/edge_weights.py
2,698
3.578125
4
import networkx as nx # The following line initializes two empty directed graph objects G1=nx.DiGraph() G2=nx.DiGraph() # An empty undirected graph object can be initialized using the command # G=nx.Graph() G1.add_node(1) G1.add_node(2) G1.add_node(3) G1.add_node(4) G1.add_node(5) G1.add_node(6) G1.nodes() list_node...
af3577d2b776b6eb9813729dc3e0a610aab5990f
SergeyRusskih/CrackingCodingInterview
/2_linked_list/singly_linked_list.py
805
3.578125
4
from node import Node from super_list import SuperList class SinglyLinkedList(SuperList): def __init__(self, data): self.head = Node(data) self.tail = self.head def add_node(self, data): self.head.next = Node(data) self.head = self.head.next def delete_node(self, data): ...
5f87db6d46a46b1cacaa850570de463143539baa
SergeyRusskih/CrackingCodingInterview
/2_linked_list/5_sum_list.py
1,382
3.609375
4
from singly_linked_list import SinglyLinkedList def sum_list(list1, list2): next1 = list1.tail next2 = list2.tail increase_next = False result = [] while next1 or next2: val1 = 0 if next1: val1 = next1.data val2 = 0 if next2: val2 = next2.dat...
8466967dd41829b398eb0298d13781d3d255e15c
engine-it-in/Sandbox
/biblio_fm/passwordcheck.py
1,082
3.84375
4
#-*- coding:utf-8 -*- import re """ Validation data of user""" def check_pass(password): """ Password verification :param password: value of password :return: vocabulary with result and schedule of exception """ try: for i in password: length_error = len(i) < 8 ...
9335582b9e1698595c8c97639ffb232a2f69b07b
mfranklin128/interview-prep
/graphs_and_trees/dfs.py
1,586
3.90625
4
import binary_tree def make_testdata(): root = binary_tree.Node(6) root.left = binary_tree.Node(4) root.left.left = binary_tree.Node(1) root.left.left.left = binary_tree.Node(0) root.left.left.right = binary_tree.Node(3) root.right = binary_tree.Node(8) root.right.left = binary_tree.Node(6)...
4838f3dc940ee136f9b184af65698570036bd54a
mfranklin128/interview-prep
/linked_lists/remove_duplicates.py
1,035
3.6875
4
import node def remove_duplicates(head): seen = set() prev = None curr = head while curr: if curr.data not in seen: seen.add(curr.data) prev = curr else: # Remove the node. # Note: this is safe because the head can never be a dupe. ...
cc13ba8a7c37611b6c8939cc7ae9f498b18373a6
archibanerj/IITKGP-Computational-Physics-Spring-2021
/Solutions/A7/A7_Q3.py
1,876
3.625
4
import numpy as np import matplotlib.pyplot as plt import cubicspline as cs """ We use cubic spline interpolation as it gives a better estimate for x=pi/2 for both half data set and the full one, as well as gives a good fit in the plot """ A = np.loadtxt('file_1.txt') x = A[:,0] y = A[:,1] #Finding value at x = pi/2...
c68b339b61f4e094162b6e17b623307d5c584a07
archibanerj/IITKGP-Computational-Physics-Spring-2021
/Solutions/A8/A8_Q1.py
945
3.546875
4
import numpy as np def func(x): return x**4 - 2*x + 1 def trapezoidal(domain,f): h = domain[1] - domain[0] return h*(2*np.sum(f) - f[0] - f[len(f)-1])/2 def euler_maclaurin(domain,f): h = domain[1] - domain[0] term_1 = trapezoidal(domain,f) dx = 1e-5 a = domain[0] b = domain[len(domai...
f29a60d2e454b57248e072debb3b491143e2f292
archibanerj/IITKGP-Computational-Physics-Spring-2021
/Solutions/A7/A7_Q2.py
1,252
3.859375
4
import numpy as np import matplotlib.pyplot as plt def func(x,y): return np.sin(x+y) + np.cos(x+y) def interpolate(x,y,samples_x,samples_y) : #x,y - domain point at which we have to find the value of the interpolated polynomial #samples_x, samples_y - the points at which the values of original function ha...
7324d3ddcee52723748f0e0c7786b6bcc91d9884
archibanerj/IITKGP-Computational-Physics-Spring-2021
/Solutions/Practice Problem Solutions/Rk2.py
739
3.828125
4
import numpy as np import matplotlib.pyplot as plt """ 2nd order Runge Kutta method """ def f(x,t): return -x**3 + np.sin(t) #Replace this with the function you want. What to do with singularities??? def solve(x_initial, t_initial, t_stop,dt): """ x_intiial is the initial value of x at the time t_initi...
59f7f64bb8c9f5e95894905cbbc8633d45ab8b3f
Khalid-Sultan/Phase-2-Algorithms-Prep
/Leetcode/Depth-First_Search,Breadth-First_Search/2_-_Medium/130._Surrounded_Regions.py
1,261
3.71875
4
class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ for row in range(len(board)): for col in range(len(board[0])): if board[row][col]=='O': tobechanged = set() ...
2d7ed5267e90d29f2eaeae1ee057f11c68e6969e
Khalid-Sultan/Phase-2-Algorithms-Prep
/Leetcode/LinkedList/1_-_Easy/234._Palindrome_Linked_List.py
1,216
3.671875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome(self, head: ListNode) -> bool: # ls = [] # while head: # ls.append(head.val) # head= head.n...
bda1d2fb6a387ba1725a82836f414657a1e19c09
Khalid-Sultan/Phase-2-Algorithms-Prep
/Leetcode/Sorting,_Binary_Search/1_-_Easy/374._Guess_Number_Higher_or_Lower.py
482
3.53125
4
# The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 # def guess(num: int) -> int: class Solution: def guessNumber(self, n: int) -> int: l, r = 1, n while l<=r: m = l + (r-l)//2 ...
c8722d29a28f580b1d9229e10804d0886cb71418
NyxofDarkness/snakes-cafe
/snakes_cafe/snakes_cafe.py
1,557
3.828125
4
x = "*" y = x*50 print(y) print("**", " ", "Welcome to the Snakes Cafe!", " ", "**") print("**", " ", "Please see our menu below.", " ", "**") print("**") print("**", " ", "To quit anytime, type 'quit'", " ", "**") print(y) print() print("Appetizers") print("----------") myapps = ["Wings", "Cookies", "Spring Rol...
e6cccbbc99c59dd0fe07921988d8f713c057ee7a
tristandb/NaturalComputing
/A3/E3/kmeans.py
1,964
3.78125
4
""" K-Means Algorithm for clustering. Often results in the following confusion matrix: [[50 0 0] [ 0 48 14] [ 0 2 36]] """ import numpy as np import matplotlib.pyplot as plt from random import uniform from mpl_toolkits.mplot3d import Axes3D from sklearn.metrics import confusion_matrix from A3.E3.functions impor...
e71be24c38e3b70830f436871e37f56912e5c0ef
tristandb/NaturalComputing
/A1/oneplusone.py
996
3.890625
4
import numpy as np import matplotlib.pyplot as plt from random import randint from random import random as rand def new_individual(length): return [randint(0, 1) for _ in range(length)] def fitness(individual): return np.sum(individual) def flip(individual, p): return [int(not bit) if rand() < p else bit...
4f6be737533b85045b5bea6c85060f939b6b1d36
itsfelli/Jenga_Datafoundations
/question6.py
355
3.984375
4
# This program writes to a file the numbers 1 to 100, #and their squares and square roots import math def calc (): outfile=open ("calculations.txt","w") for i in range (1,101): square= i*i root= math.sqrt (i) print (i,"\t",square,"\t",format(root, ".3f"),"\n",file=outfile) ...
6121bfd8f14d4314ce2cc22640ee511ce2afd06b
chaosmail/google-codejam-16
/starter/main.py
717
3.5
4
import fs # filesystem wrapper from https://pypi.python.org/pypi/pyfs def solve(input): cols = input.split(' ') # ############### # Code goes here # ############### return input if __name__ == '__main__': IN_NAME = 'input.txt' OUT_NAME = 'output.txt' raw_input = fs.read(IN_NAME) print('====> Readin...
0fc2becbda9f616476bba434ff1af13f54da3052
dujinglong/uiAutoTestHmtt
/scripts/test01.py
701
3.65625
4
''' 目标:selenium Grid的使用 需求: 1、打开chrome浏览器 2、打开百度并搜索python关键字 3、暂停3秒 关闭浏览器 ''' # 导包 # from selenium import webdriver # from time import sleep # # 获取driver # # driver = webdriver.Chrome() # # 重点 driver获取 # cap = { # "browserName": "chrome", # "platform": "WINDOWS" # } # driver = webdriver.Remo...
55eb8b19fb35ed270d3687e9d363e641481cf117
chnlee/For_Coding_Test
/unpacking(_).py
106
3.671875
4
#using asterisk as unpacking _list = [1,2,3,4,5] print(*_list) #tuple a,b,c = [1,2,3] d = a,b,c print(d)
3ffd3cb6ffc44fd936b94a7056667c67506c9b0f
roonil-wazlib/Programming-Competition-Practice
/test.py
3,296
3.6875
4
def find_hori(crossword): hori_words = [] hori_indices = [] for index, x in enumerate(crossword): current_word = "" for y_index, y in enumerate(x): if y != "@": current_word += y if len(current_word) == 1: hori_indices.append(...
957127fd23cc629c434f86469f029831dcd69e45
G00364756/Project_Euler
/euler3.py
1,491
3.75
4
# The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? # This code was taken from a youtube video https://youtu.be/Y3n-PA3QoAE on figuring out problem3 on the euler project. # I had some difficulty with this problem and after viewing the youtube video # I l...
b6737d7af233929277294ba121ac12cc6190a5b8
KeuryLendof/PythonTkinter
/MessageBox.py
407
3.71875
4
import tkinter as tk from tkinter import messagebox mywindow = tk.Tk() mywindow.geometry("500x300") mywindow.title("Keury Lendof") mywindow.resizable(False,False) def myMessage(): messagebox.showwarning("Dangerous!", "MMG va a explotar la computadura! ") btn1 = tk.Button(mywindow, text="1st Button", command=...
5606faaf24795055840c06c2375b70d74bcddc28
ldehaas1612/Python
/hu/Opdrachten/Week 10/3. ASCII.py
206
3.875
4
def code(invoerstring): asciiStr = "" for char in invoerstring: asciiStr += chr(ord(char)+3) return asciiStr print(code(input("Geef de voornaam, beginpunt en eindpunt zonder spaties")))
fb0c8d67a63839b17c60bcb2a5c256d9ff8c2877
ldehaas1612/Python
/hu/Opdrachten/Week 10/2. random.py
460
3.625
4
from random import randint def monopolyWorp(): steen1 = 0 steen2 = 0 dubbels = 0 while steen1 == steen2: steen1 = randint(1, 6) steen2 = randint(1, 6) if(dubbels <2): print(steen1,"+",steen2,'=',steen1+steen2,("(dubbel)" if steen1 == steen2 else "")) else: ...
a764a6e47bc022266c43a94bf748abdffa661ad4
ldehaas1612/Python
/hu/Opdrachten/Week 8/3. listsplit.py
489
3.6875
4
invoer = "5-9-7-1-7-8-3-2-4-8-7-9" numbers = invoer.split('-') uitvoer = [] for number in numbers: num = int(number) uitvoer.append(num) lowest = min(uitvoer) highest = max(uitvoer) total = sum(uitvoer) uitvoerlen = len(uitvoer) uitvoer.sort() print("Gesorteerde list van ints:",uitvoer) print("Grootste getal...