blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a929bac01aaa8cd1501ac5e811d9f578e4bf14a6
mps-jenkins/API
/pythonwork/groupby.py
119
3.546875
4
from itertools import groupby string="aabnnn" print(groupby(string[1])) #print(''.join(i[0] for i in groupby(string)))
19ce271fbed21911cb4845774d3def642a180e1c
mps-jenkins/API
/pythonwork/ty.py
266
4.0625
4
def print_reverse(string_list): dict = {} for str in string_list: print(str) if dict[str]: print(str) print(''.join(reversed(str))) dict[''.join(reversed(str))] = 1 list="youarewthene" print_reverse(list)
6ce31a00096f059a523de1c806c89d2150863b43
mps-jenkins/API
/pythonwork/sumoflist.py
206
3.96875
4
#! /usr/bin/python list1 = (1, 2, 10, 34, 22) def addlist(listing): if len(listing) == 1: return listing[0] else: return listing[0] + addlist(listing[1:]) print(addlist(list1))
83c9e61357cd68a4c20f5a62a039ba3e4444171b
mps-jenkins/API
/pythonwork/reversetypes.py
133
3.671875
4
name = "Shreeti" newstr = "" def reversing(string): newstring = string[::-1] return newstring print(reversing("Shreeti"))
3e6435849f3f4e3e19b5ca9a3c2b50a58ff3947d
Rakhatolla/Rakhatolla
/day_1.py
447
4.03125
4
# числа, строки # команда() - что-то, что выполняется # print('привет') # print(10 + 25) # print('10' + '25') # print(19 + '5') # print(f'Сумма {39+10}') # переменная - ячейка для хранения информация num1 = int(input('Введите первое число')) num2 = int(input('Введите второе число')) print('Сумма {num1+num2}') ...
0ae6315a37bc2f857bd5bbe4785f4b0c8d019b86
BeLazy167/css
/diffehellman.py
771
3.65625
4
import hashlib g=int(input("Enter value of g: ")) p=int(input("Enter value of p: ")) a=int(input("Enter random number for alice: ")) b=int(input("Enter random number for bob: ")) A = (g**a) % p B = (g**b) % p print('g: ',g,' (a shared value), n: ',p, ' (a prime number)') print('\nAlice calculates:') print('a (Ali...
e9acdbfd9ab5a29c06f1e27abcd1d384611c5cf0
chizhangucb/Python_Material
/cs61a/lectures/Week2/Lec_Week2_3.py
2,095
4.21875
4
## Functional arguments def apply_twice(f, x): """Return f(f(x)) >>> apply_twice(square, 2) 16 >>> from math import sqrt >>> apply_twice(sqrt, 16) 2.0 """ return f(f(x)) def square(x): return x * x result = apply_twice(square, 2) ## Nested Defintions # 1. Every user-defined func...
6303e82883ac28ef965a177e45358a74a7ecd233
sendador/Challenge
/Chapter 3/chapter_3.py
1,141
3.875
4
from itertools import groupby def check_adjacent(number_list): adjacent_groups = [len(list(g)) for k, g in groupby(number_list)] identical_adjacent_digits_counter = len( list(u for u in adjacent_groups if u > 1)) return identical_adjacent_digits_counter def check_increasing_numbers(number_list...
fbd7afe059c5eb0b6d99122e46b1ddbcaac18de0
hammer-spring/PyCharmProject
/pythion3 实例/30_list常用操作.py
1,680
4.1875
4
print("1.list 定义") li = ["a", "b", "mpilgrim", "z", "example"] print(li[1]) print("2.list 负数索引") print(li[-1]) print(li[-3]) print(li[1:3]) print(li[1:-1]) print(li[0:3]) print("3.list 增加元素") li.append("new") print(li) li.insert(2,"new") print(li) li.extend(["two","elements"]) print(li) print("4.list 搜索") a = li.ind...
7ea2b18c1371846f59f41193d89a7480c08351fc
hammer-spring/PyCharmProject
/11_线程/17.py
311
3.703125
4
import threading import time def func(): print("I am running.........") time.sleep(4) print("I am done......") if __name__ == "__main__": t = threading.Timer(6, func) t.start() i = 0 while True: print("{0}***************".format(i)) time.sleep(3) i += 1
3a4377cb8dfe546ebb09bfef38f2fc5c2ae24f68
hammer-spring/PyCharmProject
/01-python基础/2-OOP/01.py
806
3.734375
4
''' 定以一个学生类,用来形容学生 ''' # 定义一个空的类 class Student(): # 一个空类,pass代表直接跳过 # 此处pass必须有 pass # 定义一个对象 mingyue = Student() # 在定义一个类,用来描述听Python的学生 class PythonStudent(): # 用None给不确定的值赋值 name = None age = 18 course = "Python" # 需要注意 # 1. def doHomework的缩进层级 # 2. 系统默认由一个self参数 def d...
029c38ddbc3acc9025050bb84b6fc7661cd8a088
hammer-spring/PyCharmProject
/07_图像处理-pillow/12.2.py
1,404
3.5625
4
from tkinter import * import tkinter.filedialog from PIL import Image #创建主窗口 win = Tk() win.title(string = "图像文件的属性") #打开一个[打开旧文件]对话框 def createOpenFileDialog(): #返回打开的文件名 filename = myDialog.show() #打开该文件 imgFile = Image.open(filename) #填入该文件的属性 label1.config(text = "format = " + imgFile.for...
3a09ac22c92a4c6403f1e92f7dcbaf4a980bb887
hammer-spring/PyCharmProject
/数据挖掘/基于SVM算法的手写数字识别系统/03_核转换函数.py
1,048
3.609375
4
#核转换函数 def kernelTrans(X, A, kTup): # calc the kernel or transform data to a higher dimensional space m, n = shape(X) K = mat(zeros((m, 1))) if kTup[0] == 'lin': K = X * A.T # linear kernel elif kTup[0] == 'rbf': for j in range(m): deltaRow = X[j, :] - A K[j] = ...
99a4589ac6adbe80b7efc1a04fd9761892d09deb
hammer-spring/PyCharmProject
/18-Spider/v23.py
986
4.125
4
''' python中正则模块是re 使用大致步骤: 1. compile函数讲正则表达式的字符串便以为一个Pattern对象 2. 通过Pattern对象的一些列方法对文本进行匹配,匹配结果是一个Match对象 3. 用Match对象的方法,对结果进行操纵 ''' import re # \d表示以数字 # 后面+号表示这个数字可以出现一次或者多次 s = r"\d+" # r表示后面是原生字符串,后面不需要转义 # 返回Pattern对象 pattern = re.compile(s) # 返回一个Match对象 # 默认找到一个匹配就返回 m = pattern.match("one12two2three3") ...
456c580d8fea29eee70b8e417cb5eccfb9431210
hammer-spring/PyCharmProject
/pythion3 实例/9_判断奇数偶数.py
299
3.84375
4
while True: try: num=int(input('输入一个整数:')) #判断输入是否为整数 except ValueError: #不是纯数字需要重新输入 print("输入的不是整数!") continue if num%2==0: print('偶数') else: print('奇数') break
fc93851b1d48839215c48b9e6434d0dd890ef028
hammer-spring/PyCharmProject
/06_Tkinter/6.34 创建命令型单选按钮.pyw
1,263
3.734375
4
from tkinter import * #创建主窗口 win = Tk() #运动项目列表 sports = ["棒球", "篮球", "足球", "网球", "排球"] #将用户的选择,显示在Label控件上 def showSelection(): choice = "您的选择是:" + sports[var.get()] label.config(text = choice) #读取用户的选择值,是一个整数 var = IntVar() #创建单选按钮 radio1 = Radiobutton(win, text=sports[0], variable=var,value=0,command=show...
1a1c4576569d277cb166a2bb1dd81a5866b40114
hammer-spring/PyCharmProject
/06_Tkinter/6.11 place()方法.py
578
3.890625
4
from tkinter import * # 主窗口 win = Tk() # 创建窗体 frame = Frame(win, relief=RAISED, borderwidth=2, width=400, height=300) frame.pack(side=TOP, fill=BOTH, ipadx=5, ipady=5, expand=1) # 第1个按钮的位置在距离窗体左上角的(40, 40)坐标处 button1 = Button(frame, text="Button 1") button1.place(x=40, y=40, anchor=W, width=80, height=40) # 第2个按钮的位...
e4739836cd7ea6d249d79245517aeebe143bb502
rylanlee/glakemap-dev
/glakemap/dirext/dirextmngmt.py
2,424
3.5
4
import os import zipfile class DirMngmt(object): """1) Creates folders and unzip files containing zip extension 2) Read '.safe' file and process SAR data """ def __init__(self, main_dir, subfolder_1, subfolder_2, subfolder_3): """Note: Give 'subfolder_1' name and folder containing S...
b24fbc344986a78340a95cb32da676f9d7a5b248
muneermohd9690/Remove_Vowels
/Troll_Optimizer.py
428
3.6875
4
# This website is for losers LOL!" would become "Ths wbst s fr lsrs LL import re vowels = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') def find_vowels(s, v): #s = s.casefold() newstring = s for x in s: if x in v: newstring = newstring.replace(x, "") print("Optimize...
8af5abe525f744858cddc9e5cb5746ccc3d997d3
CDinuwan/PyUnitTesting
/Unit.py
221
3.828125
4
def add(x, y): return x + y def substract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: print("Cannot devide by zero") return x / y print(add(4, 5))
6b780c850343264c10ee5de6dd2856132dda26e0
Apisk1991/LearnPyton
/Основы pyton/1/HumanDate.py
481
3.90625
4
# Задание по переводу секунд в минуты, часы, дни # 1 min 60 sec # 1 hour 3600 seconds # 1 day 86400 seconds dur = int(input('Введите число')) if dur >= 86400: day = dur // 86400 dur = dur % 86400 print(day, "дн. ") if dur >= 3600: hour = dur // 3600 dur = dur % 3600 print(hour, "час. ") if du...
75cb43a2a144fed4334ea1693c8cc9d0d56cbca5
francliu/mmseg
/core/Chunk.py
1,133
3.546875
4
#encoding:utf-8 class Chunk(object): def __init__(self, *words): self.words = [] for word in words: if len(word) == 0: continue self.words.append(word) #计算chunk的总长度 def total_word_length(self): length = 0 for word in self.words: ...
2b02e816299308c0a6402507f38e2c1fb974ea8d
Mrs-Jekel/Python_exercises
/homework1_6_20.py
240
3.9375
4
list = [3, 6, 8, 2, 34, 379, 98, 7, 355, 6, 73] list.sort() print(list) def find(sorted_list, num_to_find): for i in list: if i == num_to_find: return True print(i) return False print(find(2, 5))
cca9af58b9bde01d82a61f36f3de3986f01157c2
MariaLaveniaVikaPamukasari/Maria-Lavenia-Vika-Pamukasari_I0320056_Tiffany-Bella-Nagari_Tugas4
/I0320056_soal4.py
852
3.90625
4
# Program Pengujian Spesifikasi Kursus Mobil Online #Mulai print("\t\t\tSelamat datang di Mobiline") print("\t\t\tBelajar bisa,Bisa belajar,Saya bisa") a = input("\nSiapakah nama Anda? :") print("Nama Anda adalah",a) b = int(input("Berapa usia Anda? :")) print("Usia Anda adalah",b,"tahun") if b < 21 : print("\nMaa...
878cc1191155aa1265e6d6b591dcffc7ec9a898c
ursaMaj0r/python-csc-125
/Snippets/image-manipulation-1/color_tinting.py
850
3.578125
4
from PIL import Image # prompt for file name = input("File name: ") red_tint = int(input("Red tint: ")) green_tint = int(input("Green tint: ")) blue_tint = int(input("Blue tint: ")) img = Image.open(name) # split into 3 profiles red, green, blue = img.split() # for each pixel, subtract value from 255 for y in range...
1dc0538ba1efe1d972174d4daced83826d6d0979
ursaMaj0r/python-csc-125
/Snippets/Intro/speaker_backwards.py
111
3.953125
4
# input input_text = input("Line: ") # response for letter in reversed(input_text): print(letter, end='')
6d91127f84a5a041282cda7d0ae8db27e453e0f6
ursaMaj0r/python-csc-125
/Snippets/intro-1/how_many_words.py
224
3.796875
4
# input input_words = [] input_word = input("Word: ") # reponse while input_word != '': input_words.append(input_word) input_word = input("Word: ") print("You know {} unique word(s)!".format(len(set(input_words))))
63d2067421dcbba6c72de3e7827eb61a1c9a4aed
ursaMaj0r/python-csc-125
/Snippets/code-gym-1/compare_two_numbers.py
280
4.09375
4
# prompt number = int(input("Enter a number: ")) anotherOne = int(input("Enter another number: ")) # response if number > anotherOne: print("{0} is greater than {1}.".format(number, anotherOne)) else: print("{0} is less than or equal to {1}.".format(number, anotherOne))
29bef0572e2a646e9a639494d3f826ae66f34d93
ursaMaj0r/python-csc-125
/Snippets/intro-2/bombs_away.py
283
4
4
guess = input('Guess: ') guesses = set() while guess != "": # check if in set if guess not in guesses: print("Hit {}".format(guess)) guesses.add(guess) else: print("You've chosen that square already") # reprompt guess = input('Guess: ')
cff034359b7f5bb521b3c92817db6cf01b32c61e
ursaMaj0r/python-csc-125
/Snippets/code-gym-1/hello_hello_hello.py
135
3.859375
4
# prompt word = input("What did you say? ") print("{0}".format(word)) print("{0} {0}".format(word)) print("{0} {0} {0}".format(word))
398205a1297308d15a1dda69775740c131fbd721
ursaMaj0r/python-csc-125
/Snippets/intro-2/maths_mix.py
175
4
4
# input num1 = int(input("Number 1: ")) num2 = int(input("Number 2: ")) # response print(num1, "plus", num2, "is", (num1+num2)) print(num1, "times", num2, "is", (num1*num2))
3db2e66a966211e9d81e46d5a55cb44419ab4259
ursaMaj0r/python-csc-125
/Snippets/intro-1/up_the_downstair.py
178
4.0625
4
# input input_steps = int(input("How many steps? ")) step = 1 # reponse print("__") while step < input_steps: print(" "*2*step + "|_") step += 1 print("_"*2*step + "|")
0b1a1ec8e2a093a30358e8d544fcb0eb7d734867
slagtkracht/data-processing
/homework/week_1/moviescraper.py
4,828
3.828125
4
#!/usr/bin/env python # Name: Rosa Slagt # Student number: 11040548 """ This script scrapes IMDB and outputs a CSV file with highest rated movies. """ import csv from requests import get from requests.exceptions import RequestException from contextlib import closing from bs4 import BeautifulSoup TARGET_URL = "https:/...
d1cd9f83c1fa3ab54128aacfbdf1bc25d2f3c14e
dvaage/PHYS202-S14
/iPython/mymodule.py
164
3.53125
4
#demonstrationn of modules def add_numbers(x,y): """add x and y""" return x + y def subtract_numbers(x,y): """substract y from x""" return x - y
cf4cb4471c6a75f14207422340fed49f049be790
brayanarroyo/Automatas2
/triangulo.py
785
3.921875
4
#Nombre: triangulos.py #Objetivo: determinar tipo de triangulo con su perimetro #Autor: Arroyo Chávez Brayan Alberto #Fecha: 01/07/2019 def determinarTipo(l1,l2,l3): if (l1 == l2 and l1 ==l3): return "Triangulo equilatero" elif ((l1 == l2 and l3!= l1) or (l1 == l3 and l1 !=l2) or (l2 == l3 and l2!=l1)...
16de2e7de7cbfa9a4e206e143a970ab581307345
brayanarroyo/Automatas2
/fibonacci.py
373
3.890625
4
#Nombre: fibonacci.py #Objetivo: calcula la serie de fibonacci #Autor: Arroyo Chávez Brayan Alberto #Fecha: 01/07/2019 def fibonacci(n,f1,f2,b): if(b==1): print("1") if (n!=1): fn=f1 + f2 f1=f2 print(fn) fibonacci(n-1,f1,fn,0) def main(): num = int(input("Ingrese u...
16021ebd861f8d23781064101d52eba228a6f800
mldeveloper01/Coding-1
/Strings/0_Reverse_Words.py
387
4.125
4
""" Given a String of length S, reverse the whole string without reversing the individual words in it. Words are separated by dots. """ def reverseWords(s): l = list(s.split('.')) l = reversed(l) return '.'.join(l) if __name__ == "__main__": t = int(input()) for i in range(t): string = str(i...
51814edad633fa6b47cde948d3e8aae77d38353d
mldeveloper01/Coding-1
/Strings/4_Check_String_Rot.py
450
3.75
4
""" Given two strings a and b. The task is to find if a string 'a' can be obtained by rotating another string 'b' by 2 places. """ def areSame(a, b): x = a[2:]+a[:2] y = a[-2]+a[:-2] print(x, y) if b == x or b == y: return 1 else: return 0 if __name__ == "__main__": t = int(inpu...
50e3656d0540cd6ed8fe02aa73d24923d1096862
mldeveloper01/Coding-1
/Strings/5_Roman_to_Int.py
619
3.890625
4
""" Given an string in roman no format (s) your task is to convert it to integer .Given an string in roman no format (s) your task is to convert it to integer . """ def RomantoInt(s): romans = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} value = romans[s[-1]] for i in range(len(s) - 1): if ...
f56cd3726af9261337bf475cfc309c97ad0c2bd9
mldeveloper01/Coding-1
/sudoku.py
1,807
3.78125
4
# Solving Sudoku by Backtracking import numpy as np mat = [] # mat = [ # [7,8,0,4,0,0,1,2,0], # [6,0,0,0,7,5,0,0,9], # [0,0,0,6,0,1,0,7,8], # [0,0,7,0,4,0,2,6,0], # [0,0,1,0,5,0,9,3,0], # [9,0,4,0,6,0,0,0,5], # [0,7,0,3,0,0,0,1,2], # [1,2,0,0,0,7,4,0,0], # [0,4,9,2,0,6,0,0,7] # ] #...
b872799531e4406c213af6582cf5cb706184186c
LiaoTingChun/python_fundamental
/ch9_sort.py
483
3.765625
4
# select students with 2nd high score def second_highest(students): if len(students) < 2: print("Need at least 2 students!") else: sorted_score = sorted([score[1] for score in students], reverse = True) second_score = sorted_score[1] for student in students: if stude...
52ce0b5051d3cf5643af5b121f2b1e5dc18ed52a
wayayastone/encrypt
/myencrypt.py
8,069
4
4
# -*- coding: utf-8 -*- import sys import pyDes from pyDes import * import binascii #凯撒加密 def Caesar(text, x): x = int(x) encode = '' for ch in text: encode = encode + chr((ord(ch) - ord('a') + x) % 26 + ord('a')) print(('右移'+str(x)+'位,Caesar密文为:'+encode).decode('utf-8')) #凯撒解密 def DeCaesar(tex...
5da38300cd8c406f1b1b8a40bbfdf6b1e318f314
HanhengHe/NeuralNetworks
/BasicNN/basicNN.py
7,472
3.609375
4
# -*- coding: UTF-8 -*- import numpy as np from math import exp # basic neural network # which means only one hidden layer available # parameters # active function def Sigmoid(X): return 1 / (1 + exp(-X)) # low memory require Predictor class Predictor: def __init__(self, labelsName, HLSize, outputSize...
a1c860865ec2611b532dcf6783432e253a002c00
piyushaga27/Criminal-record
/criminal_record.py
3,690
3.890625
4
#criminal data import pandas as pd import matplotlib.pyplot as plt df=pd.read_csv('criminal_data.csv',sep=',') rew=list(df['reward']) nme=list(df['name']) city=list(df['city']) city_dict={} for i in city: city_dict[i]=city.count(i) def allData(): print('All Data is:') print('='*50) ...
13563d927a4adb1a45b0bcf7b9501df715a8b801
agalyaswami/datastructures
/delete singly.py
1,375
3.71875
4
class node: def __init__(self,data): self.data=data self.next=None class slinkedlist: def __init__(self): self.head=None def atbeginning(self,data_in): newnode=node(data_in) newnode.next=self.head self.head=newnode def removenode(self,removekey): h...
6505aa61ab8755e17c720c24691524ede1890632
TrevorCap/Python
/PyBank/Main.py
1,605
3.5625
4
import os import csv csvpath = os.path.join('budget_data.csv') with open(csvpath, newline="") as budget: csvreader = csv.reader(budget, delimiter=",") budget.readline() total = 0 rows = 0 MaxV = 0 MaxD = "" MinV = 0 MinD = "" change = 0 Taverage = 0 val1 = 0...
ff75931a0dd9ed44b400bd128f0b696a912f2a6f
SimplyAhmazing/go-board-game
/tests/test_piece.py
2,368
3.640625
4
import unittest from utils import create_board_from_str from colors import Color from piece import Piece class PieceTestCase(unittest.TestCase): def setUp(self): self.white_piece = Piece(Color.white, (0,0), None) self.black_piece = Piece(Color.black, (0,0), None) def test_piece_as_str(self):...
f02766bc5853123e4f99c4501e4dce2506fe6a11
adamgreig/basebandboard
/gateware/bbb/rng.py
6,957
3.546875
4
""" Generate random numbers. Copyright 2017 Adam Greig """ import numpy as np from functools import reduce from operator import xor from migen import Module, Signal from migen.sim import run_simulation class LUTOPT(Module): """ Generates uniform random integers according to the given binary recurrence. ...
c1980126338e9c410c4c4d7cf46613a25bddba5f
rolkotaki/PythonForML
/loading_data/load_csv.py
438
3.65625
4
import pandas path = 'fruits.csv' # loading the CSV file dataframe = pandas.read_csv(filepath_or_buffer=path, sep=',', skip_blank_lines=True) # header=None # It has many parameters! print(dataframe.head(2)) # returns the first n rows; -1 --> except the las...
f4790912e0569ccd3954c0208c88477ecc6f33d4
rolkotaki/PythonForML
/logistic_regression.py
5,554
3.90625
4
import numpy as np from sklearn.linear_model import LogisticRegression, LogisticRegressionCV from sklearn import datasets from sklearn.preprocessing import StandardScaler # Training a Binary Classifier iris = datasets.load_iris() features = iris.data[:100, :] target = iris.target[:100] # Standardize features scaler ...
01bc8bc47ea5ecc7656e731b5ec007049efc4888
faantoniadou/Computer-Simulation
/CP1.py
2,962
3.96875
4
''' Polynomial Class ''' from operator import add class Polynomial(object): coeffs = [] def __init__(self, coeffs): """ Constructor to form a polynomial """ self.coeffs = coeffs def order(self): """ Method to return order of polynomial """ ...
0053bde8153d3559f824aed6a017c528410538ea
JaredD-SWENG/beginnerpythonprojects
/3. QuadraticSolver.py
1,447
4.1875
4
#12.18.2017 #Quadratic Solver 2.4.6 '''Pseudocode: The program is designed to solve qudratics. It finds it's zeros and vertex. It does this by asking the user for the 'a', 'b', and 'c' of the quadratic. With these pieces of information, the program plugs in the variables into the quadratic formula and the formula...
b8d23be3ed6ea8a2c50c939df0c15b80269be0da
LajosNeto/algorithms-n-more
/data-structures-algorithms/data-structures/stack/python/stack.py
1,313
4.09375
4
""" Stack data structure implementation based on linked lists """ # Author: # Lajos Neto <lajosnetogit@gmail.com> class _Node: """ Simple node used for representing values inside the stack. """ def __init__(self, value): self.value = value self.next = None class Stack: ...
21ebc7c9197a4effdaa167dd49d107d463b230d2
LajosNeto/algorithms-n-more
/data-structures-algorithms/data-structures/tree/bst/python/bst_test.py
6,355
3.578125
4
# bst_test.py # # Binary Tree (BST) implementation tests # # author Lajos Onodi Neto import sys import unittest from bst import Bst class BstTest(unittest.TestCase): def __init__(self, *args, **kwargs): super(BstTest, self).__init__(*args, **kwargs) self.bst = Bst() def test_insert(self)...
d5042d0f20d97b4557e967ae7a68bcb30cdfcd06
sujmkim/Shop
/fruit_store.py
2,610
3.515625
4
#USM2-Assgn-8 class FruitInfo: __fruit_name_list = ["Apple", "Guava", "Orange", "Grape", "Sweet Lime"] __fruit_price_list = [200, 80, 70, 110, 60] @staticmethod def get_fruit_price(fruit_name): if(fruit_name in FruitInfo.__fruit_name_list): index = FruitInfo.__fruit_name...
75e596334f33547dde5c94853d17360ae284042d
bekasov/PyQtFftAnalyzer
/Resources/_examples/DataCursor.py
2,391
4.03125
4
# -*- noplot -*- """ This example shows how to use matplotlib to provide a data cursor. It uses matplotlib to draw the cursor and may be a slow since this requires redrawing the figure with every mouse move. Faster cursoring is possible using native GUI drawing, as in wxcursor_demo.py. The mpldatacursor a...
e3d8c4a067cb6598b25756f109b3ea5807bd297e
Pooja1826/tathastu_week_of_code
/day1/program3.py
212
3.984375
4
num1=int(input("Enter first number: ")) num2=int(input("Enter second number: ")) num1 = num1+num2 num2= num1-num2 num1= num1-num2 print("After Swapping") print("Value of num1:",num1) print("Value of num2:",num2)
a01a2492929251aec7dc00154e1dc5824266a72a
davidcviray/lis161
/Exercise9-10_FileReadSpamConfidence-EasterEgg.py
465
3.671875
4
filename = input("Enter the file name: ") if filename=="na na boo boo": print('Here is a funny message') else: fhand = open(filename + ".txt") count = 0 average = 0 for line in fhand: line = line.rstrip() if line.startswith('X-DSPAM-Confidence:') : count = count...
bc1e27bea818066ce6e066436a82b0d3fd418a01
davidcviray/lis161
/Exercise12_MaxMinLists.py
455
3.875
4
def computemin(numbercheck): return min(numbercheck) def computemax(numbercheck): return max(numbercheck) minval = None maxval = None values = list() while True: line = input('Enter a number: ') if line == 'done' : print(computemin(values),computemax(values)) break...
7fb2fa209095f786f9e2be7ce34d8e7e28e3b7df
achutman/handpump-Aquifer-Monitoring-Lstm
/scripts/LSTMmultiInUniOut.py
5,230
3.9375
4
# -*- coding: utf-8 -*- """ Created on 29 Sep 2019 Class definition of LSTM multi input unit output framework. @author: Achut Manandhar Adapted from the following example: https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/ """ from keras.models import Sequential from...
3d3a752ddf16bc39e94945f39b7b978d5f246995
Gear-bao/Python
/dice_rolling_simulator.py
3,104
4.21875
4
#Made on May 27th, 2017 #Made by SlimxShadyx #Dice Rolling Simulator import random #These variables are used for user input and while loop checking. correct_word = False dice_checker = False dicer = False roller_loop = False #Checking the user input to start the program. while correct_word == False: user_input...
87209c89e2b29804a7cbfc1f6f283048f2bbeaaa
wellqin/USTC
/leetcode/editor/cn/[24]两两交换链表中的节点.py
3,070
4.0625
4
# 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。 # # 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 # # # # 示例: # # 给定 1->2->3->4, 你应该返回 2->1->4->3. # # # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 和链表反转类似,关键在于有三个指针,分别指向前后和当前节点。不同点是两两交换后,移动...
a39e684c2138d23efca3d207f35e60821a2305cb
wellqin/USTC
/leetcode/editor/cn/[4]寻找两个有序数组的中位数.py
8,916
3.921875
4
# -*- coding: utf-8 -*- # 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 # # 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 # # 你可以假设 nums1 和 nums2 不会同时为空。 # # 示例 1: # # nums1 = [1, 3] # nums2 = [2] # # 则中位数是 2.0 # # # 示例 2: # # nums1 = [1, 2] # nums2 = [3, 4] # # 则中位数是 (2 + 3)/2 = 2.5 # for循环遍历两个列表失败—— ValueError: too many va...
110ef73dda205d379734a6a1333c8f692a40c564
wellqin/USTC
/PythonBasic/base_pkg/python-05-flntPy-Review/fpy_05_decomp.py
1,541
3.921875
4
# normal usage names = ("ZL", "World") a, b = names print(a) print(b) a, b = divmod(10, 3) print(a) print(b) # ignore some elements local = [(1, "hello"), (2, "world"), (3, "bonjure")] for _, word in local: print(word) # ignore more t = (3, 1, 1, 0, 10) a, b, *rest = t print(a) print(b) print(rest...
c1263b660b54e5ebbf61a82535e765332c994e2a
wellqin/USTC
/Thread/多线程/13-⽣产者与消费者模式.py
3,193
3.65625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 13-⽣产者与消费者模式 Description : Author : wellqin date: 2019/9/11 Change Activity: 2019/9/11 ------------------------------------------------- """ """ Python的Queue模块中提供了同步的、线程安全的队列类,包括FIFO(先⼊先出)队列Queue,LI...
d9b8e47a7d2d0726a06fd3b203566e8c1eaca461
wellqin/USTC
/leetcode/editor/cn/[74]搜索二维矩阵.py
3,833
3.609375
4
# 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性: # # # 每行中的整数从左到右按升序排列。 # 每行的第一个整数大于前一行的最后一个整数。 # # # 示例 1: # # 输入: # matrix = [ # [1, 3, 5, 7], # [10, 11, 16, 20], # [23, 30, 34, 50] # ] # target = 3 # 输出: true # # # 示例 2: # # 输入: # matrix = [ # [1, 3, 5, 7], # [10, 11, 16, 20], # ...
62f5d3d7f50398a679a084c8c68f5a84929e20dc
wellqin/USTC
/DataStructure/堆/算法导论.py
2,816
3.5625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 算法导论 Description : Author : wellqin date: 2019/7/10 Change Activity: 2019/7/10 ------------------------------------------------- 堆排序的时间复杂度分为两个部分一个是建堆的时候所耗费的时间,一个是进行堆调整的时候所耗费的时间。而堆排序则是调用了建堆和堆调整。 刚刚在上...
5feeb8b7e5028174a702568103bdfe0ee3808f9c
wellqin/USTC
/PythonBasic/base_pkg/python-06-stdlib-review/chapter-01-Text/1.1-string/py_01_string.py
1,459
3.78125
4
""" std lib -- string ! why do I need it when I have tools like str class, format() function and % etc? :: this lib provides other tools to make advanced text manipulation simple.. ? hmm, advanced text manipulations :: I'm not aware of these manipulations... TODOS: learns advanced text manipulations. string |-- stri...
3041fd1452213bb71bfa8b21fb1704df33c6f1f7
wellqin/USTC
/PythonBasic/yield_from.py
945
3.65625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: yield_from Description : Author : wellqin date: 2020/2/11 Change Activity: 2020/2/11 ------------------------------------------------- """ from collections import namedtuple Result = namedtuple("Res...
ef0820cbaced0d6c3784e945dd11eb7daf3b430f
wellqin/USTC
/leetcode/editor/cn/[207]课程表.py
2,268
3.71875
4
#现在你总共有 n 门课需要选,记为 0 到 n-1。 # # 在选修某些课程之前需要一些先修课程。 例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹配来表示他们: [0,1] # # 给定课程总量以及它们的先决条件,判断是否可能完成所有课程的学习? # # 示例 1: # # 输入: 2, [[1,0]] #输出: true #解释: 总共有 2 门课程。学习课程 1 之前,你需要完成课程 0。所以这是可能的。 # # 示例 2: # # 输入: 2, [[1,0],[0,1]] #输出: false #解释: 总共有 2 门课程。学习课程 1 之前,你需要先完成​课程 0;并且学习课程 0 之前,你还...
5f843a653c6e85236b302276e5bb0166a2bef614
wellqin/USTC
/DataStructure/栈/二个队列实现栈.py
2,995
3.8125
4
# coding=utf-8 """ ------------------------------------------------- File Name: 二个队列实现栈 Description : Author : wellqin date: 2019/7/11 Change Activity: 2019/7/11 ------------------------------------------------- """ class Queue(object): def __init__(self): self.queue1 = [] ...
81d316841feb2f12e7afdb55b50575222e3ed1a6
wellqin/USTC
/DataStructure/二叉树/二叉树的搜索/二叉树的最左下树节点的值.py
1,039
3.640625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 二叉树的最左下树节点的值 Description : Author : wellqin date: 2020/1/31 Change Activity: 2020/1/31 ------------------------------------------------- """ # https://www.cnblogs.com/ArsenalfanInECNU/p/5346751.html ...
d5fdf34549d49cc2a0c40e70bb07641a874fa20e
wellqin/USTC
/leetcode/editor/cn/[61]旋转链表.py
2,007
3.515625
4
# 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数。 # # 示例 1: # # 输入: 1->2->3->4->5->NULL, k = 2 # 输出: 4->5->1->2->3->NULL # 解释: # 向右旋转 1 步: 5->1->2->3->4->NULL # 向右旋转 2 步: 4->5->1->2->3->NULL # # # 示例 2: # # 输入: 0->1->2->NULL, k = 4 # 输出: 2->0->1->NULL # 解释: # 向右旋转 1 步: 2->0->1->NULL # 向右旋转 2 步: 1->2->0->NULL # 向右...
2aee0d132a9bc1043c3460f310fb00f1a41e9e81
wellqin/USTC
/PythonBasic/base_pkg/python-05-flntPy-Review/fpy_03_listcomp.py
335
3.921875
4
# list comprehension symbols = '$¢£¥€¤' codes = [ord(symbol) for symbol in symbols] print(codes) # or map codes = list(map(ord, symbols)) print(codes) # implement filtering codes = [ord(symbol) for symbol in symbols if ord(symbol) > 127] print(codes) # or codes = list(filter(lambda x: x > 127, map(ord, symbols))) pri...
227465cca1abd1e78f250c5991f716f719b4fcf1
wellqin/USTC
/leetcode/editor/cn/[78]子集.py
1,448
4.03125
4
# 给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。 # # 说明:解集不能包含重复的子集。 # # 示例: # # 输入: nums = [1,2,3] # 输出: # [ # [3], #   [1], #   [2], #   [1,2,3], #   [1,3], #   [2,3], #   [1,2], #   [] # ] # from typing import List class Solution: def subsets(self, nums): # dfs or 回溯 if not nums: return [] ...
bc8b1bf4f8e8e9c03494d58c294fc7eb74a697fc
wellqin/USTC
/PythonBasic/base_pkg/python-06-stdlib-review/chapter-10-ConcurrencyWithProcessThreadsCoroutines/10.4-multiprocessing/what-does-ellipsis(3dots)-do.py
2,104
3.890625
4
""" Q: wtf is `...` in Python? A: it is `Ellipsis` object. Python > 3, using `...`, Python < 3, using `Ellipsis` Q: why the fuck do we need this? A: for showoff? i have no funcking idea. Ellipsis is just a normal object. Ellipsis itself has no special methods or properties. Official document says Ellipsis usual...
4cd4c4a1a0722f4e3c2a29493fe8bcc60114f9dc
wellqin/USTC
/PythonBasic/base_pkg/python-05-flntPy-Review/fpy_08_memoryview.py
352
3.546875
4
import array # signed short array numbers = array.array('h', [-2, -1, 0, 1, 2]) # puts the array into a memoryview memv = memoryview(numbers) # length print(len(memv)) # retrieve element print(memv[0]) # changes memv into unsinged char memv_oct = memv.cast('B') print(memv_oct.tolist()) # unsigned char -> singed short ...
b57d5f57a387a69c4b3fdd8e06e57dcf83841c8c
wellqin/USTC
/DataStructure/排序/test.py
2,001
4
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: test Description : Author : wellqin date: 2020/3/12 Change Activity: 2020/3/12 ------------------------------------------------- """ import random def insertSort(nums): pass # def partition(n...
bf217099c4cd2547f792e271d60cefcb696187ad
wellqin/USTC
/DataStructure/字符串/数字.py
1,974
4.1875
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 数字 Description : Author : wellqin date: 2019/8/1 Change Activity: 2019/8/1 ------------------------------------------------- """ import math # // 得到的并不一定是整数类型的数,它与分母分子的数据类型有关系。 print(7.5//2) # 3.0 p...
c9349ccb62462c57e247fd069636ec8eb45c370a
wellqin/USTC
/leetcode/editor/cn/[230]二叉搜索树中第K小的元素.py
2,163
3.6875
4
#给定一个二叉搜索树,编写一个函数 kthSmallest 来查找其中第 k 个最小的元素。 # # 说明: #你可以假设 k 总是有效的,1 ≤ k ≤ 二叉搜索树元素个数。 # # 示例 1: # # 输入: root = [3,1,4,null,2], k = 1 # 3 # / \ # 1 4 # \ #  2 #输出: 1 # # 示例 2: # # 输入: root = [5,3,6,2,4,null,null,1], k = 3 # 5 # / \ # 3 6 # / \ # 2 4 # / # 1 #输出: 3 # # 进阶: #如果二叉...
db0b2438e58491158c853913b3ba15fd6f8fedbe
wellqin/USTC
/leetcode/editor/cn/[782]变为棋盘.py
1,375
3.515625
4
# 一个 N x N的 board 仅由 0 和 1 组成 。每次移动,你能任意交换两列或是两行的位置。 # # 输出将这个矩阵变为 “棋盘” 所需的最小移动次数。“棋盘” 是指任意一格的上下左右四个方向的值均与本身不同的矩阵。如果不存在可行的变换,输出 -1。 # # 示例: # 输入: board = [[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]] # 输出: 2 # 解释: # 一种可行的变换方式如下,从左到右: # # 0110 1010 1010 # 0110 --> 1010 --> 0101 # 1001 0101 1010 # 1001...
c1b024fe6518776cbeaabb614ca1fa63813b02b7
wellqin/USTC
/PythonBasic/base_pkg/python-06-stdlib-review/chapter-01-Text/1.1-string/py_02_stringTemplate.py
1,422
4.1875
4
### string.Template is an alternative of str object's interpolation (format(), %, +) import string def str_tmp(s, insert_val): t = string.Template(s) return t.substitute(insert_val) def str_interplote(s, insert_val): return s % insert_val def str_format(s, insert_val): return s.format(**insert_val) ...
e4e5ae4189e9e62096b88e1d867545d3fdc0ccc5
wellqin/USTC
/DesignPatterns/creational/singleton/singleton_decorator.py
510
4.0625
4
# -*- coding:utf-8 -*- def singleton(cls): _instance = {} def _singleton(*args, **kargs): if cls not in _instance: _instance[cls] = cls(*args, **kargs) return _instance[cls] return _singleton @singleton class A(object): """ 装饰器解析 A = singleton(A) -> 此步骤返回了_singl...
3915dd867788d1553cd3827c8105be9b87196a39
wellqin/USTC
/DesignPatterns/structural/Iterator.py
1,379
3.984375
4
# -*- coding:utf-8 -*- # Iterator Pattern with Python Code from abc import abstractmethod, ABCMeta # 创建Iterator接口 class Iterator(metaclass=ABCMeta): @abstractmethod def hasNext(self): pass @abstractmethod def next(self): pass # 创建Container接口 class Container(metaclass=ABCMeta): ...
2ac4045d4fd826c4b2c69be9ed87e68c37add73a
wellqin/USTC
/leetcode/editor/cn/[143]重排链表.py
1,695
3.796875
4
# 给定一个单链表 L:L0→L1→…→Ln-1→Ln , # 将其重新排列后变为: L0→Ln→L1→Ln-1→L2→Ln-2→… # # 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 # # 示例 1: # # 给定链表 1->2->3->4, 重新排列为 1->4->2->3. # # 示例 2: # # 给定链表 1->2->3->4->5, 重新排列为 1->5->2->4->3. # Related Topics 链表 # leetcode submit region begin(Prohibit modification and deletion) # Defi...
988ab3ba48c2d279c3706a2f12224f3793182a14
wellqin/USTC
/DesignPatterns/behavioral/Adapter.py
1,627
4.21875
4
# -*- coding:utf-8 -*- class Computer: def __init__(self, name): self.name = name def __str__(self): return 'the {} computer'.format(self.name) def execute(self): return self.name + 'executes a program' class Synthesizer: def __init__(self, name): self.name = name ...
8b827e7324cb5a5d9f0f690db82f3d94403f06f4
wellqin/USTC
/DataStructure/树/travelTest.py
2,275
3.75
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: travelTest Description : Author : wellqin date: 2020/3/13 Change Activity: 2020/3/13 ------------------------------------------------- """ class Node: def __init__(self,val): self.val ...
ee8418ec927e244df1019eb7e450d6fce80b4823
wellqin/USTC
/DataStructure/二叉树/二叉树遍历/postOrder.py
2,147
4
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: postOrder Description : Author : wellqin date: 2020/1/31 Change Activity: 2020/1/31 ------------------------------------------------- """ # 构建了层序遍历: [0, 1, 2, 3, 4, 5, 6]的二叉树 class Node(object): ...
5800fa4cbb7efda4b7b1167d2524c96ab52fc3e4
wellqin/USTC
/DataStructure/链表/翻转.py
3,096
3.734375
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 翻转 Description : Author : wellqin date: 2019/9/17 Change Activity: 2019/9/17 ------------------------------------------------- """ # -*- coding: utf-8 -*- ''' 链表逆序 ''' class ListNode: def __in...
61d59949fb0089fbf3d9d71f16521fa9ebeeb02b
wellqin/USTC
/leetcode/editor/cn/[23]合并K个排序链表.py
1,174
3.78125
4
# 合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。 # # 示例: # # 输入: # [ #   1->4->5, #   1->3->4, #   2->6 # ] # 输出: 1->1->2->3->4->4->5->6 # import collections # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeKLists(self, ...
6148139a20c2643f6b94e3be310b5a7561da8da9
wellqin/USTC
/leetcode/editor/cn/[54]螺旋矩阵.py
2,324
3.984375
4
# 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 # # 示例 1: # # 输入: # [ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] # ] # 输出: [1,2,3,6,9,8,7,4,5] # # # 示例 2: # # 输入: # [ # [1, 2, 3, 4], # [5, 6, 7, 8], # [9,10,11,12] # ] # 输出: [1,2,3,4,8,12,11,10,9,5,6,7] # # Related Topics 数组 # leetcode submit region beg...
202e163898f01680e454e3d2833053e694486fef
wellqin/USTC
/leetcode/editor/cn/[394]字符串解码.py
1,316
3.59375
4
#给定一个经过编码的字符串,返回它解码后的字符串。 # # 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次。注意 k 保证为正整数。 # # 你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。 # # 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像 3a 或 2[4] 的输入。 # # 示例: # # #s = "3[a]2[bc]", 返回 "aaabcbc". #s = "3[a2[c]]", 返回 "accaccacc". #s = "2[abc]3[cd]ef"...
660d95c531d49f25f00f7c7db961578f90d7aed1
wellqin/USTC
/leetcode/editor/cn/[257]二叉树的所有路径.py
1,778
3.796875
4
# 给定一个二叉树,返回所有从根节点到叶子节点的路径。 # # 说明: 叶子节点是指没有子节点的节点。 # # 示例: # # 输入: # # 1 # / \ # 2 3 # \ # 5 # # 输出: ["1->2->5", "1->3"] # # 解释: 所有根节点到叶子节点的路径为: 1->2->5, 1->3 # # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # se...
f3dfaccab0fda2249b97371e524960fa89a7c245
wellqin/USTC
/open_source/funcy/funcy_demo.py
347
3.578125
4
# -*- coding:utf-8 -*- """ https://github.com/Suor/funcy """ from itertools import count from pprint import pprint import funcy as fc """Sequences""" item = [1, 2, 3] def sequences_generate(): pprint([item] * 3) pprint(item * 3) # pprint(list(map(lambda x: x ** 2, count(1)))) if __name__ == "__main__"...
fb536fe2658f763ed392f61917ea0960a77e7a64
wellqin/USTC
/DataStructure/队列/链表实现队列.py
1,822
3.625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 链表实现队列 Description : Author : wellqin date: 2019/7/11 Change Activity: 2019/7/11 ------------------------------------------------- """ class QueueError(ValueError): def __init__(self, text='队列为...
517e45cb3695fbf5c8cb545f5128f5e99e5f01c8
wellqin/USTC
/leetcode/editor/cn/[35]搜索插入位置.py
1,957
3.859375
4
# 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 # # 你可以假设数组中无重复元素。 # # 示例 1: # # 输入: [1,3,5,6], 5 # 输出: 2 # # # 示例 2: # # 输入: [1,3,5,6], 2 # 输出: 1 # # # 示例 3: # # 输入: [1,3,5,6], 7 # 输出: 4 # # # 示例 4: # # 输入: [1,3,5,6], 0 # 输出: 0 # 【1, 3, 5, 6】,target=2, nums[mid]=3, 终于想明白了:当nums[mid]>target, # 表...
1c3f394f36cccb7a009572700d25228070e85967
wellqin/USTC
/leetcode/editor/cn/[926]将字符串翻转到单调递增.py
3,130
3.625
4
# 如果一个由 '0' 和 '1' 组成的字符串,是以一些 '0'(可能没有 '0')后面跟着一些 '1'(也可能没有 '1')的形式组成的,那么该字符串是单调 # 递增的。 # # 我们给出一个由字符 '0' 和 '1' 组成的字符串 S,我们可以将任何 '0' 翻转为 '1' 或者将 '1' 翻转为 '0'。 # # 返回使 S 单调递增的最小翻转次数。 # # # # 示例 1: # # 输入:"00110" # 输出:1 # 解释:我们翻转最后一位得到 00111. # # # 示例 2: # # 输入:"010110" # 输出:2 # 解释:我们翻转得到 011111,或者是 ...
5418a6f0c7d57b28dceac134cc4f7c0332573857
wellqin/USTC
/leetcode/editor/cn/[169]求众数.py
400
3.578125
4
#给定一个大小为 n 的数组,找到其中的众数。众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素。 # # 你可以假设数组是非空的,并且给定的数组总是存在众数。 # # 示例 1: # # 输入: [3,2,3] #输出: 3 # # 示例 2: # # 输入: [2,2,1,1,1,2,2] #输出: 2 # # class Solution: def majorityElement(self, nums: List[int]) -> int:
9b91add0752b364855c9ecfa06cea14faff8f1c6
wellqin/USTC
/Interview/快手/验证ip地址.py
1,420
3.515625
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 验证ip地址 Description : Author : wellqin date: 2019/9/16 Change Activity: 2019/9/16 ------------------------------------------------- """ # 验证ip地址 import sys class Solution: def vaild_ipaddr(self, s...
869249517b832ef71fc07a9b1c59bae4e6f8123a
wellqin/USTC
/PythonBasic/base_pkg/python-06-stdlib-review/chapter-18-LanguageTools/py_01_dis.py
259
3.625
4
import dis def fib(n): r = [0, 1] if n < 2: return r[n] else: for i in range(2, n + 1): r.append(r[i-1] + r[i-2]) return r[n] # print(fib(3)) if __name__ == "__main__": dis.dis(fib) dis.show_code(fib)