blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5f3b342f6ee8ce9741486d00c16cd5a46deccee5
ofhellsfire/python-notes
/lectures/02-intermediate/04-properties-class-methods/examples/classmethod_inheritance.py
686
3.796875
4
from classmethod_ import Point, Quadangle class Rectangle(Quadangle): def __init__(self, lt, rb, p2=None, p3=None): """ Constructs rectangle :param: lt (Point) - left top :param: rb (Point) - right bottom """ super().__init__(lt, p2, p3, rb) def get_area(self): ...
9a13d7c8bb66da6923b4a71699acb4c8480252ce
ofhellsfire/python-notes
/lectures/02-intermediate/09-context-managers-introspection/example/scopes_introspection.py
566
3.53125
4
# Demonstrates some basic scope introspection from pprint import pprint as pp print('Globals:') pp(globals()) a = 53 print('Globals:') pp(globals()) print('Defining a new variable through globals()') globals()['b'] = 3.14124 print('Globals:') pp(globals()) print(b) def report_scope(arg): a = 1024 pp(local...
3ae2d0099a34b681dae5729ef7597182bb735147
ofhellsfire/python-notes
/lectures/02-intermediate/07-inheritance-subtype-polymorphism/example/super.py
550
4.03125
4
# Demonstrates super() built-in function usage class Base: def __init__(self): print('Base init') def foo(self): print('Base.foo()') class Sub(Base): def __init__(self): super().__init__() print('Sub init') def foo(self): print('Sub.foo()') def bar(sel...
c6107a22053bb4913a7b1f27bb9fd11ea53e4579
ofhellsfire/python-notes
/lectures/02-intermediate/08-protocols-exceptions/example/fib_sequence.py
1,111
4.0625
4
# Demonstrates simple sequence protocol implementation by Fibonacci Sequence # NOTE: Don't use it on production, for demo purpose only from collections.abc import Sequence class Fibonacci(Sequence): def __init__(self, nmax): self.length = nmax self._items = [] self._calculate() def...
9b580f344385cb81744e255656e1403f23544f6a
abcoda/etch
/previous_versions/lewp4.py
21,303
3.6875
4
from tkinter import Tk, Canvas, Frame, BOTH from PIL import Image import numpy as np import keyboard import time import matplotlib.pyplot as plt # import random # random.seed(0) """ Display: Class for a UI Window which displays the drawing in its current state. Each display object is linked to a drawing. Mainly for de...
000adc85e18fa1949d6add57789eea148bd120e6
yashlad27/MAC-Python-basics-Jun21
/listsAccess01.py
799
4.46875
4
# PYTHON - ACCESS LIST ITEMS: # first item of list has index zero: # List items are indexed and you can access them by referring to the index number: L1 = ['apple', 'horse', 'whale'] print(L1[1]) # Negative indexing: # negative meaning starts from the end: # -1 refers to the last item, -2 refers to the second last ite...
4f3482ec5e1b4e52d811f3dc8cd0af49fe2006c5
yashlad27/MAC-Python-basics-Jun21
/tupleLoop.py
162
4.3125
4
# PYTHON - LOOP TUPLES # You can loop through the tuple items by using a for loop: thistuple1 = ("yash", "lad", "fog", "horse") for x in thistuple1: print(x)
b9ea661bcaec1f176387e3f51e1e2653321fc44e
LeeYongGeun/untitled
/20161115.py
275
3.8125
4
# import random as rn #말 줄이기 # a = rn.randint(1,9) # print(a) # # from random import randint #random패키지중에 randint라는 함수만 불러옴(메모리 적제 줄임으로서 실행속도 향상) # a = randint(1,9) # print (a) def myadd(a, b): return a+b
086afc867954fd27db9dcd8447e446cdbfe89e0f
SRK-wakasugi/Dx-
/Python課題1/Q3.py
268
3.90625
4
#ユーザー入力用 print("任意の自然数を入力してください") num_a = int(input("a= ")) num_b = int(input("b= ")) #足し算 print (num_a + num_b) #引き算 print(num_a - num_b) #掛け算 print(num_a * num_b) input("処理終了")
99f6c05f23677843c5b8cf1294ca4794ef0f4b03
mitkopavlovv/OOP_Traning
/Training_demos/OOP-Fund_Abstr.py
734
3.96875
4
from abc import ABC, abstractmethod class Person(ABC): @abstractmethod def age(self): pass @abstractmethod def hairColor(self): pass class Music(ABC): @abstractmethod def style(self): pass class Ivan(Person, Music): def age(self): print("Age 23") def ...
901eb84c2a4016d440a07407b39e9859493b8f30
PrimerLi/svm
/data/Point.py
425
3.921875
4
class Point: def __init__(self, x, y, label): self.x = x self.y = y self.label = label def __str__(self): return str(self.x) + " " + str(self.y) + " "+ str(self.label) def inner(pointA, pointB): return pointA.x * pointB.x + pointA.y * pointB.y def main(): point = Poin...
f3731475fe0ed50c8d885d3bf04fa90fc7e87551
Projects-zy1012/Learn_Machine_Learning
/CompleteSMO.py
8,250
3.5
4
import numpy as np import matplotlib.pyplot as plt # help function to read data in def loadData(filename): input = [] # store the feature vector x label = [] # store the label y with open(filename, 'r') as f: for line in f.readlines(): tempArr = line.strip().split() input....
6149b323702f6b670041b4db075ba03efe950ccb
LuoBingjun/Homework-old
/Algorithms/HW1/test.py
158
3.796875
4
strs=[] for i in range(30): str = input() strs.append(str) input() print('开始输出') for i in range(30): print(strs[29-i]) print('')
46747b3ea2bcf4c49fd88c67ab82c1b09cd61946
FeagleFrank/LeetCode
/6. ZigZag Conversion/python/solution_1.py
547
3.625
4
class Solution: def convert(self, s, numRows): """ :type s: str :type numRows: int :rtype: str """ if numRows == 1: return s r = [''] * numRows fl = numRows*2 - 2 for i in range(len(s)): if i % fl < numRows: ...
dc270b917ae56cdc6eba2a261b76a4ce7837d1e3
sajib1066/python-source-code
/beginner/List.py
970
3.78125
4
num = [1,2,3,4,5,6,7,8,9,10, 'math', 6.7] #adding list item sum = 0 for i in num: if type(i) == int: sum += i print(i) print('Sum is {sum}'.format(sum=sum)) car_list = ['honda', 'hino', 'toyota', 'tata'] #adding list car_list.append('bmw') print(car_list) #insert car_list.insert(2...
11aecedd2544c1a5d5d31d77f4a57153b6675492
sajib1066/python-source-code
/beginner/Dictonary.py
369
3.9375
4
#Dictionary dict = {} dict['name'] = 'sajib' dict['age'] = 19 print(dict['name'], dict['age'], sep=' | ') dict1 = {'Sajib' : 226758, 'Atik' : 226738, 'Tanim' : 226714} #iterate for name, roll in dict1.items(): print(name, roll, sep=' | ') #add new item dict1['Pabel'] = 226745 print(dict1) ...
7be817598c3a9819e8e8a4400f23f9416ec91d12
sajib1066/python-source-code
/oop/OOP1.py
261
3.78125
4
class Person(): def __init__(self, name, age): self.name = name self.age = age def details(self): print(self.name, self.age) person = Person('Sajib', 19) person.details() print('Name: ', person.name) print('Age: ', person.age)
1c62e000670c9a5df82f90cb5edaac5390e11638
yysung1123/DLcourse
/lab0/main.py
2,490
3.59375
4
import numpy as np import matplotlib.pyplot as plt def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) def d_sigmoid(x): return x * (1 - x) def dataset(): return np.array([[0, 0], [0, 1], [1, 0], [1, 1]]), np.array([[0], [1], [1], [0]]) class FC: def __init__(self, in_size, out_size): self.in_si...
52c27c2eed457c99fb4ce6b63d6c77930e1a1212
Sleeither1234/t10-HUATAY.CHUNGA
/huatay/submenu_CLI6.py
2,531
3.796875
4
def caramelos_goma(): def masmellow(): costo=13 print("Usted ha elejido los masmellow su costo es de "+str(costo)) archivo=open("golosinas.txt","a") archivo.write("Usted ha elejido los masmellow su costo es de "+str(costo)) print("Datos guardados correctamente") archi...
116d5f68c9a41b0d974e2a726c9fd1ef27d91549
abrahamsk/ml_perceptrons
/test.py
3,675
3.71875
4
#!/usr/bin/env python # Machine Learning 445 # HW 1: Perceptrons # Katie Abrahams, abrahake@pdx.edu # 1/19/16 import letter, random, sys from train import perceptrons from input import letters_list_testing from pandas_confusion import ConfusionMatrix import pandas as pd pd.set_option('max_rows',500) and pd.set_option...
1ec59829aa219ae560adc21ca58b51f316ab6adc
Vivekasr/python-funwork
/fib.py
314
4
4
n = int(input('Enter the number of fibonacci number you want:')) count = 0 n1 = 0 n2 = 1 if n<=0: print('invalid choose positive') elif n==1: print('0') elif n==2: print('1') else: while count < n: print(n1,end=' ') nth = n1 + n2 n1 = n2 n2 = nth count += 1
a111d0b6f69871b2d49dd022df6b67ab63380f36
will-data/Self-Study-WIL
/HackerRank/Interview Preparation Kit/Insertanodeataspecificpositioninalinkedlist.py
891
3.8125
4
#!/bin/python3 import math import os import random import re import sys class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, ...
30bb29c71d55fa64b9aec512a977d10dd2ac50dc
will-data/Self-Study-WIL
/HackerRank/30 Days of Code/Dictionaries and Maps.py
391
3.5625
4
n = int(input()) phone_book = {} for i in range(n): name, phoneNumber = input().split() phone_book[name] = phoneNumber while True: # Use try syntax for the not fixed number of inputs try: name = input() if name in phone_book: print(name,'=',phone_book[name], sep="") ...
bb136d70a5205bcfd84a04c9a705d51537b982ae
rcoconnor/TensorflowProjectExamples
/quickstartGuide.py
2,828
3.703125
4
import tensorflow as tf # load the dataset mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() # convert the integers to floating point numbers x_train, x_test = x_train / 255.0, x_test / 255.0 # build the model by stacking layers, choose an optimizer and loss function print("-...
aa9233881af022b3c6861cfa96852048b1c2d2ca
yang1127/school-test
/数据管理与方法/百马百担问题.py
250
3.78125
4
for x in range(0,34): for y in range(0,51): for z in range(0,101): if x*3 + y*2 + z*0.5 == 100 and x + y + z == 100: print("大马有:",x,"匹,中马有:",y,"匹,小马有:",z,"匹")
75c31a8efbe7394c38634925ffca38b1f3c4ebb2
yang1127/school-test
/数据管理与方法/圆面积.py
339
3.71875
4
class Circle: def __init__(self,r): self.r = r def GetGirth(self): return 2*3.1415926*self.r def GetArea(self): return 3.1415926*self.r*self.r for i in range(10): myCircle = Circle(i+1) print("半径为 %d 的圆,面积: %.2f 周长: %.2f "%(i+1, myCircle.GetArea(), myCircle.GetGirth()))
3c892868bc2f8949d83c67367f9e950c02e8f9b7
lam1nO/tasks-univer
/Arina_var7_1st.py
4,192
3.59375
4
from random import shuffle mainSq = [1, 2, 3, 4, 5, 6, 7, 8, 9] aPoints = 0 bPoints = 0 shuffle(mainSq) print (mainSq[0:3]) print (mainSq[3:6]) print (mainSq[6:9]) cnt = 0 dic = { } alrdy = {} for i in range(0, 9): dic[mainSq[i]] = i # присваиваем индексы числам из нашей таблицы, чтоб быстро доставать их из ...
e3955e18cc56c17da4c0d1e9fbf736679a4d4772
ianepreston/amigos_advent
/ryam/challenges/02/advent_02.py
1,692
3.890625
4
# advent 02 ## part 01 # CREATE: parse text function def parse_line(line): # stolen from Ian return tuple(int(_int) for _int in line.split("x")) # CREATE: surface area return function def surface_area(_list): l = int(_list[0]) w = int(_list[1]) h = int(_list[2]) sa_01 = l * w sa_02 = w * h...
6b3836091cd2e669153935080adb9f304620b47c
CliTest88/myProjects
/interviewQuestions/Question4/FriendlyWords.py
5,919
3.984375
4
############## # DOCUMENTATION # Author: Christine Li # Date: 5/1/2021 # A program prints out all friendly words from given a set of words ############## # The Input file: the given set of words with format below: # car # cheating # dale # ... # The output file: the output set of friendly words with format ...
b5ecc70ffe78b1d2fbfc8cca8a924df69cb4c66b
ritikapatel1410/Python_Data_Structure
/string/unique_word_sequence.py
1,551
3.78125
4
''' @Author: Ritika Patidar @Date: 2021-02-27 14:20:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-27 14:20:38 @Title : print unique word sequence of given sequence ''' import sys import os sys.path.insert(0, os.path.abspath('LogFile')) import loggerfile def sorted_sequence_word(word_sequence...
2ed922852430fe247e4027e2df6f4aed59a1d95b
ritikapatel1410/Python_Data_Structure
/List/sorted_list_tuple.py
2,149
4.03125
4
''' @Author: Ritika Patidar @Date: 2021-02-26 18:35:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-26 18:35:38 @Title : sorted list by last element of tuple ''' import sys import os sys.path.insert(0, os.path.abspath('LogFile')) import loggerfile def sort_list(user_created_list): """ ...
f10f94630d4318f183265d452b9b68c4547cf326
ritikapatel1410/Python_Data_Structure
/Basic_Programs/Data_Structure/Basic_Program/get_size_of_object.py
587
3.5625
4
''' @Author: Ritika Patidar @Date: 2021-02-23 22:15:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-23 22:15:38 @Title : get size of object ''' import sys #object str1 = 123 str2 = "dipu" str3 = "aastha patel" #print size of object print("========================================================...
942c91dbeef146183bae2a5fefe631427697a126
ritikapatel1410/Python_Data_Structure
/string/find_max_len_string.py
1,788
4.125
4
''' @Author: Ritika Patidar @Date: 2021-02-27 14:10:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-27 14:10:38 @Title : find maximum length word in list ''' import sys import os sys.path.insert(0, os.path.abspath('LogFile')) import loggerfile def maximum_word(word_list): """ Descripti...
f524ce244b07d9bae3dfb08a8a3ea7f7dcce9eb3
ritikapatel1410/Python_Data_Structure
/Array/create_array_and_display.py
2,008
4
4
''' @Author: Ritika Patidar @Date: 2021-02-17 12:15:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-18 12:15:38 @Title : create an array of integers and display the array items problem ''' from array import * #import module import sys import os sys.path.insert(0, os.path.abspath('LogFile')) #im...
f62780df36904c4b6538e597ff337740af8b0147
ritikapatel1410/Python_Data_Structure
/List/find_larger_word.py
1,913
3.84375
4
''' @Author: Ritika Patidar @Date: 2021-02-26 19:35:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-26 19:35:38 @Title : find larger word then n ''' import sys import os sys.path.insert(0, os.path.abspath('LogFile')) import loggerfile def string_list(user_created_list,n): """ Descript...
868669d40230716eb8e164f4ca7a2ea096f5ea2b
ritikapatel1410/Python_Data_Structure
/List/create_copy_list.py
2,031
3.640625
4
''' @Author: Ritika Patidar @Date: 2021-02-26 18:35:10 @Last Modified by: Ritika Patidar @Last Modified time: 2021-02-26 18:35:38 @Title : create duplicate list of original list ''' import sys import os sys.path.insert(0, os.path.abspath('LogFile')) import loggerfile def duplicate_list(user_defind_list): ""...
bdcac1fdd9a6d63b3c90d5f259ebcaea60ca5394
duanwandao/PythonBaseExercise
/Day12(设计模式及异常处理)/Test01.py
1,775
4.1875
4
""" 类的组成部分: 属性 类属性: 类变量 对象属性: 成员变量 行为: 成员方法 类方法 静态方法 1.什么叫类变量: 变量定义在类中,方法外,属于类所有,所有对象共享一份 2.与成员变量有什么区别? 定义位置不同 属于者不同 成员变量属于对象 类变量属于类 存储份数不同: 成员变量: 每个对...
fbcbdb24db9dbbb1b8b9952e622cfd009fbea46a
duanwandao/PythonBaseExercise
/Day18(核心编程)/Test09.py
584
4.3125
4
""" 用法: 求原点到指定点的距离 sqrt((x-x1)^2 + (y-y1)^2) 1.函数 2.闭包 """ import math #求两个点之间的距离 def get_dis(x,y,x1,y1): return math.sqrt((x-x1)**2 + ((y-y1)**2)) print(get_dis(0,0,10,10)) print(get_dis(0,0,100,100)) def get_dis_out(x,y): def get_dis_in(x1,y1): return math.sqrt((x - x1) ** 2 + ...
200cdd1ac8abcd619da2de5a6c52c0ce7755c16d
duanwandao/PythonBaseExercise
/Day02(分支及循环)/Test02.py
1,609
4.375
4
""" 多分支语句: 多分支: if 表达式1: 表达式1成立执行的代码 elif 表达式2: 表达式2成立执行的代码 elif 表达式3: 表达式3成立执行的代码 else: 三个条件都不满足执行的代码 A[90,100] B[80,90) C[70,80) D[60,69] E < 60 跟电脑猜石头剪子布,打印输赢 1.计算机随机生成:0.石头 1.剪刀 2.布 ra...
e00f7c7d232bf820f2e955c691ed6e6c7a187db0
duanwandao/PythonBaseExercise
/Day04(列表及嵌套列表)/Test02.py
554
3.75
4
""" 方法: 拆分方法: partition rpartition isalpha 所有字符都是字母 isdigit 是否所有的字符都是数字 isalnum 是否所有字符都是数字或者字母 isspace 是否所有字符都是space join """ str1 = 'ni hao ma hao de hen' print(str1.partition('hao')) print(str1.rpartition('hao')) print(str1.split('hao')) str2 = 'abc...
b03f3e70f91949d17e4e164e1473cf37d753dd90
duanwandao/PythonBaseExercise
/Day01(变量及运算符))/Test07.py
354
4.0625
4
""" if 语句 if 表达式: 表达式成立执行的代码 1-6 模拟实现骰子大小 1.随机数 2.if 判断 1-3 输出小 4-6 输出大 """ import random #得到[1,6]范围内的随机数,包括1,6 rand_num = random.randint(1,6) print(rand_num) if rand_num <= 3: print("小") if rand_num >= 4: print("大")
034ee13bf13f0223e7a17aeff1ede1ff5b4dac9d
duanwandao/PythonBaseExercise
/Day04(列表及嵌套列表)/Test01.py
1,655
4
4
""" 1.嵌套循环的使用: 2.for循环 for 变量 in range(start,end,step): 循环体 3.for循环的嵌套 for for 4.99乘法表的练习 倒序99乘法表 for 循环.__reversed__(): 5. 等腰三角形/菱形 * *** ***** 6.字符串的使用 6.1定义 6.2输出 6.3输入 6.4求长度 6.5索引值范围 [0,字符串长度-1] 6.6切片操作 字符串[start:end:step] ...
d7a163e6f55ce8c56e8c2c083f2eb5499f1b8e8e
duanwandao/PythonBaseExercise
/Day07(递归及文件处理)/Test02.py
655
3.96875
4
""" 水仙花数 水仙花数是指一个 3 位数, 它的每个位上的数字的 3次幂之和等于它本身 (例如:1^3 + 5^3+ 3^3 = 153) """ #判断一个数字是否为水仙花数 def isNarcissisticNumber(num): if num < 100 or num > 999: # 结束函数 return False #将num 个位、十位、百位上的数字分别取出来 a = num % 10 b = num // 10 % 10 c = num // 100 return a ** 3 + b ** 3 + c ** 3 == num ...
83d3e664a060edc0abf7a6285bf1dca642aee68f
duanwandao/PythonBaseExercise
/Day19(高级特性)/Test06.py
388
3.984375
4
""" 装饰器装饰固定个数参数的函数 """ def func_out(func): def func_in(arg): func(arg) return func_in @func_out #func_1 = func_out(func_1) def func_1(a): print("a = %s"%a) # func_1(10) def func_out2(func): def func_in(a,b): func(a,b) return func_in @func_out2 #func_2 = func_out2(func_2) def ...
29e83b6be181515c77db4e0103db4a472d435a58
duanwandao/PythonBaseExercise
/Day18(核心编程)/Test07.py
2,196
4.4375
4
""" 迭代器: 迭代: 遍历的一种方式 可迭代性:iterable 如何判断一个对象是否具备可迭代性? 1.判断目标对象是否属于Iterable类 instance 2.for 循环 练习: 测试列表,字符串,元组,字典,是否具备可迭代性,生成器 迭代器: Iterator 能够使用next()函数调用,并不断返回下一个值的对象,称为迭代器 生成器是否是迭代器? 列表、元组、字符串、字典是否是迭代器? 具备可迭...
a8f4c44009289f8c9778035f39b583e768f16ad4
duanwandao/PythonBaseExercise
/Day08(文件)/Test02.py
894
3.890625
4
""" 切片 字符串[start:end:step] 切片操作:包括start,不包括end """ #复制目标文件: 文件为srcFile:表示的完整路径(绝对路径) #C:/Users/Administrator/Desktop/123.txt def copyFile(scrFile): file = open(scrFile, 'r') content = file.read() file_name = scrFile[scrFile.rindex('/')+1:] # print(file_name) index = file_name.rindex('.') na...
fd8d29a95486e2888e7bccf1d44ee63be3eb1747
duanwandao/PythonBaseExercise
/Day01(变量及运算符))/Test04.py
1,014
4.21875
4
""" 汉字-》组词-》造句-》作文 变量-》语句-》函数-》类 数学运算符: +: 1.求和 2.正号 3.连接两个字符串 "a"+"b" = "ab" -: 1.求差 2.负号 *: 1.求乘积 2.重复 /: 1.求商 //: 1.取整除 /是精确除法,//是向下取整除法,%是求模 **: 1.求几次幂 a ** b 求a的b次方 %: 取余数 """ #-------+ 的用途---------- # a = 10 # b = +20 # c = a + b # print("%d + %d =...
5a9f3a0fcc3732bef0100efb8b5eb805800a8215
duanwandao/PythonBaseExercise
/Day08(文件)/Test03.py
1,276
3.6875
4
""" 文件指针的偏移 查看光标的位置 tell() 查看光标位置 光标位置手动偏移 seek(offset,position) """ # file = open('123.txt') # print(file.tell()) # file.read(2) # print(file.tell()) # file.close() # file = open('123.txt') #往后偏移两个位置 import io # io.SEEK_SET 0 # io.SEEK_CUR 1 # io.SEEK_END 2 # file.s...
ac647a4fac455b2a2988516757cf4cb5f43fd6ec
duanwandao/PythonBaseExercise
/Day02(分支及循环)/Test06.py
554
4.375
4
""" 循环: 分支: 分支: 嵌套循环: 外循环: 内循环: while 条件: while 条件: 内循环的代码 外循环执行一次,内循环要执行一遍 """ # i = 0 # while i < 3: # print("我是外循环%d"%i) # j = 0 # while j < 2: # print("我是内循环%d"%j) # j += 1 # i += 1 # 打印 ***** # print("*****") # print("*"*5) """ ***** ***** ***** """...
3d8a954a61bb14bf4610220e90c3660a35ac0173
duanwandao/PythonBaseExercise
/Day02(分支及循环)/Test05.py
1,553
3.921875
4
""" 求1-100中所有偶数的和 1 2 3 4...100 判断某个数字是否为偶数(能被2整除,i%2 == 0) 猜数字的游戏: 1.随机生成一个数字[1,100] random while 2.输入猜测 input if - elif - else 猜大了,再小点 猜小了,再大点 猜中了 统计猜的次数: 根据次数评级: ...
d97b1ab5b1894189dee826bffccbf5fd79dd2983
duanwandao/PythonBaseExercise
/Day18(核心编程)/Test06.py
1,089
4.1875
4
""" 创建生成器的方式: 1. 列表推导式 g = (列表推导式) generator 2. yield 定义任意一个方法,在方法中加入yield关键字 生成器生成数据3中方式: next(g) g.__next__() g.send() 如果使用send生成第一个数据的时候,必须有一个None参数 yield: 携程 """ # def test(): # for x in range(10): # p...
9071994a0b349f11f2291e10273c69803b3c7e32
crifat/python_algorithm_implementation
/merge_sort.py
1,022
3.875
4
import numpy as np def generate_random_list(): sampl = np.random.randint(100, size=10) print(sampl.tolist()) return sampl.tolist() def initiate_mergesort(): random_list = generate_random_list() print("Sorted List", merge_sort(random_list)) def merge_sort(list): if len(list) == 1 : pri...
e7f5e17a6b0e57ded53c19e422d3834235c912ef
liulin1840/python-
/day6/本节笔记.py
1,052
3.609375
4
# # 特性 # class # object # # 封装 # 继承 # 多态 # # 语法 # # 调用函数 --》 执行 --》返回结果 # # r1 = Role.__init__() return x342423 # # r1 = Role(r1,"Alex","Police","15000") # r1.name = "Alex" # r1.role = "Poice" # r1.money = 15000 # r1.buy_gun() # Role.buy_gun(r1) # # 属性 # 方法 # 类变量的用途? 大家共用的属性 ,节省开销 # class...
ccab4635039018356d140e23f00d27a529e01b0b
linhptk/phamthikhanhlinh-fundamental-C4E27
/Session01/HW/ex3.py
190
3.921875
4
x = float(input("Enter the temperature in Celsius?\n")) print(str(x) + "(C) = " + str(x*5) + "(F)") # print(x + x*5 + x) la phep cong # print(str(x) + "(C) = " + str(x*5) + "(F)") la string
c11a0e0c3506e4b5a17d792898e76a47246dd60f
linhptk/phamthikhanhlinh-fundamental-C4E27
/Session02/HW/Serious excercise 4.py
1,294
4
4
# a, # for i in range(1,21): # print("*", end=' ') # # b, # n = input ("Enter the number of stars:\n") # n = int(n) # for i in range(0,n): # print("*", end=' ') # # c, # for i in range(0,4): # print("x", end=' ') # for i in range(0,1): # print("*", end=' ') # print("x") # # d, # # *Mi...
1a85ff2224ba7a940ce77c9960424cab86a8b2ea
linhptk/phamthikhanhlinh-fundamental-C4E27
/Session01/HW/ex2.py
67
3.9375
4
x = float(input("Radius? \n")) print("Area = " + str(3.14 * x*x))
d86d3497455fd1cf08d1a32d59f201596a383c8b
KatarzynaConnell/pands-problem-set
/Solution-10.py
1,174
4.40625
4
# Kasia Connell, 2019 # Solution to Question 10 # The Program will output the plot of functions x, power x and 2 to the power of x in the range [0,4] # References: # Video tutorial about Numpy: https://web.microsoftstream.com/video/74b18405-5ee1-47f0-a42d-e8831a453a91 # Video tutorial about plotting with Matplotlib: ht...
701459a4e2efc41a8cf6554c83bd64f911c14c39
eckp/TAS
/regression.py
8,800
4.0625
4
'''Provide functions that fit exponential curves to a given set of data points.''' import numpy as np from scipy import optimize def exp_regression(x, y, p0=None): '''Accept two lists of x and y values of the data points, with an optional list of initial guesses for the parameters. Return the fitted funct...
c9b4bed6dbeed45067585cee6ad819607e1bc3d2
SakshiUppoor/atomic-password
/src/demo.py
7,303
4.25
4
#IF STATEMENT ''' age = int(input('Enter your age')) if age >=18: print("You are an adult") else: print("You are not an adult") ''' #ELIF STATEMENT ''' marks =int(input('Enter your marks')) if marks >= 90: print('Grade A') elif marks >=80: print('Grade B') elif marks >=60: print('Grade C') eli...
f72e1bdfae4ec386c6c4ef226fbe7188f80906ef
dl3447/COMSW4156_001_2021_3---ADVANCED-SOFTWARE-ENGINEERING
/Skeleton/db.py
2,276
3.890625
4
import sqlite3 from sqlite3 import Error ''' Initializes the Table GAME Do not modify ''' def init_db(): # creates Table conn = None try: conn = sqlite3.connect('sqlite_db') conn.execute('CREATE TABLE GAME(current_turn TEXT, board TEXT,' + 'winner TEXT, player1 TEXT, ...
6b73127bf25bf9acb408b3278f81a5de5ad74a7f
pgurazada/ml-projects
/wells-africa/2018-05-23_annotate.py
2,325
3.703125
4
# coding: utf-8 # This script accomplishes a few key tasks # - Convert all categorical features to numeric (using dummy variables) # - fill in missing values # - scale all the features # In[33]: import pandas as pd import numpy as np # In[2]: from sklearn.preprocessing import Imputer, StandardScaler from sk...
7b68bb30c8dd418642ce7a98d4c3d07bfc401c36
pavanimallem/pavs2
/guvi62.py
134
3.84375
4
x=raw_input() count=0 for i in x: if((i=='0') or (i=='1')): count+=1 if(count==(len(x))): print("yes") else: print("no")
7332f70185840a835388a4a59e42792aaad1d56a
mirageq/SuperReversi-Gamer
/resources/game_app.py
10,049
3.578125
4
import pygame pygame.init() width,height,d = 700,700,0 position = ["a","b","c","d","e","f","g","h"] turn = ["b","w"] count = [0 for i in range(8)] board = [[False for x in range(8)] for y in range(8)] board[3][3] = "w" board[4][4] = "w" board[4][3] = "b" board[3][4] = "b" #Board definition class BoxesGame(): #Images ...
97c225aaa97a9795bdf460a17fddbf63374956fb
ArnarSG/TileTraveller
/TileTraveller_2.py
2,491
4.3125
4
location = "1,1" while location != "3,1": if location == "1,1": print("You can travel: (N)orth.") dir = input("Direction: ") if (dir == "N") or (dir == "n"): location = "1,2" else: print("Not a valid direction!") if location == "1,2": print("You c...
e03968322d42328520fd05301c58ea893874af1a
I-Kermit/HawkingTalking
/sp0256al2_words/convert.py
599
3.65625
4
""" Convert SP0256-AL2 allophones to dictionary """ from sp0256al2_words import allophones def convert_to_allophones(dictionary_of_words): """ convert_to_allophones(dictionary_of_words) """ converted_words = {} for key, value in dictionary_of_words.items(): connverted_list = [] for allopho...
9948e22a898a4802104414ed3e1be5d8b0f6a750
hxmuller/adventure-game
/adventure_game.py
4,547
3.890625
4
import time import random # Slow message printing for humans # str - String to be printed def print_slow(str): print(str) time.sleep(1.5) # Print intro text def intro_text(): print_slow("\nYour stomach starts to grumble.") print_slow("You walk over to the freezer, open it and look " "...
b0f781115c0d701f76f2659fbce2c59ce2565c7a
sifirib/AoC_Solutions
/Solutions/20_09.py
999
3.53125
4
f = open("20_09_inputs", "r") port_outputs = [int(num.strip()) for num in f.readlines()] f.close() # part 1 def is_producible(num): for i, num_ in enumerate(previous_nums): for num__ in previous_nums[i:]: if num_ + num__ == num: return True return False def solve_part1(): ...
b570e53fa055b832c360921b187f89feaeb27dcb
Bryan-Turek/SchoolBackup
/cs310/cs310assignment-code/.svn/pristine/b5/b570e53fa055b832c360921b187f89feaeb27dcb.svn-base
1,933
3.96875
4
#!/usr/bin/env python class Edge: def __init__(self,here,there,txt): self.description = txt # why am i making this jump? self.here = here # where do i start self.there = there # where to i end self.here.out += [self] # btw, tell here that they can go there def ...
676d3b01731b352397392249f9c2d21bfce46065
jurrchen/basic-operations
/intersection.py
139
3.53125
4
def intersection(lhs, rhs): # rhs to set names = set(map(lambda x: x.name, rhs)) for i in lhs: if i.name in names: yield i
37fe7cee833be9ed79906614d458e84f6b41741c
wangchong6808/PyHelloWorld
/src/oo/iter.py
1,559
3.578125
4
class Fib(object): def __init__(self): self.age = 13 self.a, self.b = 0, 1 self.c, self.d = 1, 1 def __iter__(self): print('iter', self.c) self.c += 1 return self def __next__(self): print('next', self.d) self.a, self.b = self.b, self.a + ...
2d821c814dcb5ae3b9b0b4eefdbf107bc56051cf
wangchong6808/PyHelloWorld
/src/guess_number.py
346
3.828125
4
import random count = 1 answer = random.randint(0, 100) while True: print('this is the %s guess' % count) count += 1 input_value = int(input('please guess:')) if input_value > answer: print('it is big') elif input_value < answer: print('it is small') else: print('that i...
127dc5e662826a3eaea17a85f515d2bf32c4e99a
Luis-Javier-Aguilar-Lopez/Luis-Javier-Aguilar---Funciones
/Funciones.py
3,965
3.75
4
print "Ejercicios 1.1.2" print "\nEscriba una función llamanda display_message() que imprima en la pantalla un mensaje que indique los temas que se han visto hasta el momento." def display_message(): print "\nLos temas vistos hasta el momento son:" print "Funciones" print "Clases" display_message() ...
3beeeaae93a618df9cf400cb9566b1444e0df0cc
hieplt1018/AI_for_everyone
/W1/overview.py
928
4.03125
4
#Declare object number_days_of_the_week = 10 point_of_Math = 9.4 say_i_love_you_in_Japanese = '大好きです。' love_AI = True #print() function print(number_days_of_the_week) print(point_of_Math) print(say_i_love_you_in_Japanese) print(love_AI) #type() function print(type(number_days_of_the_week)) print(type(point_of_Math))...
bb198439eff3e7cd608232a1db7101d953331b20
hieplt1018/AI_for_everyone
/W2/list.py
411
3.625
4
data = [1,2,3,4,5,6,7,8] data[-1] data[:3] #<3 data[1:3] #1 <= x <3 data[0] = 2 data.append(10) data2 = ['data2'] data_plus = data + data2 data_plus data3 = ['hello',[3,2]] data_m = data3*2 data_m data.insert(0,'hey Jude') data del data_m[1:3] data_m data.remove(3) data.remove(2) data data.pop(4) data data.index('hey J...
d1b927bb78df6e2ba7931b0789fe15ec4bc99e43
hieplt1018/AI_for_everyone
/W2/median.py
347
3.53125
4
def calculate_median(numbers): l = len(numbers) numbers.sort() if l % 2 == 0: m1 = l/2 m2 = l/2 + 1 m1 = int(m1) - 1 m2 = int(m2) - 1 median = (numbers[m1] + numbers[m2])/2 else: m = int((l+1)/2) median = numbers[m] return median donations = [100,200,40,322222,4000,123330,44030] c...
91998f92123c00a872cca022014d25ef6d054bb5
hieplt1018/AI_for_everyone
/W1/basic_math_algorithm.py
707
4.34375
4
import math #change degree to radian degree = float(input("Input your degree: ")) radian = degree * (math.pi / 180) print(radian) #change radian to degree radian2 = float(input("Input your radian: ")) degree = (radian2 * 180) / math.pi print(degree) #check right-angled triangle a = int(input("Input a: ")) b = int(inp...
1ca9551f6b09f2db525aff66966310efb71fc297
YusukeKitamura/Python_algo
/面積/area.py
301
3.609375
4
# coding=utf-8 # area.py -- 面積 def area(n, x, y): a = x[n - 1] * y[0] - x[0] * y[n - 1] for i in range(1, n): a += x[i - 1] * y[i] - x[i] * y[i - 1] return 0.5 * a #テスト用 if __name__ == '__main__': x = [1, 3, 2, 0 ] y = [ 1, 2, 4, 2 ] a = area(4, x, y) print("面積 = ", a)
372fc198ca96ced801146ca3a430f4f205da7566
YusukeKitamura/Python_algo
/石取りゲーム/ishi1.py
788
3.90625
4
# coding=utf-8 # ishi1.py -- 石取りゲーム 1 def ishi1(n, m): my_turn = 1 while n > 0 : if my_turn == 1: x = (n - 1) % (m + 1) if x == 0: x = 1 print("私は ", x, " 個の石を取ります.") else: while True: print("何個取りますか? "); x = int(input()) if (x > 0 and x <= m and x <= n): break n -= x prin...
853093602c3fb6b873e7d94904b11b2cc2a1bfc9
andersonheinz/python-desing-patterns
/strutural_patterns/decorator_python.py
574
3.578125
4
""" O exemplo abaixo e um recurso padrao da linguagem, o designer pattern decorator aplica o mesmo conceito na OO, porem com mais flexibilidade. """ def TDA(metodo_ou_funcao): def wrapper(*args, **kwargs): return metodo_ou_funcao(*args, **kwargs) + 20.0 return wrapper def TDE(metodo_ou_funcao): ...
c33c59aa04150fd9becfabcad77e3f4b67ead3b4
johathom/johathom.github.io
/exampleClass1.py
161
3.671875
4
C:\Users\johathom>python #!/usr/bin/env python def average(my_list): sum = 0 for i in my_list: sum = sum + i average = sum/len(my_list) print "average"
ae635a0cf85f869edcefa8974d7cef6382207fbe
vwalle/phyton-study
/Sudoku/Read-Array.py
496
3.71875
4
""" Start by reading a pre-filled array; in future versions we will feed the array The name of the file will be pre-filled array """ """ import csv with open('Pre-filled Array', newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter=',') print(spamreader) """ #f = open('Pre-filled Array', ...
e2cde588249762a1c0ed9995946955f034cea965
PyCN/python_study
/python_advanced/object_attribute_3.py
272
3.734375
4
class Person(object): __count = 0 def __init__(self, name): Person.__count += 1 print Person.__count self.name = name p1 = Person('Bob') p2 = Person('Alice') try: print Person.__count except AttributeError: print 'attributeerror'
67eeb28d3ea21126266268a29741a57ffc7c02cf
PyCN/python_study
/python_advanced/tupleArgs.py
464
3.78125
4
def tupleArgs(arg1, arg2= 'B', *arg3): print('arg 1:%s ' % arg1) print('arg 2:%s ' % arg2) for eachArgNum in range(len(arg3)): print('the %d in arg 3 :%s ' % (eachArgNum,arg3[eachArgNum])) if __name__ == '__main__': tupleArgs('A') # arg 1:A # arg 2:B tupleArgs('23','C') # a...
547bd4c0ca56e6b988ec000e7188896550055158
shwetha729/Python-Peon
/arrays and lists/sortedlist.py
327
3.875
4
# Question 2: Given a sorted list, find a target value index, if target do not exist, return -1. # Example: #Let = [1,2,3,4,5,6,7] #target = 2. # function should return 1 # Please include input, function, and test cases and an analysis of time/space complexity. # Please zip your code and upload your file to the google...
f86018b1cdac5ccd7329de42a48673fc5d0b8483
86xiang/python60
/33.py
239
3.703125
4
num = 7 while True: guess = int(input('请输入你猜的数(0~9):')) if guess == num: print("恭喜!你猜中了!") break elif guess > num: print("太大") else: print("太小")
ff2dea10a1219243c6ffb247219c6882a11d4814
86xiang/python60
/18.py
136
3.65625
4
def Sum(v): s = 0 for i in v: s += i return s x = [1, 2, 3, 4, 5] print(Sum(x)) x = (1, 2, 3, 4, 5) print(Sum(x))
f8ce539c5ba7f434d3cce5354752402889519244
hanseopark/PythonTutorial
/recursion/hanoi.py
306
3.890625
4
def hanoi(number_of_disks_to_move, from_, to_, via_): if number_of_disks_to_move == 1: print(from_, "->", to_) else: hanoi(number_of_disks_to_move-1, from_, via_, to_) print(from_, "->", to_) hanoi(number_of_disks_to_move-1, via_, to_, from_) print(hanoi(4,0,1,0))
b16dcdaade9a586b54a6d0459ca7de8db351251c
LevanBorchkhadze/IMDb_analyses
/Director_module.py
5,715
3.671875
4
import csv from collections import Counter import numpy as np import re # input value (director name) director_name_input = input("Please input name of the director >") with open('clean_movie_data.csv', 'r',) as f: reader = csv.DictReader(f) gross = [] budget = [] imdb_rating = [] movie_title = []...
f0f89980fc3e1128a87b24466191be8caf3d173c
PalmiraPereira/PalmiraProject
/create_mesh.py
2,924
3.609375
4
__author__ = 'Palmira Pereira' class vector(object): def __init__(self,x,y): self.x=float(x) self.y=float(y) def __add__(self,v): return vector(self.x + v.x, self.y + v.y ) def __sub__(self,v): return vector(self.x - v.x, self.y - v.y ) def __mul__(self,val): r...
1c6cdef2e255d550929a8a0ceb9652cac08d368a
PalmiraPereira/PalmiraProject
/vectorclass.py
550
3.875
4
__author__ = 'Palmira Pereira' class vector(object): def __init__(self,x,y): self.x=float(x) self.y=float(y) def __add__(self,v): return vector(self.x + v.x, self.y + v.y ) def __sub__(self,v): return vector(self.x - v.x, self.y - v.y ) def __mul__(self,val): ...
3f337144bc63c353a7b3b095f09363c98294743a
lotlordx/CodeGroffPy
/sandwich_decorator.py
857
3.515625
4
import re from collections import ChainMap, Counter from functools import wraps UPPER_SLICE = "=== Upper bread slice ===" LOWER_SLICE = "=== Lower bread slice ===" def sandwich(func): """Write a decorator that prints UPPER_SLICE and LOWER_SLICE before and after calling the function (func) that is p...
c229be5fa6e4d60299e4c688c06315e2dc5f8643
lotlordx/CodeGroffPy
/simple_property.py
338
3.578125
4
import datetime as d from datetime import datetime NOW = datetime.now() class Promo: def __init__(self, name, expires): self.name = name self.expires = expires @property def expired(self): return self.expires > NOW something = Promo('Voilin', NOW + d.timedelta(days=1)) print(s...
3d70f455abf54678516e19e2f7c4ff21c3c8c207
BedirYilmaz/cs231-stanford
/assignment1/cs231n/classifiers/softmax.py
6,000
3.78125
4
import numpy as np from random import shuffle from past.builtins import xrange def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape ...
0556d65bd9c5e0e1012f8f8e35efa4070c9c0a5a
tlhr/plumology
/plumology/learn/som.py
12,300
3.515625
4
"""som - Self-organising-map""" from typing import Optional, Tuple import numpy as np from sklearn.decomposition import PCA class SOM: """ SOM - Self-Organising-Map. A 2D neural network that clusters high-dimensional data iteratively. Parameters ---------- nx : Number of neurons on x-axis. ...
6e61fe93d8e026c68268f89b2ca9cc91031c5939
MDCGP105-1718/portfolio-s189385
/xp6.py
541
3.953125
4
my_name = input("Please enter your name ") print (f" hello {my_name}") my_age = input("Please enter your age ") print (f" wow youre only {my_age} you are so young") my_height = input("Please enter your height ") print (" youre such a good height ") my_weight = input("Please enter your weight ") print (" you tubby pers...
fb3bb984cb2aa42b5401c9c4a93eda7a31a68fcc
MDCGP105-1718/portfolio-s189385
/xp12.py
470
4.25
4
from random import randint number = randint(1,10) guess = int(input("please enter a guess between 1 and 10 ")) number_of_guesses = 0 while number != guess: if number > guess: print("Your guess was too small") elif number < guess: print("Your guess was too big") guess = int(input("please enter a guess between ...
93f782b283dd83c536976c6dc13be851b0dde449
nickdeighton/adventofcode
/2020/binaryBoarding.py
1,507
3.6875
4
#Day 5 Advent of Code 2020 #Nick Deighton import math def lineReader(): with open('2020/seating.txt') as f: seating = f.readlines() seating = [row.rstrip('\n') for row in seating] return seating def calculate(line): rowMax = 127 rowMin = 0 colMax = 7 colMin = 0 row = 0 ...
36a7c6c8c843c85a4987db8fb9ee00d1681a6de6
demidov8314/Demidov_Sergey_dz_1.
/task_1_1.py
611
4.03125
4
duration = int(input("Введите нужное количество секунд ")) hours = duration // 3600 minutes = (duration - 3600 * hours) // 60 seconds = 0 days = 0 if duration == 0: seconds = 0 print(seconds, "сек") elif duration > 0 and duration < 60: seconds = duration print(seconds, "сек") elif duration >= 60 and d...
9ef0903ac2edbda870bc0ecbfd3ba4ee9450fdbb
poonkin/Udacity-1
/AIRobotics/Search/search_path.py
4,369
3.546875
4
#!/usr/bin/python # ----------- # User Instructions: # # Modify the the search function so that it returns # a shortest path as follows: # # [['>', 'v', ' ', ' ', ' ', ' '], # [' ', '>', '>', '>', '>', 'v'], # [' ', ' ', ' ', ' ', ' ', 'v'], # [' ', ' ', ' ', ' ', ' ', 'v'], # [' ', ' ', ' ', ' ', ' ', '*']] # # W...
cdb9c7cc42984ecf8a7d708da01291ff37acaae4
Chinna2002/Python-Lab
/L3-Search an elemnet.py
527
3.734375
4
print("121901313006","Rohit Bharadwaj Kadiyala") x=0 def search(arr):#Fuction 1 x=int(input("Enter search element:")) for i in arr: if(x==i): flag=1 break else: flag=0 if(flag==1): print("Search element",x,"found in the array at",i-1) ...