blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bf5ea4d3bc5bb3bc474d9fd69ef9b8473049cd44
chenlei65368/algorithm004-05
/Week 3/id_295/LeetCode_126_295.py
2,155
3.671875
4
# 给定两个单词(beginWord 和 endWord)和一个字典 wordList,找出所有从 beginWord 到 endWord 的最短转换序列。转换需遵循如下规则: # # 每次转换只能改变一个字母。 # 转换过程中的中间单词必须是字典中的单词。 # 说明: # # 如果不存在这样的转换序列,返回一个空列表。 # 所有单词具有相同的长度。 # 所有单词只由小写字母组成。 # 字典中不存在重复的单词。 # 你可以假设 beginWord 和 endWord 是非空的,且二者不相同。 # 示例 1: # # 输入: # beginWord = "hit", # endWord = "cog", # wordList = ["...
9ded5a819aed4d2225826ef7e5d63c06603929c2
azegun/workspace_python
/python_newclass/tkiner_practice/tkiner_text.py
785
3.765625
4
from tkinter import * window = Tk() # tkinter 클래스 선언해주고 # 윈도우 기본 설정 window.title("python txt") # 윈도우 타이틀 window.geometry("640x400+650+380") # 윈도우 사이즈랑, 위치(너비 x 높으 + x좌표 + y좌표) window.resizable(False, False) # 상하, 좌우 크기 조절 여부 def btncmd(event): # text와 엔트리의 내용 출력 print("txt >>", txt.get("1.0", END)...
349edbb06ff816c0052ef1d4f1409fe08fd1ea70
mr-d-self-driving/AutonomousDriving
/traj_planner/OneRoadTestEnv/distance.py
11,310
3.84375
4
import numpy as np import math import sys class Distance: def pseudo_distance(self, point0, point1, point2, point3, veh_position): """ Computes the Pseudo compute_distance between two states. :param point0: one point before the point1 for tangents computation: it is a vector so it is array...
98b5262de9a1fe0b14c90905d591fc6cc7cb375b
yaliqin/data_structure_python
/double_link_list.py
4,297
3.515625
4
class Node(): def __init__(self, value = None, pre= None, next= None): self.value, self.pre, self.next = value, pre, next class CircularDoublelinedList(): def __init__(self,max_size = None): node = Node() node.next, node.pre = node, node self.root = node self.length = 0 ...
8cbe3abf33d07c49071ebdd15804bce9d9e2ef33
frclasso/revisao_Python_modulo1
/cap09-strings/26_replace_method.py
600
4.375
4
#!/usr/bin/python3 """The replace() method returns a copy of the string in which the occurrences of old have been replaced with new, optionally restricting the number of replacements to max. Syntax str.replace(old, new[, max]) """ str = "this is string example....wow!!! this is really string" print (str.replace("is",...
32a366df1910962fb9cbdea8ff243141ab09a95c
HabibaMostafa/SkinDetector
/SkinDetectionAglorithms/algorithm-2.py
741
3.53125
4
################################## Median Filtering Algorithm ############################## from PIL import Image import statistics import sys # open image and load it as a pixel map img = Image.open(sys.argv[1]).convert('YCbCr') pixelMap = img.load() # convert image to RGB segmentedImg = Image.open(sys.argv[1]).co...
87de0564cf4646beb5aa20c8a08b16eb793aad6b
smartinsert/CodingProblem
/amazon/max_of_min_altitudes.py
1,660
3.921875
4
""" Given a matrix with r rows and c columns, find the maximum score of a path starting at [0, 0] and ending at [r-1, c-1]. The score of a path is the minimum value in that path. For example, the score of the path 8 → 4 → 5 → 9 is 4. Don't include the first or final entry. You can only move either down or right at any ...
26ac5e4834438e2eccd8f68f25e8167a5c1412e2
Coccoliso/mi_primer_programa
/adivina_numero.py
338
4
4
number_to_guess = int(input("Jugador 1: indica el numero a adivinar: ")) user_number = int(input('Jugador 2: adivina el numero: ')) while number_to_guess != user_number: if number_to_guess == user_number: print('Has ganado') else: user_number = int(input('Introduzca otro numero: ')) print(...
1fcfab8b2a2651243c30e91487f459809e315e05
CharlotteGenius/Machine-Learning
/Machine Learning A-Z Template Folder/Part 6 - Reinforcement Learning/Section 32 - Upper Confidence Bound (UCB)/UCB/upper_confidence_bound.py
2,263
3.796875
4
# Upper Confidence Bound # UCB # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Ads_CTR_Optimisation.csv') '''In the file, they're series of 1s and 0s showing 10000 users reacts to 10 different ads''' # Implementing UCB i...
a1108cbe2eb848d23aaed7830178cc9569b784df
fcendra/IoTProject
/Day 4/Ping_Pong_Program/echo_client.py
733
3.765625
4
import socket # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Connect the socket to the port where the server is listening # 'localhost' means this computer # 12345 is the port number server_address = ('localhost', 12345) print('connecting to %s port %s' % server_address) sock.con...
c4ae48ca5a4df6ba9f76c1d1de5e1f88b5a22bb0
HIPERFIT/hipermark
/test_students_t
2,578
3.875
4
#!/usr/bin/env python from scipy.stats import t # Student's T distribution import math CONFIDENCE_LEVEL = 0.95 def get_nth_moment (result_times, n): """ Calculates the nth moment of a list. Keyword values: result_times -- list of result times (floats) n -- integer describing that statistical mo...
c7f6e0e95f519d918ad1b93d930ac503bc443b6f
GuuMee/ExercisesTasksPython
/1 Basics/16_area_volume.py
595
4.59375
5
from math import pi """ Write a program that begins by reading a radius, r, from the user. The program will continue by computing and displaying the area of a circle with radius r and the volume of a sphere with radius r. Use the pi constant in the math module in your calculations. """ def area_and_volume(): r = ...
11abd751cdd0d41cb324bc80d7584d6f1e9fea34
rafasapiens/learning
/Find e Replace.py
1,207
3.515625
4
from tkinter import * top = Tk() top.title('Localizar & Substituir') top.geometry('800x800') Label(top,text="Localizar:").grid(row=0, column=0, sticky='e') Entry(top).grid(row=0,column=1,padx=2,pady=2,sticky='we',columnspan=9) Label(top, text="Substituir:").grid(row=1, column=0, sticky='e') Entry(top).grid(row...
9f5b592d0485e3a7b2825c5280083bd93fa8f026
DOGEE7/pythonLeetCode
/question11.py
1,477
3.765625
4
''' 盛水最多问题: 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器,且 n 的值至少为 2。 示例: 输入: [1,8,6,2,5,4,8,3,7] 输出: 49 ''' class Solution: def maxArea(self, height): ''' :param height: List[int] :return: int ...
fb3ecce220a1fed6969ffea2a86cd9f35fab9cc1
Codyh3/NeuralNetworkLib
/neural_network_lib/neural_nets.py
16,694
4
4
import numpy as np from neural_network_lib.loss_models import loss_models from neural_network_lib.layers import nn_layers __version__ = '0.0.0' class NeuralNetwork: """ A simple neural net object. """ def __init__(self): self.layers = [] def add_layer(self, layer=None, layer_type='De...
793c0972c7984d212246e9eb8a55cb15a5180e58
whosdman2005/python_train
/numerals.py
1,419
4.46875
4
# Arithmetic Operators: # Addition 3 + 2 # Subtraction 3 - 2 # Multiplication 3 * 2 # Division 3 / 2 # Floor Division 3 // 2 # Exponent 3 ** 2 # Modulus 3 % 2 # Comparisons: # Equal: 3 == 2 # Not Equa...
acdccf2ba5662c9efbb5d90e96748b910a86b19b
pvr30/Python-Tutorial
/Files In Python/Quize Exercise.py
868
3.96875
4
""" sample `questions.txt` file: 1+1=2 2+2=4 8-4=4 task description: - read from `questions.txt` - for each question, print out the question and and wait for the user's answer for example, for the first question, print out: `1+1=` - after the user answers all the questions, calculate her score and write it to the `...
47b9fdfa53da30171d6e661f57d6333e681ffe6d
ClaytonStudent/leetcode-
/LeetCodePython/110_Balanced_Binary_Tree.py
1,202
3.75
4
# source: https://leetcode.com/problems/balanced-binary-tree/discuss/362017/Python3-recursively # analysis: base case 是左右子树的高度相差不超过1,且左右子树同样是满足 class Solution(object): def isBalanced(self, root): """ :type root: TreeNode :rtype: bool """ if root == None: return T...
979a4b4bf63712ccfbc9dd7dd80586dc37ef1e96
wan-catherine/Leetcode
/problems/N529_Minesweeper.py
1,397
3.609375
4
class Solution(object): def updateBoard(self, board, click): """ :type board: List[List[str]] :type click: List[int] :rtype: List[List[str]] """ if board[click[0]][click[1]] == 'M': board[click[0]][click[1]] = 'X' return board rows, co...
25e59f08fe32c37cb56e5f1b91b6df4f240f84d1
m24murray/rpi-scripts
/ledButton.py
705
3.75
4
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) blinkCount = 100 count = 0 LEDPin = 22 buttonPin = 5 # Setup the pin the LED is connected to GPIO.setup(LEDPin, GPIO.OUT) GPIO.setup(buttonPin, GPIO.IN, pull_up_down = GPIO.PUD_UP) buttonPress = True ledState = False try: while count < blinkCou...
765f45f726499adc1626b5cd14a8836b4a2cc20d
kapil87/LeetCode
/inorderIterative.py
1,119
3.890625
4
def inorderIterative(tree): stack, result = [], [] while stack or tree: if tree: stack.apppend(tree) #Go to the left subtree tree = tree.left else: #Go up in the tree tree = stack.pop() result.append(tree.data) ...
47ba45402622e0e7abc3ea18a7c078d164e47589
rjshaver/axfr-tools
/lib/comparisons.py
2,022
3.53125
4
import os class Compare(object): ''' This class is used for comparisons ''' def __init__(self): pass def domains(self): ''' SQL style Right join comparison Consider domains previously scanned as table scanned Consider list of domains to scan as table todo ...
abfa37257b79f52046ae1f7b26e0b80cc2a5da6d
Gamer153/Console3DGame
/world.py
808
3.5625
4
from object import Object class World: objects = list() # type: list [Object] def __init__(self) -> None: pass def add_object(self, object): self.objects.append(object) def add_objects(self, *objects): for obj in objects: self.add_object(obj) def remove_obje...
b758e6631c2b6999d10d5ce7efa5320bf94b4192
arunkumar1722/CharlotteBank---Py
/main.py
1,216
4.0625
4
# Main class to demonstrate Bank Account from bankaccount.checkingbankaccount import CheckingBankAccount from bankaccount.savingsbankaccount import SavingsBankAccount import random class Main: # Checking Account checking_account = CheckingBankAccount(str(random.randrange(0,10**10)), 'Alejandro Lopez-Perez') prin...
88a0e1728474ea0bb7e1325c72dfdc05bcfe9c2b
JasirMJ/Trail-1
/python_pgms/random_task4.py
496
3.71875
4
#from random import * #print(randint(1,7)) import random skip=random.randint(1,7) print("python chooses",skip, "randomly") if skip==1: print("sunday") elif skip==2: print("monday") elif skip==3: print("tuesday") elif skip==4: print("wed") elif skip==5: print("thu") elif skip==6: ...
aecb48a6b829dda19bbc30f479c0ed5fd625e1ba
c0r4line/Practicas-y-entregas
/desafios/desafio1-3.py
319
4.125
4
#escribir una función que imprima sus argumentos agregando de qué tipo son. def imprimo(*args): """ Esta función imprime los argumentos y sus tipos""" for valor in args: print(f"{valor} es de tipo {type(valor)}") imprimo(1) print("-"*30) imprimo(2, "hola") print("-"*30) imprimo([1,2], "hola", 3.2)
5aa172e54c30dd8a16f59044c315a4c46e95ad38
ortalglatt/Intro-Python-ex10
/asteroid.py
2,291
4.25
4
import math class Asteroid: """ Class of Asteroid objects, contains the coordinates of the asteroid, the speed and the asteroid's size. This class contains functions that return an information about the asteroid, and functions that change the asteroid's attributes if needed. """ def __ini...
11a01fab11d7c2b08f50853557eda752c50681bf
player1537-playground/opendata
/ncdc.noaa.gov/qclcd/analysis/cluster.py
3,061
3.578125
4
#!/usr/bin/python from __future__ import division import sys import scipy.io import collections import sklearn.decomposition import numpy as np def cluster(X=None, U=None, V=None, k=None): """Determines clusters of X based on the NMF results with the given rank. X should an NxM matrix, where each column rep...
1c719f031025893960a94c504e5fe8d980da36a3
nsa18685/my_first_python
/7장/7.14.py
270
3.53125
4
def main(): a = A() '''a.print()''' print(a.getS()) class A: def __init__(self, newS = "환영합니다."): self.__s = newS '''def print(self): print(self.__s)''' def getS(self): return self.__s main()
5ae0a8d688d64fae9b82abd14998f0d441500a1e
rllabmcgill/rlcourse-march-24-h-aboutalebi
/GAMBLER/main.py
1,891
3.765625
4
from state import * # import state def main(): print("Goal: ") n=101 p=0.4 value_iteration(n,p) # implements the value_iteration method def value_iteration(n,p): for i in range(n): if(i==n-1): s = state(1, i) state.Array_States[i] = s continue # ...
12ce0fd989f8f65e68b49f47b861db7c712c7131
somnathbanerjee2020/PythonCode
/pySpark/LoadFile.py
498
4.03125
4
# import pySpark as ps # pandas is a dataframe library import numpy as np import pandas as pd import os #convert list to DF #l1={1,2,3,4,5,6} #df1=pd.DataFrame([l1]) #print(df1) # creating a pandas dataframe using a test csv os.chdir("c:/Users/banerso/Documents/GitHub/PythonCode/pySpark/") f=open("fifa18.csv","r") d...
39acb5a7a47c994ff170eeb77319b1c1e36acc94
EduardoAirton/Python-Calculator
/calculadora.py
1,324
4.0625
4
# Programa para realizar operações dadas pelo usuario # Eduardo Airton import os sair = "" os.system('cls') #Limpa o prompt while sair.lower() != "nao": try: numero1 = float(input("Digite o primeiro numero: ")) numero2 = float(input("Digite o segundo numero: ")) except ValueError:...
cbe2b38f2c025982222c992df88a641df1bf6e02
gongtian1234/-offer
/数据结构与算法进阶/14 数学表达式.py
634
3.96875
4
''' 题目:数学表达式。给定a和b两个数,a<=b,把b以a乘2或者加1的最快的方式表示出来。 思路:主要分析b>2a以及b%2=0是否成立, 当b<2a时,只能通过加1达到b,当b为奇数时通过加减1使b变为偶数 ''' def solution(a, b): # 先设置一个base,即迭代的结束条件 if a==b: return str(a) if b<2*a: return '(' + solution(a, b-1) + '+1)' if b%2==1: return '(' + solution(a, b-1) + ...
77b7949501370090f7ab8a3a460eb47a95cd6be4
devsunb/study-python
/tools/len4dic.py
258
4
4
import string for a in string.ascii_lowercase: print(a) for b in string.ascii_lowercase: print(a+b) for c in string.ascii_lowercase: print(a+b+c) for d in string.ascii_lowercase: print(a+b+c+d)
5dfe0550840cce94b094341a6d439e71809501aa
Siwani102/money-manager-using-tkinter-for-beginner
/money manager.py
4,888
3.84375
4
from tkinter import * import tkinter.messagebox messagebox.showinfo("Welcome","Welcome to money manager\nEnter you username and password\nto login.") amount=10000 total="" def Submit(): if(e1.get()=='money manager'): print(e1.get()) if(e2.get()=='1234'): print(e2.get()) ...
7bda1564b73adeec2c320f433866cbe2b9412947
FelixDesrochers/MasterMind
/functions.py
2,583
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #define decorator who can verify the type of the variable of a function def control_types(*a_args, **a_kwargs): """On attend en paramètres du décorateur les types souhaités. On accepte une liste de paramètres indéterminés, étant donné que notre fonction définie...
3ce29cc9ac5c7a19512133af7c18173e84972ab1
aimclee/javascript-2019-
/advanced_javascript/1.class/inheritance_super/inheritance_super.py
499
3.640625
4
class Animal: def __init__(self, leg): self.leg = leg def printAnimal(self): print(self.name + "은 " + str(self.leg) + "개의 다리를 가진다") class Lion(Animal): def __init__(self, name, leg): super().__init__(leg) self.name = name # self는 전달된 객체 # self.name은 인스턴스...
5ac1d8d71ff9cd055e4ed1792ec0a5a9754d3664
pyjune/ssa2019
/0218/dec2bin.py
241
3.703125
4
a = 14 for i in range(7, -1, -1): if(a&(1<<i) == 0): print(0, end='') else: print(1, end='') print() for i in range(7, -1, -1): if (a & (1 << i) != 0): print(1, end='') else: print(0, end='')
cedcc682dec6d56e7792a9e5b23fbfc5a04e391b
m-book/atcoder
/mitsui_sumitomo_2019/november_30.py
129
3.5
4
today = input() tomorrow = list(map(lambda x: int(x), input().split(" "))) if tomorrow[1] == 1: print(1) else: print(0)
829aa8d9c64da78643695ca982ece59f1f9e6821
albertbko/aoc
/2020/12.py
3,347
3.640625
4
import os path = os.path.abspath(os.path.dirname(__file__)) inputfile = open(path + '\\12input.txt', 'r') input = inputfile.read().splitlines() # Part 1 x, y = 0, 0 location =[x, y] heading = 'E' def move(location, direction, distance): if (direction == 'N'): location[1] += distance elif (direction ...
8dcfdf4b7b0f7d57fedc306251e4d185aad6b0f8
muhdazmitomirin/python-training
/tuple_examples.py
271
3.703125
4
# TUPLE IS IMMUTABLE # FASTER THAN LIST tuple_a = ('a', 'b', 'c','a') tuple_b = tuple() print(bool(tuple_a)) print(bool(tuple_b)) tuple_c = (1, 2, 3) tuple_d = 1 print(tuple_c) print(tuple_d) # TUPLE OPERATIONS print(tuple_a.count('a')) print(tuple_c.index(1))
899642f2dd4465473cfff75b92df302b321e30af
mpencegithub/python
/pyds/8_4.py
253
3.75
4
fhandle=open('romeo.txt', 'r') words=list() for lines in fhandle : line=lines.rstrip() pieces=line.split() for piece in pieces : if piece not in words : words.append(piece) words.sort() print(words)
b89aa451e02649d7937c1d514909e84263d8e6fc
Silvarion/python
/learning/code_samples/url_to_file.py
855
3.609375
4
#!/usr/bin/env python from __future__ import print_function from argparse import ArgumentParser import requests parser = ArgumentParser(description="Dumps an URL content into a text file") parser.add_argument('-u', '--url', type=str, dest='url', help='url to dump to file') parser.add_argument('-f', '--file', type=str...
8b3c4713f2f3e1bdc002a80fac0b7d02ccc83982
mupengbo/algorithm
/quicksort.py
471
3.984375
4
# quick sort algorithm implemented in python def quicksort(nums): if len(nums) <= 0: return [] pivot = nums[0] less, greater = [], [] for i in nums[1:]: if i <= pivot: less.append(i) else: greater.append(i) return quicksort(less) + [pivot] + quickso...
6a0392ddcf8a0daeb561b2a03e3d88a55df3d1d9
JRBenson01/FootBall_Arcade
/engineDev3.py
34,843
3.796875
4
""" Designer: Justin Benson Version: 3 Description: Version 3 adds abilities to set object variables via dictionary instead of using individual functions to set each variable. In version 3 colors are now objects instead of individual variables. """ print("+++Starting up+++") ...
48c6dabb42d6cfccc485facf558dfbbb277f284d
t2025/Advance-Python-Programming
/Python GUI Programming/login.py
1,005
3.828125
4
from tkinter import * import tkinter as ttk import pymysql root=Tk() root.geometry("260x110") root.title("Login form") db=pymysql.connect("localhost","root","root","Login") cursor=db.cursor() def insert(): try: sql="select username,password from login_details where username='%s' and password='%s'" %(e1.get(...
d6a878fd70851e059c07a5603dc7e2ebe95e4693
ashish-5209/Array
/stockBuySell.py
211
3.515625
4
def Stock(arr, n): profit = 0 for i in range(1, n): if arr[i] > arr[i-1]: profit += (arr[i] - arr[i-1]) return profit arr = [1,5,3,8,12] print(Stock(arr, len(arr)))
71ef2087d31e6ec6b1c31ecceca97096ed53746c
Tammon23/Daily-Coding-Problems
/problems/problem2.py
1,436
3.921875
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Uber. Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], ...
f41936c6cd9c72b58814d6e54de0b7e81efa70db
ProjektOsmium/All-Algorithms
/counting_sort/Python/counting_sort.py
1,158
4.53125
5
def counting_sort(arr, digit: int, radix=10): """ Fuction to sort using Counting Sort <https://en.wikipedia.org/wiki/Counting_sort>. :param arr: A list of number to sort :param digit: The digit we want to sort by :param radix: The base of the number system :return result: The sorted...
ea017b69ab1b5359bd80dd34a75c04a2abb8f780
Dylan-Lebedin/Computer-Science-1
/Labs/dna.py
5,633
4.03125
4
""" file: dna.py author: Dylan Lebedin description: Implement the required functions from the lab document """ from linked_code import concatenate from linked_code import LinkNode import linked_code from linked_code import length_iter def convert_to_nodes(DNA): """ Convert a string to a linked-no...
b510f7fa30efe4175e55390c5dcd57b3e37a94b7
Amsterdam/schoonmonitor
/cmsdownloader/json2geojson.py
3,867
3.65625
4
import json def flatten_json(y): """ Flatten nested json to ['key.subkey.subsubkey'] values https://towardsdatascience.com/flattening-json-objects-in-python-f5343c794b10 """ out = {} def flatten(x, name=''): if type(x) is dict: for a in x: flatten(x...
65d01fcbb87d2e9837869811926930a33a00afdb
joe-bq/dynamicProgramming
/python/LearnPythonTheHardWay/Exceptions/Asserts/AssertDemo.py
581
3.75
4
''' Created on 2012-11-17 @author: Administrator file: AssertDemo.py descripition: AssertDemo.py will demonstrate the use of the assert in python, assertion is one of the following. ''' def demo_assert(): x = (1, 2, 3) assert len(x) < 5, "the length of the list should be less than 3" def demo_as...
0a994433382dd9eba32a706ce0597b57c3981b9f
apprentice1985/python
/Thread3rd.py
1,093
4.0625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- #Threading with locks - Chapter 21 -locks.py import threading, time #Initialize a simple variable b = 50 #And a lock object l = threading.Lock() def threadcode(): """This is run in the created threads """ global b print "Thread %s invoked" %threading.curren...
8f3d12275d0228bc3692424906aab7d2f7dd3a56
matthewru/PythonLearning
/CTY_Python_Introduction/Unit 7/Activity 7-3_mru1350102.py
702
4.5625
5
#This part sets the count values to the default setting of 1. outer_count = 1 inner_count = 1 #Setting up the loop to nest the inner loop. for outer_count in range (1, 3): for inner_count in range (1, 4): print("Outer loop iteration %d and inner loop iteration %d" % (outer_count, inner_count)) #While loop...
010d47021b6c792550c80048755083e9212cd007
berrycore/PythonTutorial
/02.Variable/ex3_convert_data_type.py
611
4
4
# convert data type (str) a = input("input 1st number : ") # if a = "10" b = input("input 2nd number : ") # if b = "20" print(a + b) # "1020" # convert data type (str -> int) a = int(input("input 1st number : ")) # if a = 10 b = int(input("input 2nd number : ")) # if b = 20 print(a + b) ...
0cfa5f5baf7e9d13a88003ace20a109e96523525
IvarK/surrortg-sdk
/games/gps_car/area/game_areas.py
1,757
3.640625
4
"""" Methods in these classes should have access to the motor object in order to change the speed of the robot. Individual instances of this class need a 'label' attribute. """ class GameArea: """ Attributes: -id -label -coordinates -Props """ def __init__(self, data)...
ba2c0d6f2bc0d83a73192f2dd51f78dd49b3ec1f
rv404674/Learn-Python3-the-Hard-Way
/ch3.py
435
3.875
4
cars = 100 space_in_cars = 100 passengers = 90 drivers = 20 cars_not_driven = cars-drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_cars average_passengers_per_car = passengers / cars_driven print("There are", cars , "cars available") print("There are only", drivers, "drivers available.") print(...
371d426c9ecdc68439f5cbca3f01dd5d32b33881
yujinee/scimat2
/science/AlternatingCurrent/power-energy-of-LCRcircuit/power-energy-of-LCRcircuit.py
1,686
3.59375
4
import random import math # Suppose the inital charge on the capacitor in an LC circuit with 30 muF capacitor and 27 mH inductor is 6 mC. What is the total energy stored in the circuit initially? What is the total energy at later time? # A series LCR circuit with R = 20 ohm, L = 1.5 H and C = 35 muF is connected to a ...
a52b7d09afe3f0283c774672da6694316706dec7
noahcoomer/leetcode
/python/maxDepth.py
1,175
3.71875
4
# 10/25/2019 # 104. Maximum Depth of Binary Tree - https://leetcode.com/problems/maximum-depth-of-binary-tree/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque from he...
d23aa787a8183ffd581cc10cabb54361a3b7a522
leejeyeol/LJY_DS_and_algorithm
/treasure_password.py
921
3.59375
4
# https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRUN9KfZ8DFAUo#none import utils def solution(test_case, N, K, question): answer_list = [] num_rotation = len_num = int(N/4) dou_question = question + question for i in range(num_rotation): for j in range(4): ...
81cf1338d95b73dbcd01ff045f5a74b0eacc190a
SohamRoyNoel/PythonNew
/StringMatch.py
893
4.03125
4
parrot = "parrot is a sucker" print(parrot) print(parrot[1]) print(parrot[0]) print(parrot[6]) # space print(parrot[-1]) print(parrot[0:2]) print(parrot[0:8]) print(parrot[3:9]) print(parrot[-2:0]) # nothing comes after the last letter print(parrot[:6]) print(parrot[6:]) print(parrot[-4:-1]) # starts @ -1 (r) & runs...
018054d481af35902ec9d361681329887bbad86e
kevinconway/chattools
/chattools/emoticon.py
2,250
3.609375
4
"""Tools for extracting emoticon data.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import re MAX_EMOTICON_LENGTH = 15 EMOTICON_REGEX = re.compile( r'\((\w{{1,{0}}})\)'.format(MAX_EMOTICON_LENGTH), re....
bc0a58a95f6b68880a9331c021b9681275cd205d
sudeep0901/python
/backup/11.countvertorizer.py
1,565
3.859375
4
from sklearn.feature_extraction.text import CountVectorizer import pandas as pd vectorizor = CountVectorizer() sample_text = ["One of the most basic ways we can numerically represent words " "is through the one-hot encoding method (also sometimes called " "count vectorizing)."] vectorizo...
ce42c6eafd1372dbe521a66fb7ff3b9cf47c4c06
ayesha53/ayeshajawaid
/q33.py
244
4.34375
4
#.Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them first_name=input("Enter your first name: ") last_name=input("Enter your last name: ") print(last_name,first_name)
7cdabcc690729f07df0ae2a929f76d090921f4b3
chadadavis/junk
/python/insertion_sort.py
284
3.75
4
#!/usr/bin/python def insertion_sort(A): for j in range(1, len(A)): key = A[j] i = j - 1 while i >= 0 and A[i] > key: A[i + 1] = A[i] i = i - 1 A[i + 1] = key # insertion_sort # Test #A = [4,1,3,3,65,1,66,352,6234,2,3,55,62,6,346,622,3] #insertion_sort(A) #print A
1d978ec139f4901750b6c234c49d4217a2842d47
carv-silva/cursoemvideo-python
/Mundo02/exercsMundo02/ex071.py
1,075
4.1875
4
'''Crie um programa que simule o funcionamento de um caixa eletronico. No inicio,pergunte ao usuario qual sera o valor a ser sacado(numero inteiro) e o programa vai informar quantas celulas de cada valor serao entregues obs: considere que o caixa possui cedulas de 50, 20, 10 e 1 .''' print('=' * 30) print(' BANCO ...
2e9d004fcdd1285ebb4eca7bab63a99f15a8f5a5
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH04/EX4.22.py
864
4.375
4
# 4.22 (Geometry: point in a circle?) Write a program that prompts the user to enter a # point (x, y) and checks whether the point is within the circle centered at (0, 0) with # radius 10. For example, (4, 5) is inside the circle and (9, 9) is outside the circle, as # shown in Figure 4.8a. # (Hint: A point is in the ci...
969890c389f100e4e97aa4fcc2ee98c0c03ddf30
Pebaz/coding-problems
/lambda/pool.py
3,002
3.984375
4
""" The NumberPool is a lowest available number checkout system. When a new instance is created, it logically contains all counting numbers 1-Long.MAX_VALUE. This means a call to checkout immediately after instantiation will return 1. The next checkout will return 2, and so on. When a number is checked back into the po...
78210c12ac907849c4fa410fa639bb829cf9b683
pabsilop/Curso-2020
/Sistemas de Gestion/EjercicioListaPalabras/Ejercicio.py
431
4.125
4
print("Indique las palabras que quiere introducir en la lista cuando quiera parar de meter palabras escriba FIN ") listaPalabras=[] palabraDada="" while palabraDada!="FIN": palabraDada=input("Di una palabra: ") listaPalabras.append(palabraDada) print("Orden alfabético") listaPalabras.sort(key = str.lower) prin...
a1852f0f642df8f806b2baab0e79e5d3da6a5133
clementeqp/Analisis_de_Datos_Python_2021
/part03-e01_column_comparison/src/column_comparison.py
685
3.921875
4
#!/usr/bin/env python3 import numpy as np def column_comparison(a): result=a[a[:,1] > a[:,-2]] return result def main(): a=np.array([[8, 9, 3, 8, 8], [0, 5, 3, 9, 9], [5, 7, 6, 0, 4], [7, 8, 1, 6, 2], ...
1d0222869a5c57a09fa13a2e3ffdc69c43bcc215
r-mishra2126/IT475
/py40.py
396
3.703125
4
class Employee: #initialising def __init__(self): print("employee created") #Calling destructor def __del__(self): print("Destructor called") def Create_obj(): print("Making objects..") obj = Employee() print("function end..") return obj print("Calling C...
a58b309891557f7a324e0d6a3ddecc00dc6d61a0
Aasthaengg/IBMdataset
/Python_codes/p03285/s795617551.py
149
3.5
4
N = int(input()) answer="No" for i in range(26): for j in range(16): total = 4*i + 7*j if total==N: answer="Yes" print(answer)
28bb6a3ba7d65c72cdad582d53f4bc0cff708289
trizdreaming/prog_practice_week3
/practice1.py
199
3.53125
4
def print_name(name, famname): your_info = 'your name : \n' + name + '\n'+ 'he is from ' + famname + ' family' # print your_info return your_info result = print_name('bruce', 'lee') print result
9596d1b8bd8525edd370acb5b0208bfa61c7d1d1
Katiedaisey/Projects
/Solutions/fibonacci_sequence.py
423
4.46875
4
# **Fibonacci Sequence** - # Enter a number and have the program generate the # Fibonacci sequence to that number or to the Nth number. num = int(raw_input('Enter a number: ')) count = 2 fib = [1,1] if num == 1: fib [1] if num == 2: fib = [1,1] count = count + 1 elif num > 2: while count < num: fib.append(int...
3d0aa9af2a96fc461ca8750ffa2150b1d681e474
mritunjayaverma/tathastu_week_of_code
/day1/program5.py
471
3.9375
4
rp1=int(input("enter run score by player 1")) rp2=int(input("enter run score by player 2")) rp3=int(input("enter run score by player 3")) str1=rp1*100/60 str2=rp2*100/60 str3=rp3*100/60 print("number of maximum sixes by player 1:",str1) print("number of maximum sixes by player 2:",str2) print("number of maximum sixes b...
740dea53af4f680e2118ce4c79f700bd5f35da8f
yuzujoe/python-practice
/data-structure/zip.py
190
3.78125
4
days = ['Mon', 'Tue', 'Wed'] fruits = ["apple", "banana", "orange"] drinks = ['coffee', 'tea', 'beer'] for days, fruits, drinks in zip(days, fruits, drinks): print(days, fruits, drinks)
1722c2425c9418f2a5aed7d431950b1c3b0fa3d9
HilbertSpaces/pyAlgorithms
/SortSearch/mergeSort.py
608
3.53125
4
def merge(A,p,q,r): n1=q-p n2=r-q-1 infinity=10000000 L=[] R=[] for i in range(n1+1): L.append(A[p+i]) for j in range(n2+1): R.append(A[q+j+1]) L.append(infinity) R.append(infinity) k=p i=0 j=0 while k<=r: if L[i]<=R[j]: A[k]=L[i] ...
d740c459284f590d024e4effc5c0f804a4b22ac5
mbwreath/blackjack
/blackjack/deck.py
1,433
3.625
4
from blackjack.card import Card, ranks, suits from blackjack.player_hand import Player_hand import random class Deck: """a deck of cards Responsibilites: *holds collection of cards *new deck shoul have all 52 cards *allow others to draw cards *shuffles cards or re-shuffle *report its curr...
24bcbee55cece6182a055d111872129292aacc35
Y81Kakaei/Coursera_Learn_to_Program_exercises
/assignment1_time_difference.py
3,746
4.5
4
def seconds_difference(time_1, time_2): """ (number, number) -> number Return the number of seconds later that a time in seconds time_2 is than a time in seconds time_1. >>> seconds_difference(1800.0, 3600.0) 1800.0 >>> seconds_difference(3600.0, 1800.0) -1800.0 >>> seconds_difference(...
fd326c98608ffa1bf02fb52d33bf20ab45c3de8f
ConnerBluck/ttweet-Application
/ttweetcl.py
10,052
3.71875
4
import argparse import errno import json # JSON library is used to cleanly hold info sent between client/server import os import re import socket import sys import time # Function to handle the subscribe command # command_string -> the command + the hashtag # subscribe command looks like > subscribe <hashtag> # Retu...
9fde1f2fc7d4fc3b13fde60223cbf28964def95f
swbuild1988/leetcode
/0021. 合并两个有序链表/main.py
1,132
3.90625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ prenode = L...
7e341407e4464ae3214b4ad32bfee1570adeaaa7
ishantk/GW2019PDec
/Session10D.py
606
3.625
4
cart = [ ["Shoe", "Shirt", "Watch"], # 0 [300, 400, 900], # 1 [3.5, 4.4, 5.0] # 2 ] print(cart) print(len(cart)) #3 print(cart[0]) # ["Shoe", "Shirt", "Watch"] print(len(cart[0])) # 3 print(cart[1][2]) # 900 print(cart[1][0:2...
f97d5a1ff64cd719805992160bdb7208a538e71d
sander777/struct_n_algs_lab_1
/lab4.py
1,598
3.765625
4
import random class Set: def __init__(self, *arr): self.set = [] for i in arr: is_in = False for j in self.set: if i == j: is_in = True if not is_in: self.set.append(i) def add(self, *el): for i in ...
3a666b444b1c6035bd928ce94a30ff8c90ff91fa
ay701/Coding_Challenges
/number/powerOfTwo.py
120
3.53125
4
# Use anonymous function def power_of_two(n): return list(map(lambda x: x**2, range(n))) print(power_of_two(5))
b490e9de3e7d3b4f1e626b2363f3c1d40f1fe617
IsFilimonov/Interviews
/LeetCode/Python/001-Two_Sum.py
3,344
3.734375
4
import timeit from typing import List import random class Solution(object): def __init__(self, list_length: tuple, list_values: tuple, int_value: tuple) -> None: # PEP-0484 self.nums = [random.randint(*list_values) for _ in range(random.randint(*list_length))] self.target = random.randint(*int_va...
340a932ecf20f50994eafa90a3bb0cc095a3bf62
jhonberly/upeu-proyecto
/disting-lenguaje/AreaTriangulo.py
268
3.71875
4
#variable de entrada y otros print("ejercicio 01:Area Triangulo") #datos de entrada ingresados por dispositivo de entrada b=int(input("ingrese la base:")) h=int(input("ingrese la altura:")) #proceso area=(b*h)/2 #datos de salida print("el area de triangulo es:",area)
3666b6dc33401c834cad5a6717afb096e885ca07
wangpeibao/leetcode-python
/easy/easy1496.py
1,233
3.84375
4
""" 1496. 判断路径是否相交 给你一个字符串 path,其中 path[i] 的值可以是 'N'、'S'、'E' 或者 'W',分别表示向北、向南、向东、向西移动一个单位。 机器人从二维平面上的原点 (0, 0) 处开始出发,按 path 所指示的路径行走。 如果路径在任何位置上出现相交的情况,也就是走到之前已经走过的位置,请返回 True ;否则,返回 False 。 示例 1: 输入:path = "NES" 输出:false 解释:该路径没有在任何位置相交。 示例 2: 输入:path = "NESWW" 输出:true 解释:该路径经过原点两次。 提示: 1 <= path.length <= 10^4 path 仅...
60ee1368f9b1a4e2a0664d42d30f743caa80b7e4
mbesson/file_loss
/utilities.py
883
3.71875
4
# Utilities for functions in file file_loss.py from itertools import (cycle, islice, combinations, chain) from operator import mul from functools import reduce def window(seq, n): """ Implement a sliding window of size n for a sequence seq. Args: seq (list): The sequence we want to apply the s...
48463ea521261eb0078a35d9138d5ea1ed10a8ee
lihalyf/Python
/All_Subsets(Lintcode_17).py
1,235
3.828125
4
#version 1 (0, 1 select or not) import copy def subsets(nums): result = [] if nums == None: return result subset = [] nums = sorted(nums) dfs(nums, 0, subset, result) return result def dfs(num_list, index, subset, result): # 1. recursion define # 2. recursion out if index ...
99326c3594cd347e1d83347ce72b76fa2df0281c
ankitsingh03/code-python
/geeksforgeek/list/print all even numbers in a range.py
229
3.890625
4
start = int(input("enter starting point: ")) end = int(input("enter ending point: ")) # print([i for i in range(start,end+1) if i % 2 == 0]) for i in filter(lambda a: a % 2 == 0, range(start, end+1)): print(f"{i},", end=" ")
388aca4601812402861e786393a60f086344ece2
zoog15/python_practice
/시간순삭 파이썬/0712 7장 연습문제4 랜덤도형그리기.py
700
3.921875
4
import turtle import random t = turtle.Turtle() s = turtle.Screen() #객채선 def draw_shape(t,c,length,sides,x,y) : #랜덤으로 도형을 그리는 함수 선언 t.up() t.goto(x,y) t.down() t.fillcolor(c) #c에 해당하는 색깔로 도형 채움 angle = 360.0 / sides t.begin_fill() for dist in range(sides) : t.forward(length) ...
2f15bd1479f3278c04021a9f6cd7b991df3240d0
ManjotSinghSindhu/PYTHON
/LOOPS.py
349
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 18 09:03:41 2018 @author: Manjot singh """ x=int(input('enter a no.')) if x%2==0: print(x,' is even ') else: print(x,' is odd ') y=int(input('enter a no')) if y==0: print(y,'is zero') elseif y%2==0: print(y,'is even') ...
65e02cb31eedd78dd8694fd62c6cb3fdae5a6c72
trithagoras/MoonlapseMUD
/networking/packet.py
10,008
3.640625
4
import traceback import json from . import payload from .payload import Payload from typing import * class Packet: """ A custom Packet data type encapsulating a netstring. See http://cr.yp.to/proto/netstrings.txt for the specification of netstrings. Every netstring starts with decimal digits that sp...
af9a205574ccf3e66ae2dc40739cba5e385fb960
rhanifsat/PythonProject
/Chapter 7 Latihan No. 2.py
710
3.671875
4
try: direktori = input("masukkan direktori file: ") file = open(direktori, "r") while True: file = open(direktori, "a") tambah = input("Data yang mau ditambahkan: ") file.write(tambah) while True: lanjut = input("Mau lagi (y/n) : ") jadin = "n" ...
33eb8556e73c4366b8c0d01df42f84e41c3560a3
kazemicode/AdventOfCode
/2019/2/day2-part1.py
1,826
4.03125
4
# An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). # To run one, start by looking at the first integer (called position 0). # Here, you will find an opcode - either 1, 2, or 99. # Opcode 1 adds together numbers read from two positions and stores the result in a third position. # The t...
b3a6e0d967c19e9244d0135bad1bbf58448d4114
willcray/leetcode
/Python/frog_river_one.py
1,289
3.625
4
""" https://app.codility.com/programmers/lessons/4-counting_elements/frog_river_one/ 12/7/2019 time - O(N) space - O(N) """ # assuming: # array A is non-empty # N and X are integers within the range [1..100,000] # each element of array A is an integer within the range [1..X] # def solution(X, A): # frog can't p...
f694a2628565bd38ea370390388b127bfa6574af
obitech/tutorials
/automate_python/range.py
154
3.890625
4
for x in range(10): print(x) animals = ["cats", "dogs", "mammals", "birds", "fish", "reptiles"] for i in range(len(animals)): print(i, animals[i])
4fd3ccfdaf9c2b0d356c5adcf9cd08657b66794c
becodev/python-utn-frcu
/guia02python/ejercicio13.py
277
4
4
""" Dado tres números obtener el mayor de estos. """ numeros = 1 lista = [] while numeros < 4: numero1 = float(input("Ingrese un numero: ")) lista.append(numero1) numeros += 1 maximo = max(lista, key=float) print("El numero mayor de los ingresados es:", maximo)
72c51837c930b45ab86824891d631a5faa7a8ae8
chrisssc/pyVis
/vuMeter.py
1,004
3.703125
4
""" vuMeter: detects the Sound Pressure Level of a given input in a fashion similar to VU meters on mixing desks """ __author__ = 'Chris Curry' __version__ = '3.0' import math as m import numpy as np class VUMeter: def __init__(self, bit_depth = 2**15): self.bit_depth = bit_depth def get_SPL(self,...
2165ddd47e1a8cda160162f8e46c77cfad8e5f51
EachenKuang/LeetCode
/SwordOffer/SwordOffer_06.py
1,274
4.0625
4
# 输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。 # # # 示例 1: # # 输入:head = [1,3,2] # 输出:[2,3,1] # # 限制: # # 0 <= 链表长度 <= 10000 # # 链接:https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof from typing import List from SwordOffer.DataStruct import ListNode, init_list_node_from_list class Solution: def revers...