blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
11123bbab0f9f4e4f939cc86b1ce235330b1caed
ChWeiking/PythonTutorial
/Python基础/day03(运算、if判断、循环)/demo/02_if语句/07_if判断复习.py
886
3.609375
4
import random com = random.randint(0,2) players = input('输入:(剪刀 石头 布):') # dicts = {1:'剪刀',2:"石头",3:'布'} mylist = ('剪刀',"石头",'布') if players not in mylist: print('输入的东西不太对!') else: print('你:%s 它:%s'%(players,mylist[com])) if players == mylist[com]: print('平手呢!') else: if players == ...
35f60514ec8786b329995344a6bc3e838c3eb046
ChWeiking/PythonTutorial
/Python基础/day11(继承、多态、类属性、类方法、静态方法)/demo/01_继承/02_覆盖重写.py
2,862
4.34375
4
''' 子类和父类都有相同的属性、方法 子类对象在调用的时候,会覆盖父类的,调用子类的 与参数无关,只看名字 覆盖、重写: 扩展功能 ''' class Fu(object): def __init__(self): print('init1...') self.num = 20 def sayHello(self): print("halou-----1") class Zi(Fu): def __init__(self): print('init2...') self.num = 200 def sayHello(self): print("halou-----2") ...
a2a4481984ab02aa0ef7cfcd031b58df618dba0f
ChWeiking/PythonTutorial
/Python基础/day06(字符串、函数)/demo/01_字符串/02_常用功能.py
4,474
3.6875
4
''' find 从左面找第一次出现的位置 rfind 从右面找第一次出现的位置 找不到返回-1 index rindex 功能和find一样,但是找不到会报错,一般不用 下标依然从左面0开始 ''' info = '今天,中华人民共和国今天终于成立中国啦' sub_info = '今天' index1 = info.find(sub_info) print(index1) index1 = info.find(sub_info,-9,-1) print(index1) index1 = info.find(sub_info,3) print(index1) index1 = info.rfind(sub_in...
782d959a221631b777677fd9528059ab9bf0913c
ChWeiking/PythonTutorial
/Python高级/day40(算法整理回顾)/demo/01_几种排序算法/03.选择排序.py
297
3.5625
4
def selection_sort(list2): for i in range(0, len (list2)): min = i for j in range(i + 1,len(list2)): if list2[j] < list2[min]: min = j list2[i], list2[min] = list2[min], list2[i] if __name__ == '__main__': ls = [11,22,88,66,77,99,44,55,33] selection_sort(ls) print(ls)
91e720afd1e2680f41f518ee32ac548300dc1b2a
ChWeiking/PythonTutorial
/Python基础/day04(while循环、列表)/demo/01_while循环/02_九九乘法表.py
309
3.515625
4
''' 九九乘法表 n*m=结果 ''' m = 1 #第几次循环,第几行 n = 1 #这一行,打印几次 while m<10: while n<=m: print('%sx%s=%s\t'%(n,m,m*n),end='') n+=1 print('') n=1 m+=1 ''' print('老王',end='') print('旺财') ''' ''' print('老王\t旺财') \n换行 \t制表位 '''
2311416d1a66e4362b9f966edf4cf74a92990fdf
ChWeiking/PythonTutorial
/Python基础/day06(字符串、函数)/demo/练习/day_06.py
1,895
3.5
4
''' a = '窗前明月光\n疑是地上霜\n举头望明月\n低头思故乡' print(a) print(len(a)) #b = ''' #窗前明月光 #疑是地上霜 #举头望明月 #低头思故乡 ''' print(b) print(len(b)) name = '老王' print(name) name = '老\t王' print(name) name = '老\\t王' print(name) name = '"老王"' print(name) name = '\'老王\'' print(name) print('A\t'*10) ''' ''' a = 'abcdfauiyapflj' a = a.split('a')...
70c3af5be6a4a3684e5a6b761dbb18230ae04022
ChWeiking/PythonTutorial
/Python基础/day04(while循环、列表)/demo/练习/01_集合容器多项方法.py
1,481
3.875
4
''' list = [1,2,3,4,5,6] list.append(3) print(list) lala = list.index(3) print(lala) print(list[5]) print(list.count(3)) lenth = len(list) print(lenth) print(max(list),min(list)) list.insert(1,9) print(list) list.extend([10,12,15]) print(list) aaa = [1,2,'nihao',3,[11,14,15,['老王'],18]] print(aaa[4][3]) ''' ''' ...
f895be8e15f66b241820646ff499bc41e5b2a117
ChWeiking/PythonTutorial
/Python基础/day10(私有化、魔法方法del、类的继承)/demo/03_继承/03_多继承.py
399
3.921875
4
''' python支持多继承。 一个类可以有多个父类 ''' class Donkey: def f1(self): print('Donkey。。。') class Horse: def f2(self): print('Horse。。。') class Mule(Donkey,Horse): def f3(self): print('Mule。。。') mule = Mule() print(dir(mule)) mule.f1() mule.f2() mule.f3() ''' 基类(父类) 派生类(子类) ''' print(Mule.__bases__) print(Mule...
1106b6b68f093954c719f72f0f5e5244b4368dda
ChWeiking/PythonTutorial
/Python基础/day02(注释、变量、运算符)/demo/04_运算符/运算符.py
792
3.859375
4
num1 = 10 num2 = 20 #算术运算 ret = num1+num2 print(ret) str1 = 'a' str2 = 'b' #字符串拼接 ret = str1+str2 print(ret) num1 = 10 num2 = 20 #算术运算 ret = num1*num2 print(ret) print('--------------------------------') print('-'*20) print(2**4) #结果是浮点型 print(10/2) print(10/3) print(10/4) print('-'*20) #取余 print(10%2) print(10%3) ...
f2bedd9135dddbeb2dfc022b3c5ee00572e2c7a6
ChWeiking/PythonTutorial
/Django/day58(回顾整理)/demo/01_python写的cgi脚本部分代码.py
3,227
3.765625
4
''' 什么是Web框架? Django是一个卓越的新一代Web框架,而使用Django 这个web框架的意义是什么呢? 要回答这个问题,让我们来看看通过编写标准的CGI程序来开发Web应用,这在大约1998年的时候非常流行。 编写CGI Web应用时,你需要自己处理所有的操作,就像你想烤面包,但是都需要自己生火一样。 下面是实例,一个简单的CGI脚本,用Python写的,读取数据库并显示最新发布的十本书: ''' #!/usr/bin/python import MySQLdb print "Content-Type: text/html" print print "<html><head><title>Books</...
28624d6b4fe400671cec84c3b57ff5948db2a323
ChWeiking/PythonTutorial
/Python高级/day38(算法)/demo/02_二叉树_广度优先.py
2,028
4.1875
4
class MyQueue(object): """队列""" def __init__(self): self.items = [] def is_empty(self): return self.items == [] def enqueue(self, item): self.items.insert(0,item) def dequeue(self): """出队列""" return self.items.pop() def size(self): """返回大小""" ...
46a4b5fac21253cff9e24012c4c6a5d1053f65f0
ChWeiking/PythonTutorial
/Python基础/day05(集合容器、for循环)/demo/02_tuple/01_tuple.py
555
4.28125
4
''' 元组:是用小括号的 ''' directions = ('东','西','南','北','中') print(directions) print(directions[1]) print('*'*20) t1 = (1,2,3) #t1[0]=2 t2 = ([1,2,3],110,'120',(1,2,3)) t2[0].append(110) print(t2) ''' 列表和元组相互转换 ls = list(元组) tu = tuple(列表) ''' ls = [1,2,3] print(type(ls)) print(ls) tu = tuple(ls) print(type(tu)) pr...
6b2294cc8c6d68c6aaed002c3ddc90f5d9060ae8
ChWeiking/PythonTutorial
/Python基础/day03(运算、if判断、循环)/demo/练习/02_判断是否为闰年.py
456
3.71875
4
''' if: 条件语句1……………… 条件语句2……………… else: 条件语句a 条件语句b ……………… 注意: 1.if else 后面都需要有冒号 2.if条件语句中只存在真True或者假False 3.条件语句要进行缩进 ''' read = int(input('请输入年份:')) if ((read%4==0) and (read%100!=0)) or (read%400==0): print('%d是闰年'%(read)) else: print('%d不是闰年'%(read)) print('判断结束')
15ed26f5268192a2b767cd372ac3401a3a70bbbe
ChWeiking/PythonTutorial
/Python基础/day02(注释、变量、运算符)/demo/练习/02_类型转化.py
337
3.9375
4
#类型转化 a = 1 b = float(a) print(b) print(type(b)) a = 1 b = str(a) print(b) print(type(b)) a = 1 b = bool(a) print(b) print(type(b)) a = 1.1 b = int(a) print(b) print(type(b)) a = 1.1 b = bool(a) print(b) print(type(b)) a = 1.1 b = str(a) print(b) print(type(b)) a = '12.3' a = float(a) b = int(a) print(b) print(t...
251b26428c895b27abb3e0db7ff0316e5bc8a7e1
Filjo0/PythonProjects
/Ch3.py
2,197
4.25
4
""" Chapter 3. 11. In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on. A little mathematical analysis re...
3cd6ff12af16a6a3d672cad425a9df0d398cedb1
lslewis1/Python-Labs
/Week 5 Py Labs/Seconds converter.py
747
4.21875
4
#10/1/14 #This program will take a user input of a number of seconds. #The program will then display how many full minutes, hours, days, and leftover seconds there are #ts is the input of seconds #s1 is the leftover seconds for the minutes #s2 is the seconds for hours #s3 is the seconds for days #m is the numb...
c46d80d326ba0b65ca97c0679faa2e50aa384371
lslewis1/Python-Labs
/Week 5 Py Labs/BMI.py
530
4.34375
4
#10/1/14 #This program will determine a person's BMI #Then it will display wheter the person in optimal weight, over, or under #bmi is the body mass indicator #w is the weight #h is the height w=float(input("Enter your weight in pounds :")) h=float(input("Enter your height in inches :")) bmi=(w*703)/(h*h) ...
f22d1886a08da98b613d9ed89432a39d47679830
lslewis1/Python-Labs
/Week 6 Py Labs/calories burned.py
327
4.125
4
#10/6/14 #This program will use a loop to display the number of calories burned after time. #The times are: 10,15,20,25, and 30 minutes #i controls the while loop #cb is calories burned #m is minutes i=10 while i<=30: m=i cb=m*3.9 i=i+5 print(cb,"Calories burned for running for", m,"minut...
fc0c81055407aa4869426c1b2fd843cc0cfd71c3
lslewis1/Python-Labs
/Week 3 Py Labs/Dollar calculation game.py
765
3.8125
4
#9/17/14 #This program will ask a user to enter the exact amount of coins to make a dollar #If the user correctly enters the amount of coins for a dollar, a message is displayed #If not, the progam tells the usere if they were above or below a dollar #p is the number of pennies #n is the nickels #d is dimes #q...
29260166c31c491e47c68e1674e384bc56c6a2d5
lslewis1/Python-Labs
/Week 8 Py Labs/Temperature converter.py
919
4.4375
4
#10/20/14 #This program will utilize a for loop to convert a given temperature. #The conversion will be between celsius and fahrenheit based on user input. ch=int(input("Enter a 1 for celsuis to fahrenheit, or a 2 for fahrenheit to celsius: ")) if ch==1: start=int(input("Please enter your start value: ")) ...
d31c472acb56ddda5e696e10c957d3d85cf88220
lslewis1/Python-Labs
/Week 4 Py Labs/Letter grade graded lab.py
536
4.375
4
#9/26/14 #This program will display a student's grade. #The prgram will print a letter grade after receiving the numerical grade #Grade is the numerical grade #Letter is the letter grade Grade=float(input("Please enter your numerical grade :")) if Grade>=90: print("Your letter grade is an A.") elif Grad...
d2c0a048d7ff8e29edeeceb1239e51202efab2cd
lslewis1/Python-Labs
/Week 12 Py Labs/Week 12 Graded Lab funcitons.py
942
4.0625
4
#11/21/14 #This program will take an input of five test scores. #Two fucntions will be used to display the letter grade of the scores, and #The overall average #A list will be used for the test scores in the calc_average function def calc_average(mylist): sum=0 for i in range(len(mylist)): sum...
0496c19404d9e80edc3e63cdefeeec8d1a6de78b
lslewis1/Python-Labs
/Week 3 Py Labs/Gross pay if 2.py
476
4.03125
4
#9/15/14 #This program will determine the gross pay for an employee of a company. #the hourly rate is $10 #if an employee works more than 20 hours there is a $5 extra for each hour. #hrs is the hours worked #gross is the gross pay #othrs is overtime hours #otpay is overtime pay hrs=float(input("Please enter...
13221ac3c781524a6eb988f988bb02c3b562caab
lslewis1/Python-Labs
/Week 8 Py Labs/Series 2.py
187
3.953125
4
#10/22/14 n=int(input("Please enter how many numbers are in the series: ")) sum=0 for tn in range(1,n+1): tv=((tn**2)+1) print(tv) sum+=tv print("The sum is: ",sum)
598595e2f8c924f11b5012f226e8e3d8254a3ce5
lslewis1/Python-Labs
/Week 12 Py Labs/property value functions.py
344
3.609375
4
#11/19/14 def assesment(a): asmt= actual*.60 return asmt def proptax(a): ptax= (asmt//100)*.64 return ptax actual=int(input("What is the actual property value? ")) asmt=assesment(actual) print("The assessment is: ",format(asmt,'.2f')) ptax=proptax(actual) print("The tax owed is: ",format(pt...
609f7fa62dc98f98ae9fa4dd97752f54db454b71
lslewis1/Python-Labs
/Week 4 Py Labs/Credit limit.py
509
4
4
#9/22/14 #This program will determine whether one is going over their credit limit or not #maxcred is the maximum credit limit #npb is the not paid balance #exp is the expenses for the current month maxcred=float(input("Enter your maximum credit limit :")) np=float(input("Enter the outstanding not paid balanc...
1948e1d43d1fb61ed5abb32217f22d67ff26b6ce
ryanwolters/geohasher
/Geohasher.py
1,129
3.546875
4
import hashlib from datetime import date today = date.today() userDegLat = input("Your current degrees latitude? (Number before decimal point): ") userDegLong = input("Your current degrees longitude? (Number before decimal point): ") dow = input("Today's Dow opening price: ") geoString = str(today) + "-" + ...
03ee87714b5de1f9db70051b215fe07ec991a8b2
ShurfLL/infa_2020_kuruts
/lab8_gun/gun.py
9,107
3.578125
4
import math from random import choice from random import randint as rnd import pygame from pygame.draw import * FPS = 60 TRANSPARENT = (0, 0, 0, 0) GREY = (150, 150, 150) WHITE = (255, 255, 255) RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) GREEN = (0, 255, 0) MAGENTA = (255, 0, 255) CYAN = (0, 255, 25...
5b331dd77269f762c7752b184b3bebd8d3bc7c89
mike-alesso/MaxTextStringReverser
/mtsr/mtsr.py
3,008
4.34375
4
import argparse import os import re import sys def filter_non_words(word): """ Filtering words that have characters or symbols not found in a word Parameters: arg1 (str): Word to be checked Returns: bool: Returns true if only letters are present """ regex = r'[\W0-9]' return not ...
ace072fe1f59697c4e7d876bda7d6fbb5f48e121
sarthak625/python-scripts
/passwordLocker.py
500
3.984375
4
#! python3 # passwordLocker.py - A password locker program import sys import pyperclip PASSWORDS = { 'gmail': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6', 'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt', 'luggage': '12345' } if len(sys.argv) < 2: print ('Usage: python passwordLocker.py [account] - copy account password') s...
2133da4d37bcfce301984b336ee076b9dd7b5728
zachwitz/eMPRess
/empress/clumpr/HistogramMainInput.py
4,263
3.546875
4
# HistogramMainInput.py # Adrian Garcia, March 2020 # Main input function for HistogramMain from pathlib import Path def getInput(filename, d, t, l, args): """ Get additional input from user for computing and saving the PDV :param filename <str> - the path to a .newick file with the input trees and tip ma...
7f0bcddba963482972f1c6b2e9d6d9688cf5cee6
samanta-antonio/python_basics
/fizz.py
283
4.21875
4
#Receba um número inteiro na entrada e imprima Fizz se o número for divisível por 3. Caso contrário, imprima o mesmo número que foi dado na entrada. numero = int(input("Digite um número: ")) resto = (numero % 3) if resto == 0: print("Fizz") else: print(numero)
6ae4c647e621a3e7e2ea807840c7fb64217685f6
samanta-antonio/python_basics
/vogais.py
271
3.8125
4
#Escreva a função vogal que recebe um único caractere como parâmetro e devolve True se ele for uma vogal e False se for uma consoante. def vogal(v): if v == "a" or v == "e" or v == "i" or v == "o" or v == "u": return True else: return False
fbaf2e1cfb11b783fae84e043a70e8ea0af6943a
mimixtvxq/data_science_projects
/Churn Prediction ANN Implementation/ann.py
4,496
3.53125
4
# -*- coding: utf-8 -*- # Artificial Neural Network # Data Preprocessing # Classification template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Churn_Modelling.csv') X = dataset.iloc[:, 3:-1].values y = dataset.iloc[...
58a2ddd3c64f04deff58812d6f13da29e79745ed
harshadrai/DataStructures
/BinarySearchTree.py
2,885
4.0625
4
import Queue class BinarySearchTree(object): def __init__(self,value,left=None,right=None): self.value=value self.left=left self.right=right def search_tree(tree,key): if not tree: return elif key==tree.value: return tree elif key<tree.value: return sear...
fae9d7dd8592dbaec63eba892d077f5b5a55c5f4
harshadrai/DataStructures
/BinaryMaxHeap.py
3,103
3.53125
4
from math import * class Element(object): def __init__(self,value=None,description=None): self.value=value self.description=description class BinaryMaxHeap(object): def __init__(self,element=None): self.heap=[element] self.size=len(self.heap) def parent(self,position): ...
c5fdb0f6a37c397aba0145606608798ac05d2259
ybdesire/WebLearn
/15_python/multi_thread/1_start_new_thread.py
532
3.875
4
#!/usr/bin/python # python 3.x import threading import time # Define a function for the thread def print_time(threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print("{0}: {1}".format( threadName, time.ctime(time.time()) )) # Create two threads as follows...
be5432b5a1785fc52c64c26e50b75fff8b9a1c17
liyigao/ANLY-501-Introduction-to-Data-Analytics
/InClassActivityWeek10/part3.py
602
3.59375
4
import networkx as nx import matplotlib.pyplot as plt def main(): with open("dataset.txt", "rb") as file: G = nx.read_edgelist(file, delimiter = ',', create_using = nx.Graph(), nodetype = str, data = [("weight", int)]) print("Graph is", G.edges(data = True)) edge_labels = dict( ((z1, z2), z["weig...
209efe9460bf209ea4a33a32be5d865bab710699
aaqibgouher/python
/ifelse.py
150
4.0625
4
if 10>2: print("10") elif 2==2: print("3") else: print("2") a=2 b=3 min = a if a<b else b print(min) print("a") if False else print("b")
2404343037a0b87df3ae0ab3acbbcc38f2bd464c
aaqibgouher/python
/trycatch.py
239
4.09375
4
try: n = input("Enter a positive number ") if type(n) != int: raise Exception("input should be integer") n = int(n) if n<0: raise Exception("number cannot be negative") except Exception as e: print("error") print(e)
aaa2074b588a9d417b05c244f2dd53ae00fcc32e
aaqibgouher/python
/pandas_eg/Iteration.py
379
4
4
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(6,3),columns=["x","y","z"]) print(df) # Iteration through column : for key, values in df.iteritems() : print(key,values) # Iteration through row : for row_index,row in df.iterrows() : print(row_index,row) # Iteration through in rows...
c03523d806625a1fe3fe5f243702564c2ac439b9
aaqibgouher/python
/numpy_eg/vector/Set_operations.py
785
3.890625
4
import numpy as np # 1. finding unique elements in set # arr = np.array([1,1,1,1,2,2,2,3,4,5,6,7,7,7]) # set_ = np.unique(arr) # print(set_) # print(type(set_)) # 2. Union for two sets : # arr_1 = np.array([1,3,5,7,9]) # arr_2 = np.array([2,4,6,8]) # print(np.union1d(arr_1,arr_2)) # 3.Intersection for two sets : ...
27d22cb8815a9c0f3af3d0cc9455789a89b6dd25
aaqibgouher/python
/pandas_eg/dataframe.py
707
3.9375
4
import pandas as pd df = pd.DataFrame() print(df) print(type(df)) # df from list df = pd.DataFrame([1,2,3,4,5]) print(df) # from list custom index df = pd.DataFrame([1,2,3,4,5], columns=["Age"]) print(df) # df from 2d list arr = [ ["nazish", 25], ["aaqib", 20], ["danish", 30] ] df = pd.DataFrame(arr, co...
6b6bee3144bce48f71c9eb02c574d7540f0f42da
aaqibgouher/python
/numpy_random/generate_rn.py
815
4.34375
4
from numpy import random # 1. for random integer till 100. also second parameter is size means how much you wanna generate # num_1 = random.randint(100) #should give the last value # print(num_1) # 2. for random int array : # num = random.randint(100,size=10) # print(num) # 3. for random float ; # num_2 = ra...
9a52bf83259b55eddb32603836b235dec291cf38
aaqibgouher/python
/set.py
784
3.9375
4
# declare myset = {"nazish", "aaqib", "danish"} print(myset) # you cannot access using index value # access through loop for i in myset: print(i) # check from value in set print("nazish" in myset) # you cannot modify a value because you dont have access for a speciac index # only adding new value allow myset.add...
962557880d2b679913ac49c86658aa8e5bb1205d
aaqibgouher/python
/numpy_eg/vector/summation.py
995
4.21875
4
import numpy as np # 1. simple add element wise # arr_1 = np.array([1,2,3,4,5]) # arr_2 = np.array([1,2,3,4,5]) # print(np.add(arr_1,arr_2)) # 2. summation - first it will sum the arr_1,arr_2 and arr_3 individually and then sum it at once and will give the output. also axis means it will sum and give the output in on...
95d294cbff2e851b9e541be789d63edf5060c37c
foanwang/Python-learn
/bank.py
472
3.703125
4
class Account: def __init__(self, name, number, balance): self.name = name self.number = number self.balance = balance def deposit(self, amount): if amount <= 0: print('amount should > 0') else: self.balance += amount def withdraw(self, amount): if amount > self.balance : print('balance is ...
1f8069cf46fb5e40f28dbedb81b26caef387d5e7
paymantohidifar/DNAtaxis
/motifanalysis/scripts/py_classes/sequence.py
910
3.53125
4
class Sequence: # acceptable DNA base pairs ValidChars = 'TCAGtcag' + 'YMRWSK' + '[]' # construction a complement table to use with str.translate to generate complement sequence ComplementTable = str.maketrans('TCAGtcag[]', 'AGTCagtc][') @classmethod def invalid_char(cls, seqstring): r...
3d9f9ce0867eb9fb9928220370f1f462a7b4a859
Ashish-Jagarlamudi/Python_Learning
/HackerRank/Mutations.py
337
4
4
def mutate_string(string, position, character): lst=list(string) lst[position]=character output="".join(lst) return output output=mutate_string(input("Enter a String:"),int(input("Enter position of the string to be replaced:")) ,input("Enter the character to be updated at position"...
49bf861bfbb04989bde002edcb54380d753d6377
MAPSWorks/pySlipQt
/pySlipQt/examples/tkinter_error.py
3,187
3.890625
4
""" A small function to put an error message on the screen with Tkinter. Used by GUI programs started from a desktop icon. """ import textwrap try: from tkinter import * except ImportError: print("You must install 'tkinter'") print("Ubuntu: apt-get install python-tk") print("Windows: ???...
8b12eadd79467b7c31cc71b3f2535a7eba1de09e
GHubgenius/DevSevOps
/2.python/0.python基础/day6/代码/集合的内置方法.py
1,184
3.703125
4
# ========================集合基本方法=========================== # 用途: 去重、关系运算 # 定义方式: 通过大括号存储数据,每个元素通过逗号分隔 # 定义空集合,必须使用set()来定义 # l1 = [] # s1 = "" # d1 = {} # ss1 = set() # 常用方法: """ 合集:| 交集:& 差集:- 对称差集:^ """ """ 1、集合中不可能出现两个相同的元素 """ python_student = {'egon', 'jason', 'tank', 'owen', 'egon'} linux_student = {'frank', ...
eafb27b52d7258758ce39e6228f765533bd55be3
GHubgenius/DevSevOps
/2.python/0.python基础/day11/01 函数对象应用复习.py
457
3.703125
4
''' : ȡif֧ ''' # ATM 100 def login(): pass def register(): pass # ֵ func_dic = { '1': login, '2': register, } choice = input('빦: ').strip() if choice in func_dic: # ʹdict.getʽȡֵ func_dic.get(choice)() # # if choice == 'login': # login() # elif choice == 'register': # register() # ...
ac79aa0e13ff2748571b1c47fa92e779ae85cd6b
GHubgenius/DevSevOps
/2.python/0.python基础/day8/代码/文件打开模式的补充.py
543
3.9375
4
""" r w a # 纯净模式 # 可读可写 除了可读·可写之外剩下都是自己的特性 r+ w+ a+ """ # with open(r'a.txt','r+',encoding='gbk')as f: # f.write("亚峰牛批") # print(f.read()) # print(f.readable()) # print(f.writable()) # with open(r'c.txt','w+',encoding='gbk')as f: # f.write("亚峰牛批") # print(f.read()) # print(f.readable()) ...
5846ab5ebd0cf10b4b8ade3fc54cdf9af24b83f9
GHubgenius/DevSevOps
/2.python/0.python基础/day7/代码/文件打开模式.py
1,063
3.640625
4
""" 打开文件的三种模式: r : 1、只读 2、如果文件不存在,会报错 w:(慎用) 1、只写 2、如果文件不存在,则新建一个文件写入数据 3、如果文件内存在数据,会将数据清空,重新写入 a: 1、追加写 2、如果文件内存在数据,会在已有数据的后面追加数据 3、如果文件不存在,则新建一个文件写入数据 处理文件的模式: t b """ # with open(r'dir\b.txt','r',encoding='gbk')as f: # print(f.r...
c0af4782f04ee35396b0ca77e1187a7f1a2d95bf
GHubgenius/DevSevOps
/2.python/0.python基础/day14/代码/02 剩余内置函数.py
1,741
3.8125
4
''' map: 映射 map(函数地址, 可迭代对象) ---> map对象 map会将可迭代对象中的每一个值进行修改,然后映射一个map对象中, 可以再将map对象转换成列表/元组。 注意: 只能转一次。 reduce: 合并 reduce(函数地址, 可迭代对象, 默认为0) reduce(函数地址, 可迭代对象, 初始值) filter: 过滤 filter(函数地址, 可迭代对象) --> filter 对象 ''' # def func(): # pass # map(func) # 姓名列表 # name_list = ['egon', 'jason'...
f81990e2965f39346a35129b8614a71c702191a5
GHubgenius/DevSevOps
/2.python/0.python基础/day3/代码/逻辑运算符.py
395
4
4
# 与 或 非 # and or not a = 1 b = 2 c = 3 # print(a < b and b > c) # and:如果有一个式子不符合条件,整条式子都为False # print(a > b and b < c) # print(a < b or b < c) # or:只要有一个式子符合条件,整条式子都为True # print(a > b or b < c) # print(not a < b) # 取反 print(a < b and b < c or a > c) # True print(a > b or b < c and a > c) # False
cc22a9186c232e9b318940858ad2f0757b6ae77a
GHubgenius/DevSevOps
/2.python/0.python基础/day13/代码/7 匿名函数.py
659
4.25
4
''' 匿名函数: 无名字的函数 # :左边是参数, 右边是返回值 lambda : PS: 原因,因为没有名字,函数的调用 函数名 + () 匿名函数需要一次性使用。 注意: 匿名函数单独使用毫无意义,它必须配合 “内置函数” 一起使用的才有意义。 有名函数: 有名字的函数 ''' # 有名函数 def func(): return 1 print(func()) # func函数对象 + () print(func()) # 匿名函数: # def (): # pass # # () # + () # 匿名(), return 已经...
1a62de36ae15d14bdfbe63084863d64b8f2fe278
GHubgenius/DevSevOps
/2.python/0.python基础/day13/代码/0 昨日回顾.py
2,665
3.765625
4
# def wrapper1(func): # def inner1(*args, **kwargs): # print('1---start') # # 被裝飾對象在調用時,如果還有其他裝飾器,會先執行其他裝飾器中的inner # # inner2 # res = func(*args, **kwargs) # print('1---end') # return res # return inner1 # # # def wrapper2(func): # inner3 # def inner2(*args, ...
45511470c4e3732cb408a609b81daf21b0567553
GHubgenius/DevSevOps
/2.python/0.python基础/day13/代码/8 内置函数.py
1,042
4.21875
4
''' 内置函数: range() print() len() # python内部提供的内置方法 max, min, sorted, map, filter sorted: 对可迭代对象进行排序 ''' # max求最大值 max(可迭代对象) # list1 = [1, 2, 3, 4, 5] # max内部会将list1中的通过for取出每一个值,并且进行判断 # print(max(list1)) # # dict1 = { # 'tank': 1000, # 'egon': 500, # 'sean': 200, # 'jason'...
a7f71f51a443042364a36a82503ab431e29394a8
GHubgenius/DevSevOps
/2.python/0.python基础/day10/代码/02 函数的嵌套.py
551
4.15625
4
# 函数的嵌套调用:在函数内调用函数 # def index(): # print('from index') # # # def func(): # index() # print('from func') # # # func() # def func1(x, y): # if x > y: # return x # else: # return y # print(func1(1,2)) # def func2(x, y, z, a): # result = func1(x, y) # result = func1(result...
ddc120377da0e7c2c7e0ef8594abc91cb0335640
GHubgenius/DevSevOps
/2.python/0.python基础/day15/代码/05 sys模块.py
328
3.53125
4
import sys import os # 获取当前的Python解释器的环境变量路径 print(sys.path) # 将当前项目添加到环境变量中 BASE_PATH = os.path.dirname(os.path.dirname(__file__)) sys.path.append(BASE_PATH) # 获取cmd终端的命令行 python3 py文件 用户名 密码 print(sys.argv) # 返回的是列表['']
dc2a706e7b5f0c577aed8879ed3185ecece313ce
Gnome0512/LearnPython
/LazyProperty/lazyproperty.py
3,011
3.625
4
#!/usr/bin/env python class LazyProperty(): def __init__(self,func): self.func = func def __get__(self,instance,owner): value = self.func(instance) setattr(instance,self.func.__name__,value) return value class Test(): Pi = 3.14 def __init__(self,r): self.r = r ...
525de0cf414116db445adf077538308c4682ba66
duedil-ltd/pyfilesystem
/fs/multifs.py
10,616
3.75
4
""" fs.multifs ========== A MultiFS is a filesystem composed of a sequence of other filesystems, where the directory structure of each filesystem is overlaid over the previous filesystem. When you attempt to access a file from the MultiFS it will try each 'child' FS in order, until it either finds a path that exists o...
03d2bf8a74e0c8bf1565c87d41365ce21aec58f8
BigRLab/pottery
/pottery/bloom.py
9,975
3.53125
4
# --------------------------------------------------------------------------- # # bloom.py # # # # Copyright © 2015-2020, Rajiv Bakulesh Shah, original author. # ...
07923c14b2d3cc7e14a49c0eaff1e20d8769b7cb
Jonaugustin/MyContactsAssignment
/main.py
2,408
4.34375
4
contacts = [["John", 311, "noemail@email.com"], ["Robert", 966, "uisemali@email.com"], ["Edward", 346, "nonumber@email.ca"]] menu = """ Main Menu 1. Display All Contacts Names 2. Search Contacts 3. Edit Contact 4. New Contact 5. Remove Contact 6. Exit """ def displayContact(): if contacts: pr...
f0172ce268dd5be4c51c45c8d401f8430c267b1c
davidadeola/My_Hackerrank_Solutions
/python/text_wrap.py
783
3.953125
4
# Init solution # def wrap(string, max_width): # div_count = int(len(string)/max_width) # div_count = None # if(len(string)%max_width != 0): # div_count = int(len(string)/max_width) # else: # div_count = int(len(string)/max_width) + 1 # start = 0 # stop = max_width # arr = [] # for i in r...
5e24db4e26278f2e13d471437c3bb4b744b45fd9
davidadeola/My_Hackerrank_Solutions
/python/sparseArrays.py
379
3.734375
4
def matchingStrings(strings, queries): # Write your code here def str_count(arr, text): count = 0 for x in arr: if x == text: count+= 1 return count arr_of_counts = map(lambda query: str_count(strings, query), queries) return list(arr_of_counts) result = matchingStri...
5c3ba45bdf9f033132f356bb6cdd0bcd41db24bd
benstafford/vndly_taxes
/store.py
1,146
3.640625
4
import math from scanner import Scanner class Store: def __init__(self, items): self.items = items def print_receipt(self): output = '' total_tax = 0 total = 0 for item in self.items: item_total, item_tax = self.calculate_item_tax(item) total...
7ad516362ed65cf597cc5f358a0a8c7dd339aa67
cabb99/Tools
/math2py.py
631
4.0625
4
#!/usr/bin/python #Mathematica to python #Parse text text="" t = input("Insert mathematica text here: (end with new line)\n") while t!="": text+=t t = input() #Replace new line with space text=text.replace("\n"," ") #Merge extra spaces while " " in text: text=text.replace(" "," ") #Replace ", " with n...
2b03baf1b9820a25b227b9efaa0e8a3a6967b8f4
Suhee05/sentenceGenerate
/sentGenerate.py
8,278
4
4
from tkinter import * from collections import Counter import re # 1) This N-gram Viewer enables to set value N.(N cannot exceed 3) # 2) According to the value, N grams are presented # 3) If you click any pair of N gram (or any unique word in case of unigram), its approximated probablity will show up # 4) is the mo...
185d6b1b2d4e8d49949d85e483cbb80696efbe66
hb5105/LabsSem6
/DS LAB/WEEK1/check.py
172
4.03125
4
#capitalize() #count(): str.count("substring"), counts the no of times a substring occurs in a paticular string str #str.find("sub"): returns index of sub in str if found #
66f4a01eb2398ae91b1865f595bf022eec9d134d
Mahdieh-Aghagoli/Maktab44-Group8-Smart-home-management-panel-simulation
/Home/home.py
4,275
3.984375
4
from Home import room import csv from hashlib import sha256 class Home: def __init__(self, rooms, sensors, password): """ :param rooms: different rooms of the house :param sensors: different sensors in a specific house :param password: users password to check her house """ ...
412e77a957e32678dd1bbdc9f4dde0c8bd05df34
blackplusy/0706
/0722-练习参考1.py
517
3.828125
4
#coding=utf-8 dic={'admin':'123','user1':'123','heygor':'456'} while 1: name=input('请输入您的用户名:') if name not in dic.keys() or len(name)==0 : print('请重新输入您的用户名') else: print('yes') while 1: password=input('请输入您的密码') if dic[name]==password: ...
7d9c73c2e51ca6e212557d53f865f59e74146b83
blackplusy/0706
/例子-0722-02.字典.py
795
3.921875
4
#coding=utf-8 dic={'name':'heygor','age':18} dic1={'name':'o8ma'} #直接访问 print(dic) #数据筛选 print(dic['name']) print(dic['age']) #删除字典 #del dic={'name':'heygor','age':18} print(dic) del dic['age'] print(dic) del dic #print(dic) #clear dic={'name':'heygor','age':18} print(dic) dic.clear() print(dic) ...
08ad7e95bcd680f5323a82226afe9480187eafbc
blackplusy/0706
/例子-0721-06.列表.py
595
3.953125
4
#coding=utf-8 #直接访问 l=['李元芳','李白','钟馗'] print(l) #遍历访问 for i in l: print(i) #成员访问 if '张小敬' in l: print('is here') else: print('not here!') #列表的索引和切片 l1=['黄忠','赵云','关羽','马超','张飞'] print(l1[0]) print(l1[-2]) #print(l1[5]) print(l1[2:]) print(l1[2:3]) #列表的拼接 l=[1,2,3,4] m=['a','b'] print(...
827a81f68dac1efc06f5b4f9a63d15d5a816253e
dogsoft0937/SEOULIT_PYTHON_LEARN
/day1/exampl2.py
179
3.859375
4
num1=int(input("입력:")) if num1>=90: print("A") elif num1>=80: print("B") elif num1 >= 70: print("C") elif num1 >= 60: print("D") else: print("F")
231de3811ff5e25460cf7a6d1e100b01c668a41c
dogsoft0937/SEOULIT_PYTHON_LEARN
/day2/function06.py
373
3.984375
4
import turtle as t def polygon(n): for x in range(n): t.forward(50) t.left(360/n) def polygon2(n,a): for x in range(n): t.forward(a) t.left(360/n) polygon(3)#삼각형 polygon(5)#오각형 polygon(7)#7각형 polygon(9)#9각형 polygon(11)#11각형 t.up() t.forward(150) t.down() po...
9883714347754e1813afebad16bc7117107d7848
dogsoft0937/SEOULIT_PYTHON_LEARN
/day1/for_range.py
258
4.09375
4
# Standard range for x in range(10): print('Hello') # Block example for x in range(3): print(100) print(200) for y in range(5): print(y) print(300) sum=0 for x in range(1,11): print(x) sum+=x print(sum)
380134e8d4ff8a293366ce18dd3caec8e5d2e7f8
StBies/Drifttube-practicalCourse
/Drifttube.py
7,082
3.671875
4
import numpy as np import matplotlib.pyplot as plt class Data: """ The Data class is basically a container for an array that contains the raw voltage This class offers a method to plot the event using matplotlib Author: Stefan Bieschke Date: 02/12/2018 """ def __init__(self,data_ar...
73ad42dfc62970e717c437a6b6599fb84b57aeb4
KyleSMarshall/LeetCode
/[849] Maximize Distance to Closest Person.py
1,355
4.03125
4
# Problem: ''' In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized. Return that maximum ...
49eac1715b6c7b72904e5b0577cbaa702e26ac10
KyleSMarshall/LeetCode
/[1282] Group the People Given the Group Size They Belong To.py
1,702
3.65625
4
# Problem: ''' There are n people whose IDs go from 0 to n - 1 and each person belongs exactly to one group. Given the array groupSizes of length n telling the group size each person belongs to, return the groups there are and the people's IDs each group includes. You can return any solution in any order and the sam...
363e45e54a4803717070ce3fabe1b1ed8e45d0b8
hnishi/TrainingProject_DA_TeamOseti
/hnishi/test_nan.py
225
3.703125
4
import pandas as pd import numpy as np s = pd.Series([2,3,np.nan,7,"The Hobbit"]) s s.isnull() print (s) print (s.isnull()) #https://chartio.com/resources/tutorials/how-to-check-if-any-value-is-nan-in-a-pandas-dataframe/
7521ad06856aa16cf0e88cefb6e0d3b72377f3af
Team-Cha0s/CCC-Solutions
/2021-j3.py
701
3.609375
4
number = int(input()) number = [int(x) for x in str(number)] sum = number[0] + number[1] + number[2] + number[3] + number[4] direction = 0 sum1 = 0 while sum != 45: sum1 = number[0] + number[1] if (sum1 == 0): print(previous + str(number[2]) + str(number[3]) + str(number[4])) elif (sum1 %...
9b4710aa46107b5bd94aa643f94ff6e5b7b9e572
Team-Cha0s/CCC-Solutions
/2013-j2.py
151
4.125
4
string = input() rotate = "IOSHZXN" final = "YES" for i in string: if i not in rotate: final = "NO" break print(final)
11fbbd7e664ef5078bc18f6ed2c5ef04a1ef15d2
Team-Cha0s/CCC-Solutions
/2014-j1.py
359
3.640625
4
# made by mohammed s1 = int(input()) s2 = int(input()) s3 = int(input()) Total = s1 + s2 + s3 if Total == 180: if s1 == s2 or s2 == s3 or s1 == s3: variable = "Isosceles" if s1 == s2 == s3: variable = "Equilateral" else: variable = "Scalene" else: ...
096707681911d70ef27dd0c46db54c406efd8cc0
Team-Cha0s/CCC-Solutions
/2015-j2.py
226
3.78125
4
#made by mohammed string = str(input()) h = string.count(":-)") s = string.count (":-(") total = h + s if total == 0: print("none") elif h == s: print("unsure") elif h > s: print("happy") else: print("sad")
34cea829d60a1c9e75f55d2566d0cb61cf14758e
kezia-petch/COMP150
/Lab 10/QUEST 2 Lab 10.py
344
3.734375
4
def dollars(filename): file = open(filename) text = file.read() words = text.split() new_string = "" for word in words: new_string += "$" + word + ",000" + "\n" return new_string my_file = open('numbers.txt', 'w') my_file.write("35 15 353 1 30 54 44 501") my_file.close() print(dollars(...
a9fb9c7ed0b8049b2474d765be8ee743829413a0
kezia-petch/COMP150
/PROGRESSION 5/PRO 5 quest 5.py
844
3.75
4
def save_word_lengths(file_name, destination): """ >>> save_word_lengths("russia.txt", "russia_word_lengths.txt") >>> f1 = open("russia_word_lengths.txt") >>> text1 = f1.read() >>> f2 = open("russia_answer_word_lengths.txt") >>> text2 = f2.read() >>> text1 == text2 True >>> save_word...
17e4ec95fa480a53df11784e4ae27b69e0680ccd
kezia-petch/COMP150
/PRO 6 quest 7.py
508
3.5
4
myfile = open("text.txt", "w") myfile.write("I have a bunch\nof red roses") myfile.close() myfile = open('text.txt', 'r') text = myfile.read() def line_length(filename, line): file = open(filename) text = file.read().replace("\n","") i = 0 new = '' while i < len(text): if text[i].isspace():...
4e66727d658e663835d86fe29b4cdb51b9446f40
nprun/f12
/5448/hw1/Shapes.py
2,193
3.8125
4
import random ##Python program ''' Generic 2-D point ''' class Point: def __init__(self, x, y): self.x = x self.y = y def display(self): return 'x={0}, y={1}'.format(self.x, self.y) ''' Base shape class ''' class Shape: def display(): pass def sort_order(sel...
f475992eed78724908315c200e0851170df69fb2
lukejskim/sba19-seoulit
/Sect-A/source/sect06_function/s633_arbitrary_argument.py
620
3.671875
4
# Arbitrary Arguments, 가변 인자 리스트 활용 def introduceMyFamily(my_name, *family_names, **family_info): print('안녕하세요, 저는 %s 입니다.'%(my_name)) print('-'*35) print('제 가족들의 이름은 아래와 같아요. ') for name in family_names: print('* %s ' % (name), end='\t') else: print() print('-' * 35) for key...
7e46a856a34046e99f4353318d1cc9bf787973b2
lukejskim/sba19-seoulit
/Sect-A/source/sect07_class/s720_gen_object.py
255
4.125
4
# 클래스 정의 class MyClass: name = str() def sayHello(self): hello = "Hello, " + self.name + "\t It's Good day !" print(hello) # 객체 생성, 인스턴스화 myClass = MyClass() myClass.name = '준영' myClass.sayHello()
d8ce92f3cc9d892a6b6978d3bcd27a59b975cf81
lukejskim/sba19-seoulit
/Sect-A/source/sect04_control/s410_if_ex07_leapyear2.py
330
3.671875
4
year = int(input("서기 몇 년 ? ")) # 윤년 판정 --- (*1) is_leap = False if year % 400 == 0: is_leap = True elif year % 100 == 0: is_leap = False elif year % 4 == 0: is_leap = True else: is_leap = False # 결과 표시 if is_leap: print("윤년입니다.") else: print("윤년이 아닙니다.")
6b85ba08d25071f8d55f0518c560eed24840aec0
lukejskim/sba19-seoulit
/Sect-A/source/sect00_turtle/draw_color_polygon.py
760
3.65625
4
import turtle as t t.pensize(3) # 삼각형 만들기 t.penup() t.goto(-200, -50) t.pendown() t.begin_fill() t.color('red') t.circle(40, steps=3) t.end_fill() # 사각형 만들기 t.penup() t.goto(-100, -50) t.pendown() t.begin_fill() t.color('blue') t.circle(40, steps=4) t.end_fill() # 오각형 만들기 t.penup() t.goto(0, -50) t.pendown() t.begi...
4353a5bb8b67db3637dd46b357cfcc99c28623aa
lukejskim/sba19-seoulit
/Sect-A/source/sect05_project/gugudan.py
242
3.609375
4
#준영이가 스스로 만든 구구단_01 단 = int(input('구구단을 몇단을 출력 할까요? 숫자를 입력하세요.: ')) print(단, '단') for x in range(1, 10): 값 = int(단 * x ) print(단, ' x ', x, ' = ', 값)
51e38c2f22a6a41a8c4c8e55399ab28e99cd13f9
lukejskim/sba19-seoulit
/Sect-A/source/sect00_turtle/PY-C02_for_dot_line.py
144
3.578125
4
import turtle as t t.pensize(3) t.color('red') for i in range(10): t.forward(15) t.penup() t.forward(15) t.pendown() t.done()
074602ae42dc365199b1c4930c6556990b755d91
lukejskim/sba19-seoulit
/Sect-A/source/sect08_module/fibo.py
510
4.0625
4
### 피보나치 수열을 위한 모듈 def fib(n): ''' n 까지의 피보나치 수열을 출력 하는 함수 :param n: Integer :return: None ''' a, b = 0, 1 while b < n: print(b, end=' ') a, b = b, a+b print() def fib2(n): ''' n 까지의 피보나치 수열을 반환 하는 함수 :param n: Integer :return: List ''' result...
49713880f6ddd0e8594f6ddd241cbed8702f0faa
capt-alien/CDJ_Python
/python_dir/fundamentals/hello_world.py
390
3.90625
4
#!python3 hw="Hello World!" # Variables myself="Captain Alien!" num = 12 food_1="rice" food_2="BBQ" def main(): print(hw) print("Hello ",myself) print(f"Hello {myself}") print("Hello ", num) print(f"Hello {num}") print("I like to eat ",food_1, "and ", food_2) print(f"I like to eat {food...
b034a6757d736e41fc4815822066c68720e7dcf6
capt-alien/CDJ_Python
/python_dir/oop/zoo.py
2,005
3.953125
4
#!python3 class Cat: def __init__(self, name): self.name = name self.coat = 'striped' self.size = 200 self.diet = 'meat' self.health = 500 self.happiness = 300 def eat(self, amount=50): self.health += 10 self.size += amount/100 return sel...
9d008fbcdab18fd562f74367abe5796d7f8f99fb
souzajean/iniciandopython
/20180922_aula6.py
341
4.03125
4
#Version: Python 3.6 -> data:22/09/2018 # coding: utf-8 print('Seja bem vindo ao mundo PYTHON') print('''Vamos aprender desde o inicio PYTHON ''') print("Objetivo inicial 'aprender a sintaxe' PYTHON") print('Estudar "logica de programação"') linguagem = str (input('Qual é a "melhor" linguagen para aprender?')) ...