blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3fea96d33785caef7e4bc8b0bcba9df180fa346c
cn5036518/xq_py
/python16/day22-40/day22 常用模块01 random collection time/作业/zuoye.py
3,880
4.5
4
#!/usr/bin/env python #-*- coding:utf-8 -*- # 8题 class Foo(object): a1 = 11 a2 = 12 def __init__(self): self.a1 = 1 obj = Foo() print(obj.a1) #1 print(obj.a2) #12 print(Foo.a1) #11 print(Foo.a2) #12 # # 9题 # class Foo(object): # a1 = 11 # # def __init__(self, num): # self...
e487ac62ffac9b4dab33a2836519c1989f48c9ae
Damon0626/Leetcode-
/226-Invert Binary Tree.py
488
3.96875
4
# -*-coding:utf-8-*- # @Author: Damon0626 # @Time : 19-2-24 下午7:19 # @Email : wwymsn@163.com # @Software: PyCharm # 反转二叉树 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def invertTree(self, root: TreeN...
50884f6e03c0ef9e680e3e6c1bbca73fb54b15bd
ajgoranson/SoftwareCapstoneWeek2Lab
/student_dataclass.py
1,088
4.59375
5
# create a student dataclass with student objects #import the dataclass from dataclasses import dataclass # Initialize the data class (This will produce its own __init__ and __str__ methods using the given data) # This may be useful when creating a more simple class like this one, where you may not care about the f...
764631835f8270badc2edac03fba750dba1f63c9
SamCas/Python-Udemy
/primer_programa.py
227
4.09375
4
# Python 3 outputs the decimal point, not in Python 2. # Clasic Division. x = 0 x = 3/2 print(x) # Power x = 2**3 print(x) # Varible declaration. my_income = 100 tax_rate = 0.1 my_taxes = my_income * tax_rate print(my_taxes)
aa02c9c328c4b532451181a4425421faa2c4c683
PaulWells314/ReinforcementLearning
/LunarLander_TD.py
3,689
3.859375
4
""" Lunar Lander: An example of Reinforcement Learning by solving Bellman equations. """ import numpy as np from enum import Enum import matplotlib.pyplot as plt class Action(Enum): ACTION_NONE = 1 # free-fall ACTION_BURN = 2 # positve accelertation (up) NUM_POS = 20 # 0 = ground NU...
bc0700e0a2f6dac9a24b16404e1a8a07326f1065
guozhaoxin/leetcode
/num001_100/num091_100/num099.py
748
3.765625
4
#encoding:utf8 __author__ = 'gold' ''' Recover Binary Search Tree Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Input: [1,3,null,null,2] 1 / 3 \ 2 Output: [3,1,null,null,2] 3 / 1 \ 2 Example 2: Input: [3,1,4,...
dd39d3f17008dd0f9a6e8c164c22d17a86b61a3f
ashu002712/python_sem3
/quiz app.py
1,766
3.859375
4
from tkinter import * def sel(): selection = "Correct Answer " + str(var.get()==1) label.config(text = selection) root = Tk() root.title("QUIZ APPLICATION") var = IntVar() Label(root,text=""" What's Machine Learning ? """,justify=LEFT,padx =20).pack() Radiobutton(root, text = "The autonomous acquisition of kn...
36510ed906158c4997fff6e386b465efb24345ac
betty29/code-1
/recipes/Python/164274_Fixed_size_cache/recipe-164274.py
1,623
3.6875
4
import weakref class DoubleNode: """node for a double linked list """ previous = None next = None def __init__(self, value): self.value = value def extract(self): previous = self.previous next = self.next if previous: previous.next = next if next: next.previous = previous self.next...
ba2af4192c48854ad09b2e750d2931664b3b2525
komaljit/leetcode
/148 sort list.py
1,126
3.875
4
class Solution(object): def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None or head.next == None: return head mid = head front = head while front.next != None: front = front.next ...
f51925ccdf7998143eb11b12bd421e50bfd69773
SalvaDaking/Python_learning
/Mastermind.py
757
3.65625
4
import random secret = ["A", "B", "C", "D", "E", "F"] random.shuffle(secret) result = ["X"] * 6 tries = 4 show = "".join(secret) user_code = input("Solve the code [ABCDEF]:\n").upper() while tries != 0: for user, letter, num in zip(user_code, secret, range(0, 6)): if user == letter: ...
4239cf58d23d7d10f8dcbcfb1ee248e5c233af64
vowatchka/jpathpy
/jpathpy/__init__.py
34,710
4.25
4
#!/usr/bin/env python """ This package is easy way for selecting items from objects, that can be iterate by keys or indices (such as dictionaries or lists). Also you can use syntax of JPath for selecting items by string expression. For example, it can be usefull for selecting some items from JSON. Example: >>> fro...
3503c4d1cc1ddc7c65fc52e87e0e0360c877b40c
AdmiralAckbar13/nmt_python_labs
/pascal.py
569
3.984375
4
#Pascal.py (Lab 3) [Shane Roeseberg] def pascal_tri(n): if n == 1: return [1] else: line = [1] existing_line = pascal_tri(n - 1) for x in range(len(existing_line) - 1): line.append(existing_line[x] + existing_line[x + 1]) line += [1] return line for i...
8f3323ac289f66451b9626ee40eeb0a3a031b312
amartyahatua/programpractice
/Python/ConditionalStatement.py
3,609
4.1875
4
## Source https://www.youtube.com/watch?v=eHxoh9Rrtdk ## If with strings answer = input("Would you like express shipping \n") ## Converting all the answers in lower case so that we can accept any input answer = answer.lower() if (answer == "yes"): print("That will be an extra $10") print("Have a nice day") fav...
84ce844938ea3fa916b309dfe4929ef2501f2e8b
victorfengming/python_projects
/history_pro/python_January/python05/6匿名函数lambda.py
2,965
4.125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # coding by xiaoming ''' # 教案 lambda表达式 lambda表达式是一种简洁格式的函数。该表达式不是正常的函数结构,而是属于表达式的类型。 基本格式: lambda 参数,参数...:函数功能代码 如:lambda x,y:x + y 获取2个值的和的lambda函数 带分支格式: lambda 参数,参数... :值1 if 条件表达式 else 值2 如:lambda sex : '有胡子' if sex == 'man' else '没胡子' 调用函数格式: lambda 参数,参数...:...
bc467932aff6ce4f84e3b987c3ba6523bd431459
thomaspfeiffer-git/raspberry
/libs/Shutdown.py
1,298
3.671875
4
# -*- coding: utf-8 -*- ############################################################################### # Shutdown.py # # (c) https://github.com/thomaspfeiffer-git 2017 # ########################################################...
b46c817035d2cf642ee43b5234e208b71a720e24
UWICompSociety/python-starter
/tutorials/5A.py
1,838
3.578125
4
import math print "\nTutorial 5A" print "\nQuestion 1" def my_sum1(start, stop): if start > stop: return 0 else: return start + my_sum1(start + 1, stop) def my_sum2(start, stop): if start > stop: return 0 else: return 1.0 / start + my_sum2(start + 1, stop) def my_...
f7cd250aba8842ce286fe99ff370e026c4a42470
justinpaulturner/Swiggy_Orders_Download_Python
/swiggy_orders.py
8,021
3.8125
4
''' Description: Python 3 code using Seleniun to login to your Swiggy account on the Desktop, scrape all the order information in your account and present the information in a json file that includes details like: 1. Number of Swiggy Orders 2. Total amount spent 3. Number of orders delivered 4. Number of orders cancell...
8ad103a43414f50f80f5b16ad260e609b475e134
nikita-sh/CSC148
/A2/a2_tree.py
1,037
3.546875
4
""" Bare bones Tree ADT for iterative minimax. """ from typing import List, Union class MinimaxTree: """ Tree ADT that identifies the root with the entire tree. Has score and move attributes for iterative minimax simulation. ===Attributes=== value: value of the root node move: move made to r...
01c5ff1fa0468ca4a16850d98e703818fd4b6341
CleitonFurst/Exercicios_Python_Blue
/Exercicios_para_entregar/Exercicio_02.py
1,055
4.21875
4
# 02 - Utilizando estruturas de repetição com variável de controle, # faça um programa que receba uma string com uma frase informada pelo usuário # e conte quantas vezes aparece as vogais a,e,i,o,u e mostre na tela, # depois mostre na tela essa mesma frase sem nenhuma vogal. #insere a frase frase = str(input('Digite ...
2d593998eaf8c47e2b476f7d5c50143ef75f409a
gpastor3/Google-ITAutomation-Python
/Course_2/Week_5/charfreq.py
873
4.1875
4
#!/usr/bing/env python3 """ This script is used for course notes. Author: Erick Marin Date: 12/26/2020 """ # To use a try-except block, we need to be aware of the errors that functions # that we're calling might raise. This information is usually part of the # documentation of the functions. Once we know this we ca...
fc204218043d507ad81323d41427259146ee7622
serdardurmus/hjelperfunksjoner_v1.1
/python/challenge_easy/sudoku_displayer.py
1,929
4.125
4
# """ Task: The department you work for has received a project that displays the solved sudoku puzzles in a digital environment. Write a Python code to print out the given sudoku puzzle matrix in the following format. Given format : sudoku = [ [0, 0, 0, 0, 6, 4, 0, 0, 0], [7, 0, 0, 0, 0, 0, 3, 9, 0], [8,...
e3e6007db1a89060f7122b8a61eab3d973ddbcff
George-Spanos/HashcodePractice
/entities/team.py
792
3.78125
4
class Team: def __init__(self, members): self.members = members self.pizzas = [] self.delivered = False def append_pizza(self, pizza): if not self.delivered: self.pizzas.append(pizza) if len(self.pizzas) == self.members: self.delivered = T...
aff18800cd49972e9fcd7eb04c28b2dd85117f8b
Subhamp7/Machine_Learning
/Clustering/Hierarchical_Clustering/hierarchical_clustering.py
1,980
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 2 15:01:18 2020 @author: subham """ """ref:https://towardsdatascience.com/understanding-the-concept-of-hierarchical-clustering-technique-c6e8243758ec """ # Hierarchical Clustering # Importing the libraries import matplotlib.pyplot as plt import pandas as pd import scipy...
fa2f3f9edb9f15fcd8de85216e126ffd765a9fbe
shobhit-nigam/onsemi_one
/day1/data_structs/3.py
349
3.5
4
# lists # mutable num_a = [8, 9, 3, 4, 6, 10, 20] num_b = [33.4, 77.8, 99.0, 12.3] south_america = ['lima', 'bogota', 'buenos aires', 'santiago'] lista = [23, 88.9, 'hello', 'hi', 10] listb = [22, 'tt', lista, 'yy'] print(south_america) print(type(south_america)) print(type(south_america[1])) south_america[1] = 'ca...
0bc24b05753eb6335cf49e38d01a7a5d691dc4e3
JiayangWu/Basic-machine-learning-algorithms
/linear regression.py
893
3.671875
4
#Import Library #Import other necessary libraries like pandas, numpy... from sklearn import linear_model #Load Train and Test datasets #Identify feature and response variable(s) and values must be numeric and numpy arrays x_train=[[2],[3],[5],[8],[9]] # The reason why x should be 2D array is in https://segmentfault.c...
8b210c5f155c4d4dfefc5c9769790c1203a01111
the-blackbeard/python-code
/bfs.py
1,019
4.21875
4
class Node: def __init__(self, name): self.name = name self.adjacency_list = [] self.visited = False def breadth_first_search(start_node): # FIFO: First item we insert will be taken out first queue = [start_node] # We keep iterating (considering the neighbour) until the queue is empty while queu...
debbfc31ca921b9661f45da433c89d1bb9940ff4
Bibin22/pythonpgms
/Tutorials/Loop/multtable.py
121
3.5625
4
a = int(input(" number")) b = int(input(" limit")) for x in range(1, b + 1): c = x * a print(a, "*", x, "=", c)
e662544a7f192047085a3ddf9c220b7a534a9406
IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo
/semana 7/ejercicios-clase-07-01bim-JamilErasmo/EjemplosFor/Ejemplo01.py
143
3.890625
4
for i in range(0, 10): # for i in range(10, 1, -1): # for i in range(0, 10, 5): # for i in range(0, 10, 3): # for i in range(0, 10, -11): #
ead5740c504b3022130cddaf3229eb752f844856
ChiehAn0416240/Cloud-Computing-and-Cyber-Security-2020-Fall
/Term Project/compute.py
636
3.578125
4
import pandas as pd df = pd.read_csv('usable_csv.csv') #處理過後的csv檔案 def compute(station, time): if time == 'Morning': data = df[(df['time'].isin([7,8,9]))] #早上時段的csv elif time == 'Noon': data = df[(df['time'].isin([11,12,13]))] #中午時段的csv else: data = df[(df['time'].isin([17,18,19]))] #晚上時段的csv output_df = ...
e479eac7aa1e8cff679688c5867e07b6cbc92cd6
sohyunwriter/algorithm
/프로그래머스/깊이너비우선탐색/네트워크.py
781
3.625
4
from collections import defaultdict from collections import deque def array_to_graph(computers, n): graph = defaultdict(list) for i in range(n): for j in range(n): if i != j and computers[i][j]: graph[i+1].append(j+1) return graph def bfs(graph, start, visited): q =...
9e1412f6c1ae6d44996ed274e9e4b2668d4efd7c
luismelendez94/holbertonschool-higher_level_programming
/0x0B-python-input_output/6-load_from_json_file.py
243
3.546875
4
#!/usr/bin/python3 """ Lets creates Object from a JSON file """ def load_from_json_file(filename): """ Create an Object from a JSON file """ import json with open(filename, 'r') as readFile: return(json.load(readFile))
0974db3a168df9727e01e10d6c7b1879228f52b0
strange-hawk/data_structure_algorithms
/recursion/string.py
276
3.5
4
def string(length,a,b,c): if length==0: return 0 if length<0: return -1 res=max((string(length-a,a,b,c)),(string(length-b,a,b,c)),(string(length-c,a,b,c))) if res==-1: return -1 else: return 1+res print(string(23,9,11,12))
9f26133b399b3c1660c11e98cd5bc3112995caad
robsondrs/Exercicios_Python
/ex089 - Boletim com listas compostas.py
755
3.75
4
lista = list() while True: nome = str(input('Nome: ')) nota1 = float(input('Nota 1: ')) nota2 = float(input('Nota 2: ')) media = (nota1 + nota2)/2 lista.append([nome, [nota1, nota2], media]) resp = str(input('Quer continuar? [S/N] ')).upper().strip()[0] if resp in 'N': break print('-...
39e52448d3e498e2adffa45ab724f90b1c2919b1
gyalpodongo/g_lab
/Mini Project/Mini Project/mini_project_v4.py
7,027
4.125
4
""" The purpose of this mini project for ES 8.01/8.012 is to show the orbit of two objects in a bynary system using Newton's Gravitational Law, Conservation of Momentum and Newton's 2nd Law. The visualization will be produced using the different features of vpython. Before running the code, in the command pro...
ee4ab902f5dabefa8f3ba4119d8dd67bdd244d26
wulinlw/leetcode_cn
/leetcode-vscode/100.相同的树.py
1,900
3.6875
4
# # @lc app=leetcode.cn id=100 lang=python3 # # [100] 相同的树 # # https://leetcode-cn.com/problems/same-tree/description/ # # algorithms # Easy (56.54%) # Likes: 318 # Dislikes: 0 # Total Accepted: 68K # Total Submissions: 120K # Testcase Example: '[1,2,3]\n[1,2,3]' # # 给定两个二叉树,编写一个函数来检验它们是否相同。 # # 如果两个树在结构上相同,并且节...
0d4678509445fbb5c236345267eb1fb3b1ba2d60
ethanthechen/Python-2020-8
/last final.py
13,586
3.5625
4
import tkinter as tk import turtle import time import random class GameObject(object): def __init__(self, canvas, item): self.canvas = canvas self.item = item def get_position(self): return self.canvas.coords(self.item) def move(self, x, y): self.canvas.move(...
51bc1f16ad883780d5078bebec71fed536285fde
Abhrojit16/python-is-easy
/Dictionaries_sets.py
1,862
4.15625
4
""" Details: Return to your first homework assignments, when you described your favorite song. Refactor that code so all the variables are held as dictionary keys and value. Then refactor your print statements so that it's a single loop that passes through each item in the dictionary and prints out it's key and then ...
3788936b37e4198250ecd8a9c8338db1b3f8efda
oprk/project-euler
/p012_highly_divisible_triangular_number/highly_divisible_triangular_number.py
2,235
3.765625
4
# Highly divisible triangular number # # The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. # # The first ten terms would be: # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # # Let us list the factors of the first seven triang...
8893fc8e381a246dd0858371cc52b7d545f63752
PixiePilot/functions-tryout
/tafel.py
244
3.75
4
def tafels(): try: Tafel = (int)(input('van welk getal wilt u de tafel zien?: ')) except ValueError: print('Please enter a number.') tafels() for a in range(1,11): print (Tafel * a) tafels()
146383344a3764b7c26fcdd50b2bd3e79b6c2ab0
Jack-HFK/hfklswn
/pychzrm course/journey_two/day4_PM/find_dict.py
708
3.96875
4
""" 英英词典,查找单词,根据单词打印注释 """ # # 打开单词文件 # fd = open("/home/tarena/dict.txt","r") # # 文件对象本身也是一个可迭代对象,在for循环中可以迭代文件的每一行 # for line in fd: # if line == "number": # print(line) # 循环一次读取一行 def find_dict(dict01): fd = open("/home/tarena/dict.txt", "r") # 遍历的单词已经大于目标 for line in fd: ...
c5d8e839c353bbf2000bf9d34b495728bf113369
AhmedHelalAhmed/python-udacity
/while.py
109
3.703125
4
# This code demonstrates a while loop with a "counting variable" i = 0 while i < 10: print i i = i+1
ca95e840ecd8c4865ca9033313a8b775b5631189
joescottengineering/Euler-Problems
/Euler probs - 69 Totient max B.py
2,190
3.5
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 03 21:51:55 2015 @author: JKandFletch """ import math from collections import Counter import time start = time.time() def memoize(f): cache = {} def decorated_function(*args): if args in cache: return cache[args] ...
59f86fa8f0036fe99798852764a82b12230725b3
jjdblast/Principle-of-Urban-Informatics
/week5/solutions/solution_problem1.py
711
3.75
4
# Functions for students to implement. def solveWithSet(inputList): outputSet = set(inputList) return list(outputSet) def solveOnlyLists(inputList): uniqueList = [] for item in inputList: if not item in uniqueList: uniqueList.append(item) return uniqueList def solveDi...
5c2d4f6ba3a8146816f36ad3f1456875f689ef5b
sam2500/Coding-Problems
/Code Signal/Arcade/addBorder.py
500
4.03125
4
''' Given a rectangular matrix of characters, add a border of asterisks(*) to it. Example For picture = ["abc", "ded"] the output should be addBorder(picture) = ["*****", "*abc*", "*ded*", "*****"] ''' def addBorder(picture): pic = [] ...
4fa1d61de8c40f25e3fe1bb5c18d26d529981430
KseniaZikova/Project_05
/nomber_1.py
1,530
3.59375
4
import ru_local Taken = 0 date_tr = int(input(ru_local.NAME)) while Taken < 3: date_no = (input(ru_local.NAME_ONE)) date_no = int(date_no) Taken = Taken+1 if date_tr == date_no: print(ru_local.MEY,ru_local.SAVE) if date_tr != date_no: print(ru_local.NAME_THREE) if date_tr == da...
747ee26960ee81836192aa2bc3f54b34ff0cb185
GGjin/algorithm_python
/easy/107.二叉树的层次遍历II.py
1,176
3.71875
4
# 给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历) # # 例如: # 给定二叉树 [3,9,20,null,null,15,7], # # 3 # / \ # 9 20 # / \ # 15 7 # # # 返回其自底向上的层次遍历为: # # [ # [15,7], # [9,20], # [3] # ] # # Related Topics 树 广度优先搜索 # 👍 364 👎 0 # leetcode submit region begin(Prohibit modification and ...
e34a1e50d752a2a22291cb54839b211eb77ca90d
NetanelShimoni/Economic-algorithms
/Agent.py
895
3.78125
4
from typing import List class Agent: array1 = [] def value(self, option: int) -> float: return self.array1[option] def isParetoImprovement(agents: List[Agent], option1: int, option2: int) -> bool: j = 0 for i in agents: print(i.array1) if i.value(option1) > i.v...
2d6bb5dda5374b753c3792ac258146721bdf2e7f
ecotom/girls_who_code
/EXwordEncryption.py
1,576
4.09375
4
#GLOBAL FUNCTIONS codeWords = [] realWords = [] #FUNCTIONS def createCodeWords(): codingWords = True while codingWords: print("Would you like to add a word to your code word? (Yes/No)") answer = input() if (answer == 'yes'): print("What is the real word?...
6bce6ad7f0155501fcf7d0b170eecc385f64b163
Langsheng0716/zhangsan
/demo03.py
2,164
3.671875
4
'''a = input("请输入你的名字:") b = input("请输入你的年龄:") try: if int (b) >= 18: print(a,"成年了") else: print(a,"未成年") except Exception as e: print("请输入正确的年龄!")''' #处理用户输入的数据 '''代码的单位 包 自带的包 import 第三方的 pip install 包名 pip uninstall 包名 pip list 常见的第三方的包pymysql ...
8cfb237b127ae8276efcdfc984334172574515e0
nguyenvanhoang97/nguyenvanhoang-labs-c4e18
/lab3/btvn/ex5.py
252
3.921875
4
from turtle import * shape("turtle") speed(0) color("green") def draw_star(x , y , s_le): penup() setpos(x , y) pendown() left(36) for i in range(5): left(144) forward(s_le) draw_star(10 , 10 , 100) mainloop()
d6688a5d3ead15960502fb5584b89919757204f2
liliajojo/my_pathon
/syntax. 1/2.if_else.py
486
4.15625
4
# логические операторы НЕ(NOT), И(AND), ИЛИ(OR) # x = False # y = True # оператор НЕ # print(not x) # оператор И # res = x and y # print(res) # Условные операторы # if False: # c = "Hello!" # print(c) a = 10 # if a > 0: # print("больше 0") # elif a == 0: # print("равно 0") # e...
fece05db37459605654ea86410dff48a1fd75c98
camigalante04/HOoop_2018
/main.py
2,355
4.0625
4
#!/usr/bin/python #-*-coding:utf-8 -*- import random class Fila(object): """Clase base de fila""" def __init__(self): """constructor de la clase Fila """ self.enfila= 0 self.fila = [] class FilaPreferencial(Fila): """Clase de la fila de los clientes preferenciales""" ...
15b5c31f7bc1b78e8738e34e9de531c1d8c05e8c
justinta89/Work
/PythonProgramming/Chapter 9/randomWalk.py
1,474
4.5625
5
# randomWalk.py from random import randrange # Get a random number of steps from the user # flip a coin to determine step. 1 for heads, 0 for tails. # heads = step forward # tails = step backward # how many steps away from starting point are you, based on coin flips. def main(): printIntro() flip ...
4a19e8841036e7736704c7066f9689190ba611af
cmparlettpelleriti/CPSC230ParlettPelleriti
/Lectures/FilesAndExceptions_21.py
3,390
4.3125
4
# basic try and except num_not_found = True num = input("Please give me a non-zero, positive integer: ") while num_not_found: # if not num.strip("-").isnumeric(): # print("oh no that's not a good number!") # num = input("Please give me a non-zero, positive integer: ") # elif int(num) <= 0: ...
dc7c001eaad5257d8b29b314d1908ebd027c633c
dstch/my_leetcode
/Bit Manipulation/Single Number III.py
1,316
3.59375
4
''' @Author: your name @Date: 2020-01-28 11:56:40 @LastEditTime : 2020-01-29 20:50:17 @LastEditors : Please set LastEditors @Description: In User Settings Edit @FilePath: \my_leetcode\Bit Manipulation\Single Number III.py ''' #!/usr/bin/env python # encoding: utf-8 """ @author: dstch @license: (C) Copyright 2013-2019,...
3a8d562d4cc3e7c8d4010b897689a7602ff236bc
DavidLouisLevine/adventure
/adventure/direction.py
600
3.609375
4
class Direction: names = ('NORTH', 'SOUTH', 'EAST', 'WEST') NORTH = 0 SOUTH = 1 EAST = 2 WEST = 3 def __init__(self, d): if type(d) is str: self.d = Direction.FromName(d).d else: self.d = d def Name(self): return Direction.names[self.d] ...
f48d155455fbdee90da83ded9f5babbf6b86f895
Giuco/data-structures-and-algorithms
/course-1-algorithmic-toolbox/week-5/5-longest-common-subsequence-of-three-sequences/lcs3.py
2,810
3.546875
4
# Uses python3 import sys from itertools import combinations from numbers import Number from typing import List def lcs3_naive(a: List[Number], b: List[Number], c: List[Number]) -> List[Number]: """ >>> len(lcs3_naive([1, 2, 3], [2, 1, 3], [1, 3 ,5])) 2 >>> len(lcs3_naive([8, 3, 2, 1, 7], [8, 2, 1, ...
176104e539b65863a7af43b4e7fcec6d50834920
Akim-Delli/MachLearnPy
/DataPreProcessing/missing_data.py
629
3.546875
4
import pandas as pd from io import StringIO csv_data = '''A,B,C,D 1.0,2.0,3.0,4.0 5.0,6.0,,8.0 10.0,11.0,12.0,''' df = pd.read_csv(StringIO(csv_data)) print(df) print(df.isnull().sum()) # accessing the underlying Numpy Array of the DataFrame via values print(df.values) # drop rows with missing values print(df.drop...
b82a98b5129ff88bfe167d2b632d27ddd0846487
shaneebyrne/Python
/Wattage.py
384
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 28 19:01:37 2018 @author: Seamus """ class Power: def __init__(self, watt): self.watt = watt def getWatt(self): return self.watt def setWatt(self, watt): self.watt = watt #w = Pow...
970fa98c89203fa5616e7a3373577c28393d1f3c
z313608886/PythonStudy
/datastructure/linkedprocessing.py
1,812
3.703125
4
#链表操作代码 #遍历 probe = head while probe.next != None: <use or modify probe.data> probe = probe.next #搜索目标项 probe = head while probe.next != None and targetItem != probe.data : probe.next = probe if probe.next != None: <targetItem has been found> else: <targetItem is not in the linked datastructure...
f44420d1d9c60fa7c1c3d1597b1e896e1bfc60bb
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/968 Binary Tree Cameras.py
2,325
3.859375
4
#!/usr/bin/python3 """ Given a binary tree, we install cameras on the nodes of the tree. Each camera at a node can monitor its parent, itself, and its immediate children. Calculate the minimum number of cameras needed to monitor all nodes of the tree. Example 1: Input: [0,0,null,0,0] Output: 1 Explanation: One c...
8b806a2bc84dcd07e5a12b1279ac30a8abe12e23
Sajid16/World-of-Python-and-Machine-Learning
/Basic_python_Practice/returnValues.py
243
4.03125
4
def dating_age(age): age = float(age) range_age = (age/2)+5 return range_age your_age = input("Enter your age: ") dating_age = dating_age(your_age) print("The range of age of your dating girlfriend has to be ",format(dating_age))
ff5243f7ed332788d7ba076f78e1d8d2dfdc1bfc
Amundeep-Dhaliwal/Random-programs
/sudoku.py
2,944
4
4
def possible(i,j,z): ''' i is an integer j is an integer z is the chosen integer ''' #if board.shape!=(9,9): checks the dimensions of the board are correct #raise(Exception("Sudokumatrix not valid")); global board if 8 < i < 0: raise(Exception("i not valid")); if 8 ...
df7cd541f9b1ce00f42df6a05fff5f7e51a7af0f
SoundaryaAdaikkalavan/Guvi-Beginners
/returnoddnum.py
94
3.546875
4
a=input() for i in range(len(a)): b=int(a[i]) if b%2!=0: print(b,end=" ")
0493036ea04c2c9e328dd6e11a7acc5df34c9c66
gamecmt/pcc
/chapter4/numbers.py
902
4.09375
4
for value in range(1,5): print(value) numbers = list(range(1, 6)) print(numbers) even_numbers = list(range(2, 11, 2)) print(even_numbers) squares = [] for value in range(1, 11): square = value**2 squares.append(square) print(squares) print(min(squares)) print(max(squares)) print(sum(squares)) squares = [value**...
6294850944d94b64a9db8f0c87bede6ba5a8c1f9
yanggelinux/algorithm-data-structure
/leetcode/102.py
1,446
3.984375
4
# -*- coding: utf8 -*- """ 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [9,20], [15,7] ] """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.le...
ed39f962adf5447ee9ea442a8438dbc633ba8f77
ShivaVkm/PythonPractice
/subtraction.py
173
3.765625
4
# lets perform the subtraction of two numbers in python programming firstNumber = 100 secondNumber = 75 subtractedResult = firstNumber - secondNumber print(subtractedResult)
8453885a49571245a1cf98eb9a2e4cde2a35a885
carlosngo/CompetitiveProgramming
/Kattis/aboveaverage.py
377
3.5625
4
t = int(input()) for i in range(t): s = input().split(' ') n = int(s[0]) sum = 0.0 grades = [] for j in range(1, n + 1): grade = float(s[j]) grades.append(grade) sum += grade ave = sum / n ctr = 0 for j in range(n): if grades[j] > ave: ctr = ct...
310362c163fc2db22df32cfd7f5ef3e81f2cdbd4
hemuke/python
/09_func/02_func/07_closure.py
723
3.546875
4
#! /root/anaconda3/bin/python # 例子一 def outer(): a = 10 def inner(): nonlocal a a += 1 print("例子五,内函数:", a) #print("例子五,外函数:", a) return inner # outer()() #print("例子五__closure__:", outer().__closure__) #print("例子五__closure__[0].cell_contents:", outer().__closure__[0].cell_co...
156e0019503e2e254d36025ec5774d918520123d
RohanRatwani/SSW-810
/HW_03_Rohan_Ratwani/HW03_Rohan_Ratwani.py
6,712
4.46875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Implement a class for fractions that supports addition, subtraction, multiplication, and division This file provides a framework for HW02 that you can use to get organize your solution. You may also use a different solution. """ class Fraction: """ S...
54bd56e919d89a516fb64966880e4abe49da755a
zjhzxjm/Python_Train
/operator_intro.py
788
3.96875
4
# -*- coding: utf-8 -*- """ Author: xujm@realbio.cn Ver:1.0 Introduce operator """ def math_operate(): a = 3.2 b = 1.4 x = a ** b print x # 求幂 输出5.09577178308 y = a / b print y # 除法 输出2.28571428571 y1 = 7 // 3 print y1 # 整除 输出2 y2 = 7 % 3 print y2 # 取余 输出1 def assign_oper...
5e73936582b046ca6768dd300e1f6669269f6c9c
stostat/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
224
3.9375
4
#!/usr/bin/python3 def uppercase(str): for i in str: if ord(i) >= 97 and ord(i) <= 122: to_up = 32 else: to_up = 0 print("{:c}".format(ord(i) - to_up), end="") print()
6928938c150e0ddd229d2ffa6cb1b48d00f473af
sherrymou/CS110_Python
/Mou_Keni_A52_Assignment3/#1. HandShake.py
1,941
3.859375
4
''' Keni Mou kmou1@binghamton.edu Assignment3, exercise1 A52 CA: Kyle Miller ''' ''' Analysis: count the number of handshake in the classroom Output to monitor: handShake1(Float)- number calculated by foluma handShake2(Int) - number calculated by loop resultChecker(Bool) - Whether two numbers are same In...
e021f17882b94e8028fbdc662caa3fe13a0f6a64
rishavhack/Data-Structure-in-Python
/Control Flow/Iterator Functions in PythonSet 1.py
310
4
4
import itertools import operator li1=[1,4,5,7] li2=[1,6,5,9] li3=[8,10,5,4] print "The sum after each iteration is :" print list(itertools.accumulate(li1)) print "\n" print "Multiplication :" print list(itertools.accumulate(li1,operator.mul)) print "Mentioned chain" print list(itertools.chain(li1,li2,li3))
c6f9fd357264c3d02f9654fe6a0cb36518c5896c
Kevinxu99/NYU-Coursework
/CS-UY 1134/HW/HW5/sx670_hw5_q4.py
1,430
3.828125
4
class Empty(Exception): pass class ArrayStack: def __init__(self): self.data = [] def __len__(self): return len(self.data) def is_empty(self): return len(self) == 0 def push(self, val): self.data.append(val) def top(self): if (self.is_empty()): ...
0ae2ddfe26daea20f16c0201efabf3fae359493d
SuzanAlbedween/data-structure
/sorting algorithms/subarray.py
569
3.796875
4
#Given an unsorted array A of size N of non-negative integers, find a continuous sub-array which adds to a given number S. def fun1(arr, n, sum): current_sum = 0 res = [] first=0 count=0 while( current_sum !=sum and count<n): current_sum += arr[count] if( current_sum >sum): ...
c7f43711bbf3a05a0e51ad3bc9b20ef13e2d1e86
cathyleee/Swimming-Fish
/swimfishclass.py
9,447
4.0625
4
# swimfishclass.py # Assignment 9: Swimming Fish via Classes # Cathy Lee # Input: User enters a number # Output: Graphics window with aquarium drawn from graphics import * from random import * class MovingFish: def __init__(self,x,y,color,speed,dist): self.speed = speed p1 = Point(x-(d...
68b599c8259ba908662fa5828e102944edc5dfad
brucehzhai/Python-JiangHong
/源码/Pythonpa/ch10/my_math1.py
261
3.546875
4
PI = 3.14 #定义常量 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 #除
6e52b361a0f464b22e564a03e01a1a2523ea7435
sbrn3/group-holiday-split
/src/classes.py
18,715
3.734375
4
from typing import List, Dict from itertools import product class Person(object): """A person that is going on the trip""" _name: str def __init__(self, name: str, gender: str = "hello", days_staying: int = 1): """A person that will be there during the holiday :type name: str :par...
a01c00efe0655a44e52dd6b20bc4f983e908aa2f
singhamritanshu/open_cv_python_tutorial
/edge_detection.py
874
3.578125
4
import cv2 as cv import numpy as np img = cv.imread("test_images/boston.png") cv.imshow("Original",img) gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY) cv.imshow("Gray", gray) # Canny canny = cv.Canny(gray,155,255) cv.imshow("Canny",canny) # Laplacian lap = cv.Laplacian(gray,cv.CV_64F) # CV_64F is the datadepth(ddepth) v...
275865646f9112ad496864277b788aa4f479545f
openoms/lndmanage
/lib/user.py
354
4.1875
4
def yes_no_question(): """ Asks the user a yes/no question and translates it into bool. :return: bool """ yes = {'yes', 'y', 'ye', ''} no = {'no', 'n'} choice = input().lower() if choice in yes: return True elif choice in no: return False else: print("Pl...
adddb24a9fdb43f2d1504db1264e7644deda26ff
DinakarBijili/Data-structures-and-Algorithms
/BINARY TREE/CONCEPT.py
2,867
4.3125
4
# """ # The root of the tree is the node with no parents. There can be at most one root node in a tree. # The edge refers to the link from parent to child. # A node with NO children is called leaf node. # Children of same parent are called siblings. # """ class Node(object): def __init__(self, data = None): ...
fd9ebe03ff8c3c073937bbe61d2e6621188251a4
AnniePawl/Data-Structures-Intro
/Code/Stretch_Challenges/fisher_yates.py
593
3.984375
4
# Shuffle an array using Fisher Yates Shuffle Algorithm # Every permutation of array should be equally likely # 0(n) Complexity import random def fisher_yates_shuffle(array): for index in range(len(array)-1): # access all nums in array # random num between 0 and current index random_index = rand...
aa416a451fdf781d827dc8f46314cad187e0036f
vdusek/VUT_FIT
/mitai-sem4/kry-2/src/point.py
1,260
3.609375
4
""" VUT FIT MITAI KRY 2021/2022 Project: Elliptic-curve cryptography Author: Vladimir Dusek Login: xdusek27 """ from ast import literal_eval class MetaPoint: def __repr__(self): return str(self) def __eq__(self, another: object) -> bool: if isinstance(self, Point) and isinstance(another, Po...
9e10ffa42c2c829affb02ddfc28a8ea43dbdd086
JakubKazimierski/PythonPortfolio
/Coderbyte_algorithms/Easy/QuestionsMarks/QuestionsMarks.py
1,862
4.28125
4
''' QuestionMarks from Coderbyte October 2020 Jakub Kazimierski ''' from collections import Counter def QuestionsMarks(strParam): ''' Have the function QuestionsMarks(str) take the str string parameter, which will contain single digit numbers, letters, and question marks, and chec...
9ec524102700399d06fa738fe9675b08deae7f14
PriscylaSantos/estudosPython
/TutorialPoint/11 - Functions/01 - DefiningFunction.py
1,128
3.953125
4
#!/usr/bin/python3 # def functionname( parameters ): # "function_docstring" # function_suite # return [expression] def printme (str): print("This printd a passed string into this function") print(str) return printme("This is first call to the user defined function") printme(str = "My string")#Keywor...
9e089c90ff1fd5235dec74a098557082eae4c35c
asperaa/programming_problems
/queue/moving_average.py
909
3.9375
4
"""Moving average --sliding window""" from collections import deque class MovingAverage: def __init__(self, size): self.queue = deque() self.summ = 0 self.size = size self.curr_size = 0 def is_full(self): return self.size == len(self.queue) def next(self, val): ...
5448e0dcac4e729fa06ca9e620dd693a80340d1c
Uche-Clare/python-challenge-solutions
/Ekeopara_Praise/Phase 1/Python Basic 1/Day10 Tasks/Task1.py
142
4.09375
4
'''1. Write a Python program to concatenate N strings.''' num_string = ['1', '2', '3'] ans = '' for i in num_string: ans += i print(ans)
9b9da53ed47480b520b6491fc8e5b6fdb176860d
Migirditchsv/DissapativeNetworks
/dissapativeNets_model1.py
12,382
3.578125
4
# -*- coding: utf-8 -*- """ How does capitalism end? A simulation of dissapation driven percolation in competitive networks, and how the developed structures decay once the dissapative rescource runs out. Python 3.7 By Sam Migirditch and Thomas Varley samigir@iu.edu To Do: 1) Define Rescource, Producer and Consumer c...
f5e98e445594266067bede72d9b54e1073521b74
Arstanley/easy-to-use-binomial-model
/model.py
1,847
4
4
def traverse(root): current_level = [root] while current_level: print(' '.join(str(node) for node in current_level)) next_level = list() for n in current_level: if n.h: next_level.append(n.h) if n.t: next_level.append(n.t) c...
a85a5fd3a3faca2cace56e2d95e29beed56e007e
yiziqing/python-base
/kmeans.py
5,922
3.953125
4
#-*- coding: UTF-8 -*- import random import math ''' 1,造数据,展示数据 2,计算距离,这里用的是欧式距离,当然其他合理的距离都是可以的 3,随机生成初始的K 4,keans算法,输入数据和k值 5,展示聚类之后的数据 ''' '''坐标类''' class Coordinate: def __init__(self,x,y,k,flag): self.x=x self.y=y self.k=k #聚类类型 self.flag=flag #1,聚类中心标识 def __init__(...
f4d99af8c4e95a9c5276881c4af5be0ebe1f6b54
stev94/Dynamic-Pricing-with-MAB
/Implementation/Target_Creator.py
8,864
3.75
4
# Filename : Target_Creator.py # Date : 2019/10/01 11.24 # Project: Dynamic Pricing # Author : Stefano Valladares from scipy import interpolate as interpolate import numpy as np import re class Target_Creator: """ This class, given a set of prices and a conversion rate for each price, creates the target f...
fa2acd965c80ef985db5a771035230e9b36eb3cd
karimeSalomon/API_Testing_Diplomado
/HenryBenito/thrid_class/replace.py
256
3.953125
4
song = "I love spom! Spom is my favorite food.Spom, spom, yum!" def replace(input_string, old_value, new_value): words = input_string.split(old_value) return new_value.join(words) print(replace(song, "om", "am")) print(replace(song, "o", "a"))
016ab25db9d751339845fff5c71dedf2d111e863
Near-River/leet_code
/231_240/239_sliding_window_maximum.py
2,259
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. For example, Given nums = [1,3,-1,-3,5,...
38fc41e94f60748dcd8df68dff706fd72e07aefc
kannyg87/python-
/TipCalculator2.py
819
4.03125
4
amount = float(input("Enter your amount")) service = input("how do you like the service?") service = service.lower() people = int(input('enter the number of people you want to divide on:')) if service == 'good': service = amount*0.2 print('your tip amount is ',service) result = service+amount print('Th...
037d1a64cc99d4e28e474218b0f266dbd52d8a1f
MReneBrown/Python-Course
/List_Ranges.py
950
4.375
4
tags = ['python', 'development', 'tutorials', 'code'] tag_range = tags[1:2] # 1 is index of what will be printed, 2 is where the output will stop (before 2) print(tag_range) tag_range = tags[1:3] # 1 index of what will be printed, 3 is where outut will stop (before 3) print(tag_range) tag_range = tags[1:] # nothin...
545c5c726596151edb7d4050cd3fe3402775cfe3
joshbarcher/IT102_Summer2019
/9_data_structures/frequencies.py
427
4.375
4
# read an input string from the user sentence = input("Enter a (long) sentence: ") # count up the number of times each # character shows up in the string charCounts = {} for char in sentence: # ask if the character is already in the map if char in charCounts: charCounts[char] += 1 else: cha...
a559f9fc4e99e1fd2a944f27d7e830574ca52f71
IngenYah/Git
/Python/简单用户库练习/数字化.py
1,459
4.09375
4
#定义开始界面 def main_interface(): a = input('Welcome to the system\nPlease choose the sector you want to enter\n1.Building new member\n2.View member database\nPress the corresponding sign:') return a #新建用户 def new_member(): new_members.append(input("Input member's first name:")) new_members.append(input("I...
2e48c8bfc301cb9ebf0c2874886a1029aea33d7a
goldmode321/The_TCN_project_2018
/TCN_gpio.py
500
3.65625
4
# These function refer to opening the relay of the car of project import RPi.GPIO as gpio def init(): gpio.setmode(gpio.BCM) # the input can be BOARD and BCM , refer to definded pin number gpio.setwarnings(False) # Each time we setup a gpio pin , it will show warning . This disable the waring mechan...
7fd39ed0650c45af647fab7ed6797e4d15aa6789
nimu77/sprint_challenge_unit3_sprint2
/northwind.py
2,868
4.46875
4
import sqlite3 # filepath to connect filepath = 'northwind_small.sqlite3' # connecting to sqlite database connection = sqlite3.connect(filepath) # cursor to manipulate data cursor = connection.cursor() # queries # part 2 # What are the ten most expensive items (per unit price) in the database query = ''' SELECT ...