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 |
|---|---|---|---|---|---|---|
af66a02a5b9eb4d691b235afce985da44798b936 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day11/作业/hw02.py | 2,021 | 3.765625 | 4 | """
1.士兵突击
1.士兵许三多有一把AK47
2.士兵可以开火
3.枪能够发射子弹
4.枪装填子弹,增加子弹数量
士兵:类
姓名 属性
开火() 方法
许三多:对象
枪:类
ak47:对象
子弹数量 --> 属性
发射子弹() 方法
装子弹() 方法
if "":
if []:
if {}:
if ():
if None:
if 0:
if (0): # (0) == 0; (0,)-->元组; 0, --> 元组
以上都可以当做 if False:
if "0":
if (0,):
以上数据类型中只要有内容,不是空,则当做True使用
"""
class Gun... |
d9eebd9c9543e1e744770c6f8c1be345a46f2011 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/0815推导式.py | 814 | 3.71875 | 4 | list = [j * i for i in range(1, 10) for j in range(1, i + 1)]
print(list)
list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
list2 = [j for i in list1 for j in i]
print(list2)
list3 = [i[0] for i in list1]
print(list3)
list4 = [list1[i][i] for i in range(0, len(list1))]
print(list4)
dict = {"name": "rose", "age": 17, "sex": ... |
6e530049c68d652f13c6277fec441c78e89f620d | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day04/demo05_查找.py | 1,113 | 3.78125 | 4 | """
字符串的查找方法
find() : 查找, 返回从左开始第一个指定字符的索引值, 没找到返回-1
rfind(): 查找, 返回从右开始第一个指定字符的索引值, 没找到返回-1
index(): 查找, 返回从左开始第一个指定字符的索引值, 没有找到报错ValueError
rindex(): 查找, 返回从右开始第一个指定字符的索引值, 没有找到报错ValueError
count() : 计数, 返回指定字符在字符串中的个数
"""
s1 = '0123456789'
res1 = s1.find('6')
r1 = s1.inde... |
7d7c9fe76e364ee7cdfbd22a753562628cf93da9 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day09/0819魔术方法.py | 1,526 | 3.5625 | 4 | # def num(n):
# if n == 1 or n == 2:
# return 1
# else:
# return num(n-1)+ num(n-2)
# a = num(10)
# print(a)
# class Num:
# def __call__(self,n):
# if n == 1 or n == 2:
# return 1
# else:
# return self(n - 1) + self(n - 2)
#
# a = Num()
# print(a.__ca... |
d5cb46d19ae0577089f571658d80240e5237ca21 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day05/集合/demo02_集合中的数学运算.py | 917 | 4.25 | 4 | """
集合中的数学运算
交集: 取的公共部分 & intersection
并集: 取的是所有部分,不包括重复数据 | union
差集: 第一个集合有的,第二个集合没有的 - difference
反交集: 跟交集反着 取的非公共部分 ^ symmetric_difference
子集: 判断某个集合是不是另一个集合的子集 set1 < set2 issubset
超集:
"""
set1 = {1, 2, 3, 4}
set2 = {3, 4, 5, 6}
print(set1 & set2) # {3... |
b0cf0855877716f675cc1dea8a91f3d4bbc75d4a | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/h_work/0819储物柜和随机生成彩票号.py | 2,982 | 3.8125 | 4 | import random
# 随机生成彩票 六个红球 一个蓝球
class Lottery: # 彩票类
z = "必中"
def lott_creat(self): # 生成彩票
red_num = [i for i in range(1,35)]
blue_num = [i for i in range(1,17)]
blue_bol = random.sample(blue_num, 1) # 在蓝球中取 1 个
bol = random.sample(red_num,6) # 在红球中取1个
bol.exten... |
01b78460c0ed6e9e4351d39fad566ee56220330a | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day18/demo08_全局解释锁.py | 1,360 | 3.59375 | 4 | """
全局解释锁:
进程中都有一把自己的独立的全局解释锁, 在cpu调度执行线程的时候,
执行哪个线程, 就给这个线程上一把全局解释锁, 在调度结束之后, 在释放这把锁;
计算密集型;
需要进行大量的计算, 消耗cpu的资源, 比如计算圆周率, 给视频进行高清的解码;
*可以多进程的方式, 由系统创建一个主进程, 在进程中又去创建了一个主线程, 主线程中执行的
IO密集型;
涉及到网络, 磁盘的IO操作;
"""
from threading import Thread
from multi... |
4dc119fd02ad90359e36d6ad50958c10d3883fe5 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day14/homework/hw06_递归遍历文件.py | 997 | 3.609375 | 4 | """
给定一个目录,
列举出这个目录中的所有文件和文件夹,
以及子文件夹中的所有文件...
"""
import os
def func(path, f): # 参数为给定的目录 a
file_list = os.listdir(path) # 获取给定目录中的所有(文件, 文件夹)
for file in file_list: # 遍历列表, 获取其中的每个(文件, 文件夹)
file_path = path + "/" + file # D:/first_level/day14/a/b/c
if os.path.isfile(... |
65d8dad340c685fb2a9eb0d09bd3e8560bf36bc5 | ShiJingChao/Python- | /PythonStart/Blackhorse/HM_Class/384封装案例-需求分析01.py | 1,553 | 3.546875 | 4 | # CLASS 384——385-386面向对象封装案例
# 1.封装是面向对象编程的一大特点
# 2.面向对象编程的第一个步——将属性和方法封装到一个抽象的类中
# 3.外界使用类创建对象,然后让对象调用方法
# 4.对象方法的细节都被封装在类的内部
# 一个对象的属性可以是另一个类创建的对象
# 01 士兵突击
class Gun:
def __init__(self, model):
# 1.枪的型号
self.model = model
# 2.子弹的数量
self.bullet_count = 0
def add_bullet(self... |
22b535c891b0c5a719870142dc9a765417f963f5 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day09/demo07_类属性练习.py | 1,108 | 4.21875 | 4 | """
1. 写一个类, 这个可以记录产生对象的个数
2. 写个游戏类:
1. 记录历史最高分
2. 传入当前玩家姓名, 随机玩家分数
3. 获取历史最高分
"""
import random
class Person:
count = 0 # 不可变数据类型的类属性, 记录产生对象的个数
def __init__(self):
Person.count += 1
p1 = Person()
p2 = Person()
p3 = Person()
print(p2.count)
class Game:... |
cde7a2bb4457179944e66e9d5a33103acb02c8af | ShiJingChao/Python- | /PythonStart/Blackhorse/HM_Class/394继承的传递性.py | 784 | 3.578125 | 4 | # ClASS——394继承的传递性
# C类从B类继承,B类又从A类继承
# 那么C类就具有B类和A类的所有的属性和方法,子子孙孙无穷尽
class Animal:
def eat(self):
print("吃")
def drink(self):
print("喝")
def run(self):
print("跑")
def sleep(self):
print("睡")
class Dog(Animal):
# 子类拥有父类所有的属性和方法
def bark(self):
print("汪汪叫")... |
2a8eae0f9836eda729a3fbc064a23bf2530f899f | ShiJingChao/Python- | /PythonStart/一阶段查漏补缺/day6/day6.py | 1,564 | 3.875 | 4 | # class Student:
# def __init__(self,name,age,chinese,math,english):
# self.name = name
# self.age = age
# self.chinese = chinese
# self.math = math
# self.english = english
# def get_name(self):
# print(self.name)
# def get_age(self):
# return "{}的年龄:... |
be5794538a85113f2e8f496c9d9f6027979a152f | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day09/demo05_拓展方法.py | 827 | 3.8125 | 4 | """
__init__:
创建对象的时候,自动调用该方法;
__str__:
默认返回的是对象在内存中的地址;
* print(对象)时, 自动调用;
如果想让print(对象)时,打印输出其他内容;
* 需要在类中重写 __str__方法:
* 必须要有返回值, 并且返回值的类型是字符串类型;
"""
def get_sum(a, b):
return a + b
class Person:
def __init__(self, name):
self.na... |
9ac2ca32a57b5211d3998e9a7cbd344bf587771c | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day16/demo09_击中飞机.py | 6,782 | 3.546875 | 4 | """
击中飞机:
飞机类:
1. 敌方子弹击中我方飞机 (我方飞机类);
def hit(self, bullet_list): # bullet_list --> 敌方子弹列表
for bullet in bullet_list:
......判断坐标.....
击中---> break; ---> 爆炸;
2. 我方子弹击中敌方飞机 (敌方飞机类);
def hit(self, bullet_list)... |
a10a667663fe534b04ba1601dd2ec32012c524bd | ShiJingChao/Python- | /PythonStart/二阶段MySQL/day12mysql/pysql.py | 850 | 3.59375 | 4 | # 导包
import pymysql
# 1.连接数据库
db = pymysql.connect(host='localhost', user='root', password="123123",database='demo1',
cursorclass=pymysql.cursors.DictCursor)
# 2.创建游标对象
cursor = db.cursor()
# 3.定义sql语句
# sql = 'select version()'
# 定义查询的sql语句
sql = 'select * from user'
# 定义添加数据数据
# sql = 'insert in... |
c4cc79727967ed588676506a3a865445f06682cb | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day09/demo03_init方法初始化实例变量.py | 1,135 | 4.46875 | 4 | """
1. 创建对象的过程:p1 = Person()
1. 开辟内存,存储对象
2. 自动调用了init方法
2. 实例变量:
初始化实例变量, 初始化对象的属性;
实例变量: 对象的变量 --> 对象属性;
实例变量 归对象所有, 每个对象都有一份, 对象之间互不影响;
self.变量名 --> 表示实例变量(实例属性)
3. init
默认情况下啥事也没干;
一般情况下,会在init... |
13cdd8d32bb5b0f87aec3c0ae489b716e8d53d10 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day12/demo03_生成器函数的练习.py | 1,085 | 4.03125 | 4 | """
需求: 使用生成器实现一个功能:
1. 传递数据, 计算所有传递的数据的总和; --> 平均值
"""
def func1():
sum_num = 0 # 用来记录所有数字的和, 初始值0
count = 0
avg = 0 # 用来记录所有数字的平均值, 初始值0
while True:
num = yield (sum_num, avg)
count += 1 # 每输入一个数据, 计数+1
sum_num += num # 每输入一个数据, 和累加
avg = sum_num /... |
c67a958a5fc6c15b12e4d42230a7dd214ba775c7 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/h_work/0815推导式.py | 2,283 | 4.0625 | 4 | # 列表推导式
# 1.创建一个函数,输入一个大于1的整数,返回一个列表,
# 包含所有能够整除该整数的因子(不包含1和它本身),并且从小到大排序。
# 如果这个数是素数,则返回“(integer) is prime”。
# (1)使用普通函数
# (2)使用列表推导式
# def num(n):
# for i in range(2,n//2+1):
# if n % i == 0:
# list1 = [i for i in range(2, n // 2 + 1) if n % i == 0]
# return list1
# else... |
7f8da143b0bc02eb405b1749759d5c127e004fb6 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/Plane_Wars/demo09_击中飞机.py | 6,517 | 3.515625 | 4 | """
击中飞机:
子弹类:
飞机类:
1.地方子弹击中我方飞机(我方飞机类)
def init(self,bullet_list) # bullet_list 敌方子弹列表
for x in bullet()
.....判断坐标..........
击中 break: 爆炸
2.我方子弹击中敌方飞机(敌方飞机类) # 我
ef hit(self,bullet_list)
for x in bullet... |
95c7edf243a036672ddbe7833618eee3a82659d9 | ShiJingChao/Python- | /PythonStart/question/生成器.py | 2,113 | 3.765625 | 4 | #
# def g():
# print('a')
# count = yield 1
# print("--->",count)
# print("b")
# yield 2
# gm = g()
# next(gm)
# re2 = gm.send("123")
# print(re2)
#
# def odd():
# n=1
# while True:
# yield n
# n+=2
# odd_num = odd()
# count = 0
# for o in odd_num:
# if count >=5: break
#... |
a894bd48678e2c2619672dd039c9abb1fd4a021a | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day18/demo06_生产者消费者.py | 1,561 | 3.65625 | 4 | """
生产者, 消费者
对于队列而言, 生产者就是用来往队列中存储数据;
消费者就是用来从队列中取出数据;
生产/消费 ---> 数字
线程1: 生产者
线程2: 消费者
"""
from threading import Thread, current_thread
from multiprocessing import Queue
import time, random
def product(q, q_product): # 参数1: 生产消费所共同操作的队列 参数2: 生产者要生产的数据0~4... |
487eb051c83cca2110523eb9a06448e47419ab7f | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day14/demo03_练习.py | 362 | 3.671875 | 4 | # 设计一段代码, 通过索引获取列表中的元素, 使其产生异常, 并捕获处理异常;
try:
list1 = ["万启龙", "小黄龙", "小黑龙", "大花龙"]
n = 0
while n <= len(list1): # n <= 4; n = 0,1,2,3,4
print(list1[n])
n += 1
except IndexError:
print("--索引越界了--")
print("-----over-----")
|
b2ea95ddb903c0a7674369eaaaa067ca049ab357 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/自动贩卖机.py | 6,791 | 3.609375 | 4 | history = [] # 用来存储购买记录
while True:
# 主界面内容
welcome_show = ["=" * 30,
"=\t欢迎来到AI牌自动贩卖机 \t=",
"=\t1.零售\t\t\t\t\t=",
"=\t2.查询消费记录\t\t\t=",
"=\t3.退出\t\t\t\t\t="]
# 存储产品序号名称
retail1 = {1: "可口可乐",
2: "3+2饼干",
... |
266ad53bb1950c25ff582bfe6bb710290947c8f8 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day10/demo08_多层继承.py | 743 | 4.15625 | 4 | """
多继承:
子类具有多个父类的情况; 子类可以继承多个父类的功能;
python: (继承的传递)
多层继承: 子类 --> 父类 --> 爷爷类 --> 祖先类 ---> object类
"""
class A:
def func1(self):
print("我是A中func1中的方法...")
class B(A):
def func2(self):
print("我是B中的func2的方法...")
# def func1(self):
# print("我是B中的fun... |
67a7ca9faf0d06210928aa7da6ed28a3e47dc8f6 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day04/demo03_字符串的切片.py | 1,710 | 4.34375 | 4 | """
1. 字符串的拼接
+ : "abc" + "def" ---> "abcdef"
* : "李现" * 3 ---> "李现李现李现"
2. 字符串的长度
容器: 字符元素
python的内置函数len(): 获取变量的长度;
3. 切片:slice
通过切片操作获取字符串中的一部分数据;
格式:
字符串[start : stop : step]
start: 起始值, 索引值
stop: 结束值, 索引值
... |
a72c1f285ecabeec415ebe1e7f675452c802f94f | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/Plane_Wars/demo07_显示敌机.py | 4,958 | 3.625 | 4 | """
pygame.display -->跟显示相关的设置由它完成
pygame.locals -->pygame中设置的所有常量
"""
import pygame, time,random
from pygame.locals import *
# 地方战机
class Father_Bullet:
def __init__(self,screen):
self.screen = screen
class EnemyPlane:
def __init__(self,screen):
self.x = 0
self.y = 0
s... |
b37c67258f915bc26a5f5edc5b4da1ca2b49408d | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/white_practice/0805practice/第七题.py | 352 | 3.90625 | 4 | # 7.统计指定字符在字符串中出现的次数。如:String s = "mclaoyangshichoujidanhahaha"; 查找‘a’出现的索引位置
# s = "mclaoyangshichoujidanhahaha"
# count = 0
# a = list(s)
# for i in s:
# if i == "a":
# count += 1
# print(count)
# for i in range(0, len(a)):
# if a[i] == "a":
# print(i, end=" ")
|
a419d1dcc7785f5fbdca54e93c25125e8f684976 | ShiJingChao/Python- | /PythonStart/0722Python/0805Python/day17/多线程/demo04_自定义线程类.py | 634 | 3.8125 | 4 | """
自定义线程类
传参睡一下, 计算程序执行的时间
"""
from threading import Thread
import time
class MyThread(Thread):
def __init__(self, s_time): # 睡觉的时间
super().__init__()
self.s_time = s_time
def run(self): # 重写run方法, start线程对象时, 会自动的调用run方法,
# 将该线程类执行的具体功能写入到当前方法中去
t1 = time.time... |
aef9315c44a94a20f031cd87604e7efd3b0aeade | marceloonit/code_samples | /dia25/professor_tratando_arquivo.py.txt | 3,109 | 3.84375 | 4 | def dicionário_de_ocorrências(l):
ret = dict()
for elemento in l:
ret[elemento] = 0
for elemento in l:
ret[elemento] += 1
return ret
def ordenado_por_valor(d):
lista_valor_chave = []
for chave in list(d):
lista_valor_chave.append((d[chave], chave))
ret = sorted(lis... |
0d0c95f7a0bcb68cb914d7b370abd4be804a278a | marceloonit/code_samples | /pkg02/fatorial.py | 224 | 4.0625 | 4 | #!/usr/bin/env python3
# Fatorar número
n = int(input('Digite o número que você deseja calcular o fatorial: '))
fatorial = 1
for i in range(n):
fatorial = fatorial * (i + 1)
print(str(n) + "! é " + str(fatorial))
|
35e5952005bfa5cceccb73cbff27deac3cb520bc | marceloonit/code_samples | /pkg01/trabalho.py | 453 | 3.75 | 4 | #!/usr/bin/env python3
import time
idade_media = 80
nome = input("Entre com o seu nome: ")
idade = input("Entre com a sua idade (anos): ")
while (not idade.isdigit()):
idade = input("Idade deve ser em anos inteiros: ")
idade = int(idade)
restante = idade_media - idade
contador = restante
print("Olá, " + nome + ... |
f0d35874f8fcd8b605104845e847564b27870f1a | marceloonit/code_samples | /2fizzbuzz.py | 484 | 3.765625 | 4 | # fizzbuzz
# imprima numeros de 1 a 100
# se o numero for divisivel por 2 imprima fizz
# se o numero for divisivel por 3 imprima fizz
# se o numero for divisivel por 2 e 3 imprima fizzbuzz
fp = open('fizbus.txt', 'w')
for i in range(1, 101):
if i % 2 == 0 and i % 3 == 0:
print('fizzbuzz', file=fp)
el... |
80159f4825385de4cb74e4f9946c3c7470e6fbd4 | vhghhd/my-python-challenge | /third/third.py | 585 | 3.75 | 4 | """
The third problem:
recognize the characters. maybe they are in the book,
but MAYBE they are in the page source.
find rare characters in the mess below.
"""
def findthird(path):
filefd = open('third.txt',"r")
lines = filefd.readlines()
result = []
for line in lines:
data = filter(... |
006d4318ecc5f77efd912464de98ef2cf852dd42 | NataliaBeckstead/cs-module-project-recursive-sorting | /src/searching/searching.py | 1,278 | 4.40625 | 4 | # TO-DO: Implement a recursive implementation of binary search
def binary_search(arr, target, start, end):
if start > end:
return -1
mid = (start + end) // 2
if arr[mid] == target:
return mid
elif target < arr[mid]:
return binary_search(arr, target, start, mid-1)
else:
... |
70dcd1ee1a606f67646d7e8f7f3862908e3a0c76 | JannickStaes/LearningPython | /TablePrinter.py | 1,061 | 4.21875 | 4 | #! python3
# prints a table of a list of string lists
tableDataExample = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def determineMaxColumnWidths(tableData):
columnWidths = [] #a list to store the max length of ea... |
924f9130bdd0c7b965aebcdb0e94240f4cd75c2e | rodrigo-serra/courses | /freeCodeCamp/7_scientificComputingPython/projects/polygonAreaCalculator/shape_calculator.py | 1,154 | 3.875 | 4 | import math
class Rectangle:
def __init__(self, width, height):
self.w = width
self.h = height
def set_width(self, width):
self.w = width
def set_height(self, height):
self.h = height
def get_area(self):
return self.w * self.h
def get_perimeter(self):
return 2 * self.w + 2 * self.... |
3cdd229af07bdb60d470c3312be548198439ba2a | LaraMol/robotarm | /exercise12.py | 742 | 3.578125 | 4 | from RobotArm import RobotArm
robotArm = RobotArm('exercise 12')
robotArm.speed = 2
# Jouw python instructies zet je vanaf hier:
positie = 1
totaalposities = 10
loop1 = 0
while loop1 <= 8:
robotArm.grab()
color = robotArm.scan()
hoever = totaalposities - positie
hoeverTerug = hoever -... |
9daa8178ab793cd2fded4418b72367e3aca9e3ef | network-embeddings/hc_embedding | /hc_embedding/angular_coords.py | 2,071 | 3.875 | 4 | import numpy as np
def CA_coords(coords):
"""
Args:
coords: numpy.ndarray, A (N, 2) array of coordinates.
Returns: numpy.ndarray
A (N, 2) array of rescaled coordinates that fall on the unit circle.
"""
return np.array(coords) / np.linalg.norm(coords, ord=2, axis=-1, keepdims=True)... |
af175e0913b72d5c984cd90490f8405d8843d258 | Hubert51/pyLemma | /Database_sqlite/SecondPart_create class/Test_simplify_function/class2.py | 1,440 | 4.125 | 4 | import sqlite3
class DatabaseIO:
l12 = [1, 2, 3]
d_table = {}
def __init__(self, name):
"""
In my opinion, this is an initial part. If I have to use variable from
other class, I can call in this part and then call to the following
part.
Some variable must be renamed... |
2fe3daacf0639bdc0df7e9b3299ded74645b4b31 | webbshasta/pfb2018_TA_Prep | /testingSets.py | 571 | 3.765625 | 4 | #! usr/bin/env/ python3
#Owner: Shasta Webb
#Filename:PS5.1.py
setA = {3, 14, 15, 9, 26, 5, 35, 9}
setB = {60, 22, 14, 0, 9}
intersectionAB = setA & setB
print('The {} between Set A and Set B is {}'.format('intersection', intersectionAB))
differenceAB = setA - setB
print('The {} between Set A and Set B is {}'.for... |
ea9d6eb96215f1610a99a268257a63dd247b74f5 | webbshasta/pfb2018_TA_Prep | /Python4/4.5.1.py | 281 | 3.828125 | 4 | #! usr/bin/env/ python3
#Owner: Shasta Webb
#Filename: 4.5.1.py
#Description: Create a new script that uses list comprehension to do the same, uses range to print out every number bewteen 1 and 100.
nums = [num for num in range(0,100) if num % 2 == 0]
print(nums)
print("\nDone.")
|
6e20037780b1a2749d9ac22be4d0a32c62913b96 | cperalt06/codeWars | /L7_Kyu/sum_of_odd_numbers.py | 551 | 4.0625 | 4 | """
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29 ...
Calculate the row sums of this triangle from the row index
(starting at index 1) e.g.:
row_sum_odd_numbers(1); # 1
row_sum_odd_numbers(2); # 3 + 5 = 8
I think then formula is to get max value:
(n + 1) * n
to get minimum value:
n * (n - 1) + 1
"""
de... |
dc070d53832b125ebe5de09a35b37155f712fd9c | vish48/Python-Introduction | /coffee_bot.py | 1,825 | 4.09375 | 4 | # Define your functions
def extra_options():
res = input('Would you like a plastic cup or did you bring your own reusable cup? \n[a] I\'ll need a cup. \n[b] Brought my own! \n> ')
if res == 'a':
print('Okay, no problem! We\'ll get you a plastic cup.')
elif res == 'b':
print('Great! We\'ll fill up your re... |
83b3256eb8c857eded0c9ae960939e6d734ca83a | KarthikSadashiva/LearningDash | /random_sequence_generator.py | 814 | 3.59375 | 4 | '''
@author: Karthik HS
@company: UST Global
@description: This program will generate random sequence of length {{ count }}, with lower limit set by {{ lower_limit}}
and upper limit being {{ upper_limit }} along with the inter sequence delay of {{ delay }}
'''
import random
import time
import ... |
9d50312fe8599c42212974e5df3eae6ac228f3ea | Adeon18/JSON_Nav | /json_nav/helpers.py | 238 | 3.59375 | 4 | '''
Helper functions for json.navigation.py
'''
import json
def read_file(path: str) -> dict:
"""
Read the data from a file and return it
"""
with open(path) as file:
data = json.load(file)
return data
|
5089fa9cfc4985d88676cee3fffb8ddc81f96d27 | yodirh/Data-Analysis-with-python | /part01-e15_two_dice_comprehension/src/two_dice_comprehension.py | 308 | 3.859375 | 4 | #!/usr/bin/env python3
def main():
s = {"({},{})".format(a,b) for a in range(1,7) for b in range(1,7) if a+b ==5 }
for i in s:
print (i)
#better way
#print("\n".join(f"({a},{b})" for a in range(1, 7) for b in range(1, 7) if a + b == 5))
if __name__ == "__main__":
main()
|
1e049d5c37b012c4bcbf96d74e32da4f0f92be47 | yodirh/Data-Analysis-with-python | /part01-e14_find_matching/src/find_matching.py | 339 | 3.734375 | 4 | #!/usr/bin/env python3
def find_matching(L, pattern):
li = []
counter =0
for i, x in enumerate(L):
if(pattern in x):
li.append(counter)
counter+=1
return li
def main():
print (find_matching(["sensitive", "engine", "rubbish", "comment"], "en"))
if __name__ == "__m... |
025285610adc12be4d6fa00ff628ddb3db313d8f | realzhangqingwei/python_code | /day02/calculator.py | 2,849 | 3.75 | 4 | #!/usr/bin/env python
import readline,sys
result = None
list_info = []
info = raw_input('input:').replace(' ', '')
if info.isalpha() or info == "":
print 'Sorry input error...'
sys.exit()
def rep(info):
global list_info
if '+' in info:
info = info.replace('+',' + ')
if '-' in info:
... |
76474a530b54496efa803079742ade3323e40816 | ehfkdl94/Learing-Python | /2019-07-03(FizzBuzz).py | 1,144 | 3.734375 | 4 | '''
for i in range(1, 101):
if i%3 == 0:
print('Fizz')
elif i%5 == 0:
print('Buzz')
else:
print(i)
for i in range(1, 101):
if i%3==0 and i%5==0:
print('FizzBuzz')
elif i%3==0:
print('Fizz')
elif i%5==0:
print('Buzz')
else:
print(i)
for... |
0c7e4d628394242a868d0c7509bd67eb6d934953 | ehfkdl94/Learing-Python | /2019-06-30(String).py | 536 | 3.53125 | 4 | hello = "Hello, World!"
print(hello)
hello = '안녕하세요'
print(hello)
print("'Hello Python'")
print("'Python Programming'")
print('\n')
hello = '''Hello, World!
안녕하세요.
Python입니다.'''
print(hello)
s = "Python isn't difficult"
print(s)
s = 'He said "Python is easy"'
print(s)
single_quote = '''"안녕하세요."
'파이썬 입니다.... |
b65750aa19c70969412c95edca1adb8103a66223 | ehfkdl94/Learing-Python | /2019-07-23(코드업기초100제).py | 665 | 3.75 | 4 | '''
x, y = map(int, input().split())
if x==y:
print(1)
else:
print(0)
x, y = map(int, input().split())
if x==0 and y==0:
print(1)
else:
print(0)
x, y = map(int, input().split())
if x>y:
print(x)
else:
print(y)
x, y, z = map(int, input().split())
if x<y and x<z:
print(x)
elif y<x and ... |
292fd911924f7200976172a5309f3c2b077f3341 | wanglethan/Synqrinus | /task1.py | 9,635 | 3.828125 | 4 | from parseTree import *
# Dictionary that contains acceptable operators and their precedence in an equation
# Operators with greater values have higher precedence
operators = {'+': 0, '-': 0, '*': 1, '/': 1}
def get_symbols(formula, acc_list=None, acc_str=None):
"""
Converts a string in the standard s... |
5a2dd5cb914cdbd397847ab8d77521e0612580e0 | shubhranshushivam/DSPLab_22-10-2020 | /ques8.py | 605 | 4.1875 | 4 | # 8. Find the Union and Intersection of the two sorted arrays
def union(arr1,arr2):
res=arr1+arr2
res=set(res)
return list(res)
def intersection(arr1, arr2):
res=[]
for i in arr1:
if i in arr2:
res.append(i)
return res
n1=int(input("Enter size of 1st array="... |
f97d40e433e5f2af646251ddc29182ff677cf153 | riyanhax/Control_Venta_Jugos | /parcial/prueba_2.py | 1,527 | 3.640625 | 4 | def bonifica(m,s):
if m == 'junio':
boni = (s * 50) / 100
else:
boni = (s * 2.5) / 100
return boni
def salpen(s):
salu = (s * 4) / 100
penc = (s * 4) / 100
totalsalpen = salu + penc
return salu, penc, totalsalpen
def diurna(s, d):
salhora = (s / 240)
incr... |
8c53b3193049d6a3f778574da2b57d4148c75fb2 | riyanhax/Control_Venta_Jugos | /fundamentos/metodo_burbuja.py | 1,442 | 3.5 | 4 | def ordenamientoBurbuja(lista, tam):
for i in range(1, tam):
for j in range(0, tam - i):
if (lista[j] > lista[j + 1]):
k = lista[j + 1]
lista[j + 1] = lista[j]
lista[j] = k
'''for i in range(0, n).
for j in range(i+1, n):
... |
0628cef94f729071add82f7a034a7b35c6c1f17c | riyanhax/Control_Venta_Jugos | /pruebasdeparcial/paso1.py | 2,350 | 4.03125 | 4 | '''
Un peaje de la ciudad quiere que usted sistematice el control del pago de los peajes, por este pasan tres tipos de automotores:
1. Vehiculos, 2. Camiones y 3. Tractomulas no se sabe cuantos de estos pasan al dia por el peaje,
pero cuando el dia finaliza se registra un tipo de automotor cero 0.
E... |
68e6efcdc4086a0fa0b60c1e556f87f42d0d047e | riyanhax/Control_Venta_Jugos | /notapsint2/notadefinity.py | 570 | 3.96875 | 4 | """
desarrollar un programa que conociendo las notas de Quices y trabajos muestre la nota
mínima que debe sacar en el examen para pasar la materia sabiendo que la nota mínima es 3.0.
"""
print("Cual es la nota definitiva de los Quices sabiendo que equivalen al 25% :")
notaquiz = float(input())
print("Cual es la n... |
0353fe3be0ae3f34b1f18aeca57ac4d2f9fd9dcd | riyanhax/Control_Venta_Jugos | /angelica/Parcial_00.py | 907 | 3.5 | 4 | def Total(lista1, lista2, lista3):
tal = 0
for i in range(0, len(lista1)):
tal += (lista1[i] * lista3[i])
if lista2[i] == "Pesado" or lista2[i] == "pesado":
tal += ((lista1[i] * lista3[i]) * 15) / 100
return tal
def llenar(Cant):
lista1 = []
lista2 = []
li... |
f63d31378426f8a97123f8ba98da4998d8e8a987 | riyanhax/Control_Venta_Jugos | /taller_fundamentos/ejercicio_clase_5_seno.py | 666 | 3.640625 | 4 | def factoril(num):
fac1 = 1
i = 1
while i <= num:
fac1 = fac1 * i
i = i +1
return fac1
def poten(x, y):
i = 1
pot = 1
while i <= y:
pot = pot * x
i += 1
return pot
def seno(angu):
sum = 0
i = 0
w = (angu * 3.1416) / 180
... |
55487d9b41dc4fcf79d0c0c169a255111d7ad56b | JacobStephen9999/Hashing-1 | /GroupAnagram.py | 803 | 3.75 | 4 | #Time Complexity : O(NLOG(N)) FOR SORTING THE ELEMENT And O(N)for traversing the strs
#Space Complexity : O(N)
# Code Ran in Leetcode :Yes
# Procedure:
class Solution(object):
def groupAnagrams(self, strs):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
element = {} ... |
0885e6632c3f66907d832c907cb7a608f74f32fc | BStarcheus/Music-Graph-Theory | /Triad.py | 8,367 | 3.625 | 4 | # This program contains notes for a single octave of the piano starting at middle C
# Frequencies for each piano key in single octave. 40 is middle C. 52 is C5
frequencies = {40:261.6256, 41:277.1826, 42:293.6648, 43:311.1270, 44:329.6276, 45:349.2282, 46:369.9944, 47:391.9954, 48:415.3047, 49:440, 50:466.1638, 51:493... |
f1cdea7b0b37acc82b02084a52930a6b4d79d1d9 | NishantGhanate/OpenCv | /SelfDrivingCar/HoughSpacePlot.py | 270 | 3.71875 | 4 | import matplotlib.pyplot as plt
from math import atan
x = [1,2,3,4,5,6,7,8,9,10]
y = [1,2,3,4,5,6,7,8,9,10]
plt.scatter(x,y)
plt.show()
Angle1 = atan((y(2)-y(1))/(x(2)-x(1)))
plt.plot(Angle1)
plt.show()
# Angle2 = atan((b(2)-b(1))/(a(2)-a(1)))
# xcos@ - ycos@ |
8971b8f5b84d8e46cdbfa73e8719f029d621a2ba | caster-au/python | /design1.py | 406 | 3.6875 | 4 | import turtle
import random
screen=turtle.Screen()
screen.bgcolor('black')
shape=turtle.Turtle()
shape.color('white')
shape.speed(200)
side=10
colors=['red','blue','yellow','green','orange','violet']
for i in range(50):
shape.color(random.choice(colors))
for j in range (50):
shape.forward(side)
... |
60579b9081a69c58be14a0c23d6fe44f8ae65f08 | Deloss22/SoftEng_Proj_18-19 | /code/mobile_app.py | 1,255 | 3.53125 | 4 | from math import radians, cos, sin, asin, sqrt
import numpy as np
class Mobile_app(insert,system):
def __init__(self):
pass
def column(matrix, i):
return [row[i] for row in matrix]
def find_nearest_parking():
park_list=super.request("parking_list")
c2=column(park_list,2)
... |
f40f0385cbf9e8d986e9803988be61f40dcfee45 | Paladiamors/PlanetsNuPy | /planets.py | 2,772 | 3.578125 | 4 | import math
class Planet:
def __init__(self, temp, pop, supplies=0, mc=0, factories=0, mines=0, defences=0, supply=0, tax=0):
self.temp = temp
self.pop = pop
self.supplies = supplies
self.factories = factories
self.mc = mc
self.mines = mines
self.defences = ... |
21b618d159deeb658fd6d6fc1156e6983dd973c5 | jadenpadua/Data-Structures-and-Algorithms | /CTCI/isUnique.py | 726 | 3.984375 | 4 | def isunique(str):
# If length of string is greater than ascii value for unique chars, return false
if len(str) > 128:
return False
# Sets every ascii value to false initially
arr = [False] * 128
for char in str:
index = ord(char) #Ascii value for that character
# if in bool... |
fd8b7a3eb61438223ca6563de920c9e7f8eab7a4 | jadenpadua/Data-Structures-and-Algorithms | /efficient/validParenthesis/validParenthesis.py | 1,772 | 4.125 | 4 | #Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
#imports functions from our stack data structure file
from stack import Stack
#helper method checks if our open one and closed are the same
def is_match(p1, p2):
if p1 == "(" and p2 == ")":
... |
3134e0740e71bd30fa8ee4a7cc63400ef98df506 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/typing_game.py | 571 | 3.671875 | 4 | You're in the midst of creating a typing game.
Create a function that takes in two lists: the list of user-typed words, and the list of correctly-typed words and outputs a list containing 1s (correctly-typed words) and -1s (incorrectly-typed words).
# Inputs:
User-typed: ["cat", "blue", "skt", "umbrells", "paddy"]
Co... |
4e6cc402f06996598bf2d211da5eef90b9e3852f | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/removeDuplicates.py | 590 | 3.984375 | 4 | #Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return
#the new length
def remove_duplicates(nums):
#index to compare
i = 0
for j in range(1,len(nums)):
#if not duplicate adjust index pointer and copy the value of j into that updated pointer
... |
fafa0f9eb4e599490374a506858cca8988de0964 | jadenpadua/Data-Structures-and-Algorithms | /AE/bubbleSort_sol.py | 231 | 3.953125 | 4 | def bubbleSort(array):
counter = 0
for i in range(len(array)-1 - counter):
for j in range(i+1,len(array)):
if array[i] > array[j]:
temp = array[i]
array[i] = array[j]
array[j] = temp
counter += 1
return array
|
3aeae7676fd6e78c48062cf2979c3d1737426793 | jadenpadua/Data-Structures-and-Algorithms | /trees/closestValueInBST.py | 548 | 3.578125 | 4 | def closestValueInBst(tree, target):
return self.findClosestValueInBSTHelper(tree, target, float("inf"))
def findClosestValueInBSTHelper(node,target, closest):
if node is None:
return closest
if abs(target - closest) > abs(target - node.value):
closest = node.value
if target < no... |
a58926e3fdf857bda1e1a4633c135bca8ec608f1 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/romanToInt.py | 542 | 4.09375 | 4 | #Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
def roman_to_integer(s):
rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
int_val = 0
for i in range(len(s)):
if(i > 0 and rom_val[s[i]] > rom_val[s[i-1]]):
int... |
3b98b69d8a5182fca01f3ceea90444eff427a5a6 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/largest_swap.py | 370 | 4.21875 | 4 | Write a function that takes a two-digit number and determines if it's the largest of two possible digit swaps.
To illustrate:
largest_swap(27) ➞ False
largest_swap(43) ➞ True
def largest_swap(num):
original = num
d = 0
rev = 0
while num > 0:
d = num % 10
num = int(num/10)
rev = rev*10 + d
if rev > origin... |
2b59a801496f448aaaf60f9cff23dd9fed579643 | jadenpadua/Data-Structures-and-Algorithms | /75/binary/numberOfOnes.py | 329 | 3.625 | 4 |
class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 0
else:
#Adds a '1' if there are 2 1's stacked on each other, else shifts n right one space
return self.hammingWeight(n>>1) + ... |
d6404fac5d7e72741972ade1038e83de849ac709 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/needleInHaystack.py | 564 | 4.25 | 4 | # Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
def strStr(haystack,needle):
for i in range(len(haystack) - len(needle) + 1):
if haystack[i:i+len(needle)] == needle:
return i
return - 1
haystack = "Will you be able to find the ne... |
b2650417711537fd9a1567da35c17786adad5723 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/min_removal.py | 378 | 4 | 4 | Create a function that returns the minimum number of elements removed to make the sum of all elements in a list even.
Examples
minimum_removals([1, 2, 3, 4, 5]) ➞ 1
minimum_removals([5, 7, 9, 11]) ➞ 0
minimum_removals([5, 7, 9, 12]) ➞ 1
def minimum_removals(lst):
sum = 0
for i in range(len(lst)):
sum += lst[i]
... |
3702a2e59ec372033ed9f0f3cb2aa2af7bc4653b | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/alternating_one_zero.py | 626 | 4.46875 | 4 | Write a function that returns True if the binary string can be rearranged to form a string of alternating 0s and 1s.
Examples
can_alternate("0001111") ➞ True
# Can make: "1010101"
can_alternate("01001") ➞ True
# Can make: "01010"
can_alternate("010001") ➞ False
can_alternate("1111") ➞ False
def can_alternate(s):
... |
0ccbe214b5bc91d4c53e4f16218b0835b1b9d513 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/digits_in_list.py | 689 | 4.3125 | 4 | #Create a function that filters out a list to include numbers who only have a certain number of digits.
#Examples
#filter_digit_length([88, 232, 4, 9721, 555], 3) ➞ [232, 555]
# Include only numbers with 3 digits.
#filter_digit_length([2, 7, 8, 9, 1012], 1) ➞ [2, 7, 8, 9]
# Include only numbers with 1 digit.
#filter... |
71f07af33e0a35aadd6e19c965c898d260f368e8 | jadenpadua/Data-Structures-and-Algorithms | /CTCI/isPermutationBF.py | 357 | 3.890625 | 4 | # Sort the strings
def is_permutation(str1, str2):
# Sort string one and string two
sorted_str1 = sorted(str1)
sorted_str2 = sorted(str2)
#Now compare lengths of the sorted strings
if len(sorted_str1) != len(sorted_str2):
return False
return True
print(is_permutation("dadyeets", "dady... |
62e32d51ac3f9665339a7b681691c34fcb42ae09 | jadenpadua/Data-Structures-and-Algorithms | /bruteforce/check_even.py | 153 | 3.84375 | 4 | #Check if numbers in an array are all even or not
def check_all_even(lst):
for i in range(len(lst)):
if lst[i] % 2 != 0:
return False
return True
|
c5147e13d34501823f1fe6987d6b8fef8c7098cc | jadenpadua/Data-Structures-and-Algorithms | /AE/hasSingleCycle.py | 896 | 3.6875 | 4 | def hasSingleCycle(array):
# keep tabs on current idx and building elements
numElementsVisited = 0
currentIdx = 0
# while numbers visited is less than array length
while numElementsVisted < len(array):
#checks if it went bax to index 0, we know there are multiple cycles hewre
if numElementsVisited > 0 and curr... |
dcfd19f4ca5dc8d7999b8874a0d6e24d97d05d8c | jadenpadua/Data-Structures-and-Algorithms | /AE/getNthFib_BF.py | 136 | 3.546875 | 4 | def getNthFib(n):
if n == 2:
return 1
elif n == 1:
return 0
else:
return getNthFib(n-1) + getNthFib(n-2)
TC: O(2^n)
SC: O(N)
|
52015a01e3ba32f1c78e502dd3a6a226cb5b17af | jadenpadua/Data-Structures-and-Algorithms | /trees/levelOrder.py | 574 | 3.703125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def levelOrder(self, root):
res = []
self.dfs(root,0,res)
return res
def dfs(self,root, ... |
08535cc31b706298c91eac873a38b5653ea98eaa | ukhanedian/Data_Structures | /doubly_linkedlist.py | 3,537 | 3.875 | 4 | class Node(object):
def __init__(self, data = None, next = None, prev = None):
super(Node, self).__init__()
self.data = data
self.next = next
self.prev = prev
def __str__(self):
return "{} -> {}".format(self.data, self.next)
class LinkedList(object):
def __init__(self):
super(Linked... |
84d5fef5a0c4f7de4606fcfb9ed1ee4909d00420 | ankitniranjan/The-Complete-Data-Structure-and-Algorithms-Course-in-Python-Udemy | /1.Recursion/fibonacci.py | 239 | 4.1875 | 4 | #!/usr/bin/env python3
def fibonacci(n):
assert n >= 0 and int(n) == n, "Input should be of integer type"
if n in [0, 1]:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(4))
#Output
3
|
3307091e1d16ebdc19e881a31c48cc4057e4e514 | jyameo/Algorithms-and-Data-Structures | /Recursion & Backtracking/sudoku.py | 4,024 | 3.734375 | 4 | def check_sudoku(grid):
if type(grid) is not list or len(grid) != 9:
return None
n = len(grid)
for row in range(n):
if type(grid[row]) is not list or len(grid[row]) != n:
return None
for col in range(n):
val = grid[row][col]
if type(va... |
9bc9d777afe8b662c8d23798868f92cfd486e268 | jyameo/Algorithms-and-Data-Structures | /Operating System/AsyncWrite.py | 749 | 3.921875 | 4 | from threading import Thread, Lock
from time import sleep, time
class AsyncWrite(Thread):
def __init__(self, text, out):
Thread.__init__(self)
self.text = text
self.out = out
def run(self):
print("Started Background File Write to " + self.out)
f = open(self.out,... |
36c27f4c866e858352c38f6b9339f5a5932849d1 | jyameo/Algorithms-and-Data-Structures | /Graphs/BreathFirstSearch.py | 814 | 3.875 | 4 | class Node(object):
def __init__(self, data):
self.data = data
self.neighbors = []
self.visited = False
self.predecessor = None
class BreathFirstSearch(object):
def bfs(self, startNode):
queue = [startNode]
startNode.visited = True
while queue:
... |
1011c449c46c2c2172763dad49a5593995ac081d | SonishMaharjan/DataStructureAndAlgorithmPython | /DoublyLinkedList.py | 3,287 | 3.703125 | 4 | class Node:
def __init__(self,value =None):
self.prev = None
self.item = value
self.next = None
class DLinkList:
def __init__(self):
self.head = Node()
self.noOfItem = 0
def insertAtEnd(self,value):
counterNode = self.head
node = Node(value)
... |
24798239eab5a2a5f0c1a4faaedfcf0fb76850a5 | Dimonsda/Recipe-book | /sqlite_db.py | 3,026 | 3.546875 | 4 | """Модуль базы данных sqlite для приложения"""
from sqlite3 import connect
CONN = connect('cooking_book.db')
CURSOR = CONN.cursor()
CURSOR.execute("""PRAGMA foreign_keys = ON""")
CURSOR.execute("""CREATE TABLE if not exists dish
(id integer PRIMARY KEY AUTOINCREMENT,
name ... |
c81fbf2a537b1ebd817bb47ace17a6986d1c9962 | benceharomi-uob/Machine-Learning-COS6026-B | /labs/lab_01/practice.py | 1,046 | 3.75 | 4 | ## Task 1
def is_even(num):
return not num % 2
# print([i for i in range(1, 10) if (is_even(i))])
## Task 2
my_dictionary = {"First name": "Bence", "Second Name": "Háromi"}
# print(my_dictionary)
# for item in my_dictionary.items():
# print(item)
## Task 3
def is_first_and_last_same(list):
return lis... |
80b15569f8adf836485424359c93bfaf7f87cfd3 | giovic16/Python | /solo9.py | 256 | 4.1875 | 4 | #Faça um Programa que peça a temperatura em graus Farenheit, transforme e mostre a temperatura em graus Celsius.
fahrenheit = int(input('Entre com a temperatura:'))
celsius = (fahrenheit-32)//1.8
print('A temperatura transofrmada é {}' .format(celsius)) |
02e415fd8cd4019833f5e66e55cc4f1ca1fb434c | ransty/hobowars-scripts | /Auto Rat Feeder.py | 1,815 | 3.515625 | 4 | from selenium import webdriver
chrome_path = r"C:\Users\user\Desktop\chromedriver\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
print("Logging in...")
driver.get("http://hobowars.com")
driver.find_element_by_xpath("""//*[@id="login"]""").click()
driver.find_element_by_xpath("""//*[@id="login"]""").send_keys(... |
8d739c7a46103152de69c2a98ba4411f14de6c31 | BenjaminPeter/pooGUI | /matrix.py | 7,455 | 4.28125 | 4 | import Tkinter as tk
"""modified after http://stackoverflow.com/questions/11047803/creating-a-table-look-a-like-tkinter"""
class ExampleApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
t = SimpleTable(self, 10,10)
t.pack(side="top", fill="x")
t.set(0,0,"Hello, world")
class Simp... |
57be92fde5aacbb56b5b41873c6ed92c07418cfd | ocallam6/STLF-Eirgrid | /max_load/analysis.py | 925 | 3.78125 | 4 | """
Prototype1
Neural Network Using Keras
Predicts next day values. 48 steps ahead forecast.
Uses daytype,temperature,holidays and utilises autocorrelation.
Plots and Analysis
"""
def plot_values(df):
import pandas as pd
import matplotlib.pyplot as plt
plt.plot('Date and Time','Load',data=df,mark... |
65ceacc4450513c180b2535c589aed4c0b5f3ee1 | nmakro/PythonQueues | /customer/customer.py | 690 | 3.53125 | 4 | class Customer(object):
def __init__(self):
self.customer_id = 0
self._waiting_time = 0.0
self.time_started_waiting = 0.0
self.time_in_queue = 0.0
def set_time_in_queue(self, current_time):
self.time_in_queue = (current_time - self.time_started_waiting) * 10.0
def s... |
d0235d6b2122af4db46a59aa3af0ac2d6660332a | hibfnv/Alien_Invasion | /rocket_in.py | 1,016 | 3.75 | 4 | """
因为是火箭的移动,在主屏幕已经设置好相关的信息之后,我们没有看到火箭在哪里,所以在此处,我们就应该定义一个火箭了。
为了让火箭的图片显示在屏幕上,我们同样需要导入pygame模块,让它能够加载我们的图片到屏幕中去
"""
import pygame
class Rocket():
def __init__(self, screen):
"""初始化火箭的起始位置"""
self.screen = screen
# 加载火箭图片,并绘制火箭的大小的矩形
self.image = pygame.im... |
98b28d95edbd6bc1a60469775efa6004048ecc05 | ShiYujin/IntroductionToAlgorithms | /MergeSort.py | 728 | 3.6875 | 4 | # Merge sort.chapter2.3.1
__author__ = 'ShiYujin'
__date__ = '2015.5.24'
def merge(A, p, q, r):
import copy
L = copy.deepcopy(A[p:q])
R = copy.deepcopy(A[q:r])
L.append(float("inf")) # sentinel
R.append(float("inf"))
i = 0
j = 0
for k in range(p, r):
if L[i] <= R[j]:
... |
d1754f98c2f0f958139a12e336dafea76d09ed02 | DaScient/Mahalanobis-Classification | /C_string_appendor.py | 1,211 | 3.5 | 4 | 1#legit = 0
#cft = 1
#pre = input('Press 1 for CFT or 0 for LEGIT: ')
pre = 'C'
prefix = pre + ','
suffix = ''
print("You are appending " +pre+ "'s to the beginning of each line.")
#-------------------------------------------------------------
#*************************************************************
#insert ... |
0cdb7cc8800e867a1ceb2ba3d144b2141e13fd60 | JawshyJ/Coding_Practice | /Data Analysis/CSV Reader.py | 2,347 | 4.09375 | 4 | # 9/20/2020 - CSV Reader
# The purpose of this program is to read data from a csv file and to return basic information about it
# Tasks
## Output how many lines and filled cells there are
## Make it so that the program creates a new entry for each header column
## User will be able to attain statistical data, such as: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.