blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
fa5a9cb791bfdacbbac3ac9ab057404daef6c8bf
marcin-skurczynski/IPB2017
/Michal Starzec ATM HM.py
2,404
3.90625
4
balance=2475.11 print(" > > > > eCard < < < < ") for i in range (1,4): PIN = int(input('Please Enter You 4 Digit Pin: ')) if PIN == (7546): print('Your PIN Is Correct\n') print(""" 1) Balance 2) Withdraw 3) Deposit 4) Return Card """) Option=int(input...
bb00780bcd9e892df3913c24da81fb1b15f09e41
Descalzo404/CS50-Problem-Sets
/Dna/dna.py
2,693
3.875
4
from sys import argv, exit import csv import re from cs50 import get_string def main(): # Open the data base csv csv_file = argv[1] with open(csv_file) as f: reader = csv.reader(f) # Getting the opitions of STR's from the header of the csv file str_options = next(reader)[1...
d4627d478b1aa4b5d9b061d66ce6cb32643b5bc7
HyeranShin/Deep-Learning-Lecture
/deep-learning-master/tensorflow_02.py
614
3.65625
4
x = 1 y = x + 9 print(y) # 10 import tensorflow as tf # python 소스 코드 내의 x와 뒤의 string x는 다르다. # 첫번째 x는 python 변수 # 두번째 x는 TensorFlow(그래프) 상의 이름 x = tf.constant(1, name = 'x') y = tf.Variable(x + 9, name = 'y') print(y) # <tf.Variable 'y:0' shape=() dtype=int32_ref> print(y.value()) # Tensor("y/read:0", shape=(), dtyp...
fd541455bd5ad5ca18866082a77842561ca1b2b7
cuotos/bash-python-caller
/test_python_helpers.py
2,384
3.671875
4
#!/usr/bin/env python import unittest import python_helpers as ph import re class TestPythonHelper(unittest.TestCase): def test_helper_should_reject_calls_if_wrong_number_of_arguments_used(self): # not expecting any arguments def f(): pass # pass in an argument that isnt expe...
db3e8d4e2f32b0327c4d4ebad59c6270ddfa92ba
syedshameersarwar/python
/quicksortAssignment.py
1,650
4
4
def readfile(): file = open("QuickSort.txt") numbers = [] for line in file: numbers.append(int(line.strip())) return numbers def quickSort(List,start,end,partition = None ): if start < end: comparisions = end - start pivot_index = partition(List,start,end) comparisi...
b2788add12ce65a30a8856de3575d0d7100d4591
syedshameersarwar/python
/secondMaximum.py
3,011
3.5625
4
'''You are given as input an unsorted array of n distinct numbers, where n is a power of 2.Give an algorithm that identifies the second-largest number in the array,and that uses at most n+log2n−2 comparisons.''' def findMaxTournament(List): if len(List)==1: return List[:] mid = len(List)//2 firstHa...
9c7d666c90a63956d4cb2a7c36a26cbe5f1fb46d
syedshameersarwar/python
/infixpostfixprefrix.py
2,726
3.84375
4
class Stack(object): def __init__(self): self.items = [] def is_empty(self): return self.items==[] def push(self,value): self.items.append(value) def pop(self): if self.size()==0: return None return self.items.pop() def peek(self): if self....
3b8b8cc921b2bd664584adca2b8add2773823e36
syedshameersarwar/python
/BresehhamCirle-algo.py
740
4.03125
4
from graphics import * import math import numpy as np def drawPixel(x,y): global screen screen.plotPixel(int(x),int(y),"red") def BresenhamCircle(Xc,Yc,r): x = 0 y = r d=3- (2*r) while y > x: drawSymmetricPoints(Xc,Yc,x,y) if d <0: d=d + 4*x +6 else: ...
296dd75cbc77a834515929bc0820794909fb9e54
sdaless/pyfiles
/CSI127/shift_left.py
414
4.3125
4
#Name: Sara D'Alessandro #Date: September 12, 2018 #This program prompts the user to enter a word and then prints the word with each letter shifted left by 1. word = input("Enter a lowercase word: ") codedWord = "" for ch in word: offset = ord(ch) - ord('a') - 1 wrap = offset % 26 newChar = chr(ord('a...
138fd202c91719c37dbd579d03246426fb42bd4b
sdaless/pyfiles
/Hw2pr1.py
1,070
3.875
4
# Name: # Hw2pr1.py # STRING slicing and indexing challenges h = "harvey" m = "mudd" c = "college" # Problem 1: hey answer1 = h[0] + h[4:6] print(answer1,"\n") # Problem 2: collude answer2 = c[0:4] + m[1:3] + c[-1] print(answer2,"\n") # Problem 3: arveyudd answer3 = h[1:] + m[1:] print(answer3,"\n") # Problem...
b3dbf8b4190548cd3787fbe0021ca46244b116af
sdaless/pyfiles
/CSI127/turtle_color.py
208
4.53125
5
#Sara D'Alessandro #A program that changes the color of turtle #September 26th, 2018 import turtle tut = turtle.Turtle() tut.shape("turtle") hex = input("Enter a hex string starting with '#' sign: ") tut.color(hex)
d6ff6244153119d0556db2ca0720e18b373af937
sdaless/pyfiles
/CSI127/octagon.py
164
3.9375
4
#Name: Sara D'Alessandro #Date: August 29, 2018 #This program draws an octagon. import turtle tia = turtle.Turtle() for i in range(8): tia.forward(50) tia.right(45)
3bcbd6b47d2963aa858db475bb55fd4137523a89
sdaless/pyfiles
/CSI127/dna_string.py
306
4.09375
4
#Name: Sara D'Alessandro #Date: September 23, 2018 #This program prompts the user for a DNA string, and then prints the length and GC-content. dna = input("Enter a DNA string: ") l = len(dna) print("The length is", l) numC = dna.count('C') numG = dna.count('G') gc = (numC + numG) / l print('GC-content is', gc)
9f53a5c4227a048e38bdf88430c1de6c69da6493
wenqiang0517/PythonWholeStack
/day15/第一次考试机试题讲解.py
5,051
3.578125
4
# 机试题 # 1.lis = [['哇',['how',{'good':['am',100,'99']},'太白金星'],'I']] (2分) lis = [['哇', ['how', {'good': ['am', 100, '99']}, '太白金星'], 'I']] # o列表lis中的'am'变成大写。(1分) # lis[0][1][1]['good'][0] = lis[0][1][1]['good'][0].upper() # print(lis) # o列表中的100通过数字相加在转换成字符串的方式变成'10010'。(1分) # lis[0][1][1]['good'][1] = str(lis[0][1][1]...
d2322f9a5514dbe9dd807dab9053d3b1ef7bc35f
wenqiang0517/PythonWholeStack
/day06/03 代码块.py
1,215
3.65625
4
# 代码块 # * 代码块:我们的所有代码都需要依赖代码块执行,Python程序是由代码块构造的。块是一个python程序的文本,他是作为一个单元执行的。 # * 一个模块,一个函数,一个类,一个文件等都是一个代码块 # * 交互式命令下一行就是一个代码块 # 两个机制同一个代码块下,有一个机制,不同的代码块下,遵循另一个机制 # 同一代码块下的缓存机制 # * 前提条件:同一代码块内 # * 机制内容:pass # * 适用的对象:int bool str # * 具体细则:所有的数字,bool,几乎所有的字符串 # * 优点:提升性能,节省内存 # 不同代码块下的缓存机制: 小数据池 # * 前提条件:不同...
a7512d155221f8cf092c99cb58320fdb2ae6c2db
wenqiang0517/PythonWholeStack
/day26/08-反射的例子.py
1,316
3.5625
4
class Payment: pass class Alipay(Payment): def __init__(self, name): self.name = name def pay(self, money): dic = {'uname': self.name, 'price': money} print('%s通过支付宝支付%s钱成功' % (self.name, money)) class WeChat(Payment): def __init__(self, name): self.name = name def ...
f8571a2378d85ae0d51811f2c9c5b44d3cd0b475
wenqiang0517/PythonWholeStack
/day23/02-命名空间问题.py
3,168
3.859375
4
# 类的成员和命名空间 # class A: # Country = '中国' # 静态变量/静态属性 存储在类的命名空间里的 # def __init__(self,name,age): # 绑定方法 存储在类的命名空间里的 # self.name = name # self.age = age # def func1(self): # print(self) # def func2(self):pass # def func3(self):pass # def func4(self):pass # def func5...
8b1a9df76b23b6f000a74cd458e84ac32b2fa2e4
wenqiang0517/PythonWholeStack
/day01/test01.py
534
3.78125
4
# 炸金花发牌游戏(奖品) # 生成一副扑克牌,去除大小王 # 5个玩家,每个人发三张牌 # 最后计算谁是赢家(进阶) a = 1 number = [] poker = [] letter = ['J', 'Q', 'K', 'A'] design_color = ['H', 'M', 'F', 'X'] while a < 10: a = a + 1 number.append(str(a)) num = number + letter for i in design_color: for y in num: poker.append(i + y) print(poker) # print...
18e3c19deb58a4a6933c5115994dea8e4e327e1d
wenqiang0517/PythonWholeStack
/day22/03 面向对象编程.py
3,361
4.125
4
# 先来定义模子,用来描述一类事物 # 具有相同的属性和动作 # class Person: # 类名 # def __init__(self,name,sex,job,hp,weapon,ad): # # 必须叫__init__这个名字,不能改变的,所有的在一个具体的人物出现之后拥有的属性 # self.name = name # self.sex = sex # self.job = job # self.level = 0 # self.hp = hp # self.weapon = weapon...
07f0648241f066c609a566dbd1ca4688530438f8
wenqiang0517/PythonWholeStack
/day25/04-父类对子类的约束.py
2,960
3.5625
4
# 普通的类 # 抽象类 是一个开发的规范 约束它的所有子类必须实现一些和它同名的方法 # 支付程序 # 微信支付 url连接,告诉你参数什么格式 # {'username':'用户名','money':200} # 支付宝支付 url连接,告诉你参数什么格式 # {'uname':'用户名','price':200} # 苹果支付 # class Payment: # 抽象类 # def pay(self,money): # '''只要你见到了项目中有这种类,你要知道你的子类中必须实现和pay同名的方法''' # raise N...
831e5bb5428964879e6cf64ca8291cd1771db5dc
wenqiang0517/PythonWholeStack
/day23/01-内容回顾.py
1,619
3.609375
4
# 面向对象 # 类 对象/实例 实例化 # 类是具有相同属性和相似功能的一类事物 # 一个模子\大的范围\抽象 # ***************** # 你可以清楚的知道这一类事物有什么属性,有什么动作 # 但是你不能知道这些属性具体的值 # 对象===实例 # 给类中所有的属性填上具体的值就是一个对象或者实例 # 只有一个类,但是可以有多个对象都是这个类的对象 # 实例化 # 实例 = 类名() # 首先开辟空间,调用init方法,把开辟的空间地址传递给self参数 ...
269201af84089e19d224373dbdaf11e941033cf8
wenqiang0517/PythonWholeStack
/day25/07-作业.py
5,634
3.96875
4
# 1,面向对象为什么要有继承 # 当两个类中有相同或相似的静态变量或绑定方法时,使用继承可以减少代码的重用,提高代码可读性,规范编程模式 # 2,python继承时,查找成员的顺序遵循什么规则 # 经典类 -- 深度优先 # 新式类 -- 广度优先 # 3,看代码,写结果 """ class Base1: def f1(self): print('base1.f1') def f2(self): print('base1.f2') def f3(self): print('base1.f3') self.f1() class Bas...
6f566cf1fba184c37d48176800c2a6073b4041fb
YoniSchirris/SimCLR-1
/modules/deepmil.py
6,942
3.625
4
import torch as torch import torch.nn as nn import torch.nn.functional as F class Attention(nn.Module): def __init__(self, hidden_dim=2048, intermediate_hidden_dim=128, num_classes=2, attention_bias=True): super(Attention, self).__init__() self.L = hidden_dim # self.D = int(hidden_dim / 2...
51a2d991ba8669d5fa8a30d849904c0bb3c13861
yangxin6/3DPointCloud
/lesson2/bst.py
5,093
3.546875
4
import numpy as np import math from lesson2.result_set import KNNResultSet, RadiusNNResultSet class Node: def __init__(self, key, value=-1): self.left = None self.right = None self.key = key self.value = value def __str__(self): return "key: %s, value: %s" % (str(self...
344be7d9070c5770d993d6376d6bca00c0d171d1
type9/CS-1.2-Intro-Data-Structures
/Code/dictionary_words.py
1,263
3.890625
4
import random import sys from fisheryates_shuffle import shuffle def random_sentence(num_words): dictionary = open('/usr/share/dict/words', 'r') dictionary_list = list() word_list = list() # final list of words num_lines = 0 # total word count for line in dictionary: # converts each line of the d...
15f73a195b2da78189198730bb2f6ffb12fc70dc
BhujayKumarBhatta/myflask
/experiments/ospath.py
1,426
3.5
4
import os print(" current working directory is % s" % os.getcwd()) print("dirname of current file is % s" % os.path.dirname(__file__)) print("realpath of current file is % s" % os.path.realpath(__file__)) print("abspath of current file is % s" % os.path.abspath(__file__)) print(" one level up previous dir of curren...
5f7c7a681de3287b0e2c05bb05d18df626eb3b54
sudev/dsa
/graph/UsingAdjacencyList.py
1,677
4.15625
4
# A graph implementation using adjacency list # Python 3 class Vertex(): def __init__(self, key): self.id = key # A dictionary to act as adjacency list. self.connectedTo = {} def addEdge(self, vert, w=0): self.connectedTo[vert] = w # Repr def __str__(self): return str(self.id) + ' connectedTo: ' +...
9fd9d17de19a87eadcace063eab22e9a8f91a3e5
gurupatoh/pypy
/employee.py
1,443
3.65625
4
class Employee: def __init__(self, first_name, last_name, employee_id): self.first_name = first_name self.last_name = last_name self.employee_id = employee_id self.base_salary = 0 def set_base_salary(self, salary): self.base_salary = salary class TeachingStaff (Employee): def __init__(self...
c461a5df6e2ef47e30b8a95d8da5f9373e31f182
TrevorHuval/SchemePrettyPrinter
/Parse/Scanner.py
7,594
3.71875
4
# Scanner -- The lexical analyzer for the Scheme printer and interpreter import sys import io from Tokens import * class Scanner: def __init__(self, i): self.In = i self.buf = [] self.ch_buf = None def read(self): if self.ch_buf == None: return self...
45c512a90c4429bb6cc8303d11845d3205583e70
TrevorHuval/SchemePrettyPrinter
/Special/Special.py
404
3.78125
4
# Special -- Parse tree node strategy for printing special forms from abc import ABC, abstractmethod # There are several different approaches for how to implement the Special # hierarchy. We'll discuss some of them in class. The easiest solution # is to not add any fields and to use empty constructors. cla...
31d68d11fdc06c09e0721e6541024eb33b585c91
selimozen/Hackerrank
/Python/ifelse.py
546
4.3125
4
#ENG: if n is odd, print Weird , if n is even and in the inclusive range of 2 to 5, print Not Weird, #if n is even and in the inclusive range of 6 to 20, print Weird, if is even and greater than 20, print Not Weird #TR: Eğer n sayısı tekil ise, 'Weird' yazdır, eğer n sayısı 2 veya 5'e eşit veya arasında ise Not Weird...
a961f3be1e5d83fbd174bc21851b0753bec84c04
andersonresende/learning_python
/chapter_19/recursion.py
1,077
4.21875
4
#nao mudar o tipo de uma variavel e uma boa pratica #nao usar globais dentro de funcoes, pois pode criar dependencias. #durante a recursao o escopo das funcoes e mantido, por isso funciona. #recursao exige que vc crie uma funcao, enquanto procedural nao. #vc nao pode alterar os valores de variaveis a partir de fora da ...
609add66f670ba8c7b3863bc12603b83e71c99af
andersonresende/learning_python
/chapter_18/min.py
723
4.125
4
def min1(*args): ''' Retorna o menor valor, passado em uma tupla. ''' res = args[0] for arg in args[1:]: if arg < res: res = arg return res print min1(10,2,3,4) def min2(first, *rest): ''' Retorna o menor valor, recebendo um argumento inicial e outros em uma tupla. ''' for arg in rest: if arg < first:...
796c1142383f647d8774b94317198df0904523bd
rwesterman/MachineMarchMadness
/setup/clean_tables.py
2,256
3.546875
4
import pandas as pd import re from pprint import pprint def get_xl_data(): """ Returns a dictionary of dataframes where each key is a sheet name and each value is a dataframe :return: """ # Setting sheet_name = None imports all sheets df_dict = pd.read_excel("Training_Data\\KenPom_Rankings.xlsx...
281fe91d03a3841187b5856bf42524a557c8b28b
dainbot/python-programming-practice
/Algorithm/gcd.py
376
3.921875
4
# Find the greatest common denominator of two numbers. """ 1 For two integers a and b, where a > b, divide a by b 2 If the remainder, r, is 0, then stop: GCD is b 3 Otherwise, set a to b, b to r, and repeat at step 1 until r is 0 """ def gcd(a, b): while (b != 0): t = a a = b b = t...
0406e3cc0d3d09c9bbaf400c2808ebf0737d31d4
bharathkkb/peer-tutor
/peer-tutor-api/timeBlock.py
1,230
4.25
4
import time import datetime class TimeBlock: """ Returns a ```Time Block``` object with the given startTime and endTime """ def __init__(self, start_time, end_time): self.start_time = start_time self.end_time = end_time print("A time block object is created.") def __str__(...
ff81de53a5684a0b156037e3e60b5ae9fa4127a7
MB-TAYLOR/ScrabbleAR-Grupo29
/ScrabbleAR_py/AiMaquina.py
3,281
3.578125
4
import itertools as it from pattern.es import spelling,lexicon,parse Tipo= {'adj':["AO", "JJ","AQ","DI","DT"], 'sus':["NC", "NCS","NCP", "NNS","NP", "NNP","W"],#Revisar volver a comprobar en facil , primero en spell y lexi luego en sus 'verb':[ "VAG", "VBG", "VAI","VAN", "MD", "VAS" , "VMG" , "VMI", "VB", "VMM" ,"VMN"...
06a1a7c44faa8688ce5d3229fc019aae1fe86fe5
chennavamshikrishna/ml_algorithms
/linear regression.py
595
3.65625
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np dataset=pd.read_csv('Salary_Data.csv') #print(dataset) X=dataset.iloc[:,:-1].values y=dataset.iloc[:,1].values from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(X,y,random_state=0,test_size=1/3) ##pr...
6edfeb4705a4f49b354ef9571029d19b9848f8e5
dani3l8200/100-days-of-python
/day1-printing-start/project1.py
454
4.28125
4
#1. Create a greeting for your program. print('Welcome to Project1 of 100 Days of Code Python') #2. Ask the user for the city that they grew up in. city_grew_user = input('Whats is your country that grew up in?\n') #3. Ask the user for the name of a pet. pet_of_user = input('Whats is the name of any pet that having?\n'...
653c613be1c54d924fe2bf398295601817ab30a5
dani3l8200/100-days-of-python
/day1-printing-start/exercise1.1.py
265
3.828125
4
print('Day 1 - Python Print Function') print() print('This function Print() is used for print strings, objects, numbers etc') print('''Is posibble obtains errors, it is possible if not use parenthesis close or triple single quote for indicate a print extend xd''')
399c6abffb5b4bc60849a84d0c0d112ab7cd2f96
dyshko/hackerrank
/World Codesprint 13/P4.py
911
3.515625
4
#!/bin/python3 import os import sys # Complete the fewestOperationsToBalance function below. def fewestOperationsToBalance(s): rs = [] for c in s: if c == '(': rs.append(c) if c == ')': if len(rs) > 0 and rs[-1] == '(': rs.pop() else: ...
593aa904c7c4b0dd294d25debb3eae2f67f1dc62
imsilence/refactoring
/chapter01/v03.py
1,823
3.5
4
#encoding: utf-8 import json import math ''' 以查询替代临时变量 内联局部变量 注意: 重构和性能之间首选选择重构,重构完成后进行性能调优 ''' def statement(invoice, plays): total = 0 credits = 0 print("Statement for: {0}".format(invoice['customer'])) def play_for(performance): return plays.get(performance.get('playId', 0), {}) de...
215ae22230731d3c486c7b652128fb1b212c78e0
islamrumon/PythonProblems
/Sets.py
2,058
4.40625
4
# Write a Python program to create a new empty set. x =set() print(x) n = set([0, 1, 2, 3, 4]) print(n) # Write a Python program to iteration over sets. num_set = set([0, 1, 2, 3, 4, 5]) for n in num_set: print(n) # Write a Python program to add member(s) in a set. color_set = set() color_set.add("Red") print...
a8d0633d0c553059cb45d78de73748d340fa50e7
yoku2010/just-code
/algorithms/number_combination.py
2,008
3.953125
4
#!/usr/bin/python class NumberCombination(object): def __init__(self, number_list, number): self.number_list = number_list self.number = number self.result = [] def process(self): ''' Algorithm process ''' # Make It Unique self.number_list = list...
3bedc90616961f248924953f468206cc06e27f92
yoku2010/just-code
/utility/spiral-pattern/code.py
1,339
4.03125
4
#!/usr/bin/python """ @author: Yogesh Kumar @summary: To draw a spiral pattern of numbers like that. Enter Number of Element: 21 17 16 15 14 13 18 5 4 3 12 19 6 1 2 11 20 7 8 9 10 21 """ def spiral_pattern(number): n = 2 ...
497ebf8e5b03ac3e9a424ef76838da53a46da8bb
shobasri/TrainingAssignments
/Naveena/patterns.py
1,155
3.6875
4
#!/usr/bin/python import sys r=int(sys.argv[1]) n = 0 print ("Pattern B") for x in range (0,(r+1)): n = n + 1 for a in range (0, n-1): print ('*', end = '') print () print ('') print ("Pattern A") for b in range (0,(r+1)): n = n - 1 for d in range (0, n+1): print ('*', end = '')...
42178b00cf2ba281a87c64c5ab945908fc1202a8
shobasri/TrainingAssignments
/Sony/Assignments/divisable7.py
140
4.34375
4
#given no divisible by 7 or not a=input("Enter a number ") if (a%7==0): print a,"is divsible by 7" else: print a,"is not divisible by 7"
81c99b4ece820adc4c322bbf5efaa475d5bd3a83
mijodong/euler
/python/problem-20.py
138
3.765625
4
factorial = 1 for _ in range(1, 101): factorial *= _ value_sum = 0 for _ in str(factorial): value_sum += int(_) print(value_sum)
489d48a54197ec60c9e916605caf8235b09dddc7
mijodong/euler
/python/problem-4.py
464
3.84375
4
from math import floor def is_palindrome(value): value_str = str(value) length = len(value_str) for i in range(floor(length / 2)): if value_str[i] != value_str[-i - 1]: return False return True palindrome = 0 for i1 in range(100, 999): for i2 in range(100, 999): pr...
e49a5633e9f24f787b78987b8954b5c4b40f3b82
roxdsouza/PythonLessons
/RegExp.py
4,328
4.3125
4
import re # re module is used for regular expression # Documentation - https://docs.python.org/2/library/re.html # Examples - https://www.guru99.com/python-regular-expressions-complete-tutorial.html # "\d" matches any digit; "\D" matches any non digit. # "\s" matches any whitespace character; '\S" matches any non-alp...
aae16277602c86460bafa3df51c1eb258c7d85db
roxdsouza/PythonLessons
/Dictionaries.py
2,088
4.65625
5
# Dictionary is written as a series of key:value pairs seperated by commas, enclosed in curly braces{}. # An empty dictionary is an empty {}. # Dictionaries can be nested by writing one value inside another dictionary, or within a list or tuple. print "--------------------------------" # Defining dictionary dic1 = {'...
4fa1560b335f86dae73766c7f6b316e339d54671
roxdsouza/PythonLessons
/Classes04.py
964
4.125
4
# Program to understand class and instance variables # class Edureka: # # # Defining a class variable # domain = 'Big data analytics' # # def SetCourse(self, name): # name is an instance variable # # Defining an instance variable # self.name = name # # # obj1 = Edureka() # Creating an inst...
7b73ee12749b361ea8b2581da5ff19ad01c584f6
mertzd1/MachineLearning-Python
/Regression/Section 5 - Multiple Linear Regression/multiple_linear_regression_1.py
2,315
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 10 13:51:42 2019 @author: donal """ #When creating dummy variables ***Always** omit one dummy variable in a multiple regression model #This is called Avoiding the Dummy Variable Trap #importing the Libraries import numpy as np import matplotlib.pyplot as plt import pand...
e8c8201207c84dade087650a761921226e2f0cf1
mbytes21/Python-Autoclicker
/autoclick.py
352
3.671875
4
import time import pynput from time import sleep from pynput import mouse from pynput.mouse import Button, Controller mouse = Controller() delay1 = input("How long until the clicking starts? ") clicknum = int(input("How many times do you want it to click? ")) x=int(delay1) for i in range(x): sleep(1) mo...
a8630178035f69f14bb41418b6b70a3fc120945e
olk911/ps-pb-hw3
/plural_form.py
725
3.90625
4
def plural_form(number, form1, form2, form3): f ='' # правильная форма для числа number date = str(number) # преобразование в строку и следовательно в список [] if int(date[-1]) == 1 and int(date[-2:]) != 11: f = form1 if int(date[-1]) > 1 and int(date[-1]) < 5: f = for...
1df9b8f1c11e8837892fb037232d3be40a124f80
GenghisKhanDoritos/Calculator-python-ver.-
/Calculator_Memory_Type.py
2,094
4.0625
4
#Calculator Memory Type.py print('='*50) print('Calculator Memory type') print('='*50) Working_Memory = 0 Secondary_Memory = 0 def operation(FN,OP,SN,Default): if OP=='1': Working_Memory = Default+FN+SN print(Working_Memory) elif OP=='2': Working_Memory = Default+FN-SN ...
8e56d445bc8dfff8db0f2658a92f19dcbb2f7922
ArrobaAnderson/Ejer_Class
/Sem2/condicion2.py
425
3.875
4
class Condicion: def __init__(self,num1=6,num2=8): self.numero1= num1 self.numero2= num2 numero= self.numero1+self.numero2 self.numero3= numero def usoIf(self): print(self.numero3) print("instancia de la clase") cond1= Condicion(70,94) ...
6e4eac8476b5580ec806298f05ebfd0386bd57f4
ArrobaAnderson/Ejer_Class
/Sem5&6/Ordenaciones.py
4,850
3.75
4
class Ordernar: def __init__(self,lista): self.lista=lista def recorrer(self): for ele in self.lista: print(ele) def recorrerPosicion(self): for pos,ele in enumerate(self.lista): print(pos,ele) def recorrerRange(self): for pos i...
81bb1e1f9c2972273b89457532534d9ba321654c
ArrobaAnderson/Ejer_Class
/Sem2/Diccionario.py
915
3.625
4
class Sintaxis: instancia=0 def __init__(self,dato="LLamando al constructor1"): self.frase=dato Sintaxis.instancia = Sintaxis.instancia+1 def usoVariables(self): edad, _peso = 21, 70.5 nombres = "Leonardo Arroba" dirDomiciliaria= "El Triunfo" ...
29aa99e1ece33882ff8e24ba1feb008b4eb9bd8f
LewisT543/Notes
/Learning_OOP/Classes and Instances/Python OOP 2 - Class Variables.py
868
4.03125
4
# SELF REFERS TO THE INSTANCE, in this case EMPLOYEE is what self is # referring to class Employee: num_of_emps = 0 raise_amount = 1.04 def __init__(self, fname, lname, pay): self.fname = fname self.lname = lname self.pay = pay self.email = fname + '.' + lname + '@compan...
e759d2b446b087c10defe5664b855e15f468c650
LewisT543/Notes
/Learning_OOP/Different Faces of Python Methods/11Part3.py
2,284
3.671875
4
from datetime import datetime class TimeList(list): @staticmethod def add_timestamp(txt): now = datetime.now().strftime("%Y-%m-%d (%H:%M:%S)") return f'{now} >>> {txt} ' def __setitem__(self, index, value): value = TimeList.add_timestamp(value) list.__setitem__(self, i...
78d56b418170f3c6a011439fc528ee4fec66e4ce
LewisT543/Notes
/Learning_Tkinter/17Main-window+user-convos.py.py
4,950
4.09375
4
#### SHAPING THE MAIN WINDOW AND CONVERSING WITH THE USER #### # CHANGING ASPECTS OF THE WINDOW # Changing the TITLE import tkinter as tk def click(*args): global counter if counter > 0: counter -= 1 window.title(str(counter)) counter = 10 window = tk.Tk() window....
dbb7e09bda996ede7be312e7a9b3fa5c6b0c0af8
LewisT543/Notes
/Learning_Tkinter/6Building-a-GUI-from-scratch.py
2,191
4.03125
4
import tkinter as tk from tkinter import messagebox def Click(): replay = messagebox.askquestion('Quit?', 'Are, you sure?') if replay == 'yes': window.destroy() window = tk.Tk() # Label label = tk.Label(window, text = "Little label:") label.pack() # Frame frame = tk.Frame(window, height=30, width=1...
4e7b02140879900cbbb4e3889789c8b3dcd15291
LewisT543/Notes
/Learning_Data_processing/3SQLite-update-delete.py
1,440
4.46875
4
#### SQLITE UPDATING AND DELETING #### # UPDATING DATA # # Each of the tasks created has its own priority, but what if we decide that one of them should be done earlier than the others. # How can we increase its priority? We have to use the SQL statement called UPDATE. # The UPDATE sta...
5ba9ce856ff7469ae0283044f155c2d7213da8fb
LewisT543/Notes
/Learning_OOP/Shallow and Deep Copy/4Example-copy-speed-comparison.py
2,783
4.0625
4
#### SPEED COMPARISON #### # We can see the differences in execution time very clearly. # Single ref: no time at all, # Shallow copy: almost no time at all, # Deep copy: exponentially longer. import copy import time a_list = [(1,2,3) for x in range(1_000_000)] print('Single refere...
77a3de5d9a5a2fea41962f745456533430eca80f
LewisT543/Notes
/Learning_Data_processing/11Labs-exams-report.py
2,704
3.78125
4
# Your task will be to prepare a report summarizing the results of exams in maths, physics and biology. # The report should include the name of the exam, the number of candidates, the number of passed exams, the number of failed exams, # and the best and the worst scores. All the data necessary to create the rep...
2c191da1dddc35a17485a3519f63c0a2dd879dd0
LewisT543/Notes
/Learning_OOP/Decorators/Timer.py
1,026
3.59375
4
from functools import wraps class Logging_decorator(object): def __init__(self, origional_function): self.origional_function = origional_function def __call__(self, *args, **kwargs): import logging logging.basicConfig(filename=f'{self.origional_function.__name__}.log', level=l...
95ce1eb58837658a9f65247e7c3c84548644ebe0
ahovhannes/Disco_API_Test
/Source/TestFunctions/FunctionRandom/Function_Random.py
613
3.671875
4
# # Collection of functions generating random numbers # import random class bddRandom: def generate_random_number(self, beginNumber, endNumber, seedValue=None): """ Generate random number between given numbers Args: beginNumber : Start number ...
2f69fc3c07f2bdd21293db493df9e25ef1f7978a
adambjorgvins/pricelist
/snake.py
2,389
3.890625
4
import random class Game: dimension = None board = None current_x = None current_y = None monster = None snake = None brick = None score = None def __init__(self, dimension): self.current_x = random.randint(0,9) self.current_y = random.randint(0,9) self.current_monster_x = random.randint...
b99087927611afb1de15d89e863cc7ad162abf7e
velios/6_password_strength
/password_strength.py
2,341
3.59375
4
import re from string import (ascii_lowercase, ascii_uppercase, punctuation, digits) from getpass import getpass from os import path def check_upper_and_lower_case_in_string(string): return any(char in string for char in ascii_uppercase) and \ ...
9c64a4aab34c6af4b71fc4162f6ea30d7b74bc2f
iceman67/algorithm
/02-analysis/search/linsear_search.py
923
3.75
4
def linearSearch(arr, key): n = len(arr) for i in range(0, n): if arr[i] == key: return i return -1 list = [1,2,3,4,5] key = 2 pos = linearSearch(list, key) print ("position = ", pos ) if pos == -1: print("not found" ) else: print (" ", list[pos]) key = -1 pos = linearSearch(list, key) p...
1827787e352eccbf15888adb66acdafee51cfdec
davidsamuelwhite/visualnba
/JSONGameData.py
3,431
3.859375
4
# this file contains functions that manipulate the data from the JSON file which # holds all the data that is plotted by the program. it creates objects called # dataframes from the pandas packages, which are essentially 2d lists that are # easier to data manipulation with. import json import pandas as pd # d...
8a57681c6bd62de888d89661572c134906752f24
mihai064/my-projects
/python/hello.py
1,134
3.96875
4
import time print("hello") var1 = input("what's your name? ") print("nice to meet you",var1) user_reply = input("do you wanna play something? ") if user_reply == "yes": ur2 = input("greatfull. so do you like programmig? ") if ur2 == "yes": print ("let's learn python") user_reply2 = input ("do you wan...
443ba59840b6aa72447c04f6e9d2dccdf9429df7
mihai064/my-projects
/python/buton.py
529
3.8125
4
import tkinter window = tkinter.Tk() button = tkinter.Button(window, text="Do not press this button.",width=40) button.pack (padx=10, pady=10) clickCount = 0 def onClick (event): global clickCount clickCount = clickCount + 1 if clickCount == 1: button.configure (text="Seriously? Do. Not. Pr...
509be7160806b00c6f34042fbe3e5f3e6308b082
prahaladh/webscrape
/webscrape.py
555
3.53125
4
import pandas as pd import requests from bs4 import BeautifulSoup def get_data(url): res = requests.get(url) soup = BeautifulSoup(res.content,'lxml') table = soup.find_all('table')[0] list_of_rows = [] for row in table.findAll('tr'): list_of_cells = [] for cell in row.findAll(["th"...
c7eb2f952f6ceadba48a40220ed18ec0b103b386
pcw109550/id0-rsa.pub
/32_Caesar/solve.py
404
3.515625
4
#!/usr/bin/env python3 import string chset = string.ascii_uppercase N = len(chset) f = open("ct", "r") ct = f.read().strip() f.close() for i in range(N): pt = "" for c in ct: x = chset.find(c) pt += chset[(x + i) % N] if "CAESAR" in pt: print("KEY: {:s}".format(chset[i])) ...
ee7040b673ccc088d8e708f017a5dd17e203e6c6
pcw109550/id0-rsa.pub
/38_Easy_Passwords/solve.py
1,512
3.5
4
#!/usr/bin/env python from passlib.hash import md5_crypt from itertools import product from string import ascii_lowercase def hash(salt, msg): h = md5_crypt.using(salt=salt, salt_size=8) return h.hash(msg) def step1(salt, res, datas): # https://www.scrapmaker.com/data/wordlists/dictionaries/rockyou.txt ...
d530548acdd3fb83f6302d73ae83597fc38fc4f8
Woltan/Chess
/board.py
4,472
3.5625
4
import random from pieces import Pawn, Rook, Knight, King, Bishop, Queen class Board(object): Pieces = property(lambda self: self._pieces) def __init__(self, pieces, turn): self._pieces = pieces self._turn = turn self._lastMove = None @classmethod def CreateNewBoard(cls, fen=None): if fen: raise Not...
7b8414a39ff9a45806152126d9bd2bc12d1cd54a
satlawa/ucy_dsa_projects
/Project_1/problem_6.py
4,138
4.1875
4
#------------------------------------------------------# # problem 6 - Union and Intersection #------------------------------------------------------# class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class Linked...
100a33b667fa60386fabf26718b7bdf71d25d26c
satlawa/ucy_dsa_projects
/Project_0/Task2.py
1,759
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
89309e6aa3917fee2427a1e16113a3de202994d5
achmielecki/AI_Project
/agent/agent.py
2,136
4.25
4
""" File including Agent class which implementing methods of moving around, making decisions, storing the history of decisions. """ class Agent(object): """ Class representing agent in game world. Agent has to reach to destination point in the shortest distance. World is random generat...
b1e4492ff80874eeada53f05d6158fc3ce419297
lovepurple/leecode
/first_bad_version.py
1,574
4.1875
4
""" 278. 2018-8-16 18:15:47 You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose y...
1c84d570d09e47bf4e8e5404c637724605941471
lovepurple/leecode
/binarySearch.py
904
3.921875
4
""" Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1. Input: nums = [-1,0,3,5,9,12], target = 9 Output: 4 Explanation: 9 exists in nums and its index i...
309d38b353e45b90da17d15b021b83ab43c80b1e
lovepurple/leecode
/contains_duplicate.py
1,127
3.890625
4
""" 217. Contains Duplicate 2018-8-8 0:05:01 Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: t...
a1c12b3b59535fe7e82558ffe416e6cba5dbb1f6
ravi4all/Oct_AdvPythonMorningReg
/01-OOPS/02-ObjDemo.py
527
4
4
class Emp: """This is my first class demo""" id = 1 name = "Ram" print("Hello world") if __name__ == '__main__': obj_1 = Emp() # print(ram) print(obj_1.id, obj_1.name) obj_1.name = 'Shyam' print(obj_1.name) print(Emp.name) obj_2 = Emp() obj_2.name = 'Ra...
da39acfbccae16f554fc22a7e9d21300a1fac7f2
ravi4all/Oct_AdvPythonMorningReg
/02-Inheritance/03-MultipleInheritance.py
1,255
3.90625
4
class Emp: def __init__(self): self.name = "" self.age = 0 self.salary = 0 self.company = "HCL" def printEmp(self): print("Emp Details :",self.name, self.age, self.salary, self.company) class Bank: def __init__(self,balance,eligible): self....
03b65050e19e551c68bb94c17e6712357db67c09
GuillemMartinezArdanuy/Becas-Digitaliza--PUE--Programaci-n-de-Redes
/Python/06_for.py
1,033
3.90625
4
#Crear un archivo llamado 06_for.py #Crear una lista con nombres de persona e incluir, como mínimo, 5 nombres (como mínimo, uno ha de tener la vocal "a") listaNombres=["Antonio","Manuel","Jose","Manuela","Antonia","Pepita","Carol","Ivan","Guillem","Alberto","Luis"] #Crear una lista llamada "selected" selected=[] #...
be16fc36b1664629aed50ab10065ee94ad2858f1
stefan9x/pa
/vezba01/z3.py
370
3.8125
4
#Napiši program koji na ulazu prima dva stringa i na osnovu njih formira # i ispisuje novi string koji se sastoji od dva puta ponovljena prva tri # karaktera iz prvog stringa i poslednja tri karaktera drugog stringa if __name__ == "__main__": s = input('Unesite dva stringa:') s1, s2 = s.split(' ') s_out...
4425e49cff1337a3691b647d5d7752bd451fad87
stefan9x/pa
/vezba01/z2.py
441
3.59375
4
#Napisati funkciju koja računa zbir kvadrata prvih N prirodnih brojeva #parametar N se unosi kao ulazni argument programa; import sys def zbir2_n(n): zbir = 0 for i in range(n): zbir+=i**2 zbir+=n**2 return zbir if __name__ == "__main__": if len(sys.argv) < 2: print('Unesite...
5f54615d6649e495f45e630ba3c7d690e94c308a
AbelHristodor/ideas
/Games/Tris aka TicTacToe.py
3,848
3.71875
4
import time player1 = 0 player2 = 0 answer = input("Ciao, vuoi giocare a Tris? Si/No ") if answer == 'Si': player1 = input("Giocatore 1, vuoi essere X oppure 0? ") if player1 == 'X': player2 = '0' else: player2 = 'X' else: print("Vabbè giocheremo un'altra volta.") def dis...
ebed420431aece5085c524bc4a5ad5a4fdbf67ee
Willjox/WebSecurity
/HA1/micromint.py
780
3.6875
4
import random import sys import math def stddev(results, average): y= [] for x in results: y.append((x - average)**2) return math.sqrt( ( (sum(y))/z) ) def mint(u,k,c): i = 0; p = 0; korg = [0]*(2**u) rand = random.SystemRandom() while p < c: x = rand.randint(0, len(k...
6cffaeeb5b02ee6140fea0392f37d680fed205ae
dzenre/python-project-lvl1
/brain_games/cli.py
241
3.59375
4
"""Module to ask player's name.""" import prompt def welcome_user(): """Ask player's name.""" # noqa: DAR201 name = prompt.string('May I have your name? ') print('Hello, {}!'.format(name)) # noqa: WPS421 P101 return name
2a381d75c58b0a97e5599adf17466bda066f9e02
hyeongyun0916/Algorithm
/acmicpc/python/13163.py
105
3.671875
4
num = int(input()) for i in range(num): name = input().split(' ') name[0] = 'god' print(''.join(name))
8b6c96bcb94daa09063d873ab6649f49f316edca
andersoncruzz/service-ENEM
/banco.py
1,141
3.546875
4
import sqlite3 def newTeacher(Nome, Email, Matricula, Senha): try: conn = sqlite3.connect('openLab.db') cur = conn.cursor() cur.execute(""" INSERT INTO teachers (idTeacher, Nome, Email, Password) VALUES (?,?,?,?) """, (Matricula, Nome, Email, Senha)) #gravando no bd conn.commit() print('Dados...
9f7091f4f2d58967ef4f5e15f1ec47cd81995694
cleytonoliveira/pythonLearning
/Fundamentals/exercise6.py
215
3.96875
4
firstNumber = int(input('Write the first number: ')) sucessor = firstNumber + 1 predecessor = firstNumber - 1 print('The number {} has the predecessor {} and sucessor {}'.format(firstNumber, predecessor, sucessor))
de8bc57cba471bb94f6aed67eb0a35077cca72bb
cleytonoliveira/pythonLearning
/Fundamentals/exercise14.py
215
4
4
salary = int(input('How much is your salary? ')) calculateImprove = salary + (salary * 0.15) print('Your salary is R${}, but you received 15% of higher and now your salary is R${}'.format(salary, calculateImprove))
a91e85e800e795b48d9dac1586ad9b69bbd87221
bacasable34/formation-python-scripts-exemples
/carnet.py
4,882
3.5
4
#! /usr/bin/env python3 # programme carnet.py # import du module datetime utilisé dans la class Personne pour calculer l'âge avec la date de naissance import datetime class Contact: #attribut de la class Contact nb_contact =0 # __init__ dunder init est le constructeur de la class --> qd tu fais c1=Contact...
11fa3e02f3663a34cbd2804a52ac2525e2c84d35
bacasable34/formation-python-scripts-exemples
/test_sub.py
950
3.84375
4
#! /usr/bin/env python3 # # test_sub.py - Mickaël Seror # demande à l'utilisateur une chaine et une sous chaine # Compte le nombre de fois qu'apparaît la sous chaine dans la chaine # affiche les positions de la sous chaine dans la chaine # affiche la chaine avec le caractère * à la place de la sous chaine # # Usage : ....
29ef17e51ae29ba273a3b59e65419d73bacf6aa0
mathivananr1987/python-workouts
/dictionary-tuple-set.py
1,077
4.125
4
# Tuple is similar to list. But it is immutable. # Data in a tuple is written using parenthesis and commas. fruits = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango") print("count of orange", fruits.count("orange")) print('Index value of orange', fruits.index("orange")) # Python Dictionary is an unord...
4f1a69c960fb3c4575ad1dd493da268cb9b2298b
mathivananr1987/python-workouts
/try-except.py
1,745
4.03125
4
import os import sys # various exception combinations # keywords: try, except, finally try: print("Try Block") except Exception as general_error: # without except block try block will throw error print("Exception Block. {}".format(general_error)) try: vowels = ['a', 'e', 'i', 'o', 'u'] print(vow...