blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
58ea3a6b9e7abbc2d7d53b2a249fbb00c57168b5
ismaeldeprada/Python
/practica3/practica 3-5.py
129
3.828125
4
n=int(input("introduce un numero de 3 digitos o menos")) if(n>999): print("ERROR") else: print("el numero es correcto")
cd3f0f361203f7f30713af2237e493a847466781
ismaeldeprada/Python
/practica5/practica 5-4.py
108
3.984375
4
n = int(input("Escribe un numero ")) f = 1 for i in range (1,n+1): f = f*i print("El factorial es",f)
f91c791a600a4bd5774cf83991ca37934b6b5765
undarmaa/K
/Old/Gensim/mysql_try.py
3,296
3.703125
4
# MySQL 연동하는 라이브러리 사용선언 import pymysql.cursors from konlpy.tag import Mecab mecab = Mecab() # MySQL Connection 연결 connection = pymysql.connect(host='192.168.1.1', user='grit', password='grit2017', db='grit', ...
c72626070b82df52a051780bba0889583762c54f
KristoD/CallCenter-Python-OOP
/call_center.py
1,197
3.71875
4
class Call(object): def __init__(self, id, name, number, time, reason): self.id = id self.name = name self.number = number self.time = time self.reason = reason def display(self): print "ID: " + str(self.id) print "Name: " + self.name print "P...
7a2b5a841817f4daa80a4679c648bbf5552765d8
Abishek1608/Problem-solvjng
/greater 3 no.py
230
4.21875
4
n1=int(input('enter the value')) n2=int(input('enter the value')) n3=int(input('enter the value')) if(n1>n2 and n1>n3): print('n1 is greater') elif(n2>n3 and n2>n1): print('n2 is greater') else: print('n3 is greater')
0e64f375ba3242bbf15631ed705836a9d31ebbb5
evildarkarchon/andys_scripts
/andypy/mood.py
1,015
3.6875
4
import platform from termcolor import colored class Mood: """Class to replace the old Color class that uses static methods instead of string conditionals. Also, because it is using static methods, it no longer requires class instantiation.""" @staticmethod def happy(): """Prints a green sta...
1498e4c75a5180a83310a17cbbc3291e0df4a5ac
evildarkarchon/andys_scripts
/andypy/util/cleanlist.py
1,672
3.5
4
# import itertools import collections from ..mood2 import Mood def flattenlist(l): for el in l: if isinstance(el, collections.Iterable) and not isinstance(el, (str, bytes)): yield from flattenlist(el) else: yield el def cleanlist(iterable, flatten=True, dedup=True, clean=...
93b6cad0cbee34703afbd8b1cf2df297c778b535
preethiN12/Web-Scraper-Project
/Stocks/october8/sortingalgorithim.py
878
3.71875
4
index = [15,23,45,12,4,78,23,56,89,34,21,46,100,32,666,1234,43,4235,2324,7865, 243652, 2626, 6, 2, 3, 1, 23,0] def listsort(index): cpass = 0 while True: ipass = 0 i=0 badcounter=0 while i < len(index)-1: if index[i]>index[i+1]: index[i]+=in...
9458090f3f64913fd43e615c45ac31876e73cc5f
HAS-Tools-Fall2020/homework-alcely
/Submissions/lau_HW4.py
9,054
4
4
# Starter code for Homework 4 # %% # Import the modules we will use import os import numpy as np import pandas as pd import matplotlib.pyplot as plt # %% # ** MODIFY ** # Set the file name and path to where you have stored the data filename = 'streamflow_week4.txt' filepath = os.path.join('C:/Users/alcel/Documents/Gi...
c1aa374f8cb6dca56e0c9ab776a3c7d58847c619
Tiburso/Trabalhos-IST
/FP/IST Capitulo 6.1/IST 6.1.1.py
631
3.75
4
def apenas_numeros_impares_teste(num): if num < 0 or not isinstance(num,int): raise ValueError('argumento invalido') total = '' i = 0 while i < len(str(num)): if int(str(num)[i]) % 2 != 0: total += str(num)[i] i += 1 return int(total) def apenas_num...
23e0a0c300988939a1ebdfcd6205f194cd002793
Tiburso/Trabalhos-IST
/FP/Treino Exame/ex 5.py
228
3.65625
4
def triangular(n): aux = 0 i = 1 if n == 0: return False else: while aux < n: aux += i i += 1 return aux == n def nesimo_triangular(n): #TODO
eca12e994f3ec646790d38bda7c4c6e9cc8d7d52
microease/Python-Tip-Note
/033ok.py
185
3.796875
4
# 给你两个正整数a(0 < a < 100000)和n(0 <= n <=100000000000),计算(a^n) % 20132013并输出结果 a = 10000 n = 1000 #pow()是Python的内建函数 print(pow(a, n, 20132013))
5f98f317d1bdc63a50992b4df19d4b4678a7faa9
microease/Python-Tip-Note
/043ok.py
361
3.53125
4
# 斐波那契数列为1,1,2,3,5,8...。数列从第三项起满足,该项的数是其前面两个数之和。 # 现在给你一个正整数n(n < 10000), 请你求出第n个斐波那契数取模20132013的值(斐波那契数列的编号从1开始)。 l = [1, 1] a = b = 1 while len(l) < n: a, b = b, a + b l.append(b) print(l[n - 1] % 20132013)
30ac3ed98a68aacd0a26a0a9daaa8eec4b8a2233
microease/Python-Tip-Note
/021ok.py
418
3.515625
4
# 给你一个字符串a和一个正整数n,判断a中是否存在长度为n的回文子串。如果存在,则输出YES,否则输出NO。 # 回文串的定义:记串str逆序之后的字符串是str1,若str=str1,则称str是回文串,如"abcba". a = "abcba" n = 2 a1 = a[::-1] flag = "NO" for i in range(0, len(a) - n - 1): s = a[i:i + n] if (s in a1): flag = "YES" break; print(flag)
cf91d56b08c4306e88c8fe0c360b9758616812b4
ChoudhuryIqbal/python
/YardConverter.py
186
3.8125
4
#feet to yard converter def main(): feet=eval(input("Distence in feet please?")) yard=(feet-feet%3)/3; print(yard, "yards", feet%3," feet") main()
31c62be58eac8fd6880680d60fbf60589c925434
parrisem/PythonBasics
/ClassesAndObjects.py
1,486
4.5
4
# objects are an encapsulation of variables and functions into a single entity # objects get their variables and functions from classes # classes are a template to create objects class MyClass: variable = "blah" def function(self): print("This is a message inside the class.") # to assign the class to an objec...
eef0263aa12ba690d5fb7df42fd6105670602d53
parrisem/PythonBasics
/BasicStringOperators.py
3,661
4.5
4
# can be defined as anything between quotes astring = "Hello world!" # can also use single quotes to assign a string astring2 = 'Hello world!' # use double quotes if the string itself uses single quotes print("single quotes are ' '") # prints out 12, because "Hello world!" is 12 characters long, including punctuatio...
e19edaacd26ca545c4e41019ce386a27970cba53
JHuraibi/Python_Assignment_01
/Question_02.py
3,939
3.65625
4
# Author: Jamal Huraibi, fh1328 # Assignment: 1 # Question: 2 class QuadraticHelper: def __init__(self): self.a = None self.b = None self.c = None self.sqComponent = None self.bComponent = None self.most_recent_variable = None self.imaginary_flag = None ...
15ded010033adb144d4581bae07d0b25f4f2d2a4
maclararose/URI
/Python/1011.py
125
3.78125
4
import math raio = float(input()) pi = 3.14159 volume = (4.0/3.0)*pi*(pow(raio, 3)) print('VOLUME = {:.3f}'.format(volume))
2886c4fe93cce081f7499ad3ee3d00c5a3940814
angieramirez1800/Juego-Parab-lico
/parabolic.py
3,499
3.953125
4
# Código modificado # David Damián Galán # Angélica Sofía Ramírez Porras from random import randrange # Importa la función randrange from turtle import * # Importa las fuciones de turtle from freegames import vector # Importa vector ball = vector(-200, -200) # Posición inicial de la bola roja speed = vec...
2891194b417d611a9c76ad9ba08c11872b5bc780
narien/AdventOfCode2017
/day9/9.py
715
3.609375
4
import sys nestingScore = 0 currNesting = 0 inGarbage = False garbageCount = 0 with open(sys.argv[1]) as f: while True: c = f.read(1) if not c: print ("total nesting score: ", nestingScore, " GarbageCount: ", garbageCount) break if c == '!' and inGarbage: ...
fa5d8d6d56cd554d2afdffa5d94655ac4dec99f1
narien/AdventOfCode2017
/day10/10.1.py
849
3.546875
4
import sys currIx = 0 skipSize = 0 myList = list(range(int(sys.argv[2]))) def hash(length): global currIx global skipSize global myList if (currIx + length) > len(myList): reverseList = myList[currIx:] reverseList += myList[:length - len(reverseList)] else: reverseList = m...
29602f7899c9d224ac2c1cffb44f301b961cbf67
geo5555/new_and_init
/new_test2.py
345
3.609375
4
class Animal(object): def __new__(cls): print('__new__() called.') def __init__(self): print('__init__() called') def printName(): print("name") a = Animal() # init is not called # i have not returned an instance of the class a.printName() # AttributeError: 'NoneType' object has ...
ef5cae715a0c27b1110876603e89f36edbb1da17
ahemahem-pythoner/Text-Based-Rock-Paper-Scissors
/VS-Rockpapscissors w input.py
1,550
4.15625
4
#Text based Rock Paper Scissors import random def lineBreaks(): print("---") print("Welcome to Text Based Rock Paper Scissors") lineBreaks() print("To start off , enter your name below") lineBreaks() #Input Player Name player1 = input("Please Enter your name ---Player 1 is : ") lineBreaks() player2...
4bf4afcad58e7475936ce3327ef8d3bdd0dec400
david1mdavis/sam3s-demo-source
/ sam3s-demo-source --username kaiser.ren@gmail.com/python/learning_python_the_hard_way/ex8.py
428
4.0625
4
#Exercise 8: Printing, Printing format = "%r%r%r%r" print (format % (1, 2, 3, 4)) print (format % ('one', 'two', 'three','four')) print (format % (True, False, True, False)) print (format % (format, format, format, format)) print (format % ( "I had this thing.", 'That you could type up right.', '...
353c49b229c0222e35bb1a2efb7c481068a28713
david1mdavis/sam3s-demo-source
/ sam3s-demo-source --username kaiser.ren@gmail.com/python/learning_python_the_hard_way/ex24.py
948
3.859375
4
#Exercise 24: More Practice print ("Let us practice everything.") print ("you'd need to know 'bout escaptes with \\ that do \n newlines and \t tabs.") poem = """ \tThe lovely world with logic so firmly planted can't discern \n the needs of love nor comprehend passion from intuition and requires an explanati...
c3ac4de367bbc028d544f29ba2c475a70572f7d8
gddickinson/python_code
/BSU/datetimeAsNumber 2.py
206
3.625
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 6 16:36:09 2020 @author: GEORGEDICKINSON """ from datetime import date date_string = '2015-01-30' now = date(*map(int, date_string.split('-'))) print(now)
5d1af1198a05fda5be1f37f01be18a19c241d969
gddickinson/python_code
/stanford_cs106b/powerSet.py
1,146
4
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 9 10:46:06 2015 @author: george """ # generate all combinations of N items def powerSet(items): N = len(items) # enumerate the 2**N possible combinations for i in xrange(2**N): combo = [] for j in xrange(N): # test bit jth of inte...
72ff90d9fb635e27d6e62c92bf469a66cacec794
gddickinson/python_code
/code1/Code_solutions/gdcIter.py
428
3.625
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 27 11:09:26 2015 @author: george """ def gdcIter(a,b): if a > b: c = b b = a a = c if a == b: return a testValue = a for testValue in range(a,0,-1): if a%testValue == 0 and b%testValue == 0: ...
0227464a60ec7a26ebe4a1f9bbd65a616adc43e4
gddickinson/python_code
/udacity/artificialIntelligenceForRobots/search1 2.py
2,889
3.671875
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ # ---------- # User Instructions: # # Define a function, search() that returns a list # in the form of [optimal path length, row, col]. For # the grid shown below, your function should output # [11, 4, 5]. # # If there is no valid path fr...
3995ed51825b09e0b3e7e4c89c0d0ce1538b7502
gddickinson/python_code
/code1/Code_solutions/gcdRecur.py
221
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 27 12:50:19 2015 @author: george """ def gcdRecur(a,b): if b == 0: return a else: return gcdRecur(b, a%b) print (gcdRecur(17,12))
b4e7ba34ff95f29e7d5fcf562cf1b9197bdc67e5
gddickinson/python_code
/st_coding_1/Code_solutions/isSubset.py
413
3.703125
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 18 11:49:45 2015 @author: george """ def isSubset(L1, L2): for e1 in L1: matched = False for e2 in L2: if e1 == e2: matched = True break if not matched: return False return True #Dem...
9ee8e569eee4a35375eb1145baf89856921ec451
gddickinson/python_code
/code1/Code_solutions/isWordGuessed 2.py
893
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 30 21:11:27 2015 @author: george """ def isWordGuessed(secretWord, lettersGuessed): def testLetter (letter, lettersGuessed): i = (len(lettersGuessed))-1 while i >= 0: if letter == lettersGuessed[i]: return True ...
06b8e7b6cc5ee1c09a4b883af0113e7c01f6c992
gddickinson/python_code
/st_coding_1/Code_solutions/numberGuess 2.py
666
4.09375
4
print ("Please think of a number between 0 and 100!") x = 100 ans = 0 low = 0 high = x ans = (high + low)/2 user_input = '' while user_input != 'c': print ("Is your secret number " + str(ans) + "?"), user_input = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is to...
2ef2d8cc5e650a7a5dc8bd66ab9a8edc2591a66d
gddickinson/python_code
/st_coding_1/Code_solutions/lenIter_str.py
223
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 27 14:13:15 2015 @author: george """ def lenIter(aStr): ans = 0 while aStr != "": ans +=1 aStr = aStr[1:] return ans print (lenIter(""))
bcb3822d3f8c4f925f0b0fbfe20425d0bcb0f792
gddickinson/python_code
/udacity/artificialIntelligenceForRobots/project/kalmanTest2 2.py
3,445
3.546875
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 18 14:52:51 2016 @author: george """ from robot import * from math import * from matrix import * import random import matplotlib.pyplot as plt import numpy as np def kalman_xy(x, P, measurement, R, motion = matrix([[0., 0., 0., 0.]]).transpose, Q = matrix([[1., 0.,0.,0....
e03fd3512a81db86713841028fc3c13749239f4d
felipero/practice
/project_euler/1.py
166
3.875
4
# Multiples of 3 and 5 multiples_sum = 3 n = 1000 for num in range(4, n): if (not num % 3) or (not num % 5): multiples_sum += num print(multiples_sum)
3e5205cc011ad06215bd4ad85d37520c32f8400f
tiwariaanchal/Python_490
/ICP2/pythonclass2.py
266
3.921875
4
n = int(input("How many students are there?")) weights_in_lbs = [] weights_in_kgs = [] for i in range(n): x = float(input("Enter the weight")) weights_in_lbs.append(x) x = x * 0.453 weights_in_kgs.append(x) print(weights_in_lbs) print(weights_in_kgs)
48ade0a798e980c1f338c0122d5b2f0c26933ec2
beardedherring/edu
/lesson1easy3.py
322
4.09375
4
age = int(input('Введите ваш возраст: ')) if age >= 25: print ('Наш мальчик уже взрослый совсем!') elif age >= 18: print('Доступ разрешен') else: print('Извините, пользование данным ресурсом только с 18 лет')
843e6304bbdbebad0ebbd0990d4d58b33ba11921
l4es/semiteleporter
/research/triangulation_4/douglaspeucker.py
3,068
3.890625
4
import numpy as np def distance(d1, d2, p): """ Return the distance between a line determined by points d1 and d2, and a point p """ u = d2-d1 v = p-d1 return np.linalg.norm(np.cross(u, v))/np.linalg.norm(u) def douglas_peucker(points, thres, min=0, max=-1): """ Apply douglas peuc...
020840d45c974b5e241a20f89d9fedc26dde6b84
jamessuttonjr/OOP-HW
/dictionaryhw.py
591
3.96875
4
coursenumbers = {"CS101":["3004", "Haynes", "8:00a.m."], "CS102":["4501", "Alvarado", "9:00a.m."], "CS103":["6755", "Rich", "10:00a.m."], "NT110":["1244", "Burke", "11:00a.m"], "CM241":["1411", "Lee", "1:00p.m."]} coursechoice = input("Please enter a...
71651b37e5fb571f6652e2144093f7ec815977e1
cosiq/codingChallenges
/Leetcode/SingleNumber.py
437
3.875
4
# Given a non-empty array of integers, every element appears twice except for one. # Find that single one. # Note: # Your algorithm should have a linear runtime complexity. # Could you implement it without using extra memory? # Example 1: # Input: [2,2,1] # Output: 1 # Example 2: # Input: [4,1,2,1,2] # Output: ...
024b9b041fedd1ecdc89f4535592829d4344a2a5
cosiq/codingChallenges
/Leetcode/ClimbingStairs.py
847
3.96875
4
# You are climbing a stair case. It takes n steps to reach to the top. # Each time you can either climb 1 or 2 steps. # In how many distinct ways can you climb to the top? # Note: Given n will be a positive integer. # Example 1: # Input: 2 # Output: 2 # Explanation: There are two ways to climb to the top. # 1. 1 st...
aff6d0d6028beb0d4099a10e02029d613cc1351e
cosiq/codingChallenges
/Leetcode/PathSum2.py
1,650
3.609375
4
# Given a binary tree and a sum, find all root-to-leaf paths # where each path's sum equals the given sum. # Example: # Given the below binary tree and sum = 22, # 5 # / \ # 4 8 # / / \ # 11 13 4 # / \ / \ # 7 2 5 1 Return: [[5,4,11,2], [5,8,4,5]] class TreeNode: def __init_...
3d60bdd9cc6fffefae3c8a1a8c213fe44fb7f411
cosiq/codingChallenges
/Hackerrank/leftRotation.py
899
4.3125
4
# A left rotation operation on an array of size n # shifts each of the array's elements 1 unit to the left. # For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5] # then the array would become [3, 4, 5, 1, 2] # Given an array of n integers and a number d, perform d left roattions on the array. # The...
ebd2906f7c1fd2f348ca8428e081adf3dddec0ba
cosiq/codingChallenges
/Codility/PermCheck.py
379
3.578125
4
# Write a function that, given an array A, returns 1 # if array A is a permutation and 0 if it is not. # For example, given array A such that: # A[0] = 4 A[1] = 1 A[2] = 3 A[3] = 2 # the function should return 1. def permCheck(A): lenLst, lenSet = len(A), len(set(A)) if lenLst != lenSet: return 0 retu...
3957038560de40849926f31dc45c05eab37ba204
cosiq/codingChallenges
/Codility/MissingInteger.py
644
3.828125
4
# Write a function that, given an array A of N integers, # returns the smallest positive integer (greater than 0) that does not occur in A. # For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. # Given A = [1, 2, 3], the function should return 4. # Given A = [−1, −3], the function should return 1....
70bfee4d40f8bb61a86f31b2fe06f34157deccd5
cesargasca/SensorTemperatura
/Interface.py
1,837
3.5625
4
from arduinoiface import Reader import matplotlib.pyplot as plt import numpy as np # use ggplot style for more sophisticated visuals plt.style.use('ggplot') azul = (.13,.7,.185) azul_claro = (.14,.167,.255) amarillo = (.232,.255,.14) def live_plotter(x_vec,y1_data,line1,identifier='',pause_time=0.1): if line1=...
95c7f0a8ea1817731ff5d611c04618a8962fc894
achaika80/Python
/Learning/CreditCards/CreditCard_db.py
5,216
3.53125
4
from random import randint import sqlite3 class CreditCard: iin = "400000" db_connection = sqlite3.connect('./card.s3db') def __init__(self): self.cur = CreditCard.create_db_and_table() self.card = dict() self.card['iin'] = CreditCard.iin self.card['account_number'] = self.g...
3a17068cfacd7206716f45e7f7cbda278756f4d9
dacre/stefansAdventureGame3
/start.py
274
3.5625
4
johannes = "mentor" #print("hello world "+johannes) #startmeny typ name = input('Please tell me you name') def play(): alive = True while alive: print("you will die "+name) alive = False if __name__ == "__main__": play()
3cbc08ba78894ba53982e15ff56c1dead819f76e
melission/Timus.ru
/1100_memory_limit.py
1,037
3.640625
4
# https://acm.timus.ru/problem.aspx?space=1&num=1100 # ru: https://habr.com/ru/post/455722/ # eng: https://habr.com/ru/post/458518/ import sys itemcount = int(input().strip()) toSortList = [] for i in range(itemcount): str_lst = input().strip().split() # print(len(str_lst)) str_lst[1] = int(str_lst[1]) ...
f5c86a508dfb8e62e73cda80577ee2017edd90dc
melission/Timus.ru
/1001.py
378
3.546875
4
from math import sqrt import sys # nums = input() # print(nums) num_lst = [] for line in sys.stdin: for item in line.split(): num_lst.append(item) out_lst = [] for item in num_lst: root = sqrt(float(item)) root = float('{:.4f}'.format(root)) out_lst.append(root) out_lst.reverse(...
a266a2acf6204cf56c4bf68448bde3c2a88508b8
kampae/sceniccomps
/create_grid_coords.py
3,988
3.515625
4
# A function that takes in an array of two coordinates, our start and end coordinates # for our route. It creates a square based off our coordinates, increasing latitude values # by 0.009 degree increments, and increasing longitudes by increments of (1/111.111*cos(lat)). # These increments represent an increase ...
097bb34570704f75dbad0bead966ee975144b5b7
LeonidShai/origins
/Tasks/a0_my_stack.py
1,267
4.34375
4
""" My little Stack """ from typing import Any stack = [] #переменная стек def push(elem: Any) -> None: """ Operation that add element to stack :param elem: element to be pushed :return: Nothing """ print("Add element {} in stack".format(elem)) global stack stack.append(elem) return None def pop() -> An...
12b88a78737a2dc380e9ea9b9358b953d5277b4c
LeonidShai/origins
/Tasks/a3_check_brackets.py
471
4.28125
4
def check_brackets(brackets_row: str) -> bool: """ Check whether input string is a valid bracket sequence Valid examples: "", "()", "()()(()())", invalid: "(", ")", ")(" :param brackets_row: input string to be checked :return: True if valid, False otherwise """ open_skobka = brackets_row.count("(") close_skobk...
252e0a774e808e9eb7e56db2fc0724e58bef1e9c
krislidimo/Intro-Python-II
/src/adv.py
3,297
4
4
from room import Room # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room("Foyer", "Dim light filters in from the south. Dusty passages run north and east."), 'overlook': Room("Grand Overlook", "A steep cliff appears before y...
de240aa26fe24abee757a07eb082a827be9cb558
silvioedu/GFG-Practice
/arrays/rotateArray.py
332
3.65625
4
# Problem: https://practice.geeksforgeeks.org/problems/rotate-array-by-n-elements/0 if __name__ == '__main__': for _ in range(int(input())): n, d = map(int, input().split()) arr = list(map(int, input().split())) arr = arr[d:] + arr[:d] [print(arr[i], end=" ") for i in range(n)] ...
c8486c966293d58c0326ef33898868f6a2ac7cf1
JoshuaMa64/EulerProject
/EP013.py
273
3.75
4
""" Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. """ import fileinput def main(): nums = 0 for line in fileinput.input("EP013data.txt"): nums += int(line) print(nums) if __name__ == '__main__': main()
9f5cfa86ea16e858425aa37751f564c9dd82f882
JoshuaMa64/EulerProject
/EP006.py
125
3.546875
4
sum1 = 0 sum2 = 0 for i in range(101): sum1 += i**2 for i in range(101): sum2 += i sum2 = sum2**2 print(sum2 - sum1)
9b9bfb08d5361aafa6723e6f21f24f1dbfbaab40
MikeBoyd16/merchant
/src/item.py
617
3.59375
4
""" """ import json with open('data/item_data.json') as data_file: item_data = json.load(data_file) class Item: def __init__(self, item_id): self.id = item_id self.name = item_data[self.id]["name"] self.type = item_data[self.id]["type"] self.base_value = item_data[self.id]["ba...
33f2c9e8001c80bbd9074cf58c5a315afadd2016
Daeryss/python-theory
/String.py
3,276
4.0625
4
# строки в питон воспринимаются целым неделимым объектом # строку нельзя разделить или вычесть из нее, но можно сложить: s1 = 'abc' s2 = 'def' print('1. ', s1 + s2) # s1 + s2 = 'abcdef' # или строку можно умножить: print('2. ', s1 * 3) # результатом будет: # s1 * 3 = 'abcabcabc...
18c8597daf0dc62885c06576c120420079b9ab57
andreshp/hash-code-2017
/Problem/solution.py
3,312
3.671875
4
import time import os #### NOTA: ASEGURARSE DE QUE EXISTA EL DIRECTORIO solutions class AbstractSolution: def readInput(self, fname): """ Saves the name of the input file then calls the parse funcion. """ self.fname=fname.replace('.in','') self.parseFile(fname) def parseFile(self, fnam...
67668fb6f195af5cf7aa6f9c6e342a20727802bc
farahsamat/payroll
/test_payroll.py
1,789
3.84375
4
import unittest from payroll import EmployeeDetails class PayrollTest(unittest.TestCase): def test_print_correct_user_input(self): emp = EmployeeDetails('John', 'Doe', 10000, 9) self.assertEqual(emp.first_name, 'John') self.assertEqual(emp.last_name, 'Doe') self.assertEqual(emp.annu...
f8f398a38db76e5711d4b11fbd7b508d3215b5bd
KAPANDAs/check-qr-code-gen
/src/interface.py
921
3.515625
4
import tkinter from tkinter import Tk from tkinter import Button from tkinter import Label from tkinter import Entry class UserInterface: """ User interface class """ def __init__(self): """ Initialisation of user interface """ self.window = Tk() self.window.ti...
8fec06a023671646b76906922c3015e9d9336c70
jesslynparrish/DIG5508
/Final Project/Final_5508.pyde
2,700
4
4
#Goal is to create a function so that when the mouse is clicked a rectangle is placed at the mouse's position class holidayLight(object): def __init__(self, c, xpos, ypos, xspeed): self.c = c self.xpos = xpos self.ypos = ypos self.xspeed = xspeed def display(self): ...
b42f2510ca5b4cbc8a512ba21e6682f0f11d0d7d
kv9c12/Machine-Learning
/Machine Learning/Linear Regression/Linear regression using y=mx+c.py
2,544
3.84375
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 19 18:50:34 2019 @author: Kv9c12 Linear Regression Model : -> using sample self-created data for 2D -> using y = mx+b for generating the regression line - slope(m) = ( (mean(x_coordinate) * mean(y_coordinate) - mean(x_coordinate*y_coordinate)) / ...
676faaa87d7a2d83325b91cf52ef03f74bb373e3
nicket97/DAT255
/moped/SafetyLength/SafetyLength.py
559
3.828125
4
#Stops immediately if something is to close, IF ACC IS NOT ACTIVE? #Simple stop method def simpleSafety(speed, fsensor): extraSafety = 10 #Extra safety in cm sDistanceM =(((0.0070970262*(speed*speed))+(0.23482713*speed)+0.53924471) + extraSafety)/100 print ("sDistance " + str(sDistanceM)) ...
4b2f94364899fd61246cbed426666aacd664cfef
ed-ortizm/L-G-opt
/annealing/test_annealing.py
2,608
3.609375
4
#!/usr/bin/env python3 import sys from annealing import * ## Initial parameters for the annealing # n: number of steps, also length of the chain n = int(sys.argv[1]) # m: number of microstates visited to ensure thermalization m = int(sys.argv[2]) # Number of starting points p = int(sys.argv[3]) # convergence criteria ...
2f5cebc1456b416b5ad214ca30034c606989287c
SD170720000/SubhuPythonCode
/WeekNo.py
127
3.671875
4
# (11.) Write a Python program to get a week number. import datetime print(datetime.date(2015,6,16).isocalendar()[1])
f2af05e1d77224e45488d379da1cf517adc4cd5d
skols/realpython-sql
/10_sql.py
539
4.09375
4
# JOINing data from multiple tables # import the sqlite3 library import sqlite3 with sqlite3.connect("new.db") as connection: c = connection.cursor() # retrieve data c.execute("""SELECT DISTINCT p.city, p.population, r.region FROM population AS p INNER JOIN regions AS r ON p.city=r.city ...
26447f4fc89a59b6a7d15be3d8208374f1a94ddb
razeena-naaz99/Book-Rental-System
/bookrental.py
7,403
4.03125
4
class BookRentalSystem(): def __init__(self,list_of_books,Bookstore_name): # creating a dictionary of all books keys self.sum=0 self.rent_data = {} self.list_of_books = list_of_books self.Bookstore_name = Bookstore_name self.return_list={} self.offer=N...
56b8f6ba604b64d65b722974c48cae2079038abd
prasanthkc777/CooperTraining_daily_Tasks
/day1/Detect_capital.py
241
4.15625
4
word=str(input()) if word.istitle() == True : print("true") elif all([True if i.islower() else False for i in word ])==True or all([True if i.isupper() else False for i in word ])==True : print ("true") else: print("false")
d7d413862e735e3d8cdd8508a3a86a838f7ecac2
smcleod86/Python-Geocoder
/solutions/solution.py
875
3.59375
4
import geocoder import requests # declare destinations list destinations = ['Space Needle', 'Crater Lake', 'Golden Gate Bridge', 'Yosemite National Park', 'Las Vegas, Nevada', 'Grand Canyon National Park', 'Aspen, Colorado', 'Mount Rushmore', 'Yellowstone National Park', 'Sandpoint, Idaho', 'Banff ...
9bab9a5b9844b366b5b070dfd9360097bf0ed2c4
ViFLara/Python-Course
/Python-Classes/class8.py
1,536
3.546875
4
from datetime import date, time, datetime, timedelta def working_with_datetime(): current_date = datetime.now() print(current_date) print(current_date.strftime('%d/%m/%Y %H:%M:%S')) print(current_date.strftime('%c')) print(current_date.day) print(current_date.date()) tuple = ('Montag', 'Di...
dc74368b3e706a8ba06630d7487480bda67b6f2e
alanhlwang/NBA_analysis
/Basketball_Reference_scraper.py
1,155
3.546875
4
#!/usr/local/bin/python3 -tt """ Program to scrape NBA player data from https://www.basketball-reference.com/. Author: Gordon Lim Last Edit: 2 May 2018 """ import NBAanalysissetup import sys def main(): firstyear = 1980 if (len(sys.argv) > 1): firstyear_str = sys.argv[1] firstyear = int(fir...
00f0af937b6a51776634f0d9ffe56fff57493879
fdl66/LearnByCoding
/python/python/count_appear_times.py
779
4.0625
4
#!/usr/bin/env python #coding=utf-8 #使用不同的办法来统计列表中对象的出现次数。 import collections global_list = [1,2,3,4,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,3,4,4,4] print '利用list.count()方法。\n' def way1(): list1 = set(global_list) #list1是另外一个列表,里面的内容是global_list里面的无重复项. for item in list1: print item,'出现了',global_list.count(item),'...
45a0d80043e862cb7d306dfc5e940636bd99f815
yohei-washizaki/perlin
/unitvec.py
836
3.796875
4
#!/usr/bin/env python3 import math class UnitVectors: """List of unit vectors""" def __init__(self, vectors): self.vectors = vectors def __getitem__(self, k): return self.vectors[k % len(self.vectors)] @staticmethod def Create(count=8): step = 360.0 / count unit_v...
6acb9ca919926ac8109f85de679c5688f5ba30ac
moogzy/pynet
/class2/c2-e4.py
709
3.734375
4
#!/usr/bin/python """ PyNet - Python for Network Engineers Class 2 - Exercise 4 Author: Adrian Arumugam Date: 04/07/2014 """ # String variable from Cisco. cisco_ios = "Cisco IOS Software, C880 Software (C880DATA-UNIVERSALK9-M), Version 15.0(1)M4, RELEASE SOFTWARE (fc1)" # Split the string to creat...
24193318c79b1bc4dfb40baf40f9ae41a6cde8f4
LizAitken/DictionaryExercises
/ver2_letter_summary.py
431
3.90625
4
#Letter Summary - Dictionary Exercise version 2- Will do the same thing as Letter Summary without importing functions. user_input = str(input("Please enter a word: ")) dict = {} def letter_histogram(user_input, dict): count = 1 for letter in user_input: if letter in dict: dict[letter] += co...
5b9c638728dfb5df33abafe5687456556b3ea3d5
ParkerCS/ch00-loops-functions-cmoog
/ch00_problem_set(LOOPS).py
3,188
4.21875
4
# LOOPS (22pts TOTAL) import random # PROBLEM 1 (Fibonacci - 4pts) ## The Fibonacci sequence is a sequence of numbers that starts with 1, followed by 1 again. # Every next number is the sum of the two previous numbers. # I.e., the sequence starts with 1, 1, 2, 3, 5, 8, 13, 21,... # Write a program that calculates and ...
4a0c0994f418cb74df04ad9b21e7b03e02b6be7f
eslamif/Networking---FTP-program
/ftclient.py
4,511
3.703125
4
#Frank Eslami, CS 372, Project 2 #ftclient #A simple file transfer system between a server and client. This is the client application. #The following Python socket networking guide was used as reference: #http://www.binarytides.com/code-chat-application-server-client-sockets-python/ import socket, select, string, sy...
38e0546fb2972456445695b7375a316abc5a77db
armindocachada/yeelightweather
/files/Yeelight.py
5,085
3.65625
4
# minimum percentage at which point we consider it is quite likely # to rain probabilityOfPrecipitationThreshold= 50 probabilityOfHeavyRainThreshold = 50 ProbabilityOfHeavySnowThreshold = 50 # weather is freezing if minTemperature is below 0 # weather is cold if minTemperature > 0 and below 10 # weather is fair if m...
5f991e2cfb6561271d45811436991fb8d5f100f5
niwgnip/Notepad
/notepad.py
2,420
3.5
4
from tkinter import * from tkinter import scrolledtext, Menu, Tk, BOTH, filedialog, END from tkinter.ttk import Frame import os class Example(Frame): def __init__(self): super().__init__() self.initUI() def newfile(): pass # def openfile(): # filename = filedialog.askopenfilename(parent=self.master) ...
c206225a40c64fb66130768ba34591d6533c687d
quaner2557/ML_python
/pythontry/debug.py
692
3.6875
4
############################################################################ # assert # assert的意思是,表达式n != 0应该是True,否则,根据程序运行的逻辑,后面的代码肯定会出错 # 如果断言失败,assert语句本身就会抛出AssertionError def foo(s): n = int(s) assert n != 0, 'n is zero!' return 10/n def main(): foo('0') ########################################...
ac92a1208ae12074a09c4160a6cdd8c2e4ccabb4
a1nouru/iSDC-Implement-Matrix-Class
/matrix.py
6,943
4.0625
4
import math from math import sqrt import numbers def zeroes(height, width): """ Creates a matrix of zeroes. """ g = [[0.0 for _ in range(width)] for __ in range(height)] return Matrix(g) def identity(n): """ Creates a n x n identity matrix. """ I...
250ea48461ef69bde59f0af0c8b4c5ce1bf433e9
cclaude42/python_bootcamp
/day01/ex00/test.py
858
3.8125
4
#!/usr/bin/env python3 """ Book and recipe tests """ from recipe import Recipe from book import Book if __name__ == '__main__': # Create Recipe : listy = ['Pate', 'Saumon', 'Epinard'] tourte = Recipe("Tourte", 3, 20, listy, "", "lunch") # Create second Recipe : listy = ['Miel', 'Banane', 'Yaourt...
8425522ce82d81f55bea6ae207e28101f264804f
cclaude42/python_bootcamp
/day00/ex07/filterwords.py
542
4.125
4
#!/usr/bin/env python3 import sys import string if (len(sys.argv) == 3): try: length = int(sys.argv[2]) except ValueError: print("Invalid length parameter.") sys.exit() elif (len(sys.argv) < 3): print("Too few arguments.") sys.exit() elif (len(sys.argv) > 3): print("Too man...
ef2cd2e07328db85d1f14de7e85867ba2a6a1642
yernende/university
/roots/algorithms/chord.py
730
3.640625
4
def refine_root(compute_function, limits, digits): (a, b) = limits epsilon = 1 / 10 ** digits i = 0 while True: if i == 0: i += 1 elif i == 1: x_previous = x i += 1 elif i == 2: if abs(x - x_previous) < epsilon: ret...
7796161b4fa7b36d9ecea790e3bc555a5b10a137
Sedatif/db_cw
/src/prediction.py
1,555
3.546875
4
import matplotlib.pyplot as plt import numpy as np import database from data_science import load_data_frame, linear_model db = database.get_collection() df = load_data_frame(db) units = {'ram': 'GB', 'memory': 'GB', 'cpu_frequency': 'GHz', 'camera': 'mpixels', 'diagonal': 'inch', 'battery': 'mAh'} def regression(pr...
2051551032f75bf87deef3e5a099bf17bcdf663d
brev1sest/tic-tac-toe
/tic-tac-toe.py
3,806
4.03125
4
from random import choice board = [ "1","2","3", "4","5","6", "7","8","9"] current_player = "X" def display_board(): print(board[0]+" | " +board[1] + " | " + board[2]) print("-" *2+"|"+"-" *3+"|"+"-" *2) print(board[3]+" | " +board[4] + " | " + board[5]) print("-" *2...
6570ec254e6df02cd65ada508c009ce8c9027fc8
akshunive/My-sanddunes
/alphabetical.py
142
3.9375
4
#to sort the given set of strings in alplabetical order language=raw_input("enter the strings:") a=[] a.append(list(language)) print sorted(a)
74cc574f8e89d21dfe98536c9d72448d4de3de28
akshunive/My-sanddunes
/classes2.py
598
4.15625
4
'''5.Define a class which has at least two methods: getString: to get a string from console input printString: to print the string in upper case. Also please include simple test function to test the class methods.''' class Sample: def __init__(self): #constructor print "constructor is being executed" def g...
c4369a3df063dc607c93ebdc94b55101b363bda7
akshunive/My-sanddunes
/func.py
117
3.90625
4
a=input("enter a no:") b=input("enter a no:") def add(a,b): '''addition of two numbers''' print a+b add(a,b)
ba2559c6d29860e5f98be17fde544d94691919b3
noobt-tt/problems
/剑指offer/对称的二叉树.py
567
3.96875
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSymmetrical(self, pRoot): # write code here if not pRoot: return True return self.helper(pRoot.left, pRoot.right) def ...
54a5dba419ba418c03ff24c97b1ef902583e9e7c
noobt-tt/problems
/剑指offer/把数组排成最小的数.py
283
3.71875
4
# -*- coding:utf-8 -*- class Solution: def PrintMinNumber(self, numbers): # write code here if not numbers: return "" numbers = list(map(str, numbers)) numbers.sort(cmp = lambda x,y:cmp(x+y, y+x)) return "".join(numbers).lstrip("0") or "0"
b50815dd8dd2c38f9ad1dc29e14c2956e5b0b1fc
noobt-tt/problems
/剑指offer/从1到n中1出现的次数.py
301
3.546875
4
# -*- coding:utf-8 -*- class Solution: def NumberOf1Between1AndN_Solution(self, n): # write code here count, m = 0, 1 while m <= n: a = n//m b = n%m count += (a+8)//10*m + (a%10==1)*(b+1) m *= 10 return count
3d8a14ba213c47ece6dc0e6fd2c00c7f20c59160
KunChangLee/Sherpa.ai-Federated-Learning-Framework
/shfl/data_base/data_base.py
3,384
3.65625
4
import abc import numpy as np def split_train_test(data, labels, dim): """ Method that randomly choose the train and test sets from data and labels. # Arguments: data: Numpy matrix with data for extract the validation data labels: Numpy array with labels dim: Size for validation d...
2e937535faa3b1a1c4f32e0201aea6f16435a1c4
mlgiaime/KalAcademyPython
/Variable.py
165
4.125
4
def increment(x): x = x + 1 print("After increment the value is ", x) n = 10 print("Before increment ", n) increment(n) print("The new value of n is ", n)
86d94e10541b4c11c61ff87840e31f3376b01c91
sarbi127/Python
/sequence.py
4,678
4
4
# This file contains a class declaration. # I have included the initializer and an example method to help you. # You will need to add the other methods yourself. import matplotlib.pyplot as plt class Sequence: # This method is the initializer, it is called when creating (instantiating) an object (instance) of thi...
ceeed26582d70f63594a7beb7d5134d80bd0bbe3
dlee533/comp1510-programming-methods
/Assignments/A3/board.py
855
3.96875
4
def make_board() -> list: """Create a 5x5 board :postcondition: create a list with coordinate for 5x5 board :postcondition: assign the character to (0, 0) coordinate :return: the list """ coordinates = [(x, y) for x in range(5) for y in range(5)] return coordinates def print_board(charact...