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
dfe0cf970f3e31541cf54adc571db68171f18827
sigurdurh18/Forritun1
/freakingBored.py
956
3.625
4
matrix=[ [1], [0], [0] ] matrix2=[ [0,-1,0], [1,5,0], [0,0,0] ] class Matrix: def __init__(self, val): #set if(type(val)==list): self.val = val else: self.val=-1 def __eq__(self, other): #comper return self.val == other.val def __repr__(self): #get return self.val def __mul__(self, other):#multipli...
1e34f96001b049c57de96ba8aef944d7aa5268da
ShrutiBhawsar/practice-work
/MapFilterLambda_part4.py
1,502
4.25
4
numbers = [1,2,3,4,5,6,7,8,9,10] def EvenFunction1(): evenList = [] for number in numbers: if number % 2 == 0: evenList.append(number) print(numbers) print("Even Number List is {}".format(evenList)) # EvenFunction1() def OddFunction1(): oddList = [] for number in numbers: ...
36109e8fd8eb9f1141a3881f500edc309f9d5d6b
ShrutiBhawsar/practice-work
/FunctionAlias.py
613
3.96875
4
def function1(): print("Inside Function 1") def function2(func): print("Inside Function 2 ") func() print(type(func)) # aliasFunc = function1 #it creates the alias of function1 # function2(aliasFunc) def add(num1, num2): print(num1+num2) def sub(num1, num2): print(num1-num2) def mul(n...
aa3e7dc8400af85565e9a5c0639a204f3770253c
mandeepak/udacitydatastructure
/P0_Sol/Task2.py
1,761
4.03125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv import datetime from datetime import timedelta 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...
dbd875ba9e92058e6b7e542ca1d74fe54dceced0
yang529593122/python_study
/study_01/1.py
904
4.03125
4
def print_hi(): # name = input('姓名:') # age = int(input('年龄:')) # print('你的姓名是%s,年龄是%d' %(name,age)) # 变量的基本类型 # int 整形 变量名 = 数字 (数字不带小数点) # float 浮点型 变量名 = 数字 (数字带小数点) # str 字符串 变量名 = "字符串" # list 列表 列表名 = [ 元素1,元素2,... ] # tuple 元组 远组名 = (元素1,元素2,...) # set 集合 集合名...
8c1eb76bfb70214b7a1bdb3f584a39e30a27457b
yang529593122/python_study
/study_02/files.py
755
3.640625
4
# 文件操作 # r 只读 # w 只写 在原文件写,覆盖之前的内容 # a 只写 不复发你原来的内容 末尾追加 # wb 写入 以二进制形式写入 , 保存图片时使用 # r+ 读写 不覆盖原文件 末尾追加 # w+ 读写 在原文件写 覆盖之前内容 # a+ 读写 不覆盖原文件内容 末尾追加 # 读文件 # f = open(r"test.txt", 'r', encoding='utf-8') # res = f.read() # f.close() # print(res) # 读文件 # with open(r'test.txt', 'r', encoding='utf-8') as f : # res = f....
ea14d5de2d43b1f19eb612dea929a612ebfed717
Ottermad/PythonNextSteps
/myMagic8BallHello.py
819
4.15625
4
# My Magic 8 Ball import random # put answers in a tuple answers = ( "Go for it" "No way, Jose!" "I'm not sure. Ask me again." "Fear of the unkown is what imprisons us." "It would be madness to do that." "Only you can save mankind!" "Makes no difference to me, do or don't - whatever" ...
50cc388e88cb13e12575c71fe0c450227ca8fc53
charumathib/Computing-For-Biologists-Methods
/CFB_Second_Excercise_Set.pyde
1,438
3.84375
4
def absolute(n): if(n >= 0): return n return -n def palindrome4(input): if(len(input) > 4 or len(input) < 4): return False string = input[::-1] if(string == input): return True return False def ORF(DNA): beginning = DNA[:3] ending = DNA[-3:] if(beginning ==...
7b8b8d5d79a9f3bffa5b35d366c007b16282e094
Yodjji/Encryption
/main.py
715
4
4
from encryption import * from decryption import * def get_path_to_file(): path_to_file = input("Введите путь до файла: ") return path_to_file def get_file_password(): password = input("Введите пароль: ") return password def choose_the_action(): choose = input("Выберите\nЗашифровать/расшифроват...
fa2961d1fceb4bbf0c8bc813601da55ad62c0660
ok6j/CSE7
/Christian R's - Programmer.py
1,029
3.765625
4
# Programmer class Person(object): def __init__(self, name, education): self.name = name self.education = education def work(self): print("%s goes to work" % self.name) test_person = Person('Generic name', 'bachelors degree') test_person.work() class Employee(Person): def __init...
6825298ae2693de5fba4ea1c1babc18ae24047f5
isabellarhee/15-112
/week 8/SetLectureNotes.py
3,042
3.921875
4
#Sets and Dictionary notes #s = set() #set just like a list #s.add(5) #sets not subscriptable, not sorted, cant get ith value #also no repeat elements #{set elements} #elements must be immutable #very efficient def isPermutation(L): #L is a permutation if it is the same as # [0, 1, 2, 3,....N] #NlogN steps...
68bd64709a494860984ae0123140522980b5a230
isabellarhee/15-112
/week3/CTthing.py
510
3.8125
4
import basic_graphics import math def draw(canvas, width, height): t = math.pi / 2 n = 5 dt = 3 * (2 * math.pi) / n r = 100 x = width / 2 y = height / 2 canvas.create_oval(x-r, y-r, x+r, y+r) x0, y0 = x, y - r for i in range(n+1): canvas.create_oval(x0-5, y0-5, x0+5, y0+5) ...
3947caad20165e928b614189d0121881467de7b3
isabellarhee/15-112
/week3/GraphicsNotes.py
9,918
4.3125
4
#Create an Empty Canvas import basic_graphics def draw(canvas, width, height): pass # replace with your drawing code! basic_graphics.run(width=400, height=400) #canvas coordinates - y axis grows down instead of up #(0,0) is at the top left corner and bottom right is #(width,height) #Draw a Line def draw(canvas, ...
fff616d34b0e87c973d3fa135097ed2938214f4f
isabellarhee/15-112
/VarsAndFunctions.py
5,322
4.5625
5
#variables and functions notes # we put a value in a variable using an = sign x = 5 print(x) # x evaluates to 5 print(x*2) # evaluates to 10 #can assign diff types to one variable y = 10 print(y - 2) y = True print(y) # A function is composed of two parts: the header and the body. # The header defines the name and pa...
8bf1e5a964b10f44e23f8c76625f37cfc0a65b98
dilynfullerton/tr-A_dependence_plots
/src/FitFunction.py
22,969
4.15625
4
"""FitFunction.py Data definitions and examples of functional forms to be used in fitting. Definitions: fit_function: Function that given an x value and a list of parameters and constants, returns a y value, which is the fit. A fit_function has the form: f(x, params, const_list,...
2293d434adae6dd966f39109a4151edd49507903
yhfyhf/Xidian-Secret
/mimi/get_grade.py
1,751
3.75
4
# -*- coding: utf-8 -*- def get_grade(uid): if uid == "admin" or uid == "yhf": return "管理员" if not uid.isdigit(): return "error" uid_len = len(uid) if uid_len == 8 or uid_len == 11: pass else: return "error" school_num = uid[0:2] if uid_len == 8 else uid[2:4]...
b5e7ddb9fe1d7012ce4281d4f5c659907455a73e
LanaTheodory/python_stack
/_python/python_fundamentals/functions_intemediate1.py
535
3.921875
4
import random def randInt(min=0 , max= 100 ): num = random.random() * (max-min) + min return round(num) print(randInt(20)) print(randInt(20,100)) print(randInt(max=20, min=10)) print(randInt(40)) #print(randInt())     # should print a random integer between 0 to 100 #print(randInt(max=50))     # should pr...
b8c6d8af572b679438fb1c5b25b8b13427fe2185
kieran-ringel/Project4
/main.py
1,796
3.796875
4
from Organization import Org from NeuralNet import NeuralNet def main(): """ Kieran Ringel For each data set three lines are run in main. The first one creates an instance of Org with the arguments being the file name, where the header is located to be removed ([-1] if there is no header, the location o...
567cd5aaf059a7cac9112661cb3e04d0318dd2f3
yunatoomi/game-ai
/tictactoe/tictactoe.py
5,231
3.53125
4
from typing import Optional, List class TicTacToe(dict): class Tile: def __init__(self, tictactoe: 'TicTacToe', row: int, column: int): self.tictactoe = tictactoe self.row, self.column = row, column self.delegate = None self.player = None def __str...
24b8e07b7eeb8133b4e277f8ddf060e886c2252e
vkaukeano/Software-Tools-for-Engineers
/solution5.py
653
3.515625
4
#!/usr/bin/env python import random import cProfile from memory_profiler import profile @profile def FindDuplicates(numbers): counter = 0 if len(numbers) < 2: return counter else: numbers.sort() dup = 0 for i in range(1,len(numbers)): if ((numbers[i-1] == numbers[i]) & (dup == 0)): counter = counter...
ab34a3e35d870df9b1cee0fb01f3d12e8bcd5d98
Clement-Torti/pyhack
/menuWindow.py
1,376
3.5
4
from window import Window import utils import curses ''' The menu window ''' class Menu(Window): def __init__(self, h, w, options, stdscr): Window.__init__(self, stdscr, False) self.options = options self.h = h self.w = w self.selectedOption = 0 self.stdscr ...
7c31caf352a1b25caede0a2f6b79d9590a41493a
JustinSeymour/dog-breed-classifier
/get_pet_labels.py
3,970
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # */AIPND-revision/intropyproject-classify-pet-images/get_pet_labels.py # # PROGRAMMER: Justin Seymour # DATE CREATED: 19 January 2020 # REVISED DATE: # PURPOSE: ...
c203bd7a7ec3e48842cddb74d99adfd5e66f0176
cw1753/SQL_Data_Generator
/SQLTable.py
2,730
3.703125
4
class SQLTable: class Attribute: def __init__(self, tName, aName, aType, aLimit=None,): self.attName = aName self.attType = aType self.attLimit = aLimit self.tbName = tName self.attData = [] def __str__(self): if self...
6c8b2e492d41fe17b24123a7fa764db2ed4c7dc2
zabrinaisis/CS201
/Chapter 3/FahrenheitCelsiusConverter.py
155
4.03125
4
temp = float(input('Enter the temperature in degrees Fahrenheit: ')) Cel = (5/9)*(temp-32) line = 'The temperature in degrees Celsius is' print(line, Cel)
e58fa7e5a7f84cc7f04d6544d03de08864b4a31c
zabrinaisis/CS201
/Chapter 3/CalculateSquares.py
148
3.96875
4
n = int(input("Please specify a positive integer n:")) print("These are the squares of all numbers from 0 to n-1:") for i in range(n): print(i*i)
a9af5412696bbf0799bcea8d52eaf835c6bddda8
gurbain/quadruped-walking-gaits
/WorldPhysics.py
1,089
3.6875
4
''' Author: Martin Stolle Description: The physics enviroment of the simulation. ''' import ode import vpyode class myWorld: '''' Contains the world(gravity etc.) and Space(Collision)''' def __init__(self): self.world = vpyode.World() self.world.setGravity( (0,-9.81,0) ) # Gr...
2f5d7d8a3af631556b2a637ac693f3aa9e938ce3
P-N-S/SVP-CPro
/ArrayRotations.py
1,536
4.09375
4
#Array Rotations | SGVP386100 | 21F19 #https://www.geeksforgeeks.org/array-data-structure/#rotation #https://www.geeksforgeeks.org/array-rotation/ # Program for Array Rotation # Method 2 (Rotate one by one) def leftRotate(arr, d, n): print("leftRotate() | 15:21 21F19") for i in range(d): leftRotatebyO...
3624175ae39f89eb00337d80731d30cff229a54e
P-N-S/SVP-CPro
/LinkedList.py
3,273
4.53125
5
# https://www.geeksforgeeks.org/linked-list-set-1-introduction/ # Linked List | Set 1 (Introduction) # 18F19 #Node class class Node: print("Node class") # Function to initialize the Node object def __init__(self, data): self.data = data self.next = None #Linked List class class LinkedList...
1af54a6aa152c5c85731b3e4c983529495f59b17
sphrilix/pymem_csgo_aimbot
/view_angles.py
581
3.671875
4
# Implementation of the view angles class ViewAngles: # Pitch of the view angles pitch: float # Yaw of the view angles yaw: float # Roll of the view angles roll: float # Constructs a new object of view angles with given arguments def __init__(self, pitch: float, yaw: float, roll: flo...
f8a8b6cdcf813c6036fc53f5bbfefe6972e771be
hautera/PythonMath
/KochCurve.py
412
3.5
4
#Koch curve import turtle def Recursive_Koch(length, depth): if depth == 0: turtle.forward(length) else: Recursive_Koch(length, depth-1) turtle.right(60) Recursive_Koch(length, depth-1) turtle.left(120) Recursive_Koch(length, depth-1) turtle.right(60) Recursive_Koch(length, depth-1) # ---------- #tur...
153c46adaf3bf3474d8a02e601d6412ef8fbdde9
hautera/PythonMath
/dragoncurve.py
654
3.921875
4
import turtle SPIRAL = True def curve(t, length, depth, sign): #print(t) if depth == 0: #print(depth) for turtle in t: #print(type(turtle)) turtle.forward(length) else: #print(depth) curve(t,length, depth-1, 1) for turtle in t: turtle.right(90*sign) curve(t,length, depth-1, -1) if __name_...
1335f037c040fc7917bef60382a6dc56584d29f2
LJNullPointException/PythonTestDemo
/my_abs.py
206
3.5625
4
#_*_coding:utf-8_*_ def mabs(num): if not isinstance (num,(int, float)): print("typeErro we need Interge or Float ,but you give me s%" ,type(num)) return; if num>0: return num; else: return -num;
654a473ec09b39ab6ee7eeae35c40e70742925cd
ChristopherGray15/Disreate-Maths-and-Deliclarative-Programming-Command-Line-untilitly
/CP4266/week02/N-1/BMI-Calculation10.1017.py
371
3.921875
4
#Bmicalculator #ChrisGray #S17117107 #values:,<18:underweight, 18-25: Normal, 25 -30: overweight, 30+: obese name = input ("enter a name"); weight = float(input("enter your weight in kilograms(kg) : ")); height = float(input("enter your height in centimetres(cm): ")); bmi = weight /(height *height) print(bmi) print("...
9d0614294b5b1f065d08c86da18c9a95b6639de8
seun-beta/WeJapa-Data-Science
/Wave 3/for_loop_range.py
178
4.28125
4
# Write a for loop using range() to print out multiples of 5 up to 30 inclusive for number in range ((30//5) +1) : if number == 0 : continue print (5*number)
ff1c5776111629327b34355c673045274ee8a837
hannaht37/hannaht37.github.io
/story.py
6,852
4.03125
4
""" This is a story about a baker, (the user), who's store is overrun by bread Our program takes the user's input and conveys the answers into a story You need Colorama and Termcolor to run this program; To do this, add the commands 'sudo pip3 install termcolor' and 'sudo pip3 install colorama' in your bash (on Cloud ...
d67d01c50c2e6dc37660bf1c61f04ab404e4fadf
Damon-Ma/HelloPython
/part2/my_tuple.py
201
3.765625
4
''' 元祖在小括号里面包裹 和list区别:无法修改,不能append 、 + 、 删除 操作 ''' t = ('java', 'python', 'php') print(type(t)) # 访问 print(t[0]) # 切片 print(t[1:2])
e1072dd4f5165a234e548cf6f14b443f603899af
Todoriv/DB1
/Relation.py
2,801
3.78125
4
class Relation(object): def __init__(self): self.cntrDB = [] self.cntrid = 0 self.ctDB = [] self.ctid = 0 self.lastid = 0 self.sortedDB = [] def add(self, cntrid, ctid, Countries, Cities): if cntrid > Countries.lastid or cntrid < 0: ...
89370c8e8c045ec3c1ee59cd146ea49e50f9c97d
soundslash/soundslash
/src/Pipeline/src/test4.py
448
3.921875
4
class Price(object): def __get__(self, obj, objtype=None): return obj._price * obj._amount def __set__(self, obj, value): obj._price = value class Book(object): price = Price() def __init__(self, amount): self._price = 42 self._amount = amount book = Boo...
44c8457188fcb4fc443608aab66148480c0c12e3
ashiquebiniqbal/Comment-Classification
/nlpprocess.py
2,446
3.65625
4
import nltk import pandas as pd # nltk.download() pd.set_option('display.max_colwidth', 100) df = pd.read_csv('data/reddit_data.csv') print(df.head()) print(df.shape) # Getting Description print(df['num_comments'].describe()) print('Num of null in label: {}'.format(df['num_comments'].isnull().sum())) ##REMOVE PU...
62ada83a7137bc69f29b2bf9eb750afb5b5a1f61
yilin0212/PYTHON
/17.py
362
3.609375
4
sum=0 s=input('輸入五張牌:') list_s=s.split(" ") for i in range(5): if (list_s[i]=="j" or list_s[i]=="J"): sum+=11 elif(list_s[i]=="q" or list_s[i]=="Q"): sum+=12 elif(list_s[i]=="k" or list_s[i]=="K"): sum+=13 elif(list_s[i]=="a" or list_s[i]=="A"): sum+=1 else: s...
42c07fbbd091b6b3d0cd9839fbc90a95a0f739d8
yilin0212/PYTHON
/66.py
140
3.671875
4
a=input("請輸入string_a:") b=input("請輸入string_b:") a=set(a) b=set(b) c=sorted(a&b) if (c==[]): print("N") else: print(c)
b4a1bf24681802e036839fa7111c0fb39ad02604
gonglei12/cellular-auto
/ballSimulator/ball.py
1,320
3.65625
4
# -*- coding: utf-8 -*- import pygame import math class Ball(pygame.sprite.Sprite): def __init__(self, bg_size): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load('image\\ball.png').convert_alpha() self.rect = self.image.get_rect() self.width, self.height =...
89437f4b8cc05fe3a7288191e84b06a71c825e8a
Vivomo/python
/py/re/re_test.py
2,673
4.03125
4
import re import os """ re 模块的测试 """ def test_compile(): str1 = 'food' m1 = re.match('foo', str1) print(m1) print(m1.group()) print(m1.groups()) m = re.compile('foo') m2 = m.match(str1) print(m2) print(m2.group()) print(m2.groups()) def test_search(): m = re.match('foo',...
31805c7d48710dce5ef155cbf7d3cc013701a59c
richardARPANET/soft-dtw
/sdtw/path.py
1,801
3.984375
4
# Author: Mathieu Blondel # License: Simplified BSD import numpy as np def delannoy_num(m, n): """ Number of paths from the southwest corner (0, 0) of a rectangular grid to the northeast corner (m, n), using only single steps north, northeast, or east. Named after French army officer and amateur...
9f4a1f9c1e212efe17186287746b7b4004ac037a
Col-R/python_fundamentals
/fundamentals/Cole_Robinson_hello_world.py
762
4.21875
4
# 1. TASK: print "Hello World" print('Hello World!') # 2. print "Hello Noelle!" with the name in a variable name = "Col-R" print('Hello', name) # with a comma print('Hello ' + name) # with a + # # 3. print "Hello 42!" with the number in a variable number = 24 print('Hello', number) # with a comma print('Hello '+ str(nu...
7dfe89be39bf6c05135cf86796053a22855d0253
Col-R/python_fundamentals
/fundamentals/data_types.py
2,389
3.90625
4
x = 10 if x > 50: print("bigger than 50") else: print("smaller than 50") class EmptyClass: pass # Python has provided us with the pass statement for situations where we know we need the block statement, but we aren't sure what to put in it yet. for val in my_string: pass # The pass statement is a null operat...
768d5acc06bf952cb396c18ceea1c6f558634f6f
Col-R/python_fundamentals
/fundamentals/strings.py
1,874
4.4375
4
#string literals print('this is a sample string') #concatenation - The print() function inserts a space between elements separated by a comma. name = "Zen" print("My name is", name) #The second is by concatenating the contents into a new string, with the help of +. name = "Zen" print("My name is " + name) number = 5 ...
a0cfd7db9173a6a1cc4d20c63bb96e4b1fd85084
fdlancelee/workspace
/test/File.py
2,995
3.65625
4
#os模块主要用于与操作系统交互 #shutil模块则包含一些针对文件的操作 import os import os.path import shutil rootdir = "D:/Python/filetext" #os.listdir() 返回工作目录--ls os.listdir(rootdir); #print (os.listdir(rootdir)) ##os.getcwd():以字符串形式获取当前工作目录路径 → pwd ##获取工作空间目录 Wordspacedir = os.getcwd(); print ("Wordspacedir is :",Wordspacedir) #os.chdir("/abso...
82d23e27e9429182749e0530856009a473974b7f
summerThunder/simpletensorflow
/simpleflow/operations.py
7,540
3.6875
4
import numpy as np from queue import Queue class Operation(object): ''' Base class for all operations in simpleflow. An operation is a node in computational graph receiving zero or more nodes as input and produce zero or more nodes as output. Vertices could be an operation, variable or placeholder....
7e03a18526ac710886fedaf25f0635aad728331e
hrithiksagar/Python-Practice-for-TCS-Ninja-Digital
/painting cost.py
373
3.84375
4
# i = 18/sq feet # e = 12/sq feet i = float(input("Enter number of interior walls: ")) e = float(input("Enter number of Exterior Walls: ")) for a in range(0,i): si = (input("Enter Surface Area of Interior Walls:")) for b in range(0,e): se = (input("Enter Surface Area of Exterior Walls:")) total = sum([a*...
56e6a839e4b92d1141f8165c5f6c5554a5f90ca9
hrithiksagar/Python-Practice-for-TCS-Ninja-Digital
/Questions and Solution/5th Aug/Sum of Consecutive numbers.py
866
3.75
4
# given a set of array elements #task : find max sum of m consecutive elements # suppose: # arr[] = {1,3,2,5,6} # m =3 # so max sum of 3 consecutive elements is 2+5+6; # for i in range(len(=res)): # sum = 0 # sum += res[i] #User input array without knowing size: # li = [int(i) for i in input().split()] # using...
c40caf9b854e071ab4d5befea7759f76e5dfa2dd
davifantasia/ud120-projects
/datasets_questions/explore_enron_data.py
3,891
3.703125
4
#!/usr/bin/python """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features associated with that pers...
334c092e27e405708c9c7e3cd470569c5427c658
Expan75/algorithms
/ch2/insertionSort.py
377
3.65625
4
import numpy as np trial = [9,6,8,9,3,4,1,11,3,4,9,0] def insertionSort(A, *args, **kwargs): res = A for j in range(1, len(A)): key = A[j] # insert A[j] into the sorted seq A[1..j-1] i = j-1 while (i >= 0) and (A[i] > key): A[i+1] = A[i] i -= 1 A...
436402797aa6d3fc5eb9a8256127991f1ee0d537
khadak-bogati/GTx-CS1301xII-Computing-in-Python-II-Control-Structures
/manualCardTrust.py
2,887
3.625
4
#Sets genereal information about the balance, tax, cardholder, adn # Trueted vendors. Generally, the information in these would be # sent into our programe, not here here , we create it manually # to test out our code balance = 20.0 salesTax = 1.08 cardholderName = 'David Joyner' trustedVender = ["Maria's", "bob s","Vr...
3ec6c3683674d506216b3242c18c81fd66c881e8
Seong-minL/Devwood
/Calc.py
2,717
3.78125
4
variable = {} # 변수와 그 값 calculator = ('+', '-', '*', '/') # 연산자 while True: # 반복해서 입력을 받음 enter = input() # 입력문구에 따라 다른 기능 수행 if enter.lower() == 'quit': # 'quit'을 입력 시 exit() # 프로그램 종료 # '='가 2개 이상 있을 시 elif enter.count('=') > 1: # Error 발생 및 재입력 print('Error: inval...
8c726671dfdc7c25c2985f6146735d9be1cecaaf
AndreasBamesberger/KassaBuch
/libs/backend.py
31,180
3.890625
4
"""" Classes to store information of one item and a bill. Functions to read and update the json files, to write to output csv files. """ import configparser # To read config file import csv # To write the output into csv files import json # To read from and write to update json files import os # To walk through pr...
66d04eb4ab92c922cd8f9ae2d60699b1eb6947c3
Bikryptorchosis/PajtonProj
/TestSets.py
2,338
4.15625
4
# farm_animals = {"sheep", "cow", "hen"} # print(farm_animals) # # for animal in farm_animals: # print(animal) # # print('-' * 40) # # wild_animals = set(['lion', 'panther', 'tiger', 'elephant', 'hare']) # print(wild_animals) # # for animal in wild_animals: # print(animal) # # farm_animals.add('horse') # wild_a...
067cc9ab57c6c63437c25028b7ab6d6026f0371c
William-Gliz/Jogo-da-Forca-no-Pycharm
/Jogo da Forca/Jogo.py
2,766
3.703125
4
import random import time from Dados import * # Parâmetros necessários para começar o jogo: def main(dificuldade): global count global display global palavra global ja_ditas global tam global limite palavra = random.choice(palavras()) tam = len(palavra) count = 0 ...
7ddac6a6f3770cacd02645e29e1058d885e871f2
dburr698/week1-assignments
/todo_list.py
1,924
4.46875
4
# Create a todo list app. tasks = [] # Add Task: # Ask the user for the 'title' and 'priority' of the task. Priority can be high, medium and low. def add_task(tasks): name = input("\nEnter the name of your task: ") priority = input("\nEnter priority of task: ") task = {"Task": name, "Priority": priority}...
2b64f4b278ca2eb538b4b893d863a4f6fcadd162
liumg123/leetcode
/852_山脉数组的峰顶元素.py
520
3.5
4
""" 我们把符合下列属性的数组 A 称作山脉: A.length >= 3 存在 0 < i < A.length - 1 使得A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1] 给定一个确定为山脉的数组,返回任何满足 A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1] 的 i 的值。 示例 1: 输入:[0,1,0] 输出:1 示例 2: 输入:[0,2,1,0] 输出:1 """ class Solution: def peakIndexInMount...
1a7c6d4d5e9b8ae3f634324138e0cadc86a642a7
kvande-standingwave/projects-
/Reaper-Python-Scripts/KVS_Item_Select_Based_On_Exact_Length.py
2,356
3.890625
4
from Functions import * """ Notes: Need to figure out how to make Dialog Box bigger Need to understand what size_of_user_input means Why does sys.getsizeof always return 24? What does named argument mean? Why can't i put *default_value? Can I make this box show up with no value in Box? """ # Constants for pop-u...
7d6aef42709ca67f79beed472b3b1049efd73513
chriklev/INF3331
/assignment6/_build/html/_sources/temperature_CO2_plotter.py.txt
2,237
4.1875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt def plot_temperature(months, time_bounds=None, y_bounds=None): """Plots the temperatures of given months vs years Args: months (string): The month for witch temperature values to plot. Can also be list of strings with ...
3b343e3551776f7ea952f039008577bdfc36ae9c
ewertonews/learning_python
/inputs.py
222
4.15625
4
name = input("What is your name?\n") age = input("How old are you?\n") live_in = input("Where do you live?\n") string = "Hello {}! Good to know you are {} years old and live in {}" print(string.format(name, age, live_in))
db69978e4d9e030b5c7c03c1d4ed60baf83a945f
LucaGonella/python-lab1
/Lab1_es_2.py
190
4.125
4
print("give me a string: ") string=input() L=len(string) if L>3: print(string[0]+string[1]+string[L-2]+string[L-1]) else: print("you have to enter a string longer than 3 characters")
cf0fcadaa4428df29c52897e553fb46cff9c6efa
stephenh67/blackjack
/cards.py
1,634
4.0625
4
import random class Card: """Initialize cards""" def __init__(self, suit, rank): self.suit = suit self.rank = rank def __str__(self): return f'{self.rank}{self.suit}' class Deck: """Create deck""" def __init__(self): # Adds cards into deck with suits and number o...
0aa9afdbaf628b40a5ed61a5bff37c3716c47e20
kevinsu628/study-note
/leetcode-notes/medium/Tree/116_populating_next_right_pointer.py
665
3.890625
4
''' You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right n...
4d22e0f5fec68ffbf97fcbf6892f7b942ae3fe16
kevinsu628/study-note
/leetcode-notes/medium/string/5_longest_palindromic_substring.py
1,839
3.90625
4
''' Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" ''' ''' Approach 1: find the longest common substring between the string and its r...
9c3254d781dda926a1050b733044a62dd1325ec7
kevinsu628/study-note
/leetcode-notes/easy/array/27_remove_element.py
2,103
4.1875
4
''' Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond th...
501ca00cf8ad5ae48f2704fc8da8f1481d1e53c2
Libardo1/deep-learning
/scratch/stacked-autoencoder-tflean.py
9,990
3.515625
4
# -*- coding: utf-8 -*- """ Auto Encoder Example. Using an auto encoder on MNIST handwritten digits. References: Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. "Gradient-based learning applied to document recognition." Proceedings of the IEEE, 86(11):2278-2324, November 1998. Links: [MNIST Dataset] ht...
88fb26583ab450fac87f951ad3efdd5016d84069
haebuki/python_prac
/basic/list_and_string.py
444
3.859375
4
my_list = [1,2,3,4,5,6] print(my_list[0]) str = "Hello world" print(str[1]) print(3 in my_list) print('H' in str) print(my_list.index(5)) characters = list("abcdef") print(characters) words = "Hello world는 프로그래밍을 배우기에 아주 좋은 사이트 입니다." world_list = words.split() print(world_list) time = "10:35:59" time_list = ti...
939f3b8956124c281d1fae5a7d0033a73609feaa
haebuki/python_prac
/basic/slice.py
241
4.0625
4
list = [1,2,3,4,5] text = "hello world" print(text[1:5]) list = ['영','일','이','삼','사','오'] print(list[1:3]) """ list1 = list print(list1) list.sort() print(list1) """ list2 = list[:] print(list2) list.sort() print(list2)
5732de162fcd3fdc44ab5261a2c18d2e46dc2642
adhithin/virtualLibrary
/booksearch/quiz.py
3,649
4.25
4
import numpy as np def sigmoid(x): ##defining the sigmoid function return 1.0/(1+ np.exp(-x)) def sigmoid_derivative(x): return x * (1.0 - x) ##defining the derivative of the sigmoid function, which tells us the gradient class NeuralNetwork: ##initializing the neural network class def __init__(self, x, y...
13ca18375b426575e997833460d791f3a2093f27
pingany/leetcode
/reverseWords.py
598
4.0625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- import os,re,sys,commands,glob reload(sys) sys.setdefaultencoding("utf-8") def reverseWords(s): l = [x for x in s.strip().split(' ') if x] l.reverse() return " ".join(l) class Solution: # @param s, a string # @return a string def reverseWords(self,...
0b9308b18a5df038166285068c6e133c03cda9a4
pingany/leetcode
/excelTitle.py
734
3.515625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- import os,re,sys,commands,glob,json,collections,random from random import randint from LeetCodeUtils import * def f(num): r = [] while num > 0: if num % 26 == 0: r.append('Z') num -= 26 else: r.append(chr(num%2...
153ef0f130b9467f584cc6063e2438b174c5b663
pingany/leetcode
/recoverBST.py
2,442
3.796875
4
#!/usr/bin/env python #-*- coding: utf-8 -*- import os,re,sys,commands,glob,json,collections,random from random import randint from LeetCodeUtils import * # Definition for a binary tree node class TreeNode: def __init__(self, x, left=None, right=None): self.val = x self.left = left sel...
8e42a6366b13b06b4144c7435a03d8a41cec33eb
pingany/leetcode
/wordLadder2.py
3,966
3.515625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- import os,re,sys,commands,glob,json,collections,random from random import randint from LeetCodeUtils import * def reverseTraverse(g, start, depth, nodeDepth, path, results): path.append(start) if depth == 1: results.append(list(reversed(path))) p...
c02618281eb090454418f4d275f8e2b3b4fd8e6b
novemberde/lang-practice
/python3/exception.py
598
3.75
4
try: # TODO: write code... print() except Exception as e: print() # raise e try: print() except Exception as e: # raise e print() else: # TODO: write code... print() try: print() except Exception as e: # raise e print() else: print() finally: print() try: ...
c942168e48d1a04c0c18b08b201106899005c9e4
axxie/PythonCourse
/ext/code_example/logo.py
3,655
3.84375
4
import os import pygame import pygame.draw from math import cos, sin, pi class Line(object): def __init__(self, x1, y1, x2, y2, is_down, width, color): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.is_down = is_down self.width = width self.color =...
8a73a6dffdddbe5b35b35d48516bdb6efd8caea1
bsameera/Udacity-data-structures-and-algorithms
/project2/active_directory_4.py
4,570
3.921875
4
# Active Directory # In Windows Active Directory, a group can consist of user(s) and group(s) themselves. We can construct this hierarchy as such. Where User is represented by str representing their ids. class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] ...
24b8b39df896b20a79fd35014cbddf3062b3f642
Sundarasettysravanilakshmi/sravani
/pgm36.py
141
3.640625
4
import string s = list(''.join(map(str,range(10))) + string.ascii_lowercase + ' ') print len([i for i in raw_input().lower() if i not in s])
0c311d6aff4bd3366c48dae53f4add4926c122fa
kozak758/funtik
/give it to me.py
228
3.796875
4
print('Give it to me!:') number = int(input()) if number>=10: print ("Thanks, man!") elif 10 < number < 100: print("OK : (") else: print ("Whaat???!!") if number > 1000: print ("!!!Wooowww!!!")
bdea2d5d72d20c29bb8e0ca7834e997dff41b31b
abhi-31-g/code-mastermind
/scode.py
3,878
4.21875
4
import random import time print("Hi there! \n Welcome to THE MASTERMIND \n \t -Command Line Exclusive!") instr=input("Do you want to read the instructions first? (y/n): ") if instr=="y": print("The rules of mastermind are simple to learn,... but is playing the game? \n Ok,so let's discuss the rules.. \n 1. Th...
9215cf62de71cbfe89ce05f850cad174061f4f3d
gogolzf/test
/mianshi.py
2,795
3.890625
4
# 一行代码实现1--100之和 # print(sum(range(0, 101))) # 如何在一个函数内部修改全局变量 a = 10 def test(): global a a = 5 test() # print(a) # 字典如何删除键和合并两个字典 dict1 = {'name': 'lin', 'ID': 1} del dict1['name'] dict2 = {'test': 'fan'} dict1.update(dict2) # python实现列表去重的方法 list1 = [3, 2, 1] # a = set(list1) # list1 = list(a) # print(lis...
6cfdb2239c7198abcee4bf5d949707cfac1747b9
Algorithm2021/minjyo
/트리/1991.py
1,155
3.640625
4
import sys class Node: def __init__(self): self.left = None self.right = None def preOrder(node): if node == -1: return print(chr(node + ord('A')), end='') preOrder(tree[node].left) preOrder(tree[node].right) def inOrder(node): if node == -1: return inOr...
a9389f276a65c9c98ae33f398292aa1ea8652597
Spas52/Python_Basics
/Conditional Statements Advanced - Exercise/05. Journey.py
792
3.84375
4
budget = float(input()) season = input() destination = "" place = "" price = 0 if budget <= 100: destination = "Bulgaria" if season == "summer": place = "Camp" price = budget - (budget * 0.7) elif season == "winter": place = "Hotel" price = budget - (budget * 0.3)...
62cf36c7d0c094c807f166808d0eb296299d96fe
Spas52/Python_Basics
/While Loop - Exercise/01. Old Books.py
452
4.0625
4
book_name = input() current_book = input() book_count = 0 is_book_found = False while current_book != "No More Books": if current_book == book_name: is_book_found = True break else: book_count += 1 current_book = input() if is_book_found: print(f"You checked {bo...
acf2df2fa400dced494f5e5923e2713ba1dac050
Spas52/Python_Basics
/Programming Basics Online Exam - 28 and 29 March 2020/01. Supplies for School.py
489
3.703125
4
pens_count = int(input()) markers_count = int(input()) chemical_for_cleaning_desk_by_liter = float(input()) discount_in_percent = int(input()) discount_in_percent1 = discount_in_percent * 0.01 pens_price = pens_count * 5.80 markers_price = markers_count * 7.20 chemical_price = chemical_for_cleaning_desk_by_liter...
73c6b90af959e84192c26d643281932affdb5237
weih201/code-repos
/python repo/Mapreduce/strdiff.py
355
3.828125
4
import sys str1=raw_input("Input the first string") str2=raw_input("Input the second string") length = len(str1) for i in range(length): if not str1[i]==str2[i]: print "Index at: %d" % i print "The remain str in the first str are %s \n" % str1[i:] print "The remain str in the second str a...
e9c868607afc9ad01c4e5874adbbb212d75a4192
Profix11pppo/Python_DONSTU
/Python Пройденное/casino.py
577
3.5625
4
import random h=int(input("""Ты Ядровская? 1-Поэтапно(да) 2-Инкскейп(нет) """)) if h==1: print('Изучайте условие тачпада ') elif h==2: k=1000 while True: print("Проходите в вип зал ") print("У вас ",k,' рублей') stavka=int(input('Введите ставку ')) kub=random.randint(1,6) chislo=int(input(...
d3dba1574f68c2a98127344c2ad0d5f2596bc5dc
rachelzhang1/python-practice
/hash.py
860
3.890625
4
# hash table for integer - Remainder def hash_int(a_int, table_size): return a_int % table_size # hash table for strings with weighting. Solve the collisions for anangrams def hash(a_string, table_size): sum = 0 for pos in range(len(a_string)): sum = sum + ord(a_string[pos]) * (pos + 1) return sum % table_s...
1fdb3a249670cc9d45e173e5e183cc1e630fc75a
rachelzhang1/python-practice
/strings.py
365
4.09375
4
brand = 'Apple' exchangeRate = 1.235235245 message = 'The price of this %s laptop is %d USD and the exchange rate is %4.2f USD to 1 EUR' %( brand, 1299, exchangeRate) print (message) myList = [1, 2, 3, 4, 5] myList.append("How are you?") print(myList) print(myList[-1]) yourName = input("Please enter your name:") prin...
028bf1ce77662a0ec5375676f27939e7457754f6
njeri-ngigi/hello_api
/tests/test_validate.py
3,271
3.8125
4
'''tests/validate.py''' import unittest from application.views.validate import Validate class ValidateTestCase(unittest.TestCase): '''class representing Validate test case''' def setUp(self): self.validate = Validate() def test_validate_email(self): '''test to validate email''' #su...
d242ae6651fd24ce42b6aae6f2b9cabf0080d398
Programacion-Algoritmos-18-2/ejercicios-clases2bim-002-antsecv14
/manejo_archivos/paquete_modelo/mimodelo.py
3,532
4.25
4
""" creación de clases """ class Persona(object): """ """ def __init__(self, n, ape, ed, cod, n1, n2): """ """ self.nombre = n self.edad = int(ed) self.codigo = int(cod) self.apellido = ape self.nota1 = int(n1) self.nota2 = int(n2) # ...
26df43e4746898f7cb79efd320b847d633d02b67
parkouryb/Python-Hus
/week4/range.py
1,448
3.609375
4
def get_result(begin, end): s = [x for x in range(begin, end + 1) if x % 11 == 0 and x % 3 != 0] return '; '.join(str(x) for x in s) def reverse_number(x): return int("".join(reversed(str(x)))) def get_dictionary(n): result = {} for i in range(0, n): result[i] = reverse_number(i * i) ...
ee32658c4c2db2968e0c67ba4e6cc93653aca267
parkouryb/Python-Hus
/week5/system.py
1,457
3.671875
4
import os print(os.getcwd()) # try: # filename = "test.txt" # f = open(filename, 'rt') # text = f.read() # print(text) # f.close() # except IOError: # print("problem reading: " + filename) # command = input("Enter command: ") # filename = input("Enter filename: ") command = "cd" filename = "...
0ceab3aae1f8569a1f3fb20d6923dce9d4a99f7c
peta909/PlayArea
/src/main/python/candy_crush.py
1,358
3.5625
4
# in the given input array, eliminate all the elements that occur 3 or more times consecutively def findRepitition(input): """ If repetition found, returns the starting and ending index of the repeated values :return: """ prev = None count = 0 start = -1 end = -1 for i, x in enumer...
c205a7df4539a019036ad4fb3c24694ccdc5c5e2
Anortec/gettingstarted
/code_examples/collectingnumbersdata.py
213
3.53125
4
#Collecting Numbers for math x = int(raw_input()) print 1 + x #Asking for math favnum = int(raw_input("What is your favorite number")) addone = favnum + 1 print "Your favorite number is actually ", addone
5614114ce2df570bc62f294e5b283d6f9a928663
Anortec/gettingstarted
/paycheck.py
716
3.546875
4
import time reqamount = float(raw_input("Please enter the amount you would like to be paid? ")) # reqamount = 100 sstotal = reqamount * 0.0145 sstotal *= 100 sstotal += 0.5 sstotal = int(sstotal) sstotal /= float(100) mctotal = reqamount * 0.062 mctotal *= 100 mctotal += 0.5 mctotal = int(mctotal) mctotal /= floa...
880f3286c2b5052bd5972a9803db32fd1581c68d
devilsaint99/Daily-coding-problem
/product_of_array_exceptSelf.py
680
4.3125
4
"""Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], ...
d997ee82822d758eddcedd6d47059bae5b7c7cac
akassharjun/basic-rsa-algorithm
/app.py
1,320
4.15625
4
# To create keys for RSA, one does the following steps: # 1. Picks (randomly) two large prime numbers and calls them p and q. # 2. Calculates their product and calls it n. # 3. Calculates the totient of n ; it is simply ( p −1)(q −1). # 4. Picks a random integer that is coprime to ) φ(n and calls this e. A simple way i...